00001 00005 /* Copyright, 2000-2004 Nevrax Ltd. 00006 * 00007 * This file is part of NEVRAX NEL. 00008 * NEVRAX NEL is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2, or (at your option) 00011 * any later version. 00012 00013 * NEVRAX NEL is distributed in the hope that it will be useful, but 00014 * WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 00018 * You should have received a copy of the GNU General Public License 00019 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00021 * MA 02111-1307, USA. 00022 */ 00023 00024 #include "stdsound.h" 00025 00026 #include "music_source.h" 00027 #include "music_sound.h" 00028 #include "audio_mixer_user.h" 00029 #include "music_sound_manager.h" 00030 00031 00032 namespace NLSOUND { 00033 00034 00035 // *************************************************************************** 00036 CMusicSource::CMusicSource(CMusicSound *musicSound, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster) 00037 : CSourceCommon(musicSound, spawn, cb, cbUserParam, cluster) 00038 { 00039 _MusicSound= musicSound; 00040 } 00041 00042 // *************************************************************************** 00043 CMusicSource::~CMusicSource() 00044 { 00045 if(isPlaying()) 00046 stop(); 00047 00048 // avoid any bug, ensure the source is removed 00049 CAudioMixerUser::instance()->getBackgroundMusicManager()->removeMusicSourcePlaying(this); 00050 } 00051 00052 // *************************************************************************** 00053 TSoundId CMusicSource::getSound() 00054 { 00055 return _MusicSound; 00056 } 00057 00058 // *************************************************************************** 00059 void CMusicSource::play() 00060 { 00061 // if already playing, no-op (don't restart) 00062 if(isPlaying()) 00063 return; 00064 00065 // append and play common 00066 CAudioMixerUser::instance()->getBackgroundMusicManager()->addMusicSourcePlaying(this); 00067 CSourceCommon::play(); 00068 } 00069 00070 // *************************************************************************** 00071 void CMusicSource::stop() 00072 { 00073 // if already non-playing, no-op (don't restop) 00074 if(!isPlaying()) 00075 return; 00076 00077 // remove and stop common 00078 CAudioMixerUser::instance()->getBackgroundMusicManager()->removeMusicSourcePlaying(this); 00079 CSourceCommon::stop(); 00080 } 00081 00082 00083 } // NLSOUND
1.6.1