Skip to content
Snippets Groups Projects
Commit 32e5c1eb authored by Chad Hanna's avatar Chad Hanna
Browse files

hoftcache.py: 1.0 port

parent 6a538b65
No related branches found
No related tags found
No related merge requests found
......@@ -32,13 +32,11 @@ import sys
import tempfile
import pygtk
pygtk.require("2.0")
import gobject
gobject.threads_init()
import pygst
pygst.require("0.10")
import gst
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
GObject.threads_init()
Gst.init(None)
from gstlal import datasource
......@@ -116,7 +114,7 @@ class Handler(simplehandler.Handler):
self.cache = tempcache()
def do_on_message(self, bus, message):
if message.type == gst.MESSAGE_ELEMENT and message.structure.get_name() == "GstMultiFileSink":
if message.type == Gst.MessageType.ELEMENT and message.structure.get_name() == "GstMultiFileSink":
self.cache.append(pipeparts.framecpp_filesink_cache_entry_from_mfs_message(message))
return True
return False
......@@ -142,8 +140,8 @@ def mkbasicsrc(pipeline, gw_data_source_info, instrument, verbose = False):
demux = pipeparts.mkframecppchanneldemux(pipeline, src, do_file_checksum = True, channel_list = map("%s:%s".__mod__, gw_data_source_info.channel_dict.items()))
pipeparts.framecpp_channeldemux_set_units(demux, dict.fromkeys(demux.get_property("channel-list"), "strain"))
# allow frame reading and decoding to occur in a diffrent thread
src = pipeparts.mkqueue(pipeline, None, max_size_buffers = 0, max_size_bytes = 0, max_size_time = 8 * gst.SECOND)
pipeparts.src_deferred_link(demux, "%s:%s" % (instrument, gw_data_source_info.channel_dict[instrument]), src.get_pad("sink"))
src = pipeparts.mkqueue(pipeline, None, max_size_buffers = 0, max_size_bytes = 0, max_size_time = 8 * Gst.SECOND)
pipeparts.src_deferred_link(demux, "%s:%s" % (instrument, gw_data_source_info.channel_dict[instrument]), src.get_static_pad("sink"))
# FIXME: remove this when pipeline can handle disconts
src = pipeparts.mkaudiorate(pipeline, src, skip_to_first = True, silent = False)
else:
......@@ -160,7 +158,7 @@ def mkbasicsrc(pipeline, gw_data_source_info, instrument, verbose = False):
if gw_data_source_info.injection_filename is not None:
src = pipeparts.mkinjections(pipeline, src, gw_data_source_info.injection_filename)
# let the injection code run in a different thread than the whitener, etc.,
src = pipeparts.mkqueue(pipeline, src, max_size_bytes = 0, max_size_buffers = 0, max_size_time = gst.SECOND * 64)
src = pipeparts.mkqueue(pipeline, src, max_size_bytes = 0, max_size_buffers = 0, max_size_time = Gst.SECOND * 64)
# seek the pipeline
# FIXME: remove
......@@ -200,9 +198,9 @@ def build_pipeline(pipeline, data_source_info, output_path = tempfile.gettempdir
if sample_rate is not None:
# make sure we're *down*sampling
src = pipeparts.mkcapsfilter(pipeline, src, "audio/x-raw-float, rate=[%d,MAX]" % sample_rate)
src = pipeparts.mkcapsfilter(pipeline, src, "audio/x-raw, rate=[%d,MAX]" % sample_rate)
src = pipeparts.mkresample(pipeline, src, quality = 9)
src = pipeparts.mkcapsfilter(pipeline, src, "audio/x-raw-float, rate=%d" % sample_rate)
src = pipeparts.mkcapsfilter(pipeline, src, "audio/x-raw, rate=%d" % sample_rate)
#
# pack into frame files for output
......@@ -231,8 +229,8 @@ def cache_hoft(data_source_info, channel_comment = "cached h(t) for inspiral sea
#
mainloop = gobject.MainLoop()
pipeline = gst.Pipeline("pipeline")
mainloop = GObject.MainLoop()
pipeline = Gst.Pipeline(name="pipeline")
handler = Handler(mainloop, pipeline)
......@@ -250,7 +248,7 @@ def cache_hoft(data_source_info, channel_comment = "cached h(t) for inspiral sea
if verbose:
print >>sys.stderr, "setting pipeline state to playing ..."
if pipeline.set_state(gst.STATE_PLAYING) != gst.STATE_CHANGE_SUCCESS:
if pipeline.set_state(Gst.State.PLAYING) != Gst.StateChangeReturn.SUCCESS:
raise RuntimeError("pipeline did not enter playing state")
if verbose:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment