avrcp: replacle if-else-chain with simple if + return

This commit is contained in:
Matthias Ringwald 2020-07-09 22:07:42 +02:00
parent 6f35bb46e6
commit 182c9f077e

View File

@ -1080,64 +1080,64 @@ static void avrcp_target_packet_handler(uint8_t packet_type, uint16_t channel, u
connection->accept_response = 0;
avrcp_target_send_response(connection->l2cap_signaling_cid, connection);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->abort_continue_response){
if (connection->abort_continue_response){
connection->abort_continue_response = 0;
connection->now_playing_info_response = 0;
avrcp_target_abort_continue_response(connection->l2cap_signaling_cid, connection);
break;
return;
}
else if (connection->now_playing_info_response){
if (connection->now_playing_info_response){
connection->now_playing_info_response = 0;
avrcp_target_send_now_playing_info(connection->l2cap_signaling_cid, connection);
break;
return;
}
else if (connection->track_changed){
if (connection->track_changed){
connection->track_changed = 0;
avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED, connection->track_id, 8);
avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_TRACK_CHANGED);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->playback_status_changed){
if (connection->playback_status_changed){
connection->playback_status_changed = 0;
uint8_t playback_status = (uint8_t) connection->playback_status;
avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED, &playback_status, 1);
avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_PLAYBACK_STATUS_CHANGED);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->playing_content_changed){
if (connection->playing_content_changed){
connection->playing_content_changed = 0;
avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED, NULL, 0);
avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_NOW_PLAYING_CONTENT_CHANGED);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->battery_status_changed){
if (connection->battery_status_changed){
connection->battery_status_changed = 0;
avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED, (uint8_t *)&connection->battery_status, 1);
avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_BATT_STATUS_CHANGED);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->notify_volume_percentage_changed){
if (connection->notify_volume_percentage_changed){
connection->notify_volume_percentage_changed = 0;
avrcp_target_send_notification(connection->l2cap_signaling_cid, connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED, &connection->volume_percentage, 1);
avrcp_target_reset_notification(connection, AVRCP_NOTIFICATION_EVENT_VOLUME_CHANGED);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
else if (connection->reject_transport_header){
if (connection->reject_transport_header){
connection->state = AVCTP_CONNECTION_OPENED;
connection->reject_transport_header = 0;
l2cap_reserve_packet_buffer();
@ -1146,7 +1146,7 @@ static void avrcp_target_packet_handler(uint8_t packet_type, uint16_t channel, u
big_endian_store_16(out_buffer, 1, connection->invalid_pid);
l2cap_send_prepared(connection->l2cap_signaling_cid, 3);
avrcp_request_can_send_now(connection, connection->l2cap_signaling_cid);
break;
return;
}
switch (connection->state){