From b1a65c2a655b6ef60a92b82ef106a3ca19d0ea0d Mon Sep 17 00:00:00 2001 From: Marcin Paczkowski Date: Thu, 7 May 2020 17:02:46 -0700 Subject: [PATCH 1/2] servers: print "(default)" when booting with default devices --- server/scsynth/SC_PortAudio.cpp | 22 ++++++++++++++++------ server/supernova/server/main.cpp | 8 +++++--- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/server/scsynth/SC_PortAudio.cpp b/server/scsynth/SC_PortAudio.cpp index f338ce412c6..e4e3019c2c3 100644 --- a/server/scsynth/SC_PortAudio.cpp +++ b/server/scsynth/SC_PortAudio.cpp @@ -278,18 +278,28 @@ bool SC_PortAudioDriver::DriverSetup(int* outNumSamples, double* outSampleRate) pdi->maxInputChannels, pdi->maxOutputChannels); } - mDeviceInOut[0] = GetPaDeviceFromName(mWorld->hw->mInDeviceName, true); - mDeviceInOut[1] = GetPaDeviceFromName(mWorld->hw->mOutDeviceName, false); + auto m_inDeviceName = mWorld->hw->mInDeviceName; + auto m_outDeviceName = mWorld->hw->mOutDeviceName; + mDeviceInOut[0] = GetPaDeviceFromName(m_inDeviceName, true); + mDeviceInOut[1] = GetPaDeviceFromName(m_outDeviceName, false); // report requested devices fprintf(stdout, "\nRequested devices:\n"); if (mWorld->mNumInputs) { - fprintf(stdout, " In (matching device %sfound):\n - %s\n", (mDeviceInOut[0] == paNoDevice ? "NOT " : ""), - mWorld->hw->mInDeviceName); + auto nameIsEmpty = (m_inDeviceName && !m_inDeviceName[0]) || (m_inDeviceName == nullptr); + fprintf(stdout, " In%s:\n - %s\n", + nameIsEmpty + ? "" + : (mDeviceInOut[0] == paNoDevice ? " (matching device NOT found)" : " (matching device found)"), + (nameIsEmpty ? "(default)" : m_inDeviceName)); } if (mWorld->mNumOutputs) { - fprintf(stdout, " Out (matching device %sfound):\n - %s\n", (mDeviceInOut[1] == paNoDevice ? "NOT " : ""), - mWorld->hw->mOutDeviceName); + auto nameIsEmpty = (m_outDeviceName && !m_outDeviceName[0]) || (m_outDeviceName == nullptr); + fprintf(stdout, " Out%s:\n - %s\n", + nameIsEmpty + ? "" + : (mDeviceInOut[1] == paNoDevice ? " (matching device NOT found)" : " (matching device found)"), + (nameIsEmpty ? "(default)" : m_outDeviceName)); } fprintf(stdout, "\n"); diff --git a/server/supernova/server/main.cpp b/server/supernova/server/main.cpp index 0bf380202f9..5fdadba6323 100644 --- a/server/supernova/server/main.cpp +++ b/server/supernova/server/main.cpp @@ -172,9 +172,11 @@ void start_audio_backend(server_arguments const& args) { if (output_channels == 0) output_device.clear(); - std::cout << "Requested audio devices:\n"; - std::cout << " In: " << input_device << "\n"; - std::cout << " Out: " << output_device << std::endl; + std::cout << "Requested audio devices:" << std::endl; + if (input_channels) + std::cout << " In: " << (input_device.empty() ? "(default)" : input_device) << std::endl; + if (output_channels) + std::cout << " Out: " << (output_device.empty() ? "(default)" : output_device) << std::endl; bool success = instance->open_stream(input_device, input_channels, output_device, output_channels, args.samplerate, args.blocksize, args.hardware_buffer_size); From c72d944d5c7c75331afe87d132f8b4f80dd13c8e Mon Sep 17 00:00:00 2001 From: Marcin Paczkowski Date: Sat, 9 May 2020 15:49:26 -0700 Subject: [PATCH 2/2] Update SC_PortAudio.cpp --- server/scsynth/SC_PortAudio.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/scsynth/SC_PortAudio.cpp b/server/scsynth/SC_PortAudio.cpp index e4e3019c2c3..f42b24d563a 100644 --- a/server/scsynth/SC_PortAudio.cpp +++ b/server/scsynth/SC_PortAudio.cpp @@ -278,28 +278,28 @@ bool SC_PortAudioDriver::DriverSetup(int* outNumSamples, double* outSampleRate) pdi->maxInputChannels, pdi->maxOutputChannels); } - auto m_inDeviceName = mWorld->hw->mInDeviceName; - auto m_outDeviceName = mWorld->hw->mOutDeviceName; - mDeviceInOut[0] = GetPaDeviceFromName(m_inDeviceName, true); - mDeviceInOut[1] = GetPaDeviceFromName(m_outDeviceName, false); + auto* inDeviceName = mWorld->hw->mInDeviceName; + auto* outDeviceName = mWorld->hw->mOutDeviceName; + mDeviceInOut[0] = GetPaDeviceFromName(inDeviceName, true); + mDeviceInOut[1] = GetPaDeviceFromName(outDeviceName, false); // report requested devices fprintf(stdout, "\nRequested devices:\n"); if (mWorld->mNumInputs) { - auto nameIsEmpty = (m_inDeviceName && !m_inDeviceName[0]) || (m_inDeviceName == nullptr); + auto nameIsEmpty = (inDeviceName && !inDeviceName[0]) || (inDeviceName == nullptr); fprintf(stdout, " In%s:\n - %s\n", nameIsEmpty ? "" : (mDeviceInOut[0] == paNoDevice ? " (matching device NOT found)" : " (matching device found)"), - (nameIsEmpty ? "(default)" : m_inDeviceName)); + (nameIsEmpty ? "(default)" : inDeviceName)); } if (mWorld->mNumOutputs) { - auto nameIsEmpty = (m_outDeviceName && !m_outDeviceName[0]) || (m_outDeviceName == nullptr); + auto nameIsEmpty = (outDeviceName && !outDeviceName[0]) || (outDeviceName == nullptr); fprintf(stdout, " Out%s:\n - %s\n", nameIsEmpty ? "" : (mDeviceInOut[1] == paNoDevice ? " (matching device NOT found)" : " (matching device found)"), - (nameIsEmpty ? "(default)" : m_outDeviceName)); + (nameIsEmpty ? "(default)" : outDeviceName)); } fprintf(stdout, "\n");