Skip to content

Commit

Permalink
wasapi: Flag cubeb_stream as inactive when stopped, avoid reconfiguri…
Browse files Browse the repository at this point in the history
…ng inactive streams from render thread.
  • Loading branch information
kinetiknz committed Jul 26, 2023
1 parent 4c6c317 commit 28d360d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cubeb_wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ struct cubeb_stream {
* called and the render loop thread has exited, destroy this stream object.
*/
LONG ref_count = 0;

/* True if the stream is active, false if inactive. */
bool active = false;
};

class monitor_device_notifications {
Expand Down Expand Up @@ -1420,6 +1423,11 @@ static unsigned int __stdcall wasapi_stream_render_loop(LPVOID stream)
}
case WAIT_OBJECT_0 + 1: { /* reconfigure */
auto_lock lock(stm->stream_reset_lock);
if (!stm->active) {
/* Avoid reconfiguring, stream start will handle it. */
LOG("Stream is not active, ignoring reconfigure.");
continue;
}
XASSERT(stm->output_client || stm->input_client);
LOG("Reconfiguring the stream");
/* Close the stream */
Expand Down Expand Up @@ -2985,6 +2993,8 @@ wasapi_stream_start(cubeb_stream * stm)
}
}

stm->active = true;

stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_STARTED);

return CUBEB_OK;
Expand Down Expand Up @@ -3015,6 +3025,8 @@ wasapi_stream_stop(cubeb_stream * stm)
}
}

stm->active = false;

wasapi_state_callback(stm, stm->user_ptr, CUBEB_STATE_STOPPED);
}

Expand Down

0 comments on commit 28d360d

Please sign in to comment.