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(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                                        );
00100 
00101         void alsa_driver_delete(alsa_driver_t *driver);
00102         int alsa_driver_start(alsa_driver_t *driver);
00103         int alsa_driver_stop(alsa_driver_t *driver);
00104         int alsa_driver_read(alsa_driver_t *driver, jack_nframes_t nframes);
00105         int alsa_driver_write(alsa_driver_t *driver, jack_nframes_t nframes);
00106 
00107         jack_nframes_t alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
00108                                          *delayed_usecs);
00109 
00110         void alsa_driver_silence_untouched_channels (alsa_driver_t *driver,
00111                 jack_nframes_t nframes);
00112 
00113         int alsa_driver_restart (alsa_driver_t *driver);
00114         int alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs);
00115         void jack_driver_init (jack_driver_t *driver);
00116         void jack_driver_nt_init (jack_driver_nt_t * driver);
00117         void jack_driver_nt_finish(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                                  int hw_monitoring,
00130                                  int hw_metering,
00131                                  int capturing,
00132                                  int playing,
00133                                  DitherAlgorithm dither,
00134                                  int soft_mode, 
00135                                  int monitor,
00136                                  int inchannels,
00137                                  int outchannels,
00138                                  int 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 
00144         int Close();
00145         int Attach();
00146                 int Detach();
00147 
00148         int Start();
00149         int Stop();
00150 
00151         int Read();
00152         int Write();
00153 
00154         int SetBufferSize(jack_nframes_t nframes);
00155 
00156         void PrintState();
00157 };
00158 
00159 } // end of namespace
00160 
00161 #endif

Generated on Wed Jan 10 11:42:43 2007 for Jackdmp by  doxygen 1.4.5