From: <sv...@ww...> - 2005-12-05 05:40:44
|
Author: mkrose Date: 2005-12-04 21:40:38 -0800 (Sun, 04 Dec 2005) New Revision: 1725 Modified: trunk/CSP/csp/cspsim/CSPSim.cpp trunk/CSP/csp/cspsim/CSPSim.h Log: Remove some old SDL sound code from CSPSim. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1725 Modified: trunk/CSP/csp/cspsim/CSPSim.cpp =================================================================== --- trunk/CSP/csp/cspsim/CSPSim.cpp 2005-12-05 05:32:37 UTC (rev 1724) +++ trunk/CSP/csp/cspsim/CSPSim.cpp 2005-12-05 05:40:38 UTC (rev 1725) @@ -77,31 +77,9 @@ //--#include <Producer/RenderSurface> #include <SDL/SDL.h> -#include <SDL/SDL_audio.h> #include <SDL/SDL_joystick.h> - -/* -//////////////////////////////////////////////// -// FIXME - -//#include "AircraftObject.h" - -// -//////////////////////////////////////////////// - - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef TRUE -#define TRUE 1 -#endif -*/ - - CSP_NAMESPACE // For network testing on a single box it's convenient to disable rendering on @@ -109,15 +87,6 @@ bool g_DisableRender = false; -struct SDLWave { - SDL_AudioSpec spec; - Uint8 *sound; /* Pointer to wave data */ - Uint32 soundlen; /* Length of wave data */ - int soundpos; /* Current play position */ -}; - -SDLWave m_audioWave; - /////////////////////////////////////////////////////////////////////// // CSPSim @@ -307,6 +276,7 @@ std::string theater = g_Config.getPath("Testing", "Theater", "sim:theater.balkan", false); m_Theater = m_DataManager->getObject(theater.c_str()); assert(m_Theater.valid()); + //CSP_VERIFY(m_Theater->initialize(*m_DataManager)); m_Terrain = m_Theater->getTerrain(); assert(m_Terrain.valid()); m_Terrain->setScreenSizeHint(m_ScreenWidth, m_ScreenHeight); @@ -427,7 +397,6 @@ m_GameScreen->onInit(); changeScreen(m_GameScreen); - } catch (Exception &e) { FatalException(e, "initialization"); @@ -712,7 +681,7 @@ m_ScreenHeight = height; m_ScreenWidth = width; - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO /* | SDL_INIT_NOPARACHUTE */ ) != 0) { + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK) != 0) { std::cerr << "Unable to initialize SDL: " << SDL_GetError() << "\n"; CSPLOG(ERROR, APP) << "ERROR! Unable to initialize SDL: " << SDL_GetError(); return 1; @@ -730,8 +699,8 @@ } m_SDLScreen = SDL_SetVideoMode(width, height, bpp, flags); - SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 ); - SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if (m_SDLScreen == NULL) { std::cerr << "Unable to set video mode: " << SDL_GetError() << "\n"; @@ -748,52 +717,12 @@ SDL_EnableUNICODE(1); - // some simple sdl sound testing - std::string sound_path = getDataPath("SoundPath"); - std::string test_sound = ospath::join(sound_path, "avionturbine5.wav"); - if (SDL_LoadWAV(test_sound.c_str(), &m_audioWave.spec, &m_audioWave.sound, - &m_audioWave.soundlen) == NULL) { - CSPLOG(WARNING, APP) << "Couldn't load '" << test_sound << "': " << SDL_GetError(); - } else { - m_audioWave.spec.callback = fillerup; - - /* Initialize fillerup() variables */ - if (SDL_OpenAudio(&m_audioWave.spec, NULL) < 0) { - CSPLOG(ERROR, APP) << "Couldn't open audio: " << SDL_GetError(); - SDL_FreeWAV(m_audioWave.sound); - } - } - bool mute = g_Config.getBool("Testing", "Mute", false, true); - SDL_PauseAudio(mute); - /* Make sure SDL_Quit gets called when the program exits. */ atexit(SDL_Quit); return 0; } - -void fillerup(void * /*unused*/, Uint8 *stream, int len) { - Uint8 *waveptr; - int waveleft; - - /* Set up the pointers */ - waveptr = m_audioWave.sound + m_audioWave.soundpos; - waveleft = m_audioWave.soundlen - m_audioWave.soundpos; - - /* Go! */ - while ( waveleft <= len ) { - SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME); - stream += waveleft; - len -= waveleft; - waveptr = m_audioWave.sound; - waveleft = m_audioWave.soundlen; - m_audioWave.soundpos = 0; - } - SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME); - m_audioWave.soundpos += len; -} - Ref<Theater> CSPSim::getTheater() const { return m_Theater; } Modified: trunk/CSP/csp/cspsim/CSPSim.h =================================================================== --- trunk/CSP/csp/cspsim/CSPSim.h 2005-12-05 05:32:37 UTC (rev 1724) +++ trunk/CSP/csp/cspsim/CSPSim.h 2005-12-05 05:40:38 UTC (rev 1725) @@ -44,6 +44,12 @@ * */ +/** + * @namespace csp + * @brief Primary namespace for all internal code (csplib and cspsim). + */ + + #ifndef __CSPSIM_H__ #define __CSPSIM_H__ @@ -61,21 +67,19 @@ CSP_NAMESPACE class Atmosphere; -class DataManager; +class BaseScreen; class Client; -class InputEvent; -class PyShell; +class DataManager; class DynamicObject; +class EventMapIndex; +class GameScreen; +class InputEvent; +class LocalBattlefield; class TerrainObject; class Theater; -class LocalBattlefield; -class VirtualScene; class VirtualHID; -class BaseScreen; -class GameScreen; -class EventMapIndex; +class VirtualScene; -void fillerup(void *unused, unsigned char *stream, int len); /** The primary simulation engine for CSP. Also acts as a singleton to provide * direct access to shared simulation state. Do not abuse this access point; @@ -117,7 +121,6 @@ Atmosphere const * getAtmosphere() const { return m_Atmosphere.get(); } - protected: void initSim(); @@ -127,8 +130,8 @@ void updateObjects(double dt); void doStartupScript(); - private: + SDL_Surface *m_SDLScreen; SDL_Joystick* m_SDLJoystick; @@ -145,9 +148,7 @@ bool m_Finished; bool m_Clean; - /** - * The current simulation time/date - */ + // The current simulation time/date SimDate m_CurrentTime; SimTime m_FrameTime; SimTime m_FrameRate; @@ -158,16 +159,12 @@ void initTime(SimDate const &); void updateTime(); - /** - * The current input device interface - */ + // The current input device interface Ref<VirtualHID> m_Interface; Ref<EventMapIndex> m_InterfaceMaps; Ref<DynamicObject> m_ActiveObject; - /** - * The virtual battlefield - */ + // The virtual battlefield Ref<LocalBattlefield> m_Battlefield; Ref<VirtualScene> m_Scene; Ref<Client> m_NetworkClient; |