Bluetooth: Audio: Add missing null checks in mpl
There were a missing NULL check for the track segment in paused_state_command_handler when performing the segment operations. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
7efc99b9ab
commit
3d3e692190
1 changed files with 39 additions and 20 deletions
|
@ -1848,38 +1848,58 @@ void paused_state_command_handler(const struct mpl_cmd *command,
|
||||||
case MEDIA_PROXY_OP_PREV_SEGMENT:
|
case MEDIA_PROXY_OP_PREV_SEGMENT:
|
||||||
/* Switch to previous segment if we are less than 5 seconds */
|
/* Switch to previous segment if we are less than 5 seconds */
|
||||||
/* into the segment, otherwise go to start of segment */
|
/* into the segment, otherwise go to start of segment */
|
||||||
if (pl.track_pos - PREV_MARGIN <
|
if (pl.group->track->segment != NULL) {
|
||||||
pl.group->track->segment->pos) {
|
if (pl.track_pos - PREV_MARGIN < pl.group->track->segment->pos) {
|
||||||
do_prev_segment(&pl);
|
do_prev_segment(&pl);
|
||||||
|
}
|
||||||
|
|
||||||
|
pl.track_pos = pl.group->track->segment->pos;
|
||||||
|
media_proxy_pl_track_position_cb(pl.track_pos);
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
||||||
|
} else {
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_CANNOT_BE_COMPLETED;
|
||||||
}
|
}
|
||||||
pl.track_pos = pl.group->track->segment->pos;
|
|
||||||
media_proxy_pl_track_position_cb(pl.track_pos);
|
|
||||||
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
|
||||||
media_proxy_pl_command_cb(ntf);
|
media_proxy_pl_command_cb(ntf);
|
||||||
break;
|
break;
|
||||||
case MEDIA_PROXY_OP_NEXT_SEGMENT:
|
case MEDIA_PROXY_OP_NEXT_SEGMENT:
|
||||||
do_next_segment(&pl);
|
if (pl.group->track->segment != NULL) {
|
||||||
pl.track_pos = pl.group->track->segment->pos;
|
do_next_segment(&pl);
|
||||||
media_proxy_pl_track_position_cb(pl.track_pos);
|
pl.track_pos = pl.group->track->segment->pos;
|
||||||
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
media_proxy_pl_track_position_cb(pl.track_pos);
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
||||||
|
} else {
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_CANNOT_BE_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
media_proxy_pl_command_cb(ntf);
|
media_proxy_pl_command_cb(ntf);
|
||||||
break;
|
break;
|
||||||
case MEDIA_PROXY_OP_FIRST_SEGMENT:
|
case MEDIA_PROXY_OP_FIRST_SEGMENT:
|
||||||
do_first_segment(&pl);
|
if (pl.group->track->segment != NULL) {
|
||||||
pl.track_pos = pl.group->track->segment->pos;
|
do_first_segment(&pl);
|
||||||
media_proxy_pl_track_position_cb(pl.track_pos);
|
pl.track_pos = pl.group->track->segment->pos;
|
||||||
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
media_proxy_pl_track_position_cb(pl.track_pos);
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
||||||
|
} else {
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_CANNOT_BE_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
media_proxy_pl_command_cb(ntf);
|
media_proxy_pl_command_cb(ntf);
|
||||||
break;
|
break;
|
||||||
case MEDIA_PROXY_OP_LAST_SEGMENT:
|
case MEDIA_PROXY_OP_LAST_SEGMENT:
|
||||||
do_last_segment(&pl);
|
if (pl.group->track->segment != NULL) {
|
||||||
pl.track_pos = pl.group->track->segment->pos;
|
do_last_segment(&pl);
|
||||||
media_proxy_pl_track_position_cb(pl.track_pos);
|
pl.track_pos = pl.group->track->segment->pos;
|
||||||
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
media_proxy_pl_track_position_cb(pl.track_pos);
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_SUCCESS;
|
||||||
|
} else {
|
||||||
|
ntf->result_code = MEDIA_PROXY_CMD_CANNOT_BE_COMPLETED;
|
||||||
|
}
|
||||||
|
|
||||||
media_proxy_pl_command_cb(ntf);
|
media_proxy_pl_command_cb(ntf);
|
||||||
break;
|
break;
|
||||||
case MEDIA_PROXY_OP_GOTO_SEGMENT:
|
case MEDIA_PROXY_OP_GOTO_SEGMENT:
|
||||||
if (command->use_param) {
|
if (command->use_param && pl.group->track->segment != NULL) {
|
||||||
if (command->param != 0) {
|
if (command->param != 0) {
|
||||||
do_goto_segment(&pl, command->param);
|
do_goto_segment(&pl, command->param);
|
||||||
pl.track_pos = pl.group->track->segment->pos;
|
pl.track_pos = pl.group->track->segment->pos;
|
||||||
|
@ -2459,7 +2479,6 @@ void set_current_track_id(uint64_t id)
|
||||||
LOG_DBG_OBJ_ID("Track ID to set: ", id);
|
LOG_DBG_OBJ_ID("Track ID to set: ", id);
|
||||||
|
|
||||||
if (find_track_by_id(&pl, id, &group, &track)) {
|
if (find_track_by_id(&pl, id, &group, &track)) {
|
||||||
|
|
||||||
if (pl.group != group) {
|
if (pl.group != group) {
|
||||||
pl.group = group;
|
pl.group = group;
|
||||||
do_group_change_notifications(&pl);
|
do_group_change_notifications(&pl);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue