python, appsrc, signal "need-data" emitted only once
Jan Martinek
honza at dp.fce.vutbr.cz
Tue May 30 10:02:28 UTC 2017
Hi everyone,
some time ago (2009?) I wrote a couple of Python scripts playing some
generated waveform on the speakers. It used to work fine.
Now my programs are obsolete and do not work. I made a very simplified
example:
------------------------
#!/usr/bin/python
import gobject
gobject.threads_init()
import gst, gtk
import random
class Sound:
def __init__(self):
self.player = gst.parse_launch('''appsrc name=source !
capsfilter
caps=audio/x-raw-int,rate=44100,channels=2,depth=16,signed=true !
gconfaudiosink''')
playersrc = self.player.get_by_name('source')
playersrc.connect('need-data', self.needdata)
self.player.set_state(gst.STATE_PLAYING)
gtk.main()
def needdata(self, src, length):
print 'need-data:', length
data = ''
for i in range(length):
data = data + chr(random.randint(0, 255))
src.emit('push-buffer', gst.Buffer(data))
sa = Sound()
-----------------
This should produce a noise from random data. It does not work because
"need-data" signal is called only once.
On the old system it plays a noise. Is is possible to make it work?
Thank you
Jan
More information about the gstreamer-devel
mailing list