Jack2 1.9.10

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