Commit e98cd24a authored by Marton Balint's avatar Marton Balint

ffplay: precalculate audio output frame size and byte per sec

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent f4c62b9f
...@@ -145,6 +145,8 @@ typedef struct AudioParams { ...@@ -145,6 +145,8 @@ typedef struct AudioParams {
int channels; int channels;
int64_t channel_layout; int64_t channel_layout;
enum AVSampleFormat fmt; enum AVSampleFormat fmt;
int frame_size;
int bytes_per_sec;
} AudioParams; } AudioParams;
typedef struct Clock { typedef struct Clock {
...@@ -2468,6 +2470,12 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb ...@@ -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->freq = spec.freq;
audio_hw_params->channel_layout = wanted_channel_layout; audio_hw_params->channel_layout = wanted_channel_layout;
audio_hw_params->channels = spec.channels; 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; return spec.size;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment