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.

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