Here is a patch to open a dialog at startup when there are errors with
sound.
It allows you to:
* Retry: so you can close applications or plug in your USB soundcard
* Reconfigure: in case you have a better sound card anway you lucky...
person
* Help: get it, and quick from the amazing Mixxx Wiki!
* Cancel: so you can swap in your neato PCI card (after rebooting of
course) or just get out without saving prefs
Yes... I just copied the text I posted to lp verbatim, so sue me!
I hope you all enjoy it though, and criticize it, etc...
and... Thanks to ironstorm for the first version of this patch.
That's all, Take care!
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-- C+++(++++)$ UL+++$ P+ L+++>++++ E W++ N o?
K- w++(---) O? M-- V PS+++ PE-(--) Y+(++) PGP t(+) 5(+) X++
R b+>++ DI+ D+ G e h-(--) r y+
------END GEEK CODE BLOCK------
=== modified file 'mixxx/src/mixxx.cpp'
--- mixxx/src/mixxx.cpp 2009-05-03 02:34:18 +0000
+++ mixxx/src/mixxx.cpp 2009-07-23 21:12:27 +0000
@@ -284,20 +284,17 @@
#endif
// Try open player device If that fails, the preference panel is opened.
- if (soundmanager->setupDevices() != 0)
+ while (soundmanager->setupDevices() != 0)
{
#ifdef __C_METRICS__
- cm_writemsg_ascii(MIXXXCMETRICS_FAILED_TO_OPEN_SNDDEVICE_AT_STARTUP,
- "Mixxx failed to open audio device(s) on startup.");
+ cm_writemsg_ascii(MIXXXCMETRICS_FAILED_TO_OPEN_SNDDEVICE_AT_STARTUP,
+ "Mixxx failed to open audio device(s) on startup.");
#endif
- QMessageBox::warning(this, tr("Mixxx"),
- tr("Failed to open your audio device(s).\n"
- "Please verify your selection in the preferences."),
- QMessageBox::Ok,
- QMessageBox::Ok);
- prefDlg->show();
+ // Exit when we press Cancel on the noSoundDlg dialog
+ if ( noSoundDlg() != 0 )
+ exit(0);
}
//setFocusPolicy(QWidget::StrongFocus);
@@ -425,6 +422,54 @@
//#endif
}
+int MixxxApp::noSoundDlg(void)
+{
+ int reconf = 0;
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("Sound Device Busy");
+ msgBox.setText( "<html>Mixxx was unable to bind to <b><i>" +
+ config->getValueString(ConfigKey("[Soundcard]", "DeviceMaster")) +
+ "</i></b> at start-up, this could be because another application is using the "+
+ "sound device or the device is not plugged in (USB sound cards), would you "+
+ "like Mixxx to:<ul>"+
+ "<li><b>Retry</b> after you have closed the other application or reconnected the sound device."+
+ "<li><b>Reconfigure</b> Mixxx's hardware prefs to use a different sound card device for output."+
+ "<li>Get <b>Help</b> from the Mixxx Wiki and possibly get more info about this problem."+
+ "<li><b>Cancel</b> now to exit Mixxx without touching your settings"+
+ "</ul></html>");
+
+ QPushButton *retryButton = msgBox.addButton(tr("Retry"), QMessageBox::ActionRole);
+ QPushButton *reconfigureButton = msgBox.addButton(tr("Reconfigure"), QMessageBox::ActionRole);
+ QPushButton *wikiButton = msgBox.addButton(tr("Help"), QMessageBox::ActionRole);
+ QPushButton *cancelButton = msgBox.addButton(tr("Cancel"), QMessageBox::ActionRole);
+
+ while(1)
+ {
+ msgBox.exec();
+
+ if (msgBox.clickedButton() == retryButton) {
+ soundmanager->queryDevices();
+ return 0;
+ } else if (msgBox.clickedButton() == wikiButton) {
+ QDesktopServices::openUrl(QUrl("http://mixxx.org/wiki/doku.php/troubleshooting#Sound_Device_Busy"));
+ wikiButton->setEnabled(false);
+ } else if (msgBox.clickedButton() == reconfigureButton) {
+ msgBox.hide();
+ msgBox.setWindowModality(Qt::NonModal);
+ msgBox.show();
+
+ soundmanager->queryDevices();
+
+ prefDlg->setWindowModality(Qt::ApplicationModal);
+ prefDlg->show();
+
+ } else if (msgBox.clickedButton() == cancelButton) {
+ return 1;
+ }
+ }
+}
+
+
/** initializes all QActions of the application */
void MixxxApp::initActions()
{
=== modified file 'mixxx/src/mixxx.h'
--- mixxx/src/mixxx.h 2009-04-10 20:33:42 +0000
+++ mixxx/src/mixxx.h 2009-07-23 08:24:17 +0000
@@ -236,6 +236,7 @@
DlgLADSPA *ladspaDlg;
#endif
+ int noSoundDlg(void);
// Fullscreen patch
QPoint winpos;
};
=== modified file 'mixxx/src/soundmanager.cpp'
--- mixxx/src/soundmanager.cpp 2009-07-19 17:14:02 +0000
+++ mixxx/src/soundmanager.cpp 2009-07-23 21:10:48 +0000
@@ -86,14 +86,6 @@
m_samplerates.push_back("44100");
m_samplerates.push_back("48000");
m_samplerates.push_back("96000");
-
-#ifdef __PORTAUDIO__
- PaError err = Pa_Initialize();
- if (err != paNoError)
- {
- qDebug() << "Error:" << Pa_GetErrorText(err);
- }
-#endif
}
/** Destructor for the SoundManager class. Closes all the devices, cleans up their pointers
@@ -254,6 +246,10 @@
SoundDevice* dev = m_devices.takeLast();
delete dev;
}
+
+#ifdef __PORTAUDIO__
+ Pa_Terminate();
+#endif
}
/** Returns a list of samplerates we will attempt to support.
@@ -271,6 +267,13 @@
clearDeviceList();
#ifdef __PORTAUDIO__
+ PaError err = Pa_Initialize();
+ if (err != paNoError)
+ {
+ qDebug() << "Error:" << Pa_GetErrorText(err);
+ return;
+ }
+
int iNumDevices;
iNumDevices = Pa_GetDeviceCount();
if(iNumDevices < 0)
------------------------------------------------------------------------------
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel