[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[336] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2012-11-12 09:27:33
|
Revision: 336 http://mplayerxp.svn.sourceforge.net/mplayerxp/?rev=336&view=rev Author: nickols_k Date: 2012-11-12 09:27:21 +0000 (Mon, 12 Nov 2012) Log Message: ----------- remove duplicate stuff Modified Paths: -------------- mplayerxp/Makefile mplayerxp/libao2/ao_jack.c Removed Paths: ------------- mplayerxp/fifo.c mplayerxp/fifo.h Modified: mplayerxp/Makefile =================================================================== --- mplayerxp/Makefile 2012-11-12 09:23:05 UTC (rev 335) +++ mplayerxp/Makefile 2012-11-12 09:27:21 UTC (rev 336) @@ -24,7 +24,7 @@ LDFLAGS += -Wl,-rpath,${CODECDIR}/codecs SRCS_COMMON = mp_msg.c -SRCS_MPLAYER = mplayerxp.c fifo.c $(SRCS_COMMON) mp-opt-reg.c dump.c +SRCS_MPLAYER = mplayerxp.c $(SRCS_COMMON) mp-opt-reg.c dump.c OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o) Deleted: mplayerxp/fifo.c =================================================================== --- mplayerxp/fifo.c 2012-11-12 09:23:05 UTC (rev 335) +++ mplayerxp/fifo.c 2012-11-12 09:27:21 UTC (rev 336) @@ -1,86 +0,0 @@ -#include "mplayerxp.h" -#include "fifo.h" -#include "osdep/mplib.h" - -static inline int min(int a,int b) { return (a<b)?a:b; }; - -/* === Circular Buffer FIFO support === */ - -CBFifoBuffer *cb_fifo_alloc(unsigned int size) -{ - CBFifoBuffer *f= mp_mallocz(sizeof(CBFifoBuffer)); - if(!f) - return NULL; - f->buffer = mp_malloc(size); - f->end = f->buffer + size; - cb_fifo_reset(f); - if (!f->buffer) - mp_free(f); - return f; -} - -int cb_fifo_realloc2(CBFifoBuffer *f, unsigned int new_size) { - unsigned int old_size= f->end - f->buffer; - - if(old_size < new_size){ - int len= cb_fifo_size(f); - CBFifoBuffer *f2= cb_fifo_alloc(new_size); - - if (!f2) - return -1; - cb_fifo_generic_read(f, f2->buffer, len, NULL); - f2->wptr += len; - f2->wndx += len; - mp_free(f->buffer); - *f= *f2; - mp_free(f2); - } - return 0; -} - -void cb_fifo_free(CBFifoBuffer *f) -{ - if(f){ - mp_free(f->buffer); - mp_free(f); - } -} - -int cb_fifo_generic_write(CBFifoBuffer *f, any_t*src, int size, int (*func)(any_t*, any_t*, int)) -{ - int total = size; - do { - int len = min(f->end - f->wptr, size); - if(func) { - if(func(src, f->wptr, len) <= 0) - break; - } else { - memcpy(f->wptr, src, len); - src = (uint8_t*)src + len; - } -// Write memory barrier needed for SMP here in theory - f->wptr += len; - if (f->wptr >= f->end) - f->wptr = f->buffer; - f->wndx += len; - size -= len; - } while (size > 0); - return total - size; -} - -int cb_fifo_generic_read(CBFifoBuffer *f, any_t*dest, int buf_size, void (*func)(any_t*, any_t*, int)) -{ -// Read memory barrier needed for SMP here in theory - do { - int len = min(f->end - f->rptr, buf_size); - if(func) func(dest, f->rptr, len); - else{ - memcpy(dest, f->rptr, len); - dest = (uint8_t*)dest + len; - } -// memory barrier needed for SMP here in theory - cb_fifo_drain(f, len); - buf_size -= len; - } while (buf_size > 0); - return 0; -} Deleted: mplayerxp/fifo.h =================================================================== --- mplayerxp/fifo.h 2012-11-12 09:23:05 UTC (rev 335) +++ mplayerxp/fifo.h 2012-11-12 09:27:21 UTC (rev 336) @@ -1,117 +0,0 @@ -/** - * @file libavutil/fifo.h - * a very simple circular buffer FIFO implementation - */ -#include "mp_config.h" -#include "mp_msg.h" - -#include <stdint.h> -#include <stddef.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -// Note: this suff really is used by ao_jack only - -typedef struct CBFifoBuffer { - uint8_t *buffer; - uint8_t *rptr, *wptr, *end; - uint32_t rndx, wndx; -} CBFifoBuffer; - -/** - * Initializes an CBFifoBuffer. - * @param size of FIFO - * @return CBFifoBuffer or NULL if mem allocation failure - */ -CBFifoBuffer *cb_fifo_alloc(unsigned int size); - -/** - * Frees an CBFifoBuffer. - * @param *f CBFifoBuffer to mp_free - */ -void cb_fifo_free(CBFifoBuffer *f); - -/** - * Resets the CBFifoBuffer to the state right after cb_fifo_alloc, in particular it is emptied. - * @param *f CBFifoBuffer to reset - */ -static inline void cb_fifo_reset(CBFifoBuffer *f) -{ - f->wptr = f->rptr = f->buffer; - f->wndx = f->rndx = 0; -} - -/** - * Returns the amount of data in bytes in the CBFifoBuffer, that is the - * amount of data you can read from it. - * @param *f CBFifoBuffer to read from - * @return size - */ -static inline int cb_fifo_size(CBFifoBuffer *f) -{ - return (uint32_t)(f->wndx - f->rndx); -} - -/** - * Returns the amount of space in bytes in the CBFifoBuffer, that is the - * amount of data you can write into it. - * @param *f CBFifoBuffer to write into - * @return size - */ -static inline int cb_fifo_space(CBFifoBuffer *f) -{ - return f->end - f->buffer - cb_fifo_size(f); -} - -/** - * Feeds data from an CBFifoBuffer to a user-supplied callback. - * @param *f CBFifoBuffer to read from - * @param buf_size number of bytes to read - * @param *func generic read function - * @param *dest data destination - */ -int cb_fifo_generic_read(CBFifoBuffer *f, any_t*dest, int buf_size, void (*func)(any_t*, any_t*, int)); - -/** - * Feeds data from a user-supplied callback to an CBFifoBuffer. - * @param *f CBFifoBuffer to write to - * @param *src data source - * @param size number of bytes to write - * @param *func generic write function; the first parameter is src, - * the second is dest_buf, the third is dest_buf_size. - * func must return the number of bytes written to dest_buf, or <= 0 to - * indicate no more data available to write. - * If func is NULL, src is interpreted as a simple byte array for source data. - * @return the number of bytes written to the FIFO - */ -int cb_fifo_generic_write(CBFifoBuffer *f, any_t*src, int size, int (*func)(any_t*, any_t*, int)); - -/** - * Resizes an CBFifoBuffer. - * @param *f CBFifoBuffer to resize - * @param size new CBFifoBuffer size in bytes - * @return <0 for failure, >=0 otherwise - */ -int cb_fifo_realloc2(CBFifoBuffer *f, unsigned int size); - -/** - * Reads and discards the specified amount of data from an CBFifoBuffer. - * @param *f CBFifoBuffer to read from - * @param size amount of data to read in bytes - */ -static inline void cb_fifo_drain(CBFifoBuffer *f, int size) -{ - f->rptr += size; - if (f->rptr >= f->end) - f->rptr -= f->end - f->buffer; - f->rndx += size; -} - -static inline uint8_t cb_fifo_peek(CBFifoBuffer *f, int offs) -{ - uint8_t *ptr = f->rptr + offs; - if (ptr >= f->end) - ptr -= f->end - f->buffer; - return *ptr; -} Modified: mplayerxp/libao2/ao_jack.c =================================================================== --- mplayerxp/libao2/ao_jack.c 2012-11-12 09:23:05 UTC (rev 335) +++ mplayerxp/libao2/ao_jack.c 2012-11-12 09:27:21 UTC (rev 336) @@ -36,7 +36,7 @@ #include "osdep/mplib.h" #include "ao_msg.h" -#include "fifo.h" +#include "libavutil/fifo.h" #include <jack/jack.h> static const ao_info_t info = @@ -63,7 +63,7 @@ volatile float callback_interval; volatile float callback_time; - CBFifoBuffer * buffer; //! buffer for audio data + AVFifoBuffer * buffer; //! buffer for audio data }priv_t; @@ -85,9 +85,9 @@ */ static int write_buffer(ao_data_t* ao,unsigned char* data, int len) { priv_t*priv=ao->priv; - int _free = cb_fifo_space(priv->buffer); + int _free = av_fifo_space(priv->buffer); if (len > _free) len = _free; - return cb_fifo_generic_write(priv->buffer, data, len, NULL); + return av_fifo_generic_write(priv->buffer, data, len, NULL); } static void silence(float **bufs, int cnt, int num_bufs); @@ -129,12 +129,12 @@ static unsigned read_buffer(ao_data_t* ao,float **bufs, unsigned cnt, unsigned num_bufs) { priv_t*priv=ao->priv; struct deinterleave di = {bufs, num_bufs, 0, 0}; - unsigned buffered = cb_fifo_size(priv->buffer); + unsigned buffered = av_fifo_size(priv->buffer); if (cnt * sizeof(float) * num_bufs > buffered) { silence(bufs, cnt, num_bufs); cnt = buffered / sizeof(float) / num_bufs; } - cb_fifo_generic_read(priv->buffer, &di, cnt * num_bufs * sizeof(float), deinterleave); + av_fifo_generic_read(priv->buffer, &di, cnt * num_bufs * sizeof(float), deinterleave); return cnt; } @@ -259,7 +259,7 @@ MSG_FATAL("[JACK] cannot open server\n"); goto err_out; } - priv->buffer = cb_fifo_alloc(BUFFSIZE); + priv->buffer = av_fifo_alloc(BUFFSIZE); jack_set_process_callback(priv->client, outputaudio, ao); // list matching priv->ports @@ -316,7 +316,7 @@ mp_free(port_name); mp_free(client_name); if (priv->client) jack_client_close(priv->client); - cb_fifo_free(priv->buffer); + av_fifo_free(priv->buffer); priv->buffer = NULL; return MPXP_False; } @@ -328,7 +328,7 @@ reset(ao); usec_sleep(100 * 1000); jack_client_close(priv->client); - cb_fifo_free(priv->buffer); + av_fifo_free(priv->buffer); priv->buffer = NULL; mp_free(priv); } @@ -339,7 +339,7 @@ static void reset(ao_data_t* ao) { priv_t*priv=ao->priv; priv->paused = 1; - cb_fifo_reset(priv->buffer); + av_fifo_reset(priv->buffer); priv->paused = 0; } @@ -361,7 +361,7 @@ static unsigned get_space(ao_data_t* ao) { priv_t*priv=ao->priv; - return cb_fifo_space(priv->buffer); + return av_fifo_space(priv->buffer); } /** @@ -376,7 +376,7 @@ static float get_delay(ao_data_t* ao) { priv_t*priv=ao->priv; - int buffered = cb_fifo_size(priv->buffer); // could be less + int buffered = av_fifo_size(priv->buffer); // could be less float in_jack = priv->latency; if (priv->estimate && priv->callback_interval > 0) { float elapsed = (float)GetTimer() / 1000000.0 - priv->callback_time; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |