void CompilerContext::resetVisitedNodes(ASTNode const* _node) { stack<ASTNode const*> newStack; newStack.push(_node); std::swap(m_visitedNodes, newStack); updateSourceLocation(); }
int main (int argc, const char * argv[]) { MyLoopPlayer player; // convert to an OpenAL-friendly format and read into memory CheckError(loadLoopIntoBuffer(&player), "Couldn't load loop into buffer") ; // set up OpenAL buffer ALCdevice* alDevice = alcOpenDevice(NULL); CheckALError ("Couldn't open AL device"); // default device ALCcontext* alContext = alcCreateContext(alDevice, 0); CheckALError ("Couldn't open AL context"); alcMakeContextCurrent (alContext); CheckALError ("Couldn't make AL context current"); ALuint buffers[1]; alGenBuffers(1, buffers); CheckALError ("Couldn't generate buffers"); alBufferData(*buffers, AL_FORMAT_MONO16, player.sampleBuffer, player.bufferSizeBytes, player.dataFormat.mSampleRate); // AL copies the samples, so we can free them now free(player.sampleBuffer); // set up OpenAL source alGenSources(1, player.sources); CheckALError ("Couldn't generate sources"); alSourcei(player.sources[0], AL_LOOPING, AL_TRUE); CheckALError ("Couldn't set source looping property"); alSourcef(player.sources[0], AL_GAIN, AL_MAX_GAIN); CheckALError("Couldn't set source gain"); updateSourceLocation(player); CheckALError ("Couldn't set initial source position"); // connect buffer to source alSourcei(player.sources[0], AL_BUFFER, buffers[0]); CheckALError ("Couldn't connect buffer to source"); // set up listener alListener3f (AL_POSITION, 0.0, 0.0, 0.0); CheckALError("Couldn't set listner position"); // ALfloat listenerOrientation[6]; // 3 vectors: forward x,y,z components, then up x,y,z // listenerOrientation[2] = -1.0; // listenerOrientation[0] = listenerOrientation [1] = 0.0; // listenerOrientation[3] = listenerOrientation [4] = listenerOrientation[5] = 0.0; // alListenerfv (AL_ORIENTATION, listenerOrientation); // start playing // alSourcePlayv (1, player.sources); alSourcePlay(player.sources[0]); CheckALError ("Couldn't play"); // and wait printf("Playing...\n"); time_t startTime = time(NULL); do { // get next theta updateSourceLocation(player); CheckALError ("Couldn't set looping source position"); CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false); } while (difftime(time(NULL), startTime) < RUN_TIME); // cleanup: alSourceStop(player.sources[0]); alDeleteSources(1, player.sources); alDeleteBuffers(1, buffers); alcDestroyContext(alContext); alcCloseDevice(alDevice); printf ("Bottom of main\n"); }
int main (int argc, const char * argv[]) { MyStreamPlayer player; // prepare the ExtAudioFile for reading CheckError(setUpExtAudioFile(&player), "Couldn't open ExtAudioFile") ; // set up OpenAL buffers ALCdevice* alDevice = alcOpenDevice(NULL); CheckALError ("Couldn't open AL device"); // default device ALCcontext* alContext = alcCreateContext(alDevice, 0); CheckALError ("Couldn't open AL context"); alcMakeContextCurrent (alContext); CheckALError ("Couldn't make AL context current"); ALuint buffers[BUFFER_COUNT]; alGenBuffers(BUFFER_COUNT, buffers); CheckALError ("Couldn't generate buffers"); for (int i=0; i<BUFFER_COUNT; i++) { fillALBuffer(&player, buffers[i]); } // set up streaming source alGenSources(1, player.sources); CheckALError ("Couldn't generate sources"); alSourcef(player.sources[0], AL_GAIN, AL_MAX_GAIN); CheckALError("Couldn't set source gain"); updateSourceLocation(player); CheckALError ("Couldn't set initial source position"); // queue up the buffers on the source alSourceQueueBuffers(player.sources[0], BUFFER_COUNT, buffers); CheckALError("Couldn't queue buffers on source"); // set up listener alListener3f (AL_POSITION, 0.0, 0.0, 0.0); CheckALError("Couldn't set listner position"); // start playing alSourcePlayv (1, player.sources); CheckALError ("Couldn't play"); // and wait printf("Playing...\n"); time_t startTime = time(NULL); do { // get next theta updateSourceLocation(player); CheckALError ("Couldn't set source position"); // refill buffers if needed refillALBuffers (&player); CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false); } while (difftime(time(NULL), startTime) < RUN_TIME); // cleanup: alSourceStop(player.sources[0]); alDeleteSources(1, player.sources); alDeleteBuffers(BUFFER_COUNT, buffers); alcDestroyContext(alContext); alcCloseDevice(alDevice); printf ("Bottom of main\n"); }