diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kolf/kvolumecontrol.cpp | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kolf/kvolumecontrol.cpp')
-rw-r--r-- | kolf/kvolumecontrol.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/kolf/kvolumecontrol.cpp b/kolf/kvolumecontrol.cpp new file mode 100644 index 00000000..11d0be15 --- /dev/null +++ b/kolf/kvolumecontrol.cpp @@ -0,0 +1,67 @@ +#include <kdebug.h> + +#include <arts/soundserver.h> +#include <arts/flowsystem.h> + +#include "kvolumecontrol.h" + +KVolumeControl::KVolumeControl(Arts::SoundServerV2 server, KPlayObject *parent) + : QObject(parent) +{ + init(server); +} + +KVolumeControl::KVolumeControl(double vol, Arts::SoundServerV2 server, KPlayObject *parent) + : QObject(parent) +{ + init(server); + setVolume(vol); +} + +KVolumeControl::~KVolumeControl() +{ + manager.stop(); + volumeControl.stop(); +} + +void KVolumeControl::init(Arts::SoundServerV2 server) +{ + manager = Arts::DynamicCast(server.createObject("Arts::Synth_AMAN_PLAY")); + if (manager.isNull()) + { + kdError() << "Your OS is broken. Get an OS that installs KDE decently." << endl; + return; + } + manager.start(); + + volumeControl = Arts::DynamicCast(server.createObject("Arts::StereoVolumeControl")); + if (volumeControl.isNull()) + { + kdError() << "Your OS is broken. Get an OS that installs KDE decently." << endl; + return; + } + volumeControl.start(); + + Arts::connect((static_cast<KPlayObject *>(parent()))->object(), "left", volumeControl, "inleft"); + Arts::connect((static_cast<KPlayObject *>(parent()))->object(), "right", volumeControl, "inright"); + + Arts::connect(volumeControl, manager); +} + +void KVolumeControl::setVolume(double d) +{ + if (volumeControl.isNull()) + return; + + volumeControl.scaleFactor(d); +} + +double KVolumeControl::volume(void) +{ + if (volumeControl.isNull()) + return -1; + + return volumeControl.scaleFactor(); +} + +#include "kvolumecontrol.moc" |