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.
This commit is contained in:
parent
964de9fc7f
commit
933b8a7009
|
@ -967,6 +967,16 @@ void MainWindow::removeAllWidgets() {
|
||||||
deleteEventRoleWidget();
|
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() {
|
void MainWindow::onSinkTypeComboBoxChanged() {
|
||||||
showSinkType = (SinkType) sinkTypeComboBox->get_active_row_number();
|
showSinkType = (SinkType) sinkTypeComboBox->get_active_row_number();
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
|
|
||||||
void removeAllWidgets();
|
void removeAllWidgets();
|
||||||
|
|
||||||
|
void setConnectingMessage(const char *string = NULL);
|
||||||
|
|
||||||
Gtk::Notebook *notebook;
|
Gtk::Notebook *notebook;
|
||||||
Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
|
Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
|
||||||
Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel;
|
Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel;
|
||||||
|
|
|
@ -46,6 +46,7 @@ static pa_context* context = NULL;
|
||||||
static pa_mainloop_api* api = NULL;
|
static pa_mainloop_api* api = NULL;
|
||||||
static int n_outstanding = 0;
|
static int n_outstanding = 0;
|
||||||
static int default_tab = 0;
|
static int default_tab = 0;
|
||||||
|
static int reconnect_timeout = 1;
|
||||||
|
|
||||||
void show_error(const char *txt) {
|
void show_error(const char *txt) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
@ -399,6 +400,8 @@ void context_state_callback(pa_context *c, void *userdata) {
|
||||||
case PA_CONTEXT_READY: {
|
case PA_CONTEXT_READY: {
|
||||||
pa_operation *o;
|
pa_operation *o;
|
||||||
|
|
||||||
|
reconnect_timeout = 1;
|
||||||
|
|
||||||
/* Create event widget immediately so it's first in the list */
|
/* Create event widget immediately so it's first in the list */
|
||||||
w->createEventRoleWidget();
|
w->createEventRoleWidget();
|
||||||
|
|
||||||
|
@ -499,8 +502,6 @@ void context_state_callback(pa_context *c, void *userdata) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case PA_CONTEXT_FAILED:
|
case PA_CONTEXT_FAILED:
|
||||||
g_debug(_("Connection failed, attempting reconnect"));
|
|
||||||
|
|
||||||
w->setConnectionState(false);
|
w->setConnectionState(false);
|
||||||
|
|
||||||
w->removeAllWidgets();
|
w->removeAllWidgets();
|
||||||
|
@ -508,7 +509,10 @@ void context_state_callback(pa_context *c, void *userdata) {
|
||||||
pa_context_unref(context);
|
pa_context_unref(context);
|
||||||
context = NULL;
|
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;
|
return;
|
||||||
|
|
||||||
case PA_CONTEXT_TERMINATED:
|
case PA_CONTEXT_TERMINATED:
|
||||||
|
@ -541,10 +545,21 @@ gboolean connect_to_pulse(gpointer userdata) {
|
||||||
|
|
||||||
pa_context_set_state_callback(context, context_state_callback, w);
|
pa_context_set_state_callback(context, context_state_callback, w);
|
||||||
|
|
||||||
|
w->setConnectingMessage();
|
||||||
if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
|
if (pa_context_connect(context, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
|
||||||
show_error(_("Fatal Error: Unable to connect context"));
|
if (pa_context_errno(context) == PA_ERR_INVALID) {
|
||||||
Gtk::Main::quit();
|
w->setConnectingMessage(_("Connection to PulseAudio failed. Automatic retry in 5s\n\n"
|
||||||
return false;
|
"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;
|
return false;
|
||||||
|
@ -587,8 +602,12 @@ int main(int argc, char *argv[]) {
|
||||||
g_assert(api);
|
g_assert(api);
|
||||||
|
|
||||||
connect_to_pulse(mainWindow);
|
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;
|
delete mainWindow;
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
|
|
|
@ -1069,7 +1069,7 @@
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="connectingLabel">
|
<object class="GtkLabel" id="connectingLabel">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="label" translatable="yes"><i>Establishing connection to PulseAudio. Please wait...</i></property>
|
<property name="label" translatable="no">...</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
|
Loading…
Reference in New Issue