avrcp_target: allow absolute volume value overwrite when AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED event is received

This commit is contained in:
Milanka Ringwald 2021-10-21 18:48:19 +02:00
parent 984bbc3eff
commit b772a0d769
2 changed files with 23 additions and 2 deletions

View File

@ -743,6 +743,17 @@ uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_st
return ERROR_CODE_SUCCESS;
}
uint8_t avrcp_target_adjust_absolute_volume(uint16_t avrcp_cid, uint8_t absolute_volume){
avrcp_connection_t * connection = avrcp_get_connection_for_avrcp_cid_for_role(AVRCP_TARGET, avrcp_cid);
if (!connection){
log_error("avrcp_unit_info: could not find a connection.");
return ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER;
}
connection->absolute_volume = absolute_volume;
return ERROR_CODE_SUCCESS;
}
uint8_t avrcp_target_volume_changed(uint16_t avrcp_cid, uint8_t absolute_volume){
avrcp_connection_t * connection = avrcp_get_connection_for_avrcp_cid_for_role(AVRCP_TARGET, avrcp_cid);
if (!connection){
@ -1043,8 +1054,8 @@ static void avrcp_handle_l2cap_data_packet_for_signaling_connection(avrcp_connec
if (absolute_volume < 0x80){
connection->absolute_volume = absolute_volume;
}
avrcp_target_response_accept(connection, subunit_type, subunit_id, opcode, pdu_id, connection->absolute_volume);
avrcp_target_emit_volume_changed(avrcp_target_context.avrcp_callback, connection->avrcp_cid, connection->absolute_volume);
avrcp_target_response_accept(connection, subunit_type, subunit_id, opcode, pdu_id, connection->absolute_volume);
break;
}
default:

View File

@ -181,7 +181,17 @@ uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t playe
uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_status_t battery_status);
/**
* @param Set Volume and send notification if enabled
* @param Overwrite the absolute volume requested by controller with the actual absolute volume.
* This function can only be called on AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED event, which indicates a set absolute volume request by controller.
* If the absolute volume requested by controller does not match the granularity of volume control the TG provides, you can use this function to adjust the actual value.
*
* @param avrcp_cid
* @param absolute_volume
* @return
*/
uint8_t avrcp_target_adjust_absolute_volume(uint16_t avrcp_cid, uint8_t absolute_volume);
/**
* @param Set Absolute Volume and send notification if enabled
* @param avrcp_cid