Merge 7de73d94fc056fb6ff6cd15a2b6c54cdb7933463 on remote branch
Change-Id: Icad1b89bed864217c91f3836e9b63a573b6f2937
diff --git a/hal/AudioDevice.cpp b/hal/AudioDevice.cpp
index 9071cf7..0283d5c 100644
--- a/hal/AudioDevice.cpp
+++ b/hal/AudioDevice.cpp
@@ -623,12 +623,16 @@
auto iter =
std::find(stream_in_list_.begin(), stream_in_list_.end(), stream);
if (iter == stream_in_list_.end()) {
- AHAL_ERR("invalid output stream");
+ AHAL_ERR("invalid input stream");
} else {
- if (voice_) {
- voice_->stream_in_primary_ = nullptr;
- }
stream_in_list_.erase(iter);
+ if (voice_) {
+ if (stream_in_list_.size() == 0) {
+ voice_->stream_in_primary_ = nullptr;
+ } else {
+ voice_->stream_in_primary_ = stream_in_list_[0];
+ }
+ }
}
in_list_mutex.unlock();
}
diff --git a/hal/AudioStream.cpp b/hal/AudioStream.cpp
index bb0af27..0bec4fc 100644
--- a/hal/AudioStream.cpp
+++ b/hal/AudioStream.cpp
@@ -2610,9 +2610,9 @@
volume_ = NULL;
}
- if (left == right) {
- volume_ = (struct pal_volume_data *)malloc(sizeof(struct pal_volume_data)
- +sizeof(struct pal_channel_vol_kv));
+ if (audio_channel_count_from_out_mask(config_.channel_mask) == 1) {
+ volume_ = (struct pal_volume_data *)calloc(1, sizeof(struct pal_volume_data)
+ +sizeof(struct pal_channel_vol_kv));
if (!volume_) {
AHAL_ERR("Failed to allocate mem for volume_");
ret = -ENOMEM;
@@ -2620,9 +2620,15 @@
}
volume_->no_of_volpair = 1;
volume_->volume_pair[0].channel_mask = 0x03;
- volume_->volume_pair[0].vol = left;
+
+ if (config_.channel_mask == 0x1)
+ volume_->volume_pair[0].vol = left;
+ else if (config_.channel_mask == 0x2)
+ volume_->volume_pair[0].vol = right;
+ else
+ volume_->volume_pair[0].vol = (left + right)/2.0;
} else {
- volume_ = (struct pal_volume_data *)malloc(sizeof(struct pal_volume_data)
+ volume_ = (struct pal_volume_data *)calloc(1, sizeof(struct pal_volume_data)
+sizeof(struct pal_channel_vol_kv) * 2);
if (!volume_) {
AHAL_ERR("Failed to allocate mem for volume_");
@@ -2632,7 +2638,7 @@
volume_->no_of_volpair = 2;
volume_->volume_pair[0].channel_mask = 0x01;
volume_->volume_pair[0].vol = left;
- volume_->volume_pair[1].channel_mask = 0x10;
+ volume_->volume_pair[1].channel_mask = 0x02;
volume_->volume_pair[1].vol = right;
}
@@ -3201,8 +3207,15 @@
} else
outBufSize = StreamOutPrimary::GetBufferSize();
- if (usecase_ == USECASE_AUDIO_PLAYBACK_LOW_LATENCY)
- outBufCount = LOW_LATENCY_PLAYBACK_PERIOD_COUNT;
+ if (usecase_ == USECASE_AUDIO_PLAYBACK_LOW_LATENCY) {
+ if (streamAttributes_.type == PAL_STREAM_VOICE_CALL_MUSIC) {
+ outBufCount = LOW_LATENCY_ICMD_PLAYBACK_PERIOD_COUNT;
+ AHAL_DBG("LOW_LATENCY_ICMD - Buffer Count : %d", outBufCount);
+ }
+ else {
+ outBufCount = LOW_LATENCY_PLAYBACK_PERIOD_COUNT;
+ }
+ }
else if (usecase_ == USECASE_AUDIO_PLAYBACK_OFFLOAD2)
outBufCount = PCM_OFFLOAD_PLAYBACK_PERIOD_COUNT;
else if (usecase_ == USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)
diff --git a/hal/AudioStream.h b/hal/AudioStream.h
index e65ce28..ca8eba8 100644
--- a/hal/AudioStream.h
+++ b/hal/AudioStream.h
@@ -98,6 +98,7 @@
#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
#define LOW_LATENCY_PLAYBACK_PERIOD_SIZE 240 /** 5ms; frames */
#define LOW_LATENCY_PLAYBACK_PERIOD_COUNT 2
+#define LOW_LATENCY_ICMD_PLAYBACK_PERIOD_COUNT 4 /** In Call Music **/
#define PCM_OFFLOAD_PLAYBACK_PERIOD_COUNT 2 /** Direct PCM */
#define DEEP_BUFFER_PLAYBACK_PERIOD_COUNT 2 /** Deep Buffer*/