jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
6.7KB

  1. /*
  2. Copyright (C) 2001 Paul Davis
  3. Copyright (C) 2004 Grame
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __JackAlsaDriver__
  17. #define __JackAlsaDriver__
  18. #include "JackAudioDriver.h"
  19. #include "JackThreadedDriver.h"
  20. #include "JackTime.h"
  21. #include "alsa_driver.h"
  22. namespace Jack
  23. {
  24. /*!
  25. \brief The ALSA driver.
  26. */
  27. class JackAlsaDriver : public JackAudioDriver
  28. {
  29. private:
  30. jack_driver_t* fDriver;
  31. jack_time_t fDelayedUst;
  32. void alsa_driver_release_channel_dependent_memory (alsa_driver_t *driver);
  33. int alsa_driver_check_capabilities (alsa_driver_t *driver);
  34. int alsa_driver_check_card_type (alsa_driver_t *driver);
  35. int alsa_driver_hammerfall_hardware (alsa_driver_t *driver);
  36. int alsa_driver_hdsp_hardware (alsa_driver_t *driver);
  37. int alsa_driver_ice1712_hardware (alsa_driver_t *driver);
  38. int alsa_driver_usx2y_hardware (alsa_driver_t *driver);
  39. int alsa_driver_generic_hardware (alsa_driver_t *driver);
  40. int alsa_driver_hw_specific (alsa_driver_t *driver, int hw_monitoring,
  41. int hw_metering);
  42. void alsa_driver_setup_io_function_pointers (alsa_driver_t *driver);
  43. int alsa_driver_configure_stream (alsa_driver_t *driver, char *device_name,
  44. const char *stream_name,
  45. snd_pcm_t *handle,
  46. snd_pcm_hw_params_t *hw_params,
  47. snd_pcm_sw_params_t *sw_params,
  48. unsigned int *nperiodsp,
  49. unsigned long *nchns,
  50. unsigned long sample_width);
  51. int alsa_driver_set_parameters (alsa_driver_t *driver,
  52. jack_nframes_t frames_per_cycle,
  53. jack_nframes_t user_nperiods,
  54. jack_nframes_t rate);
  55. int alsa_driver_reset_parameters (alsa_driver_t *driver,
  56. jack_nframes_t frames_per_cycle,
  57. jack_nframes_t user_nperiods,
  58. jack_nframes_t rate);
  59. int alsa_driver_get_channel_addresses (alsa_driver_t *driver,
  60. snd_pcm_uframes_t *capture_avail,
  61. snd_pcm_uframes_t *playback_avail,
  62. snd_pcm_uframes_t *capture_offset,
  63. snd_pcm_uframes_t *playback_offset);
  64. jack_driver_t * alsa_driver_new(const char *name, char *playback_alsa_device,
  65. char *capture_alsa_device,
  66. jack_client_t *client,
  67. jack_nframes_t frames_per_cycle,
  68. jack_nframes_t user_nperiods,
  69. jack_nframes_t rate,
  70. int hw_monitoring,
  71. int hw_metering,
  72. int capturing,
  73. int playing,
  74. DitherAlgorithm dither,
  75. int soft_mode,
  76. int monitor,
  77. int user_capture_nchnls,
  78. int user_playback_nchnls,
  79. int shorts_first,
  80. jack_nframes_t capture_latency,
  81. jack_nframes_t playback_latency,
  82. alsa_midi_t *midi
  83. );
  84. void alsa_driver_delete(alsa_driver_t *driver);
  85. int alsa_driver_start(alsa_driver_t *driver);
  86. int alsa_driver_stop(alsa_driver_t *driver);
  87. int alsa_driver_read(alsa_driver_t *driver, jack_nframes_t nframes);
  88. int alsa_driver_write(alsa_driver_t *driver, jack_nframes_t nframes);
  89. jack_nframes_t alsa_driver_wait (alsa_driver_t *driver, int extra_fd, int *status, float
  90. *delayed_usecs);
  91. void alsa_driver_silence_untouched_channels (alsa_driver_t *driver,
  92. jack_nframes_t nframes);
  93. int alsa_driver_restart (alsa_driver_t *driver);
  94. int alsa_driver_xrun_recovery (alsa_driver_t *driver, float *delayed_usecs);
  95. void jack_driver_init (jack_driver_t *driver);
  96. void jack_driver_nt_init (jack_driver_nt_t * driver);
  97. public:
  98. JackAlsaDriver(const char* name, JackEngine* engine, JackSynchro** table): JackAudioDriver(name, engine, table)
  99. {}
  100. virtual ~JackAlsaDriver()
  101. {}
  102. int Open(jack_nframes_t nframes,
  103. jack_nframes_t user_nperiods,
  104. jack_nframes_t samplerate,
  105. bool hw_monitoring,
  106. bool hw_metering,
  107. bool capturing,
  108. bool playing,
  109. DitherAlgorithm dither,
  110. bool soft_mode,
  111. bool monitor,
  112. int inchannels,
  113. int outchannels,
  114. bool shorts_first,
  115. const char* capture_driver_name,
  116. const char* playback_driver_name,
  117. jack_nframes_t capture_latency,
  118. jack_nframes_t playback_latency,
  119. const char* midi_driver_name);
  120. int Close();
  121. int Attach();
  122. int Detach();
  123. int Start();
  124. int Stop();
  125. int Read();
  126. int Write();
  127. int SetBufferSize(jack_nframes_t nframes);
  128. // jack api emulation for the midi driver
  129. int is_realtime() const;
  130. int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
  131. int port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buf_size);
  132. int port_unregister(int port);
  133. void* port_get_buffer(int port, jack_nframes_t nframes);
  134. jack_nframes_t get_sample_rate() const;
  135. jack_nframes_t frame_time() const;
  136. jack_nframes_t last_frame_time() const;
  137. };
  138. } // end of namespace
  139. #endif