diff options
author | Joerg Mueller <nexyon@gmail.com> | 2011-06-04 03:28:57 +0400 |
---|---|---|
committer | Joerg Mueller <nexyon@gmail.com> | 2011-06-04 03:28:57 +0400 |
commit | d1c542ce0551f6ec3408b7c6689ad17b0a14e8d2 (patch) | |
tree | 4d4ca1da42cee6db71b3515f7330aa0fffdb6d70 /intern/audaspace/Python | |
parent | cd04cff1800e8f60a06d8da6e79ac436808c9a7d (diff) |
3D Audio GSoC:
Memory management improvements.
Diffstat (limited to 'intern/audaspace/Python')
-rw-r--r-- | intern/audaspace/Python/AUD_PyAPI.cpp | 166 | ||||
-rw-r--r-- | intern/audaspace/Python/AUD_PyAPI.h | 9 |
2 files changed, 89 insertions, 86 deletions
diff --git a/intern/audaspace/Python/AUD_PyAPI.cpp b/intern/audaspace/Python/AUD_PyAPI.cpp index 22376a2fcd1..53dfedee5eb 100644 --- a/intern/audaspace/Python/AUD_PyAPI.cpp +++ b/intern/audaspace/Python/AUD_PyAPI.cpp @@ -91,7 +91,7 @@ static void Factory_dealloc(Factory* self) { if(self->factory) - delete self->factory; + delete reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory); Py_XDECREF(self->child_list); Py_TYPE(self)->tp_free((PyObject*)self); } @@ -115,7 +115,7 @@ Factory_new(PyTypeObject *type, PyObject *args, PyObject *kwds) try { - self->factory = new AUD_FileFactory(filename); + self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename)); } catch(AUD_Exception& e) { @@ -155,7 +155,7 @@ Factory_sine(PyTypeObject* type, PyObject* args) { try { - self->factory = new AUD_SinusFactory(frequency, (AUD_SampleRate)rate); + self->factory = new AUD_Reference<AUD_IFactory>(new AUD_SinusFactory(frequency, (AUD_SampleRate)rate)); } catch(AUD_Exception& e) { @@ -194,7 +194,7 @@ Factory_file(PyTypeObject* type, PyObject* args) { try { - self->factory = new AUD_FileFactory(filename); + self->factory = new AUD_Reference<AUD_IFactory>(new AUD_FileFactory(filename)); } catch(AUD_Exception& e) { @@ -237,7 +237,7 @@ Factory_lowpass(Factory* self, PyObject* args) try { - parent->factory = new AUD_LowpassFactory(self->factory, frequency, Q); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LowpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q)); } catch(AUD_Exception& e) { @@ -278,7 +278,7 @@ Factory_delay(Factory* self, PyObject* args) try { - parent->factory = new AUD_DelayFactory(self->factory, delay); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DelayFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), delay)); } catch(AUD_Exception& e) { @@ -322,7 +322,7 @@ Factory_join(Factory* self, PyObject* object) try { - parent->factory = new AUD_DoubleFactory(self->factory, child->factory); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_DoubleFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory))); } catch(AUD_Exception& e) { @@ -365,7 +365,7 @@ Factory_highpass(Factory* self, PyObject* args) try { - parent->factory = new AUD_HighpassFactory(self->factory, frequency, Q); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_HighpassFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), frequency, Q)); } catch(AUD_Exception& e) { @@ -406,7 +406,7 @@ Factory_limit(Factory* self, PyObject* args) try { - parent->factory = new AUD_LimiterFactory(self->factory, start, end); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LimiterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), start, end)); } catch(AUD_Exception& e) { @@ -450,7 +450,7 @@ Factory_pitch(Factory* self, PyObject* args) try { - parent->factory = new AUD_PitchFactory(self->factory, factor); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PitchFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), factor)); } catch(AUD_Exception& e) { @@ -492,7 +492,7 @@ Factory_volume(Factory* self, PyObject* args) try { - parent->factory = new AUD_VolumeFactory(self->factory, volume); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_VolumeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), volume)); } catch(AUD_Exception& e) { @@ -535,7 +535,7 @@ Factory_fadein(Factory* self, PyObject* args) try { - parent->factory = new AUD_FaderFactory(self->factory, AUD_FADE_IN, start, length); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_IN, start, length)); } catch(AUD_Exception& e) { @@ -579,7 +579,7 @@ Factory_fadeout(Factory* self, PyObject* args) try { - parent->factory = new AUD_FaderFactory(self->factory, AUD_FADE_OUT, start, length); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_FaderFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), AUD_FADE_OUT, start, length)); } catch(AUD_Exception& e) { @@ -621,7 +621,7 @@ Factory_loop(Factory* self, PyObject* args) try { - parent->factory = new AUD_LoopFactory(self->factory, loop); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_LoopFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), loop)); } catch(AUD_Exception& e) { @@ -664,7 +664,7 @@ Factory_mix(Factory* self, PyObject* object) try { - parent->factory = new AUD_SuperposeFactory(self->factory, child->factory); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SuperposeFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), *reinterpret_cast<AUD_Reference<AUD_IFactory>*>(child->factory))); } catch(AUD_Exception& e) { @@ -697,7 +697,7 @@ Factory_pingpong(Factory* self) try { - parent->factory = new AUD_PingPongFactory(self->factory); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_PingPongFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory))); } catch(AUD_Exception& e) { @@ -736,7 +736,7 @@ Factory_reverse(Factory* self) try { - parent->factory = new AUD_ReverseFactory(self->factory); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_ReverseFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory))); } catch(AUD_Exception& e) { @@ -771,7 +771,7 @@ Factory_buffer(Factory* self) { try { - parent->factory = new AUD_StreamBufferFactory(self->factory); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_StreamBufferFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory))); } catch(AUD_Exception& e) { @@ -813,7 +813,7 @@ Factory_square(Factory* self, PyObject* args) try { - parent->factory = new AUD_SquareFactory(self->factory, threshold); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_SquareFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), threshold)); } catch(AUD_Exception& e) { @@ -910,7 +910,7 @@ Factory_filter(Factory* self, PyObject* args) try { - parent->factory = new AUD_IIRFilterFactory(self->factory, b, a); + parent->factory = new AUD_Reference<AUD_IFactory>(new AUD_IIRFilterFactory(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(self->factory), b, a)); } catch(AUD_Exception& e) { @@ -1050,7 +1050,7 @@ Handle_pause(Handle *self) try { - return PyBool_FromLong((long)device->device->pause(self->handle)); + return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->pause(self->handle)); } catch(AUD_Exception& e) { @@ -1072,7 +1072,7 @@ Handle_resume(Handle *self) try { - return PyBool_FromLong((long)device->device->resume(self->handle)); + return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->resume(self->handle)); } catch(AUD_Exception& e) { @@ -1095,7 +1095,7 @@ Handle_stop(Handle *self) try { - return PyBool_FromLong((long)device->device->stop(self->handle)); + return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->stop(self->handle)); } catch(AUD_Exception& e) { @@ -1127,7 +1127,7 @@ Handle_get_position(Handle *self, void* nothing) try { - return Py_BuildValue("f", device->device->getPosition(self->handle)); + return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getPosition(self->handle)); } catch(AUD_Exception& e) { @@ -1148,7 +1148,7 @@ Handle_set_position(Handle *self, PyObject* args, void* nothing) try { - if(device->device->seek(self->handle, position)) + if((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->seek(self->handle, position)) return 0; PyErr_SetString(AUDError, "Couldn't seek the sound!"); } @@ -1176,7 +1176,7 @@ Handle_get_keep(Handle *self, void* nothing) try { - return PyBool_FromLong((long)device->device->getKeep(self->handle)); + return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getKeep(self->handle)); } catch(AUD_Exception& e) { @@ -1199,7 +1199,7 @@ Handle_set_keep(Handle *self, PyObject* args, void* nothing) try { - if(device->device->setKeep(self->handle, keep)) + if((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->setKeep(self->handle, keep)) return 0; PyErr_SetString(AUDError, "Couldn't set keep of the sound!"); } @@ -1221,7 +1221,7 @@ Handle_get_status(Handle *self, void* nothing) try { - return PyBool_FromLong((long)device->device->getStatus(self->handle)); + return PyBool_FromLong((long)(*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getStatus(self->handle)); } catch(AUD_Exception& e) { @@ -1240,7 +1240,7 @@ Handle_get_volume(Handle *self, void* nothing) try { - return Py_BuildValue("f", device->device->getVolume(self->handle)); + return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getVolume(self->handle)); } catch(AUD_Exception& e) { @@ -1261,7 +1261,7 @@ Handle_set_volume(Handle *self, PyObject* args, void* nothing) try { - if(device->device->setVolume(self->handle, volume)) + if((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->setVolume(self->handle, volume)) return 0; PyErr_SetString(AUDError, "Couldn't set the sound volume!"); } @@ -1283,7 +1283,7 @@ Handle_get_pitch(Handle *self, void* nothing) try { - return Py_BuildValue("f", device->device->getPitch(self->handle)); + return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getPitch(self->handle)); } catch(AUD_Exception& e) { @@ -1304,7 +1304,7 @@ Handle_set_pitch(Handle *self, PyObject* args, void* nothing) try { - if(device->device->setPitch(self->handle, pitch)) + if((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->setPitch(self->handle, pitch)) return 0; PyErr_SetString(AUDError, "Couldn't set the sound pitch!"); } @@ -1326,7 +1326,7 @@ Handle_get_loop_count(Handle *self, void* nothing) try { - return Py_BuildValue("i", device->device->getLoopCount(self->handle)); + return Py_BuildValue("i", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->getLoopCount(self->handle)); } catch(AUD_Exception& e) { @@ -1347,7 +1347,7 @@ Handle_set_loop_count(Handle *self, PyObject* args, void* nothing) try { - if(device->device->setLoopCount(self->handle, loops)) + if((*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(device->device))->setLoopCount(self->handle, loops)) return 0; PyErr_SetString(AUDError, "Couldn't set the loop count!"); } @@ -1369,7 +1369,7 @@ Handle_get_location(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Vector3 v = device->getSourceLocation(self->handle); @@ -1400,7 +1400,7 @@ Handle_set_location(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Vector3 location(x, y, z); @@ -1429,7 +1429,7 @@ Handle_get_velocity(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Vector3 v = device->getSourceVelocity(self->handle); @@ -1460,7 +1460,7 @@ Handle_set_velocity(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Vector3 velocity(x, y, z); @@ -1489,7 +1489,7 @@ Handle_get_orientation(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Quaternion o = device->getSourceOrientation(self->handle); @@ -1520,7 +1520,7 @@ Handle_set_orientation(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { AUD_Quaternion orientation(w, x, y, z); @@ -1549,7 +1549,7 @@ Handle_get_relative(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return PyBool_FromLong((long)device->isRelative(self->handle)); @@ -1581,7 +1581,7 @@ Handle_set_relative(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setRelative(self->handle, relative)) @@ -1610,7 +1610,7 @@ Handle_get_volume_minimum(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getVolumeMinimum(self->handle)); @@ -1640,7 +1640,7 @@ Handle_set_volume_minimum(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setVolumeMinimum(self->handle, volume)) @@ -1669,7 +1669,7 @@ Handle_get_volume_maximum(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getVolumeMaximum(self->handle)); @@ -1699,7 +1699,7 @@ Handle_set_volume_maximum(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setVolumeMaximum(self->handle, volume)) @@ -1729,7 +1729,7 @@ Handle_get_distance_reference(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getDistanceReference(self->handle)); @@ -1759,7 +1759,7 @@ Handle_set_distance_reference(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setDistanceReference(self->handle, distance)) @@ -1789,7 +1789,7 @@ Handle_get_distance_maximum(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getDistanceMaximum(self->handle)); @@ -1819,7 +1819,7 @@ Handle_set_distance_maximum(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setDistanceMaximum(self->handle, distance)) @@ -1849,7 +1849,7 @@ Handle_get_attenuation(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getAttenuation(self->handle)); @@ -1879,7 +1879,7 @@ Handle_set_attenuation(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setAttenuation(self->handle, factor)) @@ -1914,7 +1914,7 @@ Handle_get_cone_angle_inner(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getConeAngleInner(self->handle)); @@ -1944,7 +1944,7 @@ Handle_set_cone_angle_inner(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setConeAngleInner(self->handle, angle)) @@ -1973,7 +1973,7 @@ Handle_get_cone_angle_outer(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getConeAngleOuter(self->handle)); @@ -2003,7 +2003,7 @@ Handle_set_cone_angle_outer(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setConeAngleOuter(self->handle, angle)) @@ -2032,7 +2032,7 @@ Handle_get_cone_volume_outer(Handle *self, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { return Py_BuildValue("f", device->getConeVolumeOuter(self->handle)); @@ -2062,7 +2062,7 @@ Handle_set_cone_volume_outer(Handle *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(dev->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(dev->device)->get()); if(device) { if(device->setConeVolumeOuter(self->handle, volume)) @@ -2172,7 +2172,7 @@ static void Device_dealloc(Device* self) { if(self->device) - delete self->device; + delete reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device); Py_TYPE(self)->tp_free((PyObject*)self); } @@ -2215,21 +2215,21 @@ Device_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { case AUD_DEVICE_NULL: (void)specs; /* quiet warning when others disabled */ - self->device = new AUD_NULLDevice(); + self->device = new AUD_Reference<AUD_IDevice>(new AUD_NULLDevice()); break; case AUD_DEVICE_OPENAL: #ifdef WITH_OPENAL - self->device = new AUD_OpenALDevice(specs, buffersize); + self->device = new AUD_Reference<AUD_IDevice>(new AUD_OpenALDevice(specs, buffersize)); #endif break; case AUD_DEVICE_SDL: #ifdef WITH_SDL - self->device = new AUD_SDLDevice(specs, buffersize); + self->device = new AUD_Reference<AUD_IDevice>(new AUD_SDLDevice(specs, buffersize)); #endif break; case AUD_DEVICE_JACK: #ifdef WITH_JACK - self->device = new AUD_JackDevice(name, specs, buffersize); + self->device = new AUD_Reference<AUD_IDevice>(new AUD_JackDevice(name, specs, buffersize)); #endif break; case AUD_DEVICE_READ: @@ -2307,7 +2307,7 @@ Device_play(Device *self, PyObject *args, PyObject *kwds) try { - handle->handle = self->device->play(sound->factory, keep); + handle->handle = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->play(*reinterpret_cast<AUD_Reference<AUD_IFactory>*>(sound->factory), keep); } catch(AUD_Exception& e) { @@ -2336,7 +2336,7 @@ Device_lock(Device *self) { try { - self->device->lock(); + (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->lock(); Py_RETURN_NONE; } catch(AUD_Exception& e) @@ -2356,7 +2356,7 @@ Device_unlock(Device *self) { try { - self->device->unlock(); + (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->unlock(); Py_RETURN_NONE; } catch(AUD_Exception& e) @@ -2387,7 +2387,7 @@ Device_get_rate(Device *self, void* nothing) { try { - AUD_DeviceSpecs specs = self->device->getSpecs(); + AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs(); return Py_BuildValue("i", specs.rate); } catch(AUD_Exception& e) @@ -2405,7 +2405,7 @@ Device_get_format(Device *self, void* nothing) { try { - AUD_DeviceSpecs specs = self->device->getSpecs(); + AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs(); return Py_BuildValue("i", specs.format); } catch(AUD_Exception& e) @@ -2423,7 +2423,7 @@ Device_get_channels(Device *self, void* nothing) { try { - AUD_DeviceSpecs specs = self->device->getSpecs(); + AUD_DeviceSpecs specs = (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getSpecs(); return Py_BuildValue("i", specs.channels); } catch(AUD_Exception& e) @@ -2441,7 +2441,7 @@ Device_get_volume(Device *self, void* nothing) { try { - return Py_BuildValue("f", self->device->getVolume()); + return Py_BuildValue("f", (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->getVolume()); } catch(AUD_Exception& e) { @@ -2460,7 +2460,7 @@ Device_set_volume(Device *self, PyObject* args, void* nothing) try { - self->device->setVolume(volume); + (*reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device))->setVolume(volume); return 0; } catch(AUD_Exception& e) @@ -2478,7 +2478,7 @@ Device_get_listener_location(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Vector3 v = device->getListenerLocation(); @@ -2507,7 +2507,7 @@ Device_set_listener_location(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Vector3 location(x, y, z); @@ -2533,7 +2533,7 @@ Device_get_listener_velocity(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Vector3 v = device->getListenerVelocity(); @@ -2562,7 +2562,7 @@ Device_set_listener_velocity(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Vector3 velocity(x, y, z); @@ -2588,7 +2588,7 @@ Device_get_listener_orientation(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Quaternion o = device->getListenerOrientation(); @@ -2617,7 +2617,7 @@ Device_set_listener_orientation(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { AUD_Quaternion orientation(w, x, y, z); @@ -2644,7 +2644,7 @@ Device_get_speed_of_sound(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { return Py_BuildValue("f", device->getSpeedOfSound()); @@ -2672,7 +2672,7 @@ Device_set_speed_of_sound(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { device->setSpeedOfSound(speed); @@ -2700,7 +2700,7 @@ Device_get_doppler_factor(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { return Py_BuildValue("f", device->getDopplerFactor()); @@ -2728,7 +2728,7 @@ Device_set_doppler_factor(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { device->setDopplerFactor(factor); @@ -2754,7 +2754,7 @@ Device_get_distance_model(Device *self, void* nothing) { try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { return Py_BuildValue("i", int(device->getDistanceModel())); @@ -2782,7 +2782,7 @@ Device_set_distance_model(Device *self, PyObject* args, void* nothing) try { - AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(self->device); + AUD_I3DDevice* device = dynamic_cast<AUD_I3DDevice*>(reinterpret_cast<AUD_Reference<AUD_IDevice>*>(self->device)->get()); if(device) { device->setDistanceModel(AUD_DistanceModel(model)); diff --git a/intern/audaspace/Python/AUD_PyAPI.h b/intern/audaspace/Python/AUD_PyAPI.h index 6e217b07213..d1a70ce892d 100644 --- a/intern/audaspace/Python/AUD_PyAPI.h +++ b/intern/audaspace/Python/AUD_PyAPI.h @@ -36,17 +36,20 @@ #ifdef __cplusplus extern "C" { -#include "AUD_IDevice.h" +struct AUD_Handle; #else typedef void AUD_IFactory; typedef void AUD_IDevice; typedef void AUD_Handle; #endif +typedef void AUD_Reference_AUD_IFactory; +typedef void AUD_Reference_AUD_IDevice; + typedef struct { PyObject_HEAD PyObject* child_list; - AUD_IFactory* factory; + AUD_Reference_AUD_IFactory* factory; } Factory; typedef struct { @@ -57,7 +60,7 @@ typedef struct { typedef struct { PyObject_HEAD - AUD_IDevice* device; + AUD_Reference_AUD_IDevice* device; } Device; PyMODINIT_FUNC |