filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.14k stars 450 forks source link

AudioSessionManager2.GetSessionEnumerator throws CoreAudioAPIException with 0x88890008 #443

Open TheLever opened 3 years ago

TheLever commented 3 years ago

I am trying to enumerate audio endpoints to find a named one. I am getting the collection of active endpoints and loop over that. Trying to call AudioSessionManager2.GetSessionEnumerator throws the mentioned exception with the error code also specified. Where would I begin to search for a solution to this?

using (var deviceCollection = this.deviceEnumerator.EnumAudioEndpoints(DataFlow.Render, DeviceState.Active))
 {
   var audioControls = new List<SimpleAudioVolume>();
   var count = deviceCollection.Count;
   for (var deviceIdx = 0; deviceIdx < count; deviceIdx++)
   {
      AudioSessionEnumerator audioSessionEnumerator;
      using (var audioDevice = deviceCollection[deviceIdx])
      {
         var audioSessionMgr = new AudioSessionManager2(
            audioDevice.Activate(
               typeof(IAudioSessionManager2).GUID,
               CLSCTX.CLSCTX_ALL,
               IntPtr.Zero));
            audioSessionEnumerator = audioSessionMgr.GetSessionEnumerator();
       }
       // Rest omitted for brevity
filoe commented 3 years ago

It is hard to tell. Those errors are most of the time related to driver issues. Maybe try to search the internet, there are several similar issues out there.

Also try to execute the tests of the test project: https://github.com/filoe/cscore/blob/master/CSCore.Test/CoreAudioAPI/AudioSessionTests.cs#L75

Those should work as long as the driver works properly.

TheLever commented 3 years ago

Thanks for the reply! I have searched as best I could before posting here. I am guessing also it is a driver issue - though I have not had any updates I am aware of. Is it the HRESULT you'd say is the important part here, or the API causing the failure?

filoe commented 3 years ago

See my edit above. In general the result and the called api is the only indicator you have. But the result seems not to be obe of the standard ones.

TheLever commented 3 years ago

Ok, thanks. I will try to convert the tests to a standalone app - the issue obviously does not manifest itself on my box, but on a friend's. I'll report back

TheLever commented 3 years ago

I ran the tests (adapted to a standard console app as the user has no VS installed). CanGetSessionProperties fails in the assert. Does that help in any way in diagnosing what the issue is?