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.

136 lines
3.5KB

  1. /*
  2. Copyright (C) 2009 Grame
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #ifndef __JackBoomerDriver__
  16. #define __JackBoomerDriver__
  17. #include "JackAudioDriver.h"
  18. #include "JackPlatformPlug.h"
  19. #include "ringbuffer.h"
  20. //#include "JackThread.h"
  21. namespace Jack
  22. {
  23. typedef jack_default_audio_sample_t jack_sample_t;
  24. #define OSS_DRIVER_N_PARAMS 13
  25. #define OSS_DRIVER_DEF_DEV "/dev/dsp"
  26. #define OSS_DRIVER_DEF_FS 48000
  27. #define OSS_DRIVER_DEF_BLKSIZE 1024
  28. #define OSS_DRIVER_DEF_NPERIODS 1
  29. #define OSS_DRIVER_DEF_BITS 16
  30. #define OSS_DRIVER_DEF_INS 2
  31. #define OSS_DRIVER_DEF_OUTS 2
  32. /*!
  33. \brief The Boomer driver.
  34. */
  35. class JackBoomerDriver : public JackAudioDriver, public JackRunnableInterface
  36. {
  37. enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
  38. private:
  39. int fInFD;
  40. int fOutFD;
  41. int fBits;
  42. int fSampleFormat;
  43. int fNperiods;
  44. unsigned int fSampleSize;
  45. int fRWMode;
  46. bool fExcl;
  47. bool fIgnoreHW;
  48. unsigned int fInputBufferSize;
  49. unsigned int fOutputBufferSize;
  50. void* fInputBuffer;
  51. void* fOutputBuffer;
  52. jack_ringbuffer_t** fRingBuffer;
  53. JackThread fThread;
  54. int OpenInput();
  55. int OpenOutput();
  56. int OpenAux();
  57. void CloseAux();
  58. void SetSampleFormat();
  59. void DisplayDeviceInfo();
  60. // Redefining since timing for CPU load is specific
  61. int ProcessAsync();
  62. public:
  63. JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
  64. : JackAudioDriver(name, alias, engine, table),
  65. fInFD(-1), fOutFD(-1), fBits(0),
  66. fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
  67. fInputBufferSize(0), fOutputBufferSize(0),
  68. fInputBuffer(NULL), fOutputBuffer(NULL),
  69. fRingBuffer(NULL), fThread(this)
  70. {}
  71. virtual ~JackBoomerDriver()
  72. {}
  73. int Open(jack_nframes_t frames_per_cycle,
  74. int user_nperiods,
  75. jack_nframes_t rate,
  76. bool capturing,
  77. bool playing,
  78. int chan_in,
  79. int chan_out,
  80. bool vmix,
  81. bool monitor,
  82. const char* capture_driver_name,
  83. const char* playback_driver_name,
  84. jack_nframes_t capture_latency,
  85. jack_nframes_t playback_latency,
  86. int bits,
  87. bool ignorehwbuf);
  88. int Close();
  89. int Start();
  90. int Stop();
  91. int Read();
  92. int Write();
  93. // BufferSize can be changed
  94. bool IsFixedBufferSize()
  95. {
  96. return false;
  97. }
  98. int SetBufferSize(jack_nframes_t buffer_size);
  99. bool Init();
  100. bool Execute();
  101. };
  102. } // end of namespace
  103. #endif