summaryrefslogtreecommitdiff
path: root/ffplay.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2012-04-14 18:07:58 +0200
committerMarton Balint <cus@passwd.hu>2012-06-02 19:46:00 +0200
commit734203797347ed9ded31741404010ee09c9023c9 (patch)
tree241a40612e3dbcb67279e3fdf77e3c5087671631 /ffplay.c
parente1248f5c52124f9c5a7f5a1101a37d1c86ac710d (diff)
ffplay: remove VideoState from audio_open
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ffplay.c b/ffplay.c
index 8ccb815dcb..993ee52c49 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2242,7 +2242,7 @@ static void sdl_audio_callback(void *opaque, Uint8 *stream, int len)
is->audio_current_pts_drift = is->audio_current_pts - audio_callback_time / 1000000.0;
}
-static int audio_open(VideoState *is, int64_t channel_layout, int channels, int sample_rate)
+static int audio_open(void *opaque, int64_t channel_layout, int channels, int sample_rate, struct AudioParams *audio)
{
SDL_AudioSpec wanted_spec, spec;
const char *env;
@@ -2272,7 +2272,7 @@ static int audio_open(VideoState *is, int64_t channel_layout, int channels, int
wanted_spec.silence = 0;
wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
wanted_spec.callback = sdl_audio_callback;
- wanted_spec.userdata = is;
+ wanted_spec.userdata = opaque;
if (SDL_OpenAudio(&wanted_spec, &spec) < 0) {
fprintf(stderr, "SDL_OpenAudio: %s\n", SDL_GetError());
return -1;
@@ -2289,12 +2289,11 @@ static int audio_open(VideoState *is, int64_t channel_layout, int channels, int
}
}
- is->audio_hw_buf_size = spec.size;
- is->audio_src.fmt = is->audio_tgt.fmt = AV_SAMPLE_FMT_S16;
- is->audio_src.freq = is->audio_tgt.freq = spec.freq;
- is->audio_src.channel_layout = is->audio_tgt.channel_layout = wanted_channel_layout;
- is->audio_src.channels = is->audio_tgt.channels = spec.channels;
- return 0;
+ audio->fmt = AV_SAMPLE_FMT_S16;
+ audio->freq = spec.freq;
+ audio->channel_layout = wanted_channel_layout;
+ audio->channels = spec.channels;
+ return spec.size;
}
/* open a given stream. Return 0 if OK */
@@ -2351,8 +2350,11 @@ static int stream_component_open(VideoState *is, int stream_index)
/* prepare audio output */
if (avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
- if (audio_open(is, avctx->channel_layout, avctx->channels, avctx->sample_rate) < 0)
+ int audio_hw_buf_size = audio_open(is, avctx->channel_layout, avctx->channels, avctx->sample_rate, &is->audio_src);
+ if (audio_hw_buf_size < 0)
return -1;
+ is->audio_hw_buf_size = audio_hw_buf_size;
+ is->audio_tgt = is->audio_src;
}
ic->streams[stream_index]->discard = AVDISCARD_DEFAULT;