audio: Make renamings suggested by reviewers
Rename DriverInterface::getPosition -> refinePosition. This reflects
the fact that the driver may provide more precise position, however
this is an optional operation.
Rename StreamIn/Out::mContext -> mContextInstance. This is
to emphasize that StreamIn/Out actually own the context and they
hold the real context instance, not just a reference/pointer
to it, like other classes involved in the inheritance chain.
Bug: 286914845
Test: atest VtsHalAudioCoreTargetTest
Change-Id: Id7159f9bf3ee020dc7cf594ec35f5d59d23d7e31
(cherry picked from commit 459b7331e9
)
Merged-In: Id7159f9bf3ee020dc7cf594ec35f5d59d23d7e31
This commit is contained in:
parent
aa449835dc
commit
7ed9ce5339
9 changed files with 21 additions and 23 deletions
|
@ -117,7 +117,7 @@ void StreamWorkerCommonLogic::populateReply(StreamDescriptor::Reply* reply,
|
|||
if (isConnected) {
|
||||
reply->observable.frames = mContext->getFrameCount();
|
||||
reply->observable.timeNs = ::android::elapsedRealtimeNano();
|
||||
if (auto status = mDriver->getPosition(&reply->observable); status == ::android::OK) {
|
||||
if (auto status = mDriver->refinePosition(&reply->observable); status == ::android::OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -739,12 +739,12 @@ static std::map<AudioDevice, std::string> transformMicrophones(
|
|||
} // namespace
|
||||
|
||||
StreamIn::StreamIn(StreamContext&& context, const std::vector<MicrophoneInfo>& microphones)
|
||||
: mContext(std::move(context)), mMicrophones(transformMicrophones(microphones)) {
|
||||
: mContextInstance(std::move(context)), mMicrophones(transformMicrophones(microphones)) {
|
||||
LOG(DEBUG) << __func__;
|
||||
}
|
||||
|
||||
void StreamIn::defaultOnClose() {
|
||||
mContext.reset();
|
||||
mContextInstance.reset();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus StreamIn::getActiveMicrophones(
|
||||
|
@ -800,12 +800,12 @@ ndk::ScopedAStatus StreamIn::setHwGain(const std::vector<float>& in_channelGains
|
|||
}
|
||||
|
||||
StreamOut::StreamOut(StreamContext&& context, const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: mContext(std::move(context)), mOffloadInfo(offloadInfo) {
|
||||
: mContextInstance(std::move(context)), mOffloadInfo(offloadInfo) {
|
||||
LOG(DEBUG) << __func__;
|
||||
}
|
||||
|
||||
void StreamOut::defaultOnClose() {
|
||||
mContext.reset();
|
||||
mContextInstance.reset();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus StreamOut::updateOffloadMetadata(
|
||||
|
|
|
@ -108,7 +108,7 @@ StreamAlsa::StreamAlsa(StreamContext* context, const Metadata& metadata, int rea
|
|||
return ::android::OK;
|
||||
}
|
||||
|
||||
::android::status_t StreamAlsa::getPosition(StreamDescriptor::Position* position) {
|
||||
::android::status_t StreamAlsa::refinePosition(StreamDescriptor::Position* position) {
|
||||
if (mAlsaDeviceProxies.empty()) {
|
||||
LOG(FATAL) << __func__ << ": no input devices";
|
||||
return ::android::NO_INIT;
|
||||
|
|
|
@ -320,7 +320,7 @@ StreamInBluetooth::StreamInBluetooth(StreamContext&& context, const SinkMetadata
|
|||
const std::vector<MicrophoneInfo>& microphones,
|
||||
Module::BtProfileHandles&& btProfileHandles)
|
||||
: StreamIn(std::move(context), microphones),
|
||||
StreamBluetooth(&(StreamIn::mContext), sinkMetadata, std::move(btProfileHandles)) {}
|
||||
StreamBluetooth(&mContextInstance, sinkMetadata, std::move(btProfileHandles)) {}
|
||||
|
||||
ndk::ScopedAStatus StreamInBluetooth::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return __unused) {
|
||||
|
@ -333,6 +333,6 @@ StreamOutBluetooth::StreamOutBluetooth(StreamContext&& context,
|
|||
const std::optional<AudioOffloadInfo>& offloadInfo,
|
||||
Module::BtProfileHandles&& btProfileHandles)
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamBluetooth(&(StreamOut::mContext), sourceMetadata, std::move(btProfileHandles)) {}
|
||||
StreamBluetooth(&mContextInstance, sourceMetadata, std::move(btProfileHandles)) {}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -195,10 +195,10 @@ struct DriverInterface {
|
|||
virtual ::android::status_t start() = 0;
|
||||
virtual ::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
|
||||
int32_t* latencyMs) = 0;
|
||||
// No need to implement 'getPosition' unless the driver can provide more precise
|
||||
// No need to implement 'refinePosition' unless the driver can provide more precise
|
||||
// data than just total frame count. For example, the driver may correctly account
|
||||
// for any intermediate buffers.
|
||||
virtual ::android::status_t getPosition(StreamDescriptor::Position* /*position*/) {
|
||||
virtual ::android::status_t refinePosition(StreamDescriptor::Position* /*position*/) {
|
||||
return ::android::OK;
|
||||
}
|
||||
virtual void shutdown() = 0; // This function is only called once.
|
||||
|
@ -507,7 +507,7 @@ class StreamIn : virtual public StreamCommonInterface, public BnStreamIn {
|
|||
StreamIn(StreamContext&& context,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
|
||||
StreamContext mContext;
|
||||
StreamContext mContextInstance;
|
||||
const std::map<::aidl::android::media::audio::common::AudioDevice, std::string> mMicrophones;
|
||||
};
|
||||
|
||||
|
@ -552,7 +552,7 @@ class StreamOut : virtual public StreamCommonInterface, public BnStreamOut {
|
|||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
|
||||
StreamContext mContext;
|
||||
StreamContext mContextInstance;
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo> mOffloadInfo;
|
||||
std::optional<::aidl::android::hardware::audio::common::AudioOffloadMetadata> mOffloadMetadata;
|
||||
};
|
||||
|
|
|
@ -41,7 +41,7 @@ class StreamAlsa : public StreamCommonImpl {
|
|||
::android::status_t start() override;
|
||||
::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
|
||||
int32_t* latencyMs) override;
|
||||
::android::status_t getPosition(StreamDescriptor::Position* position) override;
|
||||
::android::status_t refinePosition(StreamDescriptor::Position* position) override;
|
||||
void shutdown() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -39,7 +39,7 @@ class StreamRemoteSubmix : public StreamCommonImpl {
|
|||
::android::status_t start() override;
|
||||
::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
|
||||
int32_t* latencyMs) override;
|
||||
::android::status_t getPosition(StreamDescriptor::Position* position) override;
|
||||
::android::status_t refinePosition(StreamDescriptor::Position* position) override;
|
||||
void shutdown() override;
|
||||
|
||||
// Overridden methods of 'StreamCommonImpl', called on a Binder thread.
|
||||
|
|
|
@ -184,7 +184,7 @@ void StreamRemoteSubmix::shutdown() {
|
|||
: outWrite(buffer, frameCount, actualFrameCount));
|
||||
}
|
||||
|
||||
::android::status_t StreamRemoteSubmix::getPosition(StreamDescriptor::Position* position) {
|
||||
::android::status_t StreamRemoteSubmix::refinePosition(StreamDescriptor::Position* position) {
|
||||
sp<MonoPipeReader> source = mCurrentRoute->getSource();
|
||||
if (source == nullptr) {
|
||||
return ::android::NO_INIT;
|
||||
|
@ -363,8 +363,7 @@ size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
|
|||
StreamInRemoteSubmix::StreamInRemoteSubmix(StreamContext&& context,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamIn(std::move(context), microphones),
|
||||
StreamSwitcher(&(StreamIn::mContext), sinkMetadata) {}
|
||||
: StreamIn(std::move(context), microphones), StreamSwitcher(&mContextInstance, sinkMetadata) {}
|
||||
|
||||
ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return) {
|
||||
|
@ -405,7 +404,7 @@ StreamOutRemoteSubmix::StreamOutRemoteSubmix(StreamContext&& context,
|
|||
const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamSwitcher(&(StreamOut::mContext), sourceMetadata) {}
|
||||
StreamSwitcher(&mContextInstance, sourceMetadata) {}
|
||||
|
||||
StreamSwitcher::DeviceSwitchBehavior StreamOutRemoteSubmix::switchCurrentStream(
|
||||
const std::vector<::aidl::android::media::audio::common::AudioDevice>& devices) {
|
||||
|
|
|
@ -120,11 +120,10 @@ void StreamStub::shutdown() {
|
|||
|
||||
StreamInStub::StreamInStub(StreamContext&& context, const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamIn(std::move(context), microphones), StreamStub(&(StreamIn::mContext), sinkMetadata) {}
|
||||
: StreamIn(std::move(context), microphones), StreamStub(&mContextInstance, sinkMetadata) {}
|
||||
|
||||
StreamOutStub::StreamOutStub(StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamStub(&(StreamOut::mContext), sourceMetadata) {}
|
||||
: StreamOut(std::move(context), offloadInfo), StreamStub(&mContextInstance, sourceMetadata) {}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -85,7 +85,7 @@ std::vector<alsa::DeviceProfile> StreamUsb::getDeviceProfiles() {
|
|||
|
||||
StreamInUsb::StreamInUsb(StreamContext&& context, const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamIn(std::move(context), microphones), StreamUsb(&(StreamIn::mContext), sinkMetadata) {}
|
||||
: StreamIn(std::move(context), microphones), StreamUsb(&mContextInstance, sinkMetadata) {}
|
||||
|
||||
ndk::ScopedAStatus StreamInUsb::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return __unused) {
|
||||
|
@ -96,7 +96,7 @@ ndk::ScopedAStatus StreamInUsb::getActiveMicrophones(
|
|||
StreamOutUsb::StreamOutUsb(StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamUsb(&(StreamOut::mContext), sourceMetadata),
|
||||
StreamUsb(&mContextInstance, sourceMetadata),
|
||||
mChannelCount(getChannelCount(getContext().getChannelLayout())) {}
|
||||
|
||||
ndk::ScopedAStatus StreamOutUsb::getHwVolume(std::vector<float>* _aidl_return) {
|
||||
|
|
Loading…
Reference in a new issue