14 #if HAVE_SYS_SOUNDCARD_H 15 #include <sys/soundcard.h> 16 #elif HAVE_SOUNDCARD_H 17 #include <soundcard.h> 22 #define LOC QString("AOOSS: ") 31 audiofd(-1), numbadioctls(0),
32 mixerfd(-1), control(SOUND_MIXER_VOLUME)
64 if(ioctl(
audiofd, SNDCTL_DSP_SPEED, &rate2) >= 0
70 VBERRENO(
"Error retrieving formats");
94 for (
int i = 1; i <= 2; i++)
98 if (ioctl(
audiofd, SNDCTL_DSP_CHANNELS, &channel) >= 0 &&
123 audiofd = open(device.constData(), O_WRONLY);
124 if (
audiofd < 0 && errno != EAGAIN && errno != EINTR)
128 VBWARN(QString(
"Something is currently using: %1.")
132 VBERRENO(QString(
"Error opening audio device (%1)")
148 VBERRENO(QString(
"Error removing the O_NONBLOCK flag from audio device FD (%1)").arg(
main_device));
165 #if defined(AFMT_AC3) && defined(SNDCTL_DSP_GETFMTS) 168 int format_support = 0;
169 if (!ioctl(
audiofd, SNDCTL_DSP_GETFMTS, &format_support) &&
170 (format_support & AFMT_AC3))
187 if (ioctl(
audiofd, SNDCTL_DSP_STEREO, &stereo) < 0 ||
195 VBERRENO(QString(
"Unable to set audio device (%1) to %2 kHz, %3 bits, " 207 if (ioctl(
audiofd, SNDCTL_DSP_GETOSPACE, &info) < 0)
208 VBERRENO(
"Error retrieving card buffer size");
216 if (ioctl(
audiofd, SNDCTL_DSP_GETCAPS, &caps) == 0)
218 if (!(caps & DSP_CAP_REALTIME))
219 VBWARN(
"The audio device cannot report buffer state " 220 "accurately! audio/video sync will be bad, continuing...");
223 VBERRENO(
"Unable to get audio card capabilities");
250 int written = 0, lw = 0;
254 while ((written < size) &&
263 VBERRENO(QString(
"Error writing to audio device (%1)")
272 int soundcard_buffer=0;
274 #ifdef SNDCTL_DSP_GETODELAY 275 if(ioctl(
audiofd, SNDCTL_DSP_GETODELAY, &soundcard_buffer) < 0)
278 return soundcard_buffer;
286 if (device.toLower() ==
"software")
289 QByteArray dev = device.toLatin1();
290 mixerfd = open(dev.constData(), O_RDONLY);
294 if (controlLabel ==
"Master")
301 VBERROR(QString(
"Unable to open mixer: '%1'").arg(device));
310 int ret = ioctl(
mixerfd, MIXER_WRITE(SOUND_MIXER_VOLUME), &tmpVol);
312 VBERROR(QString(
"Error Setting initial Master Volume") +
ENO);
316 ret = ioctl(
mixerfd, MIXER_WRITE(SOUND_MIXER_PCM), &tmpVol);
318 VBERROR(QString(
"Error setting initial PCM Volume") +
ENO);
342 VBERROR(QString(
"Error reading volume for channel %1").arg(channel));
348 else if (channel == 1)
349 volume = (tmpVol >> 8) & 0xff;
351 VBERROR(
"Invalid channel. Only stereo volume supported");
361 VBERROR(QString(
"Error setting channel %1. Only 2 ch volume supported")
381 VBERROR(QString(
"Error setting volume on channel %1").arg(channel));
AudioOutputOSS(const AudioSettings &settings)
def write(text, progress=True)
void InitSettings(const AudioSettings &settings)
int output_bytes_per_frame
A QElapsedTimer based timer to replace use of QTime as a timer.
void Error(const QString &msg)
void setPassthrough(int val)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
static int FormatToBits(AudioFormat format)
virtual ~AudioOutputOSS()
AudioFormat output_format
#define VBERRNOCONST(str)
QString GetSetting(const QString &key, const QString &defaultval="")
void SetVolumeChannel(int channel, int volume) override
bool OpenDevice(void) override
#define ENO
This can be appended to the LOG args with "+".
int elapsed(void) const
Returns milliseconds elapsed since last start() or restart()
int GetNumSetting(const QString &key, int defaultval=0)
long soundcard_buffer_size
void AddSupportedRate(int rate)
void KillAudio(void)
Kill the output thread and cleanup.
void Reconfigure(const AudioSettings &settings) override
(Re)Configure AudioOutputBase
AudioFormat GetNextFormat()
AudioOutputSettings * GetOutputSettings(bool digital) override
void CloseDevice(void) override
void AddSupportedFormat(AudioFormat format)
int GetVolumeChannel(int channel) const override
static void usleep(unsigned long time)
void AddSupportedChannels(int channels)
void start(void)
starts measuring elapsed time.
int GetBufferedOnSoundcard(void) const override
Return the size in bytes of frames currently in the audio buffer adjusted with the audio playback lat...
void WriteAudio(unsigned char *aubuf, int size) override
bool init
If set to false, AudioOutput instance will not try to initially open the audio device.