diff --git a/src/main.cpp b/src/main.cpp index d35af12..cef01ff 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) { bool printSource = false; bool printSink = false; - char* ignoredSourceOutputs[MAX_IGNORED_SOURCE_OUTPUTS]; + char* ignoredSourceOutputs[MAX_IGNORED_SOURCE_OUTPUTS] = {nullptr}; int ignoredSourceOutputsCount = 0; if (argc > 1) { diff --git a/src/pulse.cpp b/src/pulse.cpp index 9994550..2b0d93c 100644 --- a/src/pulse.cpp +++ b/src/pulse.cpp @@ -44,12 +44,17 @@ void Pulse::source_output_info_callback(pa_context *, if (i && i->proplist) { const char *appName = pa_proplist_gets(i->proplist, "application.name"); if (appName) { - int i = 0; - while (data->ignoredSourceOutputs[i] != nullptr) { - if (strcmp(appName, data->ignoredSourceOutputs[i]) == 0) { + int ignoredSourceOutputsCount = 0; + while ( + data->ignoredSourceOutputs[ignoredSourceOutputsCount] != nullptr + && ignoreSourceOutput == false + && ignoredSourceOutputsCount < MAX_IGNORED_SOURCE_OUTPUTS + ) { + if (strcmp(appName, data->ignoredSourceOutputs[ignoredSourceOutputsCount]) == 0) { ignoreSourceOutput = true; + break; } - i++; + ignoredSourceOutputsCount++; } } }