mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
gst/autodetect/gstautoaudiosink.c: Get rid of old and unused magic sound-server properties stuff.
Original commit message from CVS: * gst/autodetect/gstautoaudiosink.c: (gst_auto_audio_sink_create_element_with_pretty_name), (gst_auto_audio_sink_find_best), (gst_auto_audio_sink_change_state): Get rid of old and unused magic sound-server properties stuff. Add suffix to child sink's name that makes it easy to see from the name alone which type it actually is (alsa, oss, esd, etc.).
This commit is contained in:
parent
538e3ef600
commit
e83ba9fb70
2 changed files with 63 additions and 66 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-07-27 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* gst/autodetect/gstautoaudiosink.c:
|
||||||
|
(gst_auto_audio_sink_create_element_with_pretty_name),
|
||||||
|
(gst_auto_audio_sink_find_best),
|
||||||
|
(gst_auto_audio_sink_change_state):
|
||||||
|
Get rid of old and unused magic sound-server properties stuff.
|
||||||
|
Add suffix to child sink's name that makes it easy to see from
|
||||||
|
the name alone which type it actually is (alsa, oss, esd, etc.).
|
||||||
|
|
||||||
2006-07-27 Wim Taymans <wim@fluendo.com>
|
2006-07-27 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/udp/gstudpsrc.c: (gst_udpsrc_class_init), (gst_udpsrc_init),
|
* gst/udp/gstudpsrc.c: (gst_udpsrc_class_init), (gst_udpsrc_init),
|
||||||
|
|
|
@ -150,91 +150,77 @@ gst_auto_audio_sink_compare_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
|
||||||
gst_plugin_feature_get_name (f1));
|
gst_plugin_feature_get_name (f1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstElement *
|
||||||
|
gst_auto_audio_sink_create_element_with_pretty_name (GstAutoAudioSink * sink,
|
||||||
|
GstElementFactory * factory)
|
||||||
|
{
|
||||||
|
GstElement *element;
|
||||||
|
gchar *name, *marker;
|
||||||
|
|
||||||
|
marker = g_strdup (GST_PLUGIN_FEATURE (factory)->name);
|
||||||
|
if (g_str_has_suffix (marker, "sink"))
|
||||||
|
marker[strlen (marker) - 4] = '\0';
|
||||||
|
if (g_str_has_prefix (marker, "gst"))
|
||||||
|
g_memmove (marker, marker + 3, strlen (marker + 3) + 1);
|
||||||
|
name = g_strdup_printf ("%s-actual-sink-%s", GST_OBJECT_NAME (sink), marker);
|
||||||
|
g_free (marker);
|
||||||
|
|
||||||
|
element = gst_element_factory_create (factory, name);
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
|
gst_auto_audio_sink_find_best (GstAutoAudioSink * sink)
|
||||||
{
|
{
|
||||||
GList *list, *item;
|
GList *list, *item;
|
||||||
GstElement *choice = NULL;
|
GstElement *choice = NULL;
|
||||||
gboolean ss = TRUE;
|
|
||||||
GstMessage *message = NULL;
|
GstMessage *message = NULL;
|
||||||
GSList *errors = NULL;
|
GSList *errors = NULL;
|
||||||
GstBus *bus = gst_bus_new ();
|
GstBus *bus = gst_bus_new ();
|
||||||
gchar *child_name = g_strdup_printf ("%s-actual-sink",
|
|
||||||
GST_OBJECT_NAME (sink));
|
|
||||||
|
|
||||||
list = gst_registry_feature_filter (gst_registry_get_default (),
|
list = gst_registry_feature_filter (gst_registry_get_default (),
|
||||||
(GstPluginFeatureFilter) gst_auto_audio_sink_factory_filter, FALSE, sink);
|
(GstPluginFeatureFilter) gst_auto_audio_sink_factory_filter, FALSE, sink);
|
||||||
list = g_list_sort (list, (GCompareFunc) gst_auto_audio_sink_compare_ranks);
|
list = g_list_sort (list, (GCompareFunc) gst_auto_audio_sink_compare_ranks);
|
||||||
|
|
||||||
/* FIXME:
|
/* We don't treat sound server sinks special. Our policy is that sound
|
||||||
* - soundservers have no priority yet.
|
* server sinks that have a rank must not auto-spawn a daemon under any
|
||||||
* - soundserversinks should only be chosen if already running, or if
|
* circumstances, so there's nothing for us to worry about here */
|
||||||
* the user explicitly wants this to run... That is not easy.
|
GST_LOG_OBJECT (sink, "Trying to find usable audio devices ...");
|
||||||
*/
|
|
||||||
|
|
||||||
while (1) {
|
for (item = list; item != NULL; item = item->next) {
|
||||||
GST_DEBUG_OBJECT (sink, "Trying to find %s",
|
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
||||||
ss ? "soundservers" : "audio devices");
|
GstElement *el;
|
||||||
|
|
||||||
for (item = list; item != NULL; item = item->next) {
|
if ((el = gst_auto_audio_sink_create_element_with_pretty_name (sink, f))) {
|
||||||
GstElementFactory *f = GST_ELEMENT_FACTORY (item->data);
|
GstStateChangeReturn ret;
|
||||||
GstElement *el;
|
|
||||||
|
|
||||||
if ((el = gst_element_factory_create (f, child_name))) {
|
GST_DEBUG_OBJECT (sink, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
|
||||||
/* FIXME: no element actually has this property as far as I can tell.
|
gst_element_set_bus (el, bus);
|
||||||
* also, this is a nasty uncheckable way of supporting something that
|
ret = gst_element_set_state (el, GST_STATE_READY);
|
||||||
* amounts to being an interface. */
|
if (ret == GST_STATE_CHANGE_SUCCESS) {
|
||||||
gboolean has_p = g_object_class_find_property (G_OBJECT_GET_CLASS (el),
|
gst_element_set_state (el, GST_STATE_NULL);
|
||||||
"soundserver-running") ? TRUE : FALSE;
|
GST_DEBUG_OBJECT (sink, "This worked!");
|
||||||
|
choice = el;
|
||||||
if (ss == has_p) {
|
break;
|
||||||
if (ss) {
|
|
||||||
gboolean r;
|
|
||||||
|
|
||||||
g_object_get (el, "soundserver-running", &r, NULL);
|
|
||||||
if (r) {
|
|
||||||
GST_DEBUG_OBJECT (sink, "%s - soundserver is running",
|
|
||||||
GST_PLUGIN_FEATURE (f)->name);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (sink, "%s - Soundserver is not running",
|
|
||||||
GST_PLUGIN_FEATURE (f)->name);
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GST_DEBUG_OBJECT (sink, "Testing %s", GST_PLUGIN_FEATURE (f)->name);
|
|
||||||
gst_element_set_bus (el, bus);
|
|
||||||
if (gst_element_set_state (el,
|
|
||||||
GST_STATE_READY) == GST_STATE_CHANGE_SUCCESS) {
|
|
||||||
gst_element_set_state (el, GST_STATE_NULL);
|
|
||||||
GST_DEBUG_OBJECT (sink, "This worked!");
|
|
||||||
choice = el;
|
|
||||||
goto done;
|
|
||||||
} else {
|
|
||||||
/* collect all error messages */
|
|
||||||
while ((message = gst_bus_pop (bus))) {
|
|
||||||
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
|
|
||||||
GST_DEBUG_OBJECT (sink, "appending error message %"
|
|
||||||
GST_PTR_FORMAT, message);
|
|
||||||
errors = g_slist_append (errors, message);
|
|
||||||
} else {
|
|
||||||
gst_message_unref (message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gst_element_set_state (el, GST_STATE_NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next:
|
|
||||||
gst_object_unref (el);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!ss)
|
/* collect all error messages */
|
||||||
break;
|
while ((message = gst_bus_pop (bus))) {
|
||||||
ss = FALSE;
|
if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
|
||||||
|
GST_DEBUG_OBJECT (sink, "error message %" GST_PTR_FORMAT, message);
|
||||||
|
errors = g_slist_append (errors, message);
|
||||||
|
} else {
|
||||||
|
gst_message_unref (message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_element_set_state (el, GST_STATE_NULL);
|
||||||
|
gst_object_unref (el);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
|
||||||
GST_DEBUG_OBJECT (sink, "done trying");
|
GST_DEBUG_OBJECT (sink, "done trying");
|
||||||
if (!choice) {
|
if (!choice) {
|
||||||
if (errors) {
|
if (errors) {
|
||||||
|
@ -249,7 +235,6 @@ done:
|
||||||
("Failed to find a supported audio sink"));
|
("Failed to find a supported audio sink"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_free (child_name);
|
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
gst_plugin_feature_list_free (list);
|
gst_plugin_feature_list_free (list);
|
||||||
g_slist_foreach (errors, (GFunc) gst_mini_object_unref, NULL);
|
g_slist_foreach (errors, (GFunc) gst_mini_object_unref, NULL);
|
||||||
|
@ -307,6 +292,8 @@ gst_auto_audio_sink_change_state (GstElement * element,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||||
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
||||||
|
return ret;
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_READY_TO_NULL:
|
case GST_STATE_CHANGE_READY_TO_NULL:
|
||||||
|
|
Loading…
Reference in a new issue