summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/AudioFlinger.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/audioflinger/AudioFlinger.cpp')
-rw-r--r--services/audioflinger/AudioFlinger.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index bf94efe..724b1e3 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -255,6 +255,9 @@ AudioFlinger::AudioFlinger()
void AudioFlinger::onFirstRef()
{
int rc = 0;
+#ifdef QCOM_HARDWARE
+ mA2DPHandle = -1;
+#endif
Mutex::Autolock _l(mLock);
@@ -866,6 +869,9 @@ status_t AudioFlinger::setMasterVolume(float value)
return PERMISSION_DENIED;
}
+#ifdef QCOM_HARDWARE
+ mA2DPHandle = -1;
+#endif
Mutex::Autolock _l(mLock);
mMasterVolume = value;
@@ -1351,7 +1357,7 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
sp<NotificationClient> notificationClient = new NotificationClient(this,
client,
binder);
- ALOGV("registerClient() client %p, binder %d", notificationClient.get(), binder.get);
+ ALOGV("registerClient() client %p, binder %d", notificationClient.get(), binder.get());
mNotificationClients.add(binder, notificationClient);
@@ -1368,6 +1374,13 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
mRecordThreads.valueAt(i)->sendIoConfigEvent(AudioSystem::INPUT_OPENED);
}
}
+#ifdef QCOM_HARDWARE
+ // Send the notification to the client only once.
+ if (mA2DPHandle != -1) {
+ ALOGV("A2DP active. Notifying the registered client");
+ client->ioConfigChanged(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &mA2DPHandle);
+ }
+#endif
}
#ifdef QCOM_HARDWARE
@@ -7675,6 +7688,15 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
#endif
mPlaybackThreads.add(id, thread);
+#ifdef QCOM_HARDWARE
+ // if the device is a A2DP, then this is an A2DP Output
+ if ( true == audio_is_a2dp_device((audio_devices_t) *pDevices) )
+ {
+ mA2DPHandle = id;
+ ALOGV("A2DP device activated. The handle is set to %d", mA2DPHandle);
+ }
+#endif
+
if (pSamplingRate != NULL) *pSamplingRate = config.sample_rate;
if (pFormat != NULL) *pFormat = config.format;
if (pChannelMask != NULL) *pChannelMask = config.channel_mask;
@@ -7775,6 +7797,14 @@ status_t AudioFlinger::closeOutput_nonvirtual(audio_io_handle_t output)
}
audioConfigChanged_l(AudioSystem::OUTPUT_CLOSED, output, NULL);
mPlaybackThreads.removeItem(output);
+#ifdef QCOM_HARDWARE
+ if (mA2DPHandle == output)
+ {
+ mA2DPHandle = -1;
+ ALOGV("A2DP OutputClosed Notifying Client");
+ audioConfigChanged_l(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &mA2DPHandle);
+ }
+#endif
}
thread->exit();
// The thread entity (active unit of execution) is no longer running here,
@@ -7960,6 +7990,12 @@ status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, audio_io_hand
PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
thread->invalidateTracks(stream);
}
+#ifdef QCOM_HARDWARE
+ if ( mA2DPHandle == output ) {
+ ALOGV("A2DP Activated and hence notifying the client");
+ audioConfigChanged_l(AudioSystem::A2DP_OUTPUT_STATE, mA2DPHandle, &output);
+ }
+#endif
return NO_ERROR;
}