diff options
author | Chris Robinson <[email protected]> | 2009-08-26 19:15:17 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-08-26 19:15:17 -0700 |
commit | 7976de05a54fb84c575723d77465308e49c9a258 (patch) | |
tree | 5ea263be25c5bcafbc06a29e5c04ebf4e5a7a56d /Alc | |
parent | 70c88879abaa7f4946dc009770bf23fab3f2ee48 (diff) |
Add base support for ALC_EXT_disconnect
Individual backends need to be updated to handle disconnection events
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 22 | ||||
-rw-r--r-- | Alc/ALu.c | 36 |
2 files changed, 56 insertions, 2 deletions
@@ -169,7 +169,7 @@ static ALCchar *alcDefaultAllDeviceSpecifier = alcAllDeviceList; static ALCchar *alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList; -static ALCchar alcExtensionList[] = "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_EFX"; +static ALCchar alcExtensionList[] = "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_disconnect ALC_EXT_EFX"; static ALCint alcMajorVersion = 1; static ALCint alcMinorVersion = 1; @@ -576,6 +576,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL memset(pDevice, 0, sizeof(ALCdevice)); //Validate device + pDevice->Connected = ALC_TRUE; pDevice->IsCaptureDevice = AL_TRUE; pDevice->Frequency = frequency; @@ -808,6 +809,13 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize SetALCError(ALC_INVALID_VALUE); break; + case ALC_CONNECTED: + if(size <= 0) + SetALCError(ALC_INVALID_VALUE); + else + *data = device->Connected; + break; + default: SetALCError(ALC_INVALID_ENUM); break; @@ -944,6 +952,15 @@ ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsize *data = device->lNumStereoSources; break; + case ALC_CONNECTED: + if(!IsDevice(device)) + SetALCError(ALC_INVALID_DEVICE); + else if(size <= 0) + SetALCError(ALC_INVALID_VALUE); + else + *data = device->Connected; + break; + default: SetALCError(ALC_INVALID_ENUM); break; @@ -1058,7 +1075,7 @@ ALCAPI ALCcontext* ALCAPIENTRY alcCreateContext(ALCdevice *device, const ALCint ALuint ulAttributeIndex, ulRequestedStereoSources; ALuint RequestedSends; - if(IsDevice(device) && !device->IsCaptureDevice) + if(IsDevice(device) && !device->IsCaptureDevice && device->Connected) { // Reset Context Last Error code g_eLastContextError = ALC_NO_ERROR; @@ -1351,6 +1368,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName) memset(device, 0, sizeof(ALCdevice)); //Validate device + device->Connected = ALC_TRUE; device->IsCaptureDevice = AL_FALSE; //Set output format @@ -1385,3 +1385,39 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma ProcessContext(ALContext); } + +ALvoid aluHandleDisconnect(ALCdevice *device) +{ + if(!device->IsCaptureDevice) + { + ALsource *source = NULL; + + SuspendContext(device->Context); + if(device->Context) + source = device->Context->Source; + + while(source) + { + if(source->state == AL_PLAYING) + { + ALbufferlistitem *BufferListItem; + + source->state = AL_STOPPED; + source->inuse = AL_FALSE; + source->BuffersPlayed = source->BuffersInQueue; + BufferListItem = source->queue; + while(BufferListItem != NULL) + { + BufferListItem->bufferstate = PROCESSED; + BufferListItem = BufferListItem->next; + } + source->position = 0; + source->position_fraction = 0; + } + source = source->next; + } + ProcessContext(device->Context); + } + + device->Connected = ALC_FALSE; +} |