[openal] OpenALSoft on Android, how to handle suspend/resume of application

Olle Hedman olle at illusionlabs.se
Mon Sep 3 09:24:17 EDT 2018


Great!

alcDevicePauseSOFT/alcDeviceResumeSOFT was exactly what I needed!

I've attached patch files for the additions I've done

coreaudio-ios-buildfix.diff
-
This small patch is to make coreaudio backend build and run on iOS. Capture
is disabled. (I have no use for it, and there was some issue with it, I
don't remember exactly. Possibly it's not available on iOS, or there was
some sandbox/entitlement issue)

ios-bundle-config.diff
-
Another minor iOS fix, this makes it possible to keep the config file in
the application bundle.
This might not be needed, but it was how I solved it at that time. Possibly
you could also just "chdir()" in your app to the bundle path and it would
also work.
I'm not using a config file now, but I thought I should include this patch
anyhow.

wave-output.diff
-
The most impactful patch, introduces a few new API functions:
+ALC_API ALCboolean ALC_APIENTRY alcSetPlaybackBackendSOFT(const char*
name); - Switches backend. Must be called before creating device/context.
When switching, I shut down, switch, and recreate device and context. I use
this to switch between "core" and "wave".

+ALC_API void ALC_APIENTRY alcSetWaveOutputFileSOFT(const char* path); -
Setting what file wave backend output too, it was impractical to use the
config file for this on iOS. Also introduces the internal SetConfigValue
function.

+ALC_API void ALC_APIENTRY alcSetWaveOutputRealtimeSOFT(ALCboolean
realtime); - Toggles realtime mode on wave backend. if true, works as
before with background thread, if false, you must call the next function to
step the mixer/backend

+ALC_API void ALC_APIENTRY alcWaveOutputRenderSOFT(ALCdevice *device,
ALCdouble dt); - Steps the mixer/backend for dt seconds outputting to the
wave file (used only if backend has realtime==false). I needed this to
synchronize with offscreen rendering when recording video with sound from
our game engine. Implementation could be cleaned up for better code
re-use...


That's it.

Also, thank you for maintaining this very useful software! :)




On 30 August 2018 at 16:59, Chris Robinson <chris.kcat at gmail.com> wrote:

> On 08/30/2018 06:57 AM, Olle Hedman wrote:
>
>> But at least one thing does not work for me anymore on Android, and that
>> is
>> suspending and resuming. (when application goes into background and comes
>> back again). The problem is the mixing thread is still running and
>> outputting (very choppy) sound for all our looping sound effects while the
>> app is in background...
>>
>> How am I supposed to handle this? Destroying and recreating the context is
>> very inconvenient since the suspend can happen at any time and we want
>> everything to restart playing exactly where suspended when we resume
>> again.
>>
>
> Hi.
>
> Since 1.16, OpenAL Soft has the ALC_SOFT_pause_device extension which
> should do what you want. It adds the alcDevicePauseSOFT function you can
> use to stop output processing (when you detect the app has been put into
> the background, for instance), and alcDeviceResumeSOFT to resume where it
> left off (when back in the foreground).
>
> <http://kcat.strangesoft.net/openal-extensions/SOFT_pause_device.txt>
>
> Feel free to ask if you have any questions with using it.
>
> Also, let me know if you are interested in knowing more about any of our
>> other patches.
>>
>
> Sure, it would be good to know what changes you've needed or wanted.
>



-- 

*Best regards,*
*Olof Hedman*

Mobile:

+46 (0)708 - 42 28 76
Office:

+46 (0)40 - 644 44 95
Web:

www.illusionlabs.com
Twitter:

twitter.com/illusionlabs

Illusion Labs AB
Kalendegatan 25
SE-211 35 Malmö, Sweden


"The information in this e-mail, and attachment(s) thereto, is strictly
confidential and may be legally privileged. It is intended solely for the
named recipient(s), and access to this e-mail, or any attachment(s)
thereto, by anyone else is unauthorized. If you are not the intended
recipient please inform the sender by replying to this transmission, and
delete the e-mail, its attachment(s), and any copies of it, without
disclosing it."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openal.org/pipermail/openal/attachments/20180903/7903bffb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: coreaudio-ios-buildfix.diff
Type: application/octet-stream
Size: 1818 bytes
Desc: not available
URL: <http://openal.org/pipermail/openal/attachments/20180903/7903bffb/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ios-bundle-config.diff
Type: application/octet-stream
Size: 1300 bytes
Desc: not available
URL: <http://openal.org/pipermail/openal/attachments/20180903/7903bffb/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wave-output.diff
Type: application/octet-stream
Size: 8858 bytes
Desc: not available
URL: <http://openal.org/pipermail/openal/attachments/20180903/7903bffb/attachment-0005.obj>


More information about the openal mailing list