summaryrefslogtreecommitdiff
path: root/audio_proxy
diff options
context:
space:
mode:
authorCarter Hsu <carterhsu@google.com>2022-02-14 01:02:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2022-02-14 01:02:04 +0000
commita05a45721ba11ead7375ea71a2faad71d571bba5 (patch)
tree151069353efba15337e2f1e43a145557cee9d8cf /audio_proxy
parent1a8c7984cfcb130756ff352cf861923796137d01 (diff)
parente3324fdcf49e585280b58e1595c183f22648b5be (diff)
downloadatv-a05a45721ba11ead7375ea71a2faad71d571bba5.tar.gz
Merge "[AudioProxy] Audio HAL 7.1 implementation"
Diffstat (limited to 'audio_proxy')
-rw-r--r--audio_proxy/common/AudioProxyVersionMacro.h7
-rw-r--r--audio_proxy/service/Android.bp6
-rw-r--r--audio_proxy/service/DeviceImpl.cpp38
-rw-r--r--audio_proxy/service/DeviceImpl.h25
-rw-r--r--audio_proxy/service/DevicesFactoryImpl.cpp25
-rw-r--r--audio_proxy/service/DevicesFactoryImpl.h12
-rw-r--r--audio_proxy/service/StreamOutImpl.cpp19
-rw-r--r--audio_proxy/service/StreamOutImpl.h14
-rw-r--r--audio_proxy/service/manifest_audio_proxy_7_1.xml3
9 files changed, 134 insertions, 15 deletions
diff --git a/audio_proxy/common/AudioProxyVersionMacro.h b/audio_proxy/common/AudioProxyVersionMacro.h
index 6f788fb..d8fcd1b 100644
--- a/audio_proxy/common/AudioProxyVersionMacro.h
+++ b/audio_proxy/common/AudioProxyVersionMacro.h
@@ -36,5 +36,8 @@
#define CONCAT_4(a, b, c, d) a##b##c##d
#define EXPAND_CONCAT_4(a, b, c, d) CONCAT_4(a, b, c, d)
-/** The c++ namespace of the version: V<major>_<minor> */
-#define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, MINOR_VERSION)
+/** The c++ namespace of the version: V<major>_0.
+ * Always use minor version 0's namespace. If minor version is not zero, use
+ * the full namespace path explicitly.
+ */
+#define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, 0)
diff --git a/audio_proxy/service/Android.bp b/audio_proxy/service/Android.bp
index ed3ae69..2c219c6 100644
--- a/audio_proxy/service/Android.bp
+++ b/audio_proxy/service/Android.bp
@@ -162,15 +162,15 @@ cc_binary {
vintf_fragments: [ "manifest_audio_proxy_7_1.xml" ],
- // TODO(197547824): Upgrade to 7.1
shared_libs: [
+ "android.hardware.audio@7.1",
"android.hardware.audio@7.0",
"android.hardware.audio.common@7.0",
],
cflags: [
"-DMAJOR_VERSION=7",
- "-DMINOR_VERSION=0",
+ "-DMINOR_VERSION=1",
],
}
@@ -185,4 +185,4 @@ cc_test {
"audio_proxy_service_util",
"libgtest",
],
-} \ No newline at end of file
+}
diff --git a/audio_proxy/service/DeviceImpl.cpp b/audio_proxy/service/DeviceImpl.cpp
index c3b3a68..4684dec 100644
--- a/audio_proxy/service/DeviceImpl.cpp
+++ b/audio_proxy/service/DeviceImpl.cpp
@@ -25,8 +25,8 @@
#include "BusStreamProvider.h"
#include "StreamOutImpl.h"
-using namespace ::android::hardware::audio::CPP_VERSION;
using namespace ::android::hardware::audio::common::CPP_VERSION;
+using namespace ::android::hardware::audio::CPP_VERSION;
using ::android::wp;
@@ -113,12 +113,11 @@ Return<void> DeviceImpl::getInputBufferSize(const AudioConfig& config,
}
#if MAJOR_VERSION >= 7
-Return<void> DeviceImpl::openOutputStream(int32_t ioHandle,
- const DeviceAddress& device,
- const AudioConfig& config,
- const hidl_vec<AudioInOutFlag>& flags,
- const SourceMetadata& sourceMetadata,
- openOutputStream_cb _hidl_cb) {
+template <typename CallbackType>
+Return<void> DeviceImpl::openOutputStreamImpl(
+ int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
+ const hidl_vec<AudioInOutFlag>& flags, const SourceMetadata& sourceMetadata,
+ CallbackType _hidl_cb) {
if (device.deviceType != "AUDIO_DEVICE_OUT_BUS") {
DCHECK(false);
_hidl_cb(Result::INVALID_ARGUMENTS, nullptr, {});
@@ -155,6 +154,16 @@ Return<void> DeviceImpl::openOutputStream(int32_t ioHandle,
return Void();
}
+Return<void> DeviceImpl::openOutputStream(int32_t ioHandle,
+ const DeviceAddress& device,
+ const AudioConfig& config,
+ const hidl_vec<AudioInOutFlag>& flags,
+ const SourceMetadata& sourceMetadata,
+ openOutputStream_cb _hidl_cb) {
+ return openOutputStreamImpl(ioHandle, device, config, flags, sourceMetadata,
+ _hidl_cb);
+}
+
Return<void> DeviceImpl::openInputStream(int32_t ioHandle,
const DeviceAddress& device,
const AudioConfig& config,
@@ -284,5 +293,20 @@ Return<Result> DeviceImpl::removeDeviceEffect(AudioPortHandle device,
}
#endif
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+Return<void> DeviceImpl::openOutputStream_7_1(
+ int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
+ const hidl_vec<AudioInOutFlag>& flags, const SourceMetadata& sourceMetadata,
+ openOutputStream_7_1_cb _hidl_cb) {
+ return openOutputStreamImpl(ioHandle, device, config, flags, sourceMetadata,
+ _hidl_cb);
+}
+
+Return<Result> DeviceImpl::setConnectedState_7_1(const AudioPort& devicePort,
+ bool connected) {
+ return Result::OK;
+}
+#endif
+
} // namespace service
} // namespace audio_proxy
diff --git a/audio_proxy/service/DeviceImpl.h b/audio_proxy/service/DeviceImpl.h
index bcdd551..44ad3b0 100644
--- a/audio_proxy/service/DeviceImpl.h
+++ b/audio_proxy/service/DeviceImpl.h
@@ -55,7 +55,11 @@ using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag;
class BusStreamProvider;
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+class DeviceImpl : public android::hardware::audio::V7_1::IDevice {
+#else
class DeviceImpl : public IDevice {
+#endif
public:
DeviceImpl(BusStreamProvider& busStreamProvider, uint32_t bufferSizeMs,
uint32_t latencyMs);
@@ -127,7 +131,28 @@ class DeviceImpl : public IDevice {
uint64_t effectId) override;
#endif
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+ Return<void> openOutputStream_7_1(int32_t ioHandle,
+ const DeviceAddress& device,
+ const AudioConfig& config,
+ const hidl_vec<AudioInOutFlag>& flags,
+ const SourceMetadata& sourceMetadata,
+ openOutputStream_7_1_cb _hidl_cb) override;
+ Return<Result> setConnectedState_7_1(const AudioPort& devicePort,
+ bool connected) override;
+#endif
+
private:
+#if MAJOR_VERSION >= 7
+ template<typename CallbackType>
+ Return<void> openOutputStreamImpl(int32_t ioHandle,
+ const DeviceAddress& device,
+ const AudioConfig& config,
+ const hidl_vec<AudioInOutFlag>& flags,
+ const SourceMetadata& sourceMetadata,
+ CallbackType _hidl_cb);
+#endif
+
BusStreamProvider& mBusStreamProvider;
const uint32_t mBufferSizeMs;
const uint32_t mLatencyMs;
diff --git a/audio_proxy/service/DevicesFactoryImpl.cpp b/audio_proxy/service/DevicesFactoryImpl.cpp
index fc90988..a93ad4c 100644
--- a/audio_proxy/service/DevicesFactoryImpl.cpp
+++ b/audio_proxy/service/DevicesFactoryImpl.cpp
@@ -26,7 +26,7 @@ DevicesFactoryImpl::DevicesFactoryImpl(BusStreamProvider& busStreamProvider,
const ServiceConfig& config)
: mBusStreamProvider(busStreamProvider), mConfig(config) {}
-// Methods from android::hardware::audio::V5_0::IDevicesFactory follow.
+// Methods from android::hardware::audio::CPP_VERSION::IDevicesFactory follow.
Return<void> DevicesFactoryImpl::openDevice(const hidl_string& device,
openDevice_cb _hidl_cb) {
if (device == mConfig.name) {
@@ -48,5 +48,28 @@ Return<void> DevicesFactoryImpl::openPrimaryDevice(
return Void();
}
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+Return<void> DevicesFactoryImpl::openDevice_7_1(const hidl_string& device,
+ openDevice_7_1_cb _hidl_cb) {
+ if (device == mConfig.name) {
+ LOG(INFO) << "Audio Device was opened: " << device;
+ _hidl_cb(Result::OK,
+ new DeviceImpl(mBusStreamProvider, mConfig.bufferSizeMs,
+ mConfig.latencyMs));
+ } else {
+ _hidl_cb(Result::INVALID_ARGUMENTS, nullptr);
+ }
+
+ return Void();
+}
+
+Return<void> DevicesFactoryImpl::openPrimaryDevice_7_1(
+ openPrimaryDevice_7_1_cb _hidl_cb) {
+ // The AudioProxy HAL does not support a primary device.
+ _hidl_cb(Result::NOT_SUPPORTED, nullptr);
+ return Void();
+}
+#endif
+
} // namespace service
} // namespace audio_proxy
diff --git a/audio_proxy/service/DevicesFactoryImpl.h b/audio_proxy/service/DevicesFactoryImpl.h
index dd52d7c..560692e 100644
--- a/audio_proxy/service/DevicesFactoryImpl.h
+++ b/audio_proxy/service/DevicesFactoryImpl.h
@@ -25,7 +25,12 @@ namespace audio_proxy {
namespace service {
using android::hardware::Return;
+
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+using android::hardware::audio::V7_1::IDevicesFactory;
+#else
using android::hardware::audio::CPP_VERSION::IDevicesFactory;
+#endif
class BusStreamProvider;
@@ -39,6 +44,13 @@ class DevicesFactoryImpl : public IDevicesFactory {
openDevice_cb _hidl_cb) override;
Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override;
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+ Return<void> openDevice_7_1(const hidl_string& device,
+ openDevice_7_1_cb _hidl_cb) override;
+ Return<void> openPrimaryDevice_7_1(
+ openPrimaryDevice_7_1_cb _hidl_cb) override;
+#endif
+
private:
BusStreamProvider& mBusStreamProvider;
const ServiceConfig mConfig;
diff --git a/audio_proxy/service/StreamOutImpl.cpp b/audio_proxy/service/StreamOutImpl.cpp
index d37752b..f98bae7 100644
--- a/audio_proxy/service/StreamOutImpl.cpp
+++ b/audio_proxy/service/StreamOutImpl.cpp
@@ -567,4 +567,23 @@ Return<Result> StreamOutImpl::setPlaybackRateParameters(
}
#endif
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+Return<Result> StreamOutImpl::setLatencyMode(
+ android::hardware::audio::V7_1::LatencyMode mode) {
+ return Result::NOT_SUPPORTED;
+}
+
+Return<void> StreamOutImpl::getRecommendedLatencyModes(
+ getRecommendedLatencyModes_cb _hidl_cb) {
+ _hidl_cb(Result::NOT_SUPPORTED, {});
+ return Void();
+}
+
+Return<Result> StreamOutImpl::setLatencyModeCallback(
+ const sp<android::hardware::audio::V7_1::IStreamOutLatencyModeCallback>&
+ cb) {
+ return Result::NOT_SUPPORTED;
+}
+#endif
+
} // namespace audio_proxy::service
diff --git a/audio_proxy/service/StreamOutImpl.h b/audio_proxy/service/StreamOutImpl.h
index 5a811f8..aa394a6 100644
--- a/audio_proxy/service/StreamOutImpl.h
+++ b/audio_proxy/service/StreamOutImpl.h
@@ -44,7 +44,11 @@ class WriteThread;
typedef void (*EventFlagDeleter)(EventFlag*);
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+class StreamOutImpl : public android::hardware::audio::V7_1::IStreamOut {
+#else
class StreamOutImpl : public IStreamOut {
+#endif
public:
using CommandMQ = MessageQueue<WriteCommand, kSynchronizedReadWrite>;
using DataMQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
@@ -143,6 +147,16 @@ class StreamOutImpl : public IStreamOut {
const PlaybackRate& playbackRate) override;
#endif
+#if MAJOR_VERSION == 7 && MINOR_VERSION == 1
+ Return<Result> setLatencyMode(
+ android::hardware::audio::V7_1::LatencyMode mode) override;
+ Return<void> getRecommendedLatencyModes(
+ getRecommendedLatencyModes_cb _hidl_cb) override;
+ Return<Result> setLatencyModeCallback(
+ const sp<android::hardware::audio::V7_1::IStreamOutLatencyModeCallback>&
+ cb) override;
+#endif
+
private:
uint64_t estimateTotalPlayedFrames() const;
diff --git a/audio_proxy/service/manifest_audio_proxy_7_1.xml b/audio_proxy/service/manifest_audio_proxy_7_1.xml
index 1000527..1b3bc8b 100644
--- a/audio_proxy/service/manifest_audio_proxy_7_1.xml
+++ b/audio_proxy/service/manifest_audio_proxy_7_1.xml
@@ -8,7 +8,6 @@
<hal format="hidl">
<name>android.hardware.audio</name>
<transport>hwbinder</transport>
- <!-- TODO(b/197547824): Upgrade to 7.1 -->
- <fqname>@7.0::IDevicesFactory/mediashell</fqname>
+ <fqname>@7.1::IDevicesFactory/mediashell</fqname>
</hal>
</manifest>