Code Monkey home page Code Monkey logo

Comments (4)

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

Hey @larsk2009, well nice research so far. Unfortunately, I know this kind of issue... I came across a lot times with NAudio. It happens when you initialize a NAudio player from one thread and dispose it from another. I was able to solve the most issue by switching to direct sound and creating the AudioMaster.cs to handle the device removal events etc. So, I guess the difference with the bluetooth device is that I'm missing/not handling properly an event on AudioMaster. I will need to find a bluetooth device for testing it tho.

from flyleaf.

larsk2009 avatar larsk2009 commented on August 31, 2024

Yeah I did check the events in AudioMaster.cs, and the OnDefaultDeviceChanged and OnDeviceRemoved events do get fired when the bluetooth device gets connected or disconnected. I do agree it seems like a threading issue.

To make matters worse, I actually found with more testing that the issue happens every time when disconnecting the device, but only sometimes when connecting it.

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

Hey, as I don't have a bluetooth adapter and device to test if you want try to... test if initializing and disposing happens at the same thread... and if that's the problem.

AudioPlayer.cs:Initialize()

Log($"AudioPlayer initializing on thread {System.Threading.Thread.CurrentThread.ManagedThreadId}");

AudioPlayer.cs:Dispose()

if (player != null) Log($"AudioPlayer disposing on thread {System.Threading.Thread.CurrentThread.ManagedThreadId}");

I get different threads but Dispose is not hanging... maybe it is happening only for the bluetooth device.

I might have to create a thread only for all the naudio players for initializing/playing/disposing at the same thread. I'm afraid that it causes other issues as well. By looking at naudio's issues you will see a lot similar. Seems to be an issue with COM objects.

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on August 31, 2024

Should be fixed in v3.4.2. I wasn't able to test it so let me know if still not working!

from flyleaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.