13 #include "libmythbase/mythconfig.h"
20 #define LOC QString("AOOSS: ")
53 while (
int rate = settings->GetNextRate())
56 if(ioctl(
m_audioFd, SNDCTL_DSP_SPEED, &rate2) >= 0
58 settings->AddSupportedRate(rate);
62 VBERRENO(
"Error retrieving formats");
67 int ofmt = AFMT_QUERY;
77 settings->AddSupportedFormat(fmt);
83 settings->setPassthrough(
static_cast<int>((
formats & AFMT_AC3) != 0) - 1);
86 for (
int i = 1; i <= 2; i++)
90 if (ioctl(
m_audioFd, SNDCTL_DSP_CHANNELS, &channel) >= 0 &&
93 settings->AddSupportedChannels(i);
115 m_audioFd = open(device.constData(), O_WRONLY);
116 if (
m_audioFd < 0 && errno != EAGAIN && errno != EINTR)
120 VBWARN(QString(
"Something is currently using: %1.")
124 VBERRENO(QString(
"Error opening audio device (%1)")
141 VBERRENO(QString(
"Error removing the O_NONBLOCK flag from audio device FD (%1)").arg(
m_mainDevice));
145 int format = AFMT_QUERY;
158 #if defined(AFMT_AC3) && defined(SNDCTL_DSP_GETFMTS)
161 int format_support = 0;
162 if (!ioctl(
m_audioFd, SNDCTL_DSP_GETFMTS, &format_support) &&
163 (format_support & AFMT_AC3))
174 ioctl(
m_audioFd, SNDCTL_DSP_SETFMT, &format) < 0)
180 if (ioctl(
m_audioFd, SNDCTL_DSP_STEREO, &stereo) < 0 ||
182 ioctl(
m_audioFd, SNDCTL_DSP_SETFMT, &format) < 0)
188 VBERRENO(QString(
"Unable to set audio device (%1) to %2 kHz, %3 bits, "
201 VBERRENO(
"Error retrieving card buffer size");
209 if (ioctl(
m_audioFd, SNDCTL_DSP_GETCAPS, &caps) == 0)
211 if (!(caps & DSP_CAP_REALTIME))
212 VBWARN(
"The audio device cannot report buffer state "
213 "accurately! audio/video sync will be bad, continuing...");
217 VBERRENO(
"Unable to get audio card capabilities");
247 uchar *tmpbuf = aubuf;
249 while ((written < size) &&
258 VBERRENO(QString(
"Error writing to audio device (%1)")
267 int soundcard_buffer=0;
269 #ifdef SNDCTL_DSP_GETODELAY
270 if(ioctl(
m_audioFd, SNDCTL_DSP_GETODELAY, &soundcard_buffer) < 0)
273 return soundcard_buffer;
281 if (device.toLower() ==
"software")
284 QByteArray dev = device.toLatin1();
285 m_mixerFd = open(dev.constData(), O_RDONLY);
289 if (controlLabel ==
"Master")
296 VBERROR(QString(
"Unable to open mixer: '%1'").arg(device));
303 int tmpVol = (volume << 8) + volume;
304 int ret = ioctl(
m_mixerFd, MIXER_WRITE(SOUND_MIXER_VOLUME), &tmpVol);
306 VBERROR(QString(
"Error Setting initial Master Volume") +
ENO);
309 tmpVol = (volume << 8) + volume;
310 ret = ioctl(
m_mixerFd, MIXER_WRITE(SOUND_MIXER_PCM), &tmpVol);
312 VBERROR(QString(
"Error setting initial PCM Volume") +
ENO);
336 VBERROR(QString(
"Error reading volume for channel %1").arg(channel));
341 volume = tmpVol & 0xff;
342 else if (channel == 1)
343 volume = (tmpVol >> 8) & 0xff;
345 VBERROR(
"Invalid channel. Only stereo volume supported");
355 VBERROR(QString(
"Error setting channel %1. Only 2 ch volume supported")
372 VBERROR(QString(
"Error setting volume on channel %1").arg(channel));