Commit 392acaed authored by Nicolas George's avatar Nicolas George

ALSA: fix use of period_size.

period_size is in frames, while the demuxer assumed it was in bytes,
resulting in short reads.
parent 46edd3a0
...@@ -127,11 +127,11 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt) ...@@ -127,11 +127,11 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
snd_htimestamp_t timestamp; snd_htimestamp_t timestamp;
snd_pcm_uframes_t ts_delay; snd_pcm_uframes_t ts_delay;
if (av_new_packet(pkt, s->period_size) < 0) { if (av_new_packet(pkt, s->period_size * s->frame_size) < 0) {
return AVERROR(EIO); return AVERROR(EIO);
} }
while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) { while ((res = snd_pcm_readi(s->h, pkt->data, s->period_size)) < 0) {
if (res == -EAGAIN) { if (res == -EAGAIN) {
av_free_packet(pkt); av_free_packet(pkt);
......
...@@ -45,8 +45,8 @@ typedef void (*ff_reorder_func)(const void *, void *, int); ...@@ -45,8 +45,8 @@ typedef void (*ff_reorder_func)(const void *, void *, int);
typedef struct { typedef struct {
AVClass *class; AVClass *class;
snd_pcm_t *h; snd_pcm_t *h;
int frame_size; ///< preferred size for reads and writes int frame_size; ///< bytes per sample * channels
int period_size; ///< bytes per sample * channels int period_size; ///< preferred size for reads and writes, in frames
int sample_rate; ///< sample rate set by user int sample_rate; ///< sample rate set by user
int channels; ///< number of channels set by user int channels; ///< number of channels set by user
void (*reorder_func)(const void *, void *, int); void (*reorder_func)(const void *, void *, int);
......
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