From 10f3bc43976942abef7ea59a89d94cb63a074af9 Mon Sep 17 00:00:00 2001 From: casey langen Date: Tue, 7 Apr 2020 15:33:26 -0700 Subject: [PATCH] Additional logging for PulseOut --- src/plugins/pulseout/PulseOut.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/pulseout/PulseOut.cpp b/src/plugins/pulseout/PulseOut.cpp index f2ad8d215..6f3ccb8dd 100755 --- a/src/plugins/pulseout/PulseOut.cpp +++ b/src/plugins/pulseout/PulseOut.cpp @@ -242,6 +242,7 @@ void PulseOut::OpenDevice(musik::core::sdk::IBuffer* buffer) { this->rate != buffer->SampleRate() || this->channels != buffer->Channels()) { + int errorCode = 0; this->CloseDevice(); pa_sample_spec spec; @@ -249,9 +250,8 @@ void PulseOut::OpenDevice(musik::core::sdk::IBuffer* buffer) { spec.channels = buffer->Channels(); spec.rate = buffer->SampleRate(); - std::cerr << "PulseOut: opening device\n"; - std::string deviceId = this->GetPreferredDeviceId(); + std::cerr << "PulseOut: opening device: " << deviceId << "\n"; /* output to preferred device id, as specified in prefs */ this->audioConnection = pa_blocking_new( @@ -263,7 +263,11 @@ void PulseOut::OpenDevice(musik::core::sdk::IBuffer* buffer) { &spec, nullptr, nullptr, - 0); + &errorCode); + + if (!this->audioConnection) { + std::cerr << "PulseOut: failed to open device. errorCode=" << errorCode << "\n"; + } if (!this->audioConnection && deviceId.size()) { /* fall back to default if preferred is not found */ @@ -276,7 +280,11 @@ void PulseOut::OpenDevice(musik::core::sdk::IBuffer* buffer) { &spec, nullptr, nullptr, - 0); + &errorCode); + + if (!this->audioConnection) { + std::cerr << "PulseOut: failed to open default device. errorCode=" << errorCode << "\n"; + } } if (this->audioConnection) {