aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AudioSystem.h
blob: c941470e1531f3d51589a310be2549575f19c7e8 (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
#pragma once

#include "../api/AudioSource.h"
#include "../facade/Sound.h"
#include "../facade/SoundContext.h"

#include "System.h"

namespace crepe {

class AudioSystem : public System {
public:
	using System::System;
	void update() override;

private:
	/**
	 * \brief Private data stored by AudioSystem on AudioSource component
	 */
	struct ComponentPrivate {
		//! This sample's voice handle
		Sound::Handle handle;

		/**
		 * \name State diffing variables
		 * \{
		 */
		typeof(AudioSource::active) last_active;
		typeof(AudioSource::volume) last_volume;
		typeof(AudioSource::loop) last_loop;
		//! \}
	};

	void update_last(const AudioSource & component, ComponentPrivate & data);

	void diff_update(AudioSource & component, ComponentPrivate & data, Sound & resource);

protected:
	virtual SoundContext & get_context();

private:
	Private context;
};

} // namespace crepe