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.

124 lines
3.8KB

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