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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
// SoundPlayer.hh
//
// Copyright (C) 2002, 2003, 2006, 2007, 2008, 2009, 2010, 2011 Rob Caelers & Raymond Penners
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifndef SOUNDPLAYER_HH
#define SOUNDPLAYER_HH
#include <string>
#include <list>
#include <vector>
#include <map>
#include "ISoundDriver.hh"
class IMixer;
class SoundPlayer : public ISoundDriverEvents
{
public:
enum Device
{
DEVICE_SPEAKER = 0,
DEVICE_SOUNDCARD
};
class Theme
{
public:
std::string description;
std::vector<std::string> files;
bool active;
};
struct SoundRegistry
{
const char *label;
const char *id;
const char *wav_file;
const char *friendly_name;
};
SoundPlayer();
virtual ~SoundPlayer();
void play_sound(SoundEvent snd, bool mute_after_playback = false);
void play_sound(std::string wavfile);
static bool is_enabled();
static void set_enabled(bool enabled);
static Device get_device();
static void set_device(Device dev);
void init();
bool capability(SoundCapability cap);
void restore_mute();
bool get_sound_enabled(SoundEvent snd, bool &enabled);
void set_sound_enabled(SoundEvent snd, bool enabled);
bool get_sound_wav_file(SoundEvent snd, std::string &filename);
void set_sound_wav_file(SoundEvent snd, const std::string &wav_file);
void get_sound_themes(std::vector<Theme> &themes);
void load_sound_theme(const std::string &path, Theme &theme);
void activate_theme(const Theme &theme, bool force = true);
void eos_event();
private:
void register_sound_events(std::string theme = "");
#ifdef PLATFORM_OS_WINDOWS
void win32_remove_deprecated_appevents();
static void registry_set_value(const char *path, const char *name, const char *value);
#endif
public:
static const char *CFG_KEY_SOUND_ENABLED;
static const char *CFG_KEY_SOUND_DEVICE;
static const char *CFG_KEY_SOUND_VOLUME;
static const char *CFG_KEY_SOUND_EVENTS;
static const char *CFG_KEY_SOUND_EVENTS_ENABLED;
static const char *CFG_KEY_SOUND_MUTE;
static SoundRegistry sound_registry[SOUND_MAX];
private:
ISoundDriver *driver;
IMixer *mixer;
bool delayed_mute;
bool must_unmute;
};
#endif // SOUNDPLAYER_HH
|