Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7304 in orxonox.OLD for trunk/src/lib/sound/ogg_player.cc


Ignore:
Timestamp:
Apr 16, 2006, 8:27:32 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: moved the AudioThread completely to the OggPlayer. This cleans out the unnecesary overFULLNESS from game_world

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/sound/ogg_player.cc

    r7303 r7304  
    4040  this->buffers[0] = 0;
    4141  this->buffers[1] = 0;
     42  this->musicThread = NULL;
    4243
    4344  if (!fileName.empty())
     
    135136  return true;
    136137}
     138
     139
     140
     141int OggPlayer::createAudioThread(void* oggPlayer)
     142{
     143  if (oggPlayer == NULL)
     144    return -1;
     145  OggPlayer* ogg = (OggPlayer*)oggPlayer;
     146  PRINTF(4)("STARTIG AUDIO THREAD\n");
     147
     148  ogg->playback();
     149
     150  while (ogg->state & Playing)
     151  {
     152    ogg->update();
     153    SDL_Delay(1);
     154  }
     155  PRINTF(4)("End the AudioThread\n");
     156}
     157
    137158
    138159/**
     
    171192    this->state &= ! FileOpened;
    172193  }
    173 }
    174 
     194
     195  // Kill the Music Thread.
     196  if (this->musicThread != NULL)
     197  {
     198    assert (!(this->state & Playing));
     199    SDL_WaitThread(this->musicThread, NULL);
     200    this->musicThread = NULL;
     201  }
     202}
     203
     204
     205bool OggPlayer::play()
     206{
     207  if (this->musicThread == NULL)
     208    this->musicThread = SDL_CreateThread(OggPlayer::createAudioThread, (void*)this);
     209}
    175210
    176211/**
Note: See TracChangeset for help on using the changeset viewer.