[Vorbis-dev] [Patch] New function of libvorbis

Aoyumi aoyumi at gmail.com
Fri Sep 12 14:36:35 PDT 2008


This patch offers interface to get the library name which software uses.


Function:
char *vorbis_version_string(void);


PATCH (for libvorbis-1.2.1RC2): 
diff -crN libvorbis-1.2.1RC2/include/vorbis/codec.h libvorbis-1.2.1RC2_NI/include/vorbis/codec.h
*** libvorbis-1.2.1RC2/include/vorbis/codec.h	Mon Aug 25 05:57:44 2008
--- libvorbis-1.2.1RC2_NI/include/vorbis/codec.h	Sat Sep 13 05:00:22 2008
***************
*** 178,183 ****
--- 178,185 ----
  extern void     vorbis_dsp_clear(vorbis_dsp_state *v);
  extern double   vorbis_granule_time(vorbis_dsp_state *v,
  				    ogg_int64_t granulepos);
+ 				    
+ extern const char *vorbis_version_string(void);
  
  /* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
  
diff -crN libvorbis-1.2.1RC2/lib/info.c libvorbis-1.2.1RC2_NI/lib/info.c
*** libvorbis-1.2.1RC2/lib/info.c	Thu Sep 04 23:38:42 2008
--- libvorbis-1.2.1RC2_NI/lib/info.c	Sat Sep 13 05:20:28 2008
***************
*** 31,36 ****
--- 31,39 ----
  #include "misc.h"
  #include "os.h"
  
+ #define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.2.1RC2"
+ #define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20080501"
+ 
  /* helpers */
  static int ilog2(unsigned int v){
    int ret=0;
***************
*** 457,464 ****
  }
  
  static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
!   char temp[]="Xiph.Org libVorbis I 20080501";
!   int bytes = strlen(temp);
  
    /* preamble */  
    oggpack_write(opb,0x03,8);
--- 460,466 ----
  }
  
  static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
!   int bytes = strlen(ENCODE_VENDOR_STRING);
  
    /* preamble */  
    oggpack_write(opb,0x03,8);
***************
*** 466,472 ****
  
    /* vendor */
    oggpack_write(opb,bytes,32);
!   _v_writestring(opb,temp, bytes);
    
    /* comments */
  
--- 468,474 ----
  
    /* vendor */
    oggpack_write(opb,bytes,32);
!   _v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
    
    /* comments */
  
***************
*** 647,650 ****
--- 649,656 ----
    if(granulepos>=0)
      return((double)granulepos/v->vi->rate);
    return(-1);
+ }
+ 
+ const char *vorbis_version_string(void){
+   return GENERAL_VENDOR_STRING;
  }


More information about the Vorbis-dev mailing list