Browse Source

FreeBSD: Big driver overhaul for FreeBSD OSS.

Features:
 * Internal workings more in line with other Jack drivers.
 * Use poll() for wait and sync instead of blocking I/O.
 * Allows to use Jack in "async" mode.
 * Calculate DSP usage correctly.
 * OSS buffer management to achieve stable latencies.
 * Latency correction for asymmetric OSS buffer use.
 * More robust handling of over- and underruns.
 * Handle format changes forced by the OSS interface.
 * FreeBSD 24bit samples are always packed.

No changes to the driver parameters or the user interface.
tags/v1.9.20
Florian Walpen falkTX <falktx@falktx.com> 3 years ago
parent
commit
b5597128c2
2 changed files with 824 additions and 271 deletions
  1. +780
    -251
      freebsd/oss/JackOSSDriver.cpp
  2. +44
    -20
      freebsd/oss/JackOSSDriver.h

+ 780
- 251
freebsd/oss/JackOSSDriver.cpp
File diff suppressed because it is too large
View File


+ 44
- 20
freebsd/oss/JackOSSDriver.h View File

@@ -28,13 +28,13 @@ namespace Jack


typedef jack_default_audio_sample_t jack_sample_t; typedef jack_default_audio_sample_t jack_sample_t;


#define OSS_DRIVER_DEF_DEV "/dev/dsp"
#define OSS_DRIVER_DEF_FS 48000
#define OSS_DRIVER_DEF_BLKSIZE 1024
#define OSS_DRIVER_DEF_NPERIODS 1
#define OSS_DRIVER_DEF_BITS 16
#define OSS_DRIVER_DEF_INS 2
#define OSS_DRIVER_DEF_OUTS 2
#define OSS_DRIVER_DEF_DEV "/dev/dsp"
#define OSS_DRIVER_DEF_FS 48000
#define OSS_DRIVER_DEF_BLKSIZE 1024
#define OSS_DRIVER_DEF_NPERIODS 1
#define OSS_DRIVER_DEF_BITS 16
#define OSS_DRIVER_DEF_INS 2
#define OSS_DRIVER_DEF_OUTS 2


/*! /*!
\brief The OSS driver. \brief The OSS driver.
@@ -42,21 +42,22 @@ typedef jack_default_audio_sample_t jack_sample_t;


class JackOSSDriver : public JackAudioDriver class JackOSSDriver : public JackAudioDriver
{ {

enum { kRead = 1, kWrite = 2, kReadWrite = 3 };

private: private:


int fInFD; int fInFD;
int fOutFD; int fOutFD;


int fBits; int fBits;
int fSampleFormat;
int fNperiods; int fNperiods;
unsigned int fSampleSize;
int fRWMode;
bool fCapture;
bool fPlayback;
bool fExcl; bool fExcl;
bool fIgnoreHW; bool fIgnoreHW;
jack_nframes_t fExtraCaptureLatency;
jack_nframes_t fExtraPlaybackLatency;

unsigned int fInSampleSize;
unsigned int fOutSampleSize;


unsigned int fInputBufferSize; unsigned int fInputBufferSize;
unsigned int fOutputBufferSize; unsigned int fOutputBufferSize;
@@ -64,26 +65,49 @@ class JackOSSDriver : public JackAudioDriver
void* fInputBuffer; void* fInputBuffer;
void* fOutputBuffer; void* fOutputBuffer;


bool fFirstCycle;
jack_nframes_t fInBlockSize;
jack_nframes_t fOutBlockSize;
jack_nframes_t fInMeanStep;
jack_nframes_t fOutMeanStep;
jack_nframes_t fOSSInBuffer;
jack_nframes_t fOSSOutBuffer;

jack_time_t fOSSReadSync;
long long fOSSReadOffset;
jack_time_t fOSSWriteSync;
long long fOSSWriteOffset;

// Buffer balance and sync correction
long long fBufferBalance;
bool fForceBalancing;
bool fForceSync;


int OpenInput(); int OpenInput();
int OpenOutput(); int OpenOutput();
int OpenAux(); int OpenAux();
void CloseAux(); void CloseAux();
void SetSampleFormat();
void DisplayDeviceInfo(); void DisplayDeviceInfo();

// Redefining since timing for CPU load is specific
int ProcessSync();
int ProbeInBlockSize();
int ProbeOutBlockSize();
int Discard(jack_nframes_t frames);
int WriteSilence(jack_nframes_t frames);
int WaitAndSync();


public: public:


JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table) JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
: JackAudioDriver(name, alias, engine, table), : JackAudioDriver(name, alias, engine, table),
fInFD(-1), fOutFD(-1), fBits(0), fInFD(-1), fOutFD(-1), fBits(0),
fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
fNperiods(0), fCapture(false), fPlayback(false), fExcl(false), fIgnoreHW(true),
fExtraCaptureLatency(0), fExtraPlaybackLatency(0),
fInSampleSize(0), fOutSampleSize(0),
fInputBufferSize(0), fOutputBufferSize(0), fInputBufferSize(0), fOutputBufferSize(0),
fInputBuffer(NULL), fOutputBuffer(NULL), fFirstCycle(true)
fInputBuffer(NULL), fOutputBuffer(NULL),
fInBlockSize(1), fOutBlockSize(1),
fInMeanStep(0), fOutMeanStep(0),
fOSSInBuffer(0), fOSSOutBuffer(0),
fOSSReadSync(0), fOSSReadOffset(0), fOSSWriteSync(0), fOSSWriteOffset(0),
fBufferBalance(0), fForceBalancing(false), fForceSync(false)
{} {}


virtual ~JackOSSDriver() virtual ~JackOSSDriver()


Loading…
Cancel
Save