Bluetooth: Audio: Media - move variables to innermost scope
Move variables to innermost scope - do not define the variable (and read the value) until it is clear that the receiving callback exists. Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
This commit is contained in:
parent
98fa332527
commit
fb2df17933
@ -739,9 +739,9 @@ int media_proxy_ctrl_get_player_name(struct media_player *player)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
BT_DBG("Local player");
|
||||
if (mprx.local_player.calls->get_player_name) {
|
||||
const char *name = mprx.local_player.calls->get_player_name();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->player_name_recv) {
|
||||
const char *name = mprx.local_player.calls->get_player_name();
|
||||
|
||||
mprx.ctrlr.cbs->player_name_recv(&mprx.local_player, 0, name);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -775,9 +775,9 @@ int media_proxy_ctrl_get_icon_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_icon_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_icon_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->icon_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_icon_id();
|
||||
|
||||
mprx.ctrlr.cbs->icon_id_recv(&mprx.local_player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -810,9 +810,9 @@ int media_proxy_ctrl_get_icon_url(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_icon_url) {
|
||||
const char *url = mprx.local_player.calls->get_icon_url();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->icon_url_recv) {
|
||||
const char *url = mprx.local_player.calls->get_icon_url();
|
||||
|
||||
mprx.ctrlr.cbs->icon_url_recv(player, 0, url);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -845,9 +845,9 @@ int media_proxy_ctrl_get_track_title(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_track_title) {
|
||||
const char *title = mprx.local_player.calls->get_track_title();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_title_recv) {
|
||||
|
||||
const char *title = mprx.local_player.calls->get_track_title();
|
||||
mprx.ctrlr.cbs->track_title_recv(player, 0, title);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -880,9 +880,9 @@ int media_proxy_ctrl_get_track_duration(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_track_duration) {
|
||||
int32_t duration = mprx.local_player.calls->get_track_duration();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_duration_recv) {
|
||||
int32_t duration = mprx.local_player.calls->get_track_duration();
|
||||
|
||||
mprx.ctrlr.cbs->track_duration_recv(player, 0, duration);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -915,9 +915,9 @@ int media_proxy_ctrl_get_track_position(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_track_position) {
|
||||
int32_t position = mprx.local_player.calls->get_track_position();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_position_recv) {
|
||||
int32_t position = mprx.local_player.calls->get_track_position();
|
||||
|
||||
mprx.ctrlr.cbs->track_position_recv(player, 0, position);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -985,9 +985,9 @@ int media_proxy_ctrl_get_playback_speed(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_playback_speed) {
|
||||
int8_t speed = mprx.local_player.calls->get_playback_speed();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playback_speed_recv) {
|
||||
int8_t speed = mprx.local_player.calls->get_playback_speed();
|
||||
|
||||
mprx.ctrlr.cbs->playback_speed_recv(player, 0, speed);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1055,9 +1055,9 @@ int media_proxy_ctrl_get_seeking_speed(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_seeking_speed) {
|
||||
int8_t speed = mprx.local_player.calls->get_seeking_speed();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->seeking_speed_recv) {
|
||||
int8_t speed = mprx.local_player.calls->get_seeking_speed();
|
||||
|
||||
mprx.ctrlr.cbs->seeking_speed_recv(player, 0, speed);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1090,9 +1090,9 @@ int media_proxy_ctrl_get_track_segments_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_track_segments_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_track_segments_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->track_segments_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_track_segments_id();
|
||||
|
||||
mprx.ctrlr.cbs->track_segments_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1125,9 +1125,9 @@ int media_proxy_ctrl_get_current_track_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_current_track_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_current_track_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_track_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_current_track_id();
|
||||
|
||||
mprx.ctrlr.cbs->current_track_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1201,9 +1201,9 @@ int media_proxy_ctrl_get_next_track_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_next_track_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_next_track_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->next_track_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_next_track_id();
|
||||
|
||||
mprx.ctrlr.cbs->next_track_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1277,9 +1277,9 @@ int media_proxy_ctrl_get_parent_group_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_parent_group_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_parent_group_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->parent_group_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_parent_group_id();
|
||||
|
||||
mprx.ctrlr.cbs->parent_group_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1312,9 +1312,9 @@ int media_proxy_ctrl_get_current_group_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_current_group_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_current_group_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->current_group_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_current_group_id();
|
||||
|
||||
mprx.ctrlr.cbs->current_group_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1388,9 +1388,9 @@ int media_proxy_ctrl_get_playing_order(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_playing_order) {
|
||||
uint8_t order = mprx.local_player.calls->get_playing_order();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_order_recv) {
|
||||
uint8_t order = mprx.local_player.calls->get_playing_order();
|
||||
|
||||
mprx.ctrlr.cbs->playing_order_recv(player, 0, order);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1459,9 +1459,10 @@ int media_proxy_ctrl_get_playing_orders_supported(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_playing_orders_supported) {
|
||||
uint16_t orders = mprx.local_player.calls->get_playing_orders_supported();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->playing_orders_supported_recv) {
|
||||
uint16_t orders =
|
||||
mprx.local_player.calls->get_playing_orders_supported();
|
||||
|
||||
mprx.ctrlr.cbs->playing_orders_supported_recv(player, 0, orders);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1494,9 +1495,9 @@ int media_proxy_ctrl_get_media_state(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_media_state) {
|
||||
uint8_t state = mprx.local_player.calls->get_media_state();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->media_state_recv) {
|
||||
uint8_t state = mprx.local_player.calls->get_media_state();
|
||||
|
||||
mprx.ctrlr.cbs->media_state_recv(player, 0, state);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1564,9 +1565,10 @@ int media_proxy_ctrl_get_commands_supported(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_commands_supported) {
|
||||
uint32_t opcodes = mprx.local_player.calls->get_commands_supported();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->commands_supported_recv) {
|
||||
uint32_t opcodes =
|
||||
mprx.local_player.calls->get_commands_supported();
|
||||
|
||||
mprx.ctrlr.cbs->commands_supported_recv(player, 0, opcodes);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1634,9 +1636,9 @@ int media_proxy_ctrl_get_search_results_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_search_results_id) {
|
||||
uint64_t id = mprx.local_player.calls->get_search_results_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->search_results_id_recv) {
|
||||
uint64_t id = mprx.local_player.calls->get_search_results_id();
|
||||
|
||||
mprx.ctrlr.cbs->search_results_id_recv(player, 0, id);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
@ -1669,9 +1671,9 @@ uint8_t media_proxy_ctrl_get_content_ctrl_id(struct media_player *player)
|
||||
#if defined(CONFIG_MCTL_LOCAL_PLAYER_LOCAL_CONTROL)
|
||||
if (mprx.local_player.registered && player == &mprx.local_player) {
|
||||
if (mprx.local_player.calls->get_content_ctrl_id) {
|
||||
uint8_t ccid = mprx.local_player.calls->get_content_ctrl_id();
|
||||
|
||||
if (mprx.ctrlr.cbs && mprx.ctrlr.cbs->content_ctrl_id_recv) {
|
||||
uint8_t ccid = mprx.local_player.calls->get_content_ctrl_id();
|
||||
|
||||
mprx.ctrlr.cbs->content_ctrl_id_recv(player, 0, ccid);
|
||||
} else {
|
||||
BT_DBG("No callback");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user