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.

161 lines
3.9KB

  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 <semaphore.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
  36. {
  37. enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
  38. private:
  39. class JackBoomerDriverInput : public JackRunnableInterface {
  40. private:
  41. JackBoomerDriver* fDriver;
  42. public:
  43. JackBoomerDriverInput(JackBoomerDriver* driver): fDriver(driver)
  44. {}
  45. ~JackBoomerDriverInput()
  46. {}
  47. bool Init();
  48. bool Execute();
  49. };
  50. class JackBoomerDriverOutput : public JackRunnableInterface {
  51. private:
  52. JackBoomerDriver* fDriver;
  53. public:
  54. JackBoomerDriverOutput(JackBoomerDriver* driver): fDriver(driver)
  55. {}
  56. ~JackBoomerDriverOutput()
  57. {}
  58. bool Init();
  59. bool Execute();
  60. };
  61. int fInFD;
  62. int fOutFD;
  63. int fBits;
  64. int fSampleFormat;
  65. int fNperiods;
  66. unsigned int fSampleSize;
  67. unsigned int fFragmentSize;
  68. int fRWMode;
  69. bool fExcl;
  70. bool fSyncIO;
  71. unsigned int fInputBufferSize;
  72. unsigned int fOutputBufferSize;
  73. void* fInputBuffer;
  74. void* fOutputBuffer;
  75. sem_t fReadSema;
  76. sem_t fWriteSema;
  77. JackThread fInputThread;
  78. JackThread fOutputThread;
  79. JackBoomerDriverInput fInputHandler;
  80. JackBoomerDriverOutput fOutputHandler;
  81. int OpenInput();
  82. int OpenOutput();
  83. int OpenAux();
  84. void CloseAux();
  85. void SetSampleFormat();
  86. void DisplayDeviceInfo();
  87. void SynchronizeRead();
  88. void SynchronizeWrite();
  89. public:
  90. JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
  91. virtual ~JackBoomerDriver();
  92. int Open(jack_nframes_t frames_per_cycle,
  93. int user_nperiods,
  94. jack_nframes_t rate,
  95. bool capturing,
  96. bool playing,
  97. int chan_in,
  98. int chan_out,
  99. bool excl,
  100. bool monitor,
  101. const char* capture_driver_name,
  102. const char* playback_driver_name,
  103. jack_nframes_t capture_latency,
  104. jack_nframes_t playback_latency,
  105. int bits, bool syncio);
  106. int Close();
  107. int Start();
  108. int Stop();
  109. // BufferSize can be changed
  110. bool IsFixedBufferSize()
  111. {
  112. return false;
  113. }
  114. int SetBufferSize(jack_nframes_t buffer_size);
  115. };
  116. } // end of namespace
  117. #endif