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

Commit 9a59b4ca authored by Derek Chen's avatar Derek Chen
Browse files

hal: set default unity volume for bus streams

Set default volume at unity gain for automotive
bus streams upon open.

Change-Id: I3cc55632d6d9c642afd615c45a0b5e2cc2c49f71
parent 3b7c38b2
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -461,6 +461,7 @@ int auto_hal_open_output_stream(struct stream_out *out)
        if (out->flags == AUDIO_OUTPUT_FLAG_NONE ||
            out->flags == AUDIO_OUTPUT_FLAG_PRIMARY)
            out->flags |= AUDIO_OUTPUT_FLAG_MEDIA;
        out->volume_l = out->volume_r = MAX_VOLUME_GAIN;
        break;
    case CAR_AUDIO_STREAM_SYS_NOTIFICATION:
        /* sys notification bus stream shares pcm device with low-latency */
@@ -468,6 +469,7 @@ int auto_hal_open_output_stream(struct stream_out *out)
        out->config = pcm_config_system;
        if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
            out->flags |= AUDIO_OUTPUT_FLAG_SYS_NOTIFICATION;
        out->volume_l = out->volume_r = MAX_VOLUME_GAIN;
        break;
    case CAR_AUDIO_STREAM_NAV_GUIDANCE:
        out->usecase = USECASE_AUDIO_PLAYBACK_NAV_GUIDANCE;
@@ -481,12 +483,14 @@ int auto_hal_open_output_stream(struct stream_out *out)
        }
        if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
            out->flags |= AUDIO_OUTPUT_FLAG_NAV_GUIDANCE;
        out->volume_l = out->volume_r = MAX_VOLUME_GAIN;
        break;
    case CAR_AUDIO_STREAM_PHONE:
        out->usecase = USECASE_AUDIO_PLAYBACK_PHONE;
        out->config = pcm_config_system;
        if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
            out->flags |= AUDIO_OUTPUT_FLAG_PHONE;
        out->volume_l = out->volume_r = MAX_VOLUME_GAIN;
        break;
    case CAR_AUDIO_STREAM_REAR_SEAT:
        out->usecase = USECASE_AUDIO_PLAYBACK_REAR_SEAT;
@@ -500,6 +504,7 @@ int auto_hal_open_output_stream(struct stream_out *out)
        }
        if (out->flags == AUDIO_OUTPUT_FLAG_NONE)
            out->flags |= AUDIO_OUTPUT_FLAG_REAR_SEAT;
        out->volume_l = out->volume_r = MAX_VOLUME_GAIN;
        break;
    default:
        ALOGE("%s: Car audio stream %x not supported", __func__,
@@ -610,9 +615,9 @@ int auto_hal_set_audio_port_config(struct audio_hw_device *dev,
                     * q13 = (10^(mdb/100/20))*(2^13)
                     */
                    if(config->gain.values[0] <= (MIN_VOLUME_VALUE_MB + STEP_VALUE_MB))
                        volume = 0.0 ;
                        volume = MIN_VOLUME_GAIN;
                    else
                        volume = powf(10.0, ((float)config->gain.values[0] / 2000));
                        volume = powf(10.0f, ((float)config->gain.values[0] / 2000));
                    ALOGV("%s: set volume to stream: %p", __func__,
                        &out_ctxt->output->stream);
                    /* set gain if output stream is active */
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@
#define MAX_VOLUME_VALUE_MB 600
#define STEP_VALUE_MB 100

#define MIN_VOLUME_GAIN 0.0f
#define MAX_VOLUME_GAIN 1.0f

typedef struct auto_hal_module {
    struct audio_device *adev;
    card_status_t card_status;