AudioJack.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * AudioJack.h - support for JACK-transport
  3. *
  4. * Copyright (c) 2005-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_JACK_H
  25. #define AUDIO_JACK_H
  26. #include "lmmsconfig.h"
  27. #ifdef LMMS_HAVE_JACK
  28. #ifndef LMMS_HAVE_WEAKJACK
  29. #include <jack/jack.h>
  30. #else
  31. #include "weak_libjack.h"
  32. #endif
  33. #include <QtCore/QVector>
  34. #include <QtCore/QList>
  35. #include <QtCore/QMap>
  36. #include "AudioDevice.h"
  37. #include "AudioDeviceSetupWidget.h"
  38. class QLineEdit;
  39. class LcdSpinBox;
  40. class MidiJack;
  41. class AudioJack : public QObject, public AudioDevice
  42. {
  43. Q_OBJECT
  44. public:
  45. AudioJack( bool & _success_ful, Mixer* mixer );
  46. virtual ~AudioJack();
  47. // this is to allow the jack midi connection to use the same jack client connection
  48. // the jack callback is handled here, we call the midi client so that it can read
  49. // it's midi data during the callback
  50. AudioJack * addMidiClient(MidiJack *midiClient);
  51. jack_client_t * jackClient() {return m_client;};
  52. inline static QString name()
  53. {
  54. return QT_TRANSLATE_NOOP( "setupWidget",
  55. "JACK (JACK Audio Connection Kit)" );
  56. }
  57. class setupWidget : public AudioDeviceSetupWidget
  58. {
  59. public:
  60. setupWidget( QWidget * _parent );
  61. virtual ~setupWidget();
  62. virtual void saveSettings();
  63. private:
  64. QLineEdit * m_clientName;
  65. LcdSpinBox * m_channels;
  66. } ;
  67. private slots:
  68. void restartAfterZombified();
  69. private:
  70. bool initJackClient();
  71. virtual void startProcessing();
  72. virtual void stopProcessing();
  73. virtual void applyQualitySettings();
  74. virtual void registerPort( AudioPort * _port );
  75. virtual void unregisterPort( AudioPort * _port );
  76. virtual void renamePort( AudioPort * _port );
  77. int processCallback( jack_nframes_t _nframes, void * _udata );
  78. static int staticProcessCallback( jack_nframes_t _nframes,
  79. void * _udata );
  80. static void shutdownCallback( void * _udata );
  81. jack_client_t * m_client;
  82. bool m_active;
  83. bool m_stopped;
  84. MidiJack *m_midiClient;
  85. QVector<jack_port_t *> m_outputPorts;
  86. jack_default_audio_sample_t * * m_tempOutBufs;
  87. surroundSampleFrame * m_outBuf;
  88. f_cnt_t m_framesDoneInCurBuf;
  89. f_cnt_t m_framesToDoInCurBuf;
  90. #ifdef AUDIO_PORT_SUPPORT
  91. struct StereoPort
  92. {
  93. jack_port_t * ports[2];
  94. } ;
  95. typedef QMap<AudioPort *, StereoPort> JackPortMap;
  96. JackPortMap m_portMap;
  97. #endif
  98. signals:
  99. void zombified();
  100. } ;
  101. #endif
  102. #endif