Bug 1038645: Asynchronous |BluetoothHandsfreeInterface::VolumeControl| (under bluetooth2/), r=btian

This commit is contained in:
Thomas Zimmermann 2014-07-22 13:53:28 +02:00
parent 2f9bac6204
commit c6f9bb3981
3 changed files with 24 additions and 8 deletions

View File

@ -720,11 +720,16 @@ BluetoothHandsfreeInterface::StopVoiceRecognition(
/* Volume */
bt_status_t
BluetoothHandsfreeInterface::VolumeControl(bthf_volume_type_t aType,
int aVolume)
void
BluetoothHandsfreeInterface::VolumeControl(
bthf_volume_type_t aType, int aVolume, BluetoothHandsfreeResultHandler* aRes)
{
return mInterface->volume_control(aType, aVolume);
bt_status_t status = mInterface->volume_control(aType, aVolume);
if (aRes) {
DispatchBluetoothHandsfreeResult(
aRes, &BluetoothHandsfreeResultHandler::VolumeControl, status);
}
}
/* Device status */

View File

@ -134,7 +134,8 @@ public:
/* Volume */
bt_status_t VolumeControl(bthf_volume_type_t aType, int aVolume);
void VolumeControl(bthf_volume_type_t aType, int aVolume,
BluetoothHandsfreeResultHandler* aRes);
/* Device status */

View File

@ -968,6 +968,17 @@ BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
}
class VolumeControlResultHandler MOZ_FINAL
: public BluetoothHandsfreeResultHandler
{
public:
void OnError(bt_status_t aStatus) MOZ_OVERRIDE
{
BT_WARNING("BluetoothHandsfreeInterface::VolumeControl failed: %d",
(int)aStatus);
}
};
void
BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
{
@ -1012,9 +1023,8 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
// Only send volume back when there's a connected headset
if (IsConnected()) {
NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface);
NS_ENSURE_TRUE_VOID(BT_STATUS_SUCCESS ==
sBluetoothHfpInterface->VolumeControl(BTHF_VOLUME_TYPE_SPK,
mCurrentVgs));
sBluetoothHfpInterface->VolumeControl(BTHF_VOLUME_TYPE_SPK, mCurrentVgs,
new VolumeControlResultHandler());
}
}