output/wasapi: use AUDCLNT_BUFFERFLAGS_SILENT for paused output

This commit is contained in:
Shen-Ta Hsieh 2021-03-04 18:09:56 +01:00 committed by Max Kellermann
parent dc9103befe
commit 0f39dc1edb

View File

@ -275,6 +275,7 @@ void WasapiOutputThread::Work() noexcept {
} }
BYTE *data; BYTE *data;
DWORD mode = 0;
result = render_client->GetBuffer(write_in_frames, &data); result = render_client->GetBuffer(write_in_frames, &data);
if (FAILED(result)) { if (FAILED(result)) {
@ -282,18 +283,20 @@ void WasapiOutputThread::Work() noexcept {
} }
AtScopeExit(&) { AtScopeExit(&) {
render_client->ReleaseBuffer(write_in_frames, 0); render_client->ReleaseBuffer(write_in_frames, mode);
}; };
if (current_state == Status::PLAY) {
const UINT32 write_size = write_in_frames * frame_size; const UINT32 write_size = write_in_frames * frame_size;
UINT32 new_data_size = 0; UINT32 new_data_size = 0;
if (current_state == Status::PLAY) {
new_data_size = spsc_buffer.pop(data, write_size); new_data_size = spsc_buffer.pop(data, write_size);
std::fill_n(data + new_data_size,
write_size - new_data_size, 0);
} else { } else {
mode = AUDCLNT_BUFFERFLAGS_SILENT;
FormatDebug(wasapi_output_domain, FormatDebug(wasapi_output_domain,
"Working thread paused"); "Working thread paused");
} }
std::fill_n(data + new_data_size, write_size - new_data_size, 0);
} catch (...) { } catch (...) {
std::unique_lock<Mutex> lock(error.mutex); std::unique_lock<Mutex> lock(error.mutex);
error.error_ptr = std::current_exception(); error.error_ptr = std::current_exception();