Diffstat (limited to 'core/multimedia/opieplayer/audiodevice.h') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.h b/core/multimedia/opieplayer/audiodevice.h new file mode 100644 index 0000000..928f134 --- a/dev/null +++ b/core/multimedia/opieplayer/audiodevice.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #ifndef AUDIODEVICE_H | ||
21 | #define AUDIODEVICE_H | ||
22 | |||
23 | |||
24 | #include <qobject.h> | ||
25 | |||
26 | |||
27 | class AudioDevicePrivate; | ||
28 | |||
29 | |||
30 | class AudioDevice : public QObject { | ||
31 | Q_OBJECT | ||
32 | public: | ||
33 | AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = 2 ); | ||
34 | ~AudioDevice(); | ||
35 | |||
36 | unsigned int canWrite() const; | ||
37 | void write( char *buffer, unsigned int length ); | ||
38 | int bytesWritten(); | ||
39 | |||
40 | unsigned int channels() const; | ||
41 | unsigned int frequency() const; | ||
42 | unsigned int bytesPerSample() const; | ||
43 | unsigned int bufferSize() const; | ||
44 | |||
45 | // Each volume level is from 0 to 0xFFFF | ||
46 | static void getVolume( unsigned int& left, unsigned int& right, bool& muted ); | ||
47 | static void setVolume( unsigned int left, unsigned int right, bool muted ); | ||
48 | |||
49 | static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; } | ||
50 | static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; } | ||
51 | static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; } | ||
52 | |||
53 | static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); } | ||
54 | static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); } | ||
55 | |||
56 | public slots: | ||
57 | // Convinence functions derived from above functions | ||
58 | void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); } | ||
59 | void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); } | ||
60 | void volumeChanged( bool muted ); | ||
61 | |||
62 | signals: | ||
63 | void completedIO(); | ||
64 | |||
65 | private: | ||
66 | AudioDevicePrivate *d; | ||
67 | }; | ||
68 | |||
69 | |||
70 | #endif // AUDIODEVICE_H | ||
71 | |||