# HG changeset patch # User rosfran # Date 1164914632 0 # Node ID 1799c878245138eaebc01ad568f2d5ce1dbc2703 # Parent ae6deaca5e7b704be3caa599dc947df4e09c5a3a [svn r152] Some performance optimizations and memory clean-up routines. diff -r ae6deaca5e7b -r 1799c8782451 gst-plugins-mythtv/src/gstmythtvsrc.c --- a/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Nov 30 19:03:57 2006 +0000 +++ b/gst-plugins-mythtv/src/gstmythtvsrc.c Thu Nov 30 19:23:52 2006 +0000 @@ -442,12 +442,12 @@ else goto read_error; } else if (G_UNLIKELY (read == 0) && !src->live_tv ) - goto eos; + goto done; if ( G_UNLIKELY (src->update_prog_chain) ) goto change_progchain; - src->bytes_queue = g_byte_array_append( src->bytes_queue, g_memdup( buffer->data, read ), read ); + src->bytes_queue = g_byte_array_append( src->bytes_queue, buffer->data, read ); if ( read > buffer_size_inter ) GST_WARNING_OBJECT( src, "\n\n\n[%s]\t\tINCREASED buffer size! Backend sent more than we ask him... (%d)\n\n\n", __FUNCTION__, abs( read - buffer_size_inter ) ); @@ -468,6 +468,7 @@ guint buffer_size = ( src->buffer_remain < MAX_READ_SIZE) ? src->buffer_remain : MAX_READ_SIZE; /* Create the buffer. */ + /* ret = gst_pad_alloc_buffer ( GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)), src->read_offset, buffer_size, GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf ); @@ -478,9 +479,11 @@ else goto done; } + */ + *outbuf = gst_buffer_new_and_alloc( buffer_size ); /* gets the first buffer_size bytes from the byte array buffer variable */ - guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); + //guint8 *buf = g_memdup( src->bytes_queue->data, buffer_size ); GST_DEBUG_OBJECT( src, "[%s] read from network? %s!, buffer_remain = %d\n", __FUNCTION__, read == -1 ? "NO, got from buffer" : "YES, go see the backend's log file", src->buffer_remain ); @@ -488,7 +491,7 @@ GST_BUFFER_SIZE (*outbuf) = buffer_size; GST_BUFFER_MALLOCDATA( *outbuf ) = g_malloc0( GST_BUFFER_SIZE (*outbuf) ); GST_BUFFER_DATA( *outbuf ) = GST_BUFFER_MALLOCDATA( *outbuf ); - g_memmove( GST_BUFFER_DATA( (*outbuf) ), buf, GST_BUFFER_SIZE(*outbuf) ); + g_memmove( GST_BUFFER_DATA( (*outbuf) ), src->bytes_queue->data, GST_BUFFER_SIZE(*outbuf) ); GST_BUFFER_OFFSET (*outbuf) = src->read_offset; GST_BUFFER_OFFSET_END (*outbuf) = src->read_offset + GST_BUFFER_SIZE (*outbuf);