Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

AudioMixerControlLinux.h

Go to the documentation of this file.
00001 /* audiodevs: Abstraction layer for audio hardware & samples 00002 Copyright (C) 2003-2004 Nemosoft Unv. 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 For questions, remarks, patches, etc. for this program, the author can be 00019 reached at camstream@smcc.demon.nl. 00020 */ 00021 #ifndef AUDIODEVICEMIXER_HPP 00022 #define AUDIODEVICEMIXER_HPP 00023 00024 #ifdef HAVE_CONFIG_H 00025 #include "config.h" 00026 #endif 00027 00028 #include <qbuttongroup.h> 00029 #include <qcheckbox.h> 00030 #include <qcombobox.h> 00031 #include <qdict.h> 00032 #include <qdom.h> 00033 #include <qgrid.h> 00034 #include <qobject.h> 00035 #include <qlabel.h> 00036 #include <qlayout.h> 00037 #include <qradiobutton.h> 00038 #include <qscrollview.h> 00039 #include <qslider.h> 00040 #include <qsocket.h> 00041 #include <qvector.h> 00042 #include <qwidget.h> 00043 00044 #if (QT_VERSION >= 0x030000) 00045 #include <qmutex.h> 00046 #endif 00047 00048 #define ALSA_PCM_NEW_HW_PARAMS_API 00049 #define ALSA_PCM_NEW_SW_PARAMS_API 00050 #include <alsa/asoundlib.h> 00051 00052 class CAudioControlScrollWidget: public QScrollView 00053 { 00054 protected: 00055 void viewportResizeEvent(QResizeEvent *e); 00056 00057 public: 00058 QWidget *m_pCanvas; 00059 QGridLayout *m_pGrid; 00060 00061 QVector <QButtonGroup> m_CaptureGroups; 00062 00063 CAudioControlScrollWidget(QWidget *parent = 0, const char *name = 0, WFlags f = 0); 00064 00065 void SetSize(); 00066 }; 00067 00068 class CAudioMixerElement: public QObject 00069 { 00070 Q_OBJECT 00071 private: 00072 enum ControlType { Unknown, Playback, Capture, PlaybackCapture, Switch, Enumeration }; 00073 00074 ControlType m_SliderType; 00075 snd_mixer_t *m_pMixer; 00076 snd_mixer_selem_id_t *m_pSID; 00077 00078 int m_ChannelMask, m_ChannelCount; 00079 snd_mixer_selem_channel_id_t m_Channels[SND_MIXER_SCHN_LAST + 1]; 00080 00081 // column 0 00082 QString m_Name; 00083 00084 // column 1 00085 bool m_PlaybackMono; 00086 bool m_PlaybackSwitch; 00087 bool m_PlaybackSwitchIsMute; 00088 bool m_PlaybackVolumeJoined, m_PlaybackSwitchJoined; 00089 QSlider *m_pPlaybackSlider[SND_MIXER_SCHN_LAST + 1]; 00090 QComboBox *m_pDropdownBox; 00091 00092 // column 2 00093 QCheckBox *m_pPlaybackCheckBox; 00094 00095 // column 3 00096 bool m_CaptureMono; 00097 bool m_CaptureSwitch; 00098 bool m_CaptureVolumeJoined, m_CaptureSwitchJoined; 00099 bool m_CaptureExclusive; 00100 int m_CaptureGroup; 00101 QSlider *m_pCaptureSlider; 00102 00103 // column 4 00104 QRadioButton *m_pCaptureRadioButton; // only one of these two is used 00105 QCheckBox *m_pCaptureCheckBox; 00106 00107 00108 private slots: 00109 void MovedCaptureVolume(int); 00110 void MovedPlaybackVolume(int); 00111 void ChangedEnumerationSelection(int); 00112 void ToggledSwitch(bool); 00113 void ToggledCapture(int); 00114 00115 public: 00116 CAudioMixerElement(snd_mixer_t *mixer, snd_mixer_elem_t *elem, int row, CAudioControlScrollWidget *parent); 00117 ~CAudioMixerElement(); 00118 00119 const QString &GetName() const { return m_Name; }; 00120 void GetConfiguration(QDomNode &dom_node) const; 00121 void SetConfiguration(const QDomNode &dom_node) const; 00122 00123 int GetCaptureGroup() const; 00124 00125 public slots: 00126 void UpdateFromDevice(); 00127 00128 signals: 00129 void UserClickedSomething(); 00130 }; 00131 00132 00133 00134 00135 class CAudioControlLinux: public QObject 00136 { 00137 Q_OBJECT 00138 private: 00139 QString m_DeviceName; 00140 snd_mixer_t *m_pMixer; 00141 unsigned int m_Count; 00142 QDict<CAudioMixerElement> m_Elements; 00143 QWidget *m_pMixerWidget; 00144 CAudioControlScrollWidget *m_pScrollWidget; 00145 00146 int m_PollFDCount; 00147 struct pollfd *m_pPollFDs; 00148 QVector<QSocket> m_Sockets; 00149 00150 private slots: 00151 void SocketRead(); 00152 00153 protected: 00154 00155 public: 00156 CAudioControlLinux(const char *device); 00157 ~CAudioControlLinux(); 00158 00159 void GetConfiguration(QDomNode &dom_node) const; 00160 void SetConfiguration(const QDomNode &dom_node); 00161 00162 public slots: 00163 void ShowControls(); 00164 00165 signals: 00166 void ForceUpdate(); 00167 00168 void UpdateControls(); 00169 }; 00170 00171 #endif

Generated on Wed Dec 13 23:38:46 2006 for CamStream by doxygen 1.3.7