From 0caa5ea1e19b36ce1a4ebdc35a76db72c33e4cf6 Mon Sep 17 00:00:00 2001 From: David Freese Date: Sat, 19 Sep 2015 06:32:36 -0500 Subject: [PATCH] PA debug --- src/include/soundconf.h | 2 ++ src/main.cxx | 3 +++ src/misc/debug.cxx | 8 +++++--- src/soundcard/soundconf.cxx | 27 ++++++++++++++++++--------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/include/soundconf.h b/src/include/soundconf.h index d0459649..fa8d957e 100644 --- a/src/include/soundconf.h +++ b/src/include/soundconf.h @@ -48,7 +48,9 @@ void sound_close(void); void sound_update(unsigned idx); #include + class Fl_Choice; int pa_set_dev(Fl_Choice *choice, std::string dev_name, int dev_index); +extern std::string str_pa_devices; #endif // SOUNDCONF_H diff --git a/src/main.cxx b/src/main.cxx index 4367b8ae..0aead6ac 100644 --- a/src/main.cxx +++ b/src/main.cxx @@ -351,6 +351,9 @@ void delayed_startup(void *) if (progdefaults.check_for_updates) cb_mnuCheckUpdate((Fl_Widget *)0, NULL); +#if USE_PORTAUDIO + LOG_INFO("%s", str_pa_devices.c_str()); +#endif } int main(int argc, char ** argv) diff --git a/src/misc/debug.cxx b/src/misc/debug.cxx index 3020b604..d8faed84 100644 --- a/src/misc/debug.cxx +++ b/src/misc/debug.cxx @@ -135,7 +135,7 @@ void debug::start(const char* filename) rotate_log(filename); inst = new debug(filename); - window = new Fl_Double_Window(600, 200, _("Event log")); + window = new Fl_Double_Window(800, 400, _("Event log")); window->xclass(PACKAGE_TARNAME); int pad = 2; @@ -266,6 +266,7 @@ void debug::elog(const char* func, const char* srcf, int line, const char* text) void debug::show(void) { + btext->bottomline(btext->size()); window->show(); } @@ -290,8 +291,9 @@ void debug::sync_text(void* arg) linebuf += '\n'; size_t p1 = 0, p2 = linebuf.find("\n"); while( p2 != string::npos) { - btext->insert(1, linebuf.substr(p1, p2 - p1).c_str()); - dbg_buffer.append(linebuf.substr(p1, p2 - p1)).append("\n"); + btext->add(linebuf.substr(p1, p2 - p1).c_str()); + btext->redraw(); + dbg_buffer.append(linebuf.substr(p1, p2 - p1 + 1));//.append("\n"); p1 = p2 + 1; p2 = linebuf.find("\n", p1); } diff --git a/src/soundcard/soundconf.cxx b/src/soundcard/soundconf.cxx index f43d4948..850aea38 100644 --- a/src/soundcard/soundconf.cxx +++ b/src/soundcard/soundconf.cxx @@ -118,15 +118,18 @@ ret_def: #include +std::string str_pa_devices; + static void init_portaudio(void) { try { SoundPort::initialize(); } catch (const SndException& e) { - if (e.error() == ENODEV) // don't complain if there are no devices - return; - LOG_ERROR("%s", e.what()); +// if (e.error() == ENODEV) // don't complain if there are no devices +// return; + str_pa_devices.assign("\nPortaudio devices init failure:"); + str_pa_devices.assign(e.what()); AudioPort->deactivate(); btnAudioIO[SND_IDX_PORT]->deactivate(); if (progdefaults.btnAudioIOis == SND_IDX_PORT) @@ -150,12 +153,16 @@ static void init_portaudio(void) #endif list devlist; + int devnbr = 0; for (SoundPort::device_iterator idev = SoundPort::devices().begin(); - idev != SoundPort::devices().end(); ++idev) + idev != SoundPort::devices().end(); ++idev) { devlist.push_back( padev(*idev, idev - SoundPort::devices().begin(), Pa_GetHostApiInfo((*idev)->hostApi)->type) ); + devnbr++; + } devlist.sort(); + str_pa_devices.assign("\nPortaudio devices:\n"); PaHostApiTypeId first_api = devlist.begin()->api; for (list::const_iterator ilist = devlist.begin(); ilist != devlist.end(); ilist++) { @@ -166,22 +173,24 @@ static void init_portaudio(void) i = menu_item.length(); } menu_item.append(ilist->dev->name); + + str_pa_devices.append(menu_item).append("\n"); + // backslash-escape any slashes in the device name while ((i = menu_item.find('/', i)) != string::npos) { menu_item.insert(i, 1, '\\'); i += 2; } + // add to menu - if (ilist->dev->maxInputChannels > 0) { + if (ilist->dev->maxInputChannels > 0) menuPortInDev->add(menu_item.c_str(), 0, NULL, reinterpret_cast(ilist->idx), 0); - } - if (ilist->dev->maxOutputChannels > 0) { + if (ilist->dev->maxOutputChannels > 0) menuPortOutDev->add(menu_item.c_str(), 0, NULL, reinterpret_cast(ilist->idx), 0); -LOG_INFO("%s", menu_item.c_str()); - } + } if (progdefaults.PortInDevice.length() == 0) {