hal: Disable gapless offload playback by default.
-Set the property-audio.offload.gapless.enabled to true to enable
gapless playback by default.
-Set mixer control to the driver to decide if gapless playback needs
to be used or not
-If gapless playback is not enabled then partial drain from HAL is
treated as full drain.
Change-Id: Id7f4967fe528bab9097c3f609058276ec02174e1
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index ee68a8f..118239d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1,8 +1,8 @@
/*
- * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
*
- * Copyright (C) 2013 The Android Open Source Project
+ * Copyright (C) 2013-2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -153,6 +153,7 @@
static int set_voice_volume_l(struct audio_device *adev, float volume);
static uint32_t get_offload_buffer_size();
+static int set_gapless_mode(struct audio_device *adev);
static bool is_supported_format(audio_format_t format)
{
@@ -2138,6 +2139,9 @@
}
}
+ //Decide if we need to use gapless mode by default
+ set_gapless_mode(adev);
+
} else if (out->flags & AUDIO_OUTPUT_FLAG_INCALL_MUSIC) {
ret = voice_check_and_set_incall_music_usecase(adev, out);
if (ret != 0) {
@@ -2688,6 +2692,33 @@
return fragment_size;
}
+static int set_gapless_mode(struct audio_device *adev) {
+
+
+ char value[PROPERTY_VALUE_MAX] = {0};
+ bool gapless_enabled = false;
+ const char *mixer_ctl_name = "Compress Gapless Playback";
+ struct mixer_ctl *ctl;
+
+ ALOGV("%s:", __func__);
+ property_get("audio.offload.gapless.enabled", value, NULL);
+ gapless_enabled = atoi(value) || !strncmp("true", value, 4);
+
+ ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
+ if (!ctl) {
+ ALOGE("%s: Could not get ctl for mixer cmd - %s",
+ __func__, mixer_ctl_name);
+ return -EINVAL;
+ }
+
+ if (mixer_ctl_set_value(ctl, 0, gapless_enabled) < 0) {
+ ALOGE("%s: Could not set gapless mode %d",
+ __func__, gapless_enabled);
+ return -EINVAL;
+ }
+ return 0;
+
+}
static struct hw_module_methods_t hal_module_methods = {
.open = adev_open,
};