Skip to content

Commit

Permalink
Merge pull request #105 from rikvanriel/master
Browse files Browse the repository at this point in the history
avoid garbage collection related stream creation failure
  • Loading branch information
bastibe authored Aug 14, 2020
2 parents 878ad90 + 351094b commit 97a9f2b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions soundcard/pulseaudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,8 +644,10 @@ def __enter__(self):
if not _pulse._pa_sample_spec_valid(samplespec):
raise RuntimeError('invalid sample spec')

channelmap = _ffi.new("pa_channel_map*")
channelmap = _pa.pa_channel_map_init_auto(channelmap, samplespec.channels, _pa.PA_CHANNEL_MAP_DEFAULT)
# pam and channelmap refer to the same object, but need different
# names to avoid garbage collection trouble on the Python/C boundary
pam = _ffi.new("pa_channel_map*")
channelmap = _pa.pa_channel_map_init_auto(pam, samplespec.channels, _pa.PA_CHANNEL_MAP_DEFAULT)
if isinstance(self.channels, collections.Iterable):
for idx, ch in enumerate(self.channels):
channelmap.map[idx] = ch+1
Expand Down

0 comments on commit 97a9f2b

Please sign in to comment.