| Summary: | ogg is not played on Android if volume is not MIX_MAX_VOLUME | ||
|---|---|---|---|
| Product: | SDL_mixer | Reporter: | Alexey Tarasov <taleks> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | unspecified | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | patch for music_ogg.c | ||
This is fixed in Mercurial, thanks! |
Created attachment 2637 [details] patch for music_ogg.c SDL2_Mixer revision: 19fb1b19b512, the same issue exists at least for release-2.0.5. OGG_playAudio in music_ogg.c uses different ways to fill destination buffer depending on music volume value. If it is MIX_MAX_VOLUME, then decoded buffer is copied to destination buffer by calling SDL_memcpy. If it is any other value, SDL_MixAudio() is called, which gets audio format with get_audio_device(1) and passes it as argument to SDL_MixAudioFormat(). Issue is that there is no opened audio device with id 1, because Mix_OpenAudio() call chain ends with SDL_OpenAudioDevice(), which in turn calls open_audio_device() with minimal device id equal to 2. I've fixed it with attached patch and it works as expected after applying patch, volume is adjustable and music is played. However I've not tested it on platforms other than Android and I'm not fluent in SDL internals enough to be sure that mixer format, provided in argument for OGG_init() is the same as used by audio device. grep output shows that the same issue likely to affect other decoders as well: ./music_flac.c: SDL_MixAudio (snd, music->snd_available, mixable, music->volume); ./music_mad.c: SDL_MixAudio(out, mp3_mad->output_buffer + mp3_mad->output_begin,