author | mickeyl <mickeyl> | 2003-06-15 12:47:05 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-06-15 12:47:05 (UTC) |
commit | 24d20c74b8e02ad7b7575ab8f577880f98e43655 (patch) (unidiff) | |
tree | f10e70dc26d89012e70a7763bfea78ac14971650 | |
parent | 6b682070b6d83f3537dd9fa5aee715ab142a04e6 (diff) | |
download | opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.zip opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.tar.gz opie-24d20c74b8e02ad7b7575ab8f577880f98e43655.tar.bz2 |
just a check-in before i lose that because of my fscking harddrive...
this is work-in-progress...
-rw-r--r-- | libopie2/README | 12 | ||||
-rw-r--r-- | libopie2/config.in | 1 | ||||
-rw-r--r-- | libopie2/examples/config.in | 6 | ||||
-rw-r--r-- | libopie2/examples/examples.pro | 2 | ||||
-rw-r--r-- | libopie2/examples/opiemm/.cvsignore | 6 | ||||
-rw-r--r-- | libopie2/examples/opiemm/opiemm.pro | 3 | ||||
-rw-r--r-- | libopie2/examples/opiemm/osoundsystemdemo/.cvsignore | 6 | ||||
-rw-r--r-- | libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp | 32 | ||||
-rw-r--r-- | libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.pro | 12 | ||||
-rw-r--r-- | libopie2/libopie2.control | 2 | ||||
-rw-r--r-- | libopie2/libopie2.pro | 2 | ||||
-rw-r--r-- | libopie2/opiemm/.cvsignore | 6 | ||||
-rw-r--r-- | libopie2/opiemm/config.in | 7 | ||||
-rw-r--r-- | libopie2/opiemm/opiemm.pro | 16 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.cpp | 315 | ||||
-rw-r--r-- | libopie2/opiemm/osoundsystem.h | 216 |
16 files changed, 638 insertions, 6 deletions
diff --git a/libopie2/README b/libopie2/README index 5130290..57172a7 100644 --- a/libopie2/README +++ b/libopie2/README | |||
@@ -15,16 +15,17 @@ | |||
15 | -------------------------------------------------------- | 15 | -------------------------------------------------------- |
16 | 16 | ||
17 | libopie is functionally seperated into the following libraries: | 17 | libopie is functionally seperated into the following libraries: |
18 | - libopiecore | 18 | - libopiecore |
19 | - libopieui | 19 | - libopieui |
20 | - libopiepim | 20 | - libopiepim |
21 | - libopiedb | 21 | - libopiedb |
22 | - libopienet | 22 | - libopienet |
23 | - libopiemm | ||
23 | 24 | ||
24 | 1.1 Contents of libopiecore [ opiecore ] | 25 | 1.1 Contents of libopiecore [ opiecore ] |
25 | -------------------------------------------------------- | 26 | -------------------------------------------------------- |
26 | 27 | ||
27 | - odbgstream | 28 | - odbgstream |
28 | - ondbgstream | 29 | - ondbgstream |
29 | 30 | ||
30 | - oprocctrl | 31 | - oprocctrl |
@@ -127,16 +128,22 @@ USE THE CLASSES IN libopie/pim INSTEAD !(eilers) | |||
127 | - oippacket | 128 | - oippacket |
128 | - oudppacket | 129 | - oudppacket |
129 | - otcppacket | 130 | - otcppacket |
130 | 131 | ||
131 | <libmail stuff> | 132 | <libmail stuff> |
132 | <libbend stuff> | 133 | <libbend stuff> |
133 | <libftp stuff> | 134 | <libftp stuff> |
134 | 135 | ||
136 | 1.6 Contents of libopiemm [ opiemm ] | ||
137 | -------------------------------------------------------- | ||
138 | |||
139 | - osoundsystem | ||
140 | - oaudiointerface | ||
141 | - osoundserver | ||
135 | 142 | ||
136 | -------------------------------------------------------- | 143 | -------------------------------------------------------- |
137 | 2.0 Feature Description | 144 | 2.0 Feature Description |
138 | -------------------------------------------------------- | 145 | -------------------------------------------------------- |
139 | 146 | ||
140 | 2.1 libopiecore | 147 | 2.1 libopiecore |
141 | 148 | ||
142 | ... | 149 | ... |
@@ -150,8 +157,13 @@ USE THE CLASSES IN libopie/pim INSTEAD !(eilers) | |||
150 | ... | 157 | ... |
151 | 158 | ||
152 | 2.4 libopiedb | 159 | 2.4 libopiedb |
153 | 160 | ||
154 | ... | 161 | ... |
155 | 162 | ||
156 | 2.5 libopienet | 163 | 2.5 libopienet |
157 | 164 | ||
165 | ... | ||
166 | |||
167 | 2.6 libopiemm | ||
168 | |||
169 | ... | ||
diff --git a/libopie2/config.in b/libopie2/config.in index 7c4d9bb..5a0e443 100644 --- a/libopie2/config.in +++ b/libopie2/config.in | |||
@@ -1,10 +1,11 @@ | |||
1 | menu "libopie2" | 1 | menu "libopie2" |
2 | source libopie2/opiecore/config.in | 2 | source libopie2/opiecore/config.in |
3 | source libopie2/opiedb/config.in | 3 | source libopie2/opiedb/config.in |
4 | source libopie2/opienet/config.in | 4 | source libopie2/opienet/config.in |
5 | source libopie2/opiepim/config.in | 5 | source libopie2/opiepim/config.in |
6 | source libopie2/opieui/config.in | 6 | source libopie2/opieui/config.in |
7 | source libopie2/opiemm/config.in | ||
7 | comment "" | 8 | comment "" |
8 | source libopie2/examples/config.in | 9 | source libopie2/examples/config.in |
9 | endmenu | 10 | endmenu |
10 | 11 | ||
diff --git a/libopie2/examples/config.in b/libopie2/examples/config.in index d18e479..478a822 100644 --- a/libopie2/examples/config.in +++ b/libopie2/examples/config.in | |||
@@ -1,6 +1,6 @@ | |||
1 | config LIBOPIE2EXAMPLES | 1 | config LIBOPIE2EXAMPLES |
2 | boolean "libopie2 examples" | 2 | boolean "libopie2 examples" |
3 | default "n" | 3 | default "n" |
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI | 4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI && LIBOPIE2MM |
5 | comment "the examples need a libqpe, libopie2core, libopie2db, libopie2net, libopie2pim and libopie2ui" | 5 | comment "the examples need a libqpe, libopie2core, libopie2db, libopie2net, libopie2pim, libopie2ui and libopie2mm" |
6 | depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI) | 6 | depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2NET && LIBOPIE2UI && LIBOPIE2PIM && LIBOPIE2UI && LIBOPIE2MM) |
diff --git a/libopie2/examples/examples.pro b/libopie2/examples/examples.pro index 2ae7eb7..8add40d 100644 --- a/libopie2/examples/examples.pro +++ b/libopie2/examples/examples.pro | |||
@@ -1,4 +1,4 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | unix:SUBDIRS = opieui opienet opiecore | 2 | unix:SUBDIRS = opieui opienet opiecore opiemm |
3 | 3 | ||
4 | #include ( ../../../include.pro ) | 4 | #include ( ../../../include.pro ) |
diff --git a/libopie2/examples/opiemm/.cvsignore b/libopie2/examples/opiemm/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiemm/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/libopie2/examples/opiemm/opiemm.pro b/libopie2/examples/opiemm/opiemm.pro new file mode 100644 index 0000000..0522ebe --- a/dev/null +++ b/libopie2/examples/opiemm/opiemm.pro | |||
@@ -0,0 +1,3 @@ | |||
1 | TEMPLATE = subdirs | ||
2 | SUBDIRS = osoundsystemdemo | ||
3 | |||
diff --git a/libopie2/examples/opiemm/osoundsystemdemo/.cvsignore b/libopie2/examples/opiemm/osoundsystemdemo/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/examples/opiemm/osoundsystemdemo/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp new file mode 100644 index 0000000..79bf327 --- a/dev/null +++ b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.cpp | |||
@@ -0,0 +1,32 @@ | |||
1 | #include <opie2/osoundsystem.h> | ||
2 | |||
3 | int main( int argc, char** argv ) | ||
4 | { | ||
5 | qDebug( "OPIE Sound System Demo" ); | ||
6 | |||
7 | OSoundSystem* sound = OSoundSystem::instance(); | ||
8 | |||
9 | OSoundSystem::CardIterator it = sound->iterator(); | ||
10 | /* | ||
11 | while ( it.current() ) | ||
12 | { | ||
13 | qDebug( "DEMO: OSoundSystem contains Interface '%s'", (const char*) it.current()->name() ); | ||
14 | ++it; | ||
15 | } | ||
16 | |||
17 | */ | ||
18 | OSoundCard* card = it.current(); | ||
19 | |||
20 | OMixerInterface* mixer = card->mixer(); | ||
21 | |||
22 | QStringList channels = mixer->allChannels(); | ||
23 | |||
24 | for ( QStringList::Iterator it = channels.begin(); it != channels.end(); ++it ) | ||
25 | { | ||
26 | qDebug( "OSSDEMO: Mixer has channel %s", (const char*) *it ); | ||
27 | qDebug( "OSSDEMO: +--- volume %d (left) | %d (right)", mixer->volume( *it ) & 0xff, mixer->volume( *it ) >> 8 ); | ||
28 | } | ||
29 | |||
30 | return 0; | ||
31 | |||
32 | } | ||
diff --git a/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.pro b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.pro new file mode 100644 index 0000000..ba66165 --- a/dev/null +++ b/libopie2/examples/opiemm/osoundsystemdemo/osoundsystemdemo.pro | |||
@@ -0,0 +1,12 @@ | |||
1 | TEMPLATE = app | ||
2 | CONFIG = qt warn_on debug | ||
3 | HEADERS = | ||
4 | SOURCES = osoundsystemdemo.cpp | ||
5 | INCLUDEPATH += $(OPIEDIR)/include | ||
6 | DEPENDPATH += $(OPIEDIR)/include | ||
7 | LIBS += -lopiecore2 -lopiemm2 | ||
8 | TARGET = osoundsystemdemo | ||
9 | MOC_DIR = moc | ||
10 | OBJECTS_DIR = obj | ||
11 | |||
12 | include ( $(OPIEDIR)/include.pro ) | ||
diff --git a/libopie2/libopie2.control b/libopie2/libopie2.control index 0733bf4..cb5ada9 100644 --- a/libopie2/libopie2.control +++ b/libopie2/libopie2.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: libopie2 | 1 | Package: libopie2 |
2 | Files: $OPIEDIR/lib/libopiecore2.so.1.8.1 $OPIEDIR/lib/libopiecore2.so.1.8 $OPIEDIR/lib/libopiecore2.so.1 $OPIEDIR/lib/libopienet2.so.1.8.1 $OPIEDIR/lib/libopienet2.so.1.8 $OPIEDIR/lib/libopienet2.so.1 $OPIEDIR/lib/libopieui2.so.1.8.1 $OPIEDIR/lib/libopieui2.so.1.8 $OPIEDIR/lib/libopieui2.so.1 $OPIEDIR/etc/manufacturers | 2 | Files: $OPIEDIR/lib/libopiecore2.so.* $OPIEDIR/lib/libopienet2.so.* $OPIEDIR/lib/libopieui2.so.* $OPIEDIR/lib/libopiemm2.so.* $OPIEDIR/etc/manufacturers |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/system | 4 | Section: opie/system |
5 | Maintainer: Opie Team <opie@handhelds.org> | 5 | Maintainer: Opie Team <opie@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 1.8.1-$SUB_VERSION.2 | 7 | Version: 1.8.1-$SUB_VERSION.2 |
8 | Depends: libqpe1 | 8 | Depends: libqpe1 |
9 | Provides: libopie2 | 9 | Provides: libopie2 |
10 | Description: Opie library 2.0 | 10 | Description: Opie library 2.0 |
diff --git a/libopie2/libopie2.pro b/libopie2/libopie2.pro index 0b52abc..0bd1d06 100644 --- a/libopie2/libopie2.pro +++ b/libopie2/libopie2.pro | |||
@@ -1,4 +1,4 @@ | |||
1 | TEMPLATE = subdirs | 1 | TEMPLATE = subdirs |
2 | unix:SUBDIRS = opiecore opiedb opiepim opieui opienet examples | 2 | unix:SUBDIRS = opiecore opiedb opiepim opieui opienet opiemm examples |
3 | 3 | ||
4 | include ( $(OPIEDIR)/include.pro ) | 4 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/libopie2/opiemm/.cvsignore b/libopie2/opiemm/.cvsignore new file mode 100644 index 0000000..8f7300c --- a/dev/null +++ b/libopie2/opiemm/.cvsignore | |||
@@ -0,0 +1,6 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | *moc | ||
4 | *.o | ||
5 | ~* | ||
6 | |||
diff --git a/libopie2/opiemm/config.in b/libopie2/opiemm/config.in new file mode 100644 index 0000000..c95d14b --- a/dev/null +++ b/libopie2/opiemm/config.in | |||
@@ -0,0 +1,7 @@ | |||
1 | config LIBOPIE2MM | ||
2 | boolean "libopie2mm (audio and video related classes)" | ||
3 | default "n" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE | ||
5 | comment "libopie2mm needs a libqpe and libopie2core" | ||
6 | depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE) | ||
7 | |||
diff --git a/libopie2/opiemm/opiemm.pro b/libopie2/opiemm/opiemm.pro new file mode 100644 index 0000000..8e5eeb4 --- a/dev/null +++ b/libopie2/opiemm/opiemm.pro | |||
@@ -0,0 +1,16 @@ | |||
1 | TEMPLATE = lib | ||
2 | CONFIG += qt warn_on debug | ||
3 | DESTDIR = $(OPIEDIR)/lib | ||
4 | HEADERS = osoundsystem.h | ||
5 | SOURCES = osoundsystem.cpp | ||
6 | INTERFACES = | ||
7 | TARGET = opiemm2 | ||
8 | VERSION = 1.8.1 | ||
9 | INCLUDEPATH += $(OPIEDIR)/include | ||
10 | DEPENDPATH += $(OPIEDIR)/include | ||
11 | LIBS += | ||
12 | MOC_DIR = moc | ||
13 | OBJECTS_DIR = obj | ||
14 | |||
15 | include ( $(OPIEDIR)/include.pro ) | ||
16 | |||
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp new file mode 100644 index 0000000..fd23bea --- a/dev/null +++ b/libopie2/opiemm/osoundsystem.cpp | |||
@@ -0,0 +1,315 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #include <opie2/osoundsystem.h> | ||
33 | |||
34 | #include <errno.h> | ||
35 | #include <fcntl.h> | ||
36 | #include <string.h> | ||
37 | #include <sys/ioctl.h> | ||
38 | #include <sys/types.h> | ||
39 | #include <sys/soundcard.h> | ||
40 | #include <sys/stat.h> | ||
41 | |||
42 | |||
43 | /*====================================================================================== | ||
44 | * OSoundSystem | ||
45 | *======================================================================================*/ | ||
46 | |||
47 | OSoundSystem* OSoundSystem::_instance = 0; | ||
48 | |||
49 | OSoundSystem::OSoundSystem() | ||
50 | { | ||
51 | qDebug( "OSoundSystem::OSoundSystem()" ); | ||
52 | synchronize(); | ||
53 | } | ||
54 | |||
55 | void OSoundSystem::synchronize() | ||
56 | { | ||
57 | // 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: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | ||
60 | |||
61 | _interfaces.clear(); | ||
62 | _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); | ||
63 | |||
64 | |||
65 | /* | ||
66 | |||
67 | |||
68 | |||
69 | |||
70 | QString str; | ||
71 | QFile f( "/dev/sound" ); | ||
72 | bool hasFile = f.open( IO_ReadOnly ); | ||
73 | if ( !hasFile ) | ||
74 | { | ||
75 | qDebug( "OSoundSystem: /dev/sound not existing. No sound devices available" ); | ||
76 | return; | ||
77 | } | ||
78 | QTextStream s( &f ); | ||
79 | s.readLine(); | ||
80 | s.readLine(); | ||
81 | while ( !s.atEnd() ) | ||
82 | { | ||
83 | s >> str; | ||
84 | str.truncate( str.find( ':' ) ); | ||
85 | qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); | ||
86 | OAudioInterface* iface; | ||
87 | iface = new OAudioInterface( this, (const char*) str ); | ||
88 | |||
89 | _interfaces.insert( str, iface ); | ||
90 | s.readLine(); | ||
91 | } | ||
92 | */ | ||
93 | } | ||
94 | |||
95 | |||
96 | int OSoundSystem::count() const | ||
97 | { | ||
98 | return _interfaces.count(); | ||
99 | } | ||
100 | |||
101 | |||
102 | OSoundCard* OSoundSystem::card( const QString& iface ) const | ||
103 | { | ||
104 | return _interfaces[iface]; | ||
105 | } | ||
106 | |||
107 | |||
108 | OSoundSystem* OSoundSystem::instance() | ||
109 | { | ||
110 | if ( !_instance ) _instance = new OSoundSystem(); | ||
111 | return _instance; | ||
112 | } | ||
113 | |||
114 | |||
115 | OSoundSystem::CardIterator OSoundSystem::iterator() const | ||
116 | { | ||
117 | return OSoundSystem::CardIterator( _interfaces ); | ||
118 | } | ||
119 | |||
120 | |||
121 | /*====================================================================================== | ||
122 | * OSoundCard | ||
123 | *======================================================================================*/ | ||
124 | |||
125 | OSoundCard::OSoundCard( QObject* parent, const char* name ) | ||
126 | :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) | ||
127 | { | ||
128 | qDebug( "OSoundCard::OSoundCard()" ); | ||
129 | init(); | ||
130 | } | ||
131 | |||
132 | |||
133 | OSoundCard::~OSoundCard() | ||
134 | { | ||
135 | } | ||
136 | |||
137 | |||
138 | void OSoundCard::init() | ||
139 | { | ||
140 | _audio = new OAudioInterface( this, "/dev/dsp" ); | ||
141 | _mixer = new OMixerInterface( this, "/dev/mixer" ); | ||
142 | } | ||
143 | |||
144 | |||
145 | /*====================================================================================== | ||
146 | * OAudioInterface | ||
147 | *======================================================================================*/ | ||
148 | |||
149 | OAudioInterface::OAudioInterface( QObject* parent, const char* name ) | ||
150 | :QObject( parent, name ) | ||
151 | { | ||
152 | qDebug( "OAudioInterface::OAudioInterface()" ); | ||
153 | init(); | ||
154 | } | ||
155 | |||
156 | |||
157 | OAudioInterface::~OAudioInterface() | ||
158 | { | ||
159 | } | ||
160 | |||
161 | |||
162 | void OAudioInterface::init() | ||
163 | { | ||
164 | |||
165 | |||
166 | } | ||
167 | |||
168 | |||
169 | /*====================================================================================== | ||
170 | * OMixerInterface | ||
171 | *======================================================================================*/ | ||
172 | |||
173 | OMixerInterface::OMixerInterface( QObject* parent, const char* name ) | ||
174 | :QObject( parent, name ) | ||
175 | { | ||
176 | qDebug( "OMixerInterface::OMixerInterface()" ); | ||
177 | init(); | ||
178 | } | ||
179 | |||
180 | |||
181 | OMixerInterface::~OMixerInterface() | ||
182 | { | ||
183 | } | ||
184 | |||
185 | |||
186 | void OMixerInterface::init() | ||
187 | { | ||
188 | // open the device | ||
189 | _fd = ::open( name(), O_RDWR ); | ||
190 | if ( _fd == -1 ) | ||
191 | { | ||
192 | qWarning( "can't open mixer." ); | ||
193 | return; | ||
194 | } | ||
195 | |||
196 | // construct the device capabilities | ||
197 | int devmask = 0; | ||
198 | if ( ioctl( _fd, SOUND_MIXER_READ_DEVMASK, &devmask ) != -1 ) | ||
199 | { | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
214 | //qDebug( "devmask available and constructed." ); | ||
215 | } | ||
216 | |||
217 | devmask = 0; | ||
218 | if ( ioctl( _fd, SOUND_MIXER_READ_RECMASK, &devmask ) != -1 ) | ||
219 | { | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
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 ); | ||
234 | //qDebug( "recmask available and constructed." ); | ||
235 | } | ||
236 | |||
237 | /* ChannelIterator it; | ||
238 | for ( it = _channels.begin(); it != _channels.end(); ++it ) | ||
239 | { | ||
240 | 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 | } | ||
243 | */ | ||
244 | } | ||
245 | |||
246 | QStringList OMixerInterface::allChannels() const | ||
247 | { | ||
248 | ChannelIterator it = _channels.begin(); | ||
249 | QStringList channels; | ||
250 | while ( it != _channels.end() ) | ||
251 | { | ||
252 | channels += it.key(); | ||
253 | it++; | ||
254 | } | ||
255 | return channels; | ||
256 | } | ||
257 | |||
258 | |||
259 | QStringList OMixerInterface::recChannels() const | ||
260 | { | ||
261 | qWarning( "NYI" ); | ||
262 | } | ||
263 | |||
264 | |||
265 | QStringList OMixerInterface::playChannels() const | ||
266 | { | ||
267 | qWarning( "NYI" ); | ||
268 | } | ||
269 | |||
270 | |||
271 | bool OMixerInterface::hasChannel( const QString& channel ) | ||
272 | { | ||
273 | return _channels.contains( channel ); | ||
274 | } | ||
275 | |||
276 | |||
277 | void OMixerInterface::setVolume( const QString& channel, int left, int right ) | ||
278 | { | ||
279 | int volume = left; | ||
280 | volume |= ( right == -1 ) ? left << 8 : right << 8; | ||
281 | |||
282 | if ( _channels.contains( channel ) ) | ||
283 | { | ||
284 | int result = ioctl( _fd, MIXER_WRITE( _channels[channel] ), &volume ); | ||
285 | if ( result == -1 ) | ||
286 | { | ||
287 | qWarning( "Can't set volume: %s", strerror( errno ) ); | ||
288 | } | ||
289 | else | ||
290 | { | ||
291 | if ( result & 0xff != left ) | ||
292 | { | ||
293 | qWarning( "Device adjusted volume from %d to %d", left, result & 0xff ); | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | |||
299 | |||
300 | int OMixerInterface::volume( const QString& channel ) const | ||
301 | { | ||
302 | int volume; | ||
303 | |||
304 | if ( _channels.contains( channel ) ) | ||
305 | { | ||
306 | if ( ioctl( _fd, MIXER_READ( _channels[channel] ), &volume ) == -1 ) | ||
307 | { | ||
308 | qWarning( "Can't get volume: %s", strerror( errno ) ); | ||
309 | } | ||
310 | else return volume; | ||
311 | } | ||
312 | return -1; | ||
313 | } | ||
314 | |||
315 | |||
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h new file mode 100644 index 0000000..096d397 --- a/dev/null +++ b/libopie2/opiemm/osoundsystem.h | |||
@@ -0,0 +1,216 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | =. | ||
6 | .=l. | ||
7 | .>+-= | ||
8 | _;:, .> :=|. This program is free software; you can | ||
9 | .> <`_, > . <= redistribute it and/or modify it under | ||
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
11 | .="- .-=="i, .._ License as published by the Free Software | ||
12 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
13 | ._= =} : or (at your option) any later version. | ||
14 | .%`+i> _;_. | ||
15 | .i_,=:_. -<s. This program is distributed in the hope that | ||
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
17 | : .. .:, . . . without even the implied warranty of | ||
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
20 | ..}^=.= = ; Library General Public License for more | ||
21 | ++= -. .` .: details. | ||
22 | : = ...= . :.=- | ||
23 | -. .:....=;==+<; You should have received a copy of the GNU | ||
24 | -_. . . )=. = Library General Public License along with | ||
25 | -- :-=` this library; see the file COPYING.LIB. | ||
26 | If not, write to the Free Software Foundation, | ||
27 | Inc., 59 Temple Place - Suite 330, | ||
28 | Boston, MA 02111-1307, USA. | ||
29 | |||
30 | */ | ||
31 | |||
32 | #ifndef OSOUNDSYSTEM_H | ||
33 | #define OSOUNDSYSTEM_H | ||
34 | |||
35 | #include <qobject.h> | ||
36 | #include <qdict.h> | ||
37 | #include <qmap.h> | ||
38 | |||
39 | class OAudioInterface; | ||
40 | class OMixerInterface; | ||
41 | class OSoundCard; | ||
42 | |||
43 | /*====================================================================================== | ||
44 | * OSoundSystem | ||
45 | *======================================================================================*/ | ||
46 | |||
47 | /** | ||
48 | * @brief A container class for all audio interfaces | ||
49 | * | ||
50 | * This class provides access to all available audio/midi/sequencer interfaces of your computer. | ||
51 | * | ||
52 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
53 | */ | ||
54 | class OSoundSystem : public QObject | ||
55 | { | ||
56 | Q_OBJECT | ||
57 | |||
58 | public: | ||
59 | typedef QDict<OSoundCard> CardMap; | ||
60 | typedef QDictIterator<OSoundCard> CardIterator; | ||
61 | |||
62 | public: | ||
63 | /** | ||
64 | * @returns the number of available interfaces | ||
65 | */ | ||
66 | int count() const; | ||
67 | /** | ||
68 | * @returns a pointer to the (one and only) @ref ONetwork instance. | ||
69 | */ | ||
70 | static OSoundSystem* instance(); | ||
71 | /** | ||
72 | * @returns an iterator usable for iterating through all network interfaces. | ||
73 | */ | ||
74 | CardIterator iterator() const; | ||
75 | /** | ||
76 | * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found | ||
77 | * @see OAudioInterface | ||
78 | */ | ||
79 | OSoundCard* card( const QString& interface ) const; | ||
80 | /** | ||
81 | * @internal Rebuild the internal interface database | ||
82 | * @note Sometimes it might be useful to call this from client code, | ||
83 | * e.g. after issuing a cardctl insert | ||
84 | */ | ||
85 | void synchronize(); | ||
86 | |||
87 | protected: | ||
88 | OSoundSystem(); | ||
89 | |||
90 | private: | ||
91 | static OSoundSystem* _instance; | ||
92 | CardMap _interfaces; | ||
93 | }; | ||
94 | |||
95 | |||
96 | /*====================================================================================== | ||
97 | * OSoundCard | ||
98 | *======================================================================================*/ | ||
99 | |||
100 | class OSoundCard : public QObject | ||
101 | { | ||
102 | Q_OBJECT | ||
103 | |||
104 | public: | ||
105 | /** | ||
106 | * Constructor. Normally you don't create @ref OSoundCard objects yourself, | ||
107 | * but access them via @ref OSoundSystem::card(). | ||
108 | */ | ||
109 | OSoundCard( QObject* parent, const char* name ); | ||
110 | /** | ||
111 | * Destructor. | ||
112 | */ | ||
113 | virtual ~OSoundCard(); | ||
114 | |||
115 | bool hasMixer() const { return _audio; }; | ||
116 | bool hasAudio() const { return _mixer; }; | ||
117 | |||
118 | OAudioInterface* audio() const { return _audio; }; | ||
119 | OMixerInterface* mixer() const { return _mixer; }; | ||
120 | |||
121 | protected: | ||
122 | OAudioInterface* _audio; | ||
123 | OMixerInterface* _mixer; | ||
124 | |||
125 | private: | ||
126 | void init(); | ||
127 | }; | ||
128 | |||
129 | /*====================================================================================== | ||
130 | * OAudioInterface | ||
131 | *======================================================================================*/ | ||
132 | |||
133 | class OAudioInterface : public QObject | ||
134 | { | ||
135 | Q_OBJECT | ||
136 | |||
137 | public: | ||
138 | /** | ||
139 | * Constructor. Normally you don't create @ref OAudioInterface objects yourself, | ||
140 | * but access them via the @ref OSoundCard interface. | ||
141 | */ | ||
142 | OAudioInterface( QObject* parent, const char* name ); | ||
143 | /** | ||
144 | * Destructor. | ||
145 | */ | ||
146 | virtual ~OAudioInterface(); | ||
147 | |||
148 | protected: | ||
149 | const int _sfd; | ||
150 | |||
151 | private: | ||
152 | void init(); | ||
153 | }; | ||
154 | |||
155 | |||
156 | /*====================================================================================== | ||
157 | * OMixerInterface | ||
158 | *======================================================================================*/ | ||
159 | |||
160 | class OMixerInterface : public QObject | ||
161 | { | ||
162 | Q_OBJECT | ||
163 | |||
164 | public: | ||
165 | |||
166 | typedef QMap<QString,int>::ConstIterator ChannelIterator; | ||
167 | |||
168 | /** | ||
169 | * Constructor. Normally you don't create @ref OMixerInterface objects yourself, | ||
170 | * but access them via the @ref OSoundCard interface. | ||
171 | */ | ||
172 | OMixerInterface( QObject* parent, const char* name ); | ||
173 | /** | ||
174 | * Destructor. | ||
175 | */ | ||
176 | virtual ~OMixerInterface(); | ||
177 | |||
178 | /** | ||
179 | * @returns all available channels. | ||
180 | */ | ||
181 | QStringList allChannels() const; | ||
182 | /** | ||
183 | * @returns recordable channels. | ||
184 | */ | ||
185 | QStringList recChannels() const; | ||
186 | /** | ||
187 | * @returns playable channels. | ||
188 | */ | ||
189 | QStringList playChannels() const; | ||
190 | |||
191 | /** | ||
192 | * @returns true, if @a channel exists. | ||
193 | */ | ||
194 | bool hasChannel( const QString& channel ); | ||
195 | |||
196 | /** | ||
197 | * Set the @a left and @a right volumes for @a channel. | ||
198 | * If no value for right is given, the value for left is taken for that. | ||
199 | */ | ||
200 | void setVolume( const QString& channel, int left, int right = -1 ); | ||
201 | /** | ||
202 | * @returns the volume of @a channel or -1, if the channel doesn't exist. | ||
203 | * @note You might want to use @ref hasChannel() to check if a channel exists. | ||
204 | */ | ||
205 | int volume( const QString& channel ) const; | ||
206 | |||
207 | protected: | ||
208 | int _fd; | ||
209 | QMap<QString, int> _channels; | ||
210 | |||
211 | private: | ||
212 | void init(); | ||
213 | }; | ||
214 | |||
215 | #endif // OSOUNDSYSTEM_H | ||
216 | |||