OSDN Git Service

AudioSystem: new audioflinger restart detection
authorEric Laurent <elaurent@google.com>
Thu, 18 Jul 2013 21:38:44 +0000 (14:38 -0700)
committerEric Laurent <elaurent@google.com>
Tue, 20 Aug 2013 00:45:42 +0000 (17:45 -0700)
Add a specific method to AudioSystem for AudioService to poll
for AudioFlinger service restart instead of relying on current
callback mechanism which is flaky.

Bug: 9693068.
Change-Id: Ie88bc9d25033503bc5cd2fa9d8c754d0f8045b8f

include/media/AudioSystem.h
media/libmedia/AudioSystem.cpp

index 006af08..225ef76 100644 (file)
@@ -252,6 +252,9 @@ public:
     // bit rate, duration, video and streaming or offload property is enabled
     static bool isOffloadSupported(const audio_offload_info_t& info);
 
+    // check presence of audio flinger service.
+    // returns NO_ERROR if binding to service succeeds, DEAD_OBJECT otherwise
+    static status_t checkAudioFlinger();
     // ----------------------------------------------------------------------------
 
 private:
index a571fe4..8033c2c 100644 (file)
@@ -76,6 +76,14 @@ const sp<IAudioFlinger>& AudioSystem::get_audio_flinger()
     return gAudioFlinger;
 }
 
+/* static */ status_t AudioSystem::checkAudioFlinger()
+{
+    if (defaultServiceManager()->checkService(String16("media.audio_flinger")) != 0) {
+        return NO_ERROR;
+    }
+    return DEAD_OBJECT;
+}
+
 status_t AudioSystem::muteMicrophone(bool state) {
     const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
     if (af == 0) return PERMISSION_DENIED;