[xiph-commits] r3032 - liboggplay/trunk/src/liboggplay
shans at svn.annodex.net
shans at svn.annodex.net
Sun Jun 24 17:55:39 PDT 2007
Author: shans
Date: 2007-06-24 17:55:38 -0700 (Sun, 24 Jun 2007)
New Revision: 3032
Modified:
liboggplay/trunk/src/liboggplay/oggplay.c
liboggplay/trunk/src/liboggplay/oggplay_private.h
liboggplay/trunk/src/liboggplay/oggplay_seek.c
Log:
Mostly fixed the memory leak by adding a cleanup function for trash
Modified: liboggplay/trunk/src/liboggplay/oggplay.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-25 00:03:40 UTC (rev 3031)
+++ liboggplay/trunk/src/liboggplay/oggplay.c 2007-06-25 00:55:38 UTC (rev 3032)
@@ -67,6 +67,7 @@
me->active_tracks = 0;
me->buffer = NULL;
me->shutdown = 0;
+ me->trash = NULL;
return me;
@@ -375,6 +376,16 @@
}
/*
+ * clean up any trash pointers. As soon as the current buffer has a
+ * frame taken out, we know the old buffer will no longer be used.
+ */
+
+ if (me->trash != NULL && me->buffer->last_emptied > -1) {
+ oggplay_take_out_trash(me, me->trash);
+ me->trash = NULL;
+ }
+
+ /*
* make sure the buffer has actually got some space
*/
if ((me->buffer != NULL) && oggplay_buffer_is_full(me->buffer)) {
Modified: liboggplay/trunk/src/liboggplay/oggplay_private.h
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_private.h 2007-06-25 00:03:40 UTC (rev 3031)
+++ liboggplay/trunk/src/liboggplay/oggplay_private.h 2007-06-25 00:55:38 UTC (rev 3032)
@@ -193,7 +193,10 @@
void
oggplay_set_data_callback_force(OggPlay *me, OggPlayDataCallback callback,
void *user);
-
+
+void
+oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash);
+
#include "oggplay_callback.h"
#include "oggplay_data.h"
#include "oggplay_buffer.h"
Modified: liboggplay/trunk/src/liboggplay/oggplay_seek.c
===================================================================
--- liboggplay/trunk/src/liboggplay/oggplay_seek.c 2007-06-25 00:03:40 UTC (rev 3031)
+++ liboggplay/trunk/src/liboggplay/oggplay_seek.c 2007-06-25 00:55:38 UTC (rev 3032)
@@ -103,7 +103,18 @@
me->presentation_time /= me->callback_period;
me->presentation_time *= me->callback_period;
me->target = me->presentation_time + me->callback_period;
-
+
+ me->trash = trash;
+
return E_OGGPLAY_OK;
}
+
+void
+oggplay_take_out_trash(OggPlay *me, OggPlaySeekTrash *trash) {
+
+ oggplay_buffer_shutdown(me, trash->old_buffer);
+ oggplay_data_free_list(trash->old_data);
+ free(trash);
+
+}
More information about the commits
mailing list