Quantcast
Channel: NAudio
Viewing all articles
Browse latest Browse all 5831

Commented Unassigned: COM Exception & UnRegisterEventClient [16499]

$
0
0
I'm receiving a COM error after my app exits if I call UnRegisterEventClient.

Here is a code snippet:
private Dictionary<uint, SessionsEventCallbacks.NAudioEventCallbacks> _sessionNotifications = new Dictionary<uint, SessionsEvents.NAudioEventCallbacks>();
// NAudioEventCallbacks inherits from IAudioSessionEventsHandler
...
private void OnSessionCreated(object sender, IAudioSessionControl newSession)
{
AudioSessionControl audioSession = new AudioSessionControl(newSession);
SessionsEvents.NAudioEventCallbacks notifications = new SessionsEventCallbacks.NAudioEventCallbacks();
notifications.contentCat = 0;
notifications.programType = 0;
notifications.processId = (int)audioSession.GetProcessID;
notifications.processName = Process.GetProcessById((int)audioSession.GetProcessID).ProcessName;
notifications.domain = string.Empty;
notifications.youtubeCategory = string.Empty;
notifications.audioSession = audioSession;
notifications.SessionEndedCallback = AudioStopped;

_sessionNotifications.Add((uint)notifications.processId, notifications);
audioSession.RegisterEventClient(notifications);
}

I call UnRegisterEventClient from AudioStopped.

Any help would be greatly appreciated!

Thanks,
Randall Deetz
Comments: thanks for reporting this issue and workaround. if you have a proposed fix for the library feel free to submit a PR at github

Viewing all articles
Browse latest Browse all 5831

Trending Articles