Browse Source

Dmitry Baikov buffer size patch.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1495 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.64
sletz 18 years ago
parent
commit
0a6a0a1728
8 changed files with 34 additions and 22 deletions
  1. +4
    -0
      ChangeLog
  2. +11
    -0
      common/JackAudioDriver.cpp
  3. +3
    -0
      common/JackAudioDriver.h
  4. +0
    -7
      common/JackDummyDriver.cpp
  5. +0
    -1
      common/JackDummyDriver.h
  6. +10
    -4
      linux/alsa/JackAlsaDriver.cpp
  7. +1
    -2
      macosx/JackCoreAudioDriver.cpp
  8. +5
    -8
      windows/JackPortAudioDriver.cpp

+ 4
- 0
ChangeLog View File

@@ -2,6 +2,10 @@
Jackdmp changes log
---------------------------

2007-06-11 Stephane Letz <letz@grame.fr>

* Dmitry Baikov buffer size patch.

2007-06-10 Stephane Letz <letz@grame.fr>

* Correct deprecated jack_set_sample_rate_callback to return 0 instead of -1.


+ 11
- 0
common/JackAudioDriver.cpp View File

@@ -45,6 +45,17 @@ JackAudioDriver::JackAudioDriver(const char* name, JackEngine* engine, JackSynch
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,
jack_nframes_t samplerate,
int capturing,


+ 3
- 0
common/JackAudioDriver.h View File

@@ -79,6 +79,9 @@ class EXPORT JackAudioDriver : public JackDriver
virtual int Detach();
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

};


+ 0
- 7
common/JackDummyDriver.cpp View File

@@ -66,13 +66,6 @@ int JackDummyDriver::Process()
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()
{
std::cout << "JackDummyDriver state" << std::endl;


+ 0
- 1
common/JackDummyDriver.h View File

@@ -59,7 +59,6 @@ class JackDummyDriver : public JackAudioDriver
jack_nframes_t playback_latency);

int Process();
int SetBufferSize(jack_nframes_t buffer_size);
void PrintState();
};



+ 10
- 4
linux/alsa/JackAlsaDriver.cpp View File

@@ -1507,12 +1507,18 @@ JackAlsaDriver::alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *stat
int JackAlsaDriver::SetBufferSize(jack_nframes_t 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)->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


+ 1
- 2
macosx/JackCoreAudioDriver.cpp View File

@@ -919,8 +919,7 @@ int JackCoreAudioDriver::SetBufferSize(jack_nframes_t buffer_size)
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
for (int i = 0; i < fCaptureChannels; i++) {


+ 5
- 8
windows/JackPortAudioDriver.cpp View File

@@ -284,8 +284,8 @@ int JackPortAudioDriver::Open(jack_nframes_t nframes,
if (capturing) {
if (!GetInputDeviceFromName(capture_driver_uid, &fInputDevice, &in_max)) {
JackLog("JackPortAudioDriver::GetInputDeviceFromName cannot open %s\n", capture_driver_uid);
fInputDevice = Pa_GetDefaultInputDevice();
if (fInputDevice == paNoDevice)
fInputDevice = Pa_GetDefaultInputDevice();
if (fInputDevice == paNoDevice)
goto error;
deviceInfo = Pa_GetDeviceInfo(fInputDevice);
in_max = deviceInfo->maxInputChannels;
@@ -301,8 +301,8 @@ int JackPortAudioDriver::Open(jack_nframes_t nframes,
if (playing) {
if (!GetOutputDeviceFromName(playback_driver_uid, &fOutputDevice, &out_max)) {
JackLog("JackPortAudioDriver::GetOutputDeviceFromName cannot open %s\n", playback_driver_uid);
fOutputDevice = Pa_GetDefaultOutputDevice();
if (fOutputDevice == paNoDevice)
fOutputDevice = Pa_GetDefaultOutputDevice();
if (fOutputDevice == paNoDevice)
goto error;
deviceInfo = Pa_GetDeviceInfo(fOutputDevice);
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));
return -1;
} 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;
}
}



Loading…
Cancel
Save