[Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution)
Date | 2014-01-30 19:47 |
From | hcenteno |
Subject | [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
Hello, If I use AudioTrack for an Android app (that is, instantiating with CsoundObj(true)), 9 out of 10 times the app would freeze when trying to stop using CsoundObj.stop(). After some debugging I found the source of the problem in CsoundObj.java. The main execution while loop inside runCsoundAudioTrack(File f) contains a synchronized block of code that causes the freeze if the variable "stopped" changes to "true" after the while loop has already started. I'm not expert in threading but to my logic it seems that when CsdoundObj.stop() is called, setting stopped to "true" and waiting at thread.join(), trying to synchronize locks everything. By moving this synchronized code to the top of the while loop, solves the problem. In other words, in runCsoundAudioTrack(File f), instead of: It should be: Now, I'm not sure if inverting those two blocks of code would cause something to malfunction (writing the samples out to audioTrack after updating the values to and from Csound), but at least it seems to work fine for me. Best, Hector -- View this message in context: http://csound.1045644.n5.nabble.com/Android-runCsoundAudioTrack-app-freeze-and-possible-solution-tp5732081.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-01-30 20:27 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
why are you using AudioTrack()? The OpenSL IO will give you better performance. We never really tested the AudioTrack code too much at all, and have not used it in production. On 30 Jan 2014, at 19:47, hcenteno |
Date | 2014-01-30 21:32 |
From | hcenteno |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
I made an app that is failing to output any sound in someone else's specific device (Italian NGM Forward Prime running Android 4.2). I don't have access to the device to check the logs (and the user can't handle doing it) so I was wondering if running Csound using AudioTrack instead of OpenSL could be the solution. Does this make sense? Thanks! Hector -- View this message in context: http://csound.1045644.n5.nabble.com/Android-runCsoundAudioTrack-app-freeze-and-possible-solution-tp5732081p5732086.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-01-30 21:47 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
OpenSL is present in 4.2, and I would not think that could be the case. Did you try the Csound examples or the Csound app to see if it works? The new Csound app has a console, which makes it handy to see if there are issues. On 30 Jan 2014, at 21:32, hcenteno |
Date | 2014-01-31 16:50 |
From | hcenteno |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
I didn't know that the AudioTrack mode wasn't tested and ready for use and thought I could help by posting a solution to a problem I found. I'm wondering now, what is then the purpose of the AudioTrack mode in CsoundObj? Only to be used when a device doesn't have OpenSL (versions below Android 2.3)? Best, Hector -- View this message in context: http://csound.1045644.n5.nabble.com/Android-runCsoundAudioTrack-app-freeze-and-possible-solution-tp5732081p5732095.html Sent from the Csound - Dev mailing list archive at Nabble.com. ------------------------------------------------------------------------------ WatchGuard Dimension instantly turns raw network data into actionable security intelligence. It gives you real-time visual feedback on key security issues and trends. Skip the complicated setup - simply import a virtual appliance and go from zero to informed in seconds. http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net |
Date | 2014-01-31 17:37 |
From | Victor Lazzarini |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
The code is there because it was the first thing we did, before we worked out how to use OpenSL. Since then we have not used it. I guess an obvious use is what you said, but this will be increasingly less relevant as time passes on. So, by all means, if you need to use it, do, and send any bugs via tickets on sourceforge (if there are patches or suggested fixes, that is also great). Regards Victor On 31 Jan 2014, at 16:50, hcenteno |
Date | 2014-02-11 00:49 |
From | Andres Cabrera |
Subject | Re: [Cs-dev] Android runCsoundAudioTrack() app freeze (and possible solution) |
Attachments | None None |
Hi Hector, I'm curious, does your AmbiExplorer app use Csound internally? (BTW, just got it recently but haven't had time to get some ambi recordings in my phone to try it...)Cheers, On Fri, Jan 31, 2014 at 8:50 AM, hcenteno <hcengar@gmail.com> wrote: I didn't know that the AudioTrack mode wasn't tested and ready for use and |