From 4370099fb0bc1bdd21f78b14a91a1d8eb76e1bc1 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 7 Aug 2011 06:22:50 +0000 Subject: 3D Audio GSoC: Added a NULLHandle to prevent a crash in Python API when the device is the NULLDevice. --- intern/audaspace/intern/AUD_NULLDevice.cpp | 86 ++++++++++++++++++++++++++++-- intern/audaspace/intern/AUD_NULLDevice.h | 25 +++++++++ 2 files changed, 106 insertions(+), 5 deletions(-) (limited to 'intern/audaspace') 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 #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_NULLDevice::play(AUD_Reference reader, bool keep) { - return AUD_Reference(); + return new AUD_NULLHandle(); } AUD_Reference AUD_NULLDevice::play(AUD_Reference factory, bool keep) { - return AUD_Reference(); + 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. -- cgit v1.2.3