Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6d3ea6c authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Automerger Merge Worker
Browse files

Merge "audio: Add methods for controlling hw volume" am: 0ae51672 am: e4775104

parents c58c687e e4775104
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -41,9 +41,13 @@ interface IStreamIn {
  float getMicrophoneFieldDimension();
  void setMicrophoneFieldDimension(float zoom);
  void updateMetadata(in android.hardware.audio.common.SinkMetadata sinkMetadata);
  float[] getHwGain();
  void setHwGain(in float[] channelGains);
  const int MIC_FIELD_DIMENSION_WIDE_ANGLE = -1;
  const int MIC_FIELD_DIMENSION_NO_ZOOM = 0;
  const int MIC_FIELD_DIMENSION_MAX_ZOOM = 1;
  const int HW_GAIN_MIN = 0;
  const int HW_GAIN_MAX = 1;
  @Backing(type="int") @VintfStability
  enum MicrophoneDirection {
    UNSPECIFIED = 0,
+4 −0
Original line number Diff line number Diff line
@@ -36,4 +36,8 @@ package android.hardware.audio.core;
interface IStreamOut {
  android.hardware.audio.core.IStreamCommon getStreamCommon();
  void updateMetadata(in android.hardware.audio.common.SourceMetadata sourceMetadata);
  float[] getHwVolume();
  void setHwVolume(in float[] channelVolumes);
  const int HW_VOLUME_MIN = 0;
  const int HW_VOLUME_MAX = 1;
}
+34 −0
Original line number Diff line number Diff line
@@ -131,4 +131,38 @@ interface IStreamIn {
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     */
    void updateMetadata(in SinkMetadata sinkMetadata);

    const int HW_GAIN_MIN = 0;
    const int HW_GAIN_MAX = 1;
    /**
     * Retrieve current gain applied in hardware.
     *
     * In case when the HAL module has a gain controller, this method returns
     * the current value of its gain for each input channel.
     *
     * The valid range for gain is [0.0f, 1.0f], where 1.0f corresponds to unity
     * gain, 0.0f corresponds to full mute (see HW_GAIN_* constants).
     *
     * @return Current gain values for each input channel.
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     * @throws EX_UNSUPPORTED_OPERATION If hardware gain control is not supported.
     */
    float[] getHwGain();
    /**
     * Set gain applied in hardware.
     *
     * In case when the HAL module has a gain controller, this method sets the
     * current value of its gain for each input channel.
     *
     * The valid range for gain is [0.0f, 1.0f], where 1.0f corresponds to unity
     * gain, 0.0f corresponds to full mute (see HW_GAIN_* constants).
     *
     * @param gain Gain values for each input channel.
     * @throws EX_ILLEGAL_ARGUMENT If the number of elements in the provided
     *                             array does not match the channel count, or
     *                             gain values are out of range.
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     * @throws EX_UNSUPPORTED_OPERATION If hardware gain control is not supported.
     */
    void setHwGain(in float[] channelGains);
}
+42 −0
Original line number Diff line number Diff line
@@ -44,4 +44,46 @@ interface IStreamOut {
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     */
    void updateMetadata(in SourceMetadata sourceMetadata);

    const int HW_VOLUME_MIN = 0;
    const int HW_VOLUME_MAX = 1;
    /**
     * Retrieve current attenuation applied in hardware.
     *
     * Hardware attenuation can be used in cases when the client can not, or is
     * not allowed to modify the audio stream, for example because the stream is
     * encoded.
     *
     * The valid range for attenuation is [0.0f, 1.0f], where 1.0f corresponds
     * to unity gain, 0.0f corresponds to full mute (see HW_VOLUME_*
     * constants). The returned array specifies attenuation for each output
     * channel of the stream.
     *
     * Support of hardware volume control is optional.
     *
     * @return Current attenuation values for each output channel.
     * @throws EX_ILLEGAL_STATE If the stream is closed.
     * @throws EX_UNSUPPORTED_OPERATION If hardware volume control is not supported.
     */
    float[] getHwVolume();
    /**
     * Set attenuation applied in hardware.
     *
     * Hardware attenuation can be used in cases when the client can not, or is
     * not allowed to modify the audio stream, for example because the stream is
     * encoded.
     *
     * The valid range for attenuation is [0.0f, 1.0f], where 1.0f corresponds
     * to unity gain, 0.0f corresponds to full mute (see HW_VOLUME_* constants).
     *
     * Support of hardware volume control is optional.
     *
     * @param channelVolumes Attenuation values for each output channel.
     * @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_UNSUPPORTED_OPERATION If hardware volume control is not supported.
     */
    void setHwVolume(in float[] channelVolumes);
}
+22 −0
Original line number Diff line number Diff line
@@ -658,6 +658,17 @@ ndk::ScopedAStatus StreamIn::setMicrophoneFieldDimension(float in_zoom) {
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

ndk::ScopedAStatus StreamIn::getHwGain(std::vector<float>* _aidl_return) {
    LOG(DEBUG) << __func__;
    (void)_aidl_return;
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

ndk::ScopedAStatus StreamIn::setHwGain(const std::vector<float>& in_channelGains) {
    LOG(DEBUG) << __func__ << ": gains " << ::android::internal::ToString(in_channelGains);
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

// static
ndk::ScopedAStatus StreamOut::createInstance(const SourceMetadata& sourceMetadata,
                                             StreamContext context,
@@ -680,4 +691,15 @@ StreamOut::StreamOut(const SourceMetadata& sourceMetadata, StreamContext&& conte
    LOG(DEBUG) << __func__;
}

ndk::ScopedAStatus StreamOut::getHwVolume(std::vector<float>* _aidl_return) {
    LOG(DEBUG) << __func__;
    (void)_aidl_return;
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

ndk::ScopedAStatus StreamOut::setHwVolume(const std::vector<float>& in_channelVolumes) {
    LOG(DEBUG) << __func__ << ": gains " << ::android::internal::ToString(in_channelVolumes);
    return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}

}  // namespace aidl::android::hardware::audio::core
Loading