diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-08-07 10:22:50 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-08-07 10:22:50 +0400 |
commit | 4370099fb0bc1bdd21f78b14a91a1d8eb76e1bc1 (patch) | |
tree | af85b9c45ba59ee52242b8d6b8ed16fe2a0ccd1c /intern | |
parent | 5cc0bb0d1b3dbdc8494fe2ff444c683b82b7d15f (diff) |
3D Audio GSoC:
Added a NULLHandle to prevent a crash in Python API when the device is the NULLDevice.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/audaspace/intern/AUD_NULLDevice.cpp | 86 | ||||
-rw-r--r-- | intern/audaspace/intern/AUD_NULLDevice.h | 25 |
2 files changed, 106 insertions, 5 deletions
diff --git a/intern/audaspace/intern/AUD_NULLDevice.cpp b/intern/audaspace/intern/AUD_NULLDevice.cpp index 78a02d32cdd..dddb53fd00c 100644 --- a/intern/audaspace/intern/AUD_NULLDevice.cpp +++ b/intern/audaspace/intern/AUD_NULLDevice.cpp @@ -32,9 +32,85 @@ #include <limits> #include "AUD_NULLDevice.h" -#include "AUD_IReader.h" -#include "AUD_IFactory.h" -#include "AUD_IHandle.h" + +AUD_NULLDevice::AUD_NULLHandle::AUD_NULLHandle() +{ +} + +bool AUD_NULLDevice::AUD_NULLHandle::pause() +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::resume() +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::stop() +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::getKeep() +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::setKeep(bool keep) +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::seek(float position) +{ + return false; +} + +float AUD_NULLDevice::AUD_NULLHandle::getPosition() +{ + return 0.0f; +} + +AUD_Status AUD_NULLDevice::AUD_NULLHandle::getStatus() +{ + return AUD_STATUS_INVALID; +} + +float AUD_NULLDevice::AUD_NULLHandle::getVolume() +{ + return 0.0f; +} + +bool AUD_NULLDevice::AUD_NULLHandle::setVolume(float volume) +{ + return false; +} + +float AUD_NULLDevice::AUD_NULLHandle::getPitch() +{ + return 0.0f; +} + +bool AUD_NULLDevice::AUD_NULLHandle::setPitch(float pitch) +{ + return false; +} + +int AUD_NULLDevice::AUD_NULLHandle::getLoopCount() +{ + return 0; +} + +bool AUD_NULLDevice::AUD_NULLHandle::setLoopCount(int count) +{ + return false; +} + +bool AUD_NULLDevice::AUD_NULLHandle::setStopCallback(stopCallback callback, void* data) +{ + return false; +} AUD_NULLDevice::AUD_NULLDevice() { @@ -55,12 +131,12 @@ AUD_DeviceSpecs AUD_NULLDevice::getSpecs() const AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IReader> reader, bool keep) { - return AUD_Reference<AUD_IHandle>(); + return new AUD_NULLHandle(); } AUD_Reference<AUD_IHandle> AUD_NULLDevice::play(AUD_Reference<AUD_IFactory> factory, bool keep) { - return AUD_Reference<AUD_IHandle>(); + return new AUD_NULLHandle(); } void AUD_NULLDevice::lock() diff --git a/intern/audaspace/intern/AUD_NULLDevice.h b/intern/audaspace/intern/AUD_NULLDevice.h index 04458575f1c..59ef200f934 100644 --- a/intern/audaspace/intern/AUD_NULLDevice.h +++ b/intern/audaspace/intern/AUD_NULLDevice.h @@ -34,12 +34,37 @@ #include "AUD_IReader.h" #include "AUD_IDevice.h" +#include "AUD_IHandle.h" /** * This device plays nothing. */ class AUD_NULLDevice : public AUD_IDevice { +private: + class AUD_NULLHandle : public AUD_IHandle + { + public: + + AUD_NULLHandle(); + + virtual ~AUD_NULLHandle() {} + virtual bool pause(); + virtual bool resume(); + virtual bool stop(); + virtual bool getKeep(); + virtual bool setKeep(bool keep); + virtual bool seek(float position); + virtual float getPosition(); + virtual AUD_Status getStatus(); + virtual float getVolume(); + virtual bool setVolume(float volume); + virtual float getPitch(); + virtual bool setPitch(float pitch); + virtual int getLoopCount(); + virtual bool setLoopCount(int count); + virtual bool setStopCallback(stopCallback callback = 0, void* data = 0); + }; public: /** * Creates a new NULL device. |