We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Threading issue in Minim
Page Index Toggle Pages: 1
Threading issue in Minim (Read 1917 times)
Threading issue in Minim
Jul 3rd, 2009, 7:22am
 
Hello,

I’ve been developing an application capable of playing multiple audio files (using an AudioPlayer). Because of that I create multiple AudioPlayers via Minim.loadFile.

What I’ve noticed is that most of the AudioPlayer threads actually do not die when I call AudioPlayer.close. That’s a waste of resources as it can happen to have hundreds of sleeping threads that actually do nothing. The increasing number of threads eventually makes the application crash.

Looking at JSBaseAudioRecordingStream.java, we find out that the writeBytes method makes the thread block before it exits when the thread’s close method is called. Please, in the close method just call line.flush() before line.stop() on the close method. That solves the problem.

Best regards
Re: Threading issue in Minim
Reply #1 - Jul 9th, 2009, 2:43am
 
there is no flush() function in the minim api. i guess you mean the library needs to be rebuilt with that fix. in that case it would probably be better to email the dev himself about the hint instead of posting about it in here.. or did i miss something?  Undecided
Re: Threading issue in Minim
Reply #2 - Aug 20th, 2009, 11:26am
 
Having the very same problem! I am playing a bunch of short audio files... and my program quickly crashes under the weight of hundreds of zombie threads. (One for each minim.loadFile() none of which go away with close() calls.)

Sent this along to the library author, Damien Di Fede. I hope he doesn't mind adding this line of code to his otherwise wonderful work.

Thank you OP for the tip on how to fix this problem... but could someone help me recompile this library? I'm finding it a challenge, which jar's do I need to rebuild? ... and how do I rebuild them?

Thanks for reading this, any and all help appreciated!
Re: Threading issue in Minim
Reply #3 - Aug 25th, 2009, 7:40pm
 
ps wrote on Jul 9th, 2009, 2:43am:
there is no flush() function in the minim api. i guess you mean the library needs to be rebuilt with that fix. in that case it would probably be better to email the dev himself about the hint instead of posting about it in here.. or did i miss something  Undecided


Hello! I tried to warn the developer but I didn't get an answer. Anyway, in Minim's website he suggests that we can try to reach him through the processing forums. That's what I did :p

The flush() method exists on the object line of the minim's inner class JSBaseAudioRecordingStream that's of type javax.sound.sampled.SourceDataLine.

Indeed it would be nice to get a rebuild Smiley
Re: Threading issue in Minim
Reply #4 - Aug 25th, 2009, 7:54pm
 
hithereimdan wrote on Aug 20th, 2009, 11:26am:
Having the very same problem! I am playing a bunch of short audio files... and my program quickly crashes under the weight of hundreds of zombie threads. (One for each minim.loadFile() none of which go away with close() calls.)

Sent this along to the library author, Damien Di Fede. I hope he doesn't mind adding this line of code to his otherwise wonderful work.

Thank you OP for the tip on how to fix this problem... but could someone help me recompile this library I'm finding it a challenge, which jar's do I need to rebuild ... and how do I rebuild them

Thanks for reading this, any and all help appreciated!


Hello!
All you need to do is to get the minims full distribution, go to the source code and in ddf/mimin/javasound/JSBaseAudioRecordingStream.java add a line.flush(); before line 358.

Next, you will need to rebuild the jar. Now we can do it using the command line utility or installing a Java IDE (e.g. Ecclipse, Netbeans). Anyway, I can try to email it for you.

regards
Re: Threading issue in Minim
Reply #5 - Sep 3rd, 2009, 3:47pm
 
I've made a note of this problem in my most current source and will have it fixed in the next release. I know there hasn't been a release in forever, but I hope to have one out in early October.
Page Index Toggle Pages: 1