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

Commit a596d2d2 authored by Robert Wu's avatar Robert Wu Committed by Android (Google) Code Review
Browse files

Merge "Add AudioDeviceVector to MMAP path" into main

parents 780fc38c aeb1d00b
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#ifndef ANDROID_AUDIO_MMAP_STREAM_CALLBACK_H
#define ANDROID_AUDIO_MMAP_STREAM_CALLBACK_H

#include <media/AudioContainers.h>
#include <system/audio.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>
@@ -42,10 +43,10 @@ class MmapStreamCallback : public virtual RefBase {
    virtual void onVolumeChanged(float volume) = 0;

    /**
     * The device the stream is routed to/from has changed
     * \param[in] onRoutingChanged the unique device ID of the new device.
     * The devices the stream is routed to/from has changed
     * \param[in] deviceIds a set of the device IDs of the new devices.
     */
    virtual void onRoutingChanged(audio_port_handle_t deviceId) = 0;
    virtual void onRoutingChanged(const DeviceIdVector& deviceIds) = 0;

  protected:
    MmapStreamCallback() {}
+6 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <system/audio.h>
#include <media/AudioClient.h>
#include <media/AudioContainers.h>
#include <utils/Errors.h>
#include <utils/RefBase.h>

@@ -51,7 +52,8 @@ class MmapStreamInterface : public virtual RefBase
     *                       Requested parameters as input,
     *                       Actual parameters as output
     * \param[in] client a AudioClient struct describing the first client using this stream.
     * \param[in,out] deviceId audio device the stream should preferably be routed to/from
     * \param[in,out] deviceIds audio devices the stream should preferably be routed to/from.
     *                          Leave empty if there are no preferred devices.
     *                          Requested as input,
     *                          Actual as output
     * \param[in,out] sessionId audio sessionId for the stream
@@ -70,7 +72,7 @@ class MmapStreamInterface : public virtual RefBase
                                           const audio_attributes_t *attr,
                                           audio_config_base_t *config,
                                           const AudioClient& client,
                                           audio_port_handle_t *deviceId,
                                           DeviceIdVector *deviceIds,
                                           audio_session_t *sessionId,
                                           const sp<MmapStreamCallback>& callback,
                                           sp<MmapStreamInterface>& interface,
+11 −11
Original line number Diff line number Diff line
@@ -541,7 +541,7 @@ status_t MmapStreamInterface::openMmapStream(MmapStreamInterface::stream_directi
                                             const audio_attributes_t *attr,
                                             audio_config_base_t *config,
                                             const AudioClient& client,
                                             audio_port_handle_t *deviceId,
                                             DeviceIdVector *deviceIds,
                                             audio_session_t *sessionId,
                                             const sp<MmapStreamCallback>& callback,
                                             sp<MmapStreamInterface>& interface,
@@ -553,7 +553,7 @@ status_t MmapStreamInterface::openMmapStream(MmapStreamInterface::stream_directi
    status_t ret = NO_INIT;
    if (af != 0) {
        ret = af->openMmapStream(
                direction, attr, config, client, deviceId,
                direction, attr, config, client, deviceIds,
                sessionId, callback, interface, handle);
    }
    return ret;
@@ -563,7 +563,7 @@ status_t AudioFlinger::openMmapStream(MmapStreamInterface::stream_direction_t di
                                      const audio_attributes_t *attr,
                                      audio_config_base_t *config,
                                      const AudioClient& client,
                                      audio_port_handle_t *deviceId,
                                      DeviceIdVector *deviceIds,
                                      audio_session_t *sessionId,
                                      const sp<MmapStreamCallback>& callback,
                                      sp<MmapStreamInterface>& interface,
@@ -630,22 +630,17 @@ status_t AudioFlinger::openMmapStream(MmapStreamInterface::stream_direction_t di
        bool isBitPerfect;
        float volume;
        bool muted;
        DeviceIdVector selectedDeviceIds;
        if (*deviceId != AUDIO_PORT_HANDLE_NONE) {
            selectedDeviceIds.push_back(*deviceId);
        }
        ret = AudioSystem::getOutputForAttr(&localAttr, &io,
                                            actualSessionId,
                                            &streamType, adjAttributionSource,
                                            &fullConfig,
                                            (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_MMAP_NOIRQ |
                                                    AUDIO_OUTPUT_FLAG_DIRECT),
                                            &selectedDeviceIds, &portId, &secondaryOutputs,
                                            deviceIds, &portId, &secondaryOutputs,
                                            &isSpatialized,
                                            &isBitPerfect,
                                            &volume,
                                            &muted);
        *deviceId = getFirstDeviceId(selectedDeviceIds);
        if (ret != NO_ERROR) {
            config->sample_rate = fullConfig.sample_rate;
            config->channel_mask = fullConfig.channel_mask;
@@ -654,12 +649,17 @@ status_t AudioFlinger::openMmapStream(MmapStreamInterface::stream_direction_t di
        ALOGW_IF(!secondaryOutputs.empty(),
                 "%s does not support secondary outputs, ignoring them", __func__);
    } else {
        audio_port_handle_t deviceId = getFirstDeviceId(*deviceIds);
        ret = AudioSystem::getInputForAttr(&localAttr, &io,
                                              RECORD_RIID_INVALID,
                                              actualSessionId,
                                              adjAttributionSource,
                                              config,
                                              AUDIO_INPUT_FLAG_MMAP_NOIRQ, deviceId, &portId);
                                              AUDIO_INPUT_FLAG_MMAP_NOIRQ, &deviceId, &portId);
        deviceIds->clear();
        if (deviceId != AUDIO_PORT_HANDLE_NONE) {
            deviceIds->push_back(deviceId);
        }
    }
    if (ret != NO_ERROR) {
        return ret;
@@ -673,7 +673,7 @@ status_t AudioFlinger::openMmapStream(MmapStreamInterface::stream_direction_t di
    const sp<IAfMmapThread> thread = mMmapThreads.valueFor(io);
    if (thread != 0) {
        interface = IAfMmapThread::createMmapStreamInterfaceAdapter(thread);
        thread->configure(&localAttr, streamType, actualSessionId, callback, *deviceId, portId);
        thread->configure(&localAttr, streamType, actualSessionId, callback, *deviceIds, portId);
        *handle = portId;
        *sessionId = actualSessionId;
        config->sample_rate = thread->sampleRate();
+1 −1
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ public:
                            const audio_attributes_t *attr,
                            audio_config_base_t *config,
                            const AudioClient& client,
                            audio_port_handle_t *deviceId,
                            DeviceIdVector *deviceIds,
                            audio_session_t *sessionId,
                            const sp<MmapStreamCallback>& callback,
                            sp<MmapStreamInterface>& interface,
+1 −1
Original line number Diff line number Diff line
@@ -661,7 +661,7 @@ public:
            audio_stream_type_t streamType,
            audio_session_t sessionId,
            const sp<MmapStreamCallback>& callback,
            audio_port_handle_t deviceId,
            const DeviceIdVector& deviceIds,
            audio_port_handle_t portId) EXCLUDES_ThreadBase_Mutex = 0;
    virtual void disconnect() EXCLUDES_ThreadBase_Mutex = 0;

Loading