I`m trying to play two videos with FFMPEG+SDL2 at the same time,it is working on windows,but get an error on android and ios when I call SDL_OpenAudioDevice (Audio device already open),I cant call SDL_OpenAudioDevice twice which is ok on windows
is anyway to play two videos at the same time on android and ios ??
I don’t know whether this helps, but could you perhaps mix the two audio streams together (e.g. using SDL_MixAudioFormat()
) and use just a single audio device?
Other options …
On Android it uses by default the OpenSLES back-end.
Maybe that would work is you use the older “android” backend.
(not sure if this work if you can set an env: SDL_setenv(“SDL_AUDIODRIVER”, “android”, 1); )
(Or -if possible- one back-end for each audio source.)
thanks a lot, now I just got another problem
my app deadlock on android when call SDL_LockAudioDevice (sdl2.0.8)), I did not call SDL_LockAudioDevice in callbackfunction
here is my callbackfunction(SDL_AudioCallback):
void SDLAudio::sdl_audio_callback(void opaque, Uint8 stream, int len)
{
SDLAudio sa = (SDLAudio)opaque;
bool mute = true;
bool clean = true;
std::unordered_map<unsigned int, MediaState*>::iterator iter;
for (iter = sa->_AudioMap.begin(); iter != sa->_AudioMap.end(); iter++)
{
bool is_mute = iter->second->sdl_audio_callback(stream, len, clean);
clean = false;
if (!is_mute)
{
mute = false;
}
}
if (mute)
{
memset(stream, 0, len);
}
}
and here is my function which include SDL_LockAudioDevice:
void SDLAudio::close_audio(unsigned int id)
{
SDL_LockAudioDevice(_audio_dev);
std::unordered_map<unsigned int, MediaState*>::iterator got = _AudioMap.find(id);
if (got != _AudioMap.end())
{
_AudioMap.erase(id);
}
SDL_UnlockAudioDevice(_audio_dev);
}