瀏覽代碼

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.
jp9000 10 年之前
父節點
當前提交
1143b1d631
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      plugins/win-wasapi/win-wasapi.cpp

+ 8 - 0
plugins/win-wasapi/win-wasapi.cpp

@@ -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;
 }