We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3497 - ogg is not played on Android if volume is not MIX_MAX_VOLUME
Summary: ogg is not played on Android if volume is not MIX_MAX_VOLUME
Status: RESOLVED FIXED
Alias: None
Product: SDL_mixer
Classification: Unclassified
Component: misc (show other bugs)
Version: unspecified
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-19 14:28 UTC by Alexey Tarasov
Modified: 2017-10-18 05:19 UTC (History)
0 users

See Also:


Attachments
patch for music_ogg.c (611 bytes, patch)
2016-11-19 14:28 UTC, Alexey Tarasov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Tarasov 2016-11-19 14:28:33 UTC
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,
Comment 1 Sam Lantinga 2017-10-18 05:19:17 UTC
This is fixed in Mercurial, thanks!