src/output: Reopen device on error

This commit is contained in:
Shen-Ta Hsieh 2020-12-02 07:57:05 +08:00 committed by Max Kellermann
parent 844dbd2ec5
commit c46f97454a

View File

@ -333,6 +333,15 @@ void WasapiOutput::DoOpen(AudioFormat &audio_format) {
client.reset(); client.reset();
DWORD state;
if (HRESULT result = device->GetState(&state); FAILED(result)) {
throw FormatHResultError(result, "Unable to get device status");
}
if (state != DEVICE_STATE_ACTIVE) {
device.reset();
OpenDevice();
}
HRESULT result; HRESULT result;
result = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr, result = device->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr,
client.AddressCast()); client.AddressCast());