Package: blocks-of-the-undead / 1.0-7

03_dont_fail_if_no_sound_available.patch Patch series | download
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
From: Evgeni Golov <evgeni@debian.org>
Subject: Don't fail if there is no sound available
 This can happen when the user does not have enough rights to use the
 soundcard or there is no soundcard at all in the machine.
Bug-Debian: http://bugs.debian.org/603440

Index: blocks-of-the-undead-1.0/Oodle/src/CSound.cpp
===================================================================
--- blocks-of-the-undead-1.0.orig/Oodle/src/CSound.cpp	2005-01-16 21:20:00.000000000 +0100
+++ blocks-of-the-undead-1.0/Oodle/src/CSound.cpp	2012-05-01 20:13:34.038037764 +0200
@@ -6,13 +6,16 @@
 	const char* f2  = file.c_str();
 	data = Mix_LoadWAV( f2 );
 
-	if (!data)
-		_THROWEX(ex_sdl, "Failed to load sound", "CSound", "CSound", "snd = " << snd);
+	if (!data) {
+		LOG("Failed to load sound " << snd << ".", 1, LOG_INFO);
+		LOG("This is normal if \"CSoundSystem\" failed to load above.", 1, LOG_INFO);
+	}
 }
 
 CSound::~CSound()
 {
-	Mix_FreeChunk(data);
+	if (data)
+		Mix_FreeChunk(data);
 }
 
 void CSound::setChannel(int c)
@@ -28,4 +31,4 @@
 Mix_Chunk* CSound::getChunk() const
 {
 	return data;
-}
\ No newline at end of file
+}
Index: blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.cpp
===================================================================
--- blocks-of-the-undead-1.0.orig/Oodle/src/CSoundSystem.cpp	2005-01-16 21:20:00.000000000 +0100
+++ blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.cpp	2012-05-01 20:13:34.038037764 +0200
@@ -3,24 +3,28 @@
 CSoundSystem::CSoundSystem(int chunksize, int frequency, int channels, Uint16 format)
 {
 	SDL_InitSubSystem(SDL_INIT_AUDIO);
+	soundAvailable = true;
 	if (Mix_OpenAudio(frequency, format, channels, chunksize))
 	{
-		_THROWEX(ex_sdl, "Failed to load sound subsystem", "CSoundSystem", "CSoundSystem",
-			"frequency = " << frequency << ", chunksize = " << chunksize << ", " <<
-			"channels = " << channels << ", format = " << format);
+		soundAvailable = false;
+		LOG("Failed to load sound subsystem \"CSoundSystem\".", 1, LOG_ERROR);
+		LOG("You will not have any sound during the game.", 1, LOG_INFO);
 	}
 }
 
 void CSoundSystem::playSound(CSound &snd) const
 {
-	snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) );
+	if (soundAvailable)
+		snd.setChannel( Mix_PlayChannel(-1, snd.getChunk(), 0) );
 }
 void CSoundSystem::stopSound(const CSound &snd) const
 {
-	Mix_HaltChannel(snd.getChannel());
+	if (soundAvailable)
+		Mix_HaltChannel(snd.getChannel());
 }
 
 CSoundSystem::~CSoundSystem()
 {
-	Mix_CloseAudio();
-}
\ No newline at end of file
+	if (soundAvailable)
+		Mix_CloseAudio();
+}
Index: blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.h
===================================================================
--- blocks-of-the-undead-1.0.orig/Oodle/src/CSoundSystem.h	2005-01-17 05:48:19.000000000 +0100
+++ blocks-of-the-undead-1.0/Oodle/src/CSoundSystem.h	2012-05-01 20:13:34.038037764 +0200
@@ -13,7 +13,7 @@
 	void playSound(CSound &snd) const;
 	void stopSound(const CSound &snd) const;
 private:
-	
+	bool soundAvailable;
 };
 
 #endif