From 94f329e8fbb28a9f0ea69b23bb60abc0b8a88f96 Mon Sep 17 00:00:00 2001 From: Shinya Kitaoka Date: Apr 15 2016 09:03:25 +0000 Subject: fix tsound_mac.cpp --- diff --git a/toonz/sources/common/tsound/tsound_mac.cpp b/toonz/sources/common/tsound/tsound_mac.cpp index a225dda..63dd759 100644 --- a/toonz/sources/common/tsound/tsound_mac.cpp +++ b/toonz/sources/common/tsound/tsound_mac.cpp @@ -22,7 +22,7 @@ namespace TThread::Mutex MutexOut; } -class TSoundOutputDeviceImp +class TSoundOutputDeviceImp : public std::enable_shared_from_this { public: bool m_isPlaying; @@ -65,10 +65,18 @@ struct MyData { void *sourceBuffer; AudioConverterRef converter; - TSoundOutputDeviceImp *imp; + std::shared_ptr imp; bool isLooping; MyData() - : entireFileBuffer(0), totalPacketCount(0), fileByteCount(0), maxPacketSize(0), packetOffset(0), byteOffset(0), sourceBuffer(0), isLooping(false), imp(0), m_doNotify(true) + : entireFileBuffer(0) + , totalPacketCount(0) + , fileByteCount(0) + , maxPacketSize(0) + , packetOffset(0) + , byteOffset(0) + , sourceBuffer(0) + , isLooping(false) + , m_doNotify(true) { } }; @@ -341,7 +349,6 @@ TSoundOutputDevice::~TSoundOutputDevice() { stop(); close(); - delete m_imp; } //------------------------------------------------------------------------------ @@ -415,7 +422,7 @@ void TSoundOutputDeviceImp::play(const TSoundTrackP &st, TINT32 s0, TINT32 s1, b OSStatus err = noErr; MyData *myData = new MyData(); - myData->imp = this; + myData->imp = shared_from_this(); UInt32 magicCookieSize = 0; //PrintStreamDesc(&outputASBD); err = AudioConverterNew(&fileASBD, &outputASBD, &converter); @@ -710,11 +717,6 @@ TSoundInputDevice::TSoundInputDevice() : m_imp(new TSoundInputDeviceImp) TSoundInputDevice::~TSoundInputDevice() { - /* - if(m_imp->m_port) - alClosePort(m_imp->m_port); - delete m_imp; - */ } //------------------------------------------------------------------------------ diff --git a/toonz/sources/include/tsound.h b/toonz/sources/include/tsound.h index 8f3b543..1920805 100644 --- a/toonz/sources/include/tsound.h +++ b/toonz/sources/include/tsound.h @@ -360,7 +360,7 @@ class TSoundOutputDeviceImp; */ class DVAPI TSoundOutputDevice { - std::unique_ptr m_imp; + std::shared_ptr m_imp; public: TSoundOutputDevice();