Bug 1102703: (8/10) Porting bluetooth interface of bluez 5.26 (a2dp) r=btian, f=tzimmermann

This commit is contained in:
Bruce Sun 2015-01-09 13:38:53 +08:00
parent ab37e51ad8
commit 6d06d39873
2 changed files with 59 additions and 1 deletions

View File

@ -262,6 +262,52 @@ BluetoothDaemonA2dpModule::AudioStateNtf(
AudioStateInitOp(aPDU)); AudioStateInitOp(aPDU));
} }
// Init operator class for AudioConfigNotification
class BluetoothDaemonA2dpModule::AudioConfigInitOp MOZ_FINAL
: private PDUInitOp
{
public:
AudioConfigInitOp(BluetoothDaemonPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (nsString& aArg1, uint32_t aArg2, uint8_t aArg3) const
{
BluetoothDaemonPDU& pdu = GetPDU();
/* Read address */
nsresult rv = UnpackPDU(
pdu, UnpackConversion<BluetoothAddress, nsAString>(aArg1));
if (NS_FAILED(rv)) {
return rv;
}
/* Read sample rate */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read channel count */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void
BluetoothDaemonA2dpModule::AudioConfigNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU)
{
AudioConfigNotification::Dispatch(
&BluetoothA2dpNotificationHandler::AudioConfigNotification,
AudioConfigInitOp(aPDU));
}
void void
BluetoothDaemonA2dpModule::HandleNtf( BluetoothDaemonA2dpModule::HandleNtf(
const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU, const BluetoothDaemonPDUHeader& aHeader, BluetoothDaemonPDU& aPDU,
@ -271,6 +317,9 @@ BluetoothDaemonA2dpModule::HandleNtf(
const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = { const BluetoothDaemonPDUHeader&, BluetoothDaemonPDU&) = {
INIT_ARRAY_AT(0, &BluetoothDaemonA2dpModule::ConnectionStateNtf), INIT_ARRAY_AT(0, &BluetoothDaemonA2dpModule::ConnectionStateNtf),
INIT_ARRAY_AT(1, &BluetoothDaemonA2dpModule::AudioStateNtf), INIT_ARRAY_AT(1, &BluetoothDaemonA2dpModule::AudioStateNtf),
#if ANDROID_VERSION >= 21
INIT_ARRAY_AT(2, &BluetoothDaemonA2dpModule::AudioConfigNtf),
#endif
}; };
MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!NS_IsMainThread());

View File

@ -105,8 +105,14 @@ protected:
const nsAString&> const nsAString&>
AudioStateNotification; AudioStateNotification;
class AudioStateInitOp; typedef BluetoothNotificationRunnable3<NotificationHandlerWrapper, void,
nsString, uint32_t, uint8_t,
const nsAString&, uint32_t, uint8_t>
AudioConfigNotification;
class ConnectionStateInitOp; class ConnectionStateInitOp;
class AudioStateInitOp;
class AudioConfigInitOp;
void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader, void ConnectionStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU); BluetoothDaemonPDU& aPDU);
@ -114,6 +120,9 @@ protected:
void AudioStateNtf(const BluetoothDaemonPDUHeader& aHeader, void AudioStateNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU); BluetoothDaemonPDU& aPDU);
void AudioConfigNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU);
void HandleNtf(const BluetoothDaemonPDUHeader& aHeader, void HandleNtf(const BluetoothDaemonPDUHeader& aHeader,
BluetoothDaemonPDU& aPDU, BluetoothDaemonPDU& aPDU,
void* aUserData); void* aUserData);