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

Commit 6b2718c6 authored by Glenn Kasten's avatar Glenn Kasten
Browse files

Bug 3352047 Wrong message when adjusting volume

Add hidden AudioManager.getDevicesForStream and output device codes.

Change-Id: I4d1c1d3b6a077cd117720817d1f733dda557b947
parent fcac8fa9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -392,6 +392,7 @@ public:
    static status_t getStreamVolumeIndex(stream_type stream, int *index);

    static uint32_t getStrategyForStream(stream_type stream);
    static uint32_t getDevicesForStream(stream_type stream);

    static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
    static status_t registerEffect(effect_descriptor_t *desc,
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public:
    virtual status_t setStreamVolumeIndex(AudioSystem::stream_type stream, int index) = 0;
    virtual status_t getStreamVolumeIndex(AudioSystem::stream_type stream, int *index) = 0;
    virtual uint32_t getStrategyForStream(AudioSystem::stream_type stream) = 0;
    virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream) = 0;
    virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
    virtual status_t registerEffect(effect_descriptor_t *desc,
                                    audio_io_handle_t output,
+7 −0
Original line number Diff line number Diff line
@@ -668,6 +668,13 @@ uint32_t AudioSystem::getStrategyForStream(AudioSystem::stream_type stream)
    return aps->getStrategyForStream(stream);
}

uint32_t AudioSystem::getDevicesForStream(AudioSystem::stream_type stream)
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return 0;
    return aps->getDevicesForStream(stream);
}

audio_io_handle_t AudioSystem::getOutputForEffect(effect_descriptor_t *desc)
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+19 −1
Original line number Diff line number Diff line
@@ -49,7 +49,8 @@ enum {
    GET_OUTPUT_FOR_EFFECT,
    REGISTER_EFFECT,
    UNREGISTER_EFFECT,
    IS_STREAM_ACTIVE
    IS_STREAM_ACTIVE,
    GET_DEVICES_FOR_STREAM,
};

class BpAudioPolicyService : public BpInterface<IAudioPolicyService>
@@ -263,6 +264,15 @@ public:
        return reply.readInt32();
    }

    virtual uint32_t getDevicesForStream(AudioSystem::stream_type stream)
    {
        Parcel data, reply;
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        data.writeInt32(static_cast <uint32_t>(stream));
        remote()->transact(GET_DEVICES_FOR_STREAM, data, &reply);
        return (uint32_t) reply.readInt32();
    }

    virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc)
    {
        Parcel data, reply;
@@ -495,6 +505,14 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        } break;

        case GET_DEVICES_FOR_STREAM: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            AudioSystem::stream_type stream =
                    static_cast <AudioSystem::stream_type>(data.readInt32());
            reply->writeInt32(static_cast <int>(getDevicesForStream(stream)));
            return NO_ERROR;
        } break;

        case GET_OUTPUT_FOR_EFFECT: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            effect_descriptor_t desc;
+14 −0
Original line number Diff line number Diff line
@@ -1543,6 +1543,20 @@ uint32_t AudioPolicyManagerBase::getStrategyForStream(AudioSystem::stream_type s
    return (uint32_t)getStrategy(stream);
}

uint32_t AudioPolicyManagerBase::getDevicesForStream(AudioSystem::stream_type stream) {
    uint32_t devices;
    // By checking the range of stream before calling getStrategy, we avoid
    // getStrategy's behavior for invalid streams.  getStrategy would do a LOGE
    // and then return STRATEGY_MEDIA, but we want to return the empty set.
    if (stream < (AudioSystem::stream_type) 0 || stream >= AudioSystem::NUM_STREAM_TYPES) {
        devices = 0;
    } else {
        AudioPolicyManagerBase::routing_strategy strategy = getStrategy(stream);
        devices = getDeviceForStrategy(strategy, true);
    }
    return devices;
}

AudioPolicyManagerBase::routing_strategy AudioPolicyManagerBase::getStrategy(
        AudioSystem::stream_type stream) {
    // stream to strategy mapping
Loading