void BluetoothDaemonA2dpModule::HandleNtf( const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, void* aUserData) { static void (BluetoothDaemonA2dpModule::* const HandleNtf[])( const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = { INIT_ARRAY_AT(0, &BluetoothDaemonA2dpModule::ConnectionStateNtf), INIT_ARRAY_AT(1, &BluetoothDaemonA2dpModule::AudioStateNtf), #if ANDROID_VERSION >= 21 INIT_ARRAY_AT(2, &BluetoothDaemonA2dpModule::AudioConfigNtf), #endif }; MOZ_ASSERT(!NS_IsMainThread()); uint8_t index = aHeader.mOpcode - 0x81; if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) || NS_WARN_IF(!HandleNtf[index])) { return; } (this->*(HandleNtf[index]))(aHeader, aPDU); }
void BluetoothDaemonA2dpModule::HandleRsp( const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, void* aUserData) { static void (BluetoothDaemonA2dpModule::* const HandleRsp[])( const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&, BluetoothA2dpResultHandler*) = { INIT_ARRAY_AT(OPCODE_ERROR, &BluetoothDaemonA2dpModule::ErrorRsp), INIT_ARRAY_AT(OPCODE_CONNECT, &BluetoothDaemonA2dpModule::ConnectRsp), INIT_ARRAY_AT(OPCODE_DISCONNECT, &BluetoothDaemonA2dpModule::DisconnectRsp), }; MOZ_ASSERT(!NS_IsMainThread()); // I/O thread if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) || NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) { return; } nsRefPtr<BluetoothA2dpResultHandler> res = already_AddRefed<BluetoothA2dpResultHandler>( static_cast<BluetoothA2dpResultHandler*>(aUserData)); if (!res) { return; // Return early if no result handler has been set for response } (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res); }
void BluetoothDaemonAvrcpModule::HandleSvc(const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, void* aUserData) { static void (BluetoothDaemonAvrcpModule::* const HandleOp[])( const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&, void*) = { INIT_ARRAY_AT(0, &BluetoothDaemonAvrcpModule::HandleRsp), INIT_ARRAY_AT(1, &BluetoothDaemonAvrcpModule::HandleNtf), }; MOZ_ASSERT(!NS_IsMainThread()); unsigned int isNtf = !!(aHeader.mOpcode & 0x80); (this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData); }
void BluetoothDaemonAvrcpModule::HandleRsp( const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, void* aUserData) { static void (BluetoothDaemonAvrcpModule::* const HandleRsp[])( const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&, BluetoothAvrcpResultHandler*) = { INIT_ARRAY_AT(OPCODE_ERROR, &BluetoothDaemonAvrcpModule::ErrorRsp), INIT_ARRAY_AT(OPCODE_GET_PLAY_STATUS_RSP, &BluetoothDaemonAvrcpModule::GetPlayStatusRspRsp), INIT_ARRAY_AT(OPCODE_LIST_PLAYER_APP_ATTR_RSP, &BluetoothDaemonAvrcpModule::ListPlayerAppAttrRspRsp), INIT_ARRAY_AT(OPCODE_LIST_PLAYER_APP_VALUE_RSP, &BluetoothDaemonAvrcpModule::ListPlayerAppValueRspRsp), INIT_ARRAY_AT(OPCODE_GET_PLAYER_APP_VALUE_RSP, &BluetoothDaemonAvrcpModule::GetPlayerAppValueRspRsp), INIT_ARRAY_AT(OPCODE_GET_PLAYER_APP_ATTR_TEXT_RSP, &BluetoothDaemonAvrcpModule::GetPlayerAppAttrTextRspRsp), INIT_ARRAY_AT(OPCODE_GET_PLAYER_APP_VALUE_TEXT_RSP, &BluetoothDaemonAvrcpModule::GetPlayerAppValueTextRspRsp), INIT_ARRAY_AT(OPCODE_GET_ELEMENT_ATTR_RSP, &BluetoothDaemonAvrcpModule::GetElementAttrRspRsp), INIT_ARRAY_AT(OPCODE_SET_PLAYER_APP_VALUE_RSP, &BluetoothDaemonAvrcpModule::SetPlayerAppValueRspRsp), INIT_ARRAY_AT(OPCODE_REGISTER_NOTIFICATION_RSP, &BluetoothDaemonAvrcpModule::RegisterNotificationRspRsp), INIT_ARRAY_AT(OPCODE_SET_VOLUME, &BluetoothDaemonAvrcpModule::SetVolumeRsp) }; MOZ_ASSERT(!NS_IsMainThread()); // I/O thread if (NS_WARN_IF(!(aHeader.mOpcode < MOZ_ARRAY_LENGTH(HandleRsp))) || NS_WARN_IF(!HandleRsp[aHeader.mOpcode])) { return; } nsRefPtr<BluetoothAvrcpResultHandler> res = already_AddRefed<BluetoothAvrcpResultHandler>( static_cast<BluetoothAvrcpResultHandler*>(aUserData)); if (!res) { return; // Return early if no result handler has been set for response } (this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res); }
void BluetoothDaemonAvrcpModule::HandleNtf( const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, void* aUserData) { static void (BluetoothDaemonAvrcpModule::* const HandleNtf[])( const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = { #if ANDROID_VERSION >= 19 INIT_ARRAY_AT(0, &BluetoothDaemonAvrcpModule::RemoteFeatureNtf), INIT_ARRAY_AT(1, &BluetoothDaemonAvrcpModule::GetPlayStatusNtf), INIT_ARRAY_AT(2, &BluetoothDaemonAvrcpModule::ListPlayerAppAttrNtf), INIT_ARRAY_AT(3, &BluetoothDaemonAvrcpModule::ListPlayerAppValuesNtf), INIT_ARRAY_AT(4, &BluetoothDaemonAvrcpModule::GetPlayerAppValueNtf), INIT_ARRAY_AT(5, &BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextNtf), INIT_ARRAY_AT(6, &BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextNtf), INIT_ARRAY_AT(7, &BluetoothDaemonAvrcpModule::SetPlayerAppValueNtf), INIT_ARRAY_AT(8, &BluetoothDaemonAvrcpModule::GetElementAttrNtf), INIT_ARRAY_AT(9, &BluetoothDaemonAvrcpModule::RegisterNotificationNtf), INIT_ARRAY_AT(10, &BluetoothDaemonAvrcpModule::VolumeChangeNtf), INIT_ARRAY_AT(11, &BluetoothDaemonAvrcpModule::PassthroughCmdNtf) #else INIT_ARRAY_AT(0, &BluetoothDaemonAvrcpModule::GetPlayStatusNtf), INIT_ARRAY_AT(1, &BluetoothDaemonAvrcpModule::ListPlayerAppAttrNtf), INIT_ARRAY_AT(2, &BluetoothDaemonAvrcpModule::ListPlayerAppValuesNtf), INIT_ARRAY_AT(3, &BluetoothDaemonAvrcpModule::GetPlayerAppValueNtf), INIT_ARRAY_AT(4, &BluetoothDaemonAvrcpModule::GetPlayerAppAttrsTextNtf), INIT_ARRAY_AT(5, &BluetoothDaemonAvrcpModule::GetPlayerAppValuesTextNtf), INIT_ARRAY_AT(6, &BluetoothDaemonAvrcpModule::SetPlayerAppValueNtf), INIT_ARRAY_AT(7, &BluetoothDaemonAvrcpModule::GetElementAttrNtf), INIT_ARRAY_AT(8, &BluetoothDaemonAvrcpModule::RegisterNotificationNtf) #endif }; MOZ_ASSERT(!NS_IsMainThread()); uint8_t index = aHeader.mOpcode - 0x81; if (NS_WARN_IF(!(index < MOZ_ARRAY_LENGTH(HandleNtf))) || NS_WARN_IF(!HandleNtf[index])) { return; } (this->*(HandleNtf[index]))(aHeader, aPDU); }