@@ -80,13 +80,14 @@ bool OPUSDecoder_AllocateBuffers(){
8080 int32_t ret = 0 , silkDecSizeBytes = 0 ;
8181 (void ) ret;
8282 (void ) silkDecSizeBytes;
83+ silk_InitDecoder ();
8384 // ret = silk_Get_Decoder_Size(&silkDecSizeBytes);
84- if (ret){
85- log_e (" internal error" );
86- }
87- else {
88- log_i (" silkDecSizeBytes %i" , silkDecSizeBytes);
89- }
85+ // if (ret){
86+ // log_e("internal error");
87+ // }
88+ // else{
89+ // log_i("silkDecSizeBytes %i", silkDecSizeBytes);
90+ // }
9091 return true ;
9192}
9293void OPUSDecoder_FreeBuffers (){
@@ -365,7 +366,7 @@ int32_t opus_decode_frame(uint8_t *inbuf, int16_t *outbuf, int32_t packetLen, ui
365366
366367 if (s_mode == MODE_SILK_ONLY) {
367368 log_w (" Silk mode not yet supported" );
368- ret = samplesPerFrame;
369+ return samplesPerFrame;
369370
370371
371372
@@ -377,14 +378,21 @@ int32_t opus_decode_frame(uint8_t *inbuf, int16_t *outbuf, int32_t packetLen, ui
377378 else if (s_bandWidth == OPUS_BANDWIDTH_WIDEBAND) { s_internalSampleRate = 16000 ; }
378379 else { s_internalSampleRate = 16000 ; }
379380 ec_dec_init ((uint8_t *)inbuf, packetLen);
380- silk_setRawParams (2 , 2 , payloadSize_ms, s_internalSampleRate, 48000 );
381+ uint8_t APIchannels = 2 ;
382+ silk_setRawParams (s_opusChannels, APIchannels, payloadSize_ms, s_internalSampleRate, 48000 );
381383 // log_w("payloadSize_ms %i, s_internalSampleRate %i", payloadSize_ms, s_internalSampleRate);
382- silk_InitDecoder ();
384+ static bool silkInit = false ;
385+ if (!silkInit){
386+ silkInit = true ;
387+ silk_InitDecoder ();
388+ }
389+ // silk_InitDecoder();
383390
384391 do {
385392 /* Call SILK decoder */
393+ int lost_flag = 0 ;
386394 int first_frame = decodedSamples == 0 ;
387- int silk_ret = silk_Decode (0 , first_frame, (int16_t *)outbuf + decodedSamples, &silk_frame_size);
395+ int silk_ret = silk_Decode (lost_flag , first_frame, (int16_t *)outbuf + decodedSamples, &silk_frame_size);
388396 if (silk_ret)log_w (" silk_ret %i" , silk_ret);
389397 decodedSamples += silk_frame_size;
390398 // log_w("decodedSamples %i, samplesPerFrame %i", decodedSamples, samplesPerFrame);
0 commit comments