[openal] ALC_SOFT_reopen_device extension proposal

Chris Robinson chris.kcat at gmail.com
Wed Dec 8 14:57:13 EST 2021


On Wednesday, December 8, 2021 11:35:46 AM PST Guillermo Hugo Ojea Quintana 
wrote:
> Hello Chris,
> 
> This extension would be extremely useful.
> 
> So, the idea is that we have already opened and initialized some device and
> its context:
> ALCdevice *device;
> device = alcOpenDevice("OpenAL Soft on Altavoces");
> 
> ALCcontext *ctx;
> ctx = alcCreateContext(device, NULL);
> ...
> 
> Then, the user wants to change the device, so we would do this:
> alcReopenDeviceSOFT(device, "OpenAL Soft on Realtek Digital Output", NULL);
> 
> And now the 'device' pointer would refer to the other device?
> 
> There would be no need to create a new context, etc?

Correct. The device stops playing on the old device and starts playing on the 
new one, and all of its contexts and associated objects remain valid. There's 
no need to recreate anything.

> If there is sound playing what would happen?

It keeps playing, with the output on the new device instead of the old one. 
Under the hood, OpenAL Soft stops the system device currently associated with 
the ALCdevice, which pauses mixing and leaves the state of everything as-is. 
Then it attempts to open the new requested system device, and if successful, 
re-associates the ALCdevice with it, closes the old system device, and 
configures and starts output on the new device, resuming everything to 
continue right from where it left off.




More information about the openal mailing list