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.

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