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.

172 lines
7.0KB

  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. void alsa_driver_release_channel_dependent_memory(alsa_driver_t *driver);
  32. int alsa_driver_check_capabilities(alsa_driver_t *driver);
  33. int alsa_driver_check_card_type(alsa_driver_t *driver);
  34. int alsa_driver_hammerfall_hardware(alsa_driver_t *driver);
  35. int alsa_driver_hdsp_hardware(alsa_driver_t *driver);
  36. int alsa_driver_ice1712_hardware(alsa_driver_t *driver);
  37. int alsa_driver_usx2y_hardware(alsa_driver_t *driver);
  38. int alsa_driver_generic_hardware(alsa_driver_t *driver);
  39. int alsa_driver_hw_specific(alsa_driver_t *driver, int hw_monitoring,
  40. int hw_metering);
  41. void alsa_driver_setup_io_function_pointers (alsa_driver_t *driver);
  42. int alsa_driver_configure_stream(alsa_driver_t *driver, char *device_name,
  43. const char *stream_name,
  44. snd_pcm_t *handle,
  45. snd_pcm_hw_params_t *hw_params,
  46. snd_pcm_sw_params_t *sw_params,
  47. unsigned int *nperiodsp,
  48. unsigned long *nchns,
  49. unsigned long sample_width);
  50. int alsa_driver_set_parameters(alsa_driver_t *driver,
  51. jack_nframes_t frames_per_cycle,
  52. jack_nframes_t user_nperiods,
  53. jack_nframes_t rate);
  54. int alsa_driver_reset_parameters(alsa_driver_t *driver,
  55. jack_nframes_t frames_per_cycle,
  56. jack_nframes_t user_nperiods,
  57. jack_nframes_t rate);
  58. int alsa_driver_get_channel_addresses(alsa_driver_t *driver,
  59. snd_pcm_uframes_t *capture_avail,
  60. snd_pcm_uframes_t *playback_avail,
  61. snd_pcm_uframes_t *capture_offset,
  62. snd_pcm_uframes_t *playback_offset);
  63. jack_driver_t * alsa_driver_new(const char *name, char *playback_alsa_device,
  64. char *capture_alsa_device,
  65. jack_client_t *client,
  66. jack_nframes_t frames_per_cycle,
  67. jack_nframes_t user_nperiods,
  68. jack_nframes_t rate,
  69. int hw_monitoring,
  70. int hw_metering,
  71. int capturing,
  72. int playing,
  73. DitherAlgorithm dither,
  74. int soft_mode,
  75. int monitor,
  76. int user_capture_nchnls,
  77. int user_playback_nchnls,
  78. int shorts_first,
  79. jack_nframes_t capture_latency,
  80. jack_nframes_t playback_latency,
  81. alsa_midi_t *midi);
  82. void alsa_driver_delete(alsa_driver_t *driver);
  83. int alsa_driver_start(alsa_driver_t *driver);
  84. int alsa_driver_stop(alsa_driver_t *driver);
  85. int alsa_driver_read(alsa_driver_t *driver, jack_nframes_t nframes);
  86. int alsa_driver_write(alsa_driver_t *driver, jack_nframes_t nframes);
  87. jack_nframes_t alsa_driver_wait(alsa_driver_t *driver, int extra_fd, int *status, float
  88. *delayed_usecs);
  89. void alsa_driver_silence_untouched_channels(alsa_driver_t *driver,
  90. jack_nframes_t nframes);
  91. int alsa_driver_restart(alsa_driver_t *driver);
  92. int alsa_driver_xrun_recovery(alsa_driver_t *driver, float *delayed_usecs);
  93. void jack_driver_init(jack_driver_t *driver);
  94. void jack_driver_nt_init(jack_driver_nt_t * driver);
  95. public:
  96. JackAlsaDriver(const char* name, JackEngine* engine, JackSynchro** table): JackAudioDriver(name, engine, table)
  97. {}
  98. virtual ~JackAlsaDriver()
  99. {}
  100. int Open(jack_nframes_t nframes,
  101. jack_nframes_t user_nperiods,
  102. jack_nframes_t samplerate,
  103. bool hw_monitoring,
  104. bool hw_metering,
  105. bool capturing,
  106. bool playing,
  107. DitherAlgorithm dither,
  108. bool soft_mode,
  109. bool monitor,
  110. int inchannels,
  111. int outchannels,
  112. bool shorts_first,
  113. const char* capture_driver_name,
  114. const char* playback_driver_name,
  115. jack_nframes_t capture_latency,
  116. jack_nframes_t playback_latency,
  117. const char* midi_driver_name);
  118. int Close();
  119. int Attach();
  120. int Detach();
  121. int Start();
  122. int Stop();
  123. int Read();
  124. int Write();
  125. int SetBufferSize(jack_nframes_t nframes);
  126. // jack api emulation for the midi driver
  127. int is_realtime() const;
  128. int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
  129. jack_port_id_t port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size);
  130. int port_unregister(jack_port_id_t port_index);
  131. void* port_get_buffer(int port, jack_nframes_t nframes);
  132. int port_set_alias(int port, const char* name);
  133. jack_nframes_t get_sample_rate() const;
  134. jack_nframes_t frame_time() const;
  135. jack_nframes_t last_frame_time() const;
  136. };
  137. } // end of namespace
  138. #endif