[Spice-devel] [spice-gtk v2 3/3] gstaudio: rely on SpiceSession init of GStreamer
Victor Toso
victortoso at redhat.com
Mon Sep 9 10:29:49 UTC 2019
From: Victor Toso <me at victortoso.com>
This means we can drop gst_init_check() function and replace its calls
with gst_is_initialized().
A small code refactor was done in spice_gstaudio_new() to make an
early return on error. The previous warning around GStreamer not being
initialized was demoted to a debug message as the warning should be
issued in SpiceSession initialization.
Signed-off-by: Victor Toso <victortoso at redhat.com>
---
src/spice-gstaudio.c | 59 ++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 32 deletions(-)
diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index 4dd3d81..517d612 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -552,45 +552,40 @@ static gboolean connect_channel(SpiceAudio *audio, SpiceChannel *channel)
SpiceGstaudio *spice_gstaudio_new(SpiceSession *session, GMainContext *context,
const char *name)
{
- GError *err = NULL;
-
- if (gst_init_check(NULL, NULL, &err)) {
- GstPluginFeature *pulsesrc;
-
- pulsesrc = gst_registry_lookup_feature(gst_registry_get(), "pulsesrc");
- if (pulsesrc) {
- unsigned major, minor, micro;
- GstPlugin *plugin = gst_plugin_feature_get_plugin(pulsesrc);
-
- if (sscanf(gst_plugin_get_version(plugin), "%u.%u.%u",
- &major, &minor, µ) != 3) {
- g_warn_if_reached();
- gst_object_unref(plugin);
- gst_object_unref(pulsesrc);
- return NULL;
- }
-
- if (major < 1 ||
- (major == 1 && minor < 14) ||
- (major == 1 && minor == 14 && micro < 5)) {
- g_warning("Bad pulsesrc version %s, lowering its rank",
- gst_plugin_get_version(plugin));
- gst_plugin_feature_set_rank(pulsesrc, GST_RANK_NONE);
- }
+ if (!gst_is_initialized()) {
+ spice_debug("GStreamer is not initialized: disabling GStreamer audio support");
+ return NULL;
+ }
+
+ GstPluginFeature *pulsesrc = gst_registry_lookup_feature(gst_registry_get(), "pulsesrc");
+ if (pulsesrc) {
+ unsigned major, minor, micro;
+ GstPlugin *plugin = gst_plugin_feature_get_plugin(pulsesrc);
+ if (sscanf(gst_plugin_get_version(plugin), "%u.%u.%u",
+ &major, &minor, µ) != 3) {
+ g_warn_if_reached();
gst_object_unref(plugin);
gst_object_unref(pulsesrc);
+ return NULL;
+ }
+
+ if (major < 1 ||
+ (major == 1 && minor < 14) ||
+ (major == 1 && minor == 14 && micro < 5)) {
+ g_warning("Bad pulsesrc version %s, lowering its rank",
+ gst_plugin_get_version(plugin));
+ gst_plugin_feature_set_rank(pulsesrc, GST_RANK_NONE);
}
- return g_object_new(SPICE_TYPE_GSTAUDIO,
- "session", session,
- "main-context", context,
- NULL);
+ gst_object_unref(plugin);
+ gst_object_unref(pulsesrc);
}
- g_warning("Disabling GStreamer audio support: %s", err->message);
- g_clear_error(&err);
- return NULL;
+ return g_object_new(SPICE_TYPE_GSTAUDIO,
+ "session", session,
+ "main-context", context,
+ NULL);
}
static void spice_gstaudio_get_playback_volume_info_async(SpiceAudio *audio,
--
2.21.0
More information about the Spice-devel
mailing list