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

Commit 83dc617a authored by Dean Wheatley's avatar Dean Wheatley
Browse files

Propagate AudioFlinger open output flags to audio policy

Returning the output stream flags from audio flinger to audio policy
software output descriptor allows for improved decision making in audio
policy.

Test: lunch aosp_cf_x86_phone-next-eng # Enable HIDL audio HAL
      atest CtsMediaAudioTestCases:android.media.audio.cts.LoopbackPassthroughTest
      => verify through logging that SwAudioOutputDescriptor open flags
         returned as 0x401 (including AUDIO_OUTPUT_FLAG_IEC958_NONAUDIO)
         which is modified from the supplied 0x1 (AUDIO_OUTPUT_FLAG_DIRECT only)
      atest audiopolicy_tests
Bug: 311830316
Change-Id: Ia6afb882a7c1e3969594529f1b97b8ad4c792923
parent f320a4a8
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -2923,7 +2923,7 @@ sp<IAfThreadBase> AudioFlinger::openOutput_l(audio_module_handle_t module,
                                                        audio_config_base_t *mixerConfig,
                                                        audio_devices_t deviceType,
                                                        const String8& address,
                                                        audio_output_flags_t flags,
                                                        audio_output_flags_t *flags,
                                                        const audio_attributes_t attributes)
{
    AudioHwDevice *outHwDev = findSuitableHwDev_l(module, deviceType);
@@ -2958,7 +2958,7 @@ sp<IAfThreadBase> AudioFlinger::openOutput_l(audio_module_handle_t module,
    mHardwareStatus = AUDIO_HW_IDLE;

    if (status == NO_ERROR) {
        if (flags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) {
        if (*flags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) {
            const sp<IAfMmapPlaybackThread> thread = IAfMmapPlaybackThread::create(
                    this, *output, outHwDev, outputStream, mSystemReady);
            mMmapThreads.add(*output, thread);
@@ -2967,22 +2967,22 @@ sp<IAfThreadBase> AudioFlinger::openOutput_l(audio_module_handle_t module,
            return thread;
        } else {
            sp<IAfPlaybackThread> thread;
            if (flags & AUDIO_OUTPUT_FLAG_BIT_PERFECT) {
            if (*flags & AUDIO_OUTPUT_FLAG_BIT_PERFECT) {
                thread = IAfPlaybackThread::createBitPerfectThread(
                        this, outputStream, *output, mSystemReady);
                ALOGV("%s() created bit-perfect output: ID %d thread %p",
                      __func__, *output, thread.get());
            } else if (flags & AUDIO_OUTPUT_FLAG_SPATIALIZER) {
            } else if (*flags & AUDIO_OUTPUT_FLAG_SPATIALIZER) {
                thread = IAfPlaybackThread::createSpatializerThread(this, outputStream, *output,
                                                    mSystemReady, mixerConfig);
                ALOGV("openOutput_l() created spatializer output: ID %d thread %p",
                      *output, thread.get());
            } else if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
            } else if (*flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
                thread = IAfPlaybackThread::createOffloadThread(this, outputStream, *output,
                        mSystemReady, halConfig->offload_info);
                ALOGV("openOutput_l() created offload output: ID %d thread %p",
                      *output, thread.get());
            } else if ((flags & AUDIO_OUTPUT_FLAG_DIRECT)
            } else if ((*flags & AUDIO_OUTPUT_FLAG_DIRECT)
                    || !IAfThreadBase::isValidPcmSinkFormat(halConfig->format)
                    || !IAfThreadBase::isValidPcmSinkChannelMask(halConfig->channel_mask)) {
                thread = IAfPlaybackThread::createDirectOutputThread(this, outputStream, *output,
@@ -3046,7 +3046,7 @@ status_t AudioFlinger::openOutput(const media::OpenOutputRequest& request,
    audio_utils::lock_guard _l(mutex());

    const sp<IAfThreadBase> thread = openOutput_l(module, &output, &halConfig,
            &mixerConfig, deviceType, address, flags, attributes);
            &mixerConfig, deviceType, address, &flags, attributes);
    if (thread != 0) {
        uint32_t latencyMs = 0;
        if ((flags & AUDIO_OUTPUT_FLAG_MMAP_NOIRQ) == 0) {
+1 −1
Original line number Diff line number Diff line
@@ -337,7 +337,7 @@ private:
            audio_config_base_t* mixerConfig,
            audio_devices_t deviceType,
            const String8& address,
            audio_output_flags_t flags,
            audio_output_flags_t* flags,
            audio_attributes_t attributes) final REQUIRES(mutex());
    const DefaultKeyedVector<audio_module_handle_t, AudioHwDevice*>&
            getAudioHwDevs_l() const final REQUIRES(mutex(), hardwareMutex()) {
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ public:
            audio_config_base_t* mixerConfig,
            audio_devices_t deviceType,
            const String8& address,
            audio_output_flags_t flags,
            audio_output_flags_t* flags,
            audio_attributes_t attributes) REQUIRES(mutex()) = 0;
    virtual audio_utils::mutex& mutex() const
            RETURN_CAPABILITY(audio_utils::AudioFlinger_Mutex) = 0;
+1 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ status_t PatchPanel::createAudioPatch_l(const struct audio_patch* patch,
                                                            &mixerConfig,
                                                            outputDevice,
                                                            outputDeviceAddress,
                                                            flags,
                                                            &flags,
                                                            attributes);
                    ALOGV("mAfPatchPanelCallback->openOutput_l() returned %p", thread.get());
                    if (thread == 0) {
+8 −7
Original line number Diff line number Diff line
@@ -41,19 +41,20 @@ status_t AudioHwDevice::openOutputStream(
        AudioStreamOut **ppStreamOut,
        audio_io_handle_t handle,
        audio_devices_t deviceType,
        audio_output_flags_t flags,
        audio_output_flags_t *flags,
        struct audio_config *config,
        const char *address,
        const std::vector<playback_track_metadata_v7_t>& sourceMetadata)
{

    struct audio_config originalConfig = *config;
    auto outputStream = new AudioStreamOut(this, flags);
    auto outputStream = new AudioStreamOut(this);

    // Try to open the HAL first using the current format.
    ALOGV("openOutputStream(), try sampleRate %d, format %#x, channelMask %#x", config->sample_rate,
            config->format, config->channel_mask);
    status_t status = outputStream->open(handle, deviceType, config, address, sourceMetadata);
    status_t status = outputStream->open(handle, deviceType, config, flags, address,
                                        sourceMetadata);

    if (status != NO_ERROR) {
        delete outputStream;
@@ -67,13 +68,13 @@ status_t AudioHwDevice::openOutputStream(

        // If the data is encoded then try again using wrapped PCM.
        const bool wrapperNeeded = !audio_has_proportional_frames(originalConfig.format)
                && ((flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)
                && ((flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0);
                && ((*flags & AUDIO_OUTPUT_FLAG_DIRECT) != 0)
                && ((*flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) == 0);

        if (wrapperNeeded) {
            if (SPDIFEncoder::isFormatSupported(originalConfig.format)) {
                outputStream = new SpdifStreamOut(this, flags, originalConfig.format);
                status = outputStream->open(handle, deviceType, &originalConfig, address,
                outputStream = new SpdifStreamOut(this, originalConfig.format);
                status = outputStream->open(handle, deviceType, &originalConfig, flags, address,
                                            sourceMetadata);
                if (status != NO_ERROR) {
                    ALOGE("ERROR - openOutputStream(), SPDIF open returned %d",
Loading