summaryrefslogtreecommitdiff
authorzecke <zecke>2004-09-10 11:05:37 (UTC)
committer zecke <zecke>2004-09-10 11:05:37 (UTC)
commitd416ff23ea50303173d07ea243498a163f5995b5 (patch) (unidiff)
tree8ab861514fd1dc87c509e6ac988ed683f82370ec
parent224c96feb94acd6a87e1a2463aca9726afe925ef (diff)
downloadopie-d416ff23ea50303173d07ea243498a163f5995b5.zip
opie-d416ff23ea50303173d07ea243498a163f5995b5.tar.gz
opie-d416ff23ea50303173d07ea243498a163f5995b5.tar.bz2
The usual... fix warnings about unused parameters
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/oimagezoomer.cpp2
-rw-r--r--libopie2/opiemm/osoundsystem.cpp8
2 files changed, 6 insertions, 4 deletions
diff --git a/libopie2/opiemm/oimagezoomer.cpp b/libopie2/opiemm/oimagezoomer.cpp
index d1eec67..b7ef238 100644
--- a/libopie2/opiemm/oimagezoomer.cpp
+++ b/libopie2/opiemm/oimagezoomer.cpp
@@ -9,225 +9,225 @@
9#include <qpoint.h> 9#include <qpoint.h>
10#include <qsize.h> 10#include <qsize.h>
11 11
12namespace Opie { 12namespace Opie {
13namespace MM { 13namespace MM {
14 14
15/** 15/**
16 * \brief The most simple c'tor 16 * \brief The most simple c'tor
17 * The main c'tor. You still need to set a QPixmap/QIMage, 17 * The main c'tor. You still need to set a QPixmap/QIMage,
18 * setImageSize,setViewPortSize,setVisiblePoint 18 * setImageSize,setViewPortSize,setVisiblePoint
19 * 19 *
20 * @param parent The parent widget 20 * @param parent The parent widget
21 * @param name A name for this widget 21 * @param name A name for this widget
22 * @param fl The widget flags 22 * @param fl The widget flags
23 * 23 *
24 */ 24 */
25OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl ) 25OImageZoomer::OImageZoomer( QWidget* parent, const char* name, WFlags fl )
26 : QFrame( parent, name, fl ) { 26 : QFrame( parent, name, fl ) {
27 init(); 27 init();
28} 28}
29 29
30 30
31/** 31/**
32 * \brief This c'tor takes a QPixmap additional 32 * \brief This c'tor takes a QPixmap additional
33 * 33 *
34 * You initially set the QPixmap but you still need to provide 34 * You initially set the QPixmap but you still need to provide
35 * the additional data to make this widget useful 35 * the additional data to make this widget useful
36 * 36 *
37 * @param pix A Pixmap it'll be converted to a QImage later! 37 * @param pix A Pixmap it'll be converted to a QImage later!
38 * @param par The parent widget 38 * @param par The parent widget
39 * @param name The name of this widget 39 * @param name The name of this widget
40 * @param fl The widget flags 40 * @param fl The widget flags
41 */ 41 */
42OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl ) 42OImageZoomer::OImageZoomer( const QPixmap& pix, QWidget* par, const char* name, WFlags fl )
43 : QFrame( par, name, fl ) { 43 : QFrame( par, name, fl ) {
44 init(); 44 init();
45 setImage( pix ); 45 setImage( pix );
46} 46}
47 47
48 48
49/** 49/**
50 * \brief This c'tor takes a QImage instead 50 * \brief This c'tor takes a QImage instead
51 * You just provide a QImage which is saved. It behaves the same as the others. 51 * You just provide a QImage which is saved. It behaves the same as the others.
52 * 52 *
53 * @param img A Image which will be used for the zoomer content 53 * @param img A Image which will be used for the zoomer content
54 * @param par The parent of the widget 54 * @param par The parent of the widget
55 * @param name The name of the widget 55 * @param name The name of the widget
56 * @param fl The widgets flags 56 * @param fl The widgets flags
57 */ 57 */
58OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl) 58OImageZoomer::OImageZoomer( const QImage& img, QWidget* par, const char* name, WFlags fl)
59 : QFrame( par, name, fl ) { 59 : QFrame( par, name, fl ) {
60 init(); 60 init();
61 setImage( img ); 61 setImage( img );
62} 62}
63 63
64 64
65/** 65/**
66 * \brief overloaded c'tor 66 * \brief overloaded c'tor
67 * 67 *
68 * This differs only in the arguments it takes 68 * This differs only in the arguments it takes
69 * 69 *
70 * 70 *
71 * @param pSize The size of the Page you show 71 * @param pSize The size of the Page you show
72 * @param vSize The size of the viewport. The size of the visible part of the widget 72 * @param vSize The size of the viewport. The size of the visible part of the widget
73 * @param par The parent of the widget 73 * @param par The parent of the widget
74 * @param name The name 74 * @param name The name
75 * @param fl The window flags 75 * @param fl The window flags
76 */ 76 */
77OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par, 77OImageZoomer::OImageZoomer( const QSize& pSize, const QSize& vSize, QWidget* par,
78 const char* name, WFlags fl ) 78 const char* name, WFlags fl )
79 : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) { 79 : QFrame( par, name, fl ), m_imgSize( pSize ),m_visSize( vSize ) {
80 init(); 80 init();
81} 81}
82 82
83/** 83/**
84 * d'tor 84 * d'tor
85 */ 85 */
86OImageZoomer::~OImageZoomer() { 86OImageZoomer::~OImageZoomer() {
87 87
88} 88}
89 89
90void OImageZoomer::init() { 90void OImageZoomer::init() {
91 m_mevent = false; 91 m_mevent = false;
92 setFrameStyle( Panel | Sunken ); 92 setFrameStyle( Panel | Sunken );
93} 93}
94 94
95 95
96/** 96/**
97 * \brief set the page/image size 97 * \brief set the page/image size
98 * Tell us the QSize of the Data you show to the user. We need this 98 * Tell us the QSize of the Data you show to the user. We need this
99 * to do the calculations 99 * to do the calculations
100 * 100 *
101 * @param size The size of the stuff you want to zoom on 101 * @param size The size of the stuff you want to zoom on
102 */ 102 */
103void OImageZoomer::setImageSize( const QSize& size ) { 103void OImageZoomer::setImageSize( const QSize& size ) {
104 m_imgSize = size; 104 m_imgSize = size;
105 repaint(); 105 repaint();
106} 106}
107 107
108/** 108/**
109 * \brief Set the size of the viewport 109 * \brief Set the size of the viewport
110 * Tell us the QSize of the viewport. The viewport is the part 110 * Tell us the QSize of the viewport. The viewport is the part
111 * of the widget which is exposed on the screen 111 * of the widget which is exposed on the screen
112 * 112 *
113 * @param size Te size of the viewport 113 * @param size Te size of the viewport
114 * 114 *
115 * @see QScrollView::viewport() 115 * @see QScrollView::viewport()
116 */ 116 */
117void OImageZoomer::setViewPortSize( const QSize& size ) { 117void OImageZoomer::setViewPortSize( const QSize& size ) {
118 m_visSize = size; 118 m_visSize = size;
119 repaint(); 119 repaint();
120} 120}
121 121
122/** 122/**
123 * \brief the point in the topleft corner which is currently visible 123 * \brief the point in the topleft corner which is currently visible
124 * Set the visible point. This most of the times relate to QScrollView::contentsX() 124 * Set the visible point. This most of the times relate to QScrollView::contentsX()
125 * and QScrollView::contentsY() 125 * and QScrollView::contentsY()
126 * 126 *
127 * @see setVisiblePoint(int,int) 127 * @see setVisiblePoint(int,int)
128 */ 128 */
129void OImageZoomer::setVisiblePoint( const QPoint& pt ) { 129void OImageZoomer::setVisiblePoint( const QPoint& pt ) {
130 m_visPt = pt; 130 m_visPt = pt;
131 repaint(); 131 repaint();
132} 132}
133 133
134 134
135/** 135/**
136 * Set the Image. The image will be resized on resizeEvent 136 * Set the Image. The image will be resized on resizeEvent
137 * and it'll set the QPixmap background 137 * and it'll set the QPixmap background
138 * 138 *
139 * @param img The image will be stored internally and used as the background 139 * @param img The image will be stored internally and used as the background
140 */ 140 */
141void OImageZoomer::setImage( const QImage& img) { 141void OImageZoomer::setImage( const QImage& img) {
142 m_img = img; 142 m_img = img;
143 resizeEvent( 0 ); 143 resizeEvent( 0 );
144 repaint(); 144 repaint();
145} 145}
146 146
147/** 147/**
148 * overloaded function it calls the QImage version 148 * overloaded function it calls the QImage version
149 */ 149 */
150void OImageZoomer::setImage( const QPixmap& pix) { 150void OImageZoomer::setImage( const QPixmap& pix) {
151 setImage( pix.convertToImage() ); 151 setImage( pix.convertToImage() );
152} 152}
153 153
154void OImageZoomer::resizeEvent( QResizeEvent* ev ) { 154void OImageZoomer::resizeEvent( QResizeEvent* ev ) {
155 QFrame::resizeEvent( ev ); 155 QFrame::resizeEvent( ev );
156 setBackgroundOrigin( QWidget::WidgetOrigin ); 156 setBackgroundOrigin( QWidget::WidgetOrigin );
157 // TODO Qt3 use PalettePixmap and use size 157 // TODO Qt3 use PalettePixmap and use size
158 QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) ); 158 QPixmap pix; pix.convertFromImage( m_img.smoothScale( size().width(), size().height() ) );
159 setBackgroundPixmap( pix); 159 setBackgroundPixmap( pix);
160} 160}
161 161
162void OImageZoomer::drawContents( QPainter* p ) { 162void OImageZoomer::drawContents( QPainter* p ) {
163 /* 163 /*
164 * if the page size 164 * if the page size
165 */ 165 */
166 if ( m_imgSize.isEmpty() ) 166 if ( m_imgSize.isEmpty() )
167 return; 167 return;
168 168
169 /* 169 /*
170 * paint a red rect which represents the visible size 170 * paint a red rect which represents the visible size
171 * 171 *
172 * We need to recalculate x,y and width and height of the 172 * We need to recalculate x,y and width and height of the
173 * rect. So image size relates to contentRect 173 * rect. So image size relates to contentRect
174 * 174 *
175 */ 175 */
176 QRect c( contentsRect() ); 176 QRect c( contentsRect() );
177 p->setPen( Qt::red ); 177 p->setPen( Qt::red );
178 178
179 /* 179 /*
180 * the contentRect is set equal to the size of the image 180 * the contentRect is set equal to the size of the image
181 * Rect/Original = NewRectORWidth/OriginalVisibleStuff and then simply we 181 * Rect/Original = NewRectORWidth/OriginalVisibleStuff and then simply we
182 * need to add the c.y/x due usage of QFrame 182 * need to add the c.y/x due usage of QFrame
183 * For x and y we use the visiblePoint 183 * For x and y we use the visiblePoint
184 * For height and width we use the size of the viewport 184 * For height and width we use the size of the viewport
185 * if width/height would be bigger than our widget we use this width/height 185 * if width/height would be bigger than our widget we use this width/height
186 * 186 *
187 */ 187 */
188 int len = m_imgSize.width(); 188 int len = m_imgSize.width();
189 int x = (c.width()*m_visPt.x())/len + c.x(); 189 int x = (c.width()*m_visPt.x())/len + c.x();
190 int w = (c.width()*m_visSize.width() )/len + c.x(); 190 int w = (c.width()*m_visSize.width() )/len + c.x();
191 if ( w > c.width() ) w = c.width(); 191 if ( w > c.width() ) w = c.width();
192 192
193 len = m_imgSize.height(); 193 len = m_imgSize.height();
194 int y = (c.height()*m_visPt.y() )/len + c.y(); 194 int y = (c.height()*m_visPt.y() )/len + c.y();
195 int h = (c.height()*m_visSize.height() )/len + c.y(); 195 int h = (c.height()*m_visSize.height() )/len + c.y();
196 if ( h > c.height() ) h = c.height(); 196 if ( h > c.height() ) h = c.height();
197 197
198 p->drawRect( x, y, w, h ); 198 p->drawRect( x, y, w, h );
199} 199}
200 200
201void OImageZoomer::mousePressEvent( QMouseEvent*ev) { 201void OImageZoomer::mousePressEvent( QMouseEvent*) {
202 m_mouseX = m_mouseY = -1; 202 m_mouseX = m_mouseY = -1;
203 m_mevent = true; 203 m_mevent = true;
204} 204}
205 205
206void OImageZoomer::mouseReleaseEvent( QMouseEvent*ev) { 206void OImageZoomer::mouseReleaseEvent( QMouseEvent*ev) {
207 if (!m_mevent) return; 207 if (!m_mevent) return;
208 int mx, my; 208 int mx, my;
209 mx = ev->x(); 209 mx = ev->x();
210 my = ev->y(); 210 my = ev->y();
211 int diffx = (mx) * m_imgSize.width() / width(); 211 int diffx = (mx) * m_imgSize.width() / width();
212 int diffy = (my) * m_imgSize.height() / height(); 212 int diffy = (my) * m_imgSize.height() / height();
213 emit zoomArea(diffx,diffy); 213 emit zoomArea(diffx,diffy);
214} 214}
215 215
216void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) { 216void OImageZoomer::mouseMoveEvent( QMouseEvent* ev ) {
217 int mx, my; 217 int mx, my;
218 mx = ev->x(); 218 mx = ev->x();
219 my = ev->y(); 219 my = ev->y();
220 220
221 if ( m_mouseX != -1 && m_mouseY != -1 ) { 221 if ( m_mouseX != -1 && m_mouseY != -1 ) {
222 m_mevent = false; 222 m_mevent = false;
223 int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width(); 223 int diffx = ( mx - m_mouseX ) * m_imgSize.width() / width();
224 int diffy = ( my - m_mouseY ) * m_imgSize.height() / height(); 224 int diffy = ( my - m_mouseY ) * m_imgSize.height() / height();
225 emit zoomAreaRel( diffx, diffy ); 225 emit zoomAreaRel( diffx, diffy );
226 } 226 }
227 m_mouseX = mx; 227 m_mouseX = mx;
228 m_mouseY = my; 228 m_mouseY = my;
229} 229}
230 230
231 231
232} 232}
233} 233}
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 2b17230..763ff65 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,315 +1,317 @@
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#include <opie2/odebug.h>
34 34
35#include <errno.h> 35#include <errno.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <string.h> 37#include <string.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/types.h> 39#include <sys/types.h>
40#include <sys/soundcard.h> 40#include <sys/soundcard.h>
41#include <sys/stat.h> 41#include <sys/stat.h>
42 42
43 43
44using namespace Opie::Core; 44using namespace Opie::Core;
45using namespace Opie::MM; 45using namespace Opie::MM;
46/*====================================================================================== 46/*======================================================================================
47 * OSoundSystem 47 * OSoundSystem
48 *======================================================================================*/ 48 *======================================================================================*/
49 49
50OSoundSystem* OSoundSystem::_instance = 0; 50OSoundSystem* OSoundSystem::_instance = 0;
51 51
52OSoundSystem::OSoundSystem() 52OSoundSystem::OSoundSystem()
53{ 53{
54 odebug << "OSoundSystem::OSoundSystem()" << oendl; 54 odebug << "OSoundSystem::OSoundSystem()" << oendl;
55 synchronize(); 55 synchronize();
56} 56}
57 57
58void OSoundSystem::synchronize() 58void OSoundSystem::synchronize()
59{ 59{
60 // gather available interfaces by inspecting /dev 60 // gather available interfaces by inspecting /dev
61 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 61 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
62 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 62 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
63 63
64 _interfaces.clear(); 64 _interfaces.clear();
65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
66 66
67 67
68 /* 68 /*
69 69
70 QString str; 70 QString str;
71 QFile f( "/dev/sound" ); 71 QFile f( "/dev/sound" );
72 bool hasFile = f.open( IO_ReadOnly ); 72 bool hasFile = f.open( IO_ReadOnly );
73 if ( !hasFile ) 73 if ( !hasFile )
74 { 74 {
75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
76 return; 76 return;
77 } 77 }
78 QTextStream s( &f ); 78 QTextStream s( &f );
79 s.readLine(); 79 s.readLine();
80 s.readLine(); 80 s.readLine();
81 while ( !s.atEnd() ) 81 while ( !s.atEnd() )
82 { 82 {
83 s >> str; 83 s >> str;
84 str.truncate( str.find( ':' ) ); 84 str.truncate( str.find( ':' ) );
85 odebug << "OSoundSystem: found interface '" << str << "'" << oendl; 85 odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
86 OAudioInterface* iface; 86 OAudioInterface* iface;
87 iface = new OAudioInterface( this, (const char*) str ); 87 iface = new OAudioInterface( this, (const char*) str );
88 88
89 _interfaces.insert( str, iface ); 89 _interfaces.insert( str, iface );
90 s.readLine(); 90 s.readLine();
91 } 91 }
92*/ 92*/
93} 93}
94 94
95 95
96int OSoundSystem::count() const 96int OSoundSystem::count() const
97{ 97{
98 return _interfaces.count(); 98 return _interfaces.count();
99} 99}
100 100
101 101
102OSoundCard* OSoundSystem::card( const QString& iface ) const 102OSoundCard* OSoundSystem::card( const QString& iface ) const
103{ 103{
104 return _interfaces[iface]; 104 return _interfaces[iface];
105} 105}
106 106
107 107
108OSoundSystem* OSoundSystem::instance() 108OSoundSystem* OSoundSystem::instance()
109{ 109{
110 if ( !_instance ) _instance = new OSoundSystem(); 110 if ( !_instance ) _instance = new OSoundSystem();
111 return _instance; 111 return _instance;
112} 112}
113 113
114 114
115OSoundSystem::CardIterator OSoundSystem::iterator() const 115OSoundSystem::CardIterator OSoundSystem::iterator() const
116{ 116{
117 return OSoundSystem::CardIterator( _interfaces ); 117 return OSoundSystem::CardIterator( _interfaces );
118} 118}
119 119
120 120
121/*====================================================================================== 121/*======================================================================================
122 * OSoundCard 122 * OSoundCard
123 *======================================================================================*/ 123 *======================================================================================*/
124 124
125OSoundCard::OSoundCard( QObject* parent, const char* name ) 125OSoundCard::OSoundCard( QObject* parent, const char* name )
126 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 126 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
127{ 127{
128 odebug << "OSoundCard::OSoundCard()" << oendl; 128 odebug << "OSoundCard::OSoundCard()" << oendl;
129 init(); 129 init();
130} 130}
131 131
132 132
133OSoundCard::~OSoundCard() 133OSoundCard::~OSoundCard()
134{ 134{
135} 135}
136 136
137 137
138void OSoundCard::init() 138void OSoundCard::init()
139{ 139{
140 _audio = new OAudioInterface( this, "/dev/dsp" ); 140 _audio = new OAudioInterface( this, "/dev/dsp" );
141 _mixer = new OMixerInterface( this, "/dev/mixer" ); 141 _mixer = new OMixerInterface( this, "/dev/mixer" );
142} 142}
143 143
144 144
145/*====================================================================================== 145/*======================================================================================
146 * OAudioInterface 146 * OAudioInterface
147 *======================================================================================*/ 147 *======================================================================================*/
148 148
149OAudioInterface::OAudioInterface( QObject* parent, const char* name ) 149OAudioInterface::OAudioInterface( QObject* parent, const char* name )
150 :QObject( parent, name ), _sfd(0) 150 :QObject( parent, name ), _sfd(0)
151{ 151{
152 odebug << "OAudioInterface::OAudioInterface()" << oendl; 152 odebug << "OAudioInterface::OAudioInterface()" << oendl;
153 init(); 153 init();
154} 154}
155 155
156 156
157OAudioInterface::~OAudioInterface() 157OAudioInterface::~OAudioInterface()
158{ 158{
159} 159}
160 160
161 161
162void OAudioInterface::init() 162void OAudioInterface::init()
163{ 163{
164 164
165 165
166} 166}
167 167
168 168
169/*====================================================================================== 169/*======================================================================================
170 * OMixerInterface 170 * OMixerInterface
171 *======================================================================================*/ 171 *======================================================================================*/
172 172
173OMixerInterface::OMixerInterface( QObject* parent, const char* name ) 173OMixerInterface::OMixerInterface( QObject* parent, const char* name )
174 :QObject( parent, name ) 174 :QObject( parent, name )
175{ 175{
176 odebug << "OMixerInterface::OMixerInterface()" << oendl; 176 odebug << "OMixerInterface::OMixerInterface()" << oendl;
177 init(); 177 init();
178} 178}
179 179
180 180
181OMixerInterface::~OMixerInterface() 181OMixerInterface::~OMixerInterface()
182{ 182{
183} 183}
184 184
185 185
186void OMixerInterface::init() 186void OMixerInterface::init()
187{ 187{
188 // open the device 188 // open the device
189 _fd = ::open( name(), O_RDWR ); 189 _fd = ::open( name(), O_RDWR );
190 if ( _fd == -1 ) 190 if ( _fd == -1 )
191 { 191 {
192 owarn << "OMixerInterface::init(): Can't open mixer." << oendl; 192 owarn << "OMixerInterface::init(): Can't open mixer." << oendl;
193 return; 193 return;
194 } 194 }
195 195
196 // construct the device capabilities 196 // construct the device capabilities
197 int devmask = 0; 197 int devmask = 0;
198 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) 198 if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 )
199 { 199 {
200 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "PlayVolume", SOUND_MIXER_VOLUME ); 200 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 ); 201 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 ); 202 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 ); 203 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 ); 204 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 ); 205 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 ); 206 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 ); 207 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 ); 208 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 ); 209 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 ); 210 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 ); 211 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 ); 212 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 ); 213 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "PlayOutputGain", SOUND_MIXER_OGAIN );
214 //odebug << "devmask available and constructed." << oendl; 214 //odebug << "devmask available and constructed." << oendl;
215 } 215 }
216 216
217 devmask = 0; 217 devmask = 0;
218 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) 218 if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 )
219 { 219 {
220 if ( devmask & ( 1 << SOUND_MIXER_VOLUME ) ) _channels.insert( "RecVolume", SOUND_MIXER_VOLUME ); 220 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 ); 221 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 ); 222 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 ); 223 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 ); 224 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 ); 225 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 ); 226 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 ); 227 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 ); 228 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 ); 229 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 ); 230 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 ); 231 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 ); 232 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 ); 233 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN );
234 //odebug << "recmask available and constructed." << oendl; 234 //odebug << "recmask available and constructed." << oendl;
235 } 235 }
236 236
237/* ChannelIterator it; 237/* ChannelIterator it;
238 for ( it = _channels.begin(); it != _channels.end(); ++it ) 238 for ( it = _channels.begin(); it != _channels.end(); ++it )
239 { 239 {
240 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl; 240 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
241 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl; 241 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
242 } 242 }
243*/ 243*/
244} 244}
245 245
246QStringList OMixerInterface::allChannels() const 246QStringList OMixerInterface::allChannels() const
247{ 247{
248 ChannelIterator it = _channels.begin(); 248 ChannelIterator it = _channels.begin();
249 QStringList channels; 249 QStringList channels;
250 while ( it != _channels.end() ) 250 while ( it != _channels.end() )
251 { 251 {
252 channels += it.key(); 252 channels += it.key();
253 it++; 253 it++;
254 } 254 }
255 return channels; 255 return channels;
256} 256}
257 257
258 258
259QStringList OMixerInterface::recChannels() const 259QStringList OMixerInterface::recChannels() const
260{ 260{
261 owarn << "NYI" << oendl; 261 owarn << "NYI" << oendl;
262 return QStringList();
262} 263}
263 264
264 265
265QStringList OMixerInterface::playChannels() const 266QStringList OMixerInterface::playChannels() const
266{ 267{
267 owarn << "NYI" << oendl; 268 owarn << "NYI" << oendl;
269 return QStringList();
268} 270}
269 271
270 272
271bool OMixerInterface::hasChannel( const QString& channel ) 273bool OMixerInterface::hasChannel( const QString& channel )
272{ 274{
273 return _channels.contains( channel ); 275 return _channels.contains( channel );
274} 276}
275 277
276 278
277void OMixerInterface::setVolume( const QString& channel, int left, int right ) 279void OMixerInterface::setVolume( const QString& channel, int left, int right )
278{ 280{
279 int volume = left; 281 int volume = left;
280 volume |= ( right == -1 ) ? left << 8 : right << 8; 282 volume |= ( right == -1 ) ? left << 8 : right << 8;
281 283
282 if ( _channels.contains( channel ) ) 284 if ( _channels.contains( channel ) )
283 { 285 {
284 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); 286 int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume );
285 if ( result == -1 ) 287 if ( result == -1 )
286 { 288 {
287 owarn << "Can't set volume: " << strerror( errno ) << oendl; 289 owarn << "Can't set volume: " << strerror( errno ) << oendl;
288 } 290 }
289 else 291 else
290 { 292 {
291 if ( result & 0xff != left ) 293 if ( result & 0xff != left )
292 { 294 {
293 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl; 295 owarn << "Device adjusted volume from " << left << " to " << (result & 0xff) << oendl;
294 } 296 }
295 } 297 }
296 } 298 }
297} 299}
298 300
299 301
300int OMixerInterface::volume( const QString& channel ) const 302int OMixerInterface::volume( const QString& channel ) const
301{ 303{
302 int volume; 304 int volume;
303 305
304 if ( _channels.contains( channel ) ) 306 if ( _channels.contains( channel ) )
305 { 307 {
306 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) 308 if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 )
307 { 309 {
308 owarn << "Can't get volume: " << strerror( errno ) << oendl; 310 owarn << "Can't get volume: " << strerror( errno ) << oendl;
309 } 311 }
310 else return volume; 312 else return volume;
311 } 313 }
312 return -1; 314 return -1;
313} 315}
314 316
315 317