Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2815 in orxonox.OLD for orxonox/branches/sound/src/sound_control.cc


Ignore:
Timestamp:
Nov 11, 2004, 6:16:00 PM (20 years ago)
Author:
simon
Message:

branches/sound: made SoundControl singleton. Must be built via getObject()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/sound/src/sound_control.cc

    r2793 r2815  
    2424    \brief standard constructor
    2525   
    26     This constructor builds a SoundControl Object, which waits for callers
    27     calling its functions to output sound. All sound output is handles by this 
    28     object, which must only be constructed once.
     26    This constructor builds a SoundControl Object, which waits for callers.
     27    All sound output is handled by this singleton object.
    2928*/
    3029SoundControl::SoundControl () {
     
    4039    exit(1);
    4140  }
    42 
     41 
    4342  if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){
    4443    printf("Mix_OpenAudio: \n");
    4544    exit(1);
    4645  }
    47 
    48   postConstruction();
    49 }
    50 
    51 SoundControl::SoundControl (int audio_rate audiorate, Uint16 audio_format audioformat, int audio_channels audiochannels, int audio_buffers audiobuffers) {
    52  
    53   //setup parameters
    54   int audio_rate = audiorate, audio_channels = audiochannels, audio_buffers = audiobuffers, bits = 0;
    55   Uint16 audio_format = audioformat;
    56   Mix_Music* music = NULL;
    57  
    58   //initializing sound and calling Mix_OpenAudio
    59   if(SDL_Init(SDL_INIT_AUDIO)<0){
    60     printf("SDL_Init: \n");
    61     exit(1);
    62   }
    63 
    64   if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers)){
    65     printf("Mix_OpenAudio: \n");
    66     exit(1);
    67   }
    68 
    69   postConstruction();
    70 }
    71 
    72 
    73 /**
    74     \brief standard destructor
     46 
     47  initialise();
     48}
     49
     50
     51/**
     52    \brief Destructor for the singleton instance
    7553*/
    7654SoundControl::~SoundControl () {
    77   SoundControl* SoundControl::singleton = NULL;
    78 }
    79 
    80 SoundControl* SoundControl::singleton = NULL;
     55  instance = NULL;
     56}
     57
     58/**
     59   \brief Returns a reference to the singleton
     60*/
     61SoundControl* SoundControl::getObject(){
     62  static SoundControl instance;
     63  return &instance;
     64}
    8165
    8266
     
    8468    \brief Is called by SoundControl object to initiate all values
    8569*/
    86 void SoundControl::postConstruction () {
     70void SoundControl::initialise() {
    8771 
    8872  // Print some info
     
    9983
    10084/**
    101     \brief Sets the number of output Channels
     85    \brief Sets the number of output Channels (should not be used)
    10286*/
    10387void SoundControl::setNumberOfChannels (int number_of_channels) {
     
    220204    break;
    221205  case 4:
    222     music = Mix_LoadMUS("luke_grey_and aquarius_orxonox.ogg");
     206    music = Mix_LoadMUS("luke_grey_and_aquarius_orxonox.ogg");
    223207    break;
    224208  case 5:
    225209    music = Mix_LoadMUS("nomenes_orxonox.ogg");
    226210    break;
     211  case 6:
     212    music = Mix_LoadMUS("nomenes_funkadudu.ogg");
     213    break;
    227214  }
    228215}
Note: See TracChangeset for help on using the changeset viewer.