summaryrefslogtreecommitdiff
path: root/audio/core/all-versions/default/StreamIn.cpp
diff options
context:
space:
mode:
authorMikhail Naganov <mnaganov@google.com>2020-12-10 17:25:40 -0800
committerMikhail Naganov <mnaganov@google.com>2020-12-16 01:14:02 +0000
commite1a9c8f8b851fde6f8a1ded2c39633c2e2d90cf0 (patch)
tree45dc8a8537623e68d2a4c45201b82dfc6bb695cb /audio/core/all-versions/default/StreamIn.cpp
parentb52e93f5165c5f909e2a22478891750870969a88 (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/StreamIn.cpp')
-rw-r--r--audio/core/all-versions/default/StreamIn.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/audio/core/all-versions/default/StreamIn.cpp b/audio/core/all-versions/default/StreamIn.cpp
index f1152ca542..ead7204712 100644
--- a/audio/core/all-versions/default/StreamIn.cpp
+++ b/audio/core/all-versions/default/StreamIn.cpp
@@ -24,11 +24,12 @@
//#define LOG_NDEBUG 0
#define ATRACE_TAG ATRACE_TAG_AUDIO
+#include <HidlUtils.h>
#include <android/log.h>
#include <hardware/audio.h>
#include <utils/Trace.h>
-#include <memory>
#include <cmath>
+#include <memory>
namespace android {
namespace hardware {
@@ -36,6 +37,8 @@ namespace audio {
namespace CPP_VERSION {
namespace implementation {
+using ::android::hardware::audio::common::CPP_VERSION::implementation::HidlUtils;
+
namespace {
class ReadThread : public Thread {
@@ -141,7 +144,7 @@ bool ReadThread::threadLoop() {
StreamIn::StreamIn(const sp<Device>& device, audio_stream_in_t* stream)
: mDevice(device),
mStream(stream),
- mStreamCommon(new Stream(&stream->common)),
+ mStreamCommon(new Stream(true /*isInput*/, &stream->common)),
mStreamMmap(new StreamMmap<audio_stream_in_t>(stream)),
mEfGroup(nullptr),
mStopReadThread(false) {}
@@ -177,6 +180,7 @@ Return<uint64_t> StreamIn::getBufferSize() {
return mStreamCommon->getBufferSize();
}
+#if MAJOR_VERSION <= 6
Return<uint32_t> StreamIn::getSampleRate() {
return mStreamCommon->getSampleRate();
}
@@ -223,6 +227,18 @@ Return<Result> StreamIn::setFormat(AudioFormat format) {
return mStreamCommon->setFormat(format);
}
+#else
+
+Return<void> StreamIn::getSupportedProfiles(getSupportedProfiles_cb _hidl_cb) {
+ return mStreamCommon->getSupportedProfiles(_hidl_cb);
+}
+
+Return<Result> StreamIn::setAudioProperties(const AudioConfigBase& config) {
+ return mStreamCommon->setAudioProperties(config);
+}
+
+#endif // MAJOR_VERSION <= 6
+
Return<void> StreamIn::getAudioProperties(getAudioProperties_cb _hidl_cb) {
return mStreamCommon->getAudioProperties(_hidl_cb);
}
@@ -321,9 +337,11 @@ Return<Result> StreamIn::close() {
Return<void> StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) {
int halSource;
Result retval = mStreamCommon->getParam(AudioParameter::keyInputSource, &halSource);
- AudioSource source(AudioSource::DEFAULT);
+ AudioSource source = {};
if (retval == Result::OK) {
- source = AudioSource(halSource);
+ retval = Stream::analyzeStatus(
+ "get_audio_source",
+ HidlUtils::audioSourceFromHal(static_cast<audio_source_t>(halSource), &source));
}
_hidl_cb(retval, source);
return Void();
@@ -340,7 +358,11 @@ Return<Result> StreamIn::setGain(float gain) {
Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCount,
prepareForReading_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) {
@@ -410,8 +432,12 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCoun
mStatusMQ = std::move(tempStatusMQ);
mReadThread = tempReadThread.release();
mEfGroup = tempElfGroup.release();
+#if MAJOR_VERSION <= 6
threadInfo.pid = getpid();
threadInfo.tid = mReadThread->getTid();
+#else
+ threadInfo = mReadThread->getTid();
+#endif
_hidl_cb(Result::OK, *mCommandMQ->getDesc(), *mDataMQ->getDesc(), *mStatusMQ->getDesc(),
threadInfo);
return Void();
@@ -459,16 +485,13 @@ Return<void> StreamIn::updateSinkMetadata(const SinkMetadata& sinkMetadata) {
std::vector<record_track_metadata> halTracks;
halTracks.reserve(sinkMetadata.tracks.size());
for (auto& metadata : sinkMetadata.tracks) {
- record_track_metadata halTrackMetadata = {
- .source = static_cast<audio_source_t>(metadata.source), .gain = metadata.gain};
+ record_track_metadata halTrackMetadata = {.gain = metadata.gain};
+ (void)HidlUtils::audioSourceToHal(metadata.source, &halTrackMetadata.source);
#if MAJOR_VERSION >= 5
if (metadata.destination.getDiscriminator() ==
RecordTrackMetadata::Destination::hidl_discriminator::device) {
- halTrackMetadata.dest_device =
- static_cast<audio_devices_t>(metadata.destination.device().device);
- strncpy(halTrackMetadata.dest_device_address,
- deviceAddressToHal(metadata.destination.device()).c_str(),
- AUDIO_DEVICE_MAX_ADDRESS_LEN);
+ (void)deviceAddressToHal(metadata.destination.device(), &halTrackMetadata.dest_device,
+ halTrackMetadata.dest_device_address);
}
#endif
halTracks.push_back(halTrackMetadata);