Audio V4: Split HAL wrapper for versioning
Both core and effect Hal now have one single point of entry.
This point of entry is their respective factories:
- DevicesFactoryHalInterface::create
- EffectsFactoryHalInterface::create
Each entry point looks for their respective services supported
version, starting from the highest (currently only 2.0) and
returning the subclass wrapping this version to the most recent audio.h
framework api.
Note that EffectBufferHalInterface were previously created from static
methods (mirror and allocate) which broke the single point of entry
requirement.
As a result, buffers have now to be created from the factory like the
other classes.
Note that the death handler also need to be its own library as it is
used by versioned code and is version independent.
Bug: 38184704
Test: compile
Change-Id: Iac9b1fda561bb486193d5b9e025a870f50cda530
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/media/libaudiohal/DevicesFactoryHalInterface.cpp b/media/libaudiohal/DevicesFactoryHalInterface.cpp
new file mode 100644
index 0000000..cfec3d6
--- /dev/null
+++ b/media/libaudiohal/DevicesFactoryHalInterface.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DevicesFactoryHalHybrid.h"
+#include <android/hardware/audio/2.0/IDevicesFactory.h>
+
+using namespace ::android::hardware::audio;
+
+namespace android {
+
+// static
+sp<DevicesFactoryHalInterface> DevicesFactoryHalInterface::create() {
+ if (V2_0::IDevicesFactory::getService() != nullptr) {
+ return new DevicesFactoryHalHybrid();
+ }
+ return nullptr;
+}
+
+} // namespace android