Jack2  1.9.8
JackAlsaDriver.h
1 /*
2 Copyright (C) 2001 Paul Davis
3 Copyright (C) 2004 Grame
4 
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.
9 
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.
14 
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.
18 
19 */
20 
21 #ifndef __JackAlsaDriver__
22 #define __JackAlsaDriver__
23 
24 #include "JackAudioDriver.h"
25 #include "JackThreadedDriver.h"
26 #include "JackTime.h"
27 #include "alsa_driver.h"
28 
29 namespace Jack
30 {
31 
37 {
38 
39  private:
40 
41  jack_driver_t* fDriver;
42  int fReservedCaptureDevice;
43  int fReservedPlaybackDevice;
44 
45  void UpdateLatencies();
46 
47  public:
48 
49  JackAlsaDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
50  : JackAudioDriver(name, alias, engine, table),fDriver(NULL),fReservedCaptureDevice(-1),fReservedPlaybackDevice(-1)
51  {}
52  virtual ~JackAlsaDriver()
53  {}
54 
55  int Open(jack_nframes_t buffer_size,
56  jack_nframes_t user_nperiods,
57  jack_nframes_t samplerate,
58  bool hw_monitoring,
59  bool hw_metering,
60  bool capturing,
61  bool playing,
62  DitherAlgorithm dither,
63  bool soft_mode,
64  bool monitor,
65  int inchannels,
66  int outchannels,
67  bool shorts_first,
68  const char* capture_driver_name,
69  const char* playback_driver_name,
70  jack_nframes_t capture_latency,
71  jack_nframes_t playback_latency,
72  const char* midi_driver_name);
73 
74  int Close();
75  int Attach();
76  int Detach();
77 
78  int Start();
79  int Stop();
80 
81  int Read();
82  int Write();
83 
84  // BufferSize can be changed
85  bool IsFixedBufferSize()
86  {
87  return false;
88  }
89 
90  int SetBufferSize(jack_nframes_t buffer_size);
91 
92  void ReadInputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nread);
93  void MonitorInputAux();
94  void ClearOutputAux();
95  void WriteOutputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nwritten);
96  void SetTimetAux(jack_time_t time);
97 
98  // JACK API emulation for the midi driver
99  int is_realtime() const;
100  int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
101 
102  jack_port_id_t port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size);
103  int port_unregister(jack_port_id_t port_index);
104  void* port_get_buffer(int port, jack_nframes_t nframes);
105  int port_set_alias(int port, const char* name);
106 
107  jack_nframes_t get_sample_rate() const;
108  jack_nframes_t frame_time() const;
109  jack_nframes_t last_frame_time() const;
110 };
111 
112 } // end of namespace
113 
114 #endif