[FFmpeg-cvslog] ffplay: remove VideoState from audio_open

Marton Balint git at videolan.org
Mon Jun 4 23:39:46 CEST 2012


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Apr 14 18:07:58 2012 +0200| [734203797347ed9ded31741404010ee09c9023c9] | committer: Marton Balint

ffplay: remove VideoState from audio_open

Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=734203797347ed9ded31741404010ee09c9023c9
---

 ffplay.c |   20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/ffplay.c b/ffplay.c
index 8ccb815..993ee52 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;



More information about the ffmpeg-cvslog mailing list