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.

124 lines
2.8KB

  1. /*
  2. Copyright (C) 2008 Grame & RTL 2008
  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 __JackOSSAdapter__
  16. #define __JackOSSAdapter__
  17. #include <math.h>
  18. #include <limits.h>
  19. #include <assert.h>
  20. #include "JackAudioAdapterInterface.h"
  21. #include "JackPlatformPlug.h"
  22. #include "JackError.h"
  23. #include "jack.h"
  24. #include "jslist.h"
  25. namespace Jack
  26. {
  27. typedef jack_default_audio_sample_t jack_sample_t;
  28. #define OSS_DRIVER_N_PARAMS 12
  29. #define OSS_DRIVER_DEF_DEV "/dev/dsp"
  30. #define OSS_DRIVER_DEF_FS 48000
  31. #define OSS_DRIVER_DEF_BLKSIZE 1024
  32. #define OSS_DRIVER_DEF_NPERIODS 2
  33. #define OSS_DRIVER_DEF_BITS 16
  34. #define OSS_DRIVER_DEF_INS 2
  35. #define OSS_DRIVER_DEF_OUTS 2
  36. /*!
  37. \brief The OSS adapter.
  38. */
  39. class JackOSSAdapter : public JackAudioAdapterInterface, public JackRunnableInterface
  40. {
  41. enum { kRead = 1, kWrite = 2, kReadWrite = 3 };
  42. private:
  43. JackThread fThread;
  44. char fCaptureDriverName[JACK_CLIENT_NAME_SIZE + 1];
  45. char fPlaybackDriverName[JACK_CLIENT_NAME_SIZE + 1];
  46. int fInFD;
  47. int fOutFD;
  48. int fBits;
  49. int fSampleFormat;
  50. int fNperiods;
  51. unsigned int fSampleSize;
  52. int fRWMode;
  53. bool fIgnoreHW;
  54. bool fExcl;
  55. unsigned int fInputBufferSize;
  56. unsigned int fOutputBufferSize;
  57. void* fInputBuffer;
  58. void* fOutputBuffer;
  59. float** fInputSampleBuffer;
  60. float** fOutputSampleBuffer;
  61. bool fFirstCycle;
  62. int OpenInput();
  63. int OpenOutput();
  64. void CloseAux();
  65. void SetSampleFormat();
  66. void DisplayDeviceInfo();
  67. public:
  68. JackOSSAdapter(jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params);
  69. ~JackOSSAdapter()
  70. {}
  71. int Open();
  72. int Close();
  73. int Read();
  74. int Write();
  75. int SetBufferSize(jack_nframes_t buffer_size);
  76. bool Execute();
  77. };
  78. }
  79. #ifdef __cplusplus
  80. extern "C"
  81. {
  82. #endif
  83. #include "JackCompilerDeps.h"
  84. #include "driver_interface.h"
  85. EXPORT jack_driver_desc_t* jack_get_descriptor();
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif