summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2011-06-06 11:28:45 +0200
committerColin Guthrie <colin@mageia.org>2011-06-06 12:18:06 +0200
commit933b8a7009f72bccb378ed018a6578ccd443e748 (patch)
treeefe7da80b95e9b4099bee6cebdf085003fc3170e
parent964de9fc7f6261a5f81ff3819d2be9fefd210106 (diff)
Deal more gracefully with disconnections.
As pavucontrol is often used for debugging PA, it should be quite robust and not popup messages etc. under 'normal' testing conditions. This adds quite a verbose message under some specific conditions that do crop up from time to time.
-rw-r--r--src/mainwindow.cc10
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/pavucontrol.cc33
-rw-r--r--src/pavucontrol.glade2
4 files changed, 39 insertions, 8 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index 6d629ad..6a7e04c 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -967,6 +967,16 @@ void MainWindow::removeAllWidgets() {
deleteEventRoleWidget();
}
+void MainWindow::setConnectingMessage(const char *string) {
+ Glib::ustring markup = "<i>";
+ if (!string)
+ markup += _("Establishing connection to PulseAudio. Please wait...");
+ else
+ markup += string;
+ markup += "</i>";
+ connectingLabel->set_markup(markup);
+}
+
void MainWindow::onSinkTypeComboBoxChanged() {
showSinkType = (SinkType) sinkTypeComboBox->get_active_row_number();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 87a0898..bad9e47 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -57,6 +57,8 @@ public:
void removeAllWidgets();
+ void setConnectingMessage(const char *string = NULL);
+
Gtk::Notebook *notebook;
Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel;
diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index aa71b3e..4270fa7 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -46,6 +46,7 @@ static pa_context* context = NULL;
static pa_mainloop_api* api = NULL;
static int n_outstanding = 0;
static int default_tab = 0;
+static int reconnect_timeout = 1;
void show_error(const char *txt) {
char buf[256];
@@ -399,6 +400,8 @@ void context_state_callback(pa_context *c, void *userdata) {
case PA_CONTEXT_READY: {
pa_operation *o;
+ reconnect_timeout = 1;
+
/* Create event widget immediately so it's first in the list */
w->createEventRoleWidget();
@@ -499,8 +502,6 @@ void context_state_callback(pa_context *c, void *userdata) {
}
case PA_CONTEXT_FAILED:
- g_debug(_("Connection failed, attempting reconnect"));
-
w->setConnectionState(false);
w->removeAllWidgets();
@@ -508,7 +509,10 @@ void context_state_callback(pa_context *c, void *userdata) {
pa_context_unref(context);
context = NULL;
- g_timeout_add_seconds(1, connect_to_pulse, w);
+ if (reconnect_timeout > 0) {
+ g_debug(_("Connection failed, attempting reconnect"));
+ g_timeout_add_seconds(reconnect_timeout, connect_to_pulse, w);
+ }
return;
case PA_CONTEXT_TERMINATED:
@@ -541,10 +545,21 @@ gboolean connect_to_pulse(gpointer userdata) {
pa_context_set_state_callback(context, context_state_callback, w);
+ w->setConnectingMessage();
if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
- show_error(_("Fatal Error: Unable to connect context"));
- Gtk::Main::quit();
- return false;
+ if (pa_context_errno(context) == PA_ERR_INVALID) {
+ w->setConnectingMessage(_("Connection to PulseAudio failed. Automatic retry in 5s\n\n"
+ "In this case this is likely because PULSE_SERVER in the Environment/X11 Root Window Properties\n"
+ "or default-server in client.conf is misconfigured.\n"
+ "This situation can also arrise when PulseAudio crashed and left stale details in the X11 Root Window.\n"
+ "If this is the case, then PulseAudio should autospawn again, or if this is not configured you should\n"
+ "run start-pulseaudio-x11 manually."));
+ reconnect_timeout = 5;
+ }
+ else {
+ reconnect_timeout = -1;
+ Gtk::Main::quit();
+ }
}
return false;
@@ -587,8 +602,12 @@ int main(int argc, char *argv[]) {
g_assert(api);
connect_to_pulse(mainWindow);
+ if (reconnect_timeout >= 0)
+ Gtk::Main::run(*mainWindow);
+
+ if (reconnect_timeout < 0)
+ show_error(_("Fatal Error: Unable to connect to PulseAudio"));
- Gtk::Main::run(*mainWindow);
delete mainWindow;
if (context)
diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade
index 3077a88..2e7afe8 100644
--- a/src/pavucontrol.glade
+++ b/src/pavucontrol.glade
@@ -1069,7 +1069,7 @@
<child>
<object class="GtkLabel" id="connectingLabel">
<property name="can_focus">False</property>
- <property name="label" translatable="yes">&lt;i&gt;Establishing connection to PulseAudio. Please wait...&lt;/i&gt;</property>
+ <property name="label" translatable="no">...</property>
<property name="use_markup">True</property>
</object>
<packing>