diff options
author | Mikhail Naganov <mnaganov@google.com> | 2020-12-10 17:25:40 -0800 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2020-12-16 01:14:02 +0000 |
commit | e1a9c8f8b851fde6f8a1ded2c39633c2e2d90cf0 (patch) | |
tree | 45dc8a8537623e68d2a4c45201b82dfc6bb695cb /audio/core/all-versions/default/StreamOut.cpp | |
parent | b52e93f5165c5f909e2a22478891750870969a88 (diff) |
audio: Update default wrapper to support V7
During this conversion, the functionality of the V7 wrapper
hasn't been tested yet. This will be done in a separate CL
that will also include required updates to the VTS tests.
Since the changes were made to the code shared with pre-V7
versions, verified that V6 HAL didn't regress.
Bug: 142480271
Test: atest VtsHalAudioV6_0TargetTest
Test: m VtsHalAudioV7_0TargetTest
Change-Id: I0e42fe1279912ffa78ce40c69f6aa2054e84d385
Merged-In: I0e42fe1279912ffa78ce40c69f6aa2054e84d385
Diffstat (limited to 'audio/core/all-versions/default/StreamOut.cpp')
-rw-r--r-- | audio/core/all-versions/default/StreamOut.cpp | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/audio/core/all-versions/default/StreamOut.cpp b/audio/core/all-versions/default/StreamOut.cpp index 007eb4564a..5633cbb4b7 100644 --- a/audio/core/all-versions/default/StreamOut.cpp +++ b/audio/core/all-versions/default/StreamOut.cpp @@ -26,6 +26,7 @@ #include <memory> +#include <HidlUtils.h> #include <android/log.h> #include <hardware/audio.h> #include <utils/Trace.h> @@ -36,6 +37,8 @@ namespace audio { namespace CPP_VERSION { namespace implementation { +using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils; + namespace { class WriteThread : public Thread { @@ -142,7 +145,7 @@ bool WriteThread::threadLoop() { StreamOut::StreamOut(const sp<Device>& device, audio_stream_out_t* stream) : mDevice(device), mStream(stream), - mStreamCommon(new Stream(&stream->common)), + mStreamCommon(new Stream(false /*isInput*/, &stream->common)), mStreamMmap(new StreamMmap<audio_stream_out_t>(stream)), mEfGroup(nullptr), mStopWriteThread(false) {} @@ -182,6 +185,7 @@ Return<uint64_t> StreamOut::getBufferSize() { return mStreamCommon->getBufferSize(); } +#if MAJOR_VERSION <= 6 Return<uint32_t> StreamOut::getSampleRate() { return mStreamCommon->getSampleRate(); } @@ -228,6 +232,18 @@ Return<Result> StreamOut::setFormat(AudioFormat format) { return mStreamCommon->setFormat(format); } +#else + +Return<void> StreamOut::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) { + return mStreamCommon->getSupportedProfiles(_hidl_cb); +} + +Return<Result> StreamOut::setAudioProperties(const AudioConfigBase& config) { + return mStreamCommon->setAudioProperties(config); +} + +#endif // MAJOR_VERSION <= 6 + Return<void> StreamOut::getAudioProperties(getAudioProperties_cb _hidl_cb) { return mStreamCommon->getAudioProperties(_hidl_cb); } @@ -327,7 +343,11 @@ Return<Result> StreamOut::setVolume(float left, float right) { Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCount, prepareForWriting_cb _hidl_cb) { status_t status; +#if MAJOR_VERSION <= 6 ThreadInfo threadInfo = {0, 0}; +#else + int32_t threadInfo = 0; +#endif // Wrap the _hidl_cb to return an error auto sendError = [&threadInfo, &_hidl_cb](Result result) { @@ -396,8 +416,12 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCou mStatusMQ = std::move(tempStatusMQ); mWriteThread = tempWriteThread.release(); mEfGroup = tempElfGroup.release(); +#if MAJOR_VERSION <= 6 threadInfo.pid = getpid(); threadInfo.tid = mWriteThread->getTid(); +#else + threadInfo = mWriteThread->getTid(); +#endif _hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(), threadInfo); return Void(); @@ -565,14 +589,14 @@ Return<void> StreamOut::updateSourceMetadata(const SourceMetadata& sourceMetadat if (mStream->update_source_metadata == nullptr) { return Void(); // not supported by the HAL } - std::vector<playback_track_metadata> halTracks; + std::vector<playback_track_metadata_t> halTracks; halTracks.reserve(sourceMetadata.tracks.size()); for (auto& metadata : sourceMetadata.tracks) { - halTracks.push_back({ - .usage = static_cast<audio_usage_t>(metadata.usage), - .content_type = static_cast<audio_content_type_t>(metadata.contentType), - .gain = metadata.gain, - }); + playback_track_metadata_t halTrackMetadata = {.gain = metadata.gain}; + (void)HidlUtils::audioUsageToHal(metadata.usage, &halTrackMetadata.usage); + (void)HidlUtils::audioContentTypeToHal(metadata.contentType, + &halTrackMetadata.content_type); + halTracks.push_back(std::move(halTrackMetadata)); } const source_metadata_t halMetadata = { .track_count = halTracks.size(), |