Debian Codegraph @

debian/patches/03_dont_fail_if_no_sound_available.patch

raw symbols SCIP
1 From: Evgeni Golov <[email protected]>
2 Subject: Don't fail if there is no sound available
3 This can happen when the user does not have enough rights to use the
4 soundcard or there is no soundcard at all in the machine.
5 Bug-Debian: http://bugs.debian.org/603440
6
7 Index: blocks-of-the-undead-1.0/Oodle/src/CSound.cpp
8 ===================================================================
9 --- blocks-of-the-undead-1.0.orig/Oodle/src/CSound.cpp 2005-01-16 21:20:00.000000000 +0100
10 +++ blocks-of-the-undead-1.0/Oodle/src/CSound.cpp 2012-05-01 20:13:34.038037764 +0200
11 @@ -6,13 +6,16 @@
12 const char* f2 = file.c_str();
13 data = Mix_LoadWAV( f2 );
14
15 - if (!data)
16 - _THROWEX(ex_sdl, "Failed to load sound", "CSound", "CSound", "snd = " << snd);
17 + if (!data) {
18 + LOG("Failed to load sound " << snd << ".", 1, LOG_INFO);
19 + LOG("This is normal if \"CSoundSystem\" failed to load above.", 1, LOG_INFO);
20 + }
21 }
22
23 CSound::~CSound()
24 {
25 - Mix_FreeChunk(data);
26 + if (data)
27 + Mix_FreeChunk(data);
28 }
29
30 void CSound::setChannel(int c)
31 @@ -28,4 +31,4 @@
32 Mix_Chunk* CSound::getChunk() const
33 {
34 return data;
35 -}
36 \ No newline at end of file
37 +}
38 Index: blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.cpp
39 ===================================================================
40 --- blocks-of-the-undead-1.0.orig/Oodle/src/CSoundSystem.cpp 2005-01-16 21:20:00.000000000 +0100
41 +++ blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.cpp 2012-05-01 20:13:34.038037764 +0200
42 @@ -3,24 +3,28 @@
43 CSoundSystem::CSoundSystem(int chunksize, int frequency, int channels, Uint16 format)
44 {
45 SDL_InitSubSystem(SDL_INIT_AUDIO);
46 + soundAvailable = true;
47 if (Mix_OpenAudio(frequency, format, channels, chunksize))
48 {
49 - _THROWEX(ex_sdl, "Failed to load sound subsystem", "CSoundSystem", "CSoundSystem",
50 - "frequency = " << frequency << ", chunksize = " << chunksize << ", " <<
51 - "channels = " << channels << ", format = " << format);
52 + soundAvailable = false;
53 + LOG("Failed to load sound subsystem \"CSoundSystem\".", 1, LOG_ERROR);
54 + LOG("You will not have any sound during the game.", 1, LOG_INFO);
55 }
56 }
57
58 void CSoundSystem::playSound(CSound &snd) const
59 {
60 - snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) );
61 + if (soundAvailable)
62 + snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) );
63 }
64 void CSoundSystem::stopSound(const CSound &snd) const
65 {
66 - Mix_HaltChannel(snd.getChannel());
67 + if (soundAvailable)
68 + Mix_HaltChannel(snd.getChannel());
69 }
70
71 CSoundSystem::~CSoundSystem()
72 {
73 - Mix_CloseAudio();
74 -}
75 \ No newline at end of file
76 + if (soundAvailable)
77 + Mix_CloseAudio();
78 +}
79 Index: blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.h
80 ===================================================================
81 --- blocks-of-the-undead-1.0.orig/Oodle/src/CSoundSystem.h 2005-01-17 05:48:19.000000000 +0100
82 +++ blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.h 2012-05-01 20:13:34.038037764 +0200
83 @@ -13,7 +13,7 @@
84 void playSound(CSound &snd) const;
85 void stopSound(const CSound &snd) const;
86 private:
87 -
88 + bool soundAvailable;
89 };
90
91 #endif