policy-hal: Restrict trck offload for fractional sample rate

Restrict trck offload for fractional sample rate

Change-Id: I21ff697d90870040d800a19f0a776e855856aa8e
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index c8414af..7002932 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -52,7 +52,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>
 
@@ -1411,7 +1411,7 @@
     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
@@ -1438,7 +1438,7 @@
        // 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);
     }
 
@@ -1465,7 +1465,7 @@
     uint32_t bitWidth = (audio_bytes_per_sample(format) * 8);
 
 
-    if (tryForDirectPCM(bitWidth, &flags) &&
+    if (tryForDirectPCM(bitWidth, &flags, samplingRate) &&
         (offloadInfo == NULL)) {
 
         tOffloadInfo.sample_rate  = samplingRate;