Loading media/libaaudio/src/client/AudioStreamInternalCapture.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -295,8 +295,10 @@ void *AudioStreamInternalCapture::callbackLoop() { if ((result != mCallbackFrames)) { ALOGE("callbackLoop: read() returned %d", result); if (result >= 0) { // Only read some of the frames requested. Must have timed out. result = AAUDIO_ERROR_TIMEOUT; // Only read some of the frames requested. The stream can be disconnected // or timed out. processCommands(); result = isDisconnected() ? AAUDIO_ERROR_DISCONNECTED : AAUDIO_ERROR_TIMEOUT; } maybeCallErrorCallback(result); break; Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -353,8 +353,10 @@ void *AudioStreamInternalPlay::callbackLoop() { result = write(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { if (result >= 0) { // Only wrote some of the frames requested. Must have timed out. result = AAUDIO_ERROR_TIMEOUT; // Only wrote some of the frames requested. The stream can be disconnected // or timed out. processCommands(); result = isDisconnected() ? AAUDIO_ERROR_DISCONNECTED : AAUDIO_ERROR_TIMEOUT; } maybeCallErrorCallback(result); break; Loading services/oboeservice/AAudioServiceEndpointMMAP.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -422,10 +422,17 @@ void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { // When there is a routing changed, mmap stream should be disconnected. Set `mConnected` // as false here so that there won't be a new stream connect to this endpoint. mConnected.store(false); const android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, deviceId]() { ALOGD("onRoutingChanged() asyncTask launched"); holdEndpoint->disconnectRegisteredStreams(); // When routing changed, the stream is disconnected and cannot be used except for // closing. In that case, it should be safe to release all registered streams. // This can help release service side resource in case the client doesn't close // the stream after receiving disconnect event. holdEndpoint->releaseRegisteredStreams(); holdEndpoint->setDeviceId(deviceId); }); asyncTask.detach(); Loading services/oboeservice/AAudioServiceEndpointShared.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -219,9 +219,13 @@ aaudio_result_t AAudioServiceEndpointShared::getTimestamp(int64_t *positionFrame void AAudioServiceEndpointShared::handleDisconnectRegisteredStreamsAsync() { android::sp<AAudioServiceEndpointShared> holdEndpoint(this); // When there is a routing changed, mmap stream should be disconnected. Set `mConnected` // as false here so that there won't be a new stream connect to this endpoint. mConnected.store(false); std::thread asyncTask([holdEndpoint]() { // We do not need the returned vector. holdEndpoint->disconnectRegisteredStreams(); // When handling disconnection, the service side has disconnected. In that case, // it should be safe to release all registered streams. holdEndpoint->releaseRegisteredStreams(); }); asyncTask.detach(); } Loading
media/libaaudio/src/client/AudioStreamInternalCapture.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -295,8 +295,10 @@ void *AudioStreamInternalCapture::callbackLoop() { if ((result != mCallbackFrames)) { ALOGE("callbackLoop: read() returned %d", result); if (result >= 0) { // Only read some of the frames requested. Must have timed out. result = AAUDIO_ERROR_TIMEOUT; // Only read some of the frames requested. The stream can be disconnected // or timed out. processCommands(); result = isDisconnected() ? AAUDIO_ERROR_DISCONNECTED : AAUDIO_ERROR_TIMEOUT; } maybeCallErrorCallback(result); break; Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +4 −2 Original line number Diff line number Diff line Loading @@ -353,8 +353,10 @@ void *AudioStreamInternalPlay::callbackLoop() { result = write(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { if (result >= 0) { // Only wrote some of the frames requested. Must have timed out. result = AAUDIO_ERROR_TIMEOUT; // Only wrote some of the frames requested. The stream can be disconnected // or timed out. processCommands(); result = isDisconnected() ? AAUDIO_ERROR_DISCONNECTED : AAUDIO_ERROR_TIMEOUT; } maybeCallErrorCallback(result); break; Loading
services/oboeservice/AAudioServiceEndpointMMAP.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -422,10 +422,17 @@ void AAudioServiceEndpointMMAP::onRoutingChanged(audio_port_handle_t portHandle) ALOGD("%s() called with dev %d, old = %d", __func__, deviceId, getDeviceId()); if (getDeviceId() != deviceId) { if (getDeviceId() != AUDIO_PORT_HANDLE_NONE) { // When there is a routing changed, mmap stream should be disconnected. Set `mConnected` // as false here so that there won't be a new stream connect to this endpoint. mConnected.store(false); const android::sp<AAudioServiceEndpointMMAP> holdEndpoint(this); std::thread asyncTask([holdEndpoint, deviceId]() { ALOGD("onRoutingChanged() asyncTask launched"); holdEndpoint->disconnectRegisteredStreams(); // When routing changed, the stream is disconnected and cannot be used except for // closing. In that case, it should be safe to release all registered streams. // This can help release service side resource in case the client doesn't close // the stream after receiving disconnect event. holdEndpoint->releaseRegisteredStreams(); holdEndpoint->setDeviceId(deviceId); }); asyncTask.detach(); Loading
services/oboeservice/AAudioServiceEndpointShared.cpp +6 −2 Original line number Diff line number Diff line Loading @@ -219,9 +219,13 @@ aaudio_result_t AAudioServiceEndpointShared::getTimestamp(int64_t *positionFrame void AAudioServiceEndpointShared::handleDisconnectRegisteredStreamsAsync() { android::sp<AAudioServiceEndpointShared> holdEndpoint(this); // When there is a routing changed, mmap stream should be disconnected. Set `mConnected` // as false here so that there won't be a new stream connect to this endpoint. mConnected.store(false); std::thread asyncTask([holdEndpoint]() { // We do not need the returned vector. holdEndpoint->disconnectRegisteredStreams(); // When handling disconnection, the service side has disconnected. In that case, // it should be safe to release all registered streams. holdEndpoint->releaseRegisteredStreams(); }); asyncTask.detach(); }