Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Python + Gstreamer Error
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
regomodo
Guru
Guru


Joined: 25 Mar 2008
Posts: 445

PostPosted: Sun Nov 22, 2009 5:07 pm    Post subject: [Solved] Python + Gstreamer Error Reply with quote

Hi i'm developing an app and i'm having a problem using gstreamer's playbin2 for gapless playback. When it works, it's fine, but it rarely does and usually stops and spits out an error over Stderr which I cannot fathom out.


Code:
 (Gereqi.py:10211): CRITICAL : deactivate_group: assertion `group->active' failed


What I find weird is that on amd64 I _always_ get this error whereas on x86 I _usually_ do.

Does anybody know what it means? None of the words, apart from "Gereqi" which is the app-name, is relevant name-wise to the code.


Last edited by regomodo on Mon Nov 23, 2009 9:35 am; edited 1 time in total
Back to top
View user's profile Send private message
didumos
Guru
Guru


Joined: 19 Jan 2006
Posts: 322
Location: uk

PostPosted: Sun Nov 22, 2009 7:27 pm    Post subject: Reply with quote

The first thing that springs to mind after looking at the code is that you are emitting a signal from the about-to-finish callback so that you can handle it, whereas GStreamer expects the new uri to be set as soon as that callback returns. I'm not familiar with Qt's signals but I'm assuming that there may be some small delay between this signal being emitted and being handled, by which time GStreamer may have moved on and assumed that no new uri was being set.

It would also be handy if you could put together a simpler example that still exhibits the same problem - this may help narrow it down to either a bug with your code or a bug in pyGst/GStreamer. :)
Back to top
View user's profile Send private message
regomodo
Guru
Guru


Joined: 25 Mar 2008
Posts: 445

PostPosted: Sun Nov 22, 2009 8:11 pm    Post subject: Reply with quote

Quote:
whereas GStreamer expects the new uri to be set as soon as that callback returns

I've just had a look at the class reference (for c++, there's none for Python) and I see this

Code:
The "uri" property
  "uri"                      gchar*                : Read / Write
 Set the next URI that playbin will play. This property can be set from the about-to-finish signal to queue the next media file.
Default value: NULL


I've noticed that there's a substantial gap (~1sec) usually from the "about-to-finish" signal to the EOS message from gstreamer so i was assuming that timing wasn't an issue.

I also had a look at quod-libet's implementation, also called gstbe.py, and found it extremely hard to get my head around. What I could figure out was that the playlist/queue-list which is used with their "ab2fin" signal is some kind of dict/list. I'll try that method in a small example using the backend i've made.

I apologise if you tried to make sense of "interface.py" at my repo. I'm quite ashamed of that mess.
Back to top
View user's profile Send private message
didumos
Guru
Guru


Joined: 19 Jan 2006
Posts: 322
Location: uk

PostPosted: Sun Nov 22, 2009 8:33 pm    Post subject: Reply with quote

regomodo wrote:
I've noticed that there's a substantial gap (~1sec) usually from the "about-to-finish" signal to the EOS message from gstreamer so i was assuming that timing wasn't an issue.

This is just a guess but that apparent delay may just be because of GStreamer's internal queues/buffers. So, you get the about-to-finish signal early because it needs to start decoding the next track and pushing audio to the buffers before they empty, otherwise it wouldn't sound like it was gapless :)

I'll have a go at installing Qt and PyQt4 so I can try and reproduce the problem.
Back to top
View user's profile Send private message
didumos
Guru
Guru


Joined: 19 Jan 2006
Posts: 322
Location: uk

PostPosted: Mon Nov 23, 2009 12:11 am    Post subject: Reply with quote

Ok, I was able to reproduce the problem pretty consistently and I think my hunch may have been correct. Connecting straight from the "about-to-finish" signal to the callback function in interface.py, rather than emitting another signal from gstbe.py, seems to have solved it. Here is the relevant diff so you can give it a go yourself :D
Code:
diff --git a/ui/gstbe.py b/ui/gstbe.py
index 99dada8..7e623f2 100644
--- a/ui/gstbe.py
+++ b/ui/gstbe.py
@@ -143,7 +143,6 @@ class Player(Actions, Queries, QObject):
         gobject.threads_init() # V.Important
 
         self.pipe_line = gst.element_factory_make("playbin2", "player")
-        self.pipe_line.connect("about-to-finish",  self.__about_to_finish)
         self.pipe_line.connect("audio-changed",  self.__audio_changed)
 
         self.pipe_line.set_property('video-sink', None)
@@ -159,14 +158,6 @@ class Player(Actions, Queries, QObject):
         self.pipe_source = None       
         self.play_thread_id = None
             
-    def __about_to_finish(self, pipeline):
-        """
-        Emit a signal implying a track is needed
-        for gapless playback
-        """
-        print("ABOUT TO FINISH", pipeline)
-        self.emit(SIGNAL("about_to_finish()")) 
-   
     def __audio_changed(self, pipeline):
         print("AUDIO CHANGED", pipeline)
         self.emit(SIGNAL("track_changed()"))
diff --git a/ui/interface.py b/ui/interface.py
index 9a34c3f..4e1e6e1 100755
--- a/ui/interface.py
+++ b/ui/interface.py
@@ -57,8 +57,8 @@ class MainWindow(Setups, Finishes, QMainWindow):
         self.playlist_add_menu()
         self.create_tray_menu()
 
+        self.playbin.pipe_line.connect("about-to-finish",  self.about_to_finish)
         self.connect(self.playbin, SIGNAL("tick ( int )"), self.prog_tick)
-        self.connect(self.playbin, SIGNAL("about_to_finish()"), self.about_to_finish)
         self.connect(self.playbin, SIGNAL("track_changed()"), self.__track_changed)
         self.connect(self.playbin, SIGNAL("finished()"), self.__finished_playing)
         
@@ -516,11 +516,12 @@ class MainWindow(Setups, Finishes, QMainWindow):
         self.old_pos = time
 
 #TODO: increment the playcount in DB
-    def about_to_finish(self):
+    def about_to_finish(self, pipeline):
         """
         Generates a track to go into queue
         before playback stops
         """
+        print("ABOUT TO FINISH", pipeline)
         track = self.generate_track("next")
         #Not at end of  playlist
         if track:

I'm sure there is a more elegant solution but Python isn't quite my forte, all those self.blah statements make my head spin :P
Back to top
View user's profile Send private message
regomodo
Guru
Guru


Joined: 25 Mar 2008
Posts: 445

PostPosted: Mon Nov 23, 2009 8:21 am    Post subject: Reply with quote

@didimos

Cheer's. I haven't given that a go but I never thought to get the playbin2 message directly rather than creating a PyQt4 signal as well. The main reason why I did it that way was to make it similar to Phonon's API to ease the transition from Phonon to straight Gstreamer.

I'm really busy with other stuff atm but will give it a go later.
Back to top
View user's profile Send private message
regomodo
Guru
Guru


Joined: 25 Mar 2008
Posts: 445

PostPosted: Mon Nov 23, 2009 9:35 am    Post subject: Reply with quote

@ didumos

I put off other stuff and applied the patch. For some reason "git apply --check $PATCHFILE" produced errors so I did the changes manually.

THANK YOU! I spent the best part of a week scouring the web and doing a lot of trial and error and finally have this issue fixed. Awesome!
Back to top
View user's profile Send private message
didumos
Guru
Guru


Joined: 19 Jan 2006
Posts: 322
Location: uk

PostPosted: Mon Nov 23, 2009 9:46 am    Post subject: Reply with quote

regomodo wrote:
@ didumos

I put off other stuff and applied the patch. For some reason "git apply --check $PATCHFILE" produced errors so I did the changes manually.

THANK YOU! I spent the best part of a week scouring the web and doing a lot of trial and error and finally have this issue fixed. Awesome!

No problem :D although I'm sure I did screw the patch up, I'm still quite new to Git and haven't done anything with diffs/patches before.
Back to top
View user's profile Send private message
regomodo
Guru
Guru


Joined: 25 Mar 2008
Posts: 445

PostPosted: Mon Nov 23, 2009 11:07 am    Post subject: Reply with quote

I'd no idea how to apply a patch in Git either. I followed a tutorial and I may have got something wrong.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum