diff --git a/configure.py b/configure.py index c6ce4377..21cbaef5 100644 --- a/configure.py +++ b/configure.py @@ -1072,7 +1072,7 @@ config.libs = [ Object(Matching, "nw4r/snd/snd_StrmFile.cpp"), Object(Matching, "nw4r/snd/snd_StrmPlayer.cpp"), Object(Matching, "nw4r/snd/snd_StrmSound.cpp"), - Object(NonMatching, "nw4r/snd/snd_StrmSoundHandle.cpp"), + Object(Matching, "nw4r/snd/snd_StrmSoundHandle.cpp"), Object(Matching, "nw4r/snd/snd_Task.cpp"), Object(Matching, "nw4r/snd/snd_TaskManager.cpp"), Object(Matching, "nw4r/snd/snd_TaskThread.cpp"), diff --git a/include/nw4r/snd/snd_StrmSoundHandle.h b/include/nw4r/snd/snd_StrmSoundHandle.h index bebb9e40..3e92331c 100644 --- a/include/nw4r/snd/snd_StrmSoundHandle.h +++ b/include/nw4r/snd/snd_StrmSoundHandle.h @@ -7,6 +7,7 @@ #include "common.h" // nullptr +#include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/ut/ut_NonCopyable.h" // ut::NonCopyable /******************************************************************************* @@ -28,6 +29,7 @@ namespace nw4r { namespace snd // methods public: // methods + StrmSoundHandle(SoundHandle*); bool IsAttachedSound() const { return mSound != nullptr; } void DetachSound(); diff --git a/src/nw4r/snd/snd_StrmSoundHandle.cpp b/src/nw4r/snd/snd_StrmSoundHandle.cpp index 09c687d8..63c59b7b 100644 --- a/src/nw4r/snd/snd_StrmSoundHandle.cpp +++ b/src/nw4r/snd/snd_StrmSoundHandle.cpp @@ -11,7 +11,9 @@ #include "common.h" // nullptr +#include "nw4r/snd/snd_SoundHandle.h" #include "nw4r/snd/snd_StrmSound.h" +#include "nw4r/ut/ut_RuntimeTypeInfo.h" /******************************************************************************* * functions @@ -19,6 +21,29 @@ namespace nw4r { namespace snd { +StrmSoundHandle::StrmSoundHandle(SoundHandle* handle) + : mSound(nullptr) +{ + if (!handle) + return; + + detail::BasicSound *basicSound = handle->detail_GetAttachedSound(); + if (!basicSound) + return; + + if (detail::StrmSound *sound = + ut::DynamicCast(basicSound)) + { + + mSound = sound; + + if (mSound->IsAttachedTempSpecialHandle()) + mSound->DetachTempSpecialHandle(); + + mSound->mTempSpecialHandle = this; + } +} + void StrmSoundHandle::DetachSound() { if (IsAttachedSound())