1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 #define __BTSTACK_FILE__ "btstack_sbc_decoder_bluedroid.c" 39 40 // ***************************************************************************** 41 // 42 // SBC decoder based on Bluedroid library 43 // 44 // ***************************************************************************** 45 46 #include "btstack_config.h" 47 48 #include <stdint.h> 49 #include <stdio.h> 50 #include <stdlib.h> 51 #include <string.h> 52 53 #include "btstack_sbc.h" 54 #include "btstack_sbc_plc.h" 55 56 #include "oi_codec_sbc.h" 57 #include "oi_assert.h" 58 #include "btstack.h" 59 60 #define mSBC_SYNCWORD 0xad 61 #define SBC_SYNCWORD 0x9c 62 #define SBC_MAX_CHANNELS 2 63 // #define LOG_FRAME_STATUS 64 65 #define DECODER_DATA_SIZE (SBC_MAX_CHANNELS*SBC_MAX_BLOCKS*SBC_MAX_BANDS * 4 + SBC_CODEC_MIN_FILTER_BUFFERS*SBC_MAX_BANDS*SBC_MAX_CHANNELS * 2) 66 67 typedef struct { 68 OI_UINT32 bytes_in_frame_buffer; 69 OI_CODEC_SBC_DECODER_CONTEXT decoder_context; 70 71 uint8_t frame_buffer[SBC_MAX_FRAME_LEN]; 72 int16_t pcm_plc_data[SBC_MAX_CHANNELS * SBC_MAX_BANDS * SBC_MAX_BLOCKS]; 73 int16_t pcm_data[SBC_MAX_CHANNELS * SBC_MAX_BANDS * SBC_MAX_BLOCKS]; 74 uint32_t pcm_bytes; 75 OI_UINT32 decoder_data[(DECODER_DATA_SIZE+3)/4]; 76 int first_good_frame_found; 77 int h2_sequence_nr; 78 uint16_t msbc_bad_bytes; 79 } bludroid_decoder_state_t; 80 81 static btstack_sbc_decoder_state_t * sbc_decoder_state_singleton = NULL; 82 static bludroid_decoder_state_t bd_decoder_state; 83 84 // Testing only - START 85 static int plc_enabled = 1; 86 static int corrupt_frame_period = -1; 87 // Testing - STOP 88 89 void btstack_sbc_decoder_test_disable_plc(void){ 90 plc_enabled = 0; 91 } 92 93 void btstack_sbc_decoder_test_simulate_corrupt_frames(int period){ 94 corrupt_frame_period = period; 95 } 96 97 static int find_sequence_of_zeros(const OI_BYTE *frame_data, OI_UINT32 frame_bytes, int seq_length){ 98 int zero_seq_count = 0; 99 unsigned int i; 100 for (i=0; i<frame_bytes; i++){ 101 if (frame_data[i] == 0) { 102 zero_seq_count++; 103 if (zero_seq_count >= seq_length) return zero_seq_count; 104 } else { 105 zero_seq_count = 0; 106 } 107 } 108 return 0; 109 } 110 111 // returns position of mSBC sync word 112 static int find_h2_sync(const OI_BYTE *frame_data, OI_UINT32 frame_bytes, int * sync_word_nr){ 113 int syncword = mSBC_SYNCWORD; 114 uint8_t h2_first_byte = 0; 115 uint8_t h2_second_byte = 0; 116 117 int i; 118 for (i=0; i<frame_bytes; i++){ 119 if (frame_data[i] == syncword) { 120 // check: first byte == 1 121 if (h2_first_byte == 1) { 122 // check lower nibble of second byte == 0x08 123 uint8_t ln = h2_second_byte & 0x0F; 124 if (ln == 8) { 125 // check if bits 0+2 == bits 1+3 126 uint8_t hn = h2_second_byte >> 4; 127 if ( ((hn>>1) & 0x05) == (hn & 0x05) ) { 128 *sync_word_nr = ((hn & 0x04) >> 1) | (hn & 0x01); 129 return i; 130 } 131 } 132 } 133 } 134 h2_first_byte = h2_second_byte; 135 h2_second_byte = frame_data[i]; 136 } 137 return -1; 138 } 139 140 int btstack_sbc_decoder_num_samples_per_frame(btstack_sbc_decoder_state_t * state){ 141 bludroid_decoder_state_t * decoder_state = (bludroid_decoder_state_t *) state->decoder_state; 142 return decoder_state->decoder_context.common.frameInfo.nrof_blocks * decoder_state->decoder_context.common.frameInfo.nrof_subbands; 143 } 144 145 int btstack_sbc_decoder_num_channels(btstack_sbc_decoder_state_t * state){ 146 bludroid_decoder_state_t * decoder_state = (bludroid_decoder_state_t *) state->decoder_state; 147 return decoder_state->decoder_context.common.frameInfo.nrof_channels; 148 } 149 150 int btstack_sbc_decoder_sample_rate(btstack_sbc_decoder_state_t * state){ 151 bludroid_decoder_state_t * decoder_state = (bludroid_decoder_state_t *) state->decoder_state; 152 return decoder_state->decoder_context.common.frameInfo.frequency; 153 } 154 155 #ifdef OI_DEBUG 156 void OI_AssertFail(const char* file, int line, const char* reason){ 157 log_error("AssertFail file %s, line %d, reason %s", file, line, reason); 158 } 159 #endif 160 161 void btstack_sbc_decoder_init(btstack_sbc_decoder_state_t * state, btstack_sbc_mode_t mode, void (*callback)(int16_t * data, int num_samples, int num_channels, int sample_rate, void * context), void * context){ 162 if (sbc_decoder_state_singleton && sbc_decoder_state_singleton != state ){ 163 log_error("SBC decoder: different sbc decoder state is allready registered"); 164 } 165 OI_STATUS status = OI_STATUS_SUCCESS; 166 switch (mode){ 167 case SBC_MODE_STANDARD: 168 // note: we always request stereo output, even for mono input 169 status = OI_CODEC_SBC_DecoderReset(&(bd_decoder_state.decoder_context), bd_decoder_state.decoder_data, sizeof(bd_decoder_state.decoder_data), 2, 2, FALSE); 170 break; 171 case SBC_MODE_mSBC: 172 status = OI_CODEC_mSBC_DecoderReset(&(bd_decoder_state.decoder_context), bd_decoder_state.decoder_data, sizeof(bd_decoder_state.decoder_data)); 173 break; 174 default: 175 break; 176 } 177 178 if (status != OI_STATUS_SUCCESS){ 179 log_error("SBC decoder: error during reset %d\n", status); 180 } 181 182 sbc_decoder_state_singleton = state; 183 184 bd_decoder_state.bytes_in_frame_buffer = 0; 185 bd_decoder_state.pcm_bytes = sizeof(bd_decoder_state.pcm_data); 186 bd_decoder_state.h2_sequence_nr = -1; 187 bd_decoder_state.first_good_frame_found = 0; 188 189 memset(state, 0, sizeof(btstack_sbc_decoder_state_t)); 190 state->handle_pcm_data = callback; 191 state->mode = mode; 192 state->context = context; 193 state->decoder_state = &bd_decoder_state; 194 btstack_sbc_plc_init(&state->plc_state); 195 } 196 197 static void append_received_sbc_data(bludroid_decoder_state_t * state, uint8_t * buffer, int size){ 198 int numFreeBytes = sizeof(state->frame_buffer) - state->bytes_in_frame_buffer; 199 200 // printf("append_received_sbc_data: bytes to append %u, sizeof %u, bytes in buffer %u, free %u\n", size,sizeof(state->frame_buffer), state->bytes_in_frame_buffer, numFreeBytes); 201 202 if (size > numFreeBytes){ 203 log_error("SBC data: more bytes read %u than free bytes in buffer %u", size, numFreeBytes); 204 } 205 206 memcpy(state->frame_buffer + state->bytes_in_frame_buffer, buffer, size); 207 state->bytes_in_frame_buffer += size; 208 } 209 210 211 static void btstack_sbc_decoder_process_sbc_data(btstack_sbc_decoder_state_t * state, uint8_t * buffer, int size){ 212 bludroid_decoder_state_t * decoder_state = (bludroid_decoder_state_t*)state->decoder_state; 213 int input_bytes_to_process = size; 214 int keep_decoding = 1; 215 216 while (keep_decoding) { 217 // Fill decoder_state->frame_buffer as much as possible. 218 int bytes_free_in_frame_buffer = SBC_MAX_FRAME_LEN - decoder_state->bytes_in_frame_buffer; 219 int bytes_to_append = btstack_min(input_bytes_to_process, bytes_free_in_frame_buffer); 220 if (bytes_to_append){ 221 append_received_sbc_data(decoder_state, buffer, bytes_to_append); 222 buffer += bytes_to_append; 223 input_bytes_to_process -= bytes_to_append; 224 } 225 226 // Decode the next frame in decoder_state->frame_buffer. 227 int bytes_in_frame_buffer_before_decoding = decoder_state->bytes_in_frame_buffer; 228 const OI_BYTE *frame_data = decoder_state->frame_buffer; 229 OI_UINT32 frame_data_len = decoder_state->bytes_in_frame_buffer; 230 OI_STATUS status = OI_CODEC_SBC_DecodeFrame(&(decoder_state->decoder_context), 231 &frame_data, 232 &frame_data_len, 233 decoder_state->pcm_plc_data, 234 &(decoder_state->pcm_bytes)); 235 uint16_t bytes_processed = bytes_in_frame_buffer_before_decoding - frame_data_len; 236 237 // testing only - corrupt frame periodically 238 static int frame_count = 0; 239 if (corrupt_frame_period > 0){ 240 frame_count++; 241 242 if (frame_count % corrupt_frame_period == 0){ 243 *(uint8_t*)&frame_data[5] = 0; 244 frame_count = 0; 245 } 246 } 247 248 // Handle decoding result. 249 switch(status){ 250 case OI_STATUS_SUCCESS: 251 case OI_CODEC_SBC_PARTIAL_DECODE: 252 state->handle_pcm_data(decoder_state->pcm_plc_data, 253 btstack_sbc_decoder_num_samples_per_frame(state), 254 btstack_sbc_decoder_num_channels(state), 255 btstack_sbc_decoder_sample_rate(state), state->context); 256 state->good_frames_nr++; 257 break; 258 259 case OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA: 260 case OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA: 261 case OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA: 262 if (input_bytes_to_process > 0){ 263 // Should never occur: The SBC code claims there is not enough bytes in the frame_buffer, 264 // but the frame_buffer was full. (The frame_buffer is always full before decoding when input_bytes_to_process > 0.) 265 // Clear frame_buffer. 266 log_info("SBC decode: frame_buffer too small for frame"); 267 bytes_processed = bytes_in_frame_buffer_before_decoding; 268 } else { 269 // Exit decode loop, because there is not enough data in frame_buffer to decode the next frame. 270 keep_decoding = 0; 271 } 272 break; 273 274 case OI_CODEC_SBC_NO_SYNCWORD: 275 // This means the entire frame_buffer did not contain the syncword. 276 // Discard the frame_buffer contents. 277 log_info("SBC decode: no syncword found"); 278 bytes_processed = bytes_in_frame_buffer_before_decoding; 279 break; 280 281 case OI_CODEC_SBC_CHECKSUM_MISMATCH: 282 // The next frame is somehow corrupt. 283 log_info("SBC decode: checksum error"); 284 // Did the codec consume any bytes? 285 if (bytes_processed > 0){ 286 // Good. Nothing to do. 287 } else { 288 // Skip the bogus frame by skipping the header. 289 bytes_processed = 1; 290 } 291 break; 292 293 case OI_STATUS_INVALID_PARAMETERS: 294 // This caused by corrupt frames. 295 // The codec apparently does not recover from this. 296 // Re-initialize the codec. 297 log_info("SBC decode: invalid parameters: resetting codec"); 298 if (OI_CODEC_SBC_DecoderReset(&(bd_decoder_state.decoder_context), bd_decoder_state.decoder_data, sizeof(bd_decoder_state.decoder_data), 2, 2, FALSE) != OI_STATUS_SUCCESS){ 299 log_info("SBC decode: resetting codec failed"); 300 301 } 302 break; 303 default: 304 // Anything else went wrong. 305 // Skip a few bytes and try again. 306 bytes_processed = 1; 307 log_info("SBC decode: unknown status %d", status); 308 break; 309 } 310 311 // Remove decoded frame from decoder_state->frame_buffer. 312 if (bytes_processed > bytes_in_frame_buffer_before_decoding) { 313 bytes_processed = bytes_in_frame_buffer_before_decoding; 314 } 315 memmove(decoder_state->frame_buffer, decoder_state->frame_buffer + bytes_processed, bytes_in_frame_buffer_before_decoding - bytes_processed); 316 decoder_state->bytes_in_frame_buffer -= bytes_processed; 317 } 318 } 319 320 321 static void btstack_sbc_decoder_process_msbc_data(btstack_sbc_decoder_state_t * state, int packet_status_flag, uint8_t * buffer, int size){ 322 bludroid_decoder_state_t * decoder_state = (bludroid_decoder_state_t*)state->decoder_state; 323 int input_bytes_to_process = size; 324 unsigned int msbc_frame_size = 60; 325 326 while (input_bytes_to_process > 0){ 327 328 // fill buffer with new data 329 int bytes_missing_for_complete_msbc_frame = msbc_frame_size - decoder_state->bytes_in_frame_buffer; 330 int bytes_to_append = btstack_min(input_bytes_to_process, bytes_missing_for_complete_msbc_frame); 331 if (bytes_to_append) { 332 append_received_sbc_data(decoder_state, buffer, bytes_to_append); 333 buffer += bytes_to_append; 334 input_bytes_to_process -= bytes_to_append; 335 } 336 337 if (decoder_state->bytes_in_frame_buffer < msbc_frame_size) break; 338 339 // printf_hexdump(decoder_state->frame_buffer, decoder_state->bytes_in_frame_buffer); 340 341 uint16_t bytes_in_frame_buffer_before_decoding = decoder_state->bytes_in_frame_buffer; 342 uint16_t bytes_processed = 0; 343 const OI_BYTE *frame_data = decoder_state->frame_buffer; 344 345 // testing only - corrupt frame periodically 346 static int frame_count = 0; 347 if (corrupt_frame_period > 0){ 348 frame_count++; 349 350 if (frame_count % corrupt_frame_period == 0){ 351 *(uint8_t*)&frame_data[5] = 0; 352 frame_count = 0; 353 } 354 } 355 356 int bad_frame = 0; 357 int zero_seq_found = find_sequence_of_zeros(frame_data, decoder_state->bytes_in_frame_buffer, 20); 358 359 // after first valid frame, zero sequences count as bad frames 360 if (decoder_state->first_good_frame_found){ 361 bad_frame = zero_seq_found || packet_status_flag; 362 } 363 364 if (bad_frame){ 365 366 // stats 367 if (zero_seq_found){ 368 state->zero_frames_nr++; 369 } else { 370 state->bad_frames_nr++; 371 } 372 373 #ifdef LOG_FRAME_STATUS 374 if (zero_seq_found){ 375 printf("%d : ZERO FRAME\n", decoder_state->h2_sequence_nr); 376 } else { 377 printf("%d : BAD FRAME\n", decoder_state->h2_sequence_nr); 378 } 379 #endif 380 381 decoder_state->bytes_in_frame_buffer = 0; 382 decoder_state->msbc_bad_bytes += msbc_frame_size; 383 continue; 384 } 385 386 int h2_syncword = 0; 387 int h2_sync_pos = find_h2_sync(frame_data, decoder_state->bytes_in_frame_buffer, &h2_syncword); 388 // printf("Sync Pos: %d, nr %d\n", h2_sync_pos, h2_syncword); 389 if (h2_sync_pos < 0){ 390 // no sync found, discard all but last 2 bytes 391 bytes_processed = decoder_state->bytes_in_frame_buffer - 2; 392 memmove(decoder_state->frame_buffer, decoder_state->frame_buffer + bytes_processed, decoder_state->bytes_in_frame_buffer); 393 decoder_state->bytes_in_frame_buffer -= bytes_processed; // == 2 394 decoder_state->msbc_bad_bytes += bytes_processed; 395 continue; 396 } 397 398 decoder_state->h2_sequence_nr = h2_syncword; 399 400 // drop data before it 401 bytes_processed = h2_sync_pos - 2; 402 if (bytes_processed > 2){ 403 memmove(decoder_state->frame_buffer, decoder_state->frame_buffer + bytes_processed, decoder_state->bytes_in_frame_buffer); 404 decoder_state->bytes_in_frame_buffer -= bytes_processed; 405 decoder_state->msbc_bad_bytes += bytes_processed; 406 continue; 407 } 408 409 // ready to decode frame 410 // log_info("Before: bytes in buffer %u, pcm bytes %u", decoder_state->bytes_in_frame_buffer, decoder_state->pcm_bytes); 411 OI_STATUS status = OI_CODEC_SBC_DecodeFrame(&(decoder_state->decoder_context), 412 &frame_data, 413 &(decoder_state->bytes_in_frame_buffer), 414 decoder_state->pcm_plc_data, 415 &(decoder_state->pcm_bytes)); 416 417 bytes_processed = bytes_in_frame_buffer_before_decoding - decoder_state->bytes_in_frame_buffer; 418 // log_info("After: bytes in buffer %u, pcm bytes %u, processed %u", decoder_state->bytes_in_frame_buffer, decoder_state->pcm_bytes, bytes_processed); 419 420 switch(status){ 421 case 0: 422 decoder_state->first_good_frame_found = 1; 423 424 btstack_sbc_plc_good_frame(&state->plc_state, decoder_state->pcm_plc_data, decoder_state->pcm_data); 425 state->handle_pcm_data(decoder_state->pcm_data, 426 btstack_sbc_decoder_num_samples_per_frame(state), 427 btstack_sbc_decoder_num_channels(state), 428 btstack_sbc_decoder_sample_rate(state), state->context); 429 430 state->good_frames_nr++; 431 decoder_state->msbc_bad_bytes = 0; 432 continue; 433 434 case OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA: 435 log_error("OI_CODEC_SBC_NOT_ENOUGH_HEADER_DATA"); 436 break; 437 case OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA: 438 log_error("OI_CODEC_SBC_NOT_ENOUGH_BODY_DATA"); 439 break; 440 case OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA: 441 log_error("OI_CODEC_SBC_NOT_ENOUGH_AUDIO_DATA"); 442 break; 443 case OI_CODEC_SBC_NO_SYNCWORD: 444 log_error("OI_CODEC_SBC_NO_SYNCWORD"); 445 break; 446 447 case OI_CODEC_SBC_CHECKSUM_MISMATCH: 448 // The next frame is somehow corrupt. 449 log_info("OI_CODEC_SBC_CHECKSUM_MISMATCH"); 450 // Did the codec consume any bytes? 451 if (bytes_processed > 0){ 452 // Good. Nothing to do. 453 } else { 454 // Skip the bogus frame by skipping the header. 455 bytes_processed = 1; 456 } 457 break; 458 459 case OI_STATUS_INVALID_PARAMETERS: 460 // This caused by corrupt frames. 461 // The codec apparently does not recover from this. 462 // Re-initialize the codec. 463 log_info("SBC decode: invalid parameters: resetting codec"); 464 if (OI_CODEC_mSBC_DecoderReset(&(bd_decoder_state.decoder_context), bd_decoder_state.decoder_data, sizeof(bd_decoder_state.decoder_data)) != OI_STATUS_SUCCESS){ 465 log_info("SBC decode: resetting codec failed"); 466 } 467 break; 468 default: 469 log_info("Frame decode error: %d", status); 470 break; 471 } 472 473 if (status != 0){ 474 decoder_state->msbc_bad_bytes += bytes_processed; 475 } 476 477 memmove(decoder_state->frame_buffer, decoder_state->frame_buffer + bytes_processed, decoder_state->bytes_in_frame_buffer); 478 } 479 480 #if 0 481 // ignore bad data before first sync 482 if (!decoder_state->first_good_frame_found) return; 483 484 // PLC on> 485 if (!plc_enabled) return; 486 487 // PLC 488 while (decoder_state->msbc_bad_bytes >= msbc_frame_size){ 489 printf("BAD Bytes %u\n", decoder_state->msbc_bad_bytes); 490 decoder_state->msbc_bad_bytes -= msbc_frame_size; 491 state->bad_frames_nr++; 492 493 // prepare zero signal frame 494 const OI_BYTE * frame_data = btstack_sbc_plc_zero_signal_frame(); 495 OI_UINT32 bytes_in_frame_buffer = 57; 496 497 // printf("Bad-Before: bytes in buffer %u, pcm bytes %u\n", bytes_in_frame_buffer, decoder_state->pcm_bytes); 498 OI_STATUS status = status = OI_CODEC_SBC_DecodeFrame(&(decoder_state->decoder_context), 499 &frame_data, 500 &bytes_in_frame_buffer, 501 decoder_state->pcm_plc_data, 502 &(decoder_state->pcm_bytes)); 503 // printf("Bad-After: bytes in buffer %u, pcm bytes %u\n", bytes_in_frame_buffer, decoder_state->pcm_bytes); 504 505 if (status) { 506 log_error("SBC decoder: error %d\n", status); 507 } 508 if (bytes_in_frame_buffer){ 509 log_error("PLC: not all bytes of zero frame processed, left %u\n", bytes_in_frame_buffer); 510 } 511 512 printf_hexdump(decoder_state->pcm_plc_data, decoder_state->pcm_bytes); 513 514 btstack_sbc_plc_bad_frame(&state->plc_state, decoder_state->pcm_plc_data, decoder_state->pcm_data); 515 516 printf_hexdump(decoder_state->pcm_data, decoder_state->pcm_bytes); 517 518 state->handle_pcm_data(decoder_state->pcm_data, 519 btstack_sbc_decoder_num_samples_per_frame(state), 520 btstack_sbc_decoder_num_channels(state), 521 btstack_sbc_decoder_sample_rate(state), state->context); 522 523 524 break; 525 } 526 #endif 527 528 } 529 530 void btstack_sbc_decoder_process_data(btstack_sbc_decoder_state_t * state, int packet_status_flag, uint8_t * buffer, int size){ 531 if (state->mode == SBC_MODE_mSBC){ 532 btstack_sbc_decoder_process_msbc_data(state, packet_status_flag, buffer, size); 533 } else { 534 btstack_sbc_decoder_process_sbc_data(state, buffer, size); 535 } 536 } 537