dungeon_crawler

diff prototype/src/main.cc @ 55:4c427e28ca00

music playback bugfixing
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 19 Sep 2012 08:19:10 +0300
parents bcdea26c8f27
children f9b8bbebc9b3
line diff
     1.1 --- a/prototype/src/main.cc	Wed Sep 19 05:22:43 2012 +0300
     1.2 +++ b/prototype/src/main.cc	Wed Sep 19 08:19:10 2012 +0300
     1.3 @@ -16,6 +16,7 @@
     1.4  #include "timer.h"
     1.5  #include "audio/audio.h"
     1.6  #include "audio/source.h"
     1.7 +#include "audio/ovstream.h"
     1.8  
     1.9  bool init(int xsz, int ysz);
    1.10  void cleanup();
    1.11 @@ -45,6 +46,7 @@
    1.12  static bool show_con;
    1.13  
    1.14  static AudioSource *move_sound;
    1.15 +static OggVorbisStream *music;
    1.16  
    1.17  int main(int argc, char **argv)
    1.18  {
    1.19 @@ -104,6 +106,14 @@
    1.20  	if(cfg.sound) {
    1.21  		move_sound = new AudioSource;
    1.22  		move_sound->set_volume(0.4);
    1.23 +
    1.24 +		music = new OggVorbisStream;
    1.25 +		if(music->open(datafile_path("bgtrack.ogg"))) {
    1.26 +			music->play(PlayMode::loop);
    1.27 +		} else {
    1.28 +			delete music;
    1.29 +			music = 0;
    1.30 +		}
    1.31  	}
    1.32  
    1.33  	rend = new DeferredRenderer();
    1.34 @@ -151,6 +161,7 @@
    1.35  	cleanup_cmdcon();
    1.36  
    1.37  	if(cfg.sound) {
    1.38 +		delete music;
    1.39  		delete move_sound;
    1.40  		destroy_audio();
    1.41  	}