Loading audio/aidl/android/hardware/audio/core/IModule.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -611,6 +611,7 @@ interface IModule { * @param mute Whether the output from the module is muted. * @throws EX_UNSUPPORTED_OPERATION If muting of combined output * is not supported by the module. * @throws EX_ILLEGAL_STATE If any error happens while muting of combined output. */ void setMasterMute(boolean mute); Loading Loading @@ -642,6 +643,8 @@ interface IModule { * accepted range. * @throws EX_UNSUPPORTED_OPERATION If attenuation of combined output * is not supported by the module. * @throws EX_ILLEGAL_STATE If any error happens while updating attenuation of combined output. */ void setMasterVolume(float volume); Loading audio/aidl/android/hardware/audio/core/IStreamOut.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ interface IStreamOut { * @throws EX_ILLEGAL_ARGUMENT If the number of elements in the provided * array does not match the channel count, or * attenuation values are out of range. * @throws EX_ILLEGAL_STATE If the stream is closed. * @throws EX_ILLEGAL_STATE If the stream is closed or there is any error happens when applying hardware volume. * @throws EX_UNSUPPORTED_OPERATION If hardware volume control is not supported. */ void setHwVolume(in float[] channelVolumes); Loading audio/aidl/default/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "Telephony.cpp", "usb/ModuleUsb.cpp", "usb/StreamUsb.cpp", "usb/UsbAlsaMixerControl.cpp", "usb/UsbAlsaUtils.cpp", ], generated_sources: [ Loading audio/aidl/default/Module.cpp +42 −6 Original line number Diff line number Diff line Loading @@ -460,6 +460,7 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA connectedPort.profiles = connectedProfilesIt->second; } ports.push_back(connectedPort); onExternalDeviceConnectionChanged(connectedPort, true /*connected*/); *_aidl_return = std::move(connectedPort); std::vector<AudioRoute> newRoutes; Loading Loading @@ -513,6 +514,7 @@ ndk::ScopedAStatus Module::disconnectExternalDevice(int32_t in_portId) { << configIt->id; return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); } onExternalDeviceConnectionChanged(*portIt, false /*connected*/); ports.erase(portIt); mConnectedDevicePorts.erase(in_portId); LOG(DEBUG) << __func__ << ": connected device port " << in_portId << " released"; Loading Loading @@ -983,8 +985,17 @@ ndk::ScopedAStatus Module::getMasterMute(bool* _aidl_return) { ndk::ScopedAStatus Module::setMasterMute(bool in_mute) { LOG(DEBUG) << __func__ << ": " << in_mute; auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok() : onMasterMuteChanged(in_mute); if (result.isOk()) { mMasterMute = in_mute; return ndk::ScopedAStatus::ok(); } else { LOG(ERROR) << __func__ << ": failed calling onMasterMuteChanged(" << in_mute << "), error=" << result; // Reset master mute if it failed. onMasterMuteChanged(mMasterMute); } return std::move(result); } ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) { Loading @@ -996,8 +1007,17 @@ ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) { ndk::ScopedAStatus Module::setMasterVolume(float in_volume) { LOG(DEBUG) << __func__ << ": " << in_volume; if (in_volume >= 0.0f && in_volume <= 1.0f) { auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok() : onMasterVolumeChanged(in_volume); if (result.isOk()) { mMasterVolume = in_volume; return ndk::ScopedAStatus::ok(); } else { // Reset master volume if it failed. LOG(ERROR) << __func__ << ": failed calling onMasterVolumeChanged(" << in_volume << "), error=" << result; onMasterVolumeChanged(mMasterVolume); } return std::move(result); } LOG(ERROR) << __func__ << ": invalid master volume value: " << in_volume; return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); Loading Loading @@ -1251,14 +1271,30 @@ bool Module::isMmapSupported() { } ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort __unused) { LOG(DEBUG) << __func__ << ": do nothing and return ok"; LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Module::checkAudioPatchEndpointsMatch( const std::vector<AudioPortConfig*>& sources __unused, const std::vector<AudioPortConfig*>& sinks __unused) { LOG(DEBUG) << __func__ << ": do nothing and return ok"; LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } void Module::onExternalDeviceConnectionChanged( const ::aidl::android::media::audio::common::AudioPort& audioPort __unused, bool connected __unused) { LOG(DEBUG) << __func__ << ": do nothing and return"; } ndk::ScopedAStatus Module::onMasterMuteChanged(bool mute __unused) { LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Module::onMasterVolumeChanged(float volume __unused) { LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } Loading audio/aidl/default/include/core-impl/Module.h +7 −2 Original line number Diff line number Diff line Loading @@ -181,8 +181,6 @@ class Module : public BnModule { // Maps port ids and port config ids to patch ids. // Multimap because both ports and configs can be used by multiple patches. std::multimap<int32_t, int32_t> mPatches; bool mMasterMute = false; float mMasterVolume = 1.0f; bool mMicMute = false; ChildInterface<sounddose::ISoundDose> mSoundDose; std::optional<bool> mIsMmapSupported; Loading @@ -197,6 +195,13 @@ class Module : public BnModule { virtual ndk::ScopedAStatus checkAudioPatchEndpointsMatch( const std::vector<::aidl::android::media::audio::common::AudioPortConfig*>& sources, const std::vector<::aidl::android::media::audio::common::AudioPortConfig*>& sinks); virtual void onExternalDeviceConnectionChanged( const ::aidl::android::media::audio::common::AudioPort& audioPort, bool connected); virtual ndk::ScopedAStatus onMasterMuteChanged(bool mute); virtual ndk::ScopedAStatus onMasterVolumeChanged(float volume); bool mMasterMute = false; float mMasterVolume = 1.0f; }; } // namespace aidl::android::hardware::audio::core Loading
audio/aidl/android/hardware/audio/core/IModule.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -611,6 +611,7 @@ interface IModule { * @param mute Whether the output from the module is muted. * @throws EX_UNSUPPORTED_OPERATION If muting of combined output * is not supported by the module. * @throws EX_ILLEGAL_STATE If any error happens while muting of combined output. */ void setMasterMute(boolean mute); Loading Loading @@ -642,6 +643,8 @@ interface IModule { * accepted range. * @throws EX_UNSUPPORTED_OPERATION If attenuation of combined output * is not supported by the module. * @throws EX_ILLEGAL_STATE If any error happens while updating attenuation of combined output. */ void setMasterVolume(float volume); Loading
audio/aidl/android/hardware/audio/core/IStreamOut.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ interface IStreamOut { * @throws EX_ILLEGAL_ARGUMENT If the number of elements in the provided * array does not match the channel count, or * attenuation values are out of range. * @throws EX_ILLEGAL_STATE If the stream is closed. * @throws EX_ILLEGAL_STATE If the stream is closed or there is any error happens when applying hardware volume. * @throws EX_UNSUPPORTED_OPERATION If hardware volume control is not supported. */ void setHwVolume(in float[] channelVolumes); Loading
audio/aidl/default/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -75,6 +75,7 @@ cc_library_static { "Telephony.cpp", "usb/ModuleUsb.cpp", "usb/StreamUsb.cpp", "usb/UsbAlsaMixerControl.cpp", "usb/UsbAlsaUtils.cpp", ], generated_sources: [ Loading
audio/aidl/default/Module.cpp +42 −6 Original line number Diff line number Diff line Loading @@ -460,6 +460,7 @@ ndk::ScopedAStatus Module::connectExternalDevice(const AudioPort& in_templateIdA connectedPort.profiles = connectedProfilesIt->second; } ports.push_back(connectedPort); onExternalDeviceConnectionChanged(connectedPort, true /*connected*/); *_aidl_return = std::move(connectedPort); std::vector<AudioRoute> newRoutes; Loading Loading @@ -513,6 +514,7 @@ ndk::ScopedAStatus Module::disconnectExternalDevice(int32_t in_portId) { << configIt->id; return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE); } onExternalDeviceConnectionChanged(*portIt, false /*connected*/); ports.erase(portIt); mConnectedDevicePorts.erase(in_portId); LOG(DEBUG) << __func__ << ": connected device port " << in_portId << " released"; Loading Loading @@ -983,8 +985,17 @@ ndk::ScopedAStatus Module::getMasterMute(bool* _aidl_return) { ndk::ScopedAStatus Module::setMasterMute(bool in_mute) { LOG(DEBUG) << __func__ << ": " << in_mute; auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok() : onMasterMuteChanged(in_mute); if (result.isOk()) { mMasterMute = in_mute; return ndk::ScopedAStatus::ok(); } else { LOG(ERROR) << __func__ << ": failed calling onMasterMuteChanged(" << in_mute << "), error=" << result; // Reset master mute if it failed. onMasterMuteChanged(mMasterMute); } return std::move(result); } ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) { Loading @@ -996,8 +1007,17 @@ ndk::ScopedAStatus Module::getMasterVolume(float* _aidl_return) { ndk::ScopedAStatus Module::setMasterVolume(float in_volume) { LOG(DEBUG) << __func__ << ": " << in_volume; if (in_volume >= 0.0f && in_volume <= 1.0f) { auto result = mDebug.simulateDeviceConnections ? ndk::ScopedAStatus::ok() : onMasterVolumeChanged(in_volume); if (result.isOk()) { mMasterVolume = in_volume; return ndk::ScopedAStatus::ok(); } else { // Reset master volume if it failed. LOG(ERROR) << __func__ << ": failed calling onMasterVolumeChanged(" << in_volume << "), error=" << result; onMasterVolumeChanged(mMasterVolume); } return std::move(result); } LOG(ERROR) << __func__ << ": invalid master volume value: " << in_volume; return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); Loading Loading @@ -1251,14 +1271,30 @@ bool Module::isMmapSupported() { } ndk::ScopedAStatus Module::populateConnectedDevicePort(AudioPort* audioPort __unused) { LOG(DEBUG) << __func__ << ": do nothing and return ok"; LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Module::checkAudioPatchEndpointsMatch( const std::vector<AudioPortConfig*>& sources __unused, const std::vector<AudioPortConfig*>& sinks __unused) { LOG(DEBUG) << __func__ << ": do nothing and return ok"; LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } void Module::onExternalDeviceConnectionChanged( const ::aidl::android::media::audio::common::AudioPort& audioPort __unused, bool connected __unused) { LOG(DEBUG) << __func__ << ": do nothing and return"; } ndk::ScopedAStatus Module::onMasterMuteChanged(bool mute __unused) { LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } ndk::ScopedAStatus Module::onMasterVolumeChanged(float volume __unused) { LOG(VERBOSE) << __func__ << ": do nothing and return ok"; return ndk::ScopedAStatus::ok(); } Loading
audio/aidl/default/include/core-impl/Module.h +7 −2 Original line number Diff line number Diff line Loading @@ -181,8 +181,6 @@ class Module : public BnModule { // Maps port ids and port config ids to patch ids. // Multimap because both ports and configs can be used by multiple patches. std::multimap<int32_t, int32_t> mPatches; bool mMasterMute = false; float mMasterVolume = 1.0f; bool mMicMute = false; ChildInterface<sounddose::ISoundDose> mSoundDose; std::optional<bool> mIsMmapSupported; Loading @@ -197,6 +195,13 @@ class Module : public BnModule { virtual ndk::ScopedAStatus checkAudioPatchEndpointsMatch( const std::vector<::aidl::android::media::audio::common::AudioPortConfig*>& sources, const std::vector<::aidl::android::media::audio::common::AudioPortConfig*>& sinks); virtual void onExternalDeviceConnectionChanged( const ::aidl::android::media::audio::common::AudioPort& audioPort, bool connected); virtual ndk::ScopedAStatus onMasterMuteChanged(bool mute); virtual ndk::ScopedAStatus onMasterVolumeChanged(float volume); bool mMasterMute = false; float mMasterVolume = 1.0f; }; } // namespace aidl::android::hardware::audio::core