(iOS)Why use AudioQueue instead of AudioUnit

SDL2.0.5 use AudioQueue functions to play and record audio. In previous
version, it is AudioUnit.

Of course, SDL2.0.5 support record audio, but AudoUnit can record also. Why
SDL2.0.5 use AudioQueue instead of AudioUnit?

The commit message shares some insights: https://hg.libsdl.org/SDL/rev/38583cb96c1a https://hg.libsdl.org/SDL/rev/38583cb96c1a> On Nov 16, 2016, at 9:35 PM, leagor wrote:

SDL2.0.5 use AudioQueue functions to play and record audio. In previous version, it is AudioUnit.

Of course, SDL2.0.5 support record audio, but AudoUnit can record also. Why SDL2.0.5 use AudioQueue instead of AudioUnit?


SDL mailing list
SDL at lists.libsdl.org <mailto:SDL at lists.libsdl.org>
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

After doing a quick search, I guess this?
https://forums.libsdl.org/viewtopic.php?p=48857&sid=714b89c8259cd941f2933655840e4ab7

I think audio module on iOS has fault. In general, app opens playback at
startup, and works all time when app are runing. That is to say,
outputCallback in SDL_coreaudio.m will be called even if no sound require to
play. It will result to extra power consumption.

In previous version that using AudioUnit, I call AudioOutputUnitStop when no
sound require to play. When requiring, call AudioOutputUnitStart. This
method can avoid extra power consumption.

SDL2.0.5 use AudioQueue, it seems to be new way to avoid this problem.

Sorry if I’m missing something obvious, but are AudioQueueStop()
AudioQueueDispose()
not good enough to prevent this, or or they not being called at the right
times?

Regards,
Jeremy J.On Thu, Nov 17, 2016 at 6:59 AM, leagor wrote:

I think audio module on iOS has fault. In general, app opens playback at
startup, and works all time when app are runing. That is to say,
outputCallback in SDL_coreaudio.m will be called even if no sound require
to
play. It will result to extra power consumption.

In previous version that using AudioUnit, I call AudioOutputUnitStop when
no
sound require to play. When requiring, call AudioOutputUnitStart. This
method can avoid extra power consumption.

SDL2.0.5 use AudioQueue, it seems to be new way to avoid this problem.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

In previous version that using AudioUnit, I call AudioOutputUnitStop when no
sound require to play. When requiring, call AudioOutputUnitStart. This
method can avoid extra power consumption.

Is SDL_PauseAudioDevice() not an option?

Talking directly to system APIs for stuff SDL is handling for you tends
to be dangerous, for just this reason.

–ryan.

I think SDL_PauseAudioDevice() can not achieve this purpose.

Even if the play is paused, SDL will still call AudioQueueEnqueueBuffer,
just to set desired data to 0.

By the way, I implemented to “Pause” based on AudioQueue. Below is code.-----------------------------------
static void COREAUDIO_PauseDevice(_THIS, int pause_on)
{
if (pause_on) {
AudioQueueStop(this->hidden->audioQueue, 1);
} else {
OSStatus result = AudioQueueStart(this->hidden->audioQueue,
NULL);
}
}

----- Original Message -----
From: SDL [mailto:sdl-bounces@lists.libsdl.org] On Behalf Of Ryan C. Gordon
Sent: Sunday, November 27, 2016 1:20 PM
To: SDL Development List
Subject: Re: [SDL] (iOS)Why use AudioQueue instead of AudioUnit

In previous version that using AudioUnit, I call AudioOutputUnitStop
when no sound require to play. When requiring, call
AudioOutputUnitStart. This method can avoid extra power consumption.

Is SDL_PauseAudioDevice() not an option?

Talking directly to system APIs for stuff SDL is handling for you tends to
be dangerous, for just this reason.

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org