Back to index

supertuxkart  0.5+dfsg1
sound_plib.cpp
Go to the documentation of this file.
00001 //  $Id$
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 Patrick Ammann <pammann@aro.ch>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 //The next #if *needs* double parenthesis
00021 #if !(HAVE_OPENAL && HAVE_OGGVORBIS)
00022 
00023 #include <string>
00024 
00025 #include "sound_plib.hpp"
00026 #include "sound_manager.hpp"
00027 #include "loader.hpp"
00028 
00029 slScheduler* plib_scheduler= NULL;
00030 
00031 SFXImpl::SFXImpl(const char* filename)
00032 {
00033     std::string path = loader->getPath(filename);
00034     m_sample= new slSample(path.c_str(), plib_scheduler);
00035 }
00036 
00037 //-----------------------------------------------------------------------------
00038 SFXImpl::~SFXImpl()
00039 {
00040     delete m_sample;
00041 }
00042 
00043 //-----------------------------------------------------------------------------
00044 void SFXImpl::play()
00045 {
00046     plib_scheduler->playSample(m_sample, 1, SL_SAMPLE_MUTE, 2, NULL);
00047 }
00048 
00049 //=============================================================================
00050 void MusicPlib::update()
00051 {
00052     // Comment this next line out if the sound causes big glitches
00053     // on your IRIX machine!
00054     plib_scheduler->update();
00055 }
00056 
00057 //-----------------------------------------------------------------------------
00058 bool MusicPlib::load(const std::string& filename)
00059 {
00060     m_filename= loader->getPath(filename);
00061     return true;
00062 }
00063 
00064 //-----------------------------------------------------------------------------
00065 bool MusicPlib::playMusic()
00066 {
00067     plib_scheduler->stopMusic();
00068     plib_scheduler->loopMusic(m_filename.c_str());
00069     return true;
00070 }
00071 
00072 //-----------------------------------------------------------------------------
00073 bool MusicPlib::stopMusic()
00074 {
00075     plib_scheduler->stopMusic();
00076     return true;
00077 }
00078 
00079 //-----------------------------------------------------------------------------
00080 bool MusicPlib::pauseMusic()
00081 {
00082     plib_scheduler->stopMusic();
00083     return true;
00084 }
00085 
00086 //-----------------------------------------------------------------------------
00087 bool MusicPlib::resumeMusic()
00088 {
00089     plib_scheduler->loopMusic(m_filename.c_str());
00090     return true;
00091 }
00092 
00093 #endif //!(HAVE_OPENAL && HAVE_OGGVORBIS)
00094