Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Sound.cpp
Go to the documentation of this file.
1 //
2 // C++ Implementation: Audio::Sound
3 //
4 
5 #include "Sound.h"
6 #include "config.h"
7 
8 #include "utils.h"
9 
10 namespace Audio {
11 
12  Sound::Sound(const std::string& _name, bool streaming) throw() :
13  name(_name)
14  {
15  flags.loaded = false;
16  flags.loading = false;
17  flags.streaming = streaming;
18  }
19 
21  {
22  unload();
23  }
24 
25  void Sound::load(bool wait) throw(Exception)
26  {
27  if (!isLoaded()) {
28  if (!isLoading())
29  loadImpl(wait);
30  if (wait && !isLoaded())
31  waitLoad();
32  }
33  }
34 
36  throw(Exception)
37  {
38  while (isLoading())
39  Audio::sleep(10);
40  }
41 
42  void Sound::unload()
43  throw()
44  {
45  if (isLoading()) {
46  abortLoad();
47  if (isLoading())
48  waitLoad();
49  }
50  if (isLoaded()) {
51  unloadImpl();
52  flags.loaded = false;
53  }
54  }
55 
56  void Sound::onLoaded(bool success)
57  throw()
58  {
59  flags.loaded = success;
60  flags.loading = false;
61  }
62 
64  throw()
65  {
66  // Do nothing, there's no background load
67  }
68 
69 };