[FFmpeg-devel] [PATCH] lavdevice: SDL Audio Playback

Michael Niedermayer michaelni
Wed Dec 2 21:44:03 CET 2009


On Fri, Nov 27, 2009 at 05:38:41PM +0100, Ivo wrote:
> Hi,
> 
> The attached patch implements an SDL audio playback muxer in libavdevice. 
> Sadly, SDL does not support recording. In theory this should also enable 
> audio playback on windows/cygwin (not tested).

[...]
> +static void sdl_audio_callback(void *opaque, Uint8 *stream, int len) {
> +    AVFormatContext *s1 = opaque;
> +    SdlAudioData    *s  = s1->priv_data;
> +    int size;
> +
> +    size = av_fifo_size(s->buffer);
> +
> +    av_fifo_generic_read(s->buffer, stream, FFMIN(size,len), NULL);
> +
> +    if (size < len) {
> +        memset(stream+size, 0, len-size);
> +        av_log(s1, AV_LOG_ERROR, "buffer underrun\n");
> +    }
> +}
[...]
> +static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) {
> +    SdlAudioData *s = s1->priv_data;
> +    int counter, ret, space, size = pkt->size;
> +    uint8_t *data = pkt->data;
> +

> +    if (size*4 > s->bufsize) {
> +        if (av_fifo_realloc2(s->buffer, size*4) < 0)
> +            return AVERROR(ENOMEM);
> +        s->bufsize = size*4;
> +    }

does not look thread safe


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- 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/20091202/aba4939c/attachment.pgp>



More information about the ffmpeg-devel mailing list