Implement audio devices and streams HAL delegating to legacy HAL
Changes made to the .hal definition:
- introduce Effect ID returned by the IEffectsFactory that
needs to be passed to IStream.{add|remove}Effect; otherwise
it's impossible to retrieve the underlying HAL effect handle;
- change "bus address" in DeviceAddress to "string" type;
- fix signature of some methods w.r.t. returning Result;
- remove unused "struct AudioPatch".
Bug: 30222631
Test: make
Change-Id: Icb51729ef57bb2a5b0b78609735e7481bc04f95c
diff --git a/audio/2.0/default/service.cpp b/audio/2.0/default/service.cpp
index 39708c2..147f7b9 100644
--- a/audio/2.0/default/service.cpp
+++ b/audio/2.0/default/service.cpp
@@ -14,28 +14,23 @@
* limitations under the License.
*/
-#define LOG_TAG "soundtriggerhal"
+#define LOG_TAG "audiohalservice"
-#include <hwbinder/IInterface.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/Log.h>
-#include <utils/Looper.h>
-#include <utils/StrongPointer.h>
+#include <hidl/LegacySupport.h>
+#include <android/hardware/audio/2.0/IDevicesFactory.h>
+#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
+using android::hardware::audio::effect::V2_0::IEffectsFactory;
+using android::hardware::audio::V2_0::IDevicesFactory;
using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
+using android::hardware::registerPassthroughServiceImplementation;
int main(int /* argc */, char* /* argv */ []) {
- android::sp<ISoundTriggerHw> service =
- ISoundTriggerHw::getService("sound_trigger.primary", true /* getStub */);
-
- service->registerAsService("sound_trigger.primary");
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
+ registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
+ registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
+ return android::hardware::launchRpcServer(16);
}