Jack2 1.9.10
|
00001 /* 00002 Copyright (C) 2003-2007 Jussi Laako <jussi@sonarnerd.net> 00003 Copyright (C) 2008 Grame & RTL 2008 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 00021 #ifndef __JackOSSDriver__ 00022 #define __JackOSSDriver__ 00023 00024 #include "JackAudioDriver.h" 00025 00026 namespace Jack 00027 { 00028 00029 typedef jack_default_audio_sample_t jack_sample_t; 00030 00031 #define OSS_DRIVER_DEF_DEV "/dev/dsp" 00032 #define OSS_DRIVER_DEF_FS 48000 00033 #define OSS_DRIVER_DEF_BLKSIZE 1024 00034 #define OSS_DRIVER_DEF_NPERIODS 1 00035 #define OSS_DRIVER_DEF_BITS 16 00036 #define OSS_DRIVER_DEF_INS 2 00037 #define OSS_DRIVER_DEF_OUTS 2 00038 00043 class JackOSSDriver : public JackAudioDriver 00044 { 00045 00046 enum { kRead = 1, kWrite = 2, kReadWrite = 3 }; 00047 00048 private: 00049 00050 int fInFD; 00051 int fOutFD; 00052 00053 int fBits; 00054 int fSampleFormat; 00055 int fNperiods; 00056 unsigned int fSampleSize; 00057 int fRWMode; 00058 bool fExcl; 00059 bool fIgnoreHW; 00060 00061 unsigned int fInputBufferSize; 00062 unsigned int fOutputBufferSize; 00063 00064 void* fInputBuffer; 00065 void* fOutputBuffer; 00066 00067 bool fFirstCycle; 00068 00069 int OpenInput(); 00070 int OpenOutput(); 00071 int OpenAux(); 00072 void CloseAux(); 00073 void SetSampleFormat(); 00074 void DisplayDeviceInfo(); 00075 00076 // Redefining since timing for CPU load is specific 00077 int ProcessSync(); 00078 00079 public: 00080 00081 JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table) 00082 : JackAudioDriver(name, alias, engine, table), 00083 fInFD(-1), fOutFD(-1), fBits(0), 00084 fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true), 00085 fInputBufferSize(0), fOutputBufferSize(0), 00086 fInputBuffer(NULL), fOutputBuffer(NULL), fFirstCycle(true) 00087 {} 00088 00089 virtual ~JackOSSDriver() 00090 {} 00091 00092 int Open(jack_nframes_t frames_per_cycle, 00093 int user_nperiods, 00094 jack_nframes_t rate, 00095 bool capturing, 00096 bool playing, 00097 int chan_in, 00098 int chan_out, 00099 bool vmix, 00100 bool monitor, 00101 const char* capture_driver_name, 00102 const char* playback_driver_name, 00103 jack_nframes_t capture_latency, 00104 jack_nframes_t playback_latency, 00105 int bits, 00106 bool ignorehwbuf); 00107 00108 int Close(); 00109 00110 int Read(); 00111 int Write(); 00112 00113 // BufferSize can be changed 00114 bool IsFixedBufferSize() 00115 { 00116 return false; 00117 } 00118 00119 int SetBufferSize(jack_nframes_t buffer_size); 00120 00121 }; 00122 00123 } // end of namespace 00124 00125 #endif