git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1495 0c269be4-1314-0410-8aa9-9f06e86f4224tags/0.64
| @@ -2,6 +2,10 @@ | |||||
| Jackdmp changes log | Jackdmp changes log | ||||
| --------------------------- | --------------------------- | ||||
| 2007-06-11 Stephane Letz <letz@grame.fr> | |||||
| * Dmitry Baikov buffer size patch. | |||||
| 2007-06-10 Stephane Letz <letz@grame.fr> | 2007-06-10 Stephane Letz <letz@grame.fr> | ||||
| * Correct deprecated jack_set_sample_rate_callback to return 0 instead of -1. | * Correct deprecated jack_set_sample_rate_callback to return 0 instead of -1. | ||||
| @@ -45,6 +45,17 @@ JackAudioDriver::JackAudioDriver(const char* name, JackEngine* engine, JackSynch | |||||
| JackAudioDriver::~JackAudioDriver() | JackAudioDriver::~JackAudioDriver() | ||||
| {} | {} | ||||
| // DB: This is here because audio driver is the only one, who can change buffer size. | |||||
| // It can be moved into JackDriver, but then it would be called twice | |||||
| // because of JackServer::SetBufferSize() implementation. | |||||
| // Initial values are set in JackDriver::Open(...). Yes it is a duplicate code (bad). | |||||
| int JackAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| { | |||||
| fEngineControl->fBufferSize = buffer_size; | |||||
| fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
| return 0; | |||||
| } | |||||
| int JackAudioDriver::Open(jack_nframes_t nframes, | int JackAudioDriver::Open(jack_nframes_t nframes, | ||||
| jack_nframes_t samplerate, | jack_nframes_t samplerate, | ||||
| int capturing, | int capturing, | ||||
| @@ -79,6 +79,9 @@ class EXPORT JackAudioDriver : public JackDriver | |||||
| virtual int Detach(); | virtual int Detach(); | ||||
| virtual int Write(); | virtual int Write(); | ||||
| // sets up fEngineControl and fGraphManager, always succeeds | |||||
| virtual int SetBufferSize(jack_nframes_t buffer_size); | |||||
| virtual void NotifyXRun(jack_time_t callback_usecs); // XRun notification sent by the driver | virtual void NotifyXRun(jack_time_t callback_usecs); // XRun notification sent by the driver | ||||
| }; | }; | ||||
| @@ -66,13 +66,6 @@ int JackDummyDriver::Process() | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| int JackDummyDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| { | |||||
| fEngineControl->fBufferSize = buffer_size; | |||||
| fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // In microsec | |||||
| return 0; | |||||
| } | |||||
| void JackDummyDriver::PrintState() | void JackDummyDriver::PrintState() | ||||
| { | { | ||||
| std::cout << "JackDummyDriver state" << std::endl; | std::cout << "JackDummyDriver state" << std::endl; | ||||
| @@ -59,7 +59,6 @@ class JackDummyDriver : public JackAudioDriver | |||||
| jack_nframes_t playback_latency); | jack_nframes_t playback_latency); | ||||
| int Process(); | int Process(); | ||||
| int SetBufferSize(jack_nframes_t buffer_size); | |||||
| void PrintState(); | void PrintState(); | ||||
| }; | }; | ||||
| @@ -1507,12 +1507,18 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat | |||||
| int JackAlsaDriver::SetBufferSize(jack_nframes_t nframes) | int JackAlsaDriver::SetBufferSize(jack_nframes_t nframes) | ||||
| { | { | ||||
| JackLog("JackAlsaDriver::SetBufferSize %ld\n", nframes); | JackLog("JackAlsaDriver::SetBufferSize %ld\n", nframes); | ||||
| fEngineControl->fBufferSize = nframes; | |||||
| fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // in microsec | |||||
| return alsa_driver_reset_parameters ((alsa_driver_t *)fDriver, nframes, | |||||
| int res = alsa_driver_reset_parameters((alsa_driver_t *)fDriver, nframes, | |||||
| ((alsa_driver_t *)fDriver)->user_nperiods, | ((alsa_driver_t *)fDriver)->user_nperiods, | ||||
| ((alsa_driver_t *)fDriver)->frame_rate); | ((alsa_driver_t *)fDriver)->frame_rate); | ||||
| if (res == 0) // update fEngineControl and fGraphManager | |||||
| JackAudioDriver::SetBufferSize(nframes); // never fails | |||||
| else | |||||
| alsa_driver_reset_parameters((alsa_driver_t *)fDriver, fEngineControl->fBufferSize, | |||||
| ((alsa_driver_t *)fDriver)->user_nperiods, | |||||
| ((alsa_driver_t *)fDriver)->frame_rate); | |||||
| return res; | |||||
| } | } | ||||
| int | int | ||||
| @@ -919,8 +919,7 @@ int JackCoreAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| return -1; | return -1; | ||||
| } | } | ||||
| fEngineControl->fBufferSize = buffer_size; | |||||
| fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // In microsec | |||||
| JackAudioDriver::SetBufferSize(buffer_size); // never fails | |||||
| // Input buffers do no change : prepare them only once | // Input buffers do no change : prepare them only once | ||||
| for (int i = 0; i < fCaptureChannels; i++) { | for (int i = 0; i < fCaptureChannels; i++) { | ||||
| @@ -284,8 +284,8 @@ int JackPortAudioDriver::Open(jack_nframes_t nframes, | |||||
| if (capturing) { | if (capturing) { | ||||
| if (!GetInputDeviceFromName(capture_driver_uid, &fInputDevice, &in_max)) { | if (!GetInputDeviceFromName(capture_driver_uid, &fInputDevice, &in_max)) { | ||||
| JackLog("JackPortAudioDriver::GetInputDeviceFromName cannot open %s\n", capture_driver_uid); | JackLog("JackPortAudioDriver::GetInputDeviceFromName cannot open %s\n", capture_driver_uid); | ||||
| fInputDevice = Pa_GetDefaultInputDevice(); | |||||
| if (fInputDevice == paNoDevice) | |||||
| fInputDevice = Pa_GetDefaultInputDevice(); | |||||
| if (fInputDevice == paNoDevice) | |||||
| goto error; | goto error; | ||||
| deviceInfo = Pa_GetDeviceInfo(fInputDevice); | deviceInfo = Pa_GetDeviceInfo(fInputDevice); | ||||
| in_max = deviceInfo->maxInputChannels; | in_max = deviceInfo->maxInputChannels; | ||||
| @@ -301,8 +301,8 @@ int JackPortAudioDriver::Open(jack_nframes_t nframes, | |||||
| if (playing) { | if (playing) { | ||||
| if (!GetOutputDeviceFromName(playback_driver_uid, &fOutputDevice, &out_max)) { | if (!GetOutputDeviceFromName(playback_driver_uid, &fOutputDevice, &out_max)) { | ||||
| JackLog("JackPortAudioDriver::GetOutputDeviceFromName cannot open %s\n", playback_driver_uid); | JackLog("JackPortAudioDriver::GetOutputDeviceFromName cannot open %s\n", playback_driver_uid); | ||||
| fOutputDevice = Pa_GetDefaultOutputDevice(); | |||||
| if (fOutputDevice == paNoDevice) | |||||
| fOutputDevice = Pa_GetDefaultOutputDevice(); | |||||
| if (fOutputDevice == paNoDevice) | |||||
| goto error; | goto error; | ||||
| deviceInfo = Pa_GetDeviceInfo(fOutputDevice); | deviceInfo = Pa_GetDeviceInfo(fOutputDevice); | ||||
| out_max = deviceInfo->maxOutputChannels; | out_max = deviceInfo->maxOutputChannels; | ||||
| @@ -440,10 +440,7 @@ int JackPortAudioDriver::SetBufferSize(jack_nframes_t buffer_size) | |||||
| jack_error("Pa_OpenStream error = %s\n", Pa_GetErrorText(err)); | jack_error("Pa_OpenStream error = %s\n", Pa_GetErrorText(err)); | ||||
| return -1; | return -1; | ||||
| } else { | } else { | ||||
| // Only done when success | |||||
| fEngineControl->fBufferSize = buffer_size; | |||||
| fEngineControl->fPeriodUsecs = jack_time_t(1000000.f / fEngineControl->fSampleRate * fEngineControl->fBufferSize); // In microsec | |||||
| return 0; | |||||
| return JackAudioDriver::SetBufferSize(buffer_size); // never fails; | |||||
| } | } | ||||
| } | } | ||||