void OpenALSoundSource::stop() { alSourceRewindv(1, &source); // Stops the source alSourcei(source, AL_BUFFER, AL_NONE); try { SoundManager::check_al_error("Problem stopping audio source: "); } catch(const std::exception& e) { // Internal OpenAL error. Don't you crash on me, baby! log_warning << e.what() << std::endl; } }
void lime_al_source_rewindv (int n, value sources) { if (val_is_null (sources) == false) { int size = val_array_size (sources); ALuint* data = new ALuint[size]; for (int i = 0; i < size; ++i) { data[i] = (ALuint)val_int( val_array_i (sources, i) ); } alSourceRewindv (n, data); delete[] data; } }
// 缓冲区复位以便于从头播放 ///////////////////////////////////////////////////////////////////////////////// void OALMusicBuffer::DoReset() { ALint queued_; alGetSourcei(source_, AL_BUFFERS_QUEUED, &queued_); if (queued_ > 0) { std::vector<ALuint> cur_queue(queued_); alSourceUnqueueBuffers(source_, queued_, &cur_queue[0]); } ALenum const format(Convert(format_)); std::vector<uint8_t> data(READSIZE); dataSource_->Reset(); ALsizei non_empty_buf = 0; // 每个缓冲区中装1 / PreSecond秒的数据 for (auto const & buf : bufferQueue_) { data.resize(dataSource_->Read(&data[0], data.size())); if (data.empty()) { break; } else { ++ non_empty_buf; alBufferData(buf, format, &data[0], static_cast<ALuint>(data.size()), static_cast<ALuint>(freq_)); } } alSourceQueueBuffers(source_, non_empty_buf, &bufferQueue_[0]); alSourceRewindv(1, &source_); }
ALvoid CDECL wine_alSourceRewindv(ALsizei ns, const ALuint *sids) { alSourceRewindv(ns, sids); }
static PyObject* _sources_action (PyObject *self, PyObject *args, SourcesAction action) { unsigned int source; if (!CONTEXT_IS_CURRENT (((PySources*)self)->context)) { PyErr_SetString (PyExc_PyGameError, "source context is not current"); return NULL; } if (PySequence_Check (args)) { ALuint *sources; Py_ssize_t i; Py_ssize_t len = PySequence_Size (args); if (len > ((PySources*)self)->count) { PyErr_SetString (PyExc_ValueError, "sequence size exceeds the available sources"); return NULL; } sources = PyMem_New (ALuint, (ALsizei) len); if (!sources) return NULL; for (i = 0; i < len; i++) { if (!UintFromSeqIndex (args, i, &source)) { PyMem_Free (sources); return NULL; } sources[i] = source; } CLEAR_ALERROR_STATE (); switch (action) { case PLAY: alSourcePlayv ((ALsizei) len, sources); break; case PAUSE: alSourcePausev ((ALsizei) len, sources); break; case STOP: alSourceStopv ((ALsizei) len, sources); break; case REWIND: alSourceRewindv ((ALsizei) len, sources); break; default: break; } PyMem_Free (sources); if (SetALErrorException (alGetError (), 0)) return NULL; Py_RETURN_NONE; } else if (UintFromObj (args, &source)) { CLEAR_ALERROR_STATE (); switch (action) { case PLAY: alSourcePlay ((ALuint)source); break; case PAUSE: alSourcePause ((ALuint)source); break; case STOP: alSourceStop ((ALuint)source); break; case REWIND: alSourceRewind ((ALuint)source); break; } if (SetALErrorException (alGetError (), 0)) return NULL; Py_RETURN_NONE; } PyErr_SetString (PyExc_TypeError, "argument must be a sequence or positive integer"); return NULL; }
/** * \brief stop playing and empty buffers (for seeking/pause) */ static void reset(void) { alSourceRewindv(ao_data.channels, sources); unqueue_buffers(); }
JNIEXPORT void JNICALL Java_org_lwjgl_openal_AL10_nalSourceRewindv(JNIEnv *__env, jclass clazz, jint n, jlong sourcesAddress, jlong __functionAddress) { const ALuint *sources = (const ALuint *)(intptr_t)sourcesAddress; alSourceRewindvPROC alSourceRewindv = (alSourceRewindvPROC)(intptr_t)__functionAddress; UNUSED_PARAMS(__env, clazz) alSourceRewindv(n, sources); }
//***************************************************************************** // alSourceRewindv //***************************************************************************** // ALAPI ALvoid ALAPIENTRY alSourceRewindv(ALsizei n, const ALuint* sourceNames) { AL_VOID_FXN(alSourceRewindv(n, sourceNames)); }
void OALSoundBuffer::DoReset() { alSourceRewindv(static_cast<ALsizei>(sources_.size()), sources_.data()); }