30 #include <sys/ioctl.h>
31 #include <sys/soundcard.h>
40 const char *audio_device)
45 char *
flip = getenv(
"AUDIO_FLIP_LEFT");
62 if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
69 #define CHECK_IOCTL_ERROR(event) \
71 av_log(s1, AV_LOG_ERROR, #event ": %s\n", av_err2str(AVERROR(errno)));\
79 err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &
tmp);
85 if (
tmp & AFMT_S16_BE) {
87 }
else if (
tmp & AFMT_S16_LE) {
93 if (
tmp & AFMT_S16_LE) {
95 }
else if (
tmp & AFMT_S16_BE) {
114 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &
tmp);
117 tmp = (
s->channels == 2);
118 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &
tmp);
121 tmp =
s->sample_rate;
122 err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &
tmp);
124 s->sample_rate =
tmp;
131 #undef CHECK_IOCTL_ERROR