From 09c5bd5d88a84352f2c648d2774895b2bdd1386e Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sun, 10 Aug 2003 20:09:58 +0000 Subject: [PATCH] Remove commented code and small changes in an attempt to get this to work again. Still no luck but at least the file is readable again. --- .../src/arch/Sound/RageSoundDriver_QT.cpp | 268 +----------------- 1 file changed, 11 insertions(+), 257 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_QT.cpp b/stepmania/src/arch/Sound/RageSoundDriver_QT.cpp index 1148d9b30f..cf39d462d5 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_QT.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_QT.cpp @@ -36,99 +36,12 @@ RageException::Throw(#func " failed with error: %d at %s:%d", err, __FILE__, __L typedef struct soundInfo { RageSound *snd; - //Movie movie; - //Track track; long stopPos; - //long lastPos; bool stopping; - //long totalMediaSamples; - //SoundDescriptionHandle sndDescHdl; - //short dataRefIndices[4]; soundInfo() { snd=NULL; stopPos=0; stopping=false; } - //static soundInfo **MakeSoundInfoHdl(); - //static void DisposeSoundInfoHdl(soundInfo **sHdl); - //void Reset(); void DisposeSampleReferences(Media media, short index); - //void GetData(); -} *soundInfoPtr, **soundInfoHdl; - -/*soundInfoHdl soundInfo::MakeSoundInfoHdl() -{ - soundInfoHdl sHdl = (soundInfoHdl)NewHandle(sizeof(soundInfo)); - OSStatus err = MemError(); - TEST_ERR(err, NewHandle); - HLock(Handle(sHdl)); - err = MemError(); - TEST_ERR(err, HLock); - soundInfoPtr s = *sHdl; - - s->movie = NewMovie(newMovieActive); - err = GetMoviesError(); - TEST_ERR(err, NewMovie); - SetMovieTimeScale(s->movie, freq); - err = GetMoviesError(); - TEST_ERR(err, SetMovieTimeScale); - - s->track = NewMovieTrack(s->movie, 0, 0, kFullVolume); - err = GetMoviesError(); - TEST_ERR(err, NewMovieTrack); - - s->sndDescHdl = (SoundDescriptionHandle)NewHandleClear(sizeof(SoundDescription)); - err = MemError(); - TEST_ERR(err, NewHandleClear); - HLock(Handle(s->sndDescHdl)); - err = MemError(); - TEST_ERR(err, HLock); - SoundDescriptionPtr sndDescPtr = *s->sndDescHdl; - sndDescPtr->descSize = sizeof(SoundDescription); - sndDescPtr->dataFormat = k16BitBigEndianFormat; - sndDescPtr->numChannels = numchannels; - sndDescPtr->sampleSize = samplesize * 8 / numchannels; - sndDescPtr->sampleRate = freq << 16; - HUnlock(Handle(s->sndDescHdl)); - err = MemError(); - TEST_ERR(err, HUnlock); - - bzero(s->dataRefIndices, 8); - s->Reset(); - HUnlock(Handle(sHdl)); - err = MemError(); - TEST_ERR(err, HUnlock); - return sHdl; -} - -void soundInfo::DisposeSoundInfoHdl(soundInfoHdl sHdl) -{ - HLock(Handle(sHdl)); - soundInfoPtr s = soundInfoPtr(*sHdl); - - s->Reset(); - DisposeHandle(Handle(s->sndDescHdl)); - DisposeMovieTrack(s->track); - DisposeMovie(s->movie); - HUnlock(Handle(sHdl)); - DisposeHandle(Handle(sHdl)); -}*/ - -/* Make sure that the Handle to this data is locked before calling this method. */ -/*void soundInfo::Reset() -{ - Media media = GetTrackMedia(track); - - if (media) - { - this->DisposeSampleReferences(media, 0); - this->DisposeSampleReferences(media, 1); - this->DisposeSampleReferences(media, 2); - DisposeTrackMedia(media); - } - //dataRefIndices[3] = 0; - stopPos = 0; - lastPos = 0; - //snd = NULL; - GoToBeginningOfMovie(movie); -}*/ +} *soundInfoPtr; static short dataRefIndices[4]; static SoundDescriptionHandle sndDescHdl; @@ -158,93 +71,6 @@ void DisposeSampleReferences(Media media, short index) dataRefIndices[index] = 0; } -/* Make sure that the Handle to this data is locked before calling this method. */ -/*inline void soundInfo::GetData() -{ - CHECKPOINT; - char buffer[buffersize]; - unsigned got = snd->GetPCM(buffer, buffersize, lastPos); - - if (got < buffersize) - { - stopPos = got / samplesize + lastPos; - if (got == 0) - return; - } - lastPos += samples; - - Handle sndHdl; - PtrToHand(buffer, &sndHdl, got); - OSErr err = MemError(); - TEST_ERR(err, PtrToHand); - Handle dataRef; - PtrToHand(&sndHdl, &dataRef, sizeof(Handle)); - err = MemError(); - TEST_ERR(err, PtrToHand); - Media media = GetTrackMedia(track); - bool insert; - - if (media) - { - short index; - err = AddMediaDataRef(media, &index, dataRef, HandleDataHandlerSubType); - TEST_ERR(err, AddMediaDataRef); - ASSERT(index); - dataRefIndices[dataRefIndices[3] % 3] = index; - insert = false; - } - else - { - media = NewTrackMedia(track, SoundMediaType, freq, dataRef, HandleDataHandlerSubType); - OSErr err = GetMoviesError(); - TEST_ERR(err, NewTrackMedia); - dataRefIndices[0] = 1; - insert = true; - } - CHECKPOINT; - BeginMediaEdits(media); - AddMediaSample(media, sndHdl, 0, got, 1, SampleDescriptionHandle(sndDescHdl), samples, 0, NULL); - EndMediaEdits(media); - CHECKPOINT; - if (insert) - InsertMediaIntoTrack(track, -1, lastPos - samples, got / samplesize, 0x00010000); - CHECKPOINT; - - if (++dataRefIndices[3] > 3) - { - SetMovieActiveSegment(movie, (dataRefIndices[3] - 2) * samples, twicesamples); - DisposeSampleReferences(media, dataRefIndices[3] % 3); - } - CHECKPOINT; -} - - -static void CallBack(QTCallBack cb, long refCon) -{ - LockMutex L(SOUNDMAN->lock); - CHECKPOINT; - soundInfoHdl sHdl = soundInfoHdl(refCon); - HLock(Handle(sHdl)); - soundInfoPtr s = *sHdl; - long timeToCall; - - s->GetData(); - if (!cb) - { - StartMovie(s->movie); - cb = NewCallBack(GetMovieTimeBase(s->movie), callBackAtTime); - timeToCall = halfsamples; - } - else - timeToCall = s->lastPos - halfsamples; - if (!s->stopPos) - CallMeWhen(cb, CallBack, long(sHdl), triggerTimeFwd, timeToCall, freq); - - HUnlock(Handle(sHdl)); -}*/ - -//static vector playingSounds; -//static queue freeSounds; static vector sounds; static long lastPos; static Movie movie; @@ -253,8 +79,6 @@ static Track track; static void CallBack(QTCallBack cb, long refCon) { #pragma unused(refCon) - while (!SOUNDMAN) - SDL_Delay(10); LockMutex L(SOUNDMAN->lock); static SoundMixBuffer mix; char buffer[buffersize]; @@ -286,8 +110,7 @@ static void CallBack(QTCallBack cb, long refCon) err = MemError(); TEST_ERR(err, PtrToHand); Media media = GetTrackMedia(track); - bool insert; - + if (media) { short index; @@ -295,23 +118,23 @@ static void CallBack(QTCallBack cb, long refCon) TEST_ERR(err, AddMediaDataRef); ASSERT(index); dataRefIndices[dataRefIndices[3] % 3] = index; - insert = false; } else { media = NewTrackMedia(track, SoundMediaType, freq, dataRef, HandleDataHandlerSubType); - OSErr err = GetMoviesError(); + err = GetMoviesError(); TEST_ERR(err, NewTrackMedia); dataRefIndices[0] = 1; - insert = true; } CHECKPOINT; + TimeValue tv; BeginMediaEdits(media); - AddMediaSample(media, sndHdl, 0, samples, 1, SampleDescriptionHandle(sndDescHdl), samples, 0, NULL); + AddMediaSample(media, sndHdl, 0, samples, 1, SampleDescriptionHandle(sndDescHdl), samples, 0, &tv); EndMediaEdits(media); + err = GetMoviesError(); + TEST_ERR(err, AddMediaSample); CHECKPOINT; - if (insert) - InsertMediaIntoTrack(track, -1, lastPos - samples, samples, 0x00010000); + InsertMediaIntoTrack(track, -1, tv, samples, 0x00010000); CHECKPOINT; if (++dataRefIndices[3] > 3) @@ -324,6 +147,8 @@ static void CallBack(QTCallBack cb, long refCon) long timeToCall; if (!cb) { + LOG->Trace("Start the movie"); + GoToBeginningOfMovie(movie); StartMovie(movie); err = GetMoviesError(); TEST_ERR(err, StartMovie); @@ -337,12 +162,6 @@ static void CallBack(QTCallBack cb, long refCon) RageSound_QT::RageSound_QT() { - /*playingSounds.reserve(initialSounds); - for (unsigned i=0; idescSize = sizeof(SoundDescription); sndDescPtr->dataFormat = k16BitBigEndianFormat; @@ -379,18 +198,6 @@ RageSound_QT::RageSound_QT() RageSound_QT::~RageSound_QT() { LockMutex L(SOUNDMAN->lock); - /*while (!playingSounds.empty()) - { - soundInfoHdl &sHdl = playingSounds.back(); - soundInfo::DisposeSoundInfoHdl(sHdl); - playingSounds.pop_back(); - } - while (!freeSounds.empty()) - { - soundInfoHdl &sHdl = freeSounds.front(); - soundInfo::DisposeSoundInfoHdl(sHdl); - freeSounds.pop(); - }*/ while (!sounds.empty()) { soundInfoPtr s = sounds.back(); @@ -404,17 +211,6 @@ void RageSound_QT::StartMixing(RageSound *snd) LockMutex L(SOUNDMAN->lock); CHECKPOINT; LOG->Trace("StartMixing()"); - /*soundInfoHdl sHdl; - if (freeSounds.empty()) - sHdl = soundInfo::MakeSoundInfoHdl(); - else - { - sHdl = freeSounds.front(); - freeSounds.pop(); - } - (*sHdl)->snd = snd; - playingSounds.push_back(sHdl); - CallBack(NULL, long(sHdl));*/ soundInfoPtr s = new soundInfo; s->snd = snd; sounds.push_back(s); @@ -426,23 +222,6 @@ void RageSound_QT::StopMixing(RageSound *snd) CHECKPOINT; LOG->Trace("StopMixing"); - /*for (vector::iterator iter=playingSounds.begin(); itersnd != snd) - continue; - HLock(Handle(sHdl)); - - soundInfoPtr s = *sHdl; - - StopMovie(s->movie); - s->Reset(); - playingSounds.erase(iter); - freeSounds.push(sHdl); - HUnlock(Handle(sHdl)); - return; - }*/ for (unsigned i=0; isnd != snd) @@ -458,21 +237,6 @@ void RageSound_QT::Update(float delta) { #pragma unused (delta) LockMutex L(SOUNDMAN->lock); - - /*vector snds = playingSounds; - for (vector::iterator iter=snds.begin(); itermovie)) - (*sHdl)->snd->StopPlaying(); - else - HUnlock(Handle(sHdl)); - CHECKPOINT; - }*/ vector snds = sounds; for (unsigned i=0; ilock); - - /*for (vector::iterator iter=playingSounds.begin(); itersnd == snd) - return GetMovieTime((*sHdl)->movie, NULL); - } - RageException::Throw("Can't get the position of a sound that isn't playing");*/ return GetMovieTime(movie, NULL); } float RageSound_QT::GetPlayLatency() const { return float(halfsamples / 2) / freq; - //return 0; }