void SoundPlayer::_player_stop() { if(!stop) { stop = paused = true; alureStopSource(sourceID, AL_FALSE); alureDestroyStream(stream, 1, buf); ALSources::release(sourceID); pthread_mutex_unlock(&player_mutex); } }
void stopMOD (int i) { if (! soundOK) return; alGetError(); if (modCache[i].playing) { if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) { debugOut("Failed to stop source: %s\n", alureGetErrorString()); } } }
void killSoundStuff () { if (! soundOK) return; SilenceIKillYou = true; for (int i = 0; i < MAX_SAMPLES; i ++) { if (soundCache[i].playing) { if (! alureStopSource(soundCache[i].playingOnSource, AL_TRUE)) { debugOut( "Failed to stop source: %s\n", alureGetErrorString()); } } if (soundCache[i].stream != NULL) { if (! alureDestroyStream(soundCache[i].stream, 0, NULL)) { debugOut("Failed to destroy stream: %s\n", alureGetErrorString()); } } } for (int i = 0; i < MAX_MODS; i ++) { if (modCache[i].playing) { if (! alureStopSource(modCache[i].playingOnSource, AL_TRUE)) { debugOut( "Failed to stop source: %s\n", alureGetErrorString()); } } if (modCache[i].stream != NULL) { if (! alureDestroyStream(modCache[i].stream, 0, NULL)) { debugOut("Failed to destroy stream: %s\n", alureGetErrorString()); } } } SilenceIKillYou = false; alureShutdownDevice(); }
void huntKillSound (int filenum) { if (! soundOK) return; // Clear OpenAL errors to make sure they don't block anything: alGetError(); int gotSlot = findInSoundCache (filenum); if (gotSlot == -1) return; SilenceIKillYou = true; if (soundCache[gotSlot].playing) { if (! alureStopSource(soundCache[gotSlot].playingOnSource, AL_TRUE)) { debugOut("Failed to stop source: %s\n", alureGetErrorString()); } } SilenceIKillYou = false; }
void freeSound (int a) { if (! soundOK) return; // Clear OpenAL errors to make sure they don't block anything: alGetError(); SilenceIKillYou = true; if (soundCache[a].playing) { if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) { debugOut( "Failed to stop source: %s\n", alureGetErrorString()); } } if (! alureDestroyStream(soundCache[a].stream, 0, NULL)) { debugOut("Failed to destroy stream: %s\n", alureGetErrorString()); } soundCache[a].stream = NULL; soundCache[a].fileLoaded = -1; SilenceIKillYou = false; }
int main () { if (!alureInitDevice(NULL, NULL)) { std::fprintf(stderr, "Failed to open OpenAL device: %s\n", alureGetErrorString()); return 1; } alGenSources(1, &src); if (alGetError() != AL_NO_ERROR) { std::fprintf(stderr, "Failed to create OpenAL source!\n"); alureShutdownDevice(); return 1; } // Seeting Blip Buffer synth.treble_eq( -18.0f ); synth.volume (0.80); synth.output (&blipbuf); // Init Blip Buffer with a buffer of 250ms (second paramter is time in ms) if ( blipbuf.set_sample_rate( SR, 1000 / 4 ) ) { std::fprintf(stderr, "Failed to create Blip Buffer! Our of Memory\n"); alureShutdownDevice(); return 1; } blipbuf.clock_rate( blipbuf.sample_rate() ); blipbuf.bass_freq(300); // Equalization like a TV speaker stream = alureCreateStreamFromCallback (StreamCB, nullptr, AL_FORMAT_MONO16, SR, SR/2, 0, nullptr); if(!stream) { std::fprintf(stderr, "Error creating stream! %s\n", alureGetErrorString()); alDeleteSources(1, &src); alureShutdownDevice(); return 1; } if (!alurePlaySourceStream(src, stream, 4, 0, eos_callback, NULL)) { std::fprintf(stderr, "Failed to play stream: %s\n", alureGetErrorString()); isdone = 1; } alureUpdateInterval(0.005f); // Should be a independint thread playing the stream while(!isdone) { freq -= 1; if (freq < 1) { freq = 600; } alureSleep(0.02f); } alureStopSource(src, AL_FALSE); alDeleteSources(1, &src); alureDestroyStream(stream, 0, NULL); alureShutdownDevice(); return 0; }
void Sound::Stop() { if(alureStopSource(src, AL_TRUE) == AL_FALSE) { std::cout << "Failed to stop source." << std::endl; } }
void StopMusic() { if (!currentMusicStream) return; alureStopSource(musicSource, AL_TRUE); }
int cacheSound (int f) { if (! soundOK) return -1; unsigned int chunkLength; int retval; bool loopy; loopy = cacheLoopySound; cacheLoopySound = false; setResourceForFatal (f); if (! soundOK) return 0; int a = findInSoundCache (f); if (a != -1) { if (soundCache[a].playing) { if (! alureStopSource(soundCache[a].playingOnSource, AL_TRUE)) { debugOut( "Failed to stop source: %s\n", alureGetErrorString()); } } if (! alureRewindStream (soundCache[a].stream)) { debugOut( "Failed to rewind stream: %s\n", alureGetErrorString()); } return a; } if (f == -2) return -1; a = findEmptySoundSlot (); freeSound (a); uint32_t length = openFileFromNum (f); if (! length) return -1; unsigned char * memImage; bool tryAgain = true; while (tryAgain) { memImage = (unsigned char*)loadEntireFileToMemory (bigDataFile, length); tryAgain = memImage == NULL; if (tryAgain) { if (! forceRemoveSound ()) { fatal (ERROR_SOUND_MEMORY_LOW); return -1; } } } chunkLength = 19200; // Small looping sounds need small chunklengths. if (loopy) { if (length < NUM_BUFS * chunkLength) { chunkLength = length / NUM_BUFS; } } else if (length < chunkLength) { chunkLength = length; } soundCache[a].stream = alureCreateStreamFromMemory(memImage, length, chunkLength, 0, NULL); delete memImage; if (soundCache[a].stream != NULL) { soundCache[a].fileLoaded = f; setResourceForFatal (-1); retval = a; } else { debugOut("Failed to create stream from sound: %s\n", alureGetErrorString()); warning (ERROR_SOUND_ODDNESS); soundCache[a].stream = NULL; soundCache[a].playing = false; soundCache[a].playingOnSource = 0; soundCache[a].fileLoaded = -1; soundCache[a].looping = false; retval = -1; } return retval; }