Skip to content

Commit

Permalink
module_load: check return index value for PA_INVALID and raise PulseE…
Browse files Browse the repository at this point in the history
…rror for those
  • Loading branch information
mk-fg committed Sep 7, 2021
1 parent 6661f2c commit 8d806c8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ PulseVolumeInfo can be constructed from a numeric volume value plus number of
channels, or a python list of per-channel numbers.

All per-channel volume values in PulseVolumeInfo (and flat values in the wrapper
funcs above), are float objects in 0-65536 range, with following meaning:
funcs above), are float objects in 0-65536 range, with following meanings:

* 0.0 volume is "no sound" (corresponds to PA_VOLUME_MUTED).

Expand Down
2 changes: 2 additions & 0 deletions pulsectl/pulsectl.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ def module_load(self, name, args=''):
try: c.pa.context_load_module(self._ctx, name, args, cb, None)
except c.pa.CallError as err: raise PulseOperationInvalid(err.args[-1])
index, = data
if index == c.PA_INVALID:
raise PulseError('Failed to load module: {} {}'.format(name, args))
return index

module_unload = _pulse_method_call(c.pa.context_unload_module, None)
Expand Down
3 changes: 3 additions & 0 deletions pulsectl/tests/test_with_dummy_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,9 @@ def test_module_funcs(self):
self.assertEqual(len(pulse.sink_list()), 3)
pulse.module_unload(idx)
self.assertEqual(len(pulse.sink_list()), 2)
with self.assertRaises(pulsectl.PulseError):
pulse.module_load('module-that-does-not-exist')
self.assertEqual(len(pulse.sink_list()), 2)

def test_stream(self):
with pulsectl.Pulse('t', server=self.sock_unix) as pulse:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
setup(

name = 'pulsectl',
version = '21.5.18',
version = '21.9.0',
author = 'George Filipkin, Mike Kazantsev',
author_email = 'mk.fraggod@gmail.com',
license = 'MIT',
Expand Down

0 comments on commit 8d806c8

Please sign in to comment.