"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "a52/pcm_a52.c" between
alsa-plugins-1.2.2.tar.bz2 and alsa-plugins-1.2.5.tar.bz2

About: ALSA (Advanced Linux Sound Architecture) - Additional plugins for various audio libraries and sound servers.

pcm_a52.c  (alsa-plugins-1.2.2.tar.bz2):pcm_a52.c  (alsa-plugins-1.2.5.tar.bz2)
skipping to change at line 147 skipping to change at line 147
swab(rec->outbuf, rec->outbuf, out_bytes + 8); swab(rec->outbuf, rec->outbuf, out_bytes + 8);
memset(rec->outbuf + 8 + out_bytes, 0, memset(rec->outbuf + 8 + out_bytes, 0,
rec->outbuf_size - 8 - out_bytes); rec->outbuf_size - 8 - out_bytes);
rec->remain = rec->outbuf_size / 4; rec->remain = rec->outbuf_size / 4;
rec->filled = 0; rec->filled = 0;
} }
/* write pending encoded data to the slave pcm */ /* write pending encoded data to the slave pcm */
static int write_out_pending(snd_pcm_ioplug_t *io, struct a52_ctx *rec) static int write_out_pending(snd_pcm_ioplug_t *io, struct a52_ctx *rec)
{ {
int err, ofs = 0; int err, ofs = (rec->avctx->frame_size - rec->remain) * 4;
if (! rec->remain) if (! rec->remain)
return 0; return 0;
while (rec->remain) { while (rec->remain) {
err = snd_pcm_writei(rec->slave, rec->outbuf + ofs, rec->remain); err = snd_pcm_writei(rec->slave, rec->outbuf + ofs, rec->remain);
if (err < 0) { if (err < 0) {
if (err == -EPIPE) if (err == -EPIPE)
io->state = SND_PCM_STATE_XRUN; io->state = SND_PCM_STATE_XRUN;
if (err == -EAGAIN)
break;
return err; return err;
} else if (! err) } else if (! err)
break; break;
if (err < rec->remain) if (err < rec->remain)
ofs += (rec->remain - err) * 4; ofs += (rec->remain - err) * 4;
rec->remain -= err; rec->remain -= err;
} }
if (rec->remain && ofs)
memmove(rec->outbuf, rec->outbuf + ofs, rec->remain * 4);
return 0; return 0;
} }
/* /*
* drain callback * drain callback
*/ */
#ifdef USE_AVCODEC_FRAME #ifdef USE_AVCODEC_FRAME
static void clear_remaining_planar_data(snd_pcm_ioplug_t *io) static void clear_remaining_planar_data(snd_pcm_ioplug_t *io)
{ {
struct a52_ctx *rec = io->private_data; struct a52_ctx *rec = io->private_data;
skipping to change at line 258 skipping to change at line 258
{ 0, 1, 4, 5, 2, 3 }, { 0, 1, 4, 5, 2, 3 },
#else #else
/* libavcodec older than r18540 expects A52 order */ /* libavcodec older than r18540 expects A52 order */
{ 0, 4, 1, 2, 3, 5 }, { 0, 4, 1, 2, 3, 5 },
#endif #endif
}; };
if ((err = write_out_pending(io, rec)) < 0) if ((err = write_out_pending(io, rec)) < 0)
return err; return err;
/* If there are still frames left in outbuf, we can't
* accept a full a52 frame, because this would overwrite
* the frames in outbuf. */
if (rec->remain && len)
len--;
if (size > len) if (size > len)
size = len; size = len;
dst = rec->inbuf + rec->filled * io->channels; dst = rec->inbuf + rec->filled * io->channels;
if (!use_planar(rec) && interleaved) { if (!use_planar(rec) && interleaved) {
memcpy(dst, areas->addr + offset * io->channels * 2, memcpy(dst, areas->addr + offset * io->channels * 2,
size * io->channels * 2); size * io->channels * 2);
} else { } else {
unsigned int i, ch, dst_step; unsigned int i, ch, dst_step;
short *dst1; short *dst1;
skipping to change at line 315 skipping to change at line 321
snd_pcm_uframes_t offset, snd_pcm_uframes_t offset,
snd_pcm_uframes_t size) snd_pcm_uframes_t size)
{ {
struct a52_ctx *rec = io->private_data; struct a52_ctx *rec = io->private_data;
snd_pcm_sframes_t result = 0; snd_pcm_sframes_t result = 0;
int err = 0; int err = 0;
int interleaved = check_interleaved(areas, io->channels); int interleaved = check_interleaved(areas, io->channels);
do { do {
err = fill_data(io, areas, offset, size, interleaved); err = fill_data(io, areas, offset, size, interleaved);
if (err < 0) if (err <= 0)
break; break;
offset += (unsigned int)err; offset += (unsigned int)err;
size -= (unsigned int)err; size -= (unsigned int)err;
result += err; result += err;
rec->transfer += err; rec->transfer += err;
} while (size); } while (size);
return result > 0 ? result : err; return result > 0 ? result : err;
} }
/* /*
* pointer callback * pointer callback
* *
* Calculate the current position from the delay of slave PCM * Calculate the current position from the available frames of slave PCM
*/ */
static snd_pcm_sframes_t a52_pointer(snd_pcm_ioplug_t *io) static snd_pcm_sframes_t a52_pointer(snd_pcm_ioplug_t *io)
{ {
struct a52_ctx *rec = io->private_data; struct a52_ctx *rec = io->private_data;
snd_pcm_sframes_t delay; snd_pcm_sframes_t avail;
snd_pcm_state_t state; snd_pcm_state_t state;
int err;
state = snd_pcm_state(rec->slave); state = snd_pcm_state(rec->slave);
switch (state) { switch (state) {
case SND_PCM_STATE_RUNNING: case SND_PCM_STATE_RUNNING:
case SND_PCM_STATE_DRAINING: case SND_PCM_STATE_DRAINING:
if ((err = snd_pcm_delay(rec->slave, &delay)) < 0)
return err;
break; break;
case SND_PCM_STATE_XRUN: case SND_PCM_STATE_XRUN:
case SND_PCM_STATE_SUSPENDED: case SND_PCM_STATE_SUSPENDED:
return -EPIPE; return -EPIPE;
default: default:
return 0; return 0;
} }
if (delay < 0 || delay >= (snd_pcm_sframes_t)rec->slave_buffer_size) avail = 0;
delay = 0;
delay = (snd_pcm_sframes_t)io->appl_ptr - delay; /* Write what we have from outbuf. */
if (delay < 0) { write_out_pending(io, rec);
delay += io->buffer_size;
if (delay < 0) /* If there is anything remaining in outbuf, we can't
delay = 0; * accept any full packets. */
if (rec->remain == 0)
{
/* Round the slave frames to multiples of the packet size. */
avail += (snd_pcm_avail_update(rec->slave) / rec->avctx->frame_si
ze) * rec->avctx->frame_size;
} }
delay %= io->buffer_size;
return delay; if (avail < 0)
avail = 0;
else if (avail >= io->buffer_size)
avail = io->buffer_size - 1;
return (io->appl_ptr + avail) % io->buffer_size;
} }
/* set up the fixed parameters of slave PCM hw_parmas */ /* set up the fixed parameters of slave PCM hw_parmas */
static int a52_slave_hw_params_half(struct a52_ctx *rec) static int a52_slave_hw_params_half(struct a52_ctx *rec)
{ {
int err; int err;
if ((err = snd_pcm_hw_params_malloc(&rec->hw_params)) < 0) if ((err = snd_pcm_hw_params_malloc(&rec->hw_params)) < 0)
return err; return err;
 End of changes. 11 change blocks. 
18 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)