Lines 30-55
Link Here
|
30 |
return s; |
30 |
return s; |
31 |
} |
31 |
} |
32 |
|
32 |
|
33 |
Sound::Sound() |
33 |
Sound::Sound() : |
|
|
34 |
ctx(0) |
34 |
{ |
35 |
{ |
|
|
36 |
ca_context_create(&ctx); |
35 |
} |
37 |
} |
36 |
|
38 |
|
37 |
Sound::~Sound() |
39 |
Sound::~Sound() |
38 |
{ |
40 |
{ |
|
|
41 |
if (ctx) |
42 |
ca_context_destroy(ctx); |
39 |
} |
43 |
} |
40 |
|
44 |
|
41 |
void Sound::play(const std::string &name) |
45 |
void Sound::play(const std::string &name) |
42 |
{ |
46 |
{ |
43 |
int id; |
47 |
if (ctx) |
44 |
|
48 |
ca_context_play(ctx, 0, |
45 |
cache_map::iterator i = cache.find(name); |
49 |
CA_PROP_MEDIA_FILENAME, (MONSTER_MASHER_SOUND_DIR + name).c_str(), |
46 |
if (i != cache.end()) |
50 |
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", |
47 |
id = i->second; |
51 |
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 |
} |
52 |
} |