Skip to content

Commit

Permalink
Add logging to debug an edge-case
Browse files Browse the repository at this point in the history
  • Loading branch information
koteq authored Aug 25, 2024
1 parent 29057fb commit 188b8ab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Source/IconMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(
deviceManager.initialise(256, 256, savedAudioState.get(), true);
player.setProcessor(&graph);
deviceManager.addAudioCallback(&player);
deviceManager.addChangeListener(this);
// Plugins - all
std::unique_ptr<XmlElement> savedPluginList(getAppProperties().getUserSettings()->getXmlValue("pluginList"));
if (savedPluginList != nullptr)
Expand All @@ -87,7 +88,11 @@ IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(

IconMenu::~IconMenu()
{
knownPluginList.removeChangeListener(this);
activePluginList.removeChangeListener(this);
deviceManager.removeChangeListener(this);
savePluginStates();
shutdownAudio();
}

void IconMenu::setIcon()
Expand Down Expand Up @@ -215,6 +220,34 @@ void IconMenu::changeListenerCallback(ChangeBroadcaster* changed)
getAppProperties().saveIfNeeded();
}
}
else if (changed == &deviceManager)
{
dumpDeviceInfo();
}
}

void IconMenu::dumpDeviceInfo()
{
logger.logMessage ("--------------------------------------");
logger.logMessage ("Current audio device type: " + (deviceManager.getCurrentDeviceTypeObject() != nullptr
? deviceManager.getCurrentDeviceTypeObject()->getTypeName()
: "<none>"));

if (auto* device = deviceManager.getCurrentAudioDevice())
{
logger.logMessage ("Current audio device: " + device->getName().quoted());
logger.logMessage ("Sample rate: " + String (device->getCurrentSampleRate()) + " Hz");
logger.logMessage ("Block size: " + String (device->getCurrentBufferSizeSamples()) + " samples");
logger.logMessage ("Bit depth: " + String (device->getCurrentBitDepth()));
logger.logMessage ("Input channel names: " + device->getInputChannelNames().joinIntoString (", "));
logger.logMessage ("Active input channels: " + getListOfActiveBits (device->getActiveInputChannels()));
logger.logMessage ("Output channel names: " + device->getOutputChannelNames().joinIntoString (", "));
logger.logMessage ("Active output channels: " + getListOfActiveBits (device->getActiveOutputChannels()));
}
else
{
logger.logMessage ("No audio device open");
}
}

#if JUCE_MAC
Expand Down
1 change: 1 addition & 0 deletions Source/IconMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis
std::vector<PluginDescription> getTimeSortedList();
void setIcon();

std::unique_ptr<FileLogger> logger = FileLogger::createDefaultAppLogger("", "app.log", "LightHost logfile");
AudioDeviceManager deviceManager;
AudioPluginFormatManager formatManager;
KnownPluginList knownPluginList;
Expand Down

0 comments on commit 188b8ab

Please sign in to comment.