summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2016-02-23 23:58:55 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2016-02-23 23:58:55 -0800
commitda00d6773e74d80c0f90ca96d04a9715efe30798 (patch)
treefec41e45a030e7c41d201579cb88f27dce2868dd
parentfdd505a4c82989717045945cd45e9bba383df448 (diff)
parentbbce432b67f41703d8e15518ba86c6f4827929fa (diff)
downloadandroid_hardware_qcom_audio-da00d6773e74d80c0f90ca96d04a9715efe30798.tar.gz
android_hardware_qcom_audio-da00d6773e74d80c0f90ca96d04a9715efe30798.tar.bz2
android_hardware_qcom_audio-da00d6773e74d80c0f90ca96d04a9715efe30798.zip
Merge "hal: Ensure that stream is not started during Sub system restart." into av-userspace.lnx.1.0-dev.1.0
-rw-r--r--hal/audio_hw.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index f8b96522..e4b8a37a 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -1997,7 +1997,7 @@ static int out_standby(struct audio_stream *stream)
pthread_mutex_unlock(&adev->lock);
}
pthread_mutex_unlock(&out->lock);
- ALOGV("%s: exit", __func__);
+ ALOGD("%s: exit", __func__);
return 0;
}
@@ -2311,20 +2311,20 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
lock_output_stream(out);
if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
- // increase written size during SSR to avoid mismatch
- // with the written frames count in AF
- if (!is_offload_usecase(out->usecase))
- out->written += bytes / (out->config.channels * sizeof(short));
- if (out->pcm) {
- ALOGD(" %s: sound card is not active/SSR state", __func__);
- ret= -EIO;
- goto exit;
- } else if (is_offload_usecase(out->usecase)) {
- //during SSR for compress usecase we should return error to flinger
+ if (is_offload_usecase(out->usecase)) {
+ /*during SSR for compress usecase we should return error to flinger*/
ALOGD(" copl %s: sound card is not active/SSR state", __func__);
pthread_mutex_unlock(&out->lock);
return -ENETRESET;
+ } else {
+ /* increase written size during SSR to avoid mismatch
+ * with the written frames count in AF
+ */
+ out->written += bytes / (out->config.channels * sizeof(short));
+ ALOGD(" %s: sound card is not active/SSR state", __func__);
+ ret= -EIO;
+ goto exit;
}
}
@@ -2434,9 +2434,8 @@ exit:
out->standby = true;
}
out_standby(&out->stream.common);
- usleep(bytes * 1000000 / audio_stream_out_frame_size(stream) /
+ usleep((uint64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
out_get_sample_rate(&out->stream.common));
-
}
return bytes;
}
@@ -2550,11 +2549,13 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
ret = 0;
}
}
+ } else if (adev->snd_card_status.state == SND_CARD_STATE_OFFLINE) {
+ *frames = out->written;
+ clock_gettime(CLOCK_MONOTONIC, timestamp);
+ ret = 0;
}
}
-
pthread_mutex_unlock(&out->lock);
-
return ret;
}
@@ -2864,7 +2865,7 @@ static ssize_t in_read(struct audio_stream_in *stream, void *buffer,
return bytes;
}
- if (in->pcm && (SND_CARD_STATE_OFFLINE == snd_scard_state)) {
+ if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
ALOGD(" %s: sound card is not active/SSR state", __func__);
ret= -EIO;;
goto exit;
@@ -2930,7 +2931,7 @@ exit:
memset(buffer, 0, bytes);
in_standby(&in->stream.common);
ALOGV("%s: read failed status %d- sleeping for buffer duration", __func__, ret);
- usleep(bytes * 1000000 / audio_stream_in_frame_size(stream) /
+ usleep((uint64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /
in_get_sample_rate(&in->stream.common));
}
return bytes;