[rhythmbox] player backends: remove buffer size setting, use gsettings sinks
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] player backends: remove buffer size setting, use gsettings sinks
- Date: Sat, 9 Apr 2011 07:22:00 +0000 (UTC)
commit 8b9ebae5090045b873cb39e32a3279e21f3c0a97
Author: Jonathan Matthew <jonathan d14n org>
Date: Sat Apr 9 16:22:31 2011 +1000
player backends: remove buffer size setting, use gsettings sinks
backends/gstreamer/rb-player-gst-helper.c | 7 ++--
backends/gstreamer/rb-player-gst-xfade.c | 48 ++++++++-----------------
backends/gstreamer/rb-player-gst.c | 54 ++++++-----------------------
3 files changed, 30 insertions(+), 79 deletions(-)
---
diff --git a/backends/gstreamer/rb-player-gst-helper.c b/backends/gstreamer/rb-player-gst-helper.c
index 73c62e2..2bcc94f 100644
--- a/backends/gstreamer/rb-player-gst-helper.c
+++ b/backends/gstreamer/rb-player-gst-helper.c
@@ -64,10 +64,11 @@ rb_player_gst_try_audio_sink (const char *plugin_name, const char *name)
GstStateChangeReturn ret;
GstBus *bus;
- /* use the 'music and movies' profile for gconfaudiosink */
- if (strcmp (plugin_name, "gconfaudiosink") == 0 &&
+ /* use the 'music and movies' profile for gconfaudiosink and gsettingsaudiosink */
+ if ((strcmp (plugin_name, "gconfaudiosink") == 0 ||
+ strcmp (plugin_name, "gsettingsaudiosink") == 0) &&
g_object_class_find_property (G_OBJECT_GET_CLASS (audio_sink), "profile")) {
- rb_debug ("setting profile property on gconfaudiosink");
+ rb_debug ("setting profile property on %s", plugin_name);
g_object_set (audio_sink, "profile", 1, NULL);
}
diff --git a/backends/gstreamer/rb-player-gst-xfade.c b/backends/gstreamer/rb-player-gst-xfade.c
index 9b49475..d73c2a0 100644
--- a/backends/gstreamer/rb-player-gst-xfade.c
+++ b/backends/gstreamer/rb-player-gst-xfade.c
@@ -211,14 +211,11 @@ G_DEFINE_TYPE_WITH_CODE(RBPlayerGstXFade, rb_player_gst_xfade, G_TYPE_OBJECT,
#define FADE_IN_DONE_MESSAGE "rb-fade-in-done"
#define STREAM_EOS_MESSAGE "rb-stream-eos"
-#define MAX_NETWORK_BUFFER_SIZE (2048)
-
#define PAUSE_FADE_LENGTH (GST_SECOND / 2)
enum
{
PROP_0,
- PROP_BUFFER_SIZE,
PROP_BUS
};
@@ -266,7 +263,6 @@ struct _RBPlayerGstXFadePrivate
int volume_changed;
int volume_applied;
float cur_volume;
- guint buffer_size; /* kB */
guint tick_timeout_id;
@@ -579,9 +575,6 @@ rb_player_gst_xfade_get_property (GObject *object,
RBPlayerGstXFade *player = RB_PLAYER_GST_XFADE (object);
switch (prop_id) {
- case PROP_BUFFER_SIZE:
- g_value_set_uint (value, player->priv->buffer_size);
- break;
case PROP_BUS:
if (player->priv->pipeline) {
GstBus *bus;
@@ -602,13 +595,9 @@ rb_player_gst_xfade_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- RBPlayerGstXFade *player = RB_PLAYER_GST_XFADE (object);
+ /*RBPlayerGstXFade *player = RB_PLAYER_GST_XFADE (object);*/
switch (prop_id) {
- case PROP_BUFFER_SIZE:
- player->priv->buffer_size = g_value_get_uint (value);
- /* try to adjust any playing streams? */
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -626,14 +615,6 @@ rb_player_gst_xfade_class_init (RBPlayerGstXFadeClass *klass)
object_class->get_property = rb_player_gst_xfade_get_property;
g_object_class_install_property (object_class,
- PROP_BUFFER_SIZE,
- g_param_spec_uint ("buffer-size",
- "buffer size",
- "Buffer size for network streams, in kB",
- 64, MAX_NETWORK_BUFFER_SIZE, 128,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
PROP_BUS,
g_param_spec_object ("bus",
"bus",
@@ -2036,9 +2017,6 @@ create_stream (RBPlayerGstXFade *player, const char *uri, gpointer stream_data,
}
gst_object_ref (stream->decoder);
g_object_set (stream->decoder, "uri", uri, NULL);
- if (player->priv->buffer_size != 0) {
- g_object_set (stream->decoder, "buffer-size", player->priv->buffer_size * 1024, NULL);
- }
/* connect uridecodebin to audioconvert when it creates its output pad */
g_signal_connect_object (stream->decoder,
@@ -2632,7 +2610,7 @@ stream_volume_changed (GObject *element, GParamSpec *pspec, RBPlayerGstXFade *pl
* output sink + adder pipeline:
*
* outputcaps = audio/x-raw-int,channels=2,rate=44100,width=16,depth=16
- * outputbin = outputcaps ! volume ! filterbin ! audioconvert ! audioresample ! tee ! queue ! gconfaudiosink
+ * outputbin = outputcaps ! volume ! filterbin ! audioconvert ! audioresample ! tee ! queue ! audiosink
* silencebin = audiotestsrc wave=silence ! outputcaps
*
* pipeline = silencebin ! adder ! outputbin
@@ -2956,6 +2934,7 @@ stop_sink (RBPlayerGstXFade *player)
static gboolean
create_sink (RBPlayerGstXFade *player, GError **error)
{
+ const char *try_sinks[] = { "gsettingsaudiosink", "gconfaudiosink", "autoaudiosink" };
GstElement *audiotestsrc;
GstElement *audioconvert;
GstElement *audioresample;
@@ -2969,6 +2948,7 @@ create_sink (RBPlayerGstXFade *player, GError **error)
GstPad *addersrcpad;
GstPadLinkReturn plr;
GList *l;
+ int i;
if (player->priv->sink_state != SINK_NULL)
return TRUE;
@@ -3022,17 +3002,19 @@ create_sink (RBPlayerGstXFade *player, GError **error)
return FALSE;
}
- player->priv->sink = rb_player_gst_try_audio_sink ("gconfaudiosink", NULL);
- if (player->priv->sink == NULL) {
- player->priv->sink = rb_player_gst_try_audio_sink ("autoaudiosink", NULL);
- if (player->priv->sink == NULL) {
- g_set_error (error,
- RB_PLAYER_ERROR,
- RB_PLAYER_ERROR_GENERAL,
- _("Failed to create audio output element; check your installation"));
- return FALSE;
+ for (i = 0; i < G_N_ELEMENTS (try_sinks); i++) {
+ player->priv->sink = rb_player_gst_try_audio_sink (try_sinks[i], NULL);
+ if (player->priv->sink != NULL) {
+ break;
}
}
+ if (player->priv->sink == NULL) {
+ g_set_error (error,
+ RB_PLAYER_ERROR,
+ RB_PLAYER_ERROR_GENERAL,
+ _("Failed to create audio output element; check your installation"));
+ return FALSE;
+ }
g_object_set (player->priv->capsfilter, "caps", caps, NULL);
g_object_set (capsfilter, "caps", caps, NULL);
diff --git a/backends/gstreamer/rb-player-gst.c b/backends/gstreamer/rb-player-gst.c
index cdb998b..6cc54dc 100644
--- a/backends/gstreamer/rb-player-gst.c
+++ b/backends/gstreamer/rb-player-gst.c
@@ -63,8 +63,6 @@ G_DEFINE_TYPE_WITH_CODE(RBPlayerGst, rb_player_gst, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE(RB_TYPE_PLAYER_GST_TEE, rb_player_gst_tee_init)
)
-#define MAX_NETWORK_BUFFER_SIZE (2048)
-
#define RB_PLAYER_GST_TICK_HZ 5
#define STATE_CHANGE_MESSAGE_TIMEOUT 5
@@ -72,8 +70,7 @@ enum
{
PROP_0,
PROP_PLAYBIN,
- PROP_BUS,
- PROP_BUFFER_SIZE
+ PROP_BUS
};
enum
@@ -107,7 +104,6 @@ struct _RBPlayerGstPrivate
GstElement *playbin;
GstElement *audio_sink;
enum StateChangeAction state_change_action;
- guint buffer_size;
gboolean playing;
gboolean buffering;
@@ -659,9 +655,6 @@ construct_pipeline (RBPlayerGst *mp, GError **error)
"notify::source",
G_CALLBACK (source_notify_cb),
mp, 0);
- if (mp->priv->buffer_size != 0) {
- g_object_set (mp->priv->playbin, "buffer-size", mp->priv->buffer_size * 1024, NULL);
- }
gst_bus_add_watch (gst_element_get_bus (mp->priv->playbin),
(GstBusFunc) bus_cb,
@@ -671,26 +664,18 @@ construct_pipeline (RBPlayerGst *mp, GError **error)
g_object_notify (G_OBJECT (mp), "playbin");
g_object_notify (G_OBJECT (mp), "bus");
- /* Use gconfaudiosink for audio if there's no audio sink yet */
+ /* Use gsettingsaudiosink for audio if there's no audio sink yet */
g_object_get (mp->priv->playbin, "audio-sink", &mp->priv->audio_sink, NULL);
if (mp->priv->audio_sink == NULL) {
- mp->priv->audio_sink = gst_element_factory_make ("gconfaudiosink", NULL);
- if (mp->priv->audio_sink == NULL) {
- /* fall back to autoaudiosink */
- rb_debug ("falling back to autoaudiosink");
- mp->priv->audio_sink = gst_element_factory_make ("autoaudiosink", NULL);
- } else {
- rb_debug ("using gconfaudiosink");
- }
-
- if (mp->priv->audio_sink != NULL) {
- /* set the profile property on the gconfaudiosink to "music and movies" */
- if (g_object_class_find_property (G_OBJECT_GET_CLASS (mp->priv->audio_sink), "profile")) {
- rb_debug ("setting profile property on audio sink");
- g_object_set (mp->priv->audio_sink, "profile", 1, NULL);
+ const char *try_sinks[] = { "gsettingsaudiosink", "gconfaudiosink", "autoaudiosink" };
+ int i;
+
+ for (i = 0; i < G_N_ELEMENTS (try_sinks); i++) {
+ mp->priv->audio_sink = rb_player_gst_try_audio_sink (try_sinks[i], NULL);
+ if (mp->priv->audio_sink != NULL) {
+ g_object_set (mp->priv->playbin, "audio-sink", mp->priv->audio_sink, NULL);
+ break;
}
-
- g_object_set (mp->priv->playbin, "audio-sink", mp->priv->audio_sink, NULL);
}
} else {
rb_debug ("existing audio sink found");
@@ -1092,9 +1077,6 @@ impl_get_property (GObject *object,
gst_object_unref (bus);
}
break;
- case PROP_BUFFER_SIZE:
- g_value_set_uint (value, mp->priv->buffer_size);
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1107,16 +1089,9 @@ impl_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- RBPlayerGst *mp = RB_PLAYER_GST (object);
+ /*RBPlayerGst *mp = RB_PLAYER_GST (object);*/
switch (prop_id) {
- case PROP_BUFFER_SIZE:
- mp->priv->buffer_size = g_value_get_uint (value);
- if (mp->priv->playbin != NULL) {
- rb_debug ("setting buffer size on playbin: %d", mp->priv->buffer_size * 1024);
- g_object_set (mp->priv->playbin, "buffer-size", mp->priv->buffer_size * 1024, NULL);
- }
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1197,13 +1172,6 @@ rb_player_gst_class_init (RBPlayerGstClass *klass)
"GStreamer message bus",
GST_TYPE_BUS,
G_PARAM_READABLE));
- g_object_class_install_property (object_class,
- PROP_BUFFER_SIZE,
- g_param_spec_uint ("buffer-size",
- "buffer size",
- "Buffer size for network streams, in kB",
- 64, MAX_NETWORK_BUFFER_SIZE, 128,
- G_PARAM_READWRITE));
signals[PREPARE_SOURCE] =
g_signal_new ("prepare-source",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]