git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@2357 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.90
| @@ -20,10 +20,14 @@ Fernando Lopez-Lezcano | |||||
| Jackdmp changes log | Jackdmp changes log | ||||
| --------------------------- | --------------------------- | ||||
| 2008-05-27 Stephane Letz <letz@grame.fr> | |||||
| * Correct timing in drivers : frame time has to be incremented before Read. | |||||
| 2008-05-26 Stephane Letz <letz@grame.fr> | 2008-05-26 Stephane Letz <letz@grame.fr> | ||||
| * Merge control branch. | |||||
| * Cleanup example clients : use jack_client_open and install a proper 'quit' signal handler. | |||||
| * Merge control branch. | |||||
| * Cleanup example clients : use jack_client_open and install a proper 'quit' signal handler. | |||||
| 2008-05-24 Stephane Letz <letz@grame.fr> | 2008-05-24 Stephane Letz <letz@grame.fr> | ||||
| @@ -61,6 +61,7 @@ int JackDummyDriver::Open(jack_nframes_t nframes, | |||||
| int JackDummyDriver::Process() | int JackDummyDriver::Process() | ||||
| { | { | ||||
| fLastWaitUst = GetMicroSeconds(); // Take callback date here | fLastWaitUst = GetMicroSeconds(); // Take callback date here | ||||
| fEngineControl->CycleIncTime(fLastWaitUst); | |||||
| JackAudioDriver::Process(); | JackAudioDriver::Process(); | ||||
| usleep(std::max(0L, long(fWaitTime - (GetMicroSeconds() - fLastWaitUst)))); | usleep(std::max(0L, long(fWaitTime - (GetMicroSeconds() - fLastWaitUst)))); | ||||
| return 0; | return 0; | ||||
| @@ -27,14 +27,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |||||
| namespace Jack | namespace Jack | ||||
| { | { | ||||
| void JackEngineControl::CycleIncTime(jack_time_t callback_usecs) | |||||
| { | |||||
| // Timer | |||||
| fFrameTimer.IncFrameTime(fBufferSize, callback_usecs, fPeriodUsecs); | |||||
| } | |||||
| void JackEngineControl::CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs) | void JackEngineControl::CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs) | ||||
| { | { | ||||
| // Transport | // Transport | ||||
| fTransport.CycleBegin(fSampleRate, callback_usecs); | fTransport.CycleBegin(fSampleRate, callback_usecs); | ||||
| // Timer | |||||
| fFrameTimer.IncFrameTime(fBufferSize, callback_usecs, fPeriodUsecs); | |||||
| // Timing | // Timing | ||||
| GetTimeMeasure(table, manager, callback_usecs); | GetTimeMeasure(table, manager, callback_usecs); | ||||
| CalcCPULoad(table, manager); | CalcCPULoad(table, manager); | ||||
| @@ -138,6 +138,7 @@ struct JackEngineControl : public JackShmMem | |||||
| {} | {} | ||||
| // Cycle | // Cycle | ||||
| void CycleIncTime(jack_time_t callback_usecs); | |||||
| void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | void CycleBegin(JackClientInterface** table, JackGraphManager* manager, jack_time_t callback_usecs); | ||||
| void CycleEnd(JackClientInterface** table); | void CycleEnd(JackClientInterface** table); | ||||
| @@ -45,7 +45,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |||||
| #include "hdsp.h" | #include "hdsp.h" | ||||
| #include "ice1712.h" | #include "ice1712.h" | ||||
| #include "usx2y.h" | #include "usx2y.h" | ||||
| #include "generic.h" | #include "generic.h" | ||||
| #include "memops.h" | #include "memops.h" | ||||
| @@ -1209,7 +1208,7 @@ JackAlsaDriver::alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed | |||||
| timersub(&now, &tstamp, &diff); | timersub(&now, &tstamp, &diff); | ||||
| *delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec; | *delayed_usecs = diff.tv_sec * 1000000.0 + diff.tv_usec; | ||||
| // steph: utiliser une version TR | |||||
| // steph: TODO use a RT version | |||||
| jack_error("\n\n**** alsa_pcm: xrun of at least %.3f msecs\n\n", *delayed_usecs / 1000.0); | jack_error("\n\n**** alsa_pcm: xrun of at least %.3f msecs\n\n", *delayed_usecs / 1000.0); | ||||
| } | } | ||||
| @@ -2293,6 +2292,9 @@ int JackAlsaDriver::Read() | |||||
| if (nframes != fEngineControl->fBufferSize) | if (nframes != fEngineControl->fBufferSize) | ||||
| jack_log("JackAlsaDriver::Read nframes = %ld", nframes); | jack_log("JackAlsaDriver::Read nframes = %ld", nframes); | ||||
| // Has to be done before read | |||||
| fEngineControl->CycleIncTime(fLastWaitUst); | |||||
| return alsa_driver_read((alsa_driver_t *)fDriver, fEngineControl->fBufferSize); | return alsa_driver_read((alsa_driver_t *)fDriver, fEngineControl->fBufferSize); | ||||
| } | } | ||||
| @@ -768,6 +768,7 @@ void jack_process(midi_stream_t *str, jack_nframes_t nframes) | |||||
| { | { | ||||
| int r, w; | int r, w; | ||||
| process_jack_t proc; | process_jack_t proc; | ||||
| jack_nframes_t cur_frames; | |||||
| if (!str->owner->keep_walking) | if (!str->owner->keep_walking) | ||||
| return; | return; | ||||
| @@ -775,6 +776,13 @@ void jack_process(midi_stream_t *str, jack_nframes_t nframes) | |||||
| proc.midi = str->owner; | proc.midi = str->owner; | ||||
| proc.nframes = nframes; | proc.nframes = nframes; | ||||
| proc.frame_time = jack_last_frame_time(proc.midi->client); | proc.frame_time = jack_last_frame_time(proc.midi->client); | ||||
| cur_frames = jack_frame_time(proc.midi->client); | |||||
| int periods_diff = cur_frames - proc.frame_time; | |||||
| if (periods_diff < proc.nframes) { | |||||
| int periods_lost = periods_diff / proc.nframes; | |||||
| proc.frame_time += periods_lost * proc.nframes; | |||||
| debug_log("xrun detected: %d periods lost", periods_lost); | |||||
| } | |||||
| // process existing ports | // process existing ports | ||||
| for (r=0, w=0; r<str->jack.nports; ++r) { | for (r=0, w=0; r<str->jack.nports; ++r) { | ||||
| @@ -745,6 +745,9 @@ int JackFFADODriver::Read() | |||||
| if (nframes != fEngineControl->fBufferSize) | if (nframes != fEngineControl->fBufferSize) | ||||
| jack_log("JackFFADODriver::Read nframes = %ld", nframes); | jack_log("JackFFADODriver::Read nframes = %ld", nframes); | ||||
| // Has to be done before read | |||||
| fEngineControl->CycleIncTime(fLastWaitUst); | |||||
| printExit(); | printExit(); | ||||
| return ffado_driver_read((ffado_driver_t *)fDriver, fEngineControl->fBufferSize); | return ffado_driver_read((ffado_driver_t *)fDriver, fEngineControl->fBufferSize); | ||||
| @@ -261,7 +261,7 @@ JackFreebobDriver::SetBufferSize (jack_nframes_t nframes) | |||||
| printError("Buffer size change requested but not supported!!!"); | printError("Buffer size change requested but not supported!!!"); | ||||
| /* | /* | ||||
| driver->period_size = nframes; | |||||
| driver->period_size = nframes; | |||||
| driver->period_usecs = | driver->period_usecs = | ||||
| (jack_time_t) floor ((((float) nframes) / driver->sample_rate) | (jack_time_t) floor ((((float) nframes) / driver->sample_rate) | ||||
| * 1000000.0f); | * 1000000.0f); | ||||
| @@ -870,7 +870,7 @@ int JackFreebobDriver::Read() | |||||
| /* we detected an xrun and restarted: notify | /* we detected an xrun and restarted: notify | ||||
| * clients about the delay. | * clients about the delay. | ||||
| */ | */ | ||||
| jack_log("FreeBoB XRun "); | |||||
| jack_log("FreeBoB XRun"); | |||||
| NotifyXRun(fLastWaitUst, fDelayedUsecs); | NotifyXRun(fLastWaitUst, fDelayedUsecs); | ||||
| return -1; | return -1; | ||||
| } | } | ||||
| @@ -878,7 +878,9 @@ int JackFreebobDriver::Read() | |||||
| if (nframes != fEngineControl->fBufferSize) | if (nframes != fEngineControl->fBufferSize) | ||||
| jack_log("JackFreebobDriver::Read nframes = %ld", nframes); | jack_log("JackFreebobDriver::Read nframes = %ld", nframes); | ||||
| //return engine->run_cycle (engine, nframes, delayed_usecs); | |||||
| // Has to be done before read | |||||
| fEngineControl->CycleIncTime(fLastWaitUst); | |||||
| printExit(); | printExit(); | ||||
| return freebob_driver_read((freebob_driver_t *)fDriver, fEngineControl->fBufferSize); | return freebob_driver_read((freebob_driver_t *)fDriver, fEngineControl->fBufferSize); | ||||
| } | } | ||||
| @@ -173,6 +173,7 @@ OSStatus JackCoreAudioDriver::Render(void *inRefCon, | |||||
| driver->fActionFags = ioActionFlags; | driver->fActionFags = ioActionFlags; | ||||
| driver->fCurrentTime = (AudioTimeStamp *)inTimeStamp; | driver->fCurrentTime = (AudioTimeStamp *)inTimeStamp; | ||||
| driver->fDriverOutputData = ioData; | driver->fDriverOutputData = ioData; | ||||
| driver->fEngineControl->CycleIncTime(driver->fLastWaitUst); | |||||
| return driver->Process(); | return driver->Process(); | ||||
| } | } | ||||
| @@ -223,6 +223,7 @@ int JackPortAudioDriver::Render(const void* inputBuffer, void* outputBuffer, | |||||
| driver->fOutputBuffer = (float**)outputBuffer; | driver->fOutputBuffer = (float**)outputBuffer; | ||||
| // Setup threadded based log function | // Setup threadded based log function | ||||
| set_threaded_log_function(); | set_threaded_log_function(); | ||||
| driver->fEngineControl->CycleIncTime(driver->fLastWaitUst); | |||||
| return (driver->Process() == 0) ? paContinue : paAbort; | return (driver->Process() == 0) ? paContinue : paAbort; | ||||
| } | } | ||||