Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7175/src
Modified Files: Tag: devel_0_38 s_audio_asio.cpp Log Message: measures for handling hanging drivers
Index: s_audio_asio.cpp =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_asio.cpp,v retrieving revision 1.1.4.5 retrieving revision 1.1.4.6 diff -C2 -d -r1.1.4.5 -r1.1.4.6 *** s_audio_asio.cpp 7 Nov 2004 17:01:34 -0000 1.1.4.5 --- s_audio_asio.cpp 8 Nov 2004 13:23:47 -0000 1.1.4.6 *************** *** 32,35 **** --- 32,38 ---- #include "stdio.h" /* for sprintf */
+ #include <time.h> + #include <sys/timeb.h> + #include "assert.h" #define ASSERT assert *************** *** 43,46 **** --- 46,52 ---- #include "math.h"
+ // seconds to wait for driver to respond + #define DRIVERWAIT 3 + #ifdef PD_DEBUG #define ASIODEBUG *************** *** 396,439 **** void asio_close_audio(void) { ! ASIOError status; ! int channels = sys_inchannels + sys_outchannels; ! int i; ! ! pthread_cond_broadcast(&asio_ringbuf_cond);
! if(asio_useoutputready) ! { ! // the DMA buffers would be played past ASIOStop ! // -> clear output buffers and notify driver ! #if 0 ! // slow, blocking method ! for(i = 0; i != sys_outchannels; ++i) ! zerovec_simd(asio_ringbuffer[i], asio_ringbuffer_length); ! // wait for bufferswitch to process silence (twice) ! pthread_cond_wait(&asio_ringbuf_cond, &asio_ringbuf_mutex); ! for(i = 0; i != sys_outchannels; ++i) ! memset(asio_ringbuffer[i], 0, asio_ringbuffer_length * sizeof (t_sample)); ! pthread_cond_wait(&asio_ringbuf_cond, &asio_ringbuf_mutex); ! #else ! // direct method - clear both hardware buffers ! for(i = 0; i < sys_outchannels; ++i) { ! long bytes = asio_bufsize*asio_out_samplewidth[i]; ! memset(asio_bufferinfo[i].buffers[0],0,bytes); ! memset(asio_bufferinfo[i].buffers[1],0,bytes); ! } ! // notify driver ! ASIOOutputReady(); ! #endif ! }
! post("ASIO: close");
! status = ASIOStop(); ! ASSERT(status == ASE_OK);
- if (asio_driver) - { - ASIOStop(); - for (i = 0; i != channels; i++) freealignedbytes(asio_ringbuffer[i], --- 402,443 ---- void asio_close_audio(void) { ! if (asio_driver) ! { ! post("ASIO: close");
! pthread_cond_broadcast(&asio_ringbuf_cond);
! ASIOError status; ! int channels = sys_inchannels + sys_outchannels; ! int i;
! if(asio_useoutputready) ! { ! // the DMA buffers would be played past ASIOStop ! // -> clear output buffers and notify driver ! #if 0 ! // slow, blocking method ! for(i = 0; i != sys_outchannels; ++i) ! zerovec_simd(asio_ringbuffer[i], asio_ringbuffer_length); ! // wait for bufferswitch to process silence (twice) ! pthread_cond_wait(&asio_ringbuf_cond, &asio_ringbuf_mutex); ! for(i = 0; i != sys_outchannels; ++i) ! memset(asio_ringbuffer[i], 0, asio_ringbuffer_length * sizeof (t_sample)); ! pthread_cond_wait(&asio_ringbuf_cond, &asio_ringbuf_mutex); ! #else ! // direct method - clear both hardware buffers ! for(i = 0; i < sys_outchannels; ++i) { ! long bytes = asio_bufsize*asio_out_samplewidth[i]; ! memset(asio_bufferinfo[i].buffers[0],0,bytes); ! memset(asio_bufferinfo[i].buffers[1],0,bytes); ! } ! // notify driver ! ASIOOutputReady(); ! #endif ! } ! ! status = ASIOStop(); ! ASSERT(status == ASE_OK);
for (i = 0; i != channels; i++) freealignedbytes(asio_ringbuffer[i], *************** *** 503,507 **** if (!asio_driver) { ! error("ASIO not running"); return SENDDACS_NO; } --- 507,513 ---- if (!asio_driver) { ! static int written = 0; ! if(written%100 == 0) error("ASIO not running"); ! written++; return SENDDACS_NO; } *************** *** 541,545 **** if (asio_ringbuffer_inoffset >= asio_ringbuffer_outoffset + asio_bufsize) { ! pthread_cond_wait(&asio_ringbuf_cond, &asio_ringbuf_mutex); if (asio_ringbuffer_inoffset == asio_ringbuffer_length) { --- 547,562 ---- if (asio_ringbuffer_inoffset >= asio_ringbuffer_outoffset + asio_bufsize) { ! struct timespec tm; ! _timeb tmb; ! _ftime(&tmb); ! tm.tv_nsec = tmb.millitm*1000000; ! tm.tv_sec = tmb.time+DRIVERWAIT; // delay ! if(pthread_cond_timedwait(&asio_ringbuf_cond, &asio_ringbuf_mutex, &tm) == ETIMEDOUT) ! { ! error("ASIO: ASIO driver non-responsive! - closing"); ! asio_close_audio(); ! return SENDDACS_SLEPT; ! } ! if (asio_ringbuffer_inoffset == asio_ringbuffer_length) { *************** *** 619,624 **** long i, j;
- - // todo: store the timeInfo for later use
--- 636,639 ----