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

Commit 2fc9d15e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Select haptic output when haptic-generating effect exists."

parents c1918431 ebb6af45
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public:
                     audio_io_handle_t dstOutput);
    void moveEffects(const std::vector<int>& ids, audio_io_handle_t dstOutput);

    audio_io_handle_t getIoForSession(audio_session_t sessionId,
                                      const effect_uuid_t *effectType = nullptr);

    void dump(String8 *dst, int spaces = 0, bool verbose = true) const;

private:
+13 −0
Original line number Diff line number Diff line
@@ -202,6 +202,19 @@ void EffectDescriptorCollection::moveEffects(const std::vector<int>& ids,
    }
}

audio_io_handle_t EffectDescriptorCollection::getIoForSession(audio_session_t sessionId,
                                                              const effect_uuid_t *effectType)
{
    for (size_t i = 0; i < size(); ++i) {
        sp<EffectDescriptor> effect = valueAt(i);
        if (effect->mSession == sessionId && (effectType == nullptr ||
                memcmp(&effect->mDesc.type, effectType, sizeof(effect_uuid_t)) == 0)) {
            return effect->mIo;
        }
    }
    return AUDIO_IO_HANDLE_NONE;
}

EffectDescriptorCollection EffectDescriptorCollection::getEffectsForIo(audio_io_handle_t io) const
{
    EffectDescriptorCollection effects;
+21 −6
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@
#include <private/android_filesystem_config.h>
#include <system/audio.h>
#include <system/audio_config.h>
#include <system/audio_effects/effect_hapticgenerator.h>
#include "AudioPolicyManager.h"
#include <Serializer.h>
#include "TypeConverter.h"
@@ -1300,7 +1301,8 @@ audio_io_handle_t AudioPolicyManager::getOutputForDevices(

        // at this stage we should ignore the DIRECT flag as no direct output could be found earlier
        *flags = (audio_output_flags_t)(*flags & ~AUDIO_OUTPUT_FLAG_DIRECT);
        output = selectOutput(outputs, *flags, config->format, channelMask, config->sample_rate);
        output = selectOutput(
                outputs, *flags, config->format, channelMask, config->sample_rate, session);
    }
    ALOGW_IF((output == 0), "getOutputForDevices() could not find output for stream %d, "
            "sampling rate %d, format %#x, channels %#x, flags %#x",
@@ -1476,11 +1478,23 @@ audio_io_handle_t AudioPolicyManager::selectOutput(const SortedVector<audio_io_h
                                                   audio_output_flags_t flags,
                                                   audio_format_t format,
                                                   audio_channel_mask_t channelMask,
                                                       uint32_t samplingRate)
                                                   uint32_t samplingRate,
                                                   audio_session_t sessionId)
{
    LOG_ALWAYS_FATAL_IF(!(format == AUDIO_FORMAT_INVALID || audio_is_linear_pcm(format)),
        "%s called with format %#x", __func__, format);

    // Return the output that haptic-generating attached to when 1) session id is specified,
    // 2) haptic-generating effect exists for given session id and 3) the output that
    // haptic-generating effect attached to is in given outputs.
    if (sessionId != AUDIO_SESSION_NONE) {
        audio_io_handle_t hapticGeneratingOutput = mEffects.getIoForSession(
                sessionId, FX_IID_HAPTICGENERATOR);
        if (outputs.indexOf(hapticGeneratingOutput) >= 0) {
            return hapticGeneratingOutput;
        }
    }

    // Flags disqualifying an output: the match must happen before calling selectOutput()
    static const audio_output_flags_t kExcludedFlags = (audio_output_flags_t)
        (AUDIO_OUTPUT_FLAG_HW_AV_SYNC | AUDIO_OUTPUT_FLAG_MMAP_NOIRQ | AUDIO_OUTPUT_FLAG_DIRECT);
@@ -5290,7 +5304,8 @@ void AudioPolicyManager::checkOutputForAttributes(const audio_attributes_t &attr
                                                                     client->flags(),
                                                                     client->config().format,
                                                                     client->config().channel_mask,
                                                                     client->config().sample_rate);
                                                                     client->config().sample_rate,
                                                                     client->session());
                    if (newOutput != srcOut) {
                        invalidate = true;
                        break;
+2 −1
Original line number Diff line number Diff line
@@ -608,7 +608,8 @@ protected:
                                       audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
                                       audio_format_t format = AUDIO_FORMAT_INVALID,
                                       audio_channel_mask_t channelMask = AUDIO_CHANNEL_NONE,
                                       uint32_t samplingRate = 0);
                                       uint32_t samplingRate = 0,
                                       audio_session_t sessionId = AUDIO_SESSION_NONE);
        // samplingRate, format, channelMask are in/out and so may be modified
        sp<IOProfile> getInputProfile(const sp<DeviceDescriptor> & device,
                                      uint32_t& samplingRate,