Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30787
Modified Files: Tag: devel_0_38 s_audio_asio.cpp Log Message: bugfixes and cleanup
Index: s_audio_asio.cpp =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/s_audio_asio.cpp,v retrieving revision 1.1.4.16 retrieving revision 1.1.4.17 diff -C2 -d -r1.1.4.16 -r1.1.4.17 *** s_audio_asio.cpp 25 Nov 2004 23:13:24 -0000 1.1.4.16 --- s_audio_asio.cpp 30 Nov 2004 09:56:59 -0000 1.1.4.17 *************** *** 111,115 ****
/* function to get sample width of data according to ASIOSampleType */ ! static int asio_samplewidth(ASIOSampleType format);
--- 111,115 ----
/* function to get sample width of data according to ASIOSampleType */ ! static int asio_get_samplewidth(ASIOSampleType format);
*************** *** 118,122 **** * it's only for silence when stopping the driver.... (please find a better solution) */ ! static int *asio_out_samplewidth = NULL;
--- 118,122 ---- * it's only for silence when stopping the driver.... (please find a better solution) */ ! static int *asio_samplewidth = NULL;
*************** *** 299,303 ****
/* todo: buffer size hardcoded to asio hardware */ ! asio_bufsize = asio_maxbufsize;
#ifdef CALLBACK_SCHEDULER --- 299,303 ----
/* todo: buffer size hardcoded to asio hardware */ ! asio_bufsize = asio_prefbufsize;
#ifdef CALLBACK_SCHEDULER *************** *** 395,400 ****
asio_converter = (converter_t **)getbytes(channels * sizeof (converter_t *)); ! asio_out_samplewidth = (int *)getbytes(sys_outchannels * sizeof (int)); ! for (i = 0; i != sys_outchannels + sys_inchannels; ++i) { --- 395,401 ----
asio_converter = (converter_t **)getbytes(channels * sizeof (converter_t *)); ! asio_samplewidth = (int *)getbytes(sys_outchannels + ! sys_inchannels * sizeof (int)); ! for (i = 0; i != sys_outchannels + sys_inchannels; ++i) { *************** *** 406,415 **** post("ASIO: channel %d type %d", i, asio_channelinfo[i].type); #endif ! if (i < sys_outchannels) - { asio_converter[i] = asio_converter_send(asio_channelinfo[i].type); - asio_out_samplewidth[i] = asio_samplewidth(asio_channelinfo[i].type); - } else asio_converter[i] = asio_converter_receive(asio_channelinfo[i].type); --- 407,414 ---- post("ASIO: channel %d type %d", i, asio_channelinfo[i].type); #endif ! asio_samplewidth[i] = asio_get_samplewidth(asio_channelinfo[i].type); ! if (i < sys_outchannels) asio_converter[i] = asio_converter_send(asio_channelinfo[i].type); else asio_converter[i] = asio_converter_receive(asio_channelinfo[i].type); *************** *** 514,521 **** #else // direct method - clear both hardware buffers ! if(asio_bufferinfo && asio_out_samplewidth) { 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); --- 513,520 ---- #else // direct method - clear both hardware buffers ! if(asio_bufferinfo && asio_samplewidth) { for(i = 0; i < sys_outchannels; ++i) { ! long bytes = asio_bufsize*asio_samplewidth[i]; memset(asio_bufferinfo[i].buffers[0],0,bytes); memset(asio_bufferinfo[i].buffers[1],0,bytes); *************** *** 567,574 **** }
! if(asio_out_samplewidth) { ! freebytes(asio_out_samplewidth, sys_outchannels * sizeof (int)); ! asio_out_samplewidth = NULL; }
--- 566,573 ---- }
! if(asio_samplewidth) { ! freebytes(asio_samplewidth, (sys_outchannels + sys_inchannels) * sizeof (int)); ! asio_samplewidth = NULL; }
*************** *** 924,928 **** }
! static int asio_samplewidth(ASIOSampleType format) { switch (format) --- 923,927 ---- }
! static int asio_get_samplewidth(ASIOSampleType format) { switch (format) *************** *** 1277,1280 **** --- 1276,1281 ---- }
+ extern "C" pthread_cond_t dsp_callback; + static ASIOTime *asio_bufferSwitchTimeInfo_cb(ASIOTime *params, long db_idx, ASIOBool directprocess) *************** *** 1286,1301 **** sys_lock(); ! for (int j = 0; j != asio_ticks_per_callback; j++) { /* get sounds from input channels */ for (long i = 0; i < sys_outchannels + sys_inchannels; i++) { - t_sample * sp = sys_soundin; if(asio_converter[i]) if (asio_bufferinfo[i].isInput == ASIOTrue) { ! asio_converter[i](asio_bufferinfo[i].buffers[db_idx], sp, sys_dacblocksize); sp += sys_dacblocksize; --- 1287,1303 ---- sys_lock(); ! for (int j = 0; j != asio_ticks_per_callback; j++) { + t_sample * sp = sys_soundin; /* get sounds from input channels */ for (long i = 0; i < sys_outchannels + sys_inchannels; i++) { if(asio_converter[i]) if (asio_bufferinfo[i].isInput == ASIOTrue) { ! asio_converter[i]((char*)asio_bufferinfo[i].buffers[db_idx] + ! asio_samplewidth[i] * j *sys_dacblocksize, sp, sys_dacblocksize); sp += sys_dacblocksize; *************** *** 1307,1340 **** sched_tick(sys_time + sys_time_per_dsp_tick); /* send sound to hardware */ for (long i = 0; i < sys_outchannels + sys_inchannels; i++) { ! t_sample * sp = sys_soundout; ! ! /* clip */ ! t_float lo = -1.f; ! t_float hi = 1.f; ! t_int clipargs[6]; ! clipargs[1] = clipargs[2] = (t_int)sp; ! clipargs[3] = (t_int)&lo; ! clipargs[4] = (t_int)&hi; ! clipargs[5] = (t_int)sys_dacblocksize; ! clipblock(clipargs); ! ! /* send */ ! if(asio_converter[i]) ! if (asio_bufferinfo[i].isInput != ASIOTrue) ! { ! asio_converter[i](sp, asio_bufferinfo[i].buffers[db_idx], sys_dacblocksize); ! sp += sys_dacblocksize; ! } } } - sys_unlock();
if(asio_useoutputready) ASIOOutputReady();
return 0L; /* time info!!! */ } --- 1309,1344 ---- sched_tick(sys_time + sys_time_per_dsp_tick); + sp = sys_soundout; /* send sound to hardware */ for (long i = 0; i < sys_outchannels + sys_inchannels; i++) { ! if (asio_bufferinfo[i].isInput != ASIOTrue) ! { ! /* clip */ ! t_float lo = -1.f; ! t_float hi = 1.f; ! t_int clipargs[6]; ! clipargs[1] = clipargs[2] = (t_int)sp; ! clipargs[3] = (t_int)&lo; ! clipargs[4] = (t_int)&hi; ! clipargs[5] = (t_int)sys_dacblocksize; ! clipblock(clipargs); ! ! /* send */ ! if(asio_converter[i]) ! asio_converter[i](sp, (char*)asio_bufferinfo[i].buffers[db_idx] ! + asio_samplewidth[i] * j *sys_dacblocksize , sys_dacblocksize); ! zeroblock(sp,sys_dacblocksize); ! sp += sys_dacblocksize; ! } } }
if(asio_useoutputready) ASIOOutputReady();
+ sys_unlock(); + return 0L; /* time info!!! */ }