diff options
author | John Lin <[email protected]> | 2024-06-20 19:23:37 -0700 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2024-07-08 18:08:38 +0200 |
commit | 063a090221250a5e7c6c61a3f94c95f60cfda722 (patch) | |
tree | c6b684af2ab5fee48fda6fe2be88e9f01d33f0b9 | |
parent | 0adfabf98d8ddfae46131aab0bea5399e1ea728a (diff) | |
download | cubeb-063a090221250a5e7c6c61a3f94c95f60cfda722.tar.gz cubeb-063a090221250a5e7c6c61a3f94c95f60cfda722.zip |
[AAudio] request pause rather than stop.
According to the document,
AAudioStream_requestStop():
"The stream will stop after all of the data currently buffered has been played."
AAudioStream_requestPause():
"Pausing a stream will freeze the data flow but not flush any buffers."
-rw-r--r-- | src/cubeb_aaudio.cpp | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/cubeb_aaudio.cpp b/src/cubeb_aaudio.cpp index 847b0c1..02b88a3 100644 --- a/src/cubeb_aaudio.cpp +++ b/src/cubeb_aaudio.cpp @@ -483,9 +483,7 @@ update_state(cubeb_stream * stm) } // handle invalid stream states - if (istate == AAUDIO_STREAM_STATE_PAUSING || - istate == AAUDIO_STREAM_STATE_PAUSED || - istate == AAUDIO_STREAM_STATE_FLUSHING || + if (istate == AAUDIO_STREAM_STATE_FLUSHING || istate == AAUDIO_STREAM_STATE_FLUSHED || istate == AAUDIO_STREAM_STATE_UNKNOWN || istate == AAUDIO_STREAM_STATE_DISCONNECTED) { @@ -495,9 +493,7 @@ update_state(cubeb_stream * stm) return; } - if (ostate == AAUDIO_STREAM_STATE_PAUSING || - ostate == AAUDIO_STREAM_STATE_PAUSED || - ostate == AAUDIO_STREAM_STATE_FLUSHING || + if (ostate == AAUDIO_STREAM_STATE_FLUSHING || ostate == AAUDIO_STREAM_STATE_FLUSHED || ostate == AAUDIO_STREAM_STATE_UNKNOWN || ostate == AAUDIO_STREAM_STATE_DISCONNECTED) { @@ -556,12 +552,12 @@ update_state(cubeb_stream * stm) } break; case stream_state::STOPPING: - assert(!istate || istate == AAUDIO_STREAM_STATE_STOPPING || - istate == AAUDIO_STREAM_STATE_STOPPED); - assert(!ostate || ostate == AAUDIO_STREAM_STATE_STOPPING || - ostate == AAUDIO_STREAM_STATE_STOPPED); - if ((!istate || istate == AAUDIO_STREAM_STATE_STOPPED) && - (!ostate || ostate == AAUDIO_STREAM_STATE_STOPPED)) { + assert(!istate || istate == AAUDIO_STREAM_STATE_PAUSING || + istate == AAUDIO_STREAM_STATE_PAUSED); + assert(!ostate || ostate == AAUDIO_STREAM_STATE_PAUSING || + ostate == AAUDIO_STREAM_STATE_PAUSED); + if ((!istate || istate == AAUDIO_STREAM_STATE_PAUSED) && + (!ostate || ostate == AAUDIO_STREAM_STATE_PAUSED)) { stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED); new_state = stream_state::STOPPED; } @@ -1593,16 +1589,16 @@ aaudio_stream_stop_locked(cubeb_stream * stm, lock_guard<mutex> & lock) aaudio_result_t res; - // No callbacks are triggered anymore when requestStop returns. + // No callbacks are triggered anymore when requestPause returns. // That is important as we otherwise might read from a closed istream // for a duplex stream. // Therefor it is important to close ostream first. if (stm->ostream) { // Could use pause + flush here as well, the public cubeb interface // doesn't state behavior. - res = WRAP(AAudioStream_requestStop)(stm->ostream); + res = WRAP(AAudioStream_requestPause)(stm->ostream); if (res != AAUDIO_OK) { - LOG("AAudioStream_requestStop (ostream): %s", + LOG("AAudioStream_requestPause (ostream): %s", WRAP(AAudio_convertResultToText)(res)); stm->state.store(stream_state::ERROR); return CUBEB_ERROR; @@ -1610,9 +1606,9 @@ aaudio_stream_stop_locked(cubeb_stream * stm, lock_guard<mutex> & lock) } if (stm->istream) { - res = WRAP(AAudioStream_requestStop)(stm->istream); + res = WRAP(AAudioStream_requestPause)(stm->istream); if (res != AAUDIO_OK) { - LOG("AAudioStream_requestStop (istream): %s", + LOG("AAudioStream_requestPause (istream): %s", WRAP(AAudio_convertResultToText)(res)); stm->state.store(stream_state::ERROR); return CUBEB_ERROR; |