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

Commit eda6c364 authored by Eric Laurent's avatar Eric Laurent
Browse files

Fix issue 3371080

Modified default volume control logic in AudioService:
1 IN_CALL volume if in video/audio chat
2 NOTIFICATION if notification is playing or was playing less than 5s ago.
3 MUSIC

Modified silent mode:
- now also affect MUSIC stream type
- entering silent mode when VOL- hard key is pressed once while selected
stream volume is already at 0 (except for VOICE_CALL stream).
- exiting silent mode when pressing VOL+ hard key while in silent mode

Play sound FX (audible selections, keyboard clicks) at a fixed volume.

Modified audio framework:
- isStreamActive() method now implemented in AudioPolicyManagerBase (previously AudioFlinger)
- iStreamActive() now specifies a time window during which the stream is considered
active after it actually stopped.

Change-Id: I7e5a0724099450b9fc90825224180ac97322785f
parent ab8a0bad
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -204,8 +204,9 @@ public:
    // set audio mode in audio hardware (see AudioSystem::audio_mode)
    static status_t setMode(int mode);

    // returns true in *state if tracks are active on the specified stream
    static status_t isStreamActive(int stream, bool *state);
    // returns true in *state if tracks are active on the specified stream or has been active
    // in the past inPastMs milliseconds
    static status_t isStreamActive(int stream, bool *state, uint32_t inPastMs = 0);

    // set/get audio hardware parameters. The function accepts a list of parameters
    // key value pairs in the form: key1=value1;key2=value2;...
+0 −3
Original line number Diff line number Diff line
@@ -102,9 +102,6 @@ public:
    virtual     status_t    setMicMute(bool state) = 0;
    virtual     bool        getMicMute() const = 0;

    // is any track active on this stream?
    virtual     bool        isStreamActive(int stream) const = 0;

    virtual     status_t    setParameters(int ioHandle, const String8& keyValuePairs) = 0;
    virtual     String8     getParameters(int ioHandle, const String8& keys) = 0;

+1 −0
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ public:
                                    int session,
                                    int id) = 0;
    virtual status_t unregisterEffect(int id) = 0;
    virtual bool     isStreamActive(int stream, uint32_t inPastMs = 0) const = 0;
};


+8 −9
Original line number Diff line number Diff line
@@ -169,15 +169,6 @@ status_t AudioSystem::setMode(int mode)
    return af->setMode(mode);
}


status_t AudioSystem::isStreamActive(int stream, bool* state) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == 0) return PERMISSION_DENIED;
    *state = af->isStreamActive(stream);
    return NO_ERROR;
}


status_t AudioSystem::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == 0) return PERMISSION_DENIED;
@@ -702,6 +693,14 @@ status_t AudioSystem::unregisterEffect(int id)
    return aps->unregisterEffect(id);
}

status_t AudioSystem::isStreamActive(int stream, bool* state, uint32_t inPastMs) {
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return PERMISSION_DENIED;
    *state = aps->isStreamActive(stream, inPastMs);
    return NO_ERROR;
}


// ---------------------------------------------------------------------------

void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who) {
+0 −16
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ enum {
    SET_MODE,
    SET_MIC_MUTE,
    GET_MIC_MUTE,
    IS_STREAM_ACTIVE,
    SET_PARAMETERS,
    GET_PARAMETERS,
    REGISTER_CLIENT,
@@ -316,15 +315,6 @@ public:
        return reply.readInt32();
    }

    virtual bool isStreamActive(int stream) const
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
        data.writeInt32(stream);
        remote()->transact(IS_STREAM_ACTIVE, data, &reply);
        return reply.readInt32();
    }

    virtual status_t setParameters(int ioHandle, const String8& keyValuePairs)
    {
        Parcel data, reply;
@@ -826,12 +816,6 @@ status_t BnAudioFlinger::onTransact(
            reply->writeInt32( getMicMute() );
            return NO_ERROR;
        } break;
        case IS_STREAM_ACTIVE: {
            CHECK_INTERFACE(IAudioFlinger, data, reply);
            int stream = data.readInt32();
            reply->writeInt32( isStreamActive(stream) );
            return NO_ERROR;
        } break;
        case SET_PARAMETERS: {
            CHECK_INTERFACE(IAudioFlinger, data, reply);
            int ioHandle = data.readInt32();
Loading