win-wasapi: Prevent repeating connect fail message

Fixes an issue where if the device can't be connected, it will
continually repeat the connection failure message.
This commit is contained in:
jp9000
2015-04-09 08:48:27 -07:00
parent f3069e3ea5
commit 1143b1d631

View File

@@ -31,6 +31,7 @@ class WASAPISource {
bool isDefaultDevice = false;
bool reconnecting = false;
bool previouslyFailed = false;
WinHandle reconnectThread;
bool active = false;
@@ -271,18 +272,25 @@ bool WASAPISource::TryInitialize()
Initialize();
} catch (HRError error) {
if (previouslyFailed)
return active;
blog(LOG_WARNING, "[WASAPISource::TryInitialize]:[%s] %s: %lX",
device_name.empty() ?
device_id.c_str() : device_name.c_str(),
error.str, error.hr);
} catch (const char *error) {
if (previouslyFailed)
return active;
blog(LOG_WARNING, "[WASAPISource::TryInitialize]:[%s] %s",
device_name.empty() ?
device_id.c_str() : device_name.c_str(),
error);
}
previouslyFailed = !active;
return active;
}