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.

150 lines
4.2KB

  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. namespace Jack
  20. {
  21. typedef jack_default_audio_sample_t jack_sample_t;
  22. #define OSS_DRIVER_DEF_DEV "/dev/dsp"
  23. #define OSS_DRIVER_DEF_FS 48000
  24. #define OSS_DRIVER_DEF_BLKSIZE 1024
  25. #define OSS_DRIVER_DEF_NPERIODS 1
  26. #define OSS_DRIVER_DEF_BITS 16
  27. #define OSS_DRIVER_DEF_INS 2
  28. #define OSS_DRIVER_DEF_OUTS 2
  29. /*!
  30. \brief The OSS driver.
  31. */
  32. class JackOSSDriver : public JackAudioDriver
  33. {
  34. private:
  35. int fInFD;
  36. int fOutFD;
  37. int fBits;
  38. int fNperiods;
  39. bool fCapture;
  40. bool fPlayback;
  41. bool fExcl;
  42. bool fIgnoreHW;
  43. jack_nframes_t fExtraCaptureLatency;
  44. jack_nframes_t fExtraPlaybackLatency;
  45. unsigned int fInSampleSize;
  46. unsigned int fOutSampleSize;
  47. unsigned int fInputBufferSize;
  48. unsigned int fOutputBufferSize;
  49. void* fInputBuffer;
  50. void* fOutputBuffer;
  51. jack_nframes_t fInBlockSize;
  52. jack_nframes_t fOutBlockSize;
  53. jack_nframes_t fInMeanStep;
  54. jack_nframes_t fOutMeanStep;
  55. jack_nframes_t fOSSInBuffer;
  56. jack_nframes_t fOSSOutBuffer;
  57. jack_time_t fOSSReadSync;
  58. long long fOSSReadOffset;
  59. jack_time_t fOSSWriteSync;
  60. long long fOSSWriteOffset;
  61. // Buffer balance and sync correction
  62. long long fBufferBalance;
  63. bool fForceBalancing;
  64. bool fForceSync;
  65. int OpenInput();
  66. int OpenOutput();
  67. int OpenAux();
  68. void CloseAux();
  69. void DisplayDeviceInfo();
  70. int ProbeInBlockSize();
  71. int ProbeOutBlockSize();
  72. int Discard(jack_nframes_t frames);
  73. int WriteSilence(jack_nframes_t frames);
  74. int WaitAndSync();
  75. public:
  76. JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
  77. : JackAudioDriver(name, alias, engine, table),
  78. fInFD(-1), fOutFD(-1), fBits(0),
  79. fNperiods(0), fCapture(false), fPlayback(false), fExcl(false), fIgnoreHW(true),
  80. fExtraCaptureLatency(0), fExtraPlaybackLatency(0),
  81. fInSampleSize(0), fOutSampleSize(0),
  82. fInputBufferSize(0), fOutputBufferSize(0),
  83. fInputBuffer(NULL), fOutputBuffer(NULL),
  84. fInBlockSize(1), fOutBlockSize(1),
  85. fInMeanStep(0), fOutMeanStep(0),
  86. fOSSInBuffer(0), fOSSOutBuffer(0),
  87. fOSSReadSync(0), fOSSReadOffset(0), fOSSWriteSync(0), fOSSWriteOffset(0),
  88. fBufferBalance(0), fForceBalancing(false), fForceSync(false)
  89. {}
  90. virtual ~JackOSSDriver()
  91. {}
  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 vmix,
  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,
  106. bool ignorehwbuf);
  107. int Close();
  108. int Read();
  109. int Write();
  110. // BufferSize can be changed
  111. bool IsFixedBufferSize()
  112. {
  113. return false;
  114. }
  115. int SetBufferSize(jack_nframes_t buffer_size);
  116. };
  117. } // end of namespace
  118. #endif