Bluetooth: Audio: Media control - pass structs by reference
Changes the media_proxy API to pass structs by reference instead of by value. Also pass structs by reference in internal functions in media player and in media controller test. Add pointer checks to the public API implementation where user/application code provides structs by reference. Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
parent
ebaad4501c
commit
b0d5db147b
7 changed files with 250 additions and 244 deletions
|
@ -398,7 +398,7 @@ static void media_state_cb(struct media_player *plr, int err, uint8_t state)
|
|||
SET_FLAG(media_state_read);
|
||||
}
|
||||
|
||||
static void command_send_cb(struct media_player *plr, int err, struct mpl_cmd cmd)
|
||||
static void command_send_cb(struct media_player *plr, int err, const struct mpl_cmd *cmd)
|
||||
{
|
||||
if (err) {
|
||||
FAIL("Command send failed (%d)", err);
|
||||
|
@ -413,7 +413,7 @@ static void command_send_cb(struct media_player *plr, int err, struct mpl_cmd cm
|
|||
SET_FLAG(command_sent_flag);
|
||||
}
|
||||
|
||||
static void command_recv_cb(struct media_player *plr, int err, struct mpl_cmd_ntf cmd_ntf)
|
||||
static void command_recv_cb(struct media_player *plr, int err, const struct mpl_cmd_ntf *cmd_ntf)
|
||||
{
|
||||
if (err) {
|
||||
FAIL("Command failed (%d)", err);
|
||||
|
@ -425,7 +425,7 @@ static void command_recv_cb(struct media_player *plr, int err, struct mpl_cmd_nt
|
|||
return;
|
||||
}
|
||||
|
||||
g_command_result = cmd_ntf.result_code;
|
||||
g_command_result = cmd_ntf->result_code;
|
||||
SET_FLAG(command_results_flag);
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ static void commands_supported_cb(struct media_player *plr, int err, uint32_t op
|
|||
|
||||
|
||||
|
||||
static void search_send_cb(struct media_player *plr, int err, struct mpl_search search)
|
||||
static void search_send_cb(struct media_player *plr, int err, const struct mpl_search *search)
|
||||
{
|
||||
if (err) {
|
||||
FAIL("Search failed (%d)", err);
|
||||
|
@ -623,7 +623,7 @@ static bool test_verify_media_state_wait_flags(uint8_t expected_state)
|
|||
* Will FAIL on error to send the command.
|
||||
* Will WAIT for the required flags before returning.
|
||||
*/
|
||||
static void test_send_cmd_wait_flags(struct mpl_cmd cmd)
|
||||
static void test_send_cmd_wait_flags(struct mpl_cmd *cmd)
|
||||
{
|
||||
int err;
|
||||
|
||||
|
@ -632,7 +632,7 @@ static void test_send_cmd_wait_flags(struct mpl_cmd cmd)
|
|||
err = media_proxy_ctrl_send_command(current_player, cmd);
|
||||
if (err) {
|
||||
FAIL("Failed to send command: %d, opcode: %u",
|
||||
err, cmd.opcode);
|
||||
err, cmd->opcode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -647,7 +647,7 @@ static void test_cp_play(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_PLAY;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("PLAY command failed\n");
|
||||
|
@ -666,7 +666,7 @@ static void test_cp_pause(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_PAUSE;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("PAUSE command failed\n");
|
||||
|
@ -685,7 +685,7 @@ static void test_cp_fast_rewind(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_FAST_REWIND;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("FAST REWIND command failed\n");
|
||||
|
@ -704,7 +704,7 @@ static void test_cp_fast_forward(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_FAST_FORWARD;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("FAST FORWARD command failed\n");
|
||||
|
@ -723,7 +723,7 @@ static void test_cp_stop(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_STOP;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("STOP command failed\n");
|
||||
|
@ -760,7 +760,7 @@ static void test_cp_move_relative(void)
|
|||
cmd.use_param = true;
|
||||
cmd.param = 1000; /* Position change, measured in 1/100 of a second */
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("MOVE RELATIVE command failed\n");
|
||||
|
@ -804,7 +804,7 @@ static void test_cp_prev_segment(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_PREV_SEGMENT;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("PREV SEGMENT command failed\n");
|
||||
|
@ -821,7 +821,7 @@ static void test_cp_next_segment(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_NEXT_SEGMENT;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("NEXT SEGMENT command failed\n");
|
||||
|
@ -838,7 +838,7 @@ static void test_cp_first_segment(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_FIRST_SEGMENT;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("FIRST SEGMENT command failed\n");
|
||||
|
@ -855,7 +855,7 @@ static void test_cp_last_segment(void)
|
|||
cmd.opcode = MEDIA_PROXY_OP_LAST_SEGMENT;
|
||||
cmd.use_param = false;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("LAST SEGMENT command failed\n");
|
||||
|
@ -873,7 +873,7 @@ static void test_cp_goto_segment(void)
|
|||
cmd.use_param = true;
|
||||
cmd.param = 2; /* Second segment - not the first, maybe not last */
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("GOTO SEGMENT command failed\n");
|
||||
|
@ -920,7 +920,7 @@ static void test_cp_prev_track(void)
|
|||
test_read_current_track_object_id_wait_flags();
|
||||
object_id = g_current_track_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("PREV TRACK command failed\n");
|
||||
|
@ -949,7 +949,7 @@ static void test_cp_next_track(void)
|
|||
test_read_current_track_object_id_wait_flags();
|
||||
object_id = g_current_track_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("NEXT TRACK command failed\n");
|
||||
|
@ -977,7 +977,7 @@ static void test_cp_first_track(void)
|
|||
test_read_current_track_object_id_wait_flags();
|
||||
object_id = g_current_track_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("FIRST TRACK command failed\n");
|
||||
|
@ -1005,7 +1005,7 @@ static void test_cp_last_track(void)
|
|||
test_read_current_track_object_id_wait_flags();
|
||||
object_id = g_current_track_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("LAST TRACK command failed\n");
|
||||
|
@ -1034,7 +1034,7 @@ static void test_cp_goto_track(void)
|
|||
test_read_current_track_object_id_wait_flags();
|
||||
object_id = g_current_track_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("GOTO TRACK command failed\n");
|
||||
|
@ -1088,7 +1088,7 @@ static void test_cp_prev_group(void)
|
|||
test_read_current_group_object_id_wait_flags();
|
||||
object_id = g_current_group_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("PREV GROUP command failed\n");
|
||||
|
@ -1117,7 +1117,7 @@ static void test_cp_next_group(void)
|
|||
test_read_current_group_object_id_wait_flags();
|
||||
object_id = g_current_group_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("NEXT GROUP command failed\n");
|
||||
|
@ -1145,7 +1145,7 @@ static void test_cp_first_group(void)
|
|||
test_read_current_group_object_id_wait_flags();
|
||||
object_id = g_current_group_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("FIRST GROUP command failed\n");
|
||||
|
@ -1173,7 +1173,7 @@ static void test_cp_last_group(void)
|
|||
test_read_current_group_object_id_wait_flags();
|
||||
object_id = g_current_group_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("LAST GROUP command failed\n");
|
||||
|
@ -1202,7 +1202,7 @@ static void test_cp_goto_group(void)
|
|||
test_read_current_group_object_id_wait_flags();
|
||||
object_id = g_current_group_object_id;
|
||||
|
||||
test_send_cmd_wait_flags(cmd);
|
||||
test_send_cmd_wait_flags(&cmd);
|
||||
|
||||
if (g_command_result != MEDIA_PROXY_CMD_SUCCESS) {
|
||||
FAIL("GOTO GROUP command failed\n");
|
||||
|
@ -1271,7 +1271,7 @@ static void test_scp(void)
|
|||
UNSET_FLAG(search_result_code_flag);
|
||||
UNSET_FLAG(search_results_object_id_read);
|
||||
|
||||
err = media_proxy_ctrl_send_search(current_player, search);
|
||||
err = media_proxy_ctrl_send_search(current_player, &search);
|
||||
if (err) {
|
||||
FAIL("Failed to write to search control point\n");
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue