Question

In OpenTK or OpenAL in general, I need to change the output device without having to redo all AL work for my resources. Is it possible to change the output device in the AudioContext without messing with the OpenAL state?

E.g.: I'm changing the AudioContext using:

context = new AudioContext(deviceName, 0, 0, false, false);
context.MakeCurrent();

But this will make me have to redo things like:

BufferIds = AL.GenBuffers(3);

For every resource.

All I want is to change the output device, and I need a way to either do that while maintaining the OpenAL state, or a way to store and reload the OpenAL state in the new AudioContext.

If I'm getting the idea of AudioContexts all wrong please don't hold back =S

Gr.Viller

Was it helpful?

Solution

Judging from the discussion in the AL_EXT_disconnect extension, this does not appear to be possible:

  1. Should we make promises about buffer data post-disconnect?

    RESOLVED: No.

    The AL currently supplies no means to recover buffer data, and all contexts sharing buffers must be on the same device. As such, all buffer data is lost in the event of a disconnect. The application will be required to reupload all their buffer data after opening a new device. If a future extension exposes a means to recover buffer data from the AL, it should amend this specification.

So far I haven't been able to find an extension to recover buffer data. However, it might be worth directing this question to the openal mailing list.

Edit: another relevant discussion on stackoverflow:

All the al* functions (rather than alc* functions) operate on the current context. So, alGenBuffer calls will operate on the current context and create Buffers that belong to the Context's Device (a Context can only have one Device).

Buffers created on one Device are not available on another Device.

A Device's Buffers will (probably) be automatically destroyed when you call alcCloseDevice.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top