From ea690fa9166276ce77b944544de8a4b34b6f9b20 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Tue, 6 Dec 2011 17:01:19 -0800 Subject: [PATCH] timeside/decoder/core.py: move mainloop to its own thread to avoid memory hogging on large files --- timeside/decoder/core.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/timeside/decoder/core.py b/timeside/decoder/core.py index c258f8f..06a14a8 100644 --- a/timeside/decoder/core.py +++ b/timeside/decoder/core.py @@ -98,7 +98,22 @@ class FileDecoder(Processor): # start pipeline self.pipeline.set_state(gst.STATE_PLAYING) - self.mainloop.run() + + # self.mainloop.run() + # NOTE: instead of running the mainloop on the main thread, put it in a + # thread so that the main thread start calling process and pull from + # buffers from timesidesink + + import threading + class MainloopThread(threading.Thread): + def __init__(self, mainloop): + threading.Thread.__init__(self) + self.mainloop = mainloop + + def run(self): + self.mainloop.run() + self.mainloopthread = MainloopThread(self.mainloop) + self.mainloopthread.start() def source_pad_added_cb(self, src, pad): name = pad.get_caps()[0].get_name() @@ -108,6 +123,7 @@ class FileDecoder(Processor): def on_eos(self, bus, msg): #print 'on_eos' + self.sink.on_eos() self.pipeline.set_state(gst.STATE_NULL) self.mainloop.quit() @@ -151,7 +167,7 @@ class FileDecoder(Processor): @interfacedoc def release(self): - # nothing to do for now + self.mainloopthread.join() pass ## IDecoder methods -- 2.39.5