gst-gmyth/playbinmaemo/gstplaybinmaemo.c
branchtrunk
changeset 811 69aba3b6b7b3
parent 808 215c45290ce3
child 852 2498e4f8c758
     1.1 --- a/gst-gmyth/playbinmaemo/gstplaybinmaemo.c	Thu Aug 16 15:24:01 2007 +0100
     1.2 +++ b/gst-gmyth/playbinmaemo/gstplaybinmaemo.c	Fri Aug 17 22:47:49 2007 +0100
     1.3 @@ -35,7 +35,7 @@
     1.4  GST_DEBUG_CATEGORY_STATIC (gst_play_bin_maemo_debug);
     1.5  #define GST_CAT_DEFAULT gst_play_bin_maemo_debug
     1.6  
     1.7 -#define DEFAULT_VOLUME               10
     1.8 +#define DEFAULT_VOLUME               1.0
     1.9  #define DEFAULT_XID                 -1
    1.10  
    1.11  /* props */
    1.12 @@ -73,12 +73,16 @@
    1.13  static GList    *find_compatibles                   (GstPlayBinMaemo *pbm,
    1.14                                                       const GstCaps *caps);
    1.15  static GstPad   *find_sink_pad                      (GstElement * element);
    1.16 -static void     update_volume                       (GstPlayBinMaemo *pbm);
    1.17 +static void     update_volume                       (GstPlayBinMaemo *pbm,
    1.18 +                                                     gfloat volume);
    1.19  static void     update_xid                          (GstPlayBinMaemo *pbm);
    1.20  static void     new_decoded_pad_cb                  (GstElement *object,
    1.21                                                       GstPad* pad,
    1.22                                                       gboolean arg,
    1.23                                                       gpointer user_data);
    1.24 +static void     removed_decoded_pad_cb              (GstElement *object,
    1.25 +                                                     GstPad* pad,
    1.26 +                                                     gpointer user_data);
    1.27  static void     unknown_type_cb                     (GstElement *object,
    1.28                                                       GstPad *pad,
    1.29                                                       GstCaps *casp,
    1.30 @@ -125,7 +129,7 @@
    1.31  
    1.32    g_object_class_install_property (gobject_klass, ARG_VOLUME,
    1.33        g_param_spec_double ("volume", "Audio volume", "volume",
    1.34 -                            0.0, 10.0, (gdouble) DEFAULT_VOLUME, G_PARAM_READWRITE));
    1.35 +                            0.0, 10.0, DEFAULT_VOLUME, G_PARAM_READWRITE));
    1.36  
    1.37    g_object_class_install_property (gobject_klass, ARG_XID,
    1.38        g_param_spec_long ("xid", "xid", "X windown ID",
    1.39 @@ -158,14 +162,16 @@
    1.40    play_bin_maemo->uri = NULL;
    1.41    play_bin_maemo->source = NULL;
    1.42  
    1.43 -  play_bin_maemo->volume = DEFAULT_VOLUME * 65535 / 10;
    1.44 +  play_bin_maemo->volume = DEFAULT_VOLUME;
    1.45    play_bin_maemo->xid = DEFAULT_XID;
    1.46    play_bin_maemo->parse_metadata = TRUE;
    1.47  
    1.48 -  factories = gst_default_registry_feature_filter ((GstPluginFeatureFilter) factory_filter_sinks,
    1.49 -                                                   FALSE, play_bin_maemo);
    1.50 +  factories = gst_default_registry_feature_filter (
    1.51 +                (GstPluginFeatureFilter) factory_filter_sinks,
    1.52 +                 FALSE, play_bin_maemo);
    1.53  
    1.54 -  play_bin_maemo->factories = g_list_sort (factories, (GCompareFunc) compare_ranks);
    1.55 +  play_bin_maemo->factories = g_list_sort (factories,
    1.56 +                                           (GCompareFunc) compare_ranks);
    1.57  }
    1.58  
    1.59  static void
    1.60 @@ -328,11 +334,17 @@
    1.61                      G_CALLBACK (new_decoded_pad_cb),
    1.62                      pbm);
    1.63  
    1.64 +  g_signal_connect (G_OBJECT (decoder),
    1.65 +                    "removed-decoded-pad",
    1.66 +                    G_CALLBACK (removed_decoded_pad_cb),
    1.67 +                    pbm);
    1.68 +
    1.69 +
    1.70    queue = gst_element_factory_make ("queue", NULL);
    1.71    add_element (pbm, queue);
    1.72  
    1.73    if (gst_element_link_many (pbm->source, queue, decoder, NULL) == FALSE) {
    1.74 -    g_warning ("FAIL TO LINK SRC WITH DECODEBIN2");
    1.75 +    GST_WARNING ("FAIL TO LINK SRC WITH DECODEBIN2");
    1.76    }
    1.77  }
    1.78  
    1.79 @@ -388,7 +400,7 @@
    1.80        const gchar *uri = g_value_get_string (value);
    1.81  
    1.82        if (uri == NULL) {
    1.83 -        g_warning ("cannot set NULL uri");
    1.84 +        GST_WARNING ("cannot set NULL uri");
    1.85          return;
    1.86        }
    1.87        /* if we have no previous uri, or the new uri is different from the
    1.88 @@ -404,23 +416,8 @@
    1.89        break;
    1.90      }
    1.91      case ARG_VOLUME:
    1.92 -    {
    1.93 -      gdouble d_volume = 0;
    1.94 -      guint u_volume = 0;
    1.95 -      d_volume = g_value_get_double (value);
    1.96 -
    1.97 -      g_debug ("Getting : %5.2f", d_volume);
    1.98 -      if (d_volume != 0) {
    1.99 -        u_volume = (guint) (65535 * d_volume);
   1.100 -      }
   1.101 -
   1.102 -      g_debug ("Converting : %d", u_volume);
   1.103 -      if (play_bin_maemo->volume != u_volume) {
   1.104 -          play_bin_maemo->volume = u_volume;
   1.105 -          update_volume (play_bin_maemo);
   1.106 -      }
   1.107 +      update_volume(play_bin_maemo, g_value_get_double (value));
   1.108        break;
   1.109 -    }
   1.110      case ARG_XID:
   1.111      {
   1.112        long xid;
   1.113 @@ -442,8 +439,10 @@
   1.114  }
   1.115  
   1.116  static void
   1.117 -gst_play_bin_maemo_get_property (GObject * object, guint prop_id, GValue * value,
   1.118 -    GParamSpec * pspec)
   1.119 +gst_play_bin_maemo_get_property (GObject * object,
   1.120 +                                 guint prop_id,
   1.121 +                                 GValue * value,
   1.122 +                                 GParamSpec * pspec)
   1.123  {
   1.124    GstPlayBinMaemo *play_bin_maemo;
   1.125  
   1.126 @@ -459,14 +458,8 @@
   1.127        g_value_set_object (value, play_bin_maemo->source);
   1.128        break;
   1.129      case ARG_VOLUME:
   1.130 -    {
   1.131 -      gdouble volume  = 0;
   1.132 -      if (play_bin_maemo->volume > 0) {
   1.133 -          volume = play_bin_maemo->volume / 65535;
   1.134 -      }
   1.135 -      g_value_set_double (value, volume);
   1.136 +      g_value_set_double (value, play_bin_maemo->volume);
   1.137        break;
   1.138 -    }
   1.139      case ARG_XID:
   1.140        g_value_set_long (value, play_bin_maemo->xid);
   1.141        break;
   1.142 @@ -480,7 +473,8 @@
   1.143  }
   1.144  
   1.145  static GstStateChangeReturn
   1.146 -gst_play_bin_maemo_change_state (GstElement * element, GstStateChange transition)
   1.147 +gst_play_bin_maemo_change_state (GstElement * element,
   1.148 +                                 GstStateChange transition)
   1.149  {
   1.150    GstStateChangeReturn ret;
   1.151    GstPlayBinMaemo *play_bin_maemo;
   1.152 @@ -540,7 +534,8 @@
   1.153    if ((strstr (klass, "Sink/Video") == NULL) && (strstr (klass, "Sink/Audio") == NULL))
   1.154      return FALSE;
   1.155  
   1.156 -  g_debug ("Filtered: %s", gst_element_factory_get_longname ((GST_ELEMENT_FACTORY (feature))));
   1.157 +  GST_DEBUG_OBJECT (pbm, "Filtered: %s",
   1.158 +        gst_element_factory_get_longname ((GST_ELEMENT_FACTORY (feature))));
   1.159    rank = gst_plugin_feature_get_rank (feature);
   1.160    if (rank < GST_RANK_MARGINAL)
   1.161      return FALSE;
   1.162 @@ -549,7 +544,8 @@
   1.163  }
   1.164  
   1.165  static gint
   1.166 -compare_ranks (GstPluginFeature * f1, GstPluginFeature * f2)
   1.167 +compare_ranks (GstPluginFeature * f1,
   1.168 +               GstPluginFeature * f2)
   1.169  {
   1.170    gint diff;
   1.171    const gchar *rname1, *rname2;
   1.172 @@ -568,7 +564,8 @@
   1.173  
   1.174  
   1.175  static GList *
   1.176 -find_compatibles (GstPlayBinMaemo *pbm, const GstCaps *caps)
   1.177 +find_compatibles (GstPlayBinMaemo *pbm,
   1.178 +                  const GstCaps *caps)
   1.179  {
   1.180    GList *factories;
   1.181    GList *to_try = NULL;
   1.182 @@ -593,6 +590,7 @@
   1.183          tmpl_caps = gst_static_caps_get (&templ->static_caps);
   1.184  
   1.185          intersect = gst_caps_intersect (caps, tmpl_caps);
   1.186 +
   1.187          gst_caps_unref (tmpl_caps);
   1.188  
   1.189          /* check if the intersection is empty */
   1.190 @@ -611,7 +609,6 @@
   1.191    return to_try;
   1.192  }
   1.193  
   1.194 -
   1.195  static gboolean
   1.196  autoplug_continue_cb (GstElement* object,
   1.197                        GstCaps* caps,
   1.198 @@ -623,7 +620,7 @@
   1.199  
   1.200      pbm = GST_PLAY_BIN_MAEMO (user_data);
   1.201  
   1.202 -    //TODO: fix this for work with all metada elements
   1.203 +    //TODO: fix this to work with all metadata elements
   1.204      if (pbm->parse_metadata) {
   1.205          gchar *caps_str = gst_caps_to_string (caps);
   1.206          if ((strstr (caps_str, "id3") != NULL) &&
   1.207 @@ -651,10 +648,10 @@
   1.208                   GstCaps *caps,
   1.209                   gpointer user_data)
   1.210  {
   1.211 -  g_debug ("unknown_type_cb: %s", gst_caps_to_string (caps));
   1.212 +  GST_DEBUG ("unknown_type_cb: %s", gst_caps_to_string (caps));
   1.213  }
   1.214  
   1.215 -static GstPad *
   1.216 +static GstPad*
   1.217  find_sink_pad (GstElement * element)
   1.218  {
   1.219    GstIterator *it;
   1.220 @@ -672,7 +669,8 @@
   1.221  }
   1.222  
   1.223  static GstElement*
   1.224 -create_element (GstPlayBinMaemo *pbm, GstElementFactory *factory)
   1.225 +create_element (GstPlayBinMaemo *pbm,
   1.226 +                GstElementFactory *factory)
   1.227  {
   1.228    GstElement *queue;
   1.229    GstElement *bin = NULL;
   1.230 @@ -681,10 +679,11 @@
   1.231  
   1.232    element = gst_element_factory_create (factory, NULL);
   1.233    if (element == NULL)
   1.234 -    return NULL;
   1.235 -
   1.236 +    goto error;
   1.237  
   1.238    bin = gst_bin_new (NULL);
   1.239 +  if (bin == NULL)
   1.240 +    goto error;
   1.241  
   1.242    queue = gst_element_factory_make ("queue", NULL);
   1.243    gst_bin_add (GST_BIN (bin), queue);
   1.244 @@ -693,10 +692,12 @@
   1.245      GstElement *colorspace;
   1.246  
   1.247      colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
   1.248 +    if (colorspace == NULL)
   1.249 +      goto error;
   1.250  
   1.251      gst_bin_add (GST_BIN (bin), colorspace);
   1.252      if (gst_element_link (queue, colorspace) == FALSE) {
   1.253 -      GST_WARNING_OBJECT (pbm, "Fail to link queue and colorspace");
   1.254 +      GST_WARNING_OBJECT (pbm, "Failed to link queue and colorspace");
   1.255        gst_element_set_state (colorspace, GST_STATE_NULL);
   1.256        gst_object_unref (colorspace);
   1.257        goto error;
   1.258 @@ -704,7 +705,8 @@
   1.259  
   1.260      gst_bin_add (GST_BIN (bin), element);
   1.261      if (gst_element_link (colorspace, element) == FALSE) {
   1.262 -      GST_WARNING_OBJECT (pbm, "Fail to link colorspace and sink video: %s", GST_ELEMENT_NAME (element));
   1.263 +      GST_WARNING_OBJECT (pbm, "Failed to link colorspace and sink video: %s",
   1.264 +                          GST_ELEMENT_NAME (element));
   1.265        gst_element_set_state (colorspace, GST_STATE_NULL);
   1.266        gst_object_unref (colorspace);
   1.267        goto error;
   1.268 @@ -719,35 +721,47 @@
   1.269  
   1.270      prev = queue;
   1.271      vol_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume");
   1.272 +
   1.273      if (vol_spec == NULL) {
   1.274 +      GstElement *conv;
   1.275        GstElement *volume;
   1.276  
   1.277 -      bin = gst_bin_new (NULL);
   1.278 +      conv = gst_element_factory_make ("audioconvert", "aconv");
   1.279 +      if (conv == NULL)
   1.280 +        goto error;
   1.281 +
   1.282 +      gst_bin_add (GST_BIN_CAST (bin), conv);
   1.283 +
   1.284 +      gst_element_link (queue, conv);
   1.285 +
   1.286        volume = gst_element_factory_make ("volume", "volume");
   1.287 +      if (volume == NULL)
   1.288 +        goto error;
   1.289 +
   1.290        gst_bin_add (GST_BIN (bin), volume);
   1.291 -      if (gst_element_link (queue, volume) == FALSE) {
   1.292 -        GST_WARNING_OBJECT (pbm, "Fail to link queue and volume");
   1.293 +      if (gst_element_link (conv, volume) == FALSE) {
   1.294 +        GST_WARNING_OBJECT (pbm, "Failed to link queue and volume");
   1.295          gst_element_set_state (volume, GST_STATE_NULL);
   1.296          gst_object_unref (volume);
   1.297          goto error;
   1.298        }
   1.299  
   1.300        prev = volume;
   1.301 +    } else {
   1.302        g_param_spec_unref (vol_spec);
   1.303      }
   1.304  
   1.305      gst_bin_add (GST_BIN (bin), element);
   1.306      if (gst_element_link (prev, element) == FALSE) {
   1.307 -      GST_WARNING_OBJECT (pbm, "Fail to link volume and sink audio: %s", GST_ELEMENT_NAME (element));
   1.308 +      GST_WARNING_OBJECT (pbm, "Failed to link volume and sink audio: %s", GST_ELEMENT_NAME (element));
   1.309        if (prev != queue) {
   1.310          gst_element_set_state (prev, GST_STATE_NULL);
   1.311          gst_object_unref (prev);
   1.312        }
   1.313        goto error;
   1.314      }
   1.315 -
   1.316      pbm->volume_element = (prev != queue) ? prev : element;
   1.317 -    update_volume (pbm);
   1.318 +    update_volume (pbm, pbm->volume);
   1.319    }
   1.320  
   1.321    pad = gst_element_get_pad (queue, "sink");
   1.322 @@ -755,7 +769,9 @@
   1.323    gst_object_unref (pad);
   1.324  
   1.325    return bin;
   1.326 +
   1.327  error:
   1.328 +  GST_WARNING_OBJECT (pbm, "Error creating pipeline");
   1.329  
   1.330    gst_element_set_state (bin, GST_STATE_NULL);
   1.331    gst_object_unref (bin);
   1.332 @@ -778,13 +794,12 @@
   1.333    pbm = GST_PLAY_BIN_MAEMO (user_data);
   1.334    caps = gst_pad_get_caps (pad);
   1.335  
   1.336 -  g_debug ("new_decoded_pad_cb: %s", gst_caps_to_string (caps));
   1.337 +  GST_DEBUG_OBJECT (pbm, "new_decoded_pad_cb: %s", gst_caps_to_string (caps));
   1.338  
   1.339    comp = find_compatibles (GST_PLAY_BIN_MAEMO (user_data), caps);
   1.340  
   1.341 -
   1.342    if (comp == NULL) {
   1.343 -    g_warning ("flow error: dont find comaptible");
   1.344 +    GST_WARNING ("flow error: dont find comaptible");
   1.345      return;
   1.346    }
   1.347  
   1.348 @@ -795,51 +810,48 @@
   1.349      GstElementFactory *factory = (GstElementFactory *) walk->data;
   1.350      GstElement *element;
   1.351      GstPad *sinkpad = NULL;
   1.352 +    gint result;
   1.353  
   1.354      if ((element = create_element (pbm, factory)) == NULL) {
   1.355        GST_WARNING_OBJECT (pbm, "Could not create an element from %s",
   1.356            gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
   1.357 -      g_debug ("Could not create an element from %s",
   1.358 -          gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)));
   1.359 +      continue;
   1.360 +    }
   1.361  
   1.362 +    if (!(sinkpad = find_sink_pad (element))) {
   1.363 +      GST_WARNING_OBJECT (pbm, "Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element));
   1.364 +      gst_object_unref (element);
   1.365        continue;
   1.366      }
   1.367  
   1.368      if (!(add_element (GST_PLAY_BIN_MAEMO (user_data), element))) {
   1.369 -      GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element));
   1.370 +      GST_WARNING_OBJECT (pbm, "Couldn't add element %s to bin", GST_ELEMENT_NAME (element));
   1.371 +      gst_object_unref (sinkpad);
   1.372        gst_object_unref (element);
   1.373        continue;
   1.374      }
   1.375  
   1.376      if ((gst_element_set_state (element, GST_STATE_READY))
   1.377                     == GST_STATE_CHANGE_FAILURE) {
   1.378 +      GST_WARNING_OBJECT (pbm, "Couldn't set %s to READY", GST_ELEMENT_NAME (element));
   1.379 +      gst_object_unref (sinkpad);
   1.380 +      gst_bin_remove (GST_BIN (user_data), element);
   1.381 +      continue;
   1.382 +    }
   1.383 +
   1.384 +    if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK) {
   1.385 +      GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s", GST_DEBUG_PAD_NAME (sinkpad));
   1.386        gst_element_set_state (element, GST_STATE_NULL);
   1.387        gst_object_unref (sinkpad);
   1.388        gst_bin_remove (GST_BIN (user_data), element);
   1.389        continue;
   1.390      }
   1.391  
   1.392 -    if (!(sinkpad = find_sink_pad (element))) {
   1.393 -      GST_WARNING_OBJECT (pbm, "Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element));
   1.394 -      g_debug ("Element %s doesn't have a sink pad", GST_ELEMENT_NAME (element));
   1.395 -      gst_object_unref (element);
   1.396 -      continue;
   1.397 -    }
   1.398 -
   1.399 -
   1.400 -    if ((gst_pad_link (pad, sinkpad)) != GST_PAD_LINK_OK) {
   1.401 -        GST_WARNING_OBJECT (pbm, "Link failed on pad %s:%s", GST_DEBUG_PAD_NAME (sinkpad));
   1.402 -        gst_element_set_state (element, GST_STATE_NULL);
   1.403 -        gst_object_unref (sinkpad);
   1.404 -        gst_bin_remove (GST_BIN (user_data), element);
   1.405 -      continue;
   1.406 -    }
   1.407 -
   1.408      gst_object_unref (sinkpad);
   1.409  
   1.410      if ((gst_element_set_state (element, GST_STATE_PAUSED)) == GST_STATE_CHANGE_FAILURE) {
   1.411 -        gst_element_set_state (element, GST_STATE_NULL);
   1.412 -        gst_bin_remove (GST_BIN (user_data), element);
   1.413 +      gst_element_set_state (element, GST_STATE_NULL);
   1.414 +      gst_bin_remove (GST_BIN (user_data), element);
   1.415        continue;
   1.416      }
   1.417  
   1.418 @@ -849,40 +861,106 @@
   1.419  
   1.420    g_list_free (comp);
   1.421    if (linked == FALSE) {
   1.422 -    g_warning ("GstFlow ERROR");
   1.423 +    g_debug ("GstFlow Error");
   1.424 +    GST_WARNING ("GstFlow ERROR");
   1.425    }
   1.426    GST_PAD_STREAM_UNLOCK (pad);
   1.427  }
   1.428  
   1.429  static void
   1.430 -update_volume (GstPlayBinMaemo *pbm)
   1.431 +removed_decoded_pad_cb (GstElement *object,
   1.432 +                        GstPad* pad,
   1.433 +                        gpointer user_data)
   1.434  {
   1.435 -  if (pbm->volume_element != NULL) {
   1.436 -    if (pbm->volume > 0) {
   1.437 -      g_object_set (G_OBJECT (pbm->volume_element),
   1.438 -                    "volume", pbm->volume,
   1.439 -                    NULL);
   1.440 -    } else {
   1.441 -      g_object_set (G_OBJECT (pbm->volume_element),
   1.442 -                    "mute", TRUE,
   1.443 -                    NULL);
   1.444 +  GstElement *sink;
   1.445 +
   1.446 +  GST_DEBUG("removed_decoded_pad_cb");
   1.447 +
   1.448 +  sink = gst_pad_get_parent_element (pad);
   1.449 +
   1.450 +  if (sink)
   1.451 +    gst_bin_remove (GST_BIN (user_data), sink);
   1.452 +}
   1.453 +
   1.454 +static GValue*
   1.455 +convert_volume_base (GstPlayBinMaemo *pbm, gfloat volume)
   1.456 +{
   1.457 +  GValue value = { 0, };
   1.458 +  GValue *converted_vol = g_new0(GValue, 1);
   1.459 +
   1.460 +  GParamSpec* vol_spec = g_object_class_find_property (
   1.461 +    G_OBJECT_GET_CLASS (pbm->volume_element), "volume");
   1.462 +
   1.463 +  g_value_init (&value, vol_spec->value_type);
   1.464 +  g_value_init (converted_vol, vol_spec->value_type);
   1.465 +
   1.466 +  g_object_get_property (G_OBJECT (pbm->volume_element), "volume", &value);
   1.467 +
   1.468 +  /* convert volume from double to int range if needed */
   1.469 +  switch (G_VALUE_TYPE (&value)) {
   1.470 +    case G_TYPE_UINT:
   1.471 +    {
   1.472 +      GParamSpecUInt *puint = G_PARAM_SPEC_UINT (vol_spec);
   1.473 +      guint scale = puint->maximum - puint->minimum;
   1.474 +      guint vol_guint = (guint) ((scale * volume) + puint->minimum);
   1.475 +
   1.476 +      GST_WARNING ("Range: %u - %u, Converted: %u",
   1.477 +          puint->minimum, puint->maximum, vol_guint);
   1.478 +      g_value_set_uint (converted_vol, vol_guint);
   1.479 +      break;
   1.480      }
   1.481 +    case G_TYPE_INT:
   1.482 +    {
   1.483 +      GParamSpecInt *pint = G_PARAM_SPEC_INT (vol_spec);
   1.484 +      gint scale = pint->maximum - pint->minimum;
   1.485 +      gint vol_gint = (gint) ((scale * volume) + pint->minimum);
   1.486 +
   1.487 +      GST_WARNING ("Range: %d - %d, Converted: %d",
   1.488 +          pint->minimum, pint->maximum, vol_gint);
   1.489 +      g_value_set_int (converted_vol, vol_gint);
   1.490 +      break;
   1.491 +    }
   1.492 +    case G_TYPE_DOUBLE:
   1.493 +    case G_TYPE_FLOAT:
   1.494 +    {
   1.495 +      GST_WARNING ("Default converted to float: %f", volume);
   1.496 +      g_value_set_double (converted_vol, volume);
   1.497 +      break;
   1.498 +    }
   1.499 +    default:
   1.500 +      GST_WARNING ("Dont know how to convert volume");
   1.501 +  }
   1.502 +
   1.503 +  return converted_vol;
   1.504 +}
   1.505 +
   1.506 +static void
   1.507 +update_volume (GstPlayBinMaemo *pbm, gfloat volume)
   1.508 +{
   1.509 +  pbm->volume = volume;
   1.510 +  if (pbm->volume_element) {
   1.511 +    GValue *converted_vol = convert_volume_base (pbm, volume);
   1.512 +    g_object_set_property (G_OBJECT (pbm->volume_element), "volume",
   1.513 +                           converted_vol);
   1.514 +    g_value_unset (converted_vol);
   1.515    }
   1.516  }
   1.517  
   1.518  static void
   1.519  update_xid (GstPlayBinMaemo *pbm)
   1.520  {
   1.521 -  if ((pbm->video_sink != NULL) &&
   1.522 -    (pbm->xid != -1) &&
   1.523 -    (GST_IS_X_OVERLAY (pbm->video_sink))) {
   1.524 +  if ((pbm->video_sink != NULL) && (pbm->xid != -1) &&
   1.525 +      (GST_IS_X_OVERLAY (pbm->video_sink))) {
   1.526      Display *display;
   1.527      g_object_set (G_OBJECT (pbm->video_sink),
   1.528                    "force-aspect-ratio", TRUE, NULL);
   1.529 +
   1.530      display = XOpenDisplay(NULL);
   1.531 +
   1.532      XMapRaised(display, pbm->xid);
   1.533 +    XSync (display, FALSE);
   1.534 +
   1.535      XSetErrorHandler(x_error_handler);
   1.536 -    XSync (display, FALSE);
   1.537  
   1.538      gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (pbm->video_sink),
   1.539                                    pbm->xid);
   1.540 @@ -890,22 +968,23 @@
   1.541  }
   1.542  
   1.543  static int
   1.544 -x_error_handler(Display *display, XErrorEvent *event)
   1.545 +x_error_handler(Display *display,
   1.546 +                XErrorEvent *event)
   1.547  {
   1.548 -    g_debug ("In x error handler:");
   1.549 +    GST_DEBUG ("In x error handler:");
   1.550  
   1.551      switch (event->error_code) {
   1.552          case BadWindow:
   1.553 -            g_debug ("got bad window");
   1.554 +            GST_DEBUG ("got bad window");
   1.555              break;
   1.556          case BadDrawable:
   1.557 -            g_debug ("got bad drawable");
   1.558 +            GST_DEBUG ("got bad drawable");
   1.559              break;
   1.560          case BadGC:
   1.561 -            g_debug ("got bad gc");
   1.562 +            GST_DEBUG ("got bad gc");
   1.563              break;
   1.564          default:
   1.565 -            g_debug ("unhandled x error = %d", event->error_code);
   1.566 +            GST_DEBUG ("unhandled x error = %d", event->error_code);
   1.567      }
   1.568  
   1.569      return 0;