Is There A function to Initialize the audio and play the sound and uninitialize it , all in one function #433
-
; |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Nope, there's nothing like that and I don't have any intention on adding it, sorry. It's just too niche of a requirement. |
Beta Was this translation helpful? Give feedback.
-
Ok , when i play an Mp3 does it play on a thread , and if so how to I end it after it has finished playing on the thread |
Beta Was this translation helpful? Give feedback.
-
Also sometimes after playing a few sounds they stop playing |
Beta Was this translation helpful? Give feedback.
-
The device's data callback is run from it's own thread. It sounds like you are creating a device for each sound. If you're playing multiple sounds multiple times the correct way to do it is to create one device and many decoders. Devices and decoders are completely decoupled from each other. A better option might be to use the high level API. You can just initialize an |
Beta Was this translation helpful? Give feedback.
-
Alright , but if you run "ma_engine_play_sound()" more then once , then does it create more then one thread , or does it wait for the previous call to run , then only the current one runs |
Beta Was this translation helpful? Give feedback.
-
They'll play simultaneously, but they wont be on their own thread - they're all mixed on the engine's internal device's thread. If you need it to wait for the previous one to finish you won't be able to use There's many different ways to do what you're needing. There's no need to use the high level API if it doesn't suit you - I just mentioned in case you might find it useful. If you want to use |
Beta Was this translation helpful? Give feedback.
-
Alright ill try that |
Beta Was this translation helpful? Give feedback.
They'll play simultaneously, but they wont be on their own thread - they're all mixed on the engine's internal device's thread. If you need it to wait for the previous one to finish you won't be able to use
ma_engine_play_sound()
. Instead you'd need to initialize a sound withma_sound_init_from_file()
and manage it yourself. You can periodically callma_sound_at_end()
to determine if it's at the end.There's many different ways to do what you're needing. There's no need to use the high level API if it doesn't suit you - I just mentioned in case you might find it useful. If you want to use
ma_decoder
directly, just look at the return value ofma_decoder_read_pcm_frames()
to determine if it…