Discussion:
[SDL] (iOS)Why use AudioQueue instead of AudioUnit
leagor
2016-11-17 01:35:57 UTC
Permalink
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?
Alex Szpakowski
2016-11-17 02:10:47 UTC
Permalink
The commit message shares some insights: https://hg.libsdl.org/SDL/rev/38583cb96c1a <https://hg.libsdl.org/SDL/rev/38583cb96c1a>
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org <http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org>
Sik the hedgehog
2016-11-17 06:40:02 UTC
Permalink
After doing a quick search, I guess this?
https://forums.libsdl.org/viewtopic.php?p=48857&sid=714b89c8259cd941f2933655840e4ab7
leagor
2016-11-17 11:59:02 UTC
Permalink
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.
Jeremy Jurksztowicz
2016-11-17 13:33:31 UTC
Permalink
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.
Post by leagor
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
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Ryan C. Gordon
2016-11-27 05:20:06 UTC
Permalink
Post by leagor
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.
leagor
2016-11-27 13:59:27 UTC
Permalink
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-***@lists.libsdl.org] On Behalf Of Ryan C. Gordon
Sent: Sunday, November 27, 2016 1:20 PM
To: SDL Development List <***@lists.libsdl.org>
Subject: Re: [SDL] (iOS)Why use AudioQueue instead of AudioUnit
Post by leagor
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.

Loading...