snd_StrmSoundHandle OK

This commit is contained in:
robojumper
2025-05-27 22:10:58 +02:00
parent 5797f4cf8a
commit 8f7362eb4d
3 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -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"),
+2
View File
@@ -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();
+25
View File
@@ -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<detail::StrmSound *>(basicSound))
{
mSound = sound;
if (mSound->IsAttachedTempSpecialHandle())
mSound->DetachTempSpecialHandle();
mSound->mTempSpecialHandle = this;
}
}
void StrmSoundHandle::DetachSound()
{
if (IsAttachedSound())