You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have updated the title without removing the 🔬 emoji.
What To Research
Perform some research around how we can handle when an audio device has been disconnected and a new device needs to be picked up.
Checking if a device is connected is an OpenAL extension. The name of the extension is ALC_EXT_disconnect and getting the list of extensions for an audio device done by using the this.alInvoker.GetString(this.device, AlcGetString.Extensions) call.
Not all devices support the same extensions and some support extensions that others do not. This is of course all done at the device level.
Possible Solution 1 (With Extension Support):
The idea here is to first see if the device supports the ALC_EXT_disconnect extension. If it does, then we can use the ALC API to be able to check if the device is or is not connected.
The ALC OpenAL function to do this would be alcGetIntegerv and is documented in the OpenAL guide.
This would require adding a new function API to the ALC class for function interop. The delegate would be called ALCGetInteger and the delegate pointer creation would be delegateFactory.CreateDelegate<ALCGetInteger>(libraryPointer, "alcGetIntegerv").
The only thing we could do in this scenario is get the list of devices in the system at a particular interval and then inspect the list to see what has been removed so we can know if the current device in use was disconnected. One problem with this is that the function returns an array of strings. This would cause GC collections in scenarios where it is not ideal, such as a game engine. Research would have to be done to find a way to greatly reduce or remove the GC collections. We will be limited by the OpenAL API with this.
One possible way is to reuse the class array that holds all of the device names and overwrite the items with the new ones without creating a temporary array, which would cause an allocation.
Possible useful way to watch for device changes
This could be injected into the device manager and used to watch for device changes, and then react appropriately.
This implementation would work only for devices that support the disconnection extension but could be adapted to solution 2 mentioned above.
internalclassDeviceWatcher:IDeviceWatcher{privatereadonlyCancellationTokenSourcetokenSrc=new();privatereadonlyIOpenALInvokeralInvoker;privateTaskinternalTask;privateboolisDisposed;privateALDevicedevice;publicDeviceWatcher(IOpenALInvokeralInvoker){
ArgumentNullException.ThrowIfNull(alInvoker);this.alInvoker =alInvoker;this.internalTask =new Task(CheckDevice,this.tokenSrc.Token);}publiceventFunc<ALDevice>?DeviceDisconnected;publicvoidStartWatchingDevice(ALDevicedevice){this.device =device;this.internalTask.Start();}publicvoidStopWatchingDevice()=>this.tokenSrc.Cancel();privatevoidCheckDevice(){while(!this.tokenSrc.IsCancellationRequested){
Thread.Sleep(100);if(!this.alInvoker.IsDeviceConnected(this.device)){if(this.DeviceDisconnected is not null){this.device =this.DeviceDisconnected.Invoke();}}}}}
Research Results
No response
Acceptance Criteria
The content you are editing has changed. Please copy your edits and refresh the page.
The items to complete to satisfy the Definition of Done.
Complete The Item Below
What To Research
Perform some research around how we can handle when an audio device has been disconnected and a new device needs to be picked up.
Checking if a device is connected is an OpenAL extension. The name of the extension is
ALC_EXT_disconnect
and getting the list of extensions for an audio device done by using thethis.alInvoker.GetString(this.device, AlcGetString.Extensions)
call.Not all devices support the same extensions and some support extensions that others do not. This is of course all done at the device level.
Possible Solution 1 (With Extension Support):
The idea here is to first see if the device supports the
ALC_EXT_disconnect
extension. If it does, then we can use the ALC API to be able to check if the device is or is not connected.The ALC OpenAL function to do this would be
alcGetIntegerv
and is documented in the OpenAL guide.This would require adding a new function API to the ALC class for function interop. The delegate would be called
ALCGetInteger
and the delegate pointer creation would bedelegateFactory.CreateDelegate<ALCGetInteger>(libraryPointer, "alcGetIntegerv")
.The function signature would be:
This function could then be used to find out if the device is connected. This would be done like:
Possible Solution 2 (Without Extension Support):
The only thing we could do in this scenario is get the list of devices in the system at a particular interval and then inspect the list to see what has been removed so we can know if the current device in use was disconnected. One problem with this is that the function returns an array of strings. This would cause GC collections in scenarios where it is not ideal, such as a game engine. Research would have to be done to find a way to greatly reduce or remove the GC collections. We will be limited by the OpenAL API with this.
One possible way is to reuse the class array that holds all of the device names and overwrite the items with the new ones without creating a temporary array, which would cause an allocation.
Possible useful way to watch for device changes
This could be injected into the device manager and used to watch for device changes, and then react appropriately.
This implementation would work only for devices that support the disconnection extension but could be adapted to solution 2 mentioned above.
Research Results
No response
Acceptance Criteria
The items to complete to satisfy the Definition of Done.
ToDo Items
The items to complete to satisfy the Definition of Done.
Issue Dependencies
No response
Related Work
No response
Additional Information:
Priority Type Labels
low priority
medium priority
high priority
Code of Conduct
The text was updated successfully, but these errors were encountered: