[FFmpeg-devel] [PATCH] libavdevice: JACK demuxer
Michael Niedermayer
michaelni
Wed Mar 18 00:36:58 CET 2009
On Fri, Mar 13, 2009 at 09:05:38PM +0100, Olivier Guilyardi wrote:
> Attached: jack demuxer 0.10
>
> Michael Niedermayer wrote:
>
> > also, it seems libavutil/fifo.c/h could be used now (as ive fixed a
> > alignment bug) so you dont have to implement anything, just call the
> > code from fifo.*
>
> Done
>
> Changes since 0.9:
> - use libavutil fifo instead of jack ringbuffer
> - increase fifo buffers size from 4 to 16 audio packets
> - less paranoid protection against underrun
> - fix dependency on timefilter (in libavformat/Makefile)
> - rename PrivateData to JackData for consistency with other demuxers
>
> --
> Olivier
[...]
> Index: libavdevice/jack_audio.c
> ===================================================================
> --- libavdevice/jack_audio.c (revision 0)
> +++ libavdevice/jack_audio.c (revision 0)
[...]
> +#include "config.h"
> +#include <semaphore.h>
> +#include <jack/jack.h>
> +
> +#include "libavutil/log.h"
> +#include "libavutil/fifo.h"
> +#include "libavcodec/avcodec.h"
> +#include "libavformat/avformat.h"
> +#include "libavformat/timefilter.h"
> +
> +/**
> + * Size of the internal fifo buffers as a number of audio packets
> + */
> +#define FIFO_PACKETS_NUM 16
> +
> +#define FIFO_WRITE_SPACE(fifo) (fifo->end - fifo->buffer - av_fifo_size(fifo))
i would prefer if you did not use end/buffer directly but kept a private
variable that is the size
[...]
> + if (av_new_packet(&pkt, pkt_size) < 0) {
> + av_log(context, AV_LOG_ERROR, "Could not create packet of size %d\n", pkt_size);
> + return AVERROR(EIO);
> + }
> + av_fifo_generic_write(self->new_pkt_fifo, &pkt, sizeof(pkt), NULL);
it should be possible to use the function ptr argument of
av_fifo_generic_write to avoid the copy
[...]
> +static int audio_read_packet(AVFormatContext *context, AVPacket *pkt)
> +{
> + JackData *self = context->priv_data;
> + struct timespec timeout = {0, 0};
> + int test;
> +
> + /* Activate the jack client on first packet read. Activating the JACK client
> + * means that process_callback() starts to get called at regular interval.
> + * If we activate it in audio_read_header(), we're actually reading audio data
> + * from the device before instructed to, and that may result in an overrun. */
> + if (!self->activated && activate_jack(self, context))
> + return AVERROR(EIO);
i still think this belongs in audio_read_header()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090318/e401062b/attachment.pgp>
More information about the ffmpeg-devel
mailing list