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.

121 lines
3.6KB

  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. /* Milli Seconds represented in Micro seconds */
  23. #define MS_TO_US 1000
  24. /* Max re-try count for Alsa XRUNs */
  25. #define MAX_RECOVERY_RETRY 10
  26. namespace Jack
  27. {
  28. /*!
  29. \brief The ALSA driver.
  30. */
  31. class JackAlsaDriver : public JackAudioDriver
  32. {
  33. private:
  34. jack_driver_t* fDriver;
  35. jack_native_thread_t fReservationLoopThread;
  36. void UpdateLatencies();
  37. public:
  38. JackAlsaDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
  39. : JackAudioDriver(name, alias, engine, table),fDriver(NULL)
  40. {}
  41. virtual ~JackAlsaDriver()
  42. {}
  43. int Open(jack_nframes_t buffer_size,
  44. jack_nframes_t user_nperiods,
  45. jack_nframes_t samplerate,
  46. bool hw_monitoring,
  47. bool hw_metering,
  48. bool capturing,
  49. bool playing,
  50. DitherAlgorithm dither,
  51. bool soft_mode,
  52. bool monitor,
  53. int inchannels,
  54. int outchannels,
  55. bool shorts_first,
  56. const char* capture_driver_name,
  57. const char* playback_driver_name,
  58. jack_nframes_t capture_latency,
  59. jack_nframes_t playback_latency,
  60. const char* midi_driver_name);
  61. int Close();
  62. int Attach();
  63. int Detach();
  64. int Start();
  65. int Stop();
  66. int Read();
  67. int Write();
  68. // BufferSize can be changed
  69. bool IsFixedBufferSize()
  70. {
  71. return false;
  72. }
  73. int SetBufferSize(jack_nframes_t buffer_size);
  74. void ReadInputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nread);
  75. void MonitorInputAux();
  76. void ClearOutputAux();
  77. void WriteOutputAux(jack_nframes_t orig_nframes, snd_pcm_sframes_t contiguous, snd_pcm_sframes_t nwritten);
  78. void SetTimetAux(jack_time_t time);
  79. int PortSetDefaultMetadata(jack_port_id_t port_id, const char* pretty_name);
  80. // JACK API emulation for the midi driver
  81. int is_realtime() const;
  82. int create_thread(pthread_t *thread, int prio, int rt, void *(*start_func)(void*), void *arg);
  83. jack_port_id_t port_register(const char *port_name, const char *port_type, unsigned long flags, unsigned long buffer_size);
  84. int port_unregister(jack_port_id_t port_index);
  85. void* port_get_buffer(int port, jack_nframes_t nframes);
  86. int port_set_alias(int port, const char* name);
  87. jack_nframes_t get_sample_rate() const;
  88. jack_nframes_t frame_time() const;
  89. jack_nframes_t last_frame_time() const;
  90. };
  91. } // end of namespace
  92. #endif