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 
00028 #include "alsa_driver.h"
00029 
00030 namespace Jack
00031 {
00032 
00037 class JackAlsaDriver : public JackAudioDriver
00038 {
00039 
00040     private:
00041 
00042         jack_driver_t* fDriver;
00043         jack_time_t fDelayedUst;
00044 
00045         void alsa_driver_release_channel_dependent_memory (alsa_driver_t *driver);
00046         int alsa_driver_check_capabilities (alsa_driver_t *driver);
00047         int alsa_driver_check_card_type (alsa_driver_t *driver);
00048         int alsa_driver_hammerfall_hardware (alsa_driver_t *driver);
00049         int alsa_driver_hdsp_hardware (alsa_driver_t *driver);
00050         int alsa_driver_ice1712_hardware (alsa_driver_t *driver);
00051         int alsa_driver_usx2y_hardware (alsa_driver_t *driver);
00052         int alsa_driver_generic_hardware (alsa_driver_t *driver);
00053         int alsa_driver_hw_specific (alsa_driver_t *driver, int hw_monitoring,
00054                                      int hw_metering);
00055         void alsa_driver_setup_io_function_pointers (alsa_driver_t *driver);
00056         int alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
00057                                           const char *stream_name,
00058                                           snd_pcm_t *handle,
00059                                           snd_pcm_hw_params_t *hw_params,
00060                                           snd_pcm_sw_params_t *sw_params,
00061                                           unsigned int *nperiodsp,
00062                                           unsigned long *nchns,
00063                                           unsigned long sample_width);
00064 
00065         int alsa_driver_set_parameters (alsa_driver_t *driver,
00066                                         jack_nframes_t frames_per_cycle,
00067                                         jack_nframes_t user_nperiods,
00068                                         jack_nframes_t rate);
00069 
00070         int     alsa_driver_reset_parameters (alsa_driver_t *driver,
00071                                           jack_nframes_t frames_per_cycle,
00072                                           jack_nframes_t user_nperiods,
00073                                           jack_nframes_t rate);
00074 
00075         int alsa_driver_get_channel_addresses (alsa_driver_t *driver,
00076                                                snd_pcm_uframes_t *capture_avail,
00077                                                snd_pcm_uframes_t *playback_avail,
00078                                                snd_pcm_uframes_t *capture_offset,
00079                                                snd_pcm_uframes_t *playback_offset);
00080 
00081         jack_driver_t * alsa_driver_new(const char *name, char *playback_alsa_device,
00082                                         char *capture_alsa_device,
00083                                         jack_client_t *client,
00084                                         jack_nframes_t frames_per_cycle,
00085                                         jack_nframes_t user_nperiods,
00086                                         jack_nframes_t rate,
00087                                         int hw_monitoring,
00088                                         int hw_metering,
00089                                         int capturing,
00090                                         int playing,
00091                                         DitherAlgorithm dither,
00092                                         int soft_mode,
00093                                         int monitor,
00094                                         int user_capture_nchnls,
00095                                         int user_playback_nchnls,
00096                                         int shorts_first,
00097                                         jack_nframes_t capture_latency,
00098                                         jack_nframes_t playback_latency,
00099                                         alsa_midi_t *midi
00100                                        );
00101 
00102         void alsa_driver_delete(alsa_driver_t *driver);
00103         int alsa_driver_start(alsa_driver_t *driver);
00104         int alsa_driver_stop(alsa_driver_t *driver);
00105         int alsa_driver_read(alsa_driver_t *driver, jack_nframes_t nframes);
00106         int alsa_driver_write(alsa_driver_t *driver, jack_nframes_t nframes);
00107 
00108         jack_nframes_t alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
00109                                          *delayed_usecs);
00110 
00111         void alsa_driver_silence_untouched_channels (alsa_driver_t *driver,
00112                 jack_nframes_t nframes);
00113 
00114         int alsa_driver_restart (alsa_driver_t *driver);
00115         int alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs);
00116         void jack_driver_init (jack_driver_t *driver);
00117         void jack_driver_nt_init (jack_driver_nt_t * driver);
00118  
00119     public:
00120 
00121         JackAlsaDriver(const char* name, JackEngine* engine, JackSynchro** table): JackAudioDriver(name, engine, table)
00122         {}
00123         virtual ~JackAlsaDriver()
00124         {}
00125 
00126         int Open(jack_nframes_t nframes,
00127                                  jack_nframes_t user_nperiods,
00128                                  jack_nframes_t samplerate,
00129                                  bool hw_monitoring,
00130                                  bool hw_metering,
00131                                  bool capturing,
00132                                  bool playing,
00133                                  DitherAlgorithm dither,
00134                                  bool soft_mode, 
00135                                  bool monitor,
00136                                  int inchannels,
00137                                  int outchannels,
00138                                  bool shorts_first,
00139                                  const char* capture_driver_name,
00140                                  const char* playback_driver_name,
00141                                  jack_nframes_t capture_latency,
00142                                  jack_nframes_t playback_latency,
00143                                  const char* midi_driver_name);
00144 
00145         int Close();
00146         int Attach();
00147         int Detach();
00148         
00149         int Start();
00150         int Stop();
00151 
00152         int Read();
00153         int Write();
00154 
00155         int SetBufferSize(jack_nframes_t nframes);
00156 
00157 
00158     // jack api emulation for the midi driver
00159  
00160     int is_realtime() const;
00161     int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
00162  
00163     int port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buf_size);
00164     int port_unregister(int port);
00165     void* port_get_buffer(int port, jack_nframes_t nframes);
00166         int port_set_alias(int port, const char* name);
00167  
00168     jack_nframes_t get_sample_rate() const;
00169     jack_nframes_t frame_time() const;
00170     jack_nframes_t last_frame_time() const;
00171 };
00172 
00173 } // end of namespace
00174 
00175 #endif

Generated on Thu Feb 14 11:16:01 2008 for Jackdmp by  doxygen 1.5.1