aboutsummaryrefslogtreecommitdiffstats
path: root/ffplay.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2011-10-02 11:00:40 +0200
committerMarton Balint <cus@passwd.hu>2011-10-02 21:21:46 +0200
commit2446a8cc0a4d6c848f80a3c0a5917a4b4b9f3259 (patch)
tree3c9702818030736606afdae2e1c9d1f236a8a814 /ffplay.c
parent1e7f7dc2d1d7867bbec8a5a1f5841fe969ac902a (diff)
downloadffmpeg-2446a8cc0a4d6c848f80a3c0a5917a4b4b9f3259.tar.gz
ffplay: use avctx->channels and avctx->freq before avcodec_open2 consistently
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ffplay.c b/ffplay.c
index 66a17e813b..d346bc5cc9 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2183,8 +2183,15 @@ static int stream_component_open(VideoState *is, int stream_index)
if(codec->capabilities & CODEC_CAP_DR1)
avctx->flags |= CODEC_FLAG_EMU_EDGE;
- wanted_spec.freq = avctx->sample_rate;
- wanted_spec.channels = avctx->channels;
+ if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+ if(avctx->sample_rate <= 0 || avctx->channels <= 0){
+ fprintf(stderr, "Invalid sample rate or channel count\n");
+ return -1;
+ }
+ wanted_spec.freq = avctx->sample_rate;
+ wanted_spec.channels = avctx->channels;
+ }
+
if (!codec ||
avcodec_open2(avctx, codec, &opts) < 0)
return -1;
@@ -2195,10 +2202,6 @@ static int stream_component_open(VideoState *is, int stream_index)
/* prepare audio output */
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
- if(avctx->sample_rate <= 0 || avctx->channels <= 0){
- fprintf(stderr, "Invalid sample rate or channel count\n");
- return -1;
- }
wanted_spec.format = AUDIO_S16SYS;
wanted_spec.silence = 0;
wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
@@ -2225,7 +2228,7 @@ static int stream_component_open(VideoState *is, int stream_index)
is->audio_diff_avg_count = 0;
/* since we do not have a precise anough audio fifo fullness,
we correct audio sync only if larger than this threshold */
- is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / avctx->sample_rate;
+ is->audio_diff_threshold = 2.0 * SDL_AUDIO_BUFFER_SIZE / wanted_spec.freq;
memset(&is->audio_pkt, 0, sizeof(is->audio_pkt));
packet_queue_init(&is->audioq);