Forum: Ruby-Gnome 2 Curious GStreamer bug

Posted by Vincent Carmona (vinc-mai)
on 2010-03-02 07:38
(Received via mailing list)
Hi everyone!

I have a very strange behaviour with gstreamer. Under certain
circonstances, the play method of a playbin object freeze my Gtk/Gst
applycation. This is an example of a freezing code.

======================================================
#!/usr/bin/env ruby
# encoding: UTF-8

#gst-launch playbin
uri="http://mp3.live.tv-radio.com/centpourcent/all/centpourcent-128k.mp3"

require 'gtk2'
require 'gst'

class Player
  def initialize
    @playbin=Gst::ElementFactory.make('playbin')
    @playbin.ready
  end

  def stop
    @playbin.stop
  end

  def play
    @playbin.uri='http://mp3.live.tv-radio.com/centpourcent/all/centpourcent-128k.mp3'
    #@playbin.uri='file:///home/instable/Musique/01 - Blue Bird.mp3'
    p "Going to play..."
    @playbin.play
    p "Playing."
  end
end

class Gui
  def initialize(player)
    @player=player
    @bstop=Gtk::Button.new('Stop')
    @bstop.signal_connect('clicked'){@player.stop}
    @bplay=Gtk::Button.new('Play')
    @bplay.signal_connect('clicked'){@player.play}
    @box=Gtk::HBox.new
    @box.pack_start(@bstop)
    @box.pack_start(@bplay)
    @window=Gtk::Window.new
    @window.add(@box)
    @window.show_all
    @window.signal_connect("delete_event"){Gtk_quit; true}
    #@player.play
  end
end

player=Player.new
gui=Gui.new(player)
#player.play
Gtk.main
===========================================================

Did it also freeze the program on clicking the play button on your 
machine ?

I will try to explain the circonstances needed for a freeze.
The uri need to a webradio (maybe not all webradios freezes). No
freeze with loacal files.
The play method must be called from a block. No freeze if it is called
from the main code or within the Gui#initialize method.

If the uri was all ready played, the play method from a block do not
freeze the programm. (If I call player.play from main code, I can use
the stop and then the play button without freezing the programm.

Am I doing something wrong ?

    Vincent
Posted by Simon Arnaud (Guest)
on 2010-03-02 11:04
(Received via mailing list)
2010/3/2 vincent carmona <vinc4mai@gmail.com>:
> Did it also freeze the program on clicking the play button on your machine ?

No.
On debian sid :
Tested with 1.8.7, RG2 0.19.3
and 1.9.1, RG2 svn

I tried several times to stop/play, and it works ok.

Btw, Gtk_quit is undefined.
Posted by Vincent Carmona (vinc-mai)
on 2010-03-02 17:02
(Received via mailing list)
I am testing the script on sid. and it freezes!
Gtk::VERSION=[2, 18, 7], Gtk::BINDING_VERSION=[0, 19, 3]. Ruby 1.8.7

I have libgst-ruby1.8 and libgtk2-ruby1.8 packages installed but
neither ruby-gnome2, ruby-gnome2-dev nor libgnome2-ruby1.8.
Which packages do you have installed on your sid ?

aptitude search ruby | grep ^i
i A libatk1-ruby1.8                 - ATK bindings for the Ruby language

i A libcairo-ruby1.8                - Cairo bindings for the Ruby 
language

i A libgdk-pixbuf2-ruby1.8          - Gdk-Pixbuf 2 bindings for the Ruby
languag
i   libgettext-ruby1.8              - Gettext for ruby1.8

i A libglib2-ruby1.8                - Glib 2 bindings for the Ruby 
language

i   libgst-ruby                     - GStreamer bindings for the Ruby
language
i A libgst-ruby1.8                  - GStreamer bindings for the Ruby
language
i   libgtk2-ruby                    - GTK+ bindings for the Ruby 
language

i A libgtk2-ruby1.8                 - GTK+ bindings for the Ruby 
language

i A liblocale-ruby1.8               - pure ruby locale library

i A libpango1-ruby1.8               - Pango bindings for the Ruby 
language

i A libreadline-ruby1.8             - Readline interface for Ruby 1.8

i A libreadline-ruby1.9             - Readline interface for Ruby 1.9

i A libruby                         - Libraries necessary to run Ruby 
1.8.x

i A libruby1.8                      - Libraries necessary to run Ruby 
1.8

i A libruby1.9                      - Libraries necessary to run Ruby 
1.9

i   libtagc0-ruby                   - TagLib Audio Meta-Data Library for
Ruby
i A libtagc0-ruby1.8                - TagLib Audio Meta-Data Library for
Ruby 1.
i   ruby                            - Interpréteur pour le langage de 
script
ori
i   ruby-dev                        - Header files for compiling 
extension
modul
i A ruby1.8                         - Interpreter of object-oriented
scripting l
i A ruby1.8-dev                     - Header files for compiling 
extension
modul
i   ruby1.9
Posted by Simon Arnaud (Guest)
on 2010-03-03 10:19
(Received via mailing list)
2010/3/2 vincent carmona <vinc4mai@gmail.com>:
> I am testing the script on sid. and it freezes!
> Gtk::VERSION=[2, 18, 7], Gtk::BINDING_VERSION=[0, 19, 3]. Ruby 1.8.7
> I have libgst-ruby1.8 and libgtk2-ruby1.8 packages installed but
> neither ruby-gnome2, ruby-gnome2-dev nor libgnome2-ruby1.8.
> Which packages do you have installed on your sid ?
> aptitude search ruby | grep ^i

i A libart2-ruby                    - Libart 2 bindings for the Ruby 
language
i A libart2-ruby1.8                 - Libart 2 bindings for the Ruby 
language
i A libatk1-ruby                    - ATK bindings for the Ruby language
i A libatk1-ruby1.8                 - ATK bindings for the Ruby language
i A libcairo-ruby1.8                - Cairo bindings for the Ruby 
language
i A libgconf2-ruby                  - GConf 2 bindings for the Ruby 
language
i A libgconf2-ruby1.8               - GConf 2 bindings for the Ruby 
language
i A libgdk-pixbuf2-ruby             - Gdk-Pixbuf 2 bindings for the Ruby 
languag
i A libgdk-pixbuf2-ruby1.8          - Gdk-Pixbuf 2 bindings for the Ruby 
languag
i A libgettext-ruby-util            - Gettext utilities for ruby (dummy 
package)
i A libgettext-ruby1.8              - Gettext for ruby1.8
i A libglade2-ruby                  - Libglade 2 bindings for the Ruby 
language
i A libglade2-ruby1.8               - Libglade 2 bindings for the Ruby 
language
i A libglib2-ruby1.8                - Glib 2 bindings for the Ruby 
language
i A libgnome2-ruby                  - GNOME 2 bindings for the Ruby 
language
i A libgnome2-ruby1.8               - GNOME 2 bindings for the Ruby 
language
i A libgnomecanvas2-ruby            - GNOME Canvas 2 bindings for the 
Ruby langu
i A libgnomecanvas2-ruby1.8         - GNOME Canvas 2 bindings for the 
Ruby langu
i A libgnomevfs2-ruby               - GNOME VFS 2 bindings for the Ruby 
language
i A libgnomevfs2-ruby1.8            - GNOME VFS 2 bindings for the Ruby 
language
i   libgst-ruby                     - GStreamer bindings for the Ruby 
language
i A libgst-ruby1.8                  - GStreamer bindings for the Ruby 
language
i   libgstreamer0.10-ruby           - GStreamer 0.10 bindings for the 
Ruby langu
i A libgstreamer0.10-ruby1.8        - GStreamer 0.10 bindings for the 
Ruby langu
i A libgtk-mozembed-ruby            - ruby binding of GtkMozEmbed, gecko 
rendere
i A libgtk-mozembed-ruby1.8         - ruby binding of GtkMozEmbed, gecko 
rendere
i A libgtk2-ruby                    - GTK+ bindings for the Ruby 
language
i A libgtk2-ruby1.8                 - GTK+ bindings for the Ruby 
language
i A libgtkglext1-ruby               - GTK+ GL extension bindings for the 
Ruby la
i A libgtkglext1-ruby1.8            - GTK+ GL extension bindings for the 
Ruby la
i A liblocale-ruby1.8               - pure ruby locale library
i A libopengl-ruby                  - OpenGL binding for Ruby
i A libpanel-applet2-ruby           - GNOME 2 panel applet library 
bindings for
i A libpanel-applet2-ruby1.8        - GNOME 2 panel applet library 
bindings for
i A libpango1-ruby                  - Pango bindings for the Ruby 
language
i A libpango1-ruby1.8               - Pango bindings for the Ruby 
language
i A libreadline-ruby1.8             - Readline interface for Ruby 1.8
i A librsvg2-ruby                   - RSVG renderer bindings for the 
Ruby langua
i A librsvg2-ruby1.8                - RSVG renderer bindings for the 
Ruby langua
i A libruby                         - Libraries necessary to run Ruby 
1.8.x
i A libruby1.8                      - Libraries necessary to run Ruby 
1.8
i   libsqlite3-ruby                 - SQLite3 interface for Ruby
i A libsqlite3-ruby1.8              - SQLite3 interface for Ruby 1.8
i   libtagc0-ruby                   - TagLib Audio Meta-Data Library for 
Ruby
i A libtagc0-ruby1.8                - TagLib Audio Meta-Data Library for 
Ruby 1.
i A libvte-ruby                     - VTE widget bindings for the Ruby 
language
i A libvte-ruby1.8                  - VTE widget bindings for the Ruby 
language
i A ruby                            - Interpréteur pour le langage de 
script ori
i   ruby-gnome2                     - GNOME-related bindings for the 
Ruby langua
i A ruby1.8                         - Interpreter of object-oriented 
scripting l
i   ruby1.8-dev                     - Header files for compiling 
extension modul
i   rubygems                        - package management framework for 
Ruby libr
i A rubygems1.8                     - package management framework for 
Ruby libr
i   rubyripper                      - a digital audio extraction 
algorithm

That's with debian packaged 1.8.7.

I also use 1.9.1 through rvm, and ruby-gnome2-svn compiled from source.

I also have :
$ aptitude search gst | grep ^i
i A bluez-gstreamer                 - Bluetooth GStreamer support
i A gir1.0-gstreamer-0.10           - Description: GObject introspection 
data fo
i   gstreamer-tools                 - Tools for use with GStreamer
i A gstreamer0.10-alsa              - GStreamer plugin for ALSA
i A gstreamer0.10-ffmpeg            - FFmpeg plugin for GStreamer
i   gstreamer0.10-gnonlin           - non-linear editing module for 
GStreamer
i A gstreamer0.10-nice              - ICE library (GStreamer plugin)
i A gstreamer0.10-plugins-bad       - GStreamer plugins from the "bad" 
set
i A gstreamer0.10-plugins-base      - GStreamer plugins from the "base" 
set
i A gstreamer0.10-plugins-good      - GStreamer plugins from the "good" 
set
i A gstreamer0.10-plugins-ugly      - GStreamer plugins from the "ugly" 
set
i A gstreamer0.10-pulseaudio        - GStreamer plugin for PulseAudio
i A gstreamer0.10-tools             - Tools for use with GStreamer
i A gstreamer0.10-x                 - GStreamer plugins for X11 and 
Pango
i   libgst-ruby                     - GStreamer bindings for the Ruby 
language
i A libgst-ruby1.8                  - GStreamer bindings for the Ruby 
language
i A libgstfarsight0.10-0            - Audio/Video communications 
framework: core
i A libgstreamer-plugins-base0.10-0 - GStreamer libraries from the 
"base" set
i   libgstreamer-plugins-base0.10-d - GStreamer development files for 
libraries
i A libgstreamer0.10-0              - Core GStreamer libraries and 
elements
i   libgstreamer0.10-dev            - GStreamer core development files
i   libgstreamer0.10-ruby           - GStreamer 0.10 bindings for the 
Ruby langu
i A libgstreamer0.10-ruby1.8        - GStreamer 0.10 bindings for the 
Ruby langu
i A python-gst0.10                  - generic media-playing framework 
(Python bi

I also go through a squid proxy. If I disable the proxy, it freezes, 
obviously.

If you need more info, tell me.

Simon
Posted by Vincent Carmona (vinc-mai)
on 2010-03-03 20:23
(Received via mailing list)
2010/3/3, Simon Arnaud <mazwak@gmail.com>:
>
> I also go through a squid proxy. If I disable the proxy, it freezes,
> obviously.
>

If you disable the proxy, GStreamer freeze cause it cannot reach the
stream anymore.  Does it also freeze the gui ?

    Vincent
Posted by Vincent Carmona (vinc-mai)
on 2010-03-04 07:13
(Received via mailing list)
The bug may be thread related.
If the play method of the playbin is called inside a thread the gui
does not freeze. :)
But if I use the join method on the thread the gui freezes.
I was think at using a thread as a workaround.
Gtk and threads are not good friend. Can I just call the play method
on a thread?

I hope someone will have an idea on why that bug occurs.
============================================================
require 'gtk2'
require 'gst'

class Player
  def initialize
    @playbin=Gst::ElementFactory.make('playbin')
    @playbin.ready
  end

  def stop
    @playbin.stop
  end

  def play
    #@playbin.uri='file:///home/instable/Musique/01 - Blue Bird.mp3'
    @playbin.uri='http://mp3.live.tv-radio.com/centpourcent/all/centpourcent-128k.mp3'
    p "Going to play..."
    Thread.new{@playbin.play; p "Playing."}#.join
  end
end

class Gui
  def initialize(player)
    @player=player
    @bstop=Gtk::Button.new('Stop')
    @bstop.signal_connect('clicked'){@player.stop}
    @bplay=Gtk::Button.new('Play')
    @bplay.signal_connect('clicked'){@player.play}
    @box=Gtk::HBox.new
    @box.pack_start(@bstop)
    @box.pack_start(@bplay)
    @window=Gtk::Window.new
    @window.add(@box)
    @window.show_all
    @window.signal_connect("delete_event"){Gtk.main_quit; true}
  end
end

player=Player.new
gui=Gui.new(player)
Gtk.main
===============================================================
Posted by Vincent Carmona (vinc-mai)
on 2010-03-04 08:12
(Received via mailing list)
Apparently the freeze is caused by the souphttpsrc element.
(If I replace the playbin by a simple souphttpsrc element the freeze
still occurs)

On ubuntu I use the 0.10.16-1ubuntu3 version of
gstreamer0.10-plugins-good. Simon can you post yours ?

Maybe I do not have a freeze because of your proxy.
In souphttpsrc sources, code differs whether there is a proxy or not.
http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/ext/soup/gstsouphttpsrc.c#n1239

Maybe I should file GStremear bug.

2010/3/4, vincent carmona <vinc4mai@gmail.com>:
Posted by Simon Arnaud (Guest)
on 2010-03-04 09:36
(Received via mailing list)
2010/3/4 vincent carmona <vinc4mai@gmail.com>:
> If you disable the proxy, GStreamer freeze cause it cannot reach the
> stream anymore.  Does it also freeze the gui ?

Yes

> On ubuntu I use the 0.10.16-1ubuntu3 version of
> gstreamer0.10-plugins-good. Simon can you post yours ?

Paquet : gstreamer0.10-plugins-good
Version : 0.10.18-1

Paquet : libsoup2.4-1
Version : 2.29.91-1

You might want to test it in Python/Perl, or vala maybe.

good luck
Posted by Vincent Carmona (vinc-mai)
on 2010-03-04 10:50
(Received via mailing list)
I know none of these languages. Ruby is the only one I am used to.
Python is close to ruby maybe I can translate my bug. I suppose it
have a Gtk and a Gstreamer libraries. I have not be able to reproduce
the bug with only ruby/gst.

Thanks for your precious help.

    Vincent.

2010/3/4, Simon Arnaud <mazwak@gmail.com>:
Posted by Vincent Carmona (vinc-mai)
on 2010-03-06 06:19
(Received via mailing list)
I have test this radio with python. There is no freeze.

I am guessing that the "bug " is in ruby libraries. Maybe I should
open a bug on ruby-gnome tracker. What do you think ?

   Vincent

2010/3/4, vincent carmona <vinc4mai@gmail.com>:
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.