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.

127 lines
3.3KB

  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_N_PARAMS 13
  23. #define OSS_DRIVER_DEF_DEV "/dev/dsp"
  24. #define OSS_DRIVER_DEF_FS 48000
  25. #define OSS_DRIVER_DEF_BLKSIZE 1024
  26. #define OSS_DRIVER_DEF_NPERIODS 1
  27. #define OSS_DRIVER_DEF_BITS 16
  28. #define OSS_DRIVER_DEF_INS 2
  29. #define OSS_DRIVER_DEF_OUTS 2
  30. /*!
  31. \brief The OSS driver.
  32. */
  33. class JackOSSDriver : public JackAudioDriver
  34. {
  35. enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
  36. private:
  37. int fInFD;
  38. int fOutFD;
  39. int fBits;
  40. int fSampleFormat;
  41. int fNperiods;
  42. unsigned int fSampleSize;
  43. int fRWMode;
  44. bool fExcl;
  45. bool fIgnoreHW;
  46. unsigned int fInputBufferSize;
  47. unsigned int fOutputBufferSize;
  48. void* fInputBuffer;
  49. void* fOutputBuffer;
  50. bool fFirstCycle;
  51. int OpenInput();
  52. int OpenOutput();
  53. int OpenAux();
  54. void CloseAux();
  55. void SetSampleFormat();
  56. void DisplayDeviceInfo();
  57. // Redefining since timing for CPU load is specific
  58. int ProcessSync();
  59. public:
  60. JackOSSDriver(const char* name, const char* alias, JackLockedEngine* engine, JackSynchro* table)
  61. : JackAudioDriver(name, alias, engine, table),
  62. fInFD(-1), fOutFD(-1), fBits(0),
  63. fSampleFormat(0), fNperiods(0), fRWMode(0), fExcl(false), fIgnoreHW(true),
  64. fInputBufferSize(0), fOutputBufferSize(0),
  65. fInputBuffer(NULL), fOutputBuffer(NULL), fFirstCycle(true)
  66. {}
  67. virtual ~JackOSSDriver()
  68. {}
  69. int Open(jack_nframes_t frames_per_cycle,
  70. int user_nperiods,
  71. jack_nframes_t rate,
  72. bool capturing,
  73. bool playing,
  74. int chan_in,
  75. int chan_out,
  76. bool vmix,
  77. bool monitor,
  78. const char* capture_driver_name,
  79. const char* playback_driver_name,
  80. jack_nframes_t capture_latency,
  81. jack_nframes_t playback_latency,
  82. int bits,
  83. bool ignorehwbuf);
  84. int Close();
  85. int Read();
  86. int Write();
  87. // BufferSize can be changed
  88. bool IsFixedBufferSize()
  89. {
  90. return false;
  91. }
  92. int SetBufferSize(jack_nframes_t buffer_size);
  93. };
  94. } // end of namespace
  95. #endif