Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7283 in orxonox.OLD for trunk


Ignore:
Timestamp:
Apr 13, 2006, 7:15:37 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: thread for audio, and 'is' to 'b'

Location:
trunk/src/story_entities
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/story_entities/campaign.cc

    r7193 r7283  
    7979  PRINTF(2)("Starting Campaign nr. %i\n", this->getStoryID());
    8080
    81   this->isRunning = true;
     81  this->bRunning = true;
    8282  this->bReturnToMenu = false;
    8383  this->run();
     
    9090bool Campaign::pause()
    9191{
    92   this->isPaused = true;
     92  this->bPaused = true;
    9393}
    9494
     
    100100{
    101101  PRINTF(4)("Resuming the current Campaign\n");
    102   this->isPaused = false;
     102  this->bPaused = false;
    103103}
    104104
     
    113113    this->bReturnToMenu = true;
    114114  else
    115     this->isRunning = false;  // fast exit
     115    this->bRunning = false;  // fast exit
    116116  if( this->currentEntity != NULL)
    117117  {
     
    129129  int                storyID = WORLD_ID_0;
    130130
    131   for( this->currentEntity = this->campaignData->getFirstLevel(), this->isRunning = true;
    132        this->currentEntity != NULL && this->isRunning;
     131  for( this->currentEntity = this->campaignData->getFirstLevel(), this->bRunning = true;
     132       this->currentEntity != NULL && this->bRunning;
    133133       this->currentEntity = this->campaignData->getNextLevel())
    134134  {
  • trunk/src/story_entities/game_world.cc

    r7221 r7283  
    8989
    9090  this->dataXML = NULL;
     91
     92  this->audioThread = NULL;
    9193}
    9294
     
    100102{
    101103  PRINTF(4)("Deleted GameWorld\n");
     104
     105  if (this->audioThread != NULL)
     106    SDL_KillThread(this->audioThread);
    102107}
    103108
     
    131136}
    132137
     138int GameWorld::createAudioThread(void* gameWorld)
     139{
     140  GameWorld* gw = (GameWorld*)gameWorld;
     141  printf("STARTIG AUDIO THREAD\n");
     142  while (gw->bRunning)
     143  {
     144    if(gw->dataTank->music != NULL)
     145      gw->dataTank->music->playback();
     146    SDL_Delay(5);
     147  }
     148  printf("End the AudioThread\n");
     149}
    133150
    134151/**
     
    199216bool GameWorld::start()
    200217{
    201   this->isPaused = false;
    202   this->isRunning = true;
     218  this->bPaused = false;
     219  this->bRunning = true;
     220
     221  if (this->audioThread == NULL)
     222    this->audioThread = SDL_CreateThread(GameWorld::createAudioThread, (void*)this);
    203223
    204224  this->run();
     
    212232{
    213233  PRINTF(3)("GameWorld::stop() - got stop signal\n");
    214   this->isRunning = false;
     234  this->bRunning = false;
     235
     236//  SDL_KillThread(this->audioThread);
     237  this->audioThread = NULL;
    215238}
    216239
     
    221244bool GameWorld::pause()
    222245{
    223   this->isPaused = true;
     246  this->bPaused = true;
    224247}
    225248
     
    230253bool GameWorld::resume()
    231254{
    232   this->isPaused = false;
     255  this->bPaused = false;
    233256}
    234257
     
    243266void GameWorld::run()
    244267{
    245   /* start the music */
    246   if(this->dataTank->music != NULL)
    247     this->dataTank->music->playback();
    248 
    249268  PRINTF(3)("GameWorld::mainLoop() - Entering main loop\n");
    250269
     
    256275  this->lastFrame = SDL_GetTicks ();
    257276
    258   while( this->isRunning) /* @todo implement pause */
     277  while( this->bRunning) /* @todo implement pause */
    259278  {
    260279    /* process intput */
    261280    this->handleInput ();
    262     if( !this->isRunning)
     281    if( !this->bRunning)
    263282      break;
    264283
     
    326345  Uint32 currentFrame = SDL_GetTicks();
    327346
    328   if( !this->isPaused)
     347  if( !this->bPaused)
    329348  {
    330349    // CALCULATE FRAMERATE
  • trunk/src/story_entities/game_world.h

    r7131 r7283  
    1010#include "story_entity.h"
    1111#include "game_world_data.h"
     12
     13#include <SDL_thread.h>
    1214
    1315class Shell;
     
    5456    static void toggleBVVisibility();
    5557
    56 
     58    static int createAudioThread(void* GameWorld);
    5759
    5860
     
    7880
    7981  protected:
     82    SDL_Thread*         audioThread;
    8083    GameWorldData*      dataTank;                     //!< reference to the GameWorld Data Tank
    8184    TiXmlElement*       dataXML;                      //!< The XML-Element this World has been loaded with.
  • trunk/src/story_entities/movie_loader.cc

    r7221 r7283  
    7979  this->movie_player->start(0);
    8080
    81   this->isRunning = true;
     81  this->bRunning = true;
    8282  this->run();
    8383}
     
    8787  EventHandler::getInstance()->popState();
    8888
    89   this->isRunning = false;
     89  this->bRunning = false;
    9090}
    9191
     
    9898  this->lastFrame = SDL_GetTicks ();
    9999
    100   while( this->isRunning)
     100  while( this->bRunning)
    101101  {
    102102    EventHandler::getInstance()->process();
     
    146146
    147147  if (movie_player->getStatus() == STOP)
    148     this->isRunning = false;
     148    this->bRunning = false;
    149149
    150150  this->lastFrame = currentFrame;
  • trunk/src/story_entities/story_entity.cc

    r7221 r7283  
    3636  this->setClassID(CL_STORY_ENTITY, "StoryEntity");
    3737
    38   this->isInit = false;
    39   this->isPaused = false;
    40   this->isRunning = false;
     38  this->bInit = false;
     39  this->bPaused = false;
     40  this->bRunning = false;
    4141
    4242  this->loadFile = "";
  • trunk/src/story_entities/story_entity.h

    r7221 r7283  
    2424
    2525//! A class that represents something to play in orxonox. it is a container for worlds, movies, mission briefings, etc...
    26 class StoryEntity : virtual public BaseObject {
     26class StoryEntity : virtual public BaseObject
     27{
    2728
    28  public:
     29public:
    2930  StoryEntity ();
    3031  virtual ~StoryEntity ();
     
    8586  inline const std::string& getMenuScreenshoot() { return this->menuScreenshoot; }
    8687
    87   protected:
    88     bool          isInit;            //!< if the entity is initialized, this has to be true.
    89     bool          isRunning;         //!< is true if the entity is running
    90     bool          isPaused;          //!< is true if the entity is paused
     88protected:
     89  bool          bInit;             //!< if the entity is initialized, this has to be true.
     90  bool          bRunning;          //!< is true if the entity is running
     91  bool          bPaused;           //!< is true if the entity is paused
    9192
    9293
    93  private:
    94     int           storyID;          //!< this is the number of this entity, identifying it in a list/tree...
    95     int           nextStoryID;      //!< if this entity has finished, this entity shall be called
    96     std::string   loadFile;         //!< The file from which this world is loaded
     94private:
     95  int           storyID;          //!< this is the number of this entity, identifying it in a list/tree...
     96  int           nextStoryID;      //!< if this entity has finished, this entity shall be called
     97  std::string   loadFile;         //!< The file from which this world is loaded
    9798
    98     std::string   description;      //!< the description of the StoryEntity
    99     std::string   menuItemImage;    //!< the item image of the StoryEntity
    100     std::string   menuScreenshoot;  //!< the screenshoot of the StoryEntity
    101     bool          bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
     99  std::string   description;      //!< the description of the StoryEntity
     100  std::string   menuItemImage;    //!< the item image of the StoryEntity
     101  std::string   menuScreenshoot;  //!< the screenshoot of the StoryEntity
     102  bool          bMenuEntry;       //!< If true, this GameWorld apears in the SimpleMenu: SimpleMenu specific
    102103};
    103104
Note: See TracChangeset for help on using the changeset viewer.