Changeset 614:ba67ef04df1e in roaraudio for roard/codecfilter_speex.c
- Timestamp:
- 08/20/08 01:15:45 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/codecfilter_speex.c
r609 r614 29 29 s->info.codec = ROAR_CODEC_DEFAULT; 30 30 s->info.bits = 16; // speex hardcoded 31 s->info.channels = 1; // only mono support at the moment31 s->info.channels = 1; // only mono support at the moment 32 32 33 33 *inst = (void*) self; … … 72 72 int still_todo = len / 2 /* 16 bit */; 73 73 int ret = 0; 74 75 ROAR_WARN("cf_speex_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len); 74 int fs2; // = self->frame_size * 2; 75 char magic[ROAR_SPEEX_MAGIC_LEN]; 76 77 ROAR_DBG("cf_speex_read(inst=%p, buf=%p, len=%i) = ?", inst, buf, len); 76 78 77 79 if ( ! self->decoder ) { 78 80 ROAR_DBG("cf_speex_read(*): no decoder, starting one!"); 81 82 if ( stream_vio_s_read(self->stream, magic, ROAR_SPEEX_MAGIC_LEN) != ROAR_SPEEX_MAGIC_LEN ) 83 return 0; 84 85 if ( memcmp(magic, ROAR_SPEEX_MAGIC, ROAR_SPEEX_MAGIC_LEN) != 0 ) 86 return -1; 87 79 88 if ( stream_vio_s_read(self->stream, &ui, 2) != 2 ) 80 89 return 0; … … 97 106 speex_decoder_ctl(self->decoder, SPEEX_GET_FRAME_SIZE, &(self->frame_size)); 98 107 99 100 101 ROAR_ WARN("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, self->frame_size*2);108 fs2 = self->frame_size * 2; 109 110 ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2); 102 111 103 112 if ( !self->cd ) { 104 self->cd = malloc( (self->frame_size)*2);113 self->cd = malloc(fs2); 105 114 if ( !self->cd ) 106 115 return 0; … … 108 117 109 118 if ( !self->i_rest ) { 110 self->i_rest = malloc( (self->frame_size)*2);119 self->i_rest = malloc(fs2); 111 120 if ( !self->i_rest ) 112 121 return 0; 113 122 } 114 123 } 124 fs2 = self->frame_size * 2; 115 125 116 126 ROAR_DBG("cf_speex_read(*): Have a working decoder!"); 117 127 118 ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, self->frame_size*2);128 ROAR_DBG("cf_speex_read(*): frame_size=%i (%i bytes)", self->frame_size, fs2); 119 129 ROAR_DBG("cf_speex_read(*): i_rest is %i bytes after cd", ((void*)self->i_rest - (void*)self->cd)); 120 130 … … 122 132 if ( self->fi_rest ) { 123 133 if ( self->fi_rest > (still_todo*2) ) { 124 ROAR_WARN("cf_speex_read(*): discarding input rest data: buffer too long!"); 125 self->fi_rest = 0; 134 ROAR_DBG("cf_speex_read(*): using data from input rest buffer: len=%i (no need to read new data)", self->fi_rest); 135 still_todo *= 2; // we will set this to zero one way or another, 136 // so we don't need to care about soring a 'warong' value here. 137 memcpy(buf, self->i_rest, still_todo); 138 memmove(self->i_rest, self->i_rest + still_todo, self->fi_rest - still_todo); 139 self->fi_rest -= still_todo; 140 ret += still_todo; 141 still_todo = 0; 126 142 } else { 127 ROAR_ WARN("cf_speex_read(*): using data from input rest buffer: len=%i", self->fi_rest);143 ROAR_DBG("cf_speex_read(*): using data from input rest buffer: len=%i", self->fi_rest); 128 144 memcpy(buf, self->i_rest, self->fi_rest); 129 145 buf += self->fi_rest; … … 135 151 136 152 while (still_todo) { 137 ROAR_ WARN("cf_speex_read(*): we sill need %i frames", still_todo);153 ROAR_DBG("cf_speex_read(*): we sill need %i frames", still_todo); 138 154 if ( stream_vio_s_read(self->stream, &ui, 2) != 2 ) 139 155 return -1; … … 155 171 ret += still_todo*2; 156 172 self->fi_rest = (self->frame_size - still_todo)*2; 157 ROAR_ WARN("cf_speex_read(*): self->fi_rest=%i, off=%i", self->fi_rest, still_todo*2);173 ROAR_DBG("cf_speex_read(*): self->fi_rest=%i, off=%i", self->fi_rest, still_todo*2); 158 174 memcpy(self->i_rest, (self->cd)+(still_todo*2), self->fi_rest); 159 175 still_todo = 0; 160 176 } else { 161 memcpy(buf, self->cd, self->frame_size*2);162 buf += self->frame_size*2;163 ret += self->frame_size*2;177 memcpy(buf, self->cd, fs2); 178 buf += fs2; 179 ret += fs2; 164 180 still_todo -= self->frame_size; 165 181 } … … 167 183 168 184 if ( still_todo ) { 169 ROAR_ WARN("cf_speex_read(*): could not read all reqquested data, returning %i byte less", still_todo*2);170 } 171 172 ROAR_ WARN("cf_speex_read(*) = %i", ret);185 ROAR_DBG("cf_speex_read(*): could not read all reqquested data, returning %i byte less", still_todo*2); 186 } 187 188 ROAR_DBG("cf_speex_read(*) = %i", ret); 173 189 174 190 return ret;
Note: See TracChangeset
for help on using the changeset viewer.