Skip to content

Commit

Permalink
Throw exception when pa_stream_new fails
Browse files Browse the repository at this point in the history
Throw an exception with the pulseaudio errno when pa_stream_new
fails to set up a stream. This could be handled by the application
using SoundCard.

Signed-off-by: Rik van Riel <riel@surriel.com>
  • Loading branch information
rikvanriel committed Aug 1, 2020
1 parent f252ddd commit 0ec0197
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions soundcard/pulseaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,9 @@ def __enter__(self):
raise RuntimeError('invalid channel map')

self.stream = _pulse._pa_stream_new(_pulse.context, self._name.encode(), samplespec, channelmap)
if not self.stream:
errno = _pulse._pa_context_errno(_pulse.context)
raise RuntimeError("stream creation failed with error ", errno)
bufattr = _ffi.new("pa_buffer_attr*")
bufattr.maxlength = 2**32-1 # max buffer length
numchannels = self.channels if isinstance(self.channels, int) else len(self.channels)
Expand Down

0 comments on commit 0ec0197

Please sign in to comment.