____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 2002-2008 by Lutz Sammer, Nehal Mistry, and Jimmy Salmon 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 // 00028 00030 00031 /*---------------------------------------------------------------------------- 00032 -- Includes 00033 ----------------------------------------------------------------------------*/ 00034 00035 #include "stratagus.h" 00036 00037 #include <stdio.h> 00038 00039 #include "SDL.h" 00040 00041 #include "sound_server.h" 00042 #include "script.h" 00043 00044 /*---------------------------------------------------------------------------- 00045 -- Declaration 00046 ----------------------------------------------------------------------------*/ 00047 00048 #define SoundFrequency 44100 // sample rate of dsp 00049 00050 /*---------------------------------------------------------------------------- 00051 -- Variables 00052 ----------------------------------------------------------------------------*/ 00053 00054 static SDL_mutex *MusicFinishedMutex; 00055 static bool MusicFinished; 00056 00057 bool CallbackMusic; 00058 00059 /*---------------------------------------------------------------------------- 00060 -- Functions 00061 ----------------------------------------------------------------------------*/ 00062 00067 static void MusicFinishedCallback(void) 00068 { 00069 SDL_LockMutex(MusicFinishedMutex); 00070 MusicFinished = true; 00071 SDL_UnlockMutex(MusicFinishedMutex); 00072 } 00073 00077 void CheckMusicFinished(bool force) 00078 { 00079 bool proceed; 00080 00081 SDL_LockMutex(MusicFinishedMutex); 00082 proceed = MusicFinished; 00083 MusicFinished = false; 00084 SDL_UnlockMutex(MusicFinishedMutex); 00085 00086 if ((proceed || force) && SoundEnabled() && IsMusicEnabled() && CallbackMusic) { 00087 lua_pushstring(Lua, "MusicStopped"); 00088 lua_gettable(Lua, LUA_GLOBALSINDEX); 00089 if (!lua_isfunction(Lua, -1)) { 00090 fprintf(stderr, "No MusicStopped function in Lua\n"); 00091 StopMusic(); 00092 } else { 00093 LuaCall(0, 1); 00094 } 00095 } 00096 } 00097 00101 void InitMusic(void) 00102 { 00103 MusicFinished = false; 00104 MusicFinishedMutex = SDL_CreateMutex(); 00105 SetMusicFinishedCallback(MusicFinishedCallback); 00106 } 00107
1.5.6