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.

114 lines
2.9KB

  1. /*
  2. Copyright (C) 2003-2007 Jussi Laako <jussi@sonarnerd.net>
  3. Copyright (C) 2008 Grame & RTL 2008
  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 __JackOSSDriver__
  17. #define __JackOSSDriver__
  18. #include "JackAudioDriver.h"
  19. #include "JackOSSChannel.h"
  20. namespace Jack
  21. {
  22. typedef jack_default_audio_sample_t jack_sample_t;
  23. #define OSS_DRIVER_DEF_DEV "/dev/dsp"
  24. #define OSS_DRIVER_DEF_FS 48000
  25. #define OSS_DRIVER_DEF_BLKSIZE 1024
  26. #define OSS_DRIVER_DEF_NPERIODS 1
  27. #define OSS_DRIVER_DEF_BITS 16
  28. #define OSS_DRIVER_DEF_INS 2
  29. #define OSS_DRIVER_DEF_OUTS 2
  30. /*!
  31. \brief The OSS driver.
  32. */
  33. class JackOSSDriver : public JackAudioDriver
  34. {
  35. private:
  36. int fBits;
  37. int fNperiods;
  38. bool fCapture;
  39. bool fPlayback;
  40. bool fExcl;
  41. bool fIgnoreHW;
  42. std::int64_t fCycleEnd;
  43. std::int64_t fLastRun;
  44. std::int64_t fMaxRunGap;
  45. jack_sample_t** fSampleBuffers;
  46. JackOSSChannel fChannel;
  47. int OpenAux();
  48. void CloseAux();
  49. protected:
  50. virtual void UpdateLatencies();
  51. public:
  52. JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
  53. : JackAudioDriver(name, alias, engine, table),
  54. fBits(0),
  55. fNperiods(0), fCapture(false), fPlayback(false), fExcl(false), fIgnoreHW(true),
  56. fCycleEnd(0), fLastRun(0), fMaxRunGap(0), fSampleBuffers(nullptr)
  57. {}
  58. virtual ~JackOSSDriver()
  59. {}
  60. int Open(jack_nframes_t frames_per_cycle,
  61. int user_nperiods,
  62. jack_nframes_t rate,
  63. bool capturing,
  64. bool playing,
  65. int chan_in,
  66. int chan_out,
  67. bool vmix,
  68. bool monitor,
  69. const char* capture_driver_name,
  70. const char* playback_driver_name,
  71. jack_nframes_t capture_latency,
  72. jack_nframes_t playback_latency,
  73. int bits,
  74. bool ignorehwbuf);
  75. int Close();
  76. int Read();
  77. int Write();
  78. // BufferSize can be changed
  79. bool IsFixedBufferSize()
  80. {
  81. return false;
  82. }
  83. int SetBufferSize(jack_nframes_t buffer_size);
  84. };
  85. } // end of namespace
  86. #endif