Skip to content

Commit aafa677

Browse files
szymon-czaprackirymanluk
authored andcommitted
nimble/audio/bass: BASS modify source update
Handling for proper receive state fields is added. Fix a never-ending goto statement returning to goto itself. Fixed offset "jump" from two-bytes to one-byte.
1 parent 80d95d0 commit aafa677

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

nimble/host/audio/services/bass/include/services/bass/ble_audio_svc_bass.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ struct ble_svc_audio_bass_operation {
329329

330330
/** BIS Synchronisation of subgroups */
331331
uint32_t bis_sync[BLE_SVC_AUDIO_BASS_SUB_NUM_MAX];
332+
/** Subgroup entries */
333+
struct ble_svc_audio_bass_subgroup
334+
subgroups[BLE_SVC_AUDIO_BASS_SUB_NUM_MAX];
332335
} modify_source;
333336

334337
/**

nimble/host/audio/services/bass/src/ble_audio_svc_bass.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
477477
.status = 0
478478
}
479479
};
480+
uint8_t *metadata_ptr;
480481
uint8_t offset = 0;
481482
int rc = 0;
482483
int i;
@@ -518,6 +519,16 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
518519
for (i = 0; i < operation.modify_source.num_subgroups; i++) {
519520
operation.modify_source.bis_sync[i] = get_le32(&data[offset]);
520521
offset += 4;
522+
operation.modify_source.subgroups[i].metadata_length = data[offset++];
523+
data_len -= 5;
524+
if (data_len < operation.modify_source.subgroups[i].metadata_length) {
525+
rc = BLE_ATT_ERR_WRITE_REQ_REJECTED;
526+
ev.bass_operation_status.status = BLE_HS_ERJECT;
527+
goto done;
528+
}
529+
operation.modify_source.subgroups[i].metadata = &data[offset];
530+
offset += operation_modify_source.subgroups[i].metadata_length;
531+
data_len -= operation.modify_source.subgroups[i].metadata_length;
521532
}
522533

523534
if (check_bis_sync(operation.modify_source.num_subgroups,
@@ -527,6 +538,18 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
527538
goto done;
528539
}
529540

541+
for (i = 0; i < operation.modify_source.num_subgroups; i++) {
542+
metadata_ptr = os_memblock_get(&ble_audio_svc_bass_metadata_pool);
543+
if (metadata_ptr == NULL) {
544+
rc = BLE_HS_ENOMEM;
545+
ev.bass_operation_status.status = BLE_HS_ENOMEM;
546+
goto done;
547+
}
548+
memcpy(metadata_ptr, operation.modify_source.subgroups[i].metadata,
549+
min(operation.modify_source.subgroups[i].metadata_length,
550+
MYNEWT_VAL(BLE_SVC_AUDIO_BASS_METADATA_MAX_SZ)));
551+
}
552+
530553
if (accept_fn.ctrl_point_ev_fn) {
531554
rc = accept_fn.ctrl_point_ev_fn(&operation, accept_fn.arg);
532555
if (rc != 0) {
@@ -542,7 +565,6 @@ ble_svc_audio_bass_modify_source(uint8_t *data, uint16_t data_len, uint16_t conn
542565
if (!rc) {
543566
rc = ble_svc_audio_bass_receive_state_notify(rcv_state);
544567
ev.bass_operation_status.status = rc;
545-
goto done;
546568
}
547569

548570
ble_audio_event_listener_call(&ev);

0 commit comments

Comments
 (0)