Changeset 993:ba20ae3efe93 in roaraudio
- Timestamp:
- 12/18/08 22:52:01 (15 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/codecfilter_fishsound.c
r992 r993 28 28 29 29 int cf_fishsound_decoded_float (FishSound * fsound, float ** pcm, long frames, void * user_data) { 30 struct codecfilter_fishsound_inst * self = (struct codecfilter_fishsound_inst *) user_data; 31 struct roar_stream * stream = ROAR_STREAM(self->stream); 32 struct roar_buffer * buf; 33 int i; 34 double s; 35 union { 36 void * v; 37 char * c; 38 int16_t * i16; 39 int32_t * i32; 40 } data; 41 42 if (!self->opened) { 43 fish_sound_command(fsound, FISH_SOUND_GET_INFO, &(self->fsinfo), 44 sizeof(FishSoundInfo)); 45 } 46 47 if ( roar_buffer_new(&buf, frames*stream->info.bits*stream->info.channels) == -1 ) 48 return -1; 49 50 if ( roar_buffer_get_data(buf, &data.v) == -1 ) 51 return -1; 52 53 frames *= self->fsinfo.channels; 54 55 switch (stream->info.bits) { 56 case 8: 57 for (i = 0; i < frames; i++) { 58 s = ((float*)pcm)[i]; 59 s *= 127; 60 data.c[i] = s; 61 } 62 break; 63 case 16: 64 for (i = 0; i < frames; i++) { 65 s = ((float*)pcm)[i]; 66 s *= 32767; 67 data.i16[i] = s; 68 } 69 break; 70 case 32: 71 for (i = 0; i < frames; i++) { 72 s = ((float*)pcm)[i]; 73 s *= 2147483647; 74 data.i32[i] = s; 75 } 76 break; 77 default: 78 return -1; 79 } 80 81 if ( self->buffer == NULL ) { 82 self->buffer = buf; 83 } else { 84 roar_buffer_add(self->buffer, buf); 85 } 86 30 87 return -1; 31 88 } … … 34 91 FishSound * fsound = (FishSound *)user_data; 35 92 36 fish_sound_prepare_truncation 37 fish_sound_decode 93 fish_sound_prepare_truncation(fsound, op->granulepos, op->e_o_s); 94 fish_sound_decode(fsound, op->packet, op->bytes); 38 95 39 96 return 0; … … 56 113 self->stream = info; 57 114 self->opened = 0; 115 self->buffer = NULL; 58 116 self->fsound = fish_sound_new(FISH_SOUND_DECODE, &(self->fsinfo)); 59 117 … … 78 136 oggz_close(self->oggz); 79 137 fish_sound_delete(self->fsound); 138 139 if ( self->buffer != NULL ) 140 roar_buffer_free(self->buffer); 80 141 81 142 free(inst); … … 115 176 s->info.bits = g_sa->bits; 116 177 s->info.codec = ROAR_CODEC_NATIVE; 178 self->opened = 1; 179 errno = EAGAIN; 180 return -1; 117 181 } 118 182 -
roard/include/codecfilter_fishsound.h
r992 r993 38 38 FishSound * fsound; 39 39 OGGZ * oggz; 40 struct roar_buffer * buffer; 40 41 }; 41 42
Note: See TracChangeset
for help on using the changeset viewer.