python, appsrc, signal "need-data" emitted only once

Jan Martinek honza at
Tue May 30 10:18:10 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 

import gobject
import gst, gtk
import random

class Sound:
     def __init__(self):
         self.player = gst.parse_launch('''appsrc name=source ! 
caps=audio/x-raw-int,rate=44100,channels=2,depth=16,signed=true ! 
         playersrc = self.player.get_by_name('source')
         playersrc.connect('need-data', self.needdata)

     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

More information about the gstreamer-devel mailing list