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