コード例 #1
0
ファイル: streamplay.cpp プロジェクト: AnsonX10/bitfighter
	void unprotect()
	{
		if(alcSetThreadContext)
		{
			if(alcSetThreadContext(old_ctx) == ALC_FALSE)
				alcSetThreadContext(NULL);
		}
	}
コード例 #2
0
ファイル: streamplay.cpp プロジェクト: AnsonX10/bitfighter
void StopStream(alureStream *stream)
{
	EnterCriticalSection(&cs_StreamPlay);

	std::list<AsyncPlayEntry>::iterator i = AsyncPlayList.begin(),
	                                    end = AsyncPlayList.end();
	while(i != end)
	{
		if(i->stream == stream)
		{
			AsyncPlayEntry ent(*i);
			AsyncPlayList.erase(i);

			ALCcontext *old_ctx = (alcGetThreadContext ?
			                       alcGetThreadContext() : NULL);
			if(alcSetThreadContext)
			{
				if(alcSetThreadContext(ent.ctx) == ALC_FALSE)
					goto ctx_err;
			}

			alSourceStop(ent.source);
			alSourcei(ent.source, AL_BUFFER, 0);
			alDeleteBuffers(ent.buffers.size(), &ent.buffers[0]);
			alGetError();

			if(alcSetThreadContext)
			{
				if(alcSetThreadContext(old_ctx) == ALC_FALSE)
					alcSetThreadContext(NULL);
			}

		ctx_err:
			if(ent.eos_callback)
				ent.eos_callback(ent.user_data, ent.source);
			break;
		}
		i++;
	}

	LeaveCriticalSection(&cs_StreamPlay);
}
コード例 #3
0
ファイル: openal.c プロジェクト: AmesianX/RosWine
/* Thread-local context functions */
static ALCboolean CDECL wine_alcSetThreadContext(ALCcontext *context)
{
    EnterCriticalSection(&openal_cs);
    if(alcSetThreadContext(context) == ALC_FALSE)
    {
        WARN("Failed to make context %p current\n", context);
        LeaveCriticalSection(&openal_cs);
        return ALC_FALSE;
    }

    if(context && !loaded_procs)
    {
        loaded_procs = AL_TRUE;
        LoadProcs();
    }
    LeaveCriticalSection(&openal_cs);

    return ALC_TRUE;
}
コード例 #4
0
ファイル: streamplay.cpp プロジェクト: AnsonX10/bitfighter
/* Function: alureUpdate
 *
 * Updates the running list of streams, and checks for stopped sources. This
 * makes sure that sources played with <alurePlaySourceStream> are kept fed
 * from their associated stream, and sources played with <alurePlaySource> are
 * still playing. It will call their callbacks as needed.
 *
 * *Version Added*: 1.1
 *
 * See Also:
 * <alurePlaySourceStream>, <alurePlaySource>
 */
ALURE_API void ALURE_APIENTRY alureUpdate(void)
{
	PROTECT_CONTEXT();

	EnterCriticalSection(&cs_StreamPlay);
restart:
	std::list<AsyncPlayEntry>::iterator i = AsyncPlayList.begin(),
	                                    end = AsyncPlayList.end();
	for(;i != end;i++)
	{
		if(alcSetThreadContext)
		{
			if(alcSetThreadContext(i->ctx) == ALC_FALSE)
			{
				AsyncPlayEntry ent(*i);
				AsyncPlayList.erase(i);
				if(ent.eos_callback)
				{
					DO_UNPROTECT();
					ent.eos_callback(ent.user_data, ent.source);
					DO_PROTECT();
				}
				goto restart;
			}
		}

		if(i->stream == NULL)
		{
			ALint state;
			alGetSourcei(i->source, AL_SOURCE_STATE, &state);
			if(state == AL_STOPPED || state == AL_INITIAL)
			{
				AsyncPlayEntry ent(*i);
				AsyncPlayList.erase(i);
				DO_UNPROTECT();
				ent.eos_callback(ent.user_data, ent.source);
				DO_PROTECT();
				goto restart;
			}
			continue;
		}

		ALint queued;
		if(i->Update(&queued) != AL_PLAYING)
		{
			if(queued == 0)
			{
				AsyncPlayEntry ent(*i);
				AsyncPlayList.erase(i);

				alSourcei(ent.source, AL_BUFFER, 0);
				alDeleteBuffers(ent.buffers.size(), &ent.buffers[0]);
				if(ent.eos_callback)
				{
					DO_UNPROTECT();
					ent.eos_callback(ent.user_data, ent.source);
					DO_PROTECT();
				}
				goto restart;
			}
			if(!i->paused)
				alSourcePlay(i->source);
		}
	}
	LeaveCriticalSection(&cs_StreamPlay);
}
コード例 #5
0
ファイル: streamplay.cpp プロジェクト: AnsonX10/bitfighter
	void protect()
	{
		old_ctx = (alcGetThreadContext ? alcGetThreadContext() : NULL);
		if(alcSetThreadContext)
			alcSetThreadContext(alcGetCurrentContext());
	}