Improved error reporting in device reservation code
[jack2.git] / solaris / oss / JackOSSDriver.h
blob32758d4087891b74aa40bd9e765c6868f6dc083a
1 /*
2 Copyright (C) 2003-2007 Jussi Laako <jussi@sonarnerd.net>
3 Copyright (C) 2008 Grame & RTL 2008
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __JackOSSDriver__
22 #define __JackOSSDriver__
24 #include "JackAudioDriver.h"
26 namespace Jack
29 typedef jack_default_audio_sample_t jack_sample_t;
31 #define OSS_DRIVER_DEF_DEV "/dev/dsp"
32 #define OSS_DRIVER_DEF_FS 48000
33 #define OSS_DRIVER_DEF_BLKSIZE 1024
34 #define OSS_DRIVER_DEF_NPERIODS 1
35 #define OSS_DRIVER_DEF_BITS 16
36 #define OSS_DRIVER_DEF_INS 2
37 #define OSS_DRIVER_DEF_OUTS 2
39 /*!
40 \brief The OSS driver.
43 class JackOSSDriver : public JackAudioDriver
46 enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
48 private:
50 int fInFD;
51 int fOutFD;
53 int fBits;
54 int fSampleFormat;
55 int fNperiods;
56 unsigned int fSampleSize;
57 int fRWMode;
58 bool fExcl;
59 bool fIgnoreHW;
61 unsigned int fInputBufferSize;
62 unsigned int fOutputBufferSize;
64 void* fInputBuffer;
65 void* fOutputBuffer;
67 bool fFirstCycle;
69 int OpenInput();
70 int OpenOutput();
71 int OpenAux();
72 void CloseAux();
73 void SetSampleFormat();
74 void DisplayDeviceInfo();
76 // Redefining since timing for CPU load is specific
77 int ProcessSync();
79 public:
81 JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
82 : JackAudioDriver(name, alias, engine, table),
83 fInFD(-1), fOutFD(-1), fBits(0),
84 fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
85 fInputBufferSize(0), fOutputBufferSize(0),
86 fInputBuffer(NULL), fOutputBuffer(NULL), fFirstCycle(true)
89 virtual ~JackOSSDriver()
92 int Open(jack_nframes_t frames_per_cycle,
93 int user_nperiods,
94 jack_nframes_t rate,
95 bool capturing,
96 bool playing,
97 int chan_in,
98 int chan_out,
99 bool vmix,
100 bool monitor,
101 const char* capture_driver_name,
102 const char* playback_driver_name,
103 jack_nframes_t capture_latency,
104 jack_nframes_t playback_latency,
105 int bits,
106 bool ignorehwbuf);
108 int Close();
110 int Read();
111 int Write();
113 // BufferSize can be changed
114 bool IsFixedBufferSize()
116 return false;
119 int SetBufferSize(jack_nframes_t buffer_size);
123 } // end of namespace
125 #endif