Jack2 1.9.8

JackAlsaDriver.h

00001 /*
00002 Copyright (C) 2001 Paul Davis
00003 Copyright (C) 2004 Grame
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 __JackAlsaDriver__
00022 #define __JackAlsaDriver__
00023 
00024 #include "JackAudioDriver.h"
00025 #include "JackThreadedDriver.h"
00026 #include "JackTime.h"
00027 #include "alsa_driver.h"
00028 
00029 namespace Jack
00030 {
00031 
00036 class JackAlsaDriver : public JackAudioDriver
00037 {
00038 
00039     private:
00040 
00041         jack_driver_t* fDriver;
00042         int fReservedCaptureDevice;
00043         int fReservedPlaybackDevice;
00044 
00045         void UpdateLatencies();
00046 
00047     public:
00048 
00049         JackAlsaDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
00050                 : JackAudioDriver(name, alias, engine, table),fDriver(NULL),fReservedCaptureDevice(-1),fReservedPlaybackDevice(-1)
00051         {}
00052         virtual ~JackAlsaDriver()
00053         {}
00054 
00055         int Open(jack_nframes_t buffer_size,
00056                  jack_nframes_t user_nperiods,
00057                  jack_nframes_t samplerate,
00058                  bool hw_monitoring,
00059                  bool hw_metering,
00060                  bool capturing,
00061                  bool playing,
00062                  DitherAlgorithm dither,
00063                  bool soft_mode,
00064                  bool monitor,
00065                  int inchannels,
00066                  int outchannels,
00067                  bool shorts_first,
00068                  const char* capture_driver_name,
00069                  const char* playback_driver_name,
00070                  jack_nframes_t capture_latency,
00071                  jack_nframes_t playback_latency,
00072                  const char* midi_driver_name);
00073 
00074         int Close();
00075         int Attach();
00076         int Detach();
00077 
00078         int Start();
00079         int Stop();
00080 
00081         int Read();
00082         int Write();
00083 
00084         // BufferSize can be changed
00085         bool IsFixedBufferSize()
00086         {
00087             return false;
00088         }
00089 
00090         int SetBufferSize(jack_nframes_t buffer_size);
00091 
00092         void ReadInputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nread);
00093         void MonitorInputAux();
00094         void ClearOutputAux();
00095         void WriteOutputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nwritten);
00096         void SetTimetAux(jack_time_t time);
00097 
00098         // JACK API emulation for the midi driver
00099         int is_realtime() const;
00100         int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
00101 
00102         jack_port_id_t port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size);
00103         int port_unregister(jack_port_id_t port_index);
00104         void* port_get_buffer(int port, jack_nframes_t nframes);
00105         int port_set_alias(int port, const char* name);
00106 
00107         jack_nframes_t get_sample_rate() const;
00108         jack_nframes_t frame_time() const;
00109         jack_nframes_t last_frame_time() const;
00110 };
00111 
00112 } // end of namespace
00113 
00114 #endif