-rw-r--r-- | libopie2/opiemm/opiemm.pro | 8 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro index 8e5eeb4..d3ce8f7 100644 --- a/libopie2/opiemm/opiemm.pro +++ b/libopie2/opiemm/opiemm.pro | |||
@@ -1,16 +1,22 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on debug | 2 | CONFIG += qt warn_on debug |
3 | DESTDIR = $(OPIEDIR)/lib | 3 | DESTDIR = $(OPIEDIR)/lib |
4 | HEADERS = osoundsystem.h | 4 | HEADERS = osoundsystem.h |
5 | SOURCES = osoundsystem.cpp | 5 | SOURCES = osoundsystem.cpp |
6 | INTERFACES = | 6 | INTERFACES = |
7 | TARGET = opiemm2 | 7 | TARGET = opiemm2 |
8 | VERSION = 1.8.1 | 8 | VERSION = 1.8.1 |
9 | INCLUDEPATH += $(OPIEDIR)/include | 9 | INCLUDEPATH += $(OPIEDIR)/include |
10 | DEPENDPATH += $(OPIEDIR)/include | 10 | DEPENDPATH += $(OPIEDIR)/include |
11 | LIBS += | 11 | LIBS += |
12 | MOC_DIR = moc | 12 | MOC_DIR = moc |
13 | OBJECTS_DIR = obj | 13 | OBJECTS_DIR = obj |
14 | 14 | ||
15 | include ( $(OPIEDIR)/include.pro ) | ||
16 | 15 | ||
16 | !contains( platform, x11 ) { | ||
17 | include ( $(OPIEDIR)/include.pro ) | ||
18 | } | ||
19 | |||
20 | contains( platform, x11 ) { | ||
21 | LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | ||
22 | } | ||
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp index fd23bea..d857659 100644 --- a/libopie2/opiemm/osoundsystem.cpp +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -1,315 +1,316 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include <opie2/osoundsystem.h> | 32 | #include <opie2/osoundsystem.h> |
33 | 33 | ||
34 | #include <errno.h> | 34 | #include <errno.h> |
35 | #include <fcntl.h> | 35 | #include <fcntl.h> |
36 | #include <string.h> | 36 | #include <string.h> |
37 | #include <sys/ioctl.h> | 37 | #include <sys/ioctl.h> |
38 | #include <sys/types.h> | 38 | #include <sys/types.h> |
39 | #include <sys/soundcard.h> | 39 | #include <sys/soundcard.h> |
40 | #include <sys/stat.h> | 40 | #include <sys/stat.h> |
41 | 41 | ||
42 | #include <qstringlist.h> | ||
42 | 43 | ||
43 | /*====================================================================================== | 44 | /*====================================================================================== |
44 | * OSoundSystem | 45 | * OSoundSystem |
45 | *======================================================================================*/ | 46 | *======================================================================================*/ |
46 | 47 | ||
47 | OSoundSystem* OSoundSystem::_instance = 0; | 48 | OSoundSystem* OSoundSystem::_instance = 0; |
48 | 49 | ||
49 | OSoundSystem::OSoundSystem() | 50 | OSoundSystem::OSoundSystem() |
50 | { | 51 | { |
51 | qDebug( "OSoundSystem::OSoundSystem()" ); | 52 | qDebug( "OSoundSystem::OSoundSystem()" ); |
52 | synchronize(); | 53 | synchronize(); |
53 | } | 54 | } |
54 | 55 | ||
55 | void OSoundSystem::synchronize() | 56 | void OSoundSystem::synchronize() |
56 | { | 57 | { |
57 | // gather available interfaces by inspecting /dev | 58 | // gather available interfaces by inspecting /dev |
58 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | 59 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices |
59 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | 60 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices |
60 | 61 | ||
61 | _interfaces.clear(); | 62 | _interfaces.clear(); |
62 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); | 63 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); |
63 | 64 | ||
64 | 65 | ||
65 | /* | 66 | /* |
66 | 67 | ||
67 | 68 | ||
68 | 69 | ||
69 | 70 | ||
70 | QString str; | 71 | QString str; |
71 | QFile f( "/dev/sound" ); | 72 | QFile f( "/dev/sound" ); |
72 | bool hasFile = f.open( IO_ReadOnly ); | 73 | bool hasFile = f.open( IO_ReadOnly ); |
73 | if ( !hasFile ) | 74 | if ( !hasFile ) |
74 | { | 75 | { |
75 | qDebug( "OSoundSystem: /dev/sound not existing. No sound devices available" ); | 76 | qDebug( "OSoundSystem: /dev/sound not existing. No sound devices available" ); |
76 | return; | 77 | return; |
77 | } | 78 | } |
78 | QTextStream s( &f ); | 79 | QTextStream s( &f ); |
79 | s.readLine(); | 80 | s.readLine(); |
80 | s.readLine(); | 81 | s.readLine(); |
81 | while ( !s.atEnd() ) | 82 | while ( !s.atEnd() ) |
82 | { | 83 | { |
83 | s >> str; | 84 | s >> str; |
84 | str.truncate( str.find( ':' ) ); | 85 | str.truncate( str.find( ':' ) ); |
85 | qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); | 86 | qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); |
86 | OAudioInterface* iface; | 87 | OAudioInterface* iface; |
87 | iface = new OAudioInterface( this, (const char*) str ); | 88 | iface = new OAudioInterface( this, (const char*) str ); |
88 | 89 | ||
89 | _interfaces.insert( str, iface ); | 90 | _interfaces.insert( str, iface ); |
90 | s.readLine(); | 91 | s.readLine(); |
91 | } | 92 | } |
92 | */ | 93 | */ |
93 | } | 94 | } |
94 | 95 | ||
95 | 96 | ||
96 | int OSoundSystem::count() const | 97 | int OSoundSystem::count() const |
97 | { | 98 | { |
98 | return _interfaces.count(); | 99 | return _interfaces.count(); |
99 | } | 100 | } |
100 | 101 | ||
101 | 102 | ||
102 | OSoundCard* OSoundSystem::card( const QString& iface ) const | 103 | OSoundCard* OSoundSystem::card( const QString& iface ) const |
103 | { | 104 | { |
104 | return _interfaces[iface]; | 105 | return _interfaces[iface]; |
105 | } | 106 | } |
106 | 107 | ||
107 | 108 | ||
108 | OSoundSystem* OSoundSystem::instance() | 109 | OSoundSystem* OSoundSystem::instance() |
109 | { | 110 | { |
110 | if ( !_instance ) _instance = new OSoundSystem(); | 111 | if ( !_instance ) _instance = new OSoundSystem(); |
111 | return _instance; | 112 | return _instance; |
112 | } | 113 | } |
113 | 114 | ||
114 | 115 | ||
115 | OSoundSystem::CardIterator OSoundSystem::iterator() const | 116 | OSoundSystem::CardIterator OSoundSystem::iterator() const |
116 | { | 117 | { |
117 | return OSoundSystem::CardIterator( _interfaces ); | 118 | return OSoundSystem::CardIterator( _interfaces ); |
118 | } | 119 | } |
119 | 120 | ||
120 | 121 | ||
121 | /*====================================================================================== | 122 | /*====================================================================================== |
122 | * OSoundCard | 123 | * OSoundCard |
123 | *======================================================================================*/ | 124 | *======================================================================================*/ |
124 | 125 | ||
125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | 126 | OSoundCard::OSoundCard( QObject* parent, const char* name ) |
126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | 127 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) |
127 | { | 128 | { |
128 | qDebug( "OSoundCard::OSoundCard()" ); | 129 | qDebug( "OSoundCard::OSoundCard()" ); |
129 | init(); | 130 | init(); |
130 | } | 131 | } |
131 | 132 | ||
132 | 133 | ||
133 | OSoundCard::~OSoundCard() | 134 | OSoundCard::~OSoundCard() |
134 | { | 135 | { |
135 | } | 136 | } |
136 | 137 | ||
137 | 138 | ||
138 | void OSoundCard::init() | 139 | void OSoundCard::init() |
139 | { | 140 | { |
140 | _audio = new OAudioInterface( this, "/dev/dsp" ); | 141 | _audio = new OAudioInterface( this, "/dev/dsp" ); |
141 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | 142 | _mixer = new OMixerInterface( this, "/dev/mixer" ); |
142 | } | 143 | } |
143 | 144 | ||
144 | 145 | ||
145 | /*====================================================================================== | 146 | /*====================================================================================== |
146 | * OAudioInterface | 147 | * OAudioInterface |
147 | *======================================================================================*/ | 148 | *======================================================================================*/ |
148 | 149 | ||
149 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | 150 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) |
150 | :QObject( parent, name ) | 151 | :QObject( parent, name ) |
151 | { | 152 | { |
152 | qDebug( "OAudioInterface::OAudioInterface()" ); | 153 | qDebug( "OAudioInterface::OAudioInterface()" ); |
153 | init(); | 154 | init(); |
154 | } | 155 | } |
155 | 156 | ||
156 | 157 | ||
157 | OAudioInterface::~OAudioInterface() | 158 | OAudioInterface::~OAudioInterface() |
158 | { | 159 | { |
159 | } | 160 | } |
160 | 161 | ||
161 | 162 | ||
162 | void OAudioInterface::init() | 163 | void OAudioInterface::init() |
163 | { | 164 | { |
164 | 165 | ||
165 | 166 | ||
166 | } | 167 | } |
167 | 168 | ||
168 | 169 | ||
169 | /*====================================================================================== | 170 | /*====================================================================================== |
170 | * OMixerInterface | 171 | * OMixerInterface |
171 | *======================================================================================*/ | 172 | *======================================================================================*/ |
172 | 173 | ||
173 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | 174 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) |
174 | :QObject( parent, name ) | 175 | :QObject( parent, name ) |
175 | { | 176 | { |
176 | qDebug( "OMixerInterface::OMixerInterface()" ); | 177 | qDebug( "OMixerInterface::OMixerInterface()" ); |
177 | init(); | 178 | init(); |
178 | } | 179 | } |
179 | 180 | ||
180 | 181 | ||
181 | OMixerInterface::~OMixerInterface() | 182 | OMixerInterface::~OMixerInterface() |
182 | { | 183 | { |
183 | } | 184 | } |
184 | 185 | ||
185 | 186 | ||
186 | void OMixerInterface::init() | 187 | void OMixerInterface::init() |
187 | { | 188 | { |
188 | // open the device | 189 | // open the device |
189 | _fd = ::open( name(), O_RDWR ); | 190 | _fd = ::open( name(), O_RDWR ); |
190 | if ( _fd == -1 ) | 191 | if ( _fd == -1 ) |
191 | { | 192 | { |
192 | qWarning( "can't open mixer." ); | 193 | qWarning( "can't open mixer." ); |
193 | return; | 194 | return; |
194 | } | 195 | } |
195 | 196 | ||
196 | // construct the device capabilities | 197 | // construct the device capabilities |
197 | int devmask = 0; | 198 | int devmask = 0; |
198 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) | 199 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) |
199 | { | 200 | { |
200 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); | 201 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); |
201 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); | 202 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "PlayBass", SOUND_MIXER_BASS ); |
202 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); | 203 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "PlayTreble", SOUND_MIXER_TREBLE ); |
203 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); | 204 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "PlaySynth", SOUND_MIXER_SYNTH ); |
204 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); | 205 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "PlayPCM", SOUND_MIXER_PCM ); |
205 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); | 206 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "PlaySpeaker", SOUND_MIXER_SPEAKER ); |
206 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); | 207 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "PlayLine", SOUND_MIXER_LINE ); |
207 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); | 208 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "PlayMic", SOUND_MIXER_MIC ); |
208 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); | 209 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "PlayCD", SOUND_MIXER_CD ); |
209 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); | 210 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "PlayInputMix", SOUND_MIXER_IMIX ); |
210 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); | 211 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "PlayAltPCM", SOUND_MIXER_ALTPCM ); |
211 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); | 212 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "PlayRecord", SOUND_MIXER_RECLEV ); |
212 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); | 213 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "PlayInputGain", SOUND_MIXER_IGAIN ); |
213 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); | 214 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN ); |
214 | //qDebug( "devmask available and constructed." ); | 215 | //qDebug( "devmask available and constructed." ); |
215 | } | 216 | } |
216 | 217 | ||
217 | devmask = 0; | 218 | devmask = 0; |
218 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) | 219 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) |
219 | { | 220 | { |
220 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); | 221 | if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); |
221 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); | 222 | if ( devmask & ( 1 << SOUND_MIXER_BASS ) ) _channels.insert( "RecBass", SOUND_MIXER_BASS ); |
222 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); | 223 | if ( devmask & ( 1 << SOUND_MIXER_TREBLE ) ) _channels.insert( "RecTreble", SOUND_MIXER_TREBLE ); |
223 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); | 224 | if ( devmask & ( 1 << SOUND_MIXER_SYNTH ) ) _channels.insert( "RecSynth", SOUND_MIXER_SYNTH ); |
224 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); | 225 | if ( devmask & ( 1 << SOUND_MIXER_PCM ) ) _channels.insert( "RecPCM", SOUND_MIXER_PCM ); |
225 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); | 226 | if ( devmask & ( 1 << SOUND_MIXER_SPEAKER ) ) _channels.insert( "RecSpeaker", SOUND_MIXER_SPEAKER ); |
226 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); | 227 | if ( devmask & ( 1 << SOUND_MIXER_LINE ) ) _channels.insert( "RecLine", SOUND_MIXER_LINE ); |
227 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); | 228 | if ( devmask & ( 1 << SOUND_MIXER_MIC ) ) _channels.insert( "RecMic", SOUND_MIXER_MIC ); |
228 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); | 229 | if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); |
229 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); | 230 | if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); |
230 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); | 231 | if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); |
231 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); | 232 | if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); |
232 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); | 233 | if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); |
233 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); | 234 | if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); |
234 | //qDebug( "recmask available and constructed." ); | 235 | //qDebug( "recmask available and constructed." ); |
235 | } | 236 | } |
236 | 237 | ||
237 | /* ChannelIterator it; | 238 | /* ChannelIterator it; |
238 | for ( it = _channels.begin(); it != _channels.end(); ++it ) | 239 | for ( it = _channels.begin(); it != _channels.end(); ++it ) |
239 | { | 240 | { |
240 | qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() ); | 241 | qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() ); |
241 | qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 ); | 242 | qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 ); |
242 | } | 243 | } |
243 | */ | 244 | */ |
244 | } | 245 | } |
245 | 246 | ||
246 | QStringList OMixerInterface::allChannels() const | 247 | QStringList OMixerInterface::allChannels() const |
247 | { | 248 | { |
248 | ChannelIterator it = _channels.begin(); | 249 | ChannelIterator it = _channels.begin(); |
249 | QStringList channels; | 250 | QStringList channels; |
250 | while ( it != _channels.end() ) | 251 | while ( it != _channels.end() ) |
251 | { | 252 | { |
252 | channels += it.key(); | 253 | channels += it.key(); |
253 | it++; | 254 | it++; |
254 | } | 255 | } |
255 | return channels; | 256 | return channels; |
256 | } | 257 | } |
257 | 258 | ||
258 | 259 | ||
259 | QStringList OMixerInterface::recChannels() const | 260 | QStringList OMixerInterface::recChannels() const |
260 | { | 261 | { |
261 | qWarning( "NYI" ); | 262 | qWarning( "NYI" ); |
262 | } | 263 | } |
263 | 264 | ||
264 | 265 | ||
265 | QStringList OMixerInterface::playChannels() const | 266 | QStringList OMixerInterface::playChannels() const |
266 | { | 267 | { |
267 | qWarning( "NYI" ); | 268 | qWarning( "NYI" ); |
268 | } | 269 | } |
269 | 270 | ||
270 | 271 | ||
271 | bool OMixerInterface::hasChannel( const QString& channel ) | 272 | bool OMixerInterface::hasChannel( const QString& channel ) |
272 | { | 273 | { |
273 | return _channels.contains( channel ); | 274 | return _channels.contains( channel ); |
274 | } | 275 | } |
275 | 276 | ||
276 | 277 | ||
277 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) | 278 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) |
278 | { | 279 | { |
279 | int volume = left; | 280 | int volume = left; |
280 | volume |= ( right == -1 ) ? left << 8 : right << 8; | 281 | volume |= ( right == -1 ) ? left << 8 : right << 8; |
281 | 282 | ||
282 | if ( _channels.contains( channel ) ) | 283 | if ( _channels.contains( channel ) ) |
283 | { | 284 | { |
284 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); | 285 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); |
285 | if ( result == -1 ) | 286 | if ( result == -1 ) |
286 | { | 287 | { |
287 | qWarning( "Can't set volume: %s", strerror( errno ) ); | 288 | qWarning( "Can't set volume: %s", strerror( errno ) ); |
288 | } | 289 | } |
289 | else | 290 | else |
290 | { | 291 | { |
291 | if ( result & 0xff != left ) | 292 | if ( result & 0xff != left ) |
292 | { | 293 | { |
293 | qWarning( "Device adjusted volume from %d to %d", left, result & 0xff ); | 294 | qWarning( "Device adjusted volume from %d to %d", left, result & 0xff ); |
294 | } | 295 | } |
295 | } | 296 | } |
296 | } | 297 | } |
297 | } | 298 | } |
298 | 299 | ||
299 | 300 | ||
300 | int OMixerInterface::volume( const QString& channel ) const | 301 | int OMixerInterface::volume( const QString& channel ) const |
301 | { | 302 | { |
302 | int volume; | 303 | int volume; |
303 | 304 | ||
304 | if ( _channels.contains( channel ) ) | 305 | if ( _channels.contains( channel ) ) |
305 | { | 306 | { |
306 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) | 307 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) |
307 | { | 308 | { |
308 | qWarning( "Can't get volume: %s", strerror( errno ) ); | 309 | qWarning( "Can't get volume: %s", strerror( errno ) ); |
309 | } | 310 | } |
310 | else return volume; | 311 | else return volume; |
311 | } | 312 | } |
312 | return -1; | 313 | return -1; |
313 | } | 314 | } |
314 | 315 | ||
315 | 316 | ||