Fix tests.

looper
Ben Niemann 2016-07-03 19:50:13 +02:00
parent 1725db8075
commit 896a3e53bb
5 changed files with 37 additions and 25 deletions

View File

@ -16,8 +16,8 @@ class Scale(Node):
desc.port('out', 'output', 'audio')
desc.parameter('factor', 'float')
def __init__(self, factor):
super().__init__('scale(%.2f)' % factor)
def __init__(self, event_loop, factor):
super().__init__(event_loop, name='scale(%.2f)' % factor)
self._input = AudioInputPort('in')
self.add_input(self._input)

View File

@ -16,7 +16,7 @@ class ScaleTest(asynctest.TestCase):
source = WhiteNoiseSource()
pipeline.add_node(source)
node = scale.Scale(0.5)
node = scale.Scale(self.loop, 0.5)
pipeline.add_node(node)
node.inputs['in'].connect(source.outputs['out'])
await node.setup()

View File

@ -51,7 +51,6 @@ class TestProjectProcess(
project_process.ProjectProcessMixin, TestProjectProcessImpl):
pass
class ProxyTest(asynctest.TestCase):
async def setUp(self):
self.project_process = TestProjectProcess(self.loop)

View File

@ -62,7 +62,9 @@ class ProjectProcessMixin(object):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.audioproc_address = None
self.audioproc_client = None
self.audiostream_address = None
async def setup(self):
await super().setup()
@ -82,17 +84,10 @@ class ProjectProcessMixin(object):
self.sessions = {}
self.pending_mutations = []
self.audioproc_address = await self.manager.call(
'CREATE_AUDIOPROC_PROCESS', 'project-%s' % id(self))
self.audioproc_client = AudioProcClient(
self.event_loop, self.server)
await self.audioproc_client.setup()
await self.audioproc_client.connect(self.audioproc_address)
await self.createAudioProcProcess()
nid = await self.audioproc_client.add_node('wavfile', path='/usr/share/sounds/purple/logout.wav', loop=True)
await self.audioproc_client.connect_ports(nid, 'out', 'sink', 'in')
self.audiostream_address = await self.audioproc_client.set_backend('ipc')
async def createAudioProcProcess(self):
pass
async def cleanup(self):
if self.audioproc_client is not None:
@ -247,4 +242,16 @@ class ProjectProcessMixin(object):
class ProjectProcess(ProjectProcessMixin, core.ProcessImpl):
pass
async def createAudioProcProcess(self):
self.audioproc_address = await self.manager.call(
'CREATE_AUDIOPROC_PROCESS', 'project-%s' % id(self))
self.audioproc_client = AudioProcClient(
self.event_loop, self.server)
await self.audioproc_client.setup()
await self.audioproc_client.connect(self.audioproc_address)
nid = await self.audioproc_client.add_node('wavfile', path='/usr/share/sounds/purple/logout.wav', loop=True)
await self.audioproc_client.connect_ports(nid, 'out', 'sink', 'in')
self.audiostream_address = await self.audioproc_client.set_backend('ipc')

View File

@ -121,16 +121,7 @@ class BaseEditorApp(QApplication):
self.show_edit_areas_action.setChecked(
int(self.settings.value('dev/show_edit_areas', '0')))
self.audioproc_process = await self.process.manager.call(
'CREATE_AUDIOPROC_PROCESS', 'main')
self.audioproc_client = AudioProcClient(
self.process.event_loop, self.process.server)
await self.audioproc_client.setup()
await self.audioproc_client.connect(self.audioproc_process)
await self.audioproc_client.set_backend(
self.settings.value('audio/backend', 'pyaudio'))
await self.createAudioProcProcess()
async def cleanup(self):
logger.info("Cleaning up.")
@ -161,6 +152,9 @@ class BaseEditorApp(QApplication):
def createMidiHub(self):
return devices.MidiHub(self.sequencer)
async def createAudioProcProcess(self):
pass
def dumpSettings(self):
for key in self.settings.allKeys():
value = self.settings.value(key)
@ -284,3 +278,15 @@ class EditorApp(BaseEditorApp):
# and the console interprets it as UTF-8), 'aconnectgui' shows the
# encoded bytes.
return devices.AlsaSequencer('noisicaä')
async def createAudioProcProcess(self):
self.audioproc_process = await self.process.manager.call(
'CREATE_AUDIOPROC_PROCESS', 'main')
self.audioproc_client = AudioProcClient(
self.process.event_loop, self.process.server)
await self.audioproc_client.setup()
await self.audioproc_client.connect(self.audioproc_process)
await self.audioproc_client.set_backend(
self.settings.value('audio/backend', 'pyaudio'))