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.8KB

  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 11
  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. int fRWMode;
  68. unsigned int fInputBufferSize;
  69. unsigned int fOutputBufferSize;
  70. void* fInputBuffer;
  71. void* fOutputBuffer;
  72. sem_t fReadSema;
  73. sem_t fWriteSema;
  74. JackThread fInputThread;
  75. JackThread fOutputThread;
  76. JackBoomerDriverInput fInputHandler;
  77. JackBoomerDriverOutput fOutputHandler;
  78. int OpenInput();
  79. int OpenOutput();
  80. int OpenAux();
  81. void CloseAux();
  82. void SetSampleFormat();
  83. void DisplayDeviceInfo();
  84. void SynchronizeRead();
  85. void SynchronizeWrite();
  86. public:
  87. JackBoomerDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table);
  88. virtual ~JackBoomerDriver();
  89. int Open(jack_nframes_t frames_per_cycle,
  90. int user_nperiods,
  91. jack_nframes_t rate,
  92. bool capturing,
  93. bool playing,
  94. int chan_in,
  95. int chan_out,
  96. bool monitor,
  97. const char* capture_driver_name,
  98. const char* playback_driver_name,
  99. jack_nframes_t capture_latency,
  100. jack_nframes_t playback_latency,
  101. int bits);
  102. int Close();
  103. int Start();
  104. int Stop();
  105. // BufferSize can be changed
  106. bool IsFixedBufferSize()
  107. {
  108. return false;
  109. }
  110. int SetBufferSize(jack_nframes_t buffer_size);
  111. bool Init();
  112. bool Execute();
  113. };
  114. } // end of namespace
  115. #endif