OSDN Git Service

audio: Check status of registerPassthroughServiceImplementation
authorMikhail Naganov <mnaganov@google.com>
Thu, 9 Feb 2017 00:34:22 +0000 (16:34 -0800)
committerMikhail Naganov <mnaganov@google.com>
Thu, 9 Feb 2017 00:56:33 +0000 (16:56 -0800)
Make sure the server aborts if it can't register the main audio
service and the effects service.

Soundtrigger and FM radio are optional, thus their failure to
register is only logged.

Bug: 34634573
Change-Id: If96e3238fe4d986e91581cc1ea0d9b36c24a8b9c
Test: restart audio service

audio/2.0/default/service.cpp

index 646d898..8b608c8 100644 (file)
@@ -33,11 +33,20 @@ using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
 using android::hardware::registerPassthroughServiceImplementation;
 using android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
 
+using android::OK;
+
 int main(int /* argc */, char* /* argv */ []) {
     configureRpcThreadpool(16, true /*callerWillJoin*/);
-    registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
-    registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
-    registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
-    registerPassthroughServiceImplementation<IBroadcastRadioFactory>("broadcastradio");
+    android::status_t status;
+    status = registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
+    LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio service: %d", status);
+    status = registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
+    LOG_ALWAYS_FATAL_IF(status != OK, "Error while registering audio effects service: %d", status);
+    // Soundtrigger and FM radio might be not present.
+    status = registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
+    ALOGE_IF(status != OK, "Error while registering soundtrigger service: %d", status);
+    status = registerPassthroughServiceImplementation<IBroadcastRadioFactory>("broadcastradio");
+    ALOGE_IF(status != OK, "Error while registering fm radio service: %d", status);
     joinRpcThreadpool();
+    return status;
 }