summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2012-06-02 01:26:17 +0200
committerMarton Balint <cus@passwd.hu>2012-06-02 21:55:58 +0200
commit0dad52920170f58f1c01c8dfd5ad851b467c6c5b (patch)
treef0fa4bd66145fc4d2210b838f634f824c2750f62 /ffplay.c
parent7821264c267147033367912e84a3a6eb8f7fe4c0 (diff)
ffplay: try more channel count combinations for SDL_OpenAudio
This should fix ticket 1384. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ffplay.c b/ffplay.c
index 181b3235a4..700c89408c 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2246,6 +2246,7 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb
{
SDL_AudioSpec wanted_spec, spec;
const char *env;
+ const int next_nb_channels[] = {0, 0, 1, 6, 2, 6, 4, 6};
env = SDL_getenv("SDL_AUDIO_CHANNELS");
if (env) {
@@ -2255,12 +2256,6 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb
if (!wanted_channel_layout || wanted_nb_channels != av_get_channel_layout_nb_channels(wanted_channel_layout)) {
wanted_channel_layout = av_get_default_channel_layout(wanted_nb_channels);
wanted_channel_layout &= ~AV_CH_LAYOUT_STEREO_DOWNMIX;
- wanted_nb_channels = av_get_channel_layout_nb_channels(wanted_channel_layout);
- /* SDL only supports 1, 2, 4 or 6 channels at the moment, so we have to make sure not to request anything else. */
- while (wanted_nb_channels > 0 && (wanted_nb_channels == 3 || wanted_nb_channels == 5 || wanted_nb_channels > (SDL_VERSION_ATLEAST(1, 2, 8) ? 6 : 2))) {
- wanted_nb_channels--;
- wanted_channel_layout = av_get_default_channel_layout(wanted_nb_channels);
- }
}
wanted_spec.channels = av_get_channel_layout_nb_channels(wanted_channel_layout);
wanted_spec.freq = wanted_sample_rate;
@@ -2273,9 +2268,14 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb
wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
wanted_spec.callback = sdl_audio_callback;
wanted_spec.userdata = opaque;
- if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
- fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
- return -1;
+ while (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
+ fprintf(stderr, "SDL_OpenAudio (%d channels): %s\n", wanted_spec.channels, SDL_GetError());
+ wanted_spec.channels = next_nb_channels[FFMIN(7, wanted_spec.channels)];
+ if (!wanted_spec.channels) {
+ fprintf(stderr, "No more channel combinations to try, audio open failed\n");
+ return -1;
+ }
+ wanted_channel_layout = av_get_default_channel_layout(wanted_spec.channels);
}
if (spec.format != AUDIO_S16SYS) {
fprintf(stderr, "SDL advised audio format %d is not supported!\n", spec.format);