From: EmbeddedMicro <ju...@em...> - 2009-05-05 22:58:27
|
I need an equivalent to gst_clock_id_wait_async() for python. I need to reproduce these lines from gst-plugins-good/tests/examples/spectrum/demo-audiotest.c gst_clock_id_wait_async (clock_id, delayed_spectrum_update, (gpointer) spect); gst_clock_id_unref (clock_id); Here is what I have import rb > import gst > import serial > > class LEDcube(rb.Plugin): > > def activate(self, shell): > self.max = -60 > self.spectrum = gst.element_factory_make("spectrum") > self.spectrum.set_property('bands',70) > self.spectrum.set_property('interval',10000000) > self.spectrum.set_property('threshold',-50) > > player = shell.get_player().props.player > player.add_filter(self.spectrum) > > bus = player.props.bus > > if bus is None: > self.bus_id = player.connect('notify::bus', self.bus_notify) > else: > self.bus_id = player.props.bus.connect('message', self.on_message) > > self.ser = serial.Serial('/dev/ttyS0', 115200, timeout=1) > > def deactivate(self, shell): > player = shell.get_player().props.player > > player.remove_filter(self.spectrum) > player.props.bus.disconnect(self.bus_id) > self.bus_id = 0 > > def bus_notify(self, obj, pspec): > obj.disconnect(self.bus_id) > self.bus_id = obj.props.bus.connect('message', self.on_message) > > def on_message(self, bus, message): > clock = self.spectrum.get_clock() > if message.src == self.spectrum and > message.structure.has_key('magnitude') and clock: > magnitudes = message.structure['magnitude'] > time = message.structure['running-time'] + > message.structure['duration'] > > clock_id = clock.new_single_shot_id(time + > self.spectrum.get_base_time()) > > clock_id.wait_async() #NEED SOMETHING LIKE THIS > clock_id.unref() > > self.ser.write("\x35") > for i in range(0, 27): > mag = (50 + int(round(magnitudes[i]))) * 1.4 > > red = (mag * mag / 25) + 1 > green = ((50 - mag) * mag / 25) + 1 > > if red > 51: > red = 51 > if green > 51: > green = 51 > > self.ser.write(chr(int(round(red)))) > self.ser.write(chr(int(round(green)))) Thanks, Justin -- View this message in context: http://www.nabble.com/gst_clock_id_wait_async-equivalent-in-Python-tp23397394p23397394.html Sent from the GStreamer-devel mailing list archive at Nabble.com. |