Skip to content

Commit

Permalink
policy_hal: Update offload restrictions
Browse files Browse the repository at this point in the history
 * Fix the PCM offload duration checks
 * Reject offloading for A2DP and USB devices in order to
   hit the fail-fast path in Stagefright- this allows transparent
   fallback to 16-bit PCM with resampling when necessary.

Change-Id: I26d1fd9d92f267c6875e98ef490e8d90bb442813
  • Loading branch information
hyperb1iss committed Oct 8, 2014
1 parent cd52609 commit 6f374f0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions policy_hal/AudioPolicyManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1426,16 +1426,20 @@ bool AudioPolicyManager::isOffloadSupported(const audio_offload_info_t& offloadI

//If duration is less than minimum value defined in property, return false
if (property_get("audio.offload.min.duration.secs", propValue, NULL)) {
if (offloadInfo.duration_us < (atoi(propValue) * 1000000 )) {
if (offloadInfo.duration_us < (atoi(propValue) * 1000000 ) &&
(offloadInfo.format == AUDIO_FORMAT_MP3 || offloadInfo.format == AUDIO_FORMAT_AAC ||
(pcmOffload && offloadInfo.bit_width < 24))) {
ALOGD("copl: Offload denied by duration < audio.offload.min.duration.secs(=%s)", propValue);
return false;
}
} else if (offloadInfo.duration_us < OFFLOAD_DEFAULT_MIN_DURATION_SECS * 1000000) {
ALOGD("copl: Offload denied by duration < default min(=%u)", OFFLOAD_DEFAULT_MIN_DURATION_SECS);
//duration checks only valid for MP3/AAC formats,
//do not check duration for other audio formats, e.g. dolby AAC/AC3 and amrwb+ formats
if (offloadInfo.format == AUDIO_FORMAT_MP3 || offloadInfo.format == AUDIO_FORMAT_AAC || (pcmOffload && offloadInfo.bit_width < 24))
if (offloadInfo.format == AUDIO_FORMAT_MP3 || offloadInfo.format == AUDIO_FORMAT_AAC ||
(pcmOffload && offloadInfo.bit_width < 24)) {
ALOGD("copl: Offload denied by duration < default min(=%u)", OFFLOAD_DEFAULT_MIN_DURATION_SECS);
return false;
}
}

// Do not allow offloading if one non offloadable effect is enabled. This prevents from
Expand All @@ -1448,6 +1452,18 @@ bool AudioPolicyManager::isOffloadSupported(const audio_offload_info_t& offloadI
return false;
}

// A2DP cannot currently be offloaded
if (mA2dpDeviceAddress != "") {
ALOGD("copl: offload rejected for a2dp device");
return false;
}

// USB audio cannot be offloaded with breaking Visualizer
if (mUsbCardAndDevice != "") {
ALOGD("copl: offload rejected for USB device");
return false;
}

// Check for soundcard status
String8 valueStr = mpClientInterface->getParameters((audio_io_handle_t)0,
String8(AUDIO_PARAMETER_KEY_SND_CARD_STATUS));
Expand Down

0 comments on commit 6f374f0

Please sign in to comment.