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.

123 lines
2.7KB

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