Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
joextodd committed Apr 9, 2018
1 parent f35f9f2 commit 669bbdb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
8 changes: 0 additions & 8 deletions pysoundio/pysoundio.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,6 @@ def _create_input_ring_buffer(self, capacity):
by default.
"""
self.input_buffer = soundio.input_ring_buffer_create(capacity)
if not self.input_buffer:
raise PySoundIoError('Failed to create ring buffer')
return self.input_buffer

def _create_output_ring_buffer(self, capacity):
Expand All @@ -408,17 +406,13 @@ def _create_output_ring_buffer(self, capacity):
by default.
"""
self.output_buffer = soundio.output_ring_buffer_create(capacity)
if not self.output_buffer:
raise PySoundIoError('Failed to create ring buffer')
return self.output_buffer

def _create_input_stream(self):
"""
Allocates memory and sets defaults for input stream
"""
self.input_stream = soundio.instream_create(self.input_device)
if not self.input_stream:
raise PySoundIoError('Could not create input stream')

pyinstream = _ctypes.cast(self.input_stream, _ctypes.POINTER(SoundIoInStream))
soundio.set_read_callback(self._read_callback)
Expand Down Expand Up @@ -572,8 +566,6 @@ def _create_output_stream(self):
Allocates memory and sets defaults for output stream
"""
self.output_stream = soundio.outstream_create(self.output_device)
if not self.output_stream:
raise PySoundIoError('Could not create output stream')

pystream = _ctypes.cast(self.output_stream, _ctypes.POINTER(SoundIoOutStream))
if not self.testing:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
author='Joe Todd',
author_email='joextodd@gmail.com',
url='http://pysoundio.readthedocs.io/en/latest/',
download_url = 'https://github.com/joextodd/pysoundio/archive/' + version.group(1) + '.tar.gz',
download_url='https://github.com/joextodd/pysoundio/archive/' + version.group(1) + '.tar.gz',
packages=['pysoundio'],
ext_modules=[soundio],
test_suite='tests',
Expand Down
5 changes: 3 additions & 2 deletions tests/test_pysoundio.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def tearDownClass(cls):
cls.sio.close()

def setUp(self):
self.sio = pysoundio.PySoundIo(
backend=pysoundio.SoundIoBackendDummy)
self.sio.channels = 2
self.sio.sample_rate = 44100
self.sio.format = pysoundio.SoundIoFormatFloat32LE
Expand Down Expand Up @@ -336,6 +334,9 @@ def setUp(self):
self.sio.testing = True
self.callback_called = False

def tearDown(self):
self.sio.close()

def callback(self, data, length):
self.callback_called = True

Expand Down
14 changes: 10 additions & 4 deletions tests/test_soundiox.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ def test_instream_start(self):
soundio.instream_open()
self.assertEqual(soundio.instream_start(), 0)

def test_instream_pause(self):
self.setup_stream()
soundio.instream_open()
self.assertEqual(soundio.instream_pause(True), 0)

def test_instream_get_latency(self):
self.setup_stream()
soundio.instream_open()
Expand All @@ -185,12 +190,8 @@ def tearDown(self):
soundio.disconnect()
soundio.destroy()

def callback(self):
pass

def setup_stream(self):
self.outstream = soundio.outstream_create(self.device)
soundio.set_write_callback(self.callback)
outstream = ctypes.cast(self.outstream, ctypes.POINTER(pysoundio.SoundIoOutStream))
outstream.contents.format = soundio.SoundIoFormatFloat32LE
outstream.contents.sample_rate = 44100
Expand All @@ -208,6 +209,11 @@ def test_outstream_open(self):
# soundio.outstream_open()
# self.assertEqual(soundio.outstream_start(), 0)

def test_outstream_pause(self):
self.setup_stream()
soundio.outstream_open()
self.assertEqual(soundio.outstream_pause(True), 0)

def test_outstream_get_latency(self):
self.setup_stream()
soundio.outstream_open()
Expand Down

0 comments on commit 669bbdb

Please sign in to comment.