[xiph-cvs] cvs commit: ogg/src buffer.c ogginternal.h stream.c sync.c

Monty xiphmont at xiph.org
Thu Mar 27 13:38:16 PST 2003



xiphmont    03/03/27 16:38:16

  Modified:    include/ogg2 Tag: libogg2-zerocopy os_types.h
               src      Tag: libogg2-zerocopy buffer.c ogginternal.h
                        stream.c sync.c
  Log:
  Adding to unit tests:  mem management fixes, chasing down one more memory leak.

Revision  Changes    Path
No                   revision

<p>No                   revision

<p>1.1.2.4   +1 -1      ogg/include/ogg2/Attic/os_types.h

Index: os_types.h
===================================================================
RCS file: /usr/local/cvsroot/ogg/include/ogg2/Attic/os_types.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- os_types.h	27 Mar 2003 09:20:09 -0000	1.1.2.3
+++ os_types.h	27 Mar 2003 21:38:16 -0000	1.1.2.4
@@ -5,13 +5,13 @@
  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
  *                                                                  *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-200             *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2003             *
  * by the Xiph.Org Foundation http://www.xiph.org/                  *
  *                                                                  *
  ********************************************************************
 
  function: #ifdef jail to whip a few platforms into the UNIX ideal.
- last mod: $Id: os_types.h,v 1.1.2.3 2003/03/27 09:20:09 xiphmont Exp $
+ last mod: $Id: os_types.h,v 1.1.2.4 2003/03/27 21:38:16 xiphmont Exp $
 
  ********************************************************************/
 #ifndef _OS_TYPES_H

<p><p>No                   revision

<p>No                   revision

<p>1.1.2.13  +19 -1     ogg/src/Attic/buffer.c

Index: buffer.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/buffer.c,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -r1.1.2.12 -r1.1.2.13
--- buffer.c	27 Mar 2003 09:10:14 -0000	1.1.2.12
+++ buffer.c	27 Mar 2003 21:38:16 -0000	1.1.2.13
@@ -11,7 +11,7 @@
  ********************************************************************
 
   function: centralized fragment buffer management
-  last mod: $Id: buffer.c,v 1.1.2.12 2003/03/27 09:10:14 xiphmont Exp $
+  last mod: $Id: buffer.c,v 1.1.2.13 2003/03/27 21:38:16 xiphmont Exp $
 
  ********************************************************************/
 
@@ -48,6 +48,14 @@
   ogg_reference *rt;
 
   if(bs->shutdown){
+
+#ifdef OGGBUFFER_DEBUG
+    fprintf(stderr,"\nZero-copy pool %p lazy destroy: %d buffers outstanding.\n",
+	    bs,bs->outstanding);
+    if(!bs->outstanding)
+      fprintf(stderr,"Finishing memory cleanup of %p.\n",bs);
+#endif
+
     bt=bs->unused_buffers;
     rt=bs->unused_references;
 
@@ -55,6 +63,7 @@
       ogg_mutex_unlock(&bs->mutex);
       ogg_mutex_clear(&bs->mutex);
       _ogg_free(bs);
+      return;
     }else
       ogg_mutex_unlock(&bs->mutex);
 
@@ -64,11 +73,13 @@
       if(b->data)_ogg_free(b->data);
       _ogg_free(b);
     }
+    bs->unused_buffers=0;
     while(rt){
       ogg_reference *r=rt;
       rt=r->next;
       _ogg_free(r);
     }
+    bs->unused_references=0;
   }
 }
 
@@ -468,4 +479,11 @@
     or=or->next;
   }
   return count;
+}
+
+void ogg_buffer_outstanding(ogg_buffer_state *bs){
+#ifdef OGGBUFFER_DEBUG
+  fprintf(stderr,"Zero-copy pool %p: %d buffers outstanding.\n",
+	  bs,bs->outstanding);
+#endif
 }

<p><p>1.1.2.13  +27 -26    ogg/src/Attic/ogginternal.h

Index: ogginternal.h
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/ogginternal.h,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -r1.1.2.12 -r1.1.2.13
--- ogginternal.h	27 Mar 2003 07:12:45 -0000	1.1.2.12
+++ ogginternal.h	27 Mar 2003 21:38:16 -0000	1.1.2.13
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: internal/hidden data representation structures
- last mod: $Id: ogginternal.h,v 1.1.2.12 2003/03/27 07:12:45 xiphmont Exp $
+ last mod: $Id: ogginternal.h,v 1.1.2.13 2003/03/27 21:38:16 xiphmont Exp $
 
  ********************************************************************/
 
@@ -134,35 +134,36 @@
 };
 
 extern ogg_buffer_state *ogg_buffer_create(void);
-extern void           ogg_buffer_destroy(ogg_buffer_state *bs);
-extern ogg_reference *ogg_buffer_alloc(ogg_buffer_state *bs,long bytes);
-extern void           ogg_buffer_realloc(ogg_reference *or,long bytes);
-extern ogg_reference *ogg_buffer_dup(ogg_reference *or,long begin,long length);
-extern ogg_reference *ogg_buffer_extend(ogg_reference *or,long bytes);
-extern void           ogg_buffer_mark(ogg_reference *or);
-extern void           ogg_buffer_release(ogg_reference *or);
-extern void           ogg_buffer_release_one(ogg_reference *or);
-extern ogg_reference *ogg_buffer_pretruncate(ogg_reference *or,long pos);
-extern void           ogg_buffer_posttruncate(ogg_reference *or,long pos);
-extern ogg_reference *ogg_buffer_cat(ogg_reference *tail, ogg_reference *head);
-extern ogg_reference *ogg_buffer_walk(ogg_reference *or);
-extern long           ogg_buffer_length(ogg_reference *or);
-extern ogg_reference *ogg_buffer_split(ogg_reference **tail,
+extern void              ogg_buffer_destroy(ogg_buffer_state *bs);
+extern ogg_reference    *ogg_buffer_alloc(ogg_buffer_state *bs,long bytes);
+extern void              ogg_buffer_realloc(ogg_reference *or,long bytes);
+extern ogg_reference    *ogg_buffer_dup(ogg_reference *or,long begin,long length);
+extern ogg_reference    *ogg_buffer_extend(ogg_reference *or,long bytes);
+extern void              ogg_buffer_mark(ogg_reference *or);
+extern void              ogg_buffer_release(ogg_reference *or);
+extern void              ogg_buffer_release_one(ogg_reference *or);
+extern ogg_reference    *ogg_buffer_pretruncate(ogg_reference *or,long pos);
+extern void              ogg_buffer_posttruncate(ogg_reference *or,long pos);
+extern ogg_reference    *ogg_buffer_cat(ogg_reference *tail, ogg_reference *head);
+extern ogg_reference    *ogg_buffer_walk(ogg_reference *or);
+extern long              ogg_buffer_length(ogg_reference *or);
+extern ogg_reference    *ogg_buffer_split(ogg_reference **tail,
                                        ogg_reference **head,long pos);
+extern void              ogg_buffer_outstanding(ogg_buffer_state *bs);
 
-extern  int           oggbyte_init(oggbyte_buffer *b,ogg_reference *or,
+extern  int              oggbyte_init(oggbyte_buffer *b,ogg_reference *or,
                                    ogg_buffer_state *bs);
-extern void           oggbyte_clear(oggbyte_buffer *b);
-extern ogg_reference *oggbyte_return_and_reset(oggbyte_buffer *b);
-extern void           oggbyte_set1(oggbyte_buffer *b,unsigned char val,
+extern void              oggbyte_clear(oggbyte_buffer *b);
+extern ogg_reference    *oggbyte_return_and_reset(oggbyte_buffer *b);
+extern void              oggbyte_set1(oggbyte_buffer *b,unsigned char val,
                                    int pos);
-extern void           oggbyte_set2(oggbyte_buffer *b,int val,int pos);
-extern void           oggbyte_set4(oggbyte_buffer *b,ogg_uint32_t val,int pos);
-extern void           oggbyte_set8(oggbyte_buffer *b,ogg_int64_t val,int pos);
-extern unsigned char  oggbyte_read1(oggbyte_buffer *b,int pos);
-extern int            oggbyte_read2(oggbyte_buffer *b,int pos);
-extern ogg_uint32_t   oggbyte_read4(oggbyte_buffer *b,int pos);
-extern ogg_int64_t    oggbyte_read8(oggbyte_buffer *b,int pos);
+extern void              oggbyte_set2(oggbyte_buffer *b,int val,int pos);
+extern void              oggbyte_set4(oggbyte_buffer *b,ogg_uint32_t val,int pos);
+extern void              oggbyte_set8(oggbyte_buffer *b,ogg_int64_t val,int pos);
+extern unsigned char     oggbyte_read1(oggbyte_buffer *b,int pos);
+extern int               oggbyte_read2(oggbyte_buffer *b,int pos);
+extern ogg_uint32_t      oggbyte_read4(oggbyte_buffer *b,int pos);
+extern ogg_int64_t       oggbyte_read8(oggbyte_buffer *b,int pos);
 
 #ifdef _V_SELFTEST
 #define OGGPACK_CHUNKSIZE 3

<p><p>1.1.2.9   +52 -7     ogg/src/Attic/stream.c

Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/stream.c,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- stream.c	27 Mar 2003 09:10:14 -0000	1.1.2.8
+++ stream.c	27 Mar 2003 21:38:16 -0000	1.1.2.9
@@ -12,7 +12,7 @@
 
  function: code raw packets into framed Ogg logical stream and
            decode Ogg logical streams back into raw packets
- last mod: $Id: stream.c,v 1.1.2.8 2003/03/27 09:10:14 xiphmont Exp $
+ last mod: $Id: stream.c,v 1.1.2.9 2003/03/27 21:38:16 xiphmont Exp $
 
  ********************************************************************/
 
@@ -850,10 +850,6 @@
   int eosflag=0;
   int bosflag=0;
     
-  ogg_stream_reset(os_en);
-  ogg_stream_reset(os_de);
-  ogg_sync_reset(oy);
-
   for(packets=0;;packets++)if(pl[packets]==-1)break;
 
   for(i=0;i<packets;i++){
@@ -977,6 +973,7 @@
             }
           }
         }
+	ogg_page_release(&og);
       }
     }
   }
@@ -1007,6 +1004,16 @@
   }
   fprintf(stderr,"ok.\n");
 
+  ogg_stream_reset(os_en);
+  ogg_stream_reset(os_de);
+  ogg_sync_reset(oy);
+
+
+  ogg_buffer_outstanding(os_en->bufferpool);
+  ogg_buffer_outstanding(os_de->bufferpool);
+  ogg_buffer_outstanding(oy->bufferpool);
+  ogg_buffer_outstanding(bs);
+
 }
 
 int main(void){
@@ -1159,7 +1166,11 @@
         exit(1);
       }
     }
-
+    if(ogg_stream_pageout(os_en,&og[0])>0){
+      fprintf(stderr,"Too many pages output building sync tests!\n");
+      exit(1);
+    }
+    
     /* Test lost pages on pagein/packetout: no rollback */
     {
       ogg_page temp;
@@ -1191,18 +1202,24 @@
       
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,0,0,0);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,100,1,-1);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,4079,2,3000);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=OGG_HOLE){
         fprintf(stderr,"Error: loss of page did not return error\n");
         exit(1);
       }
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,76,5,-1);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,34,6,-1);
+      ogg_packet_release(&test);
       fprintf(stderr,"ok.\n");
     }
 
@@ -1239,18 +1256,24 @@
       
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,0,0,0);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,100,1,-1);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,4079,2,3000);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,2956,3,4000);
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=OGG_HOLE){
         fprintf(stderr,"Error: loss of page did not return error\n");
         exit(1);
       }
+      ogg_packet_release(&test);
       if(ogg_stream_packetout(os_de,&test)!=1)error();
       checkpacket(&test,300,13,14000);
+      ogg_packet_release(&test);
       fprintf(stderr,"ok.\n");
     }
     
@@ -1263,30 +1286,36 @@
       bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
       ogg_sync_wrote(oy,3);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       
       /* Test fractional page inputs: incomplete fixed header */
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,3);
       ogg_sync_wrote(oy,20);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       
       /* Test fractional page inputs: incomplete header */
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,23);
       ogg_sync_wrote(oy,5);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       
       /* Test fractional page inputs: incomplete body */
       
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,28);
       ogg_sync_wrote(oy,ogg_buffer_length(og[1].header)-28);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       
       bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body);
       ogg_sync_wrote(oy,1000);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].body)),og[1].body,1000);
       ogg_sync_wrote(oy,ogg_buffer_length(og[1].body)-1000);
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
       
       fprintf(stderr,"ok.\n");
     }
@@ -1306,7 +1335,9 @@
       bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header);
       ogg_sync_wrote(oy,20);
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
 
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[1].header)),og[1].header,20);
       ogg_sync_wrote(oy,ogg_buffer_length(og[1].header)-20);
@@ -1315,6 +1346,7 @@
       ogg_sync_wrote(oy,ogg_buffer_length(og[1].body));
 
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
 
       fprintf(stderr,"ok.\n");
     }
@@ -1339,8 +1371,11 @@
       ogg_sync_wrote(oy,20);
 
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
 
       bufcpy2(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].header)),og[2].header,20);
       ogg_sync_wrote(oy,ogg_buffer_length(og[2].header)-20);
@@ -1348,6 +1383,7 @@
       bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].body)),og[2].body);
       ogg_sync_wrote(oy,ogg_buffer_length(og[2].body));
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
 
       fprintf(stderr,"ok.\n");
     }
@@ -1373,6 +1409,7 @@
       ogg_sync_wrote(oy,ogg_buffer_length(og[2].header));
 
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
 
       bufcpy(ogg_sync_bufferin(oy,ogg_buffer_length(og[2].body)),og[2].body);
       ogg_sync_wrote(oy,ogg_buffer_length(og[2].body)-5);
@@ -1384,11 +1421,19 @@
       ogg_sync_wrote(oy,ogg_buffer_length(og[3].body));
 
       if(ogg_sync_pageout(oy,&og_de)>0)error();
+      ogg_page_release(&og_de);
       if(ogg_sync_pageout(oy,&og_de)<=0)error();
+      ogg_page_release(&og_de);
 
       fprintf(stderr,"ok.\n");
     }
-  }    
+    ogg_stream_destroy(os_en);
+    for(i=0;i<5;i++)
+      ogg_page_release(&og[i]);
+  }
+
+  ogg_stream_destroy(os_de);
+  ogg_sync_destroy(oy);
 
   ogg_buffer_destroy(bs);
   return 0;

<p><p>1.1.2.10  +2 -1      ogg/src/Attic/sync.c

Index: sync.c
===================================================================
RCS file: /usr/local/cvsroot/ogg/src/Attic/sync.c,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- sync.c	27 Mar 2003 09:10:14 -0000	1.1.2.9
+++ sync.c	27 Mar 2003 21:38:16 -0000	1.1.2.10
@@ -12,7 +12,7 @@
 
  function: decode stream sync and memory management foundation code;
            takes in raw data, spits out packets
- last mod: $Id: sync.c,v 1.1.2.9 2003/03/27 09:10:14 xiphmont Exp $
+ last mod: $Id: sync.c,v 1.1.2.10 2003/03/27 21:38:16 xiphmont Exp $
 
  note: The CRC code is directly derived from public domain code by
  Ross Williams (ross at guest.adelaide.edu.au).  See docs/framing.html
@@ -382,6 +382,7 @@
   oy->fifo_fill+=ret;
 
  sync_out:
+  if(og)memset(og,0,sizeof(*og));
   return ret;
 }
 

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list