Changeset 205:1053e00bbeb7 in roaraudio


Ignore:
Timestamp:
07/21/08 01:02:24 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

playing around with cf_vorbis*

Location:
roard
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • roard/codecfilter.c

    r201 r205  
    99  "ogg123 -q -d raw -f - -", 
    1010  cf_cmd_open, NULL, NULL, NULL, NULL, NULL}, 
     11 
     12 {ROAR_CODEC_OGG_VORBIS, "oggvorbis", "Ogg Vorbis decoder", NULL, 
     13 cf_vorbis_open, cf_vorbis_close, NULL, NULL, cf_vorbis_read, NULL}, 
    1114 
    1215 {ROAR_CODEC_FLAC, "cmd",  "ogg123", 
  • roard/codecfilter_vorbis.c

    r204 r205  
    33#include "roard.h" 
    44 
     5int cf_vorbis_open(CODECFILTER_USERDATA_T * inst, int codec, 
     6                                            struct roar_stream_server * info, 
     7                                            struct roar_codecfilter   * filter) { 
     8 struct codecfilter_vorbis_inst * self = malloc(sizeof(struct codecfilter_vorbis_inst)); 
     9 
     10 if ( !self ) 
     11  return -1; 
     12 
     13 self->current_section      = -1; 
     14 self->last_section         = -1; 
     15 self->opened               = 0; 
     16 self->stream               = info; 
     17// self->outlen               = ROAR_OUTPUT_BUFFER_SAMPLES * s->info.channels * s->info.bits / 8; // optimal size 
     18 
     19 if ( (self->in = fdopen(((struct roar_stream*)info)->fh, "r")) == NULL ) { 
     20  free((void*)self); 
     21  return -1; 
     22 } 
     23 
     24 *inst = (CODECFILTER_USERDATA_T) self; 
     25 
     26 return -1; 
     27} 
     28 
     29int cf_vorbis_close(CODECFILTER_USERDATA_T   inst) { 
     30 struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst; 
     31 
     32 if ( !inst ) 
     33  return -1; 
     34 
     35 ov_clear(&(self->vf)); 
     36 
     37 free(inst); 
     38 return -1; 
     39} 
     40 
     41int cf_vorbis_read(CODECFILTER_USERDATA_T   inst, char * buf, int len) { 
     42 struct codecfilter_vorbis_inst * self = (struct codecfilter_vorbis_inst *) inst; 
     43 long r; 
     44 
     45 if ( !self->opened == 2 ) { 
     46  if ( ov_open(self->in, &(self->vf), NULL, 0) < 0 ) { 
     47   free((void*)self); 
     48   return -1; 
     49  } 
     50 } 
     51 self->opened++; 
     52 
     53 r = ov_read(&(self->vf), buf, len, 0, 2, 1, &(self->current_section)); 
     54 
     55 if ( r == 0 ) { 
     56  // do some EOF handling... 
     57  return -1; 
     58 } else if ( r < 0 ) { 
     59  return -1; // error in stream 
     60 } else { 
     61  return r; 
     62 } 
     63} 
     64 
    565//ll 
  • roard/include/codecfilter_vorbis.h

    r204 r205  
    55 
    66#include <roaraudio.h> 
     7#include <vorbis/codec.h> 
     8#include <vorbis/vorbisfile.h> 
     9 
     10struct codecfilter_vorbis_inst { 
     11 int current_section; 
     12 int last_section; 
     13 int opened; 
     14 FILE * in; 
     15 struct roar_stream_server * stream; 
     16 OggVorbis_File vf; 
     17}; 
     18 
     19int cf_vorbis_open(CODECFILTER_USERDATA_T * inst, int codec, 
     20                                            struct roar_stream_server * info, 
     21                                            struct roar_codecfilter   * filter); 
     22 
     23int cf_vorbis_close(CODECFILTER_USERDATA_T   inst); 
     24 
     25int cf_vorbis_read(CODECFILTER_USERDATA_T   inst, char * buf, int len); 
    726 
    827#endif 
Note: See TracChangeset for help on using the changeset viewer.