Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2013-12-15 22:51:32 +0400
committerMarton Balint <cus@passwd.hu>2013-12-29 16:19:18 +0400
commite98cd24a8905ed3dde2023a8cdc083b5b6268776 (patch)
tree6eb80de7412172bbca94b37a398902dd63861f04 /ffplay.c
parentf4c62b9f6405f363a74818272e6e51838b55f056 (diff)
ffplay: precalculate audio output frame size and byte per sec
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffplay.c')
-rw-r--r--ffplay.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ffplay.c b/ffplay.c
index 0b5331b72f..0036bffdf3 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -145,6 +145,8 @@ typedef struct AudioParams {
int channels;
int64_t channel_layout;
enum AVSampleFormat fmt;
+ int frame_size;
+ int bytes_per_sec;
} AudioParams;
typedef struct Clock {
@@ -2468,6 +2470,12 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb
audio_hw_params->freq = spec.freq;
audio_hw_params->channel_layout = wanted_channel_layout;
audio_hw_params->channels = spec.channels;
+ audio_hw_params->frame_size = av_samples_get_buffer_size(NULL, audio_hw_params->channels, 1, audio_hw_params->fmt, 1);
+ audio_hw_params->bytes_per_sec = av_samples_get_buffer_size(NULL, audio_hw_params->channels, audio_hw_params->freq, audio_hw_params->fmt, 1);
+ if (audio_hw_params->bytes_per_sec <= 0 || audio_hw_params->frame_size <= 0) {
+ av_log(NULL, AV_LOG_ERROR, "av_samples_get_buffer_size failed\n");
+ return -1;
+ }
return spec.size;
}