Separate mDisconnected from mState.
The DISCONNECTED state was preventing the pause and stop
from finishing. The DISCONNECTED status is really orthogonal
to the other states like STARTED and STOPPED and needs to
be tracked separately.
Bug: 214607638
Test: atest AAudioTests
Test: TEST DISCONNECT from OboeTester
Change-Id: Ie49c1d2ee95db2bbd4285b8d003aae24e1b6e48c
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index f32ef65..8595308 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -85,7 +85,7 @@
// AudioRecord::Buffer
// TODO define our own AudioBuffer and pass it from the subclasses.
size_t written = buffer.size();
- if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED) {
+ if (isDisconnected()) {
ALOGW("%s() data, stream disconnected", __func__);
// This will kill the stream and prevent it from being restarted.
// That is OK because the stream is disconnected.
@@ -150,7 +150,7 @@
// AudioRecord::Buffer
// TODO define our own AudioBuffer and pass it from the subclasses.
size_t written = buffer.size();
- if (getState() == AAUDIO_STREAM_STATE_DISCONNECTED) {
+ if (isDisconnected()) {
ALOGW("%s() data, stream disconnected", __func__);
// This will kill the stream and prevent it from being restarted.
// That is OK because the stream is disconnected.
@@ -214,11 +214,11 @@
void AudioStreamLegacy::forceDisconnect(bool errorCallbackEnabled) {
// There is no need to disconnect if already in these states.
- if (getState() != AAUDIO_STREAM_STATE_DISCONNECTED
+ if (!isDisconnected()
&& getState() != AAUDIO_STREAM_STATE_CLOSING
&& getState() != AAUDIO_STREAM_STATE_CLOSED
) {
- setState(AAUDIO_STREAM_STATE_DISCONNECTED);
+ setDisconnected();
if (errorCallbackEnabled) {
maybeCallErrorCallback(AAUDIO_ERROR_DISCONNECTED);
}
@@ -268,7 +268,7 @@
ALOGD("%s(deviceId = %d)", __func__, (int)deviceId);
if (getDeviceId() != AAUDIO_UNSPECIFIED
&& getDeviceId() != deviceId
- && getState() != AAUDIO_STREAM_STATE_DISCONNECTED
+ && !isDisconnected()
) {
// Note that isDataCallbackActive() is affected by state so call it before DISCONNECTING.
// If we have a data callback and the stream is active, then ask the data callback