File: SoundState.h

package info (click to toggle)
libexadrums 0.7.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 652 kB
  • sloc: cpp: 6,970; ansic: 220; makefile: 160; sh: 12
file content (54 lines) | stat: -rw-r--r-- 970 bytes parent folder | download | duplicates (3)
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
/*
 * SoundState.h
 *
 *  Created on: 30 Jul 2017
 *      Author: jeremy
 */

#ifndef SOURCE_SOUND_SOUNDSTATE_H_
#define SOURCE_SOUND_SOUNDSTATE_H_

#include <atomic>

namespace Sound
{

	struct SoundState
	{

		SoundState() : id(0), volume(0.), index(0)
		{
			isPlaying.store(false);
		}

		SoundState(int i, float v, bool ip) : id(i), volume(v), index(0)
		{
			isPlaying.store(ip, std::memory_order_release);
		}

		SoundState(const SoundState& s) : id(s.id), volume(s.volume), index(s.index)
		{
			isPlaying.store(s.isPlaying.load(std::memory_order_acquire), std::memory_order_release);
		}

		SoundState& operator=(const SoundState& s)
		{

			this->id = s.id;
			this->volume = s.volume;
			this->index = s.index;
			this->isPlaying.store(s.isPlaying.load(std::memory_order_acquire), std::memory_order_release);

			return *this;
		}

		int id;
		float volume;
		std::size_t index;
		std::atomic<bool> isPlaying;

	};

}

#endif /* SOURCE_SOUND_SOUNDSTATE_H_ */