Skip to content

Commit e422cf4

Browse files
committed
Add logging into Audio thread initialization - to add more clarity into which audio device is tested and found
1 parent 0cd485a commit e422cf4

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/Qt/AudioPlaybackThread.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
#include "../AudioReaderSource.h"
2020
#include "../AudioDevices.h"
2121
#include "../Settings.h"
22+
#include "../ZmqLogger.h"
2223

2324
#include <mutex>
2425
#include <thread> // for std::this_thread::sleep_for
2526
#include <chrono> // for std::chrono::milliseconds
27+
#include <sstream>
2628

2729
using namespace juce;
2830

@@ -53,6 +55,12 @@ namespace openshot
5355
m_pInstance->currentAudioDevice.type = "";
5456
m_pInstance->defaultSampleRate = 0.0;
5557

58+
std::stringstream constructor_title;
59+
constructor_title << "AudioDeviceManagerSingleton::Instance (default audio device type: " <<
60+
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_TYPE << ", default audio device name: " <<
61+
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME << ")";
62+
ZmqLogger::Instance()->AppendDebugMethod(constructor_title.str(), "channels", channels);
63+
5664
// Get preferred audio device type and name (if any - these can be blank)
5765
openshot::AudioDeviceInfo requested_device = {Settings::Instance()->PLAYBACK_AUDIO_DEVICE_TYPE,
5866
Settings::Instance()->PLAYBACK_AUDIO_DEVICE_NAME};
@@ -102,6 +110,10 @@ namespace openshot
102110
// do not support 48000 causing no audio device to be found.
103111
int possible_rates[] { rate, 48000, 44100, 22050 };
104112
for(int attempt_rate : possible_rates) {
113+
std::stringstream title_rate;
114+
title_rate << "AudioDeviceManagerSingleton::Instance (attempt audio device name: " << attempt_device.name << ")";
115+
ZmqLogger::Instance()->AppendDebugMethod(title_rate.str(), "rate", attempt_rate, "channels", channels);
116+
105117
// Update the audio device setup for the current sample rate
106118
m_pInstance->defaultSampleRate = attempt_rate;
107119
deviceSetup.sampleRate = attempt_rate;
@@ -121,11 +133,22 @@ namespace openshot
121133
// Persist any errors detected
122134
m_pInstance->initialise_error = audio_error.toStdString();
123135

136+
if (!m_pInstance->initialise_error.empty()) {
137+
std::stringstream title_error;
138+
title_error << "AudioDeviceManagerSingleton::Instance (audio device error: " <<
139+
m_pInstance->initialise_error << ")";
140+
ZmqLogger::Instance()->AppendDebugMethod(title_error.str(), "rate", attempt_rate, "channels", channels);
141+
}
142+
124143
// Determine if audio device was opened successfully, and matches the attempted sample rate
125144
// If all rates fail to match, a default audio device and sample rate will be opened if possible
126145
foundAudioIODevice = m_pInstance->audioDeviceManager.getCurrentAudioDevice();
127146
if (foundAudioIODevice && foundAudioIODevice->getCurrentSampleRate() == attempt_rate) {
128147
// Successfully tested a sample rate
148+
std::stringstream title_found;
149+
title_found << "AudioDeviceManagerSingleton::Instance (successful audio device found: " <<
150+
foundAudioIODevice->getTypeName() << ", name: " << foundAudioIODevice->getName() << ")";
151+
ZmqLogger::Instance()->AppendDebugMethod(title_found.str(), "rate", attempt_rate, "channels", channels);
129152
break;
130153
}
131154
}
@@ -136,6 +159,7 @@ namespace openshot
136159
}
137160
}
138161

162+
ZmqLogger::Instance()->AppendDebugMethod("AudioDeviceManagerSingleton::Instance (audio device initialization completed)");
139163
}
140164
return m_pInstance;
141165
}

0 commit comments

Comments
 (0)