CSL  5.2
CAIO.h
Go to the documentation of this file.
1 //
2 // CAIO.h -- DAC IO using CoreAudio -- Abstract AUIO class and concrete CAIO class
3 // See the copyright notice and acknowledgment of authors in the file COPYRIGHT
4 //
5 
6 #ifndef CSL_CAIO_H
7 #define CSL_CAIO_H
8 
9 #include "CSL_Core.h"
10 
11 #include <AudioUnit/AudioUnit.h> // main AU include
12 
13 using namespace std;
14 
15 namespace csl {
16 
17 ///
18 /// General-purpose AudioUnit IO class
19 ///
20 
21 class AUIO : public IO {
22 public:
23  AUIO();
24  AUIO(unsigned s_rate, unsigned b_size, int in_device, int out_device, unsigned in_chans, unsigned out_chans);
25  ~AUIO();
26 
27  virtual void open() throw(CException); ///< open/close start/stop methods
28  virtual void close() throw(CException);
29  virtual void start() throw(CException);
30  virtual void stop() throw(CException);
31 
32  void setAudioUnit(AudioUnit au) { mAudioUnit = au; };
33  virtual Buffer & getInput() throw(CException); ///< get the current input buffer
34  virtual Buffer & getInput(unsigned numFrames, unsigned numChannels) throw(CException); ///< get the current input buffer
35 
36 protected:
37  AudioUnit mAudioUnit; // The AudioUnit we play out
38  void handleError(OSStatus result) throw(CException);
39 };
40 
41 ///
42 /// CoreAudio IO class
43 ///
44 
45 class CAIO : public AUIO {
46 public:
47  CAIO(); /// Most verbose constructor -- specify everything
48  CAIO(unsigned s_rate, unsigned b_size, int in_device, int out_device, unsigned in_chans, unsigned out_chans);
49  ~CAIO();
50 
51  void open() throw(CException); ///< open/close start/stop methods
52  void close() throw(CException);
53  void start() throw(CException);
54  void stop() throw(CException);
55 
56 protected:
57  void handleError(OSStatus result) throw(CException);
58 
59 };
60 
61 }
62 
63 #endif