summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2023-05-04 18:58:13 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2023-05-08 21:20:20 +0000
commit8b9f1278b2c66f7ccec53578f4c81cef60e446b8 (patch)
treec5c5613cf743f9e9e267d98423da1b65014f5c0d
parentb75114983e85cef70da398c985e8ee7f8f68e3a1 (diff)
downloadgstreamer-8b9f1278b2c66f7ccec53578f4c81cef60e446b8.tar.gz
jack: tone down log ERRORs in case no JACK server is running
jackaudiosink and jackaudiosrc have a rank and might be plugged as part of auto-plugging inside playbin and playsink or the autoaudiosink/autoaudiosrc elements, so we don't really want to spew ERROR log messages in that case, which is consistent with what alsasink and pulseaudiosink do. This is less noticable on Linux because pulseaudiosink has a higher and alsasink which has the same rank comes before jack in the alphabet. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4545>
-rw-r--r--subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c50
1 files changed, 40 insertions, 10 deletions
diff --git a/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c b/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c
index ca3ff3d1ca..fad81b6139 100644
--- a/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c
+++ b/subprojects/gst-plugins-good/ext/jack/gstjackaudioclient.c
@@ -27,10 +27,31 @@
GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_client_debug);
#define GST_CAT_DEFAULT gst_jack_audio_client_debug
+/* List of threads who are trying to establish an initial server connection.
+ * Poor man's TLS. We don't really want to waste a TLS ID for this, and the
+ * error log callback code path should not be performance sensitive anyway. */
+G_LOCK_DEFINE_STATIC (startups_lock);
+static GList *startups;
+
static void
jack_log_error (const gchar * msg)
{
- GST_ERROR ("%s", msg);
+ gboolean starting_up;
+
+ G_LOCK (startups_lock);
+ starting_up = startups && g_list_find (startups, g_thread_self ()) != NULL;
+ G_UNLOCK (startups_lock);
+
+ /* Not being able to connect to a JACK server is completely normal in case
+ * jackaudiosink or jackaudiosrc are autoplugged, so we don't want to spew
+ * ERROR log messages in that case. On Linux this is rarely noticable because
+ * pulseaudiosink has a higher rank and is chosen first and alsa comes
+ * alphabetically before jack. */
+ if (starting_up) {
+ GST_WARNING ("%s", msg);
+ } else {
+ GST_ERROR ("%s", msg);
+ }
}
static void
@@ -502,16 +523,25 @@ gst_jack_audio_client_new (const gchar * id, const gchar * server,
JackBufferSizeCallback buffer_size, JackSampleRateCallback sample_rate,
gpointer user_data, jack_status_t * status)
{
- GstJackAudioClient *client;
+ GstJackAudioClient *client = NULL;
GstJackAudioConnection *conn;
g_return_val_if_fail (id != NULL, NULL);
g_return_val_if_fail (status != NULL, NULL);
+ /* So the error log callback knows that we're doing an initial connection
+ * attempt */
+ G_LOCK (startups_lock);
+ startups = g_list_prepend (startups, g_thread_self ());
+ G_UNLOCK (startups_lock);
+
/* first get a connection for the id/server pair */
conn = gst_jack_audio_get_connection (id, server, jclient, status);
- if (conn == NULL)
+
+ if (conn == NULL) {
+ GST_DEBUG ("Could not get server connection (%d)", *status);
goto no_connection;
+ }
GST_INFO ("new client %s", id);
@@ -530,14 +560,14 @@ gst_jack_audio_client_new (const gchar * id, const gchar * server,
/* add the client to the connection */
gst_jack_audio_connection_add_client (conn, client);
- return client;
-
- /* ERRORS */
no_connection:
- {
- GST_DEBUG ("Could not get server connection (%d)", *status);
- return NULL;
- }
+
+ /* done connecting */
+ G_LOCK (startups_lock);
+ startups = g_list_remove (startups, g_thread_self ());
+ G_UNLOCK (startups_lock);
+
+ return client;
}
/**