mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 17:31:58 +00:00
audio: Update ChildInterface to set scheduler policy lazily
Since the client may end up never retrieving the interface instance for sending it over Binder, postpone setting of the scheduler policy to until that very moment. Rename 'ChildInterface::getPtr' to 'getInstance' for clarity. Bug: 264712385 Test: atest VtsHalAudioCoreTargetTest Change-Id: I31f9dd832c7f85f9632d1d389a8b1063d237d4c1
This commit is contained in:
@@ -1129,7 +1129,7 @@ ndk::ScopedAStatus Module::getSoundDose(std::shared_ptr<ISoundDose>* _aidl_retur
|
|||||||
if (!mSoundDose) {
|
if (!mSoundDose) {
|
||||||
mSoundDose = ndk::SharedRefBase::make<sounddose::SoundDose>();
|
mSoundDose = ndk::SharedRefBase::make<sounddose::SoundDose>();
|
||||||
}
|
}
|
||||||
*_aidl_return = mSoundDose.getPtr();
|
*_aidl_return = mSoundDose.getInstance();
|
||||||
LOG(DEBUG) << __func__ << ": returning instance of ISoundDose: " << _aidl_return->get();
|
LOG(DEBUG) << __func__ << ": returning instance of ISoundDose: " << _aidl_return->get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ndk::ScopedAStatus ModulePrimary::getTelephony(std::shared_ptr<ITelephony>* _aid
|
|||||||
if (!mTelephony) {
|
if (!mTelephony) {
|
||||||
mTelephony = ndk::SharedRefBase::make<Telephony>();
|
mTelephony = ndk::SharedRefBase::make<Telephony>();
|
||||||
}
|
}
|
||||||
*_aidl_return = mTelephony.getPtr();
|
*_aidl_return = mTelephony.getInstance();
|
||||||
LOG(DEBUG) << __func__
|
LOG(DEBUG) << __func__
|
||||||
<< ": returning instance of ITelephony: " << _aidl_return->get()->asBinder().get();
|
<< ": returning instance of ITelephony: " << _aidl_return->get()->asBinder().get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
|||||||
@@ -612,7 +612,7 @@ ndk::ScopedAStatus StreamCommonImpl::getStreamCommonCommon(
|
|||||||
if (!mCommon) {
|
if (!mCommon) {
|
||||||
LOG(FATAL) << __func__ << ": the common interface was not created";
|
LOG(FATAL) << __func__ << ": the common interface was not created";
|
||||||
}
|
}
|
||||||
*_aidl_return = mCommon.getPtr();
|
*_aidl_return = mCommon.getInstance();
|
||||||
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->get()->asBinder().get();
|
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->get()->asBinder().get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,14 +35,20 @@ struct ChildInterface : private std::pair<std::shared_ptr<C>, ndk::SpAIBinder> {
|
|||||||
}
|
}
|
||||||
ChildInterface& operator=(std::shared_ptr<C>&& c) {
|
ChildInterface& operator=(std::shared_ptr<C>&& c) {
|
||||||
this->first = std::move(c);
|
this->first = std::move(c);
|
||||||
this->second = this->first->asBinder();
|
|
||||||
AIBinder_setMinSchedulerPolicy(this->second.get(), SCHED_NORMAL, ANDROID_PRIORITY_AUDIO);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
explicit operator bool() const { return !!this->first; }
|
explicit operator bool() const { return !!this->first; }
|
||||||
C& operator*() const { return *(this->first); }
|
C& operator*() const { return *(this->first); }
|
||||||
C* operator->() const { return this->first; }
|
C* operator->() const { return this->first; }
|
||||||
std::shared_ptr<C> getPtr() const { return this->first; }
|
// Use 'getInstance' when returning the interface instance.
|
||||||
|
std::shared_ptr<C> getInstance() {
|
||||||
|
if (this->second.get() == nullptr) {
|
||||||
|
this->second = this->first->asBinder();
|
||||||
|
AIBinder_setMinSchedulerPolicy(this->second.get(), SCHED_NORMAL,
|
||||||
|
ANDROID_PRIORITY_AUDIO);
|
||||||
|
}
|
||||||
|
return this->first;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace aidl::android::hardware::audio::core
|
} // namespace aidl::android::hardware::audio::core
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ndk::ScopedAStatus ModuleStub::getBluetooth(std::shared_ptr<IBluetooth>* _aidl_r
|
|||||||
if (!mBluetooth) {
|
if (!mBluetooth) {
|
||||||
mBluetooth = ndk::SharedRefBase::make<Bluetooth>();
|
mBluetooth = ndk::SharedRefBase::make<Bluetooth>();
|
||||||
}
|
}
|
||||||
*_aidl_return = mBluetooth.getPtr();
|
*_aidl_return = mBluetooth.getInstance();
|
||||||
LOG(DEBUG) << __func__
|
LOG(DEBUG) << __func__
|
||||||
<< ": returning instance of IBluetooth: " << _aidl_return->get()->asBinder().get();
|
<< ": returning instance of IBluetooth: " << _aidl_return->get()->asBinder().get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
@@ -47,7 +47,7 @@ ndk::ScopedAStatus ModuleStub::getBluetoothA2dp(std::shared_ptr<IBluetoothA2dp>*
|
|||||||
if (!mBluetoothA2dp) {
|
if (!mBluetoothA2dp) {
|
||||||
mBluetoothA2dp = ndk::SharedRefBase::make<BluetoothA2dp>();
|
mBluetoothA2dp = ndk::SharedRefBase::make<BluetoothA2dp>();
|
||||||
}
|
}
|
||||||
*_aidl_return = mBluetoothA2dp.getPtr();
|
*_aidl_return = mBluetoothA2dp.getInstance();
|
||||||
LOG(DEBUG) << __func__ << ": returning instance of IBluetoothA2dp: "
|
LOG(DEBUG) << __func__ << ": returning instance of IBluetoothA2dp: "
|
||||||
<< _aidl_return->get()->asBinder().get();
|
<< _aidl_return->get()->asBinder().get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
@@ -57,7 +57,7 @@ ndk::ScopedAStatus ModuleStub::getBluetoothLe(std::shared_ptr<IBluetoothLe>* _ai
|
|||||||
if (!mBluetoothLe) {
|
if (!mBluetoothLe) {
|
||||||
mBluetoothLe = ndk::SharedRefBase::make<BluetoothLe>();
|
mBluetoothLe = ndk::SharedRefBase::make<BluetoothLe>();
|
||||||
}
|
}
|
||||||
*_aidl_return = mBluetoothLe.getPtr();
|
*_aidl_return = mBluetoothLe.getInstance();
|
||||||
LOG(DEBUG) << __func__
|
LOG(DEBUG) << __func__
|
||||||
<< ": returning instance of IBluetoothLe: " << _aidl_return->get()->asBinder().get();
|
<< ": returning instance of IBluetoothLe: " << _aidl_return->get()->asBinder().get();
|
||||||
return ndk::ScopedAStatus::ok();
|
return ndk::ScopedAStatus::ok();
|
||||||
|
|||||||
Reference in New Issue
Block a user