Lines 18-26
Link Here
|
18 |
* USA. |
18 |
* USA. |
19 |
*/ |
19 |
*/ |
20 |
|
20 |
|
21 |
#include <libgnome/gnome-sound.h> |
|
|
22 |
#include <esd.h> |
23 |
|
24 |
#include "sound.hpp" |
21 |
#include "sound.hpp" |
25 |
|
22 |
|
26 |
|
23 |
|
Lines 30-55
Link Here
|
30 |
return s; |
27 |
return s; |
31 |
} |
28 |
} |
32 |
|
29 |
|
33 |
Sound::Sound() |
30 |
Sound::Sound() : |
|
|
31 |
ctx(0) |
34 |
{ |
32 |
{ |
|
|
33 |
ca_context_create(&ctx); |
35 |
} |
34 |
} |
36 |
|
35 |
|
37 |
Sound::~Sound() |
36 |
Sound::~Sound() |
38 |
{ |
37 |
{ |
|
|
38 |
if (ctx) |
39 |
ca_context_destroy(ctx); |
39 |
} |
40 |
} |
40 |
|
41 |
|
41 |
void Sound::play(const std::string &name) |
42 |
void Sound::play(const std::string &name) |
42 |
{ |
43 |
{ |
43 |
int id; |
44 |
if (ctx) |
44 |
|
45 |
ca_context_play(ctx, 0, |
45 |
cache_map::iterator i = cache.find(name); |
46 |
CA_PROP_MEDIA_FILENAME, (MONSTER_MASHER_SOUND_DIR + name).c_str(), |
46 |
if (i != cache.end()) |
47 |
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", |
47 |
id = i->second; |
48 |
NULL); |
48 |
else { |
|
|
49 |
id = gnome_sound_sample_load(name.c_str(), |
50 |
(MONSTER_MASHER_SOUND_DIR + name).c_str()); |
51 |
cache.insert(make_pair(name, id)); |
52 |
} |
53 |
|
54 |
esd_sample_play(gnome_sound_connection_get(), id); |
55 |
} |
49 |
} |