[Mplayer-cvslog] CVS: main/libmpcodecs ad_vorbis.c,1.1,1.2

Alban Bedel CVS albeu at mplayerhq.hu
Sun Apr 21 20:06:03 CEST 2002


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv26634/libmpcodecs

Modified Files:
	ad_vorbis.c 
Log Message:
Added uninit


Index: ad_vorbis.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_vorbis.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ad_vorbis.c	31 Mar 2002 20:08:19 -0000	1.1
+++ ad_vorbis.c	21 Apr 2002 18:06:00 -0000	1.2
@@ -43,7 +43,12 @@
   ogg_packet op;
   vorbis_comment vc;
   struct ov_struct_st *ov;
-
+  int error(void) {
+    vorbis_comment_clear(&vc);
+    vorbis_info_clear(&ov->vi);
+    free(ov);
+    return 0;
+  }
   /// Init the decoder with the 3 header packets
   ov = (struct ov_struct_st*)malloc(sizeof(struct ov_struct_st));
   vorbis_info_init(&ov->vi);
@@ -53,23 +58,20 @@
   /// Header
   if(vorbis_synthesis_headerin(&ov->vi,&vc,&op) <0) {
     mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis: initial (identification) header broken!\n");
-    free(ov);
-    return 0;
+    return error();
   }
   op.bytes = ds_get_packet(sh->ds,&op.packet);
   op.b_o_s  = 0;
   /// Comments
   if(vorbis_synthesis_headerin(&ov->vi,&vc,&op) <0) {
     mp_msg(MSGT_DECAUDIO,MSGL_ERR,"OggVorbis: comment header broken!\n");
-    free(ov);
-    return 0;
+    return error();
   }
   op.bytes = ds_get_packet(sh->ds,&op.packet);
   //// Codebook
   if(vorbis_synthesis_headerin(&ov->vi,&vc,&op)<0) {
     mp_msg(MSGT_DECAUDIO,MSGL_WARN,"OggVorbis: codebook header broken!\n");
-    free(ov);
-    return 0;
+    return error();;
   } else { /// Print the infos
     char **ptr=vc.user_comments;
     while(*ptr){
@@ -80,6 +82,7 @@
 	(ov->vi.bitrate_lower!=ov->vi.bitrate_nominal)||(ov->vi.bitrate_upper!=ov->vi.bitrate_nominal)?'V':'C');
     mp_msg(MSGT_DECAUDIO,MSGL_V,"OggVorbis: Encoded by: %s\n",vc.vendor);
   }
+  vorbis_comment_clear(&vc);
 
 //  printf("lower=%d  upper=%d  \n",(int)ov->vi.bitrate_lower,(int)ov->vi.bitrate_upper);
 
@@ -100,6 +103,10 @@
 
 static void uninit(sh_audio_t *sh)
 {
+  struct ov_struct_st *ov = sh->context;
+  vorbis_block_clear(&ov->vb);
+  vorbis_info_clear(&ov->vi);
+  free(ov);
 }
 
 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
@@ -122,7 +129,6 @@
         int samples;
         float **pcm;
         ogg_packet op;
-        char* np;
         struct ov_struct_st *ov = sh->context;
         op.b_o_s =  op.e_o_s = 0;
 	while(len < minlen) {




More information about the MPlayer-cvslog mailing list