audio: Move StreamContext ownership out from StreamCommonImpl
Upcoming implementations of the streams of the primary module will need to change the underlying stream type depending on the current connected device. The stream context must persist, thus its life time must be bound to the IStreamIn/Out implementation. Move the StreamContext instance under ownership of StreamIn/Out. Add StreamCommonImpl::onClose so that the owner of the context may know when it is safe to reset it. Re-arrange the order of the arguments when creating a stream so that the context always comes first. Bug: 264712385 Test: atest VtsHalAudioCoreTargetTest Change-Id: Iaf13d4bc3a53cbfc27264d3abd1f6c417ece3941
This commit is contained in:
parent
2eabaf995b
commit
6ddefdbcdf
20 changed files with 122 additions and 91 deletions
|
@ -669,7 +669,7 @@ ndk::ScopedAStatus Module::openInputStream(const OpenInputStreamArguments& in_ar
|
|||
nullptr, nullptr, &context));
|
||||
context.fillDescriptor(&_aidl_return->desc);
|
||||
std::shared_ptr<StreamIn> stream;
|
||||
RETURN_STATUS_IF_ERROR(createInputStream(in_args.sinkMetadata, std::move(context),
|
||||
RETURN_STATUS_IF_ERROR(createInputStream(std::move(context), in_args.sinkMetadata,
|
||||
mConfig->microphones, &stream));
|
||||
StreamWrapper streamWrapper(stream);
|
||||
if (auto patchIt = mPatches.find(in_args.portConfigId); patchIt != mPatches.end()) {
|
||||
|
@ -715,7 +715,7 @@ ndk::ScopedAStatus Module::openOutputStream(const OpenOutputStreamArguments& in_
|
|||
in_args.eventCallback, &context));
|
||||
context.fillDescriptor(&_aidl_return->desc);
|
||||
std::shared_ptr<StreamOut> stream;
|
||||
RETURN_STATUS_IF_ERROR(createOutputStream(in_args.sourceMetadata, std::move(context),
|
||||
RETURN_STATUS_IF_ERROR(createOutputStream(std::move(context), in_args.sourceMetadata,
|
||||
in_args.offloadInfo, &stream));
|
||||
StreamWrapper streamWrapper(stream);
|
||||
if (auto patchIt = mPatches.find(in_args.portConfigId); patchIt != mPatches.end()) {
|
||||
|
|
|
@ -43,18 +43,18 @@ ndk::ScopedAStatus ModulePrimary::getTelephony(std::shared_ptr<ITelephony>* _aid
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModulePrimary::createInputStream(const SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
ndk::ScopedAStatus ModulePrimary::createInputStream(StreamContext&& context,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) {
|
||||
return createStreamInstance<StreamInStub>(result, sinkMetadata, std::move(context),
|
||||
return createStreamInstance<StreamInStub>(result, std::move(context), sinkMetadata,
|
||||
microphones);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModulePrimary::createOutputStream(
|
||||
const SourceMetadata& sourceMetadata, StreamContext&& context,
|
||||
StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) {
|
||||
return createStreamInstance<StreamOutStub>(result, sourceMetadata, std::move(context),
|
||||
return createStreamInstance<StreamOutStub>(result, std::move(context), sourceMetadata,
|
||||
offloadInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -663,7 +663,7 @@ ndk::ScopedAStatus StreamCommonImpl::close() {
|
|||
LOG(DEBUG) << __func__ << ": joining the worker thread...";
|
||||
mWorker->stop();
|
||||
LOG(DEBUG) << __func__ << ": worker thread joined";
|
||||
mContext.reset();
|
||||
onClose();
|
||||
mWorker->setClosed();
|
||||
return ndk::ScopedAStatus::ok();
|
||||
} else {
|
||||
|
@ -727,11 +727,15 @@ static std::map<AudioDevice, std::string> transformMicrophones(
|
|||
}
|
||||
} // namespace
|
||||
|
||||
StreamIn::StreamIn(const std::vector<MicrophoneInfo>& microphones)
|
||||
: mMicrophones(transformMicrophones(microphones)) {
|
||||
StreamIn::StreamIn(StreamContext&& context, const std::vector<MicrophoneInfo>& microphones)
|
||||
: mContext(std::move(context)), mMicrophones(transformMicrophones(microphones)) {
|
||||
LOG(DEBUG) << __func__;
|
||||
}
|
||||
|
||||
void StreamIn::defaultOnClose() {
|
||||
mContext.reset();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus StreamIn::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return) {
|
||||
std::vector<MicrophoneDynamicInfo> result;
|
||||
|
@ -784,11 +788,15 @@ ndk::ScopedAStatus StreamIn::setHwGain(const std::vector<float>& in_channelGains
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
StreamOut::StreamOut(const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: mOffloadInfo(offloadInfo) {
|
||||
StreamOut::StreamOut(StreamContext&& context, const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: mContext(std::move(context)), mOffloadInfo(offloadInfo) {
|
||||
LOG(DEBUG) << __func__;
|
||||
}
|
||||
|
||||
void StreamOut::defaultOnClose() {
|
||||
mContext.reset();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus StreamOut::updateOffloadMetadata(
|
||||
const AudioOffloadMetadata& in_offloadMetadata) {
|
||||
LOG(DEBUG) << __func__;
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
namespace aidl::android::hardware::audio::core {
|
||||
|
||||
StreamAlsa::StreamAlsa(const Metadata& metadata, StreamContext&& context, int readWriteRetries)
|
||||
: StreamCommonImpl(metadata, std::move(context)),
|
||||
StreamAlsa::StreamAlsa(const StreamContext& context, const Metadata& metadata, int readWriteRetries)
|
||||
: StreamCommonImpl(context, metadata),
|
||||
mFrameSizeBytes(getContext().getFrameSize()),
|
||||
mIsInput(isInput(metadata)),
|
||||
mConfig(alsa::getPcmConfig(getContext(), mIsInput)),
|
||||
|
|
|
@ -159,13 +159,13 @@ class Module : public BnModule {
|
|||
// The following virtual functions are intended for vendor extension via inheritance.
|
||||
|
||||
virtual ndk::ScopedAStatus createInputStream(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) = 0;
|
||||
virtual ndk::ScopedAStatus createOutputStream(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) = 0;
|
||||
|
|
|
@ -28,13 +28,13 @@ class ModulePrimary final : public Module {
|
|||
ndk::ScopedAStatus getTelephony(std::shared_ptr<ITelephony>* _aidl_return) override;
|
||||
|
||||
ndk::ScopedAStatus createInputStream(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) override;
|
||||
ndk::ScopedAStatus createOutputStream(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) override;
|
||||
|
|
|
@ -33,13 +33,13 @@ class ModuleRemoteSubmix : public Module {
|
|||
|
||||
// Module interfaces
|
||||
ndk::ScopedAStatus createInputStream(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) override;
|
||||
ndk::ScopedAStatus createOutputStream(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) override;
|
||||
|
|
|
@ -30,13 +30,13 @@ class ModuleStub final : public Module {
|
|||
ndk::ScopedAStatus getBluetoothLe(std::shared_ptr<IBluetoothLe>* _aidl_return) override;
|
||||
|
||||
ndk::ScopedAStatus createInputStream(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) override;
|
||||
ndk::ScopedAStatus createOutputStream(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) override;
|
||||
|
|
|
@ -33,13 +33,13 @@ class ModuleUsb final : public ModuleAlsa {
|
|||
|
||||
// Module interfaces
|
||||
ndk::ScopedAStatus createInputStream(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) override;
|
||||
ndk::ScopedAStatus createOutputStream(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) override;
|
||||
|
|
|
@ -411,16 +411,17 @@ class StreamCommonDelegator : public BnStreamCommon {
|
|||
};
|
||||
|
||||
// The implementation of DriverInterface must be provided by each concrete stream implementation.
|
||||
// Note that StreamCommonImpl does not own the context. This is to support swapping on the fly
|
||||
// implementations of the stream while keeping the same IStreamIn/Out instance. It's that instance
|
||||
// who must be owner of the context.
|
||||
class StreamCommonImpl : virtual public StreamCommonInterface, virtual public DriverInterface {
|
||||
public:
|
||||
StreamCommonImpl(const Metadata& metadata, StreamContext&& context,
|
||||
StreamCommonImpl(const StreamContext& context, const Metadata& metadata,
|
||||
const StreamWorkerInterface::CreateInstance& createWorker)
|
||||
: mMetadata(metadata),
|
||||
mContext(std::move(context)),
|
||||
mWorker(createWorker(mContext, this)) {}
|
||||
StreamCommonImpl(const Metadata& metadata, StreamContext&& context)
|
||||
: mContext(context), mMetadata(metadata), mWorker(createWorker(mContext, this)) {}
|
||||
StreamCommonImpl(const StreamContext& context, const Metadata& metadata)
|
||||
: StreamCommonImpl(
|
||||
metadata, std::move(context),
|
||||
context, metadata,
|
||||
isInput(metadata) ? getDefaultInWorkerCreator() : getDefaultOutWorkerCreator()) {}
|
||||
~StreamCommonImpl();
|
||||
|
||||
|
@ -462,10 +463,11 @@ class StreamCommonImpl : virtual public StreamCommonInterface, virtual public Dr
|
|||
};
|
||||
}
|
||||
|
||||
virtual void onClose() = 0;
|
||||
void stopWorker();
|
||||
|
||||
const StreamContext& mContext;
|
||||
Metadata mMetadata;
|
||||
StreamContext mContext;
|
||||
std::unique_ptr<StreamWorkerInterface> mWorker;
|
||||
ChildInterface<StreamCommonDelegator> mCommon;
|
||||
ConnectedDevices mConnectedDevices;
|
||||
|
@ -475,6 +477,8 @@ class StreamCommonImpl : virtual public StreamCommonInterface, virtual public Dr
|
|||
// concrete input/output stream implementations.
|
||||
class StreamIn : virtual public StreamCommonInterface, public BnStreamIn {
|
||||
protected:
|
||||
void defaultOnClose();
|
||||
|
||||
ndk::ScopedAStatus getStreamCommon(std::shared_ptr<IStreamCommon>* _aidl_return) override {
|
||||
return getStreamCommonCommon(_aidl_return);
|
||||
}
|
||||
|
@ -494,14 +498,17 @@ class StreamIn : virtual public StreamCommonInterface, public BnStreamIn {
|
|||
|
||||
friend class ndk::SharedRefBase;
|
||||
|
||||
explicit StreamIn(
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
StreamIn(StreamContext&& context,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
|
||||
StreamContext mContext;
|
||||
const std::map<::aidl::android::media::audio::common::AudioDevice, std::string> mMicrophones;
|
||||
};
|
||||
|
||||
class StreamOut : virtual public StreamCommonInterface, public BnStreamOut {
|
||||
protected:
|
||||
void defaultOnClose();
|
||||
|
||||
ndk::ScopedAStatus getStreamCommon(std::shared_ptr<IStreamCommon>* _aidl_return) override {
|
||||
return getStreamCommonCommon(_aidl_return);
|
||||
}
|
||||
|
@ -535,10 +542,12 @@ class StreamOut : virtual public StreamCommonInterface, public BnStreamOut {
|
|||
|
||||
friend class ndk::SharedRefBase;
|
||||
|
||||
explicit StreamOut(const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
StreamOut(StreamContext&& context,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
|
||||
std::optional<::aidl::android::media::audio::common::AudioOffloadInfo> mOffloadInfo;
|
||||
StreamContext mContext;
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo> mOffloadInfo;
|
||||
std::optional<::aidl::android::hardware::audio::common::AudioOffloadMetadata> mOffloadMetadata;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace aidl::android::hardware::audio::core {
|
|||
// provide necessary overrides for all interface methods omitted here.
|
||||
class StreamAlsa : public StreamCommonImpl {
|
||||
public:
|
||||
StreamAlsa(const Metadata& metadata, StreamContext&& context, int readWriteRetries);
|
||||
StreamAlsa(const StreamContext& context, const Metadata& metadata, int readWriteRetries);
|
||||
// Methods of 'DriverInterface'.
|
||||
::android::status_t init() override;
|
||||
::android::status_t drain(StreamDescriptor::DrainMode) override;
|
||||
|
|
|
@ -29,7 +29,7 @@ using aidl::android::hardware::audio::core::r_submix::SubmixRoute;
|
|||
|
||||
class StreamRemoteSubmix : public StreamCommonImpl {
|
||||
public:
|
||||
StreamRemoteSubmix(const Metadata& metadata, StreamContext&& context);
|
||||
StreamRemoteSubmix(const StreamContext& context, const Metadata& metadata);
|
||||
|
||||
::android::status_t init() override;
|
||||
::android::status_t drain(StreamDescriptor::DrainMode) override;
|
||||
|
@ -72,28 +72,32 @@ class StreamRemoteSubmix : public StreamCommonImpl {
|
|||
static constexpr int kReadAttemptSleepUs = 5000;
|
||||
};
|
||||
|
||||
class StreamInRemoteSubmix final : public StreamRemoteSubmix, public StreamIn {
|
||||
class StreamInRemoteSubmix final : public StreamIn, public StreamRemoteSubmix {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamInRemoteSubmix(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
ndk::ScopedAStatus getActiveMicrophones(
|
||||
std::vector<::aidl::android::media::audio::common::MicrophoneDynamicInfo>* _aidl_return)
|
||||
override;
|
||||
};
|
||||
|
||||
class StreamOutRemoteSubmix final : public StreamRemoteSubmix, public StreamOut {
|
||||
class StreamOutRemoteSubmix final : public StreamOut, public StreamRemoteSubmix {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamOutRemoteSubmix(
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace aidl::android::hardware::audio::core {
|
|||
|
||||
class StreamStub : public StreamCommonImpl {
|
||||
public:
|
||||
StreamStub(const Metadata& metadata, StreamContext&& context);
|
||||
StreamStub(const StreamContext& context, const Metadata& metadata);
|
||||
// Methods of 'DriverInterface'.
|
||||
::android::status_t init() override;
|
||||
::android::status_t drain(StreamDescriptor::DrainMode) override;
|
||||
|
@ -43,22 +43,28 @@ class StreamStub : public StreamCommonImpl {
|
|||
bool mIsStandby = true; // Used for validating the state machine logic.
|
||||
};
|
||||
|
||||
class StreamInStub final : public StreamStub, public StreamIn {
|
||||
class StreamInStub final : public StreamIn, public StreamStub {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamInStub(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
};
|
||||
|
||||
class StreamOutStub final : public StreamStub, public StreamOut {
|
||||
class StreamOutStub final : public StreamOut, public StreamStub {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamOutStub(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
StreamOutStub(StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace aidl::android::hardware::audio::core {
|
|||
|
||||
class StreamUsb : public StreamAlsa {
|
||||
public:
|
||||
StreamUsb(const Metadata& metadata, StreamContext&& context);
|
||||
StreamUsb(const StreamContext& context, const Metadata& metadata);
|
||||
// Methods of 'DriverInterface'.
|
||||
::android::status_t transfer(void* buffer, size_t frameCount, size_t* actualFrameCount,
|
||||
int32_t* latencyMs) override;
|
||||
|
@ -44,29 +44,31 @@ class StreamUsb : public StreamAlsa {
|
|||
std::atomic<bool> mConnectedDevicesUpdated = false;
|
||||
};
|
||||
|
||||
class StreamInUsb final : public StreamUsb, public StreamIn {
|
||||
class StreamInUsb final : public StreamIn, public StreamUsb {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamInUsb(
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata,
|
||||
const std::vector<::aidl::android::media::audio::common::MicrophoneInfo>& microphones);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
ndk::ScopedAStatus getActiveMicrophones(
|
||||
std::vector<::aidl::android::media::audio::common::MicrophoneDynamicInfo>* _aidl_return)
|
||||
override;
|
||||
};
|
||||
|
||||
class StreamOutUsb final : public StreamUsb, public StreamOut {
|
||||
class StreamOutUsb final : public StreamOut, public StreamUsb {
|
||||
public:
|
||||
friend class ndk::SharedRefBase;
|
||||
StreamOutUsb(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
StreamOutUsb(StreamContext&& context,
|
||||
const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
|
||||
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
|
||||
offloadInfo);
|
||||
|
||||
private:
|
||||
void onClose() override { defaultOnClose(); }
|
||||
ndk::ScopedAStatus getHwVolume(std::vector<float>* _aidl_return) override;
|
||||
ndk::ScopedAStatus setHwVolume(const std::vector<float>& in_channelVolumes) override;
|
||||
|
||||
|
|
|
@ -56,16 +56,16 @@ ndk::ScopedAStatus ModuleRemoteSubmix::setMicMute(bool in_mute __unused) {
|
|||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleRemoteSubmix::createInputStream(
|
||||
const SinkMetadata& sinkMetadata, StreamContext&& context,
|
||||
StreamContext&& context, const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones, std::shared_ptr<StreamIn>* result) {
|
||||
return createStreamInstance<StreamInRemoteSubmix>(result, sinkMetadata, std::move(context),
|
||||
return createStreamInstance<StreamInRemoteSubmix>(result, std::move(context), sinkMetadata,
|
||||
microphones);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleRemoteSubmix::createOutputStream(
|
||||
const SourceMetadata& sourceMetadata, StreamContext&& context,
|
||||
StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) {
|
||||
return createStreamInstance<StreamOutRemoteSubmix>(result, sourceMetadata, std::move(context),
|
||||
return createStreamInstance<StreamOutRemoteSubmix>(result, std::move(context), sourceMetadata,
|
||||
offloadInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ using aidl::android::media::audio::common::MicrophoneInfo;
|
|||
|
||||
namespace aidl::android::hardware::audio::core {
|
||||
|
||||
StreamRemoteSubmix::StreamRemoteSubmix(const Metadata& metadata, StreamContext&& context)
|
||||
: StreamCommonImpl(metadata, std::move(context)),
|
||||
StreamRemoteSubmix::StreamRemoteSubmix(const StreamContext& context, const Metadata& metadata)
|
||||
: StreamCommonImpl(context, metadata),
|
||||
mPortId(context.getPortId()),
|
||||
mIsInput(isInput(metadata)) {
|
||||
mStreamConfig.frameSize = context.getFrameSize();
|
||||
|
@ -353,10 +353,11 @@ size_t StreamRemoteSubmix::getStreamPipeSizeInFrames() {
|
|||
return ::android::OK;
|
||||
}
|
||||
|
||||
StreamInRemoteSubmix::StreamInRemoteSubmix(const SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
StreamInRemoteSubmix::StreamInRemoteSubmix(StreamContext&& context,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamRemoteSubmix(sinkMetadata, std::move(context)), StreamIn(microphones) {}
|
||||
: StreamIn(std::move(context), microphones),
|
||||
StreamRemoteSubmix(StreamIn::mContext, sinkMetadata) {}
|
||||
|
||||
ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return) {
|
||||
|
@ -365,9 +366,10 @@ ndk::ScopedAStatus StreamInRemoteSubmix::getActiveMicrophones(
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
StreamOutRemoteSubmix::StreamOutRemoteSubmix(const SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
StreamOutRemoteSubmix::StreamOutRemoteSubmix(StreamContext&& context,
|
||||
const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamRemoteSubmix(sourceMetadata, std::move(context)), StreamOut(offloadInfo) {}
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamRemoteSubmix(StreamOut::mContext, sourceMetadata) {}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -63,18 +63,18 @@ ndk::ScopedAStatus ModuleStub::getBluetoothLe(std::shared_ptr<IBluetoothLe>* _ai
|
|||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleStub::createInputStream(const SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
ndk::ScopedAStatus ModuleStub::createInputStream(StreamContext&& context,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) {
|
||||
return createStreamInstance<StreamInStub>(result, sinkMetadata, std::move(context),
|
||||
return createStreamInstance<StreamInStub>(result, std::move(context), sinkMetadata,
|
||||
microphones);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleStub::createOutputStream(
|
||||
const SourceMetadata& sourceMetadata, StreamContext&& context,
|
||||
StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) {
|
||||
return createStreamInstance<StreamOutStub>(result, sourceMetadata, std::move(context),
|
||||
return createStreamInstance<StreamOutStub>(result, std::move(context), sourceMetadata,
|
||||
offloadInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ using aidl::android::media::audio::common::MicrophoneInfo;
|
|||
|
||||
namespace aidl::android::hardware::audio::core {
|
||||
|
||||
StreamStub::StreamStub(const Metadata& metadata, StreamContext&& context)
|
||||
: StreamCommonImpl(metadata, std::move(context)),
|
||||
StreamStub::StreamStub(const StreamContext& context, const Metadata& metadata)
|
||||
: StreamCommonImpl(context, metadata),
|
||||
mFrameSizeBytes(getContext().getFrameSize()),
|
||||
mSampleRate(getContext().getSampleRate()),
|
||||
mIsAsynchronous(!!getContext().getAsyncCallback()),
|
||||
|
@ -118,12 +118,12 @@ void StreamStub::shutdown() {
|
|||
mIsInitialized = false;
|
||||
}
|
||||
|
||||
StreamInStub::StreamInStub(const SinkMetadata& sinkMetadata, StreamContext&& context,
|
||||
StreamInStub::StreamInStub(StreamContext&& context, const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamStub(sinkMetadata, std::move(context)), StreamIn(microphones) {}
|
||||
: StreamIn(std::move(context), microphones), StreamStub(StreamIn::mContext, sinkMetadata) {}
|
||||
|
||||
StreamOutStub::StreamOutStub(const SourceMetadata& sourceMetadata, StreamContext&& context,
|
||||
StreamOutStub::StreamOutStub(StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamStub(sourceMetadata, std::move(context)), StreamOut(offloadInfo) {}
|
||||
: StreamOut(std::move(context), offloadInfo), StreamStub(StreamOut::mContext, sourceMetadata) {}
|
||||
|
||||
} // namespace aidl::android::hardware::audio::core
|
||||
|
|
|
@ -68,22 +68,22 @@ ndk::ScopedAStatus ModuleUsb::setMicMute(bool in_mute __unused) {
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleUsb::createInputStream(const SinkMetadata& sinkMetadata,
|
||||
StreamContext&& context,
|
||||
ndk::ScopedAStatus ModuleUsb::createInputStream(StreamContext&& context,
|
||||
const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones,
|
||||
std::shared_ptr<StreamIn>* result) {
|
||||
return createStreamInstance<StreamInUsb>(result, sinkMetadata, std::move(context), microphones);
|
||||
return createStreamInstance<StreamInUsb>(result, std::move(context), sinkMetadata, microphones);
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus ModuleUsb::createOutputStream(const SourceMetadata& sourceMetadata,
|
||||
StreamContext&& context,
|
||||
ndk::ScopedAStatus ModuleUsb::createOutputStream(StreamContext&& context,
|
||||
const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo,
|
||||
std::shared_ptr<StreamOut>* result) {
|
||||
if (offloadInfo.has_value()) {
|
||||
LOG(ERROR) << __func__ << ": offload is not supported";
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
return createStreamInstance<StreamOutUsb>(result, sourceMetadata, std::move(context),
|
||||
return createStreamInstance<StreamOutUsb>(result, std::move(context), sourceMetadata,
|
||||
offloadInfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ using aidl::android::media::audio::common::MicrophoneInfo;
|
|||
|
||||
namespace aidl::android::hardware::audio::core {
|
||||
|
||||
StreamUsb::StreamUsb(const Metadata& metadata, StreamContext&& context)
|
||||
: StreamAlsa(metadata, std::move(context), 1 /*readWriteRetries*/) {}
|
||||
StreamUsb::StreamUsb(const StreamContext& context, const Metadata& metadata)
|
||||
: StreamAlsa(context, metadata, 1 /*readWriteRetries*/) {}
|
||||
|
||||
ndk::ScopedAStatus StreamUsb::setConnectedDevices(
|
||||
const std::vector<AudioDevice>& connectedDevices) {
|
||||
|
@ -55,7 +55,7 @@ ndk::ScopedAStatus StreamUsb::setConnectedDevices(
|
|||
}
|
||||
connectedDeviceProfiles.push_back(*profile);
|
||||
}
|
||||
RETURN_STATUS_IF_ERROR(StreamCommonImpl::setConnectedDevices(connectedDevices));
|
||||
RETURN_STATUS_IF_ERROR(setConnectedDevices(connectedDevices));
|
||||
std::lock_guard guard(mLock);
|
||||
mConnectedDeviceProfiles = std::move(connectedDeviceProfiles);
|
||||
mConnectedDevicesUpdated.store(true, std::memory_order_release);
|
||||
|
@ -83,9 +83,9 @@ std::vector<alsa::DeviceProfile> StreamUsb::getDeviceProfiles() {
|
|||
return connectedDevices;
|
||||
}
|
||||
|
||||
StreamInUsb::StreamInUsb(const SinkMetadata& sinkMetadata, StreamContext&& context,
|
||||
StreamInUsb::StreamInUsb(StreamContext&& context, const SinkMetadata& sinkMetadata,
|
||||
const std::vector<MicrophoneInfo>& microphones)
|
||||
: StreamUsb(sinkMetadata, std::move(context)), StreamIn(microphones) {}
|
||||
: StreamIn(std::move(context), microphones), StreamUsb(StreamIn::mContext, sinkMetadata) {}
|
||||
|
||||
ndk::ScopedAStatus StreamInUsb::getActiveMicrophones(
|
||||
std::vector<MicrophoneDynamicInfo>* _aidl_return __unused) {
|
||||
|
@ -93,10 +93,10 @@ ndk::ScopedAStatus StreamInUsb::getActiveMicrophones(
|
|||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
StreamOutUsb::StreamOutUsb(const SourceMetadata& sourceMetadata, StreamContext&& context,
|
||||
StreamOutUsb::StreamOutUsb(StreamContext&& context, const SourceMetadata& sourceMetadata,
|
||||
const std::optional<AudioOffloadInfo>& offloadInfo)
|
||||
: StreamUsb(sourceMetadata, std::move(context)),
|
||||
StreamOut(offloadInfo),
|
||||
: StreamOut(std::move(context), offloadInfo),
|
||||
StreamUsb(StreamOut::mContext, sourceMetadata),
|
||||
mChannelCount(getChannelCount(getContext().getChannelLayout())) {}
|
||||
|
||||
ndk::ScopedAStatus StreamOutUsb::getHwVolume(std::vector<float>* _aidl_return) {
|
||||
|
|
Loading…
Reference in a new issue