diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 20:33:01 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-05 20:33:11 +0100 |
commit | 4d5bbbadd7cd8ffb672fb69147da8dfbde5255fa (patch) | |
tree | 76f0203fe2088bfb19a2e75dcd24fe3fd482f9c3 /ffplay.c | |
parent | 7f83db312454b3673a4dfd34745428f61309ab30 (diff) | |
parent | 8ee77fc8d4034924c4151304e274bf65809aec39 (diff) | |
download | ffmpeg-4d5bbbadd7cd8ffb672fb69147da8dfbde5255fa.tar.gz |
Merge remote-tracking branch 'cus/stable'
* cus/stable:
ffplay: fix invalid wanted_channel_layout calculation
ffplay: honor SDL_AUDIO_CHANNELS and make sure to use SDL supported number of audio channels
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'ffplay.c')
-rw-r--r-- | ffplay.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -2221,6 +2221,8 @@ static int stream_component_open(VideoState *is, int stream_index) AVDictionary *opts; AVDictionaryEntry *t = NULL; int64_t wanted_channel_layout = 0; + int wanted_nb_channels; + const char *env; if (stream_index < 0 || stream_index >= ic->nb_streams) return -1; @@ -2257,8 +2259,19 @@ static int stream_component_open(VideoState *is, int stream_index) avctx->flags |= CODEC_FLAG_EMU_EDGE; if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) { - wanted_channel_layout = (avctx->channel_layout && avctx->channels == av_get_channel_layout_nb_channels(avctx->channels)) ? avctx->channel_layout : av_get_default_channel_layout(avctx->channels); - wanted_channel_layout &= ~AV_CH_LAYOUT_STEREO_DOWNMIX; + env = SDL_getenv("SDL_AUDIO_CHANNELS"); + if (env) + wanted_channel_layout = av_get_default_channel_layout(SDL_atoi(env)); + if (!wanted_channel_layout) { + wanted_channel_layout = (avctx->channel_layout && avctx->channels == av_get_channel_layout_nb_channels(avctx->channel_layout)) ? avctx->channel_layout : av_get_default_channel_layout(avctx->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 > 6)) { + 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 = avctx->sample_rate; if (wanted_spec.freq <= 0 || wanted_spec.channels <= 0) { |