[Gcblue-commits] gcb_wx/src/common tcOggStreamer.cpp,1.14,1.15
Status: Alpha
Brought to you by:
ddcforge
|
From: Dewitt C. <ddc...@us...> - 2005-03-15 00:36:44
|
Update of /cvsroot/gcblue/gcb_wx/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2966/src/common Modified Files: tcOggStreamer.cpp Log Message: Index: tcOggStreamer.cpp =================================================================== RCS file: /cvsroot/gcblue/gcb_wx/src/common/tcOggStreamer.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tcOggStreamer.cpp 24 Feb 2005 22:19:15 -0000 1.14 --- tcOggStreamer.cpp 15 Mar 2005 00:36:32 -0000 1.15 *************** *** 36,57 **** * oggfile to open. */ ! void tcOggStreamer::Open(std::string path) { ! return; ! if (source.valid()) ! { ! stream.get()->unref(); ! } ! else ! { ! source = new openalpp::Source; ! source->setAmbient(); ! source->setGain(volume); ! } ! ! stream = new openalpp::FileStream(path); ! source->setSound(stream.get()); ! source->play(); } --- 36,44 ---- * oggfile to open. */ ! void tcOggStreamer::Open(const std::string& path) { ! Queue(path); ! Stop(); } *************** *** 76,94 **** { volume = vol; ! if (source.valid()) ! { ! source->setGain(volume); ! } } /** ! * Stop playing and clear/unload ogg file. */ void tcOggStreamer::Stop() { ! if (source.valid()) ! { ! source->stop(); ! } } --- 63,80 ---- { volume = vol; ! ! wxASSERT(source.valid()); ! ! source->setGain(volume); } /** ! * */ void tcOggStreamer::Stop() { ! wxASSERT(source.valid()); ! ! source->stop(); } *************** *** 101,145 **** /** ! * Loads and queues all buffers if not playing. ! * This needs to be called at least once to start ! * the music. ! * Also will unpause. */ ! bool tcOggStreamer::Play() { ! if (!source.valid()) return false; ! paused = false; ! ! ! ! if (IsPlaying()) return true; ! if (IsStopped()) { ! } - - return IsPlaying(); } ! void tcOggStreamer::Queue(std::string path) { ! if ( (!source.valid()) || (!IsPlaying())) ! { ! Open(path); ! Play(); ! } ! else { ! queuedSong = path; } } bool tcOggStreamer::IsPaused() { return (source->getState() == openalpp::Paused); } --- 87,125 ---- /** ! * */ ! void tcOggStreamer::Play() { ! wxASSERT(source.valid()); ! paused = false; ! if (!IsPlaying()) { ! source->play(); } } ! void tcOggStreamer::Queue(const std::string& path) { ! wxASSERT(source.valid()); ! ! #ifdef _DEBUG ! if (queuedSong.size() > 0) { ! fprintf(stderr, "Warning - tcOggStreamer::Queue - Replacing " ! "previously queued audio file (%s)\n", queuedSong.c_str()); } + #endif + queuedSong = path; } bool tcOggStreamer::IsPaused() { + wxASSERT(source.valid()); + return (source->getState() == openalpp::Paused); } *************** *** 148,152 **** bool tcOggStreamer::IsPlaying() { ! if (!source.valid()) return false; return (source->getState() == openalpp::Playing); --- 128,132 ---- bool tcOggStreamer::IsPlaying() { ! wxASSERT(source.valid()); return (source->getState() == openalpp::Playing); *************** *** 155,168 **** bool tcOggStreamer::IsStopped() { return (source->getState() == openalpp::Stopped); } tcOggStreamer::tcOggStreamer() : volume(0.2f), queuedSong(""), ! paused(false) { } --- 135,177 ---- bool tcOggStreamer::IsStopped() { + wxASSERT(source.valid()); + return (source->getState() == openalpp::Stopped); } + void tcOggStreamer::Update() + { + if (queuedSong.size() == 0) return; + openalpp::SourceState sourceState = source->getState(); + + if (sourceState == openalpp::Playing) + { + initializingStream = false; + } + + if (initializingStream) return; + + if ((sourceState == openalpp::Stopped) || + (sourceState == openalpp::Initial)) + { + stream = new openalpp::FileStream(queuedSong); + source->setSound(stream.get()); // crashes this way + //source->setSound(new openalpp::FileStream(queuedSong)); // big memory leaks this way + source->play(); + queuedSong = ""; + initializingStream = true; + } + } tcOggStreamer::tcOggStreamer() : volume(0.2f), queuedSong(""), ! paused(false), ! initializingStream(false) { + source = new openalpp::Source; + source->setAmbient(); + source->setGain(volume); } *************** *** 173,176 **** --- 182,187 ---- source->stop(); } + //wxUSleep(500); + // wxMilliSleep(500); // 2.5 and above } |