[英]Streaming audio file in C on linux
I have a .au audio file and am reading it in parts using fread. 我有一个.au音频文件,正在使用fread进行部分读取。 However when i write this to /dev/audio there is no sound being played.
但是,当我将其写入/ dev / audio时,没有声音在播放。 Do I need to do something or is the system supposed to play back as soon as I write to /dev/audio.
我需要做些什么还是应该在我写入/ dev / audio后立即播放系统。 I am not getting any errors.
我没有任何错误。
player = open("/dev/audio", O_WRONLY, 0);
if (player < 0)
{
perror("Opening /dev/audio failed\n");
exit(1);
}
while(1)
{
//code to read from the file writes to buf 1000 bytes per read
//fread(buf,1000, 1, audioFile); //server side
write(player, buf, 1000);
}
The issue seems to be with Ubuntu. 问题似乎与Ubuntu有关。 I tried the same on a Gentoo installation in my lab and the sound can be heard
我在实验室的Gentoo安装上尝试了同样的方法,并且可以听到声音
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.