Add a method to reset the device
This basically acts as if the app created a new context with the specified attributes (causing the device to reset with new parameters), then immediately delete it. Existing contexts remain undisturbed, except for a temporary pause while the device output is reconfigured.
This commit is contained in:
@@ -162,6 +162,8 @@ static const ALCfunction alcFunctions[] = {
|
||||
|
||||
DECL(alcGetInteger64vSOFT),
|
||||
|
||||
DECL(alcResetDeviceSOFT),
|
||||
|
||||
DECL(alEnable),
|
||||
DECL(alDisable),
|
||||
DECL(alIsEnabled),
|
||||
@@ -3289,6 +3291,42 @@ ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context)
|
||||
}
|
||||
|
||||
|
||||
/* alcResetDeviceSOFT
|
||||
*
|
||||
* Resets the given device output, using the specified attribute list.
|
||||
*/
|
||||
ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs)
|
||||
{
|
||||
ALCenum err;
|
||||
|
||||
LockLists();
|
||||
if(!(device=VerifyDevice(device)) || device->Type == Capture || !device->Connected)
|
||||
{
|
||||
UnlockLists();
|
||||
alcSetError(device, ALC_INVALID_DEVICE);
|
||||
if(device) ALCdevice_DecRef(device);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
|
||||
if((err=UpdateDeviceParams(device, attribs)) != ALC_NO_ERROR)
|
||||
{
|
||||
UnlockLists();
|
||||
alcSetError(device, err);
|
||||
if(err == ALC_INVALID_DEVICE)
|
||||
{
|
||||
V0(device->Backend,lock)();
|
||||
aluHandleDisconnect(device);
|
||||
V0(device->Backend,unlock)();
|
||||
}
|
||||
ALCdevice_DecRef(device);
|
||||
return ALC_FALSE;
|
||||
}
|
||||
UnlockLists();
|
||||
ALCdevice_DecRef(device);
|
||||
|
||||
return ALC_TRUE;
|
||||
}
|
||||
|
||||
/* alcOpenDevice
|
||||
*
|
||||
* Opens the named device.
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
#define ALC_HRTF_REQUIRED_SOFT 0x0003
|
||||
#define ALC_HRTF_HEADPHONES_DETECTED_SOFT 0x0004
|
||||
#define ALC_HRTF_UNSUPPORTED_FORMAT_SOFT 0x0005
|
||||
typedef ALCboolean (ALC_APIENTRY*LPALCRESETDEVICESOFT)(ALCdevice *device, const ALCint *attribs);
|
||||
#ifdef AL_ALEXT_PROTOTYPES
|
||||
ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ALC_SOFT_midi_interface
|
||||
|
||||
Reference in New Issue
Block a user