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
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. class JackClient;
  28. typedef jack_default_audio_sample_t jack_sample_t;
  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. JackClient &fClient;
  68. public:
  69. JackOSSAdapter(JackClient &jack_client, jack_nframes_t buffer_size, jack_nframes_t sample_rate, const JSList* params);
  70. ~JackOSSAdapter()
  71. {}
  72. int Open();
  73. int Close();
  74. int Read();
  75. int Write();
  76. int SetBufferSize(jack_nframes_t buffer_size);
  77. bool Execute();
  78. };
  79. }
  80. #ifdef __cplusplus
  81. extern "C"
  82. {
  83. #endif
  84. #include "JackCompilerDeps.h"
  85. #include "driver_interface.h"
  86. SERVER_EXPORT jack_driver_desc_t* jack_get_descriptor();
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif