summaryrefslogtreecommitdiff
path: root/libopie2/opiemm
authormickeyl <mickeyl>2005-05-19 11:59:32 (UTC)
committer mickeyl <mickeyl>2005-05-19 11:59:32 (UTC)
commited7ba8b228d3d0ffae9c9b68900b7f723d7ade4a (patch) (unidiff)
tree83b59755f58747cdb7e543a4c237e9e217b03fbd /libopie2/opiemm
parentcb243f00d12c5fc40de02e7f9f20009b52303a66 (diff)
downloadopie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.zip
opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.gz
opie-ed7ba8b228d3d0ffae9c9b68900b7f723d7ade4a.tar.bz2
- add linux pcmcia subsystem wrapper: OPcmciaSystem and OPcmciaCard
- move linux-only subsystems in subdirectory linux - minor header cleanups
Diffstat (limited to 'libopie2/opiemm') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiemm/osoundsystem.cpp12
-rw-r--r--libopie2/opiemm/osoundsystem.h13
2 files changed, 13 insertions, 12 deletions
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index 2956682..6f849cd 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -1,142 +1,144 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#include <opie2/osoundsystem.h> 30#include "osoundsystem.h"
31using namespace Opie::MM;
32
33/* OPIE */
32#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35using namespace Opie::Core;
33 36
37/* STD */
34#include <errno.h> 38#include <errno.h>
35#include <fcntl.h> 39#include <fcntl.h>
36#include <string.h> 40#include <string.h>
37#include <sys/ioctl.h> 41#include <sys/ioctl.h>
38#include <sys/types.h> 42#include <sys/types.h>
39#include <sys/soundcard.h> 43#include <sys/soundcard.h>
40#include <sys/stat.h> 44#include <sys/stat.h>
41 45
42static const char* device_label[] = SOUND_DEVICE_LABELS; 46static const char* device_label[] = SOUND_DEVICE_LABELS;
43static int max_device_nr = sizeof device_label / sizeof (const char*); 47static int max_device_nr = sizeof device_label / sizeof (const char*);
44 48
45using namespace Opie::Core;
46using namespace Opie::MM;
47/*====================================================================================== 49/*======================================================================================
48 * OSoundSystem 50 * OSoundSystem
49 *======================================================================================*/ 51 *======================================================================================*/
50 52
51OSoundSystem* OSoundSystem::_instance = 0; 53OSoundSystem* OSoundSystem::_instance = 0;
52 54
53OSoundSystem::OSoundSystem() 55OSoundSystem::OSoundSystem()
54{ 56{
55 odebug << "OSoundSystem::OSoundSystem()" << oendl; 57 odebug << "OSoundSystem::OSoundSystem()" << oendl;
56 synchronize(); 58 synchronize();
57} 59}
58 60
59void OSoundSystem::synchronize() 61void OSoundSystem::synchronize()
60{ 62{
61 _interfaces.clear(); 63 _interfaces.clear();
62 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) ); 64 _interfaces.insert( "soundcard", new OSoundCard( this, "soundcard" ) );
63 65
64 /* 66 /*
65 67
66 QString str; 68 QString str;
67 QFile f( "/dev/sound" ); 69 QFile f( "/dev/sound" );
68 bool hasFile = f.open( IO_ReadOnly ); 70 bool hasFile = f.open( IO_ReadOnly );
69 if ( !hasFile ) 71 if ( !hasFile )
70 { 72 {
71 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 73 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
72 return; 74 return;
73 } 75 }
74 QTextStream s( &f ); 76 QTextStream s( &f );
75 s.readLine(); 77 s.readLine();
76 s.readLine(); 78 s.readLine();
77 while ( !s.atEnd() ) 79 while ( !s.atEnd() )
78 { 80 {
79 s >> str; 81 s >> str;
80 str.truncate( str.find( ':' ) ); 82 str.truncate( str.find( ':' ) );
81 odebug << "OSoundSystem: found interface '" << str << "'" << oendl; 83 odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
82 OAudioInterface* iface; 84 OAudioInterface* iface;
83 iface = new OAudioInterface( this, (const char*) str ); 85 iface = new OAudioInterface( this, (const char*) str );
84 86
85 _interfaces.insert( str, iface ); 87 _interfaces.insert( str, iface );
86 s.readLine(); 88 s.readLine();
87 } 89 }
88*/ 90*/
89} 91}
90 92
91 93
92int OSoundSystem::count() const 94int OSoundSystem::count() const
93{ 95{
94 return _interfaces.count(); 96 return _interfaces.count();
95} 97}
96 98
97 99
98OSoundCard* OSoundSystem::card( const QString& iface ) const 100OSoundCard* OSoundSystem::card( const QString& iface ) const
99{ 101{
100 return _interfaces[iface]; 102 return _interfaces[iface];
101} 103}
102 104
103 105
104OSoundSystem* OSoundSystem::instance() 106OSoundSystem* OSoundSystem::instance()
105{ 107{
106 if ( !_instance ) _instance = new OSoundSystem(); 108 if ( !_instance ) _instance = new OSoundSystem();
107 return _instance; 109 return _instance;
108} 110}
109 111
110 112
111OSoundSystem::CardIterator OSoundSystem::iterator() const 113OSoundSystem::CardIterator OSoundSystem::iterator() const
112{ 114{
113 return OSoundSystem::CardIterator( _interfaces ); 115 return OSoundSystem::CardIterator( _interfaces );
114} 116}
115 117
116 118
117/*====================================================================================== 119/*======================================================================================
118 * OSoundCard 120 * OSoundCard
119 *======================================================================================*/ 121 *======================================================================================*/
120 122
121OSoundCard::OSoundCard( QObject* parent, const char* name ) 123OSoundCard::OSoundCard( QObject* parent, const char* name )
122 :QObject( parent, name ), _audio( 0 ), _mixer( 0 ) 124 :QObject( parent, name ), _audio( 0 ), _mixer( 0 )
123{ 125{
124 odebug << "OSoundCard::OSoundCard()" << oendl; 126 odebug << "OSoundCard::OSoundCard()" << oendl;
125 init(); 127 init();
126} 128}
127 129
128 130
129OSoundCard::~OSoundCard() 131OSoundCard::~OSoundCard()
130{ 132{
131} 133}
132 134
133 135
134void OSoundCard::init() 136void OSoundCard::init()
135{ 137{
136#ifdef QT_QWS_DEVFS 138#ifdef QT_QWS_DEVFS
137 _audio = new OAudioInterface( this, "/dev/sound/dsp" ); 139 _audio = new OAudioInterface( this, "/dev/sound/dsp" );
138 _mixer = new OMixerInterface( this, "/dev/sound/mixer" ); 140 _mixer = new OMixerInterface( this, "/dev/sound/mixer" );
139#else 141#else
140 _audio = new OAudioInterface( this, "/dev/dsp" ); 142 _audio = new OAudioInterface( this, "/dev/dsp" );
141 _mixer = new OMixerInterface( this, "/dev/mixer" ); 143 _mixer = new OMixerInterface( this, "/dev/mixer" );
142#endif 144#endif
diff --git a/libopie2/opiemm/osoundsystem.h b/libopie2/opiemm/osoundsystem.h
index 5f6fb7a..1e48f5c 100644
--- a/libopie2/opiemm/osoundsystem.h
+++ b/libopie2/opiemm/osoundsystem.h
@@ -1,150 +1,149 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =.
5 .=l. 4 .=l.
6           .>+-= 5           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; version 2 of the License.
12     ._= =}       : or (at your option) any later version. 11     ._= =}       :
13    .%`+i>       _;_. 12    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 19++=   -.     .`     .: details.
21 :     =  ...= . :.=- 20 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
28 27
29*/ 28*/
30 29
31#ifndef OSOUNDSYSTEM_H 30#ifndef OSOUNDSYSTEM_H
32#define OSOUNDSYSTEM_H 31#define OSOUNDSYSTEM_H
33 32
34#include <qobject.h> 33#include <qobject.h>
35#include <qdict.h> 34#include <qdict.h>
36#include <qmap.h> 35#include <qmap.h>
37 36
38namespace Opie { 37namespace Opie {
39namespace MM { 38namespace MM {
40 39
41class OAudioInterface; 40class OAudioInterface;
42class OMixerInterface; 41class OMixerInterface;
43class OSoundCard; 42class OSoundCard;
44 43
45/*====================================================================================== 44/*======================================================================================
46 * OSoundSystem 45 * OSoundSystem
47 *======================================================================================*/ 46 *======================================================================================*/
48 47
49/** 48/**
50 * @brief A container class for all audio interfaces 49 * @brief A container class for the Linux OSS/ALSA audio subsystem
51 * 50 *
52 * This class provides access to all available audio/midi/sequencer interfaces of your computer. 51 * This class provides access to all available audio/midi/sequencer interfaces of your device.
53 * 52 *
54 * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 53 * @author Michael 'Mickey' Lauer <mickey@Vanille.de>
55 */ 54 */
56class OSoundSystem : public QObject 55class OSoundSystem : public QObject
57{ 56{
58 Q_OBJECT 57 Q_OBJECT
59 58
60 public: 59 public:
61 typedef QDict<OSoundCard> CardMap; 60 typedef QDict<OSoundCard> CardMap;
62 typedef QDictIterator<OSoundCard> CardIterator; 61 typedef QDictIterator<OSoundCard> CardIterator;
63 62
64 public: 63 public:
65 /** 64 /**
66 * @returns the number of available interfaces 65 * @returns the number of available interfaces
67 */ 66 */
68 int count() const; 67 int count() const;
69 /** 68 /**
70 * @returns a pointer to the (one and only) @ref OSystem instance. 69 * @returns a pointer to the (one and only) @ref OSystem instance.
71 */ 70 */
72 static OSoundSystem* instance(); 71 static OSoundSystem* instance();
73 /** 72 /**
74 * @returns an iterator usable for iterating through all sound cards. 73 * @returns an iterator usable for iterating through all sound cards.
75 */ 74 */
76 CardIterator iterator() const; 75 CardIterator iterator() const;
77 /** 76 /**
78 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found 77 * @returns a pointer to the @ref OAudioInterface object for the specified @a interface or 0, if not found
79 * @see OAudioInterface 78 * @see OAudioInterface
80 */ 79 */
81 OSoundCard* card( const QString& interface ) const; 80 OSoundCard* card( const QString& interface ) const;
82 /** 81 /**
83 * @internal Rebuild the internal interface database 82 * @internal Rebuild the internal interface database
84 * @note Sometimes it might be useful to call this from client code, 83 * @note Sometimes it might be useful to call this from client code,
85 * e.g. after issuing a cardctl insert 84 * e.g. after issuing a cardctl insert
86 */ 85 */
87 void synchronize(); 86 void synchronize();
88 87
89 protected: 88 protected:
90 OSoundSystem(); 89 OSoundSystem();
91 90
92 private: 91 private:
93 static OSoundSystem* _instance; 92 static OSoundSystem* _instance;
94 CardMap _interfaces; 93 CardMap _interfaces;
95 class Private; 94 class Private;
96 Private *d; 95 Private *d;
97}; 96};
98 97
99 98
100/*====================================================================================== 99/*======================================================================================
101 * OSoundCard 100 * OSoundCard
102 *======================================================================================*/ 101 *======================================================================================*/
103 102
104class OSoundCard : public QObject 103class OSoundCard : public QObject
105{ 104{
106 Q_OBJECT 105 Q_OBJECT
107 106
108 public: 107 public:
109 /** 108 /**
110 * Constructor. Normally you don't create @ref OSoundCard objects yourself, 109 * Constructor. Normally you don't create @ref OSoundCard objects yourself,
111 * but access them via @ref OSoundSystem::card(). 110 * but access them via @ref OSoundSystem::card().
112 */ 111 */
113 OSoundCard( QObject* parent, const char* name ); 112 OSoundCard( QObject* parent, const char* name );
114 /** 113 /**
115 * Destructor. 114 * Destructor.
116 */ 115 */
117 virtual ~OSoundCard(); 116 virtual ~OSoundCard();
118 117
119 bool hasMixer() const { return _audio; }; 118 bool hasMixer() const { return _audio; };
120 bool hasAudio() const { return _mixer; }; 119 bool hasAudio() const { return _mixer; };
121 120
122 OAudioInterface* audio() const { return _audio; }; 121 OAudioInterface* audio() const { return _audio; };
123 OMixerInterface* mixer() const { return _mixer; }; 122 OMixerInterface* mixer() const { return _mixer; };
124 123
125 protected: 124 protected:
126 OAudioInterface* _audio; 125 OAudioInterface* _audio;
127 OMixerInterface* _mixer; 126 OMixerInterface* _mixer;
128 127
129 private: 128 private:
130 void init(); 129 void init();
131 private: 130 private:
132 class Private; 131 class Private;
133 Private *d; 132 Private *d;
134}; 133};
135 134
136/*====================================================================================== 135/*======================================================================================
137 * OAudioInterface 136 * OAudioInterface
138 *======================================================================================*/ 137 *======================================================================================*/
139 138
140class OAudioInterface : public QObject 139class OAudioInterface : public QObject
141{ 140{
142 Q_OBJECT 141 Q_OBJECT
143 142
144 public: 143 public:
145 /** 144 /**
146 * Constructor. Normally you don't create @ref OAudioInterface objects yourself, 145 * Constructor. Normally you don't create @ref OAudioInterface objects yourself,
147 * but access them via the @ref OSoundCard interface. 146 * but access them via the @ref OSoundCard interface.
148 */ 147 */
149 OAudioInterface( QObject* parent, const char* name ); 148 OAudioInterface( QObject* parent, const char* name );
150 /** 149 /**