summaryrefslogtreecommitdiff
path: root/libopie2/opiemm/osoundsystem.cpp
Unidiff
Diffstat (limited to 'libopie2/opiemm/osoundsystem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/osoundsystem.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 51e088c..07f26c0 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,139 +1,141 @@
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;
45using namespace Opie::MM;
44/*====================================================================================== 46/*======================================================================================
45 * OSoundSystem 47 * OSoundSystem
46 *======================================================================================*/ 48 *======================================================================================*/
47 49
48OSoundSystem* OSoundSystem::_instance = 0; 50OSoundSystem* OSoundSystem::_instance = 0;
49 51
50OSoundSystem::OSoundSystem() 52OSoundSystem::OSoundSystem()
51{ 53{
52 odebug << "OSoundSystem::OSoundSystem()" << oendl; 54 odebug << "OSoundSystem::OSoundSystem()" << oendl;
53 synchronize(); 55 synchronize();
54} 56}
55 57
56void OSoundSystem::synchronize() 58void OSoundSystem::synchronize()
57{ 59{
58 // gather available interfaces by inspecting /dev 60 // 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 61 //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 62 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
61 63
62 _interfaces.clear(); 64 _interfaces.clear();
63 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 65 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
64 66
65 67
66 /* 68 /*
67 69
68 QString str; 70 QString str;
69 QFile f( "/dev/sound" ); 71 QFile f( "/dev/sound" );
70 bool hasFile = f.open( IO_ReadOnly ); 72 bool hasFile = f.open( IO_ReadOnly );
71 if ( !hasFile ) 73 if ( !hasFile )
72 { 74 {
73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
74 return; 76 return;
75 } 77 }
76 QTextStream s( &f ); 78 QTextStream s( &f );
77 s.readLine(); 79 s.readLine();
78 s.readLine(); 80 s.readLine();
79 while ( !s.atEnd() ) 81 while ( !s.atEnd() )
80 { 82 {
81 s >> str; 83 s >> str;
82 str.truncate( str.find( ':' ) ); 84 str.truncate( str.find( ':' ) );
83 qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); 85 qDebug( "OSoundSystem: found interface '%s'", (const char*) str );
84 OAudioInterface* iface; 86 OAudioInterface* iface;
85 iface = new OAudioInterface( this, (const char*) str ); 87 iface = new OAudioInterface( this, (const char*) str );
86 88
87 _interfaces.insert( str, iface ); 89 _interfaces.insert( str, iface );
88 s.readLine(); 90 s.readLine();
89 } 91 }
90*/ 92*/
91} 93}
92 94
93 95
94int OSoundSystem::count() const 96int OSoundSystem::count() const
95{ 97{
96 return _interfaces.count(); 98 return _interfaces.count();
97} 99}
98 100
99 101
100OSoundCard* OSoundSystem::card( const QString& iface ) const 102OSoundCard* OSoundSystem::card( const QString& iface ) const
101{ 103{
102 return _interfaces[iface]; 104 return _interfaces[iface];
103} 105}
104 106
105 107
106OSoundSystem* OSoundSystem::instance() 108OSoundSystem* OSoundSystem::instance()
107{ 109{
108 if ( !_instance ) _instance = new OSoundSystem(); 110 if ( !_instance ) _instance = new OSoundSystem();
109 return _instance; 111 return _instance;
110} 112}
111 113
112 114
113OSoundSystem::CardIterator OSoundSystem::iterator() const 115OSoundSystem::CardIterator OSoundSystem::iterator() const
114{ 116{
115 return OSoundSystem::CardIterator( _interfaces ); 117 return OSoundSystem::CardIterator( _interfaces );
116} 118}
117 119
118 120
119/*====================================================================================== 121/*======================================================================================
120 * OSoundCard 122 * OSoundCard
121 *======================================================================================*/ 123 *======================================================================================*/
122 124
123OSoundCard::OSoundCard( QObject* parent, const char* name ) 125OSoundCard::OSoundCard( QObject* parent, const char* name )
124 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 126 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
125{ 127{
126 odebug << "OSoundCard::OSoundCard()" << oendl; 128 odebug << "OSoundCard::OSoundCard()" << oendl;
127 init(); 129 init();
128} 130}
129 131
130 132
131OSoundCard::~OSoundCard() 133OSoundCard::~OSoundCard()
132{ 134{
133} 135}
134 136
135 137
136void OSoundCard::init() 138void OSoundCard::init()
137{ 139{
138 _audio = new OAudioInterface( this, "/dev/dsp" ); 140 _audio = new OAudioInterface( this, "/dev/dsp" );
139 _mixer = new OMixerInterface( this, "/dev/mixer" ); 141 _mixer = new OMixerInterface( this, "/dev/mixer" );