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

Commit b9e9dfd0 authored by Sharad Sangle's avatar Sharad Sangle Committed by Gerrit - the friendly Code Review server
Browse files

policy-hal: Restrict track offload for fractional sample rate

Restrict track offload for fractional sample rates

Change-Id: I21ff697d90870040d800a19f0a776e855856aa8e
parent 51e5a9a6
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@
// type alone is not enough: the address must match too
#define APM_AUDIO_DEVICE_MATCH_ADDRESS_ALL (AUDIO_DEVICE_IN_REMOTE_SUBMIX | \
                                            AUDIO_DEVICE_OUT_REMOTE_SUBMIX)

#define SAMPLE_RATE_8000 8000
#include <inttypes.h>
#include <math.h>

@@ -1331,7 +1331,7 @@ bool AudioPolicyManagerCustom::isDirectOutput(audio_io_handle_t output) {
    return false;
}

bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags, uint32_t samplingRate)
{
    bool playerDirectPCM = false; // Output request for Track created by mediaplayer
    bool trackDirectPCM = false;  // Output request for track created by other apps
@@ -1358,7 +1358,7 @@ bool static tryForDirectPCM(int bitWidth, audio_output_flags_t *flags)
       // Reset flag to NONE so that we can still reuse direct pcm criteria check
       // in getOutputforDevice
       *flags = AUDIO_OUTPUT_FLAG_NONE;
    } else if ( *flags == AUDIO_OUTPUT_FLAG_NONE) {
    } else if ((*flags == AUDIO_OUTPUT_FLAG_NONE) && (samplingRate % SAMPLE_RATE_8000 == 0)) {
        trackDirectPCM = property_get_bool("audio.offload.track.enable", true);
    }

@@ -1385,7 +1385,7 @@ status_t AudioPolicyManagerCustom::getOutputForAttr(const audio_attributes_t *at
    uint32_t bitWidth = (audio_bytes_per_sample(format) * 8);


    if (tryForDirectPCM(bitWidth, &flags) &&
    if (tryForDirectPCM(bitWidth, &flags, samplingRate) &&
        (offloadInfo == NULL)) {

        tOffloadInfo.sample_rate  = samplingRate;