コード例 #1
0
ファイル: Source.cpp プロジェクト: AntonioModer/LoveMore
void Source::rewindAtomic()
{
	if (valid && type == TYPE_STATIC)
	{
		alSourceRewind(source);
		if (!paused)
			alSourcePlay(source);
	}
	else if (valid && type == TYPE_STREAM)
	{
		bool waspaused = paused;
		decoder->rewind();
		// Because we still have old data
		// from before the seek in the buffers
		// let's empty them.
		stopAtomic();
		playAtomic();
		if (waspaused)
			pauseAtomic();
		offsetSamples = 0;
		offsetSeconds = 0;
	}
	else if (type == TYPE_STREAM)
	{
		decoder->rewind();
		offsetSamples = 0;
		offsetSeconds = 0;
	}
}
コード例 #2
0
	/*
	==================
	Sound::Rewind
	==================
	*/
	bool Sound::Rewind() {
		alSourceStop(source);
	
		if (pbMethod == PLAYBACK_STREAM) {
			if (ov_pcm_seek(oggStream, 0) < 0) {
				return false;
			}
		} else {
			bytePos = 0;
		}

		alSourceUnqueueBuffers(source, 2, buffers);

		if (!FillBuffer(buffers[0])) {
			return false;
		}

		if (!FillBuffer(buffers[1])) {
			return false;
		}

		alSourceQueueBuffers(source, 2, buffers);

		alSourceRewind(source);

		return true;
	}
コード例 #3
0
ファイル: LcxSndAL.cpp プロジェクト: GALICSOFT/glc220_src
INT CLcxSndAL::Reset()
{
	m_state = LCX_AV_STOP;
	alSourceRewind(m_uiSource);

	return LC_OK;
}
コード例 #4
0
void DS_SFX_Stop(sfxbuffer_t* buf)
{
    if(!buf || !buf->sample) return;

    alSourceRewind(SRC(buf));
    buf->flags &= ~SFXBF_PLAYING;
}
コード例 #5
0
ファイル: staticsource.c プロジェクト: AntonioModer/motor
void audio_StaticSource_rewind(audio_StaticSource *source) {
  alSourceRewind(source->common.source);

  if(source->common.state == audio_SourceState_playing) {
    audio_SourceCommon_play(&source->common);
  }
}
コード例 #6
0
bool AUD_OpenALDevice::AUD_OpenALHandle::seek(float position)
{
	if(!m_status)
		return false;

	m_device->lock();

	if(m_isBuffered)
		alSourcef(m_source, AL_SEC_OFFSET, position);
	else
	{
		m_reader->seek((int)(position * m_reader->getSpecs().rate));
		m_eos = false;

		ALint info;

		alGetSourcei(m_source, AL_SOURCE_STATE, &info);

		if(info != AL_PLAYING)
		{
			if(info == AL_PAUSED)
				alSourceStop(m_source);

			alSourcei(m_source, AL_BUFFER, 0);
			m_current = 0;

			ALenum err;
			if((err = alGetError()) == AL_NO_ERROR)
			{
				int length;
				AUD_DeviceSpecs specs = m_device->m_specs;
				specs.specs = m_reader->getSpecs();
				m_device->m_buffer.assureSize(m_device->m_buffersize * AUD_DEVICE_SAMPLE_SIZE(specs));

				for(int i = 0; i < CYCLE_BUFFERS; i++)
				{
					length = m_device->m_buffersize;
					m_reader->read(length, m_eos, m_device->m_buffer.getBuffer());
					alBufferData(m_buffers[i], m_format, m_device->m_buffer.getBuffer(),
								 length * AUD_DEVICE_SAMPLE_SIZE(specs), specs.rate);

					if(alGetError() != AL_NO_ERROR)
						break;
				}

				if(m_loopcount != 0)
					m_eos = false;

				alSourceQueueBuffers(m_source, CYCLE_BUFFERS, m_buffers);
			}

			alSourceRewind(m_source);
		}
	}

	m_device->unlock();

	return true;
}
コード例 #7
0
ファイル: EdenSound.c プロジェクト: AadityaDev/artoolkit5
void EdenSoundRewind(EdenSound_t *sound)
{
    if (!sound) return;
    
#ifdef EDEN_HAVE_OPENAL
    alSourceRewind(sound->uiSource);
#endif // EDEN_HAVE_OPENAL
}
コード例 #8
0
ファイル: AirAudioALSound.cpp プロジェクト: ingeyu/airengine
			void ALSound::RePlay(){
				alSourceRewind(m_uiSource);
	
				//大于9999表面是无限播放
				if(m_Info.iNumRepeat	>	999)
					return;
				//播放一次就减少次数  当这个数值小于0  则会被摧毁
				m_Info.iNumRepeat--;
			}
コード例 #9
0
ファイル: alSource.c プロジェクト: Aye1/RVProject
ALAPI ALvoid ALAPIENTRY alSourceRewindv (ALsizei n, ALuint *ID)
{
    if (n > 0)
    {
        while (n--)
        {
            alSourceRewind(ID[n]);
        }
    }
}
コード例 #10
0
ファイル: al_audio.cpp プロジェクト: take-cheeze/EasyRPG
void Audio::BGS_Play(std::string const& file, int volume, int pitch)
{
	BGS_Stop();

	alSourceRewind(*bgsSource_);
	alSourcei(*bgsSource_, AL_BUFFER, getSound(file));
	alSourcef(*bgsSource_, AL_GAIN, volume * 0.01f);
	alSourcei(*bgsSource_, AL_PITCH, pitch * 0.01f);
	alSourcei(*bgsSource_, AL_LOOPING, AL_TRUE);
	alSourcePlay(*bgsSource_);
}
コード例 #11
0
ファイル: AudioManager.cpp プロジェクト: kcat/OpenTESArena
	void stop()
	{
		if (mThread.get_id() != std::thread::id())
		{
			mQuit.store(true);
			mThread.join();
		}

		alSourceRewind(mSource);
		alSourcei(mSource, AL_BUFFER, 0);
		mBufferIdx = 0;
	}
コード例 #12
0
ファイル: soundemitter.cpp プロジェクト: fifengine/fifengine
	void SoundEmitter::rewind() {
		m_internData.playTimestamp = 0;
		m_samplesOffset = 0;
		if (!isActive() || !m_soundClip) {
			return;
		}
		if (m_soundClip->isStream()) {
			setCursor(SD_BYTE_POS, 0);
		} else {
			alSourceRewind(m_source);
		}
	}
コード例 #13
0
void AudioDescriptor::Rewind()
{
    if(_source == NULL) {
        IF_PRINT_WARNING(AUDIO_DEBUG) << "did not have access to valid AudioSource" << std::endl;
        return;
    }

    alSourceRewind(_source->source);
    if(AudioManager->CheckALError()) {
        IF_PRINT_WARNING(AUDIO_DEBUG) << "rewinding the source failed: " << AudioManager->CreateALErrorString() << std::endl;
    }
}
コード例 #14
0
ファイル: bind.cpp プロジェクト: Qard/jsgame
Handle<Value> ALSourceRewindCallback(const Arguments& args) {
	//if less that nbr of formal parameters then do nothing
	if (args.Length() < 1)
		return v8::Undefined();
	
	//get arguments
	int arg0 = args[0]->IntegerValue();

	//make call
	alSourceRewind((ALuint)arg0);
	
	return v8::Undefined();
}
コード例 #15
0
ファイル: audio.cpp プロジェクト: pakhandibaba/qTox
    void run() override final
    {
        alSourceRewind(mSource);
        alSourcePlay(mSource);

        QMutexLocker locker(&playLock);
        ALint state = AL_PLAYING;
        while (state == AL_PLAYING) {
            alGetSourcei(mSource, AL_SOURCE_STATE, &state);
            waitPlaying.wait(&playLock, 2000);
        }

        alSourceStop(mSource);
        alDeleteBuffers(1, &mBuffer);
    }
コード例 #16
0
ファイル: ltaudio.cpp プロジェクト: JakobssonAndre/lotech
 void update_state() {
     if (was_stop || was_rewind) {
         alSourceRewind(source_id);
     }
     if (new_state != curr_state || (new_state == AL_PLAYING && was_rewind)) {
         switch (new_state) {
             case AL_PLAYING: alSourcePlay(source_id); break;
             case AL_PAUSED: alSourcePause(source_id); break;
             case AL_STOPPED: alSourceStop(source_id); break;
             default: ltAbort();
         }
         check_for_errors
         curr_state = new_state;
     }
     was_stop = false;
     was_rewind = false;
 }
コード例 #17
0
ファイル: SoundAL.cpp プロジェクト: truonglvx/ouzel
        bool SoundAL::reset()
        {
            if (!Sound::reset())
            {
                return false;
            }

            alSourceRewind(sourceId);

            if (AudioAL::checkOpenALError())
            {
                log("Failed to rewind OpenAL source");
                return false;
            }

            return true;
        }
コード例 #18
0
static void
gst_openal_sink_reset (GstAudioSink * audiosink)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALCcontext *old;

  GST_OPENAL_SINK_LOCK (sink);
  old = pushContext (sink->default_context);

  sink->write_reset = AL_TRUE;
  alSourceStop (sink->default_source);
  alSourceRewind (sink->default_source);
  alSourcei (sink->default_source, AL_BUFFER, 0);
  checkALError ();

  popContext (old, sink->default_context);
  GST_OPENAL_SINK_UNLOCK (sink);
}
コード例 #19
0
static void
gst_openal_sink_reset (GstAudioSink * asink)
{
    GstOpenALSink *openal = GST_OPENAL_SINK (asink);
    ALCcontext *old;

    GST_OPENAL_SINK_LOCK (openal);
    old = pushContext (openal->context);

    openal->write_reset = AL_TRUE;
    alSourceStop (openal->sID);
    alSourceRewind (openal->sID);
    alSourcei (openal->sID, AL_BUFFER, 0);
    checkALError ();

    popContext (old, openal->context);
    GST_OPENAL_SINK_UNLOCK (openal);
}
コード例 #20
0
ファイル: OgreOggStaticSound.cpp プロジェクト: Dima-Meln/ORSE
/*/////////////////////////////////////////////////////////////////*/
void OgreOggStaticSound::_stopImpl() {
    if(mSource == AL_NONE || isStopped()) return;

    alSourceStop(mSource);
    alSourceRewind(mSource);
    mPlay = false;
    mPreviousOffset = 0;

    // Notify listener
    if(mSoundListener) mSoundListener->soundStopped(this);

    // Mark for destruction
    if(mTemporary) {
        OgreOggSoundManager::getSingletonPtr()->_destroyTemporarySound(this);
    }
    // Give up source immediately if specfied
    else if(mGiveUpSource)
        OgreOggSoundManager::getSingleton()._releaseSoundSource(this);
}
コード例 #21
0
ファイル: AudioManager.cpp プロジェクト: kcat/OpenTESArena
	~OpenALStream()
	{
		if (mThread.get_id() != std::thread::id())
		{
			/* Tell the thread to quit and wait for it to stop. */
			mQuit.store(true);
			mThread.join();
		}
		if (mSource)
		{
			/* Stop the source, remove the buffers, then put it back so it can
			 * be used again.
			 */
			alSourceRewind(mSource);
			alSourcei(mSource, AL_BUFFER, 0);
			mManager->mFreeSources.push_front(mSource);
		}
		/* Delete the buffers used for the queue. */
		alDeleteBuffers(static_cast<ALsizei>(mBuffers.size()), mBuffers.data());
	}
コード例 #22
0
ファイル: AudioManager.cpp プロジェクト: kcat/OpenTESArena
	void play()
	{
		/* If the source is already playing (thread exists and isn't stopped),
		 * don't do anything.
		 */
		if (mThread.get_id() != std::thread::id())
		{
			if (!mQuit.load())
				return;
			mThread.join();
		}

		/* Reset the source and clear any buffers that may be on it. */
		alSourceRewind(mSource);
		alSourcei(mSource, AL_BUFFER, 0);
		mBufferIdx = 0;
		mQuit.store(false);

		/* Start the background thread processing. */
		mThread = std::thread(std::mem_fn(&OpenALStream::backgroundProc), this);
	}
コード例 #23
0
ファイル: Sound.cpp プロジェクト: williamallas/TIMEngine2
bool Sound::attach(Source * source) {
    
    alSourceRewind(source->binding->handle);

    // Buffered sound can always be attached
    if (!sampler) {
        alSourcei(source->binding->handle, AL_BUFFER, handle);
        return true;
    }
    else
        alSourcei(source->binding->handle, AL_BUFFER, 0);
    
    // Streamed sound can only be attached to one source
    if (this->source)
        return false;
    
    // Attach source and queue buffers
    this->source = source;
    sampler->rewind();
    queue();
    return true;
}
コード例 #24
0
void SimpleAudioEngine::rewindBackgroundMusic()
{
    // If there is no source, then there is nothing that can be rewinded
    if (s_backgroundSource == AL_NONE)
        return;

    // Rewind and prevent the last state the source had
    ALint state;
    alGetSourcei(s_backgroundSource, AL_SOURCE_STATE, &state);
    alSourceRewind(s_backgroundSource);

    if (state == AL_PLAYING)
    {
        alSourcePlay(s_backgroundSource);
    }
    else if (state == AL_PAUSED)
    {
        alSourcePlay(s_backgroundSource);
        alSourcePause(s_backgroundSource);
    }
    checkALError("rewindBackgroundMusic:alSourceRewind");
}
コード例 #25
0
ファイル: soundsystem_openal.cpp プロジェクト: brobits/arc
int OpenALSoundSystem::PlaySound ( const char *_soundName, short _distX, short _distY )
{
    ALuint buf = m_buffers.find ( _soundName );
    if (!buf)
    {
        LoadWave(_soundName);
        buf = m_buffers.find(_soundName);
        ARCReleaseAssert ( buf != NULL );
    }

    ALuint src = AcquireSource ();
    ARCReleaseAssert ( src != 0 );

    float loc[3] = { (float)_distX, (float)_distY, 0.0f };

    alSourceStop ( src );
    alSourceRewind ( src );
    alSourcei ( src, AL_BUFFER, buf );
    alSourcefv ( src, AL_POSITION, loc );
    alSourcePlay ( src );

    return 0;
}
コード例 #26
0
ファイル: alstream.c プロジェクト: JakobssonAndre/lotech
/* Prebuffers some audio from the file, and starts playing the source */
static int StartPlayer(StreamPlayer *player)
{
    size_t i, got;

    /* Rewind the source position and clear the buffer queue */
    alSourceRewind(player->source);
    alSourcei(player->source, AL_BUFFER, 0);

    /* Fill the buffer queue */
    for(i = 0;i < NUM_BUFFERS;i++)
    {
        /* Get some data to give it to the buffer */
        got = readAVAudioData(player->stream, player->data, player->datasize);
        if(got == 0) break;

        alBufferSamplesSOFT(player->buffers[i], player->rate, player->format,
                            BytesToFrames(got, player->channels, player->type),
                            player->channels, player->type, player->data);
    }
    if(alGetError() != AL_NO_ERROR)
    {
        fprintf(stderr, "Error buffering for playback\n");
        return 0;
    }

    /* Now queue and start playback! */
    alSourceQueueBuffers(player->source, i, player->buffers);
    alSourcePlay(player->source);
    if(alGetError() != AL_NO_ERROR)
    {
        fprintf(stderr, "Error starting playback\n");
        return 0;
    }

    return 1;
}
コード例 #27
0
value lime_al_source_rewind (value source) {

    alSourceRewind (val_int (source));
    return alloc_null ();

}
コード例 #28
0
static gint
gst_openal_sink_write (GstAudioSink * audiosink, gpointer data, guint length)
{
  GstOpenALSink *sink = GST_OPENAL_SINK (audiosink);
  ALint processed, queued, state;
  ALCcontext *old;
  gulong rest_us;

  g_assert (length == sink->buffer_length);

  old = pushContext (sink->default_context);

  rest_us =
      (guint64) (sink->buffer_length / sink->bytes_per_sample) *
      G_USEC_PER_SEC / sink->rate / sink->channels;
  do {
    alGetSourcei (sink->default_source, AL_SOURCE_STATE, &state);
    alGetSourcei (sink->default_source, AL_BUFFERS_QUEUED, &queued);
    alGetSourcei (sink->default_source, AL_BUFFERS_PROCESSED, &processed);
    if (checkALError () != AL_NO_ERROR) {
      GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
          ("Source state error detected"));
      length = 0;
      goto out_nolock;
    }

    if (processed > 0 || queued < sink->buffer_count)
      break;
    if (state != AL_PLAYING)
      alSourcePlay (sink->default_source);
    g_usleep (rest_us);
  }
  while (1);

  GST_OPENAL_SINK_LOCK (sink);
  if (sink->write_reset != AL_FALSE) {
    sink->write_reset = AL_FALSE;
    length = 0;
    goto out;
  }

  queued -= processed;
  while (processed-- > 0) {
    ALuint bid;
    alSourceUnqueueBuffers (sink->default_source, 1, &bid);
  }
  if (state == AL_STOPPED) {
    /* "Restore" from underruns (not actually needed, but it keeps delay
     * calculations correct while rebuffering) */
    alSourceRewind (sink->default_source);
  }

  alBufferData (sink->buffers[sink->buffer_idx], sink->format,
      data, sink->buffer_length, sink->rate);
  alSourceQueueBuffers (sink->default_source, 1,
      &sink->buffers[sink->buffer_idx]);
  sink->buffer_idx = (sink->buffer_idx + 1) % sink->buffer_count;
  queued++;

  if (state != AL_PLAYING && queued == sink->buffer_count)
    alSourcePlay (sink->default_source);

  if (checkALError () != AL_NO_ERROR) {
    GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, (NULL),
        ("Source queue error detected"));
    goto out;
  }

out:
  GST_OPENAL_SINK_UNLOCK (sink);
out_nolock:
  popContext (old, sink->default_context);
  return length;
}
コード例 #29
0
ファイル: al_auto.c プロジェクト: AlanFreeman/Psychtoolbox-3
void al_sourcerewind( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) {

	if (NULL == alSourceRewind) mogl_glunsupported("alSourceRewind");
	alSourceRewind((ALuint)mxGetScalar(prhs[0]));

}
コード例 #30
0
ファイル: QOpenALEngine.cpp プロジェクト: shujaatak/QFFmpeg
void QOpenALEngine::rewind()
{
    alSourceRewind(uiSource);
}