diff options
Diffstat (limited to 'audio/core/all-versions/default/StreamIn.cpp')
-rw-r--r-- | audio/core/all-versions/default/StreamIn.cpp | 45 |
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); |