summaryrefslogtreecommitdiff
path: root/src/nw4r/snd/snd_SoundActor.cpp
blob: 6c286dc930895aaab82917d80040ec7b32be4d3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Only implemented to the extent necessary to match early instantiations of
 * inline functions and data sections.
 */

#include "nw4r/snd/snd_SoundActor.h"

#include "common.h"

#include "nw4r/snd/snd_SoundArchivePlayer.h"

namespace nw4r { namespace snd {

SoundActor::SoundActor(SoundArchivePlayer &player) :
	mSoundArchivePlayer	(player)
{
	
	for (int i = 0; i < ACTOR_PLAYER_COUNT; i++)
	{
		mActorPlayer[i].SetPlayableSoundCount(i == 0 ? INT_MAX : 1);
	}
}

SoundActor::~SoundActor()
{
	for (int i = 0; i < ACTOR_PLAYER_COUNT; i++)
	{
		mActorPlayer[i].DetachSoundActorAll(this);
	}
}

void SoundActor::StopAllSound(int fadeFrames)
{
	for (int i = 0; i < ACTOR_PLAYER_COUNT; i++)
	{
		mActorPlayer[i].StopAllSound(fadeFrames);
	}
}

void SoundActor::PauseAllSound(bool flag, int fadeFrames)
{
	for (int i = 0; i < ACTOR_PLAYER_COUNT; i++)
	{
		mActorPlayer[i].PauseAllSound(flag, fadeFrames);
	}
}

int SoundActor::GetPlayingSoundCount(int playerId) const
{
	return mActorPlayer[playerId].GetPlayingSoundCount();
}

SoundStartable::StartResult SoundActor::SetupSound(SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, void* arg)
{
	return mSoundArchivePlayer.detail_SetupSoundImpl(pHandle, soundId, nullptr, this, *(bool*)arg, pStartInfo);
}

SoundStartable::StartResult SoundActor::detail_SetupSoundWithAmbientInfo(SoundHandle *pHandle, u32 soundId, const StartInfo *pStartInfo, detail::BasicSound::AmbientInfo *pAmbientInfo, void* arg)
{
	return mSoundArchivePlayer.detail_SetupSoundImpl(pHandle, soundId, pAmbientInfo, this, *(bool*)arg, pStartInfo);
}

SoundStartable::StartResult SoundActor::detail_SetupSound(SoundHandle *pHandle, u32 soundId, bool holdFlag, const StartInfo *pStartInfo)
{
	return SetupSound(pHandle, soundId, pStartInfo, &holdFlag);
}

u32 SoundActor::detail_ConvertLabelStringToSoundId(const char* label)
{
	return mSoundArchivePlayer.detail_ConvertLabelStringToSoundId(label);
}

}}