00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AUDIODEVICE_H
00023 #define AUDIODEVICE_H
00024
00025
00026 #include <qobject.h>
00027 #include <sys/soundcard.h>
00028
00029
00030 class AudioDevicePrivate;
00031
00032
00033 class AudioDevice : public QObject {
00034 Q_OBJECT
00035 public:
00036 AudioDevice( unsigned int freq = 44000, unsigned int channels = 2, unsigned int bytesPerSample = AFMT_S16_LE );
00037 ~AudioDevice();
00038
00039 unsigned int canWrite() const;
00040 void write( char *buffer, unsigned int length );
00041 int bytesWritten();
00042
00043 unsigned int channels() const;
00044 unsigned int frequency() const;
00045 unsigned int bytesPerSample() const;
00046 unsigned int bufferSize() const;
00047
00048
00049 static void getVolume( unsigned int& left, unsigned int& right, bool& muted );
00050 static void setVolume( unsigned int left, unsigned int right, bool muted );
00051
00052 static unsigned int leftVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return l; }
00053 static unsigned int rightVolume() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return r; }
00054 static bool isMuted() { bool muted; unsigned int l, r; getVolume( l, r, muted ); return muted; }
00055
00056 static void increaseVolume() { setVolume( leftVolume() + 1968, rightVolume() + 1968, isMuted() ); }
00057 static void decreaseVolume() { setVolume( leftVolume() - 1966, rightVolume() - 1966, isMuted() ); }
00058
00059 public slots:
00060
00061 void setVolume( unsigned int level ) { setVolume( level, level, isMuted() ); }
00062 void mute() { setVolume( leftVolume(), rightVolume(), TRUE ); }
00063 void volumeChanged( bool muted );
00064
00065 signals:
00066 void completedIO();
00067
00068 private:
00069 AudioDevicePrivate *d;
00070 };
00071
00072
00073 #endif // AUDIODEVICE_H
00074