aix kill java,播放madplay实例——kill 使用的几种情况 (转载)

此处用了一个播放madplay的应用程序作为记录。里面有几个地方用到了kill,分别来进行播放音乐进程的开始、暂停、停止等操作:

#include #include #include #include #include #include #include

int main()

{

char ch;

int MIX_FD;

int iLeft = 60;

int iRight = 20;

int iLevel;

MIX_FD= open("/dev/mixer", O_WRONLY);

if (MIX_FD == -1)

{

perror("Error:open /dev/mixer error");

exit(1);

}

printf ("[a] Play \n");

printf ("[b] Pause \n");

printf ("[c] Resume\n");

printf ("[d] stop \n");

printf ("[+] Up Vol\n");

printf ("[-] Down Vol\n");

printf ("[e] Exit \n");

while(1)

{

printf("Please enter your choice: ");

scanf("%c",&ch);

printf("\n");

switch (ch)

{

case '+':

{

if(iLeft<100)

iLeft += 5;

iLevel = (iRight << 8) + iLeft;

ioctl(MIX_FD, MIXER_WRITE(SOUND_MIXER_VOLUME), &iLevel);

}

break;

case '-':

{

if(iLeft>20)

iLeft -= 5;

iLevel = (iRight << 8) + iLeft;

ioctl(MIX_FD, MIXER_WRITE(SOUND_MIXER_VOLUME), &iLevel);

}

break;

case 'a':

{

iLevel = (iRight << 8) + iLeft;

ioctl(MIX_FD, MIXER_WRITE(SOUND_MIXER_VOLUME), &iLevel);

system("./madplay /tmp/p.mp3 &");          //利用system函数调用madplay播放器播放*.mp3音乐

}

break;

case 'b':

{

system("killall -STOP madplay &");         //利用system函数调用killall命令将madplay暂停

}

break;

case 'c':

{

system("killall -CONT madplay &");         //利用system函数调用killall命令恢复madplay的播放

}

break;

case 'd':

{

system("killall -9 madplay");           //利用system函数调用killall命令将madplay终止掉

}

break;

case 'e':

{

goto exit;

}

}

}

exit: return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值