gst1: Fail if trying to create buffers without audio

Which causes lots of failed assertion messages from GStreamer
This commit is contained in:
Stein Magnus Jodal 2015-12-04 13:52:05 +01:00
parent ef5281488b
commit 7926ef1f12
2 changed files with 9 additions and 0 deletions

View File

@ -28,6 +28,9 @@ def create_buffer(data, capabilites=None, timestamp=None, duration=None):
.. versionchanged:: 1.2
``capabilites`` argument is no longer in use
"""
if not data:
raise ValueError(
'Cannot create buffer without data: length=%d' % len(data))
buffer_ = Gst.Buffer.new_wrapped(data)
if timestamp is not None:
buffer_.pts = timestamp

View File

@ -23,6 +23,12 @@ class TestCreateBuffer(object):
assert buf.duration == 1000000
assert buf.get_size() == len(b'123')
def test_fails_if_data_has_zero_length(self):
with pytest.raises(ValueError) as excinfo:
utils.create_buffer(b'', timestamp=0, duration=1000000)
assert 'Cannot create buffer without data' in str(excinfo.value)
# TODO: keep ids without name?
# TODO: current test is trying to test everything at once with a complete tags