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

  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. unsigned int fInSampleSize;
  44. unsigned int fOutSampleSize;
  45. unsigned int fInputBufferSize;
  46. unsigned int fOutputBufferSize;
  47. void* fInputBuffer;
  48. void* fOutputBuffer;
  49. jack_nframes_t fInBlockSize;
  50. jack_nframes_t fOutBlockSize;
  51. jack_nframes_t fInMeanStep;
  52. jack_nframes_t fOutMeanStep;
  53. jack_nframes_t fOSSInBuffer;
  54. jack_nframes_t fOSSOutBuffer;
  55. jack_time_t fOSSReadSync;
  56. long long fOSSReadOffset;
  57. jack_time_t fOSSWriteSync;
  58. long long fOSSWriteOffset;
  59. // Buffer balance and sync correction
  60. long long fBufferBalance;
  61. bool fForceBalancing;
  62. bool fForceSync;
  63. int OpenInput();
  64. int OpenOutput();
  65. int OpenAux();
  66. void CloseAux();
  67. void DisplayDeviceInfo();
  68. int ProbeInBlockSize();
  69. int ProbeOutBlockSize();
  70. int Discard(jack_nframes_t frames);
  71. int WriteSilence(jack_nframes_t frames);
  72. int WaitAndSync();
  73. protected:
  74. virtual void UpdateLatencies();
  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. fInSampleSize(0), fOutSampleSize(0),
  81. fInputBufferSize(0), fOutputBufferSize(0),
  82. fInputBuffer(NULL), fOutputBuffer(NULL),
  83. fInBlockSize(1), fOutBlockSize(1),
  84. fInMeanStep(0), fOutMeanStep(0),
  85. fOSSInBuffer(0), fOSSOutBuffer(0),
  86. fOSSReadSync(0), fOSSReadOffset(0), fOSSWriteSync(0), fOSSWriteOffset(0),
  87. fBufferBalance(0), fForceBalancing(false), fForceSync(false)
  88. {}
  89. virtual ~JackOSSDriver()
  90. {}
  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 vmix,
  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,
  105. bool ignorehwbuf);
  106. int Close();
  107. int Read();
  108. int Write();
  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