[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src clone/mainloop.c editor/editloop....
From: |
ludovic pollet |
Subject: |
[Stratagus-CVS] stratagus/src clone/mainloop.c editor/editloop.... |
Date: |
Mon, 03 Nov 2003 06:09:55 -0500 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: ludovic pollet <address@hidden> 03/11/03 06:09:53
Modified files:
src/clone : mainloop.c
src/editor : editloop.c
src/include : sound_server.h
src/sound : sound_server.c
src/ui : menu_proc.c
Log message:
Avoid calling ccl eval in sound thread. ( patch #2197 )
Patches:
Index: stratagus/src/clone/mainloop.c
diff -u stratagus/src/clone/mainloop.c:1.153
stratagus/src/clone/mainloop.c:1.154
--- stratagus/src/clone/mainloop.c:1.153 Thu Oct 30 15:22:48 2003
+++ stratagus/src/clone/mainloop.c Mon Nov 3 06:09:49 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: mainloop.c,v 1.153 2003/10/30 20:22:48 n0body Exp $
+// $Id: mainloop.c,v 1.154 2003/11/03 11:09:49 pludov Exp $
//@{
@@ -801,6 +801,7 @@
PlaySectionMusic(PlaySectionGame);
while (GameRunning) {
+
#if defined(DEBUG) && defined(HIERARCHIC_PATHFINDER)
if (setjmp(MainLoopJmpBuf)) {
GamePaused = 1;
@@ -891,6 +892,8 @@
TriggersEachCycle(); // handle triggers
UpdateMessages(); // update messages
+
+ PlayListAdvance(); // Check for next song
//
// Map scrolling
Index: stratagus/src/editor/editloop.c
diff -u stratagus/src/editor/editloop.c:1.138
stratagus/src/editor/editloop.c:1.139
--- stratagus/src/editor/editloop.c:1.138 Sat Oct 25 17:05:32 2003
+++ stratagus/src/editor/editloop.c Mon Nov 3 06:09:51 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: editloop.c,v 1.138 2003/10/25 21:05:32 n0body Exp $
+// $Id: editloop.c,v 1.139 2003/11/03 11:09:51 pludov Exp $
//@{
@@ -2031,6 +2031,8 @@
TileCursorSize = 1;
while (EditorRunning) {
+ PlayListAdvance();
+
if (MustRedraw & RedrawMinimap) {
UpdateMinimap();
}
Index: stratagus/src/include/sound_server.h
diff -u stratagus/src/include/sound_server.h:1.61
stratagus/src/include/sound_server.h:1.62
--- stratagus/src/include/sound_server.h:1.61 Mon Oct 6 16:03:29 2003
+++ stratagus/src/include/sound_server.h Mon Nov 3 06:09:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sound_server.h,v 1.61 2003/10/06 20:03:29 jsalmon3 Exp $
+// $Id: sound_server.h,v 1.62 2003/11/03 11:09:52 pludov Exp $
#ifndef __SOUND_SERVER_H__
#define __SOUND_SERVER_H__
@@ -299,6 +299,8 @@
/// Initialize the sound server.
extern int InitSoundServer(void);
+ /// Start next song if necessary
+extern void PlayListAdvance(void);
/** Ask the sound layer to write the content of its buffer to the sound
device. To be used only in the unthreaded version.
@@ -320,7 +322,7 @@
#define InitSound() 0 /// Dummy macro for without sound
#define WriteSound NULL /// Dummy macro for without sound
#define QuitSound() /// Dummy macro for without sound
-
+#define PlayListAdvance() /// Dummy macro for without sound
#endif // } WITH_SOUND
extern int WaitForSoundDevice; /// Block until sound device available
Index: stratagus/src/sound/sound_server.c
diff -u stratagus/src/sound/sound_server.c:1.124
stratagus/src/sound/sound_server.c:1.125
--- stratagus/src/sound/sound_server.c:1.124 Fri Oct 31 16:56:29 2003
+++ stratagus/src/sound/sound_server.c Mon Nov 3 06:09:52 2003
@@ -27,7 +27,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: sound_server.c,v 1.124 2003/10/31 21:56:29 jsalmon3 Exp $
+// $Id: sound_server.c,v 1.125 2003/11/03 11:09:52 pludov Exp $
//@{
@@ -59,6 +59,7 @@
#error "not USE_SDLA and USE_THREAD"
#endif
#include "SDL_audio.h"
+#include "SDL_mutex.h"
#else
#ifdef __linux__
# include <sys/ioctl.h>
@@ -132,12 +133,50 @@
global int SoundThreadRunning; /// FIXME: docu
+local int MusicTerminated;
+
+#ifdef USE_SDLA
+SDL_mutex * MusicTerminatedMutex;
+#endif
+
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
#if defined(USE_OGG) || defined(USE_FLAC) || defined(USE_MAD) ||
defined(USE_LIBMODPLUG) || defined(USE_CDDA)
+
+/**
+** Check if the playlist need to be advanced,
+** and invoque music-stopped if necessary
+*/
+global void PlayListAdvance(void)
+{
+ int proceed;
+ SCM cb;
+ SCM value;
+
+#ifdef USE_SDLA
+ SDL_LockMutex(MusicTerminatedMutex);
+#endif
+ proceed = MusicTerminated;
+ MusicTerminated = 0;
+#ifdef USE_SDLA
+ SDL_UnlockMutex(MusicTerminatedMutex);
+#endif
+
+ if (proceed) {
+ cb = gh_symbol2scm("music-stopped");
+ if (symbol_boundp(cb, NIL)) {
+
+ value = symbol_value(cb, NIL);
+ if (!gh_null_p(value)) {
+ gh_apply(value, NIL);
+ }
+ }
+ }
+}
+
/**
** Mix music to stereo 32 bit.
**
@@ -180,23 +219,19 @@
}
if (n != len) { // End reached
- SCM cb;
-
PlayingMusic = 0;
SoundFree(MusicSample);
MusicSample = NULL;
- // FIXME: we are inside the SDL callback!
+ // we are inside the SDL callback!
if (CallbackMusic) {
- cb = gh_symbol2scm("music-stopped");
- if (symbol_boundp(cb, NIL)) {
- SCM value;
-
- value = symbol_value(cb, NIL);
- if (!gh_null_p(value)) {
- gh_apply(value, NIL);
- }
- }
+#ifdef USE_SDLA
+ SDL_LockMutex(MusicTerminatedMutex);
+#endif
+ MusicTerminated = 1;
+#ifdef USE_SDLA
+ SDL_UnlockMutex(MusicTerminatedMutex);
+#endif
}
}
}
@@ -1141,6 +1176,11 @@
{
int dummy;
+ MusicTerminated = 0;
+#ifdef USE_SDLA
+ MusicTerminatedMutex = SDL_CreateMutex();
+#endif
+
#ifdef USE_SDLA
//
// Open sound device, 8bit samples, stereo.
@@ -1225,6 +1265,8 @@
SoundThreadRunning = 1;
}
#endif
+
+
return 0;
}
Index: stratagus/src/ui/menu_proc.c
diff -u stratagus/src/ui/menu_proc.c:1.108 stratagus/src/ui/menu_proc.c:1.109
--- stratagus/src/ui/menu_proc.c:1.108 Mon Oct 27 00:56:19 2003
+++ stratagus/src/ui/menu_proc.c Mon Nov 3 06:09:52 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: menu_proc.c,v 1.108 2003/10/27 05:56:19 mr-russ Exp $
+// $Id: menu_proc.c,v 1.109 2003/11/03 11:09:52 pludov Exp $
//@{
@@ -2428,9 +2428,11 @@
MustRedraw = RedrawEverything;
if (loop) {
while (CurrentMenu != NULL) {
+ PlayListAdvance();
if (!(FrameCounter % ((VideoSyncSpeed * CYCLES_PER_SECOND) / 50))) {
PlaySectionMusic(PlaySectionUnknown);
}
+
DebugLevel3("MustRedraw: 0x%08x\n" _C_ MustRedraw);
if (MustRedraw) {
if (CurrentMenu->Panel && !strcmp(CurrentMenu->Panel, ScPanel))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src clone/mainloop.c editor/editloop....,
ludovic pollet <=