AudioSdl.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * AudioSdl.h - device-class that performs PCM-output via SDL
  3. *
  4. * Copyright (c) 2004-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef AUDIO_SDL_H
  25. #define AUDIO_SDL_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_HAVE_SDL
  28. #ifdef LMMS_HAVE_SDL2
  29. #include <SDL2/SDL.h>
  30. #include <SDL2/SDL_audio.h>
  31. #else
  32. #include <SDL/SDL.h>
  33. #include <SDL/SDL_audio.h>
  34. #endif
  35. #include "AudioDevice.h"
  36. #include "AudioDeviceSetupWidget.h"
  37. class QLineEdit;
  38. class AudioSdl : public AudioDevice
  39. {
  40. public:
  41. AudioSdl( bool & _success_ful, Mixer* mixer );
  42. virtual ~AudioSdl();
  43. inline static QString name()
  44. {
  45. return QT_TRANSLATE_NOOP( "setupWidget",
  46. "SDL (Simple DirectMedia Layer)" );
  47. }
  48. class setupWidget : public AudioDeviceSetupWidget
  49. {
  50. public:
  51. setupWidget( QWidget * _parent );
  52. virtual ~setupWidget();
  53. virtual void saveSettings();
  54. private:
  55. QLineEdit * m_device;
  56. } ;
  57. private:
  58. virtual void startProcessing();
  59. virtual void stopProcessing();
  60. virtual void applyQualitySettings();
  61. static void sdlAudioCallback( void * _udata, Uint8 * _buf, int _len );
  62. void sdlAudioCallback( Uint8 * _buf, int _len );
  63. #ifdef LMMS_HAVE_SDL2
  64. static void sdlInputAudioCallback( void * _udata, Uint8 * _buf, int _len );
  65. void sdlInputAudioCallback( Uint8 * _buf, int _len );
  66. #endif
  67. SDL_AudioSpec m_audioHandle;
  68. surroundSampleFrame * m_outBuf;
  69. #ifdef LMMS_HAVE_SDL2
  70. size_t m_currentBufferFramePos;
  71. size_t m_currentBufferFramesCount;
  72. #else
  73. Uint8 * m_convertedBuf;
  74. int m_convertedBufPos;
  75. int m_convertedBufSize;
  76. bool m_outConvertEndian;
  77. #endif
  78. bool m_stopped;
  79. #ifdef LMMS_HAVE_SDL2
  80. SDL_AudioDeviceID m_outputDevice;
  81. SDL_AudioSpec m_inputAudioHandle;
  82. SDL_AudioDeviceID m_inputDevice;
  83. #endif
  84. } ;
  85. #endif
  86. #endif