Cleanup some debug print statements --> logging interface

This commit is contained in:
Anne de Jong 2021-05-08 15:03:57 +02:00
parent e72e9154aa
commit b031dfb280
3 changed files with 8 additions and 8 deletions

View File

@ -6,5 +6,6 @@ from .lasp_imptube import *
from .lasp_measurement import * from .lasp_measurement import *
from .lasp_octavefilter import * from .lasp_octavefilter import *
from .lasp_slm import * from .lasp_slm import *
from .lasp_record import *
from .lasp_siggen import * from .lasp_siggen import *
from .lasp_weighcal import * from .lasp_weighcal import *

View File

@ -5,6 +5,7 @@ from .lasp_daqconfig cimport DaqConfiguration
from cpython.ref cimport PyObject,Py_INCREF, Py_DECREF from cpython.ref cimport PyObject,Py_INCREF, Py_DECREF
import numpy as np import numpy as np
import logging
__all__ = ['Daq'] __all__ = ['Daq']
@ -82,7 +83,7 @@ cdef void audioCallbackPythonThreadFunction(void* voidsd) nogil:
callback = <object> sd.pyCallback callback = <object> sd.pyCallback
# print(f'Number of input channels: {ninchannels}') # print(f'Number of input channels: {ninchannels}')
# print(f'Number of out channels: {noutchannels}') # print(f'Number of out channels: {noutchannels}')
fprintf(stderr, 'Sleep time: %d us\n', sleeptime_us) # fprintf(stderr, 'Sleep time: %d us\n', sleeptime_us)
while not sd.stopThread.load(): while not sd.stopThread.load():
with gil: with gil:
@ -103,7 +104,7 @@ cdef void audioCallbackPythonThreadFunction(void* voidsd) nogil:
) )
except Exception as e: except Exception as e:
print('exception in Cython callback for audio output: ', str(e)) logging.error('exception in Cython callback for audio output: ', str(e))
return return
sd.outQueue.enqueue(<double*> outbuffer) sd.outQueue.enqueue(<double*> outbuffer)
@ -113,7 +114,7 @@ cdef void audioCallbackPythonThreadFunction(void* voidsd) nogil:
# Waiting indefinitely on the queue... # Waiting indefinitely on the queue...
inbuffer = <double*> sd.inQueue.dequeue() inbuffer = <double*> sd.inQueue.dequeue()
if inbuffer == NULL: if inbuffer == NULL:
printf('Stopping thread...\n') logging.debug('Stopping thread...\n')
return return
try: try:
@ -130,7 +131,7 @@ cdef void audioCallbackPythonThreadFunction(void* voidsd) nogil:
) )
except Exception as e: except Exception as e:
print('exception in cython callback for audio input: ', str(e)) logging.error('exception in cython callback for audio input: ', str(e))
return return
CPPsleep_us(sleeptime_us); CPPsleep_us(sleeptime_us);
@ -142,8 +143,6 @@ cdef void audioCallbackPythonThreadFunction(void* voidsd) nogil:
# Inputbuffer memory is owned by Numpy, so should not be free'ed # Inputbuffer memory is owned by Numpy, so should not be free'ed
inbuffer = NULL inbuffer = NULL
fprintf(stderr, 'Exiting python thread...\n')
cdef class Daq: cdef class Daq:
def __cinit__(self, DeviceInfo pydevinfo, DaqConfiguration pydaqconfig): def __cinit__(self, DeviceInfo pydevinfo, DaqConfiguration pydaqconfig):
@ -177,7 +176,7 @@ cdef class Daq:
def __dealloc__(self): def __dealloc__(self):
# fprintf(stderr, "UlDaq.__dealloc__\n") # fprintf(stderr, "UlDaq.__dealloc__\n")
if self.sd is not NULL: if self.sd is not NULL:
fprintf(stderr, "UlDaq.__dealloc__: stopping stream.\n") logging.debug("UlDaq.__dealloc__: stopping stream.")
self.stop() self.stop()
if self.daq_device is not NULL: if self.daq_device is not NULL:
@ -303,7 +302,7 @@ cdef class Daq:
free(sd.outQueue.dequeue()) free(sd.outQueue.dequeue())
del sd.outQueue del sd.outQueue
sd.outQueue = NULL sd.outQueue = NULL
fprintf(stderr, "End cleanup stream queues...\n") logging.debug("End cleanup stream queues...\n")
if sd.pyCallback: if sd.pyCallback:
Py_DECREF(<object> sd.pyCallback) Py_DECREF(<object> sd.pyCallback)