Hello
I am in the process of completeing my application. Here's what it does. The main tangible interface is a joystick. The main thread called the engine sits in the background and creates new threads as needed when the user wants it to. For example, when one hits button 1 of the joystick, mp3 decoding starts. When Joystick is moved to the left, it skips to the next song and so on.
That's where mad comes in.
The engine is completed and operational. Now I need to hack mad to suit my needs. What I need from mad is
- ability to build a playlist from sources listed in a configuration file (that's the easy part)
- stop/play mp3 decoding as needed: That is the main thread called engine controls mp3 playback via a flag maybe (inter-thread communication).
I have taken a look at the code, yet I am a bit unsure how the second paragraph can be done with mad easily... That is to say I want something very high-level and powerful as well. I would've taken a look at the API doc, but ...
I don't know what to do to acheive my goals...
Anyways suggestions/comments welcome. davoid
- stop/play mp3 decoding as needed: That is the main thread called engine
controls mp3 playback via a flag maybe (inter-thread communication).
What I do to pause is to have the output callback check to see if a "PLAY" flag is set. If it is set, then to copy the decoded audio to the audio device (/dev/dsp). If it is not set, then to sleep (actually, a select() loop with a timeout as sleep() causes all your threads to sleep). Then check the thread again after some time to see if it has been turned on, in which case, you resume your normal operation.
Reza
On Wed, Jul 24, 2002 at 11:11:33PM -0700, Reza Naima wrote:
What I do to pause is to have the output callback check to see if a "PLAY" flag is set. If it is set, then to copy the decoded audio to the audio device (/dev/dsp). If it is not set, then to sleep (actually, a select() loop with a timeout as sleep() causes all your threads to sleep). Then check the thread again after some time to see if it has been turned on, in which case, you resume your normal operation.
Using a condition variable is most likly much better than busy waiting. Most threading systems have built in condition vars.