示例#1
0
// Given the "Checksum" of a script command, then possibly handle it
// if it's a command that this component will handle	
CBaseComponent::EMemberFunctionResult CStreamComponent::CallMemberFunction( uint32 Checksum, Script::CStruct* pParams, Script::CScript* pScript )
{
	switch ( Checksum )
	{

		case 0xdb05a233:  // Obj_PlayStream
			PlayStream( pParams, pScript );
			break;
		
		case 0xa738aeb8:  // Obj_StopStream
		{
			// eventually want to be able to specify channel on here...
			int i;
			for ( i = 0; i < MAX_STREAMS_PER_OBJECT; i++ )
			{
				if ( mStreamingID[ i ] )
				{
					Pcm::StopStreamFromID( mStreamingID[ i ] );
					mStreamingID[ i ] = 0;
				}
			}
			break;
		}
		

		default:
			return CBaseComponent::MF_NOT_EXECUTED;
	}

	// the "default" case of the switch statement handles
	// unrecognized functions;  if we make it down here,
	// that means that the component already handled it
	// somehow
    return CBaseComponent::MF_TRUE;
}
unsigned long	GS_PlayStream(unsigned long nPort,HWND hWnd)
{
	//初始化渲染设备,开启线程
	PSTREAMCONFIG pm = GetStream(nPort);
	if(pm==NULL)
	{
		return S_FALSE;
	}
	if(pm->pVideoConfig)
	{
		//初始化视频渲染设备
		pm->pVideoConfig->m_hWnd = hWnd;
		if(InitDirectDraw(pm->pVideoConfig,1920,1080)==S_FALSE)
		{
			pm->nLastError = GENTEK_DDRAW_INIT_FAILED;
			if(InitGDIPlus(pm->pVideoConfig)==S_FALSE)
			{
				pm->nLastError = GENTEK_VIDEO_RENDER_FAILED;
				return S_FALSE;
			}
			else
			{
				pm->pVideoConfig->m_bUsingGDIPLUS = true;
			}
		}
		else
		{
			pm->pVideoConfig->m_bUsingGDIPLUS = false;
		}
	}
	if(pm->pAudioConfig)
	{
		//为初始化音频做准备
		pm->pAudioConfig->m_hwnd = pm->pVideoConfig->m_hWnd;
		//初始化音频设备
		if(InitDirectSound(pm->pAudioConfig)==S_FALSE)
		{
			pm->nLastError = GENTEK_AUDIO_RENDER_FAILED;
			return S_FALSE;
		}

	}
	//创建线程
	pm->pContrlConfig->nPort = nPort;
	pm->pContrlConfig->bDataOver = false;
	pm->pContrlConfig->bCallStreamOver = false;
	if(PlayStream(pm->pContrlConfig,pm->pCodecConfig,pm->pVideoConfig,pm->pAudioConfig)==S_OK)
	{
		char str[128];
		sprintf(str," Play GentekPlatformStream %d\n",nPort);
		OutputDebugStringA(str);
		return S_OK;
	}

	pm->nLastError = GENTEK_THREAD_CREAT_FAILED;
	return S_FALSE;
}
void CAudioManager::PlayStreamClip(int clipID){
  if(m_bValidAudio == false)
    return;

  for(int i = 0; i < m_StreamClip.size(); i++){
    if(m_StreamClip[i].ClipID == clipID){
      SetStreamPositionTime(m_StreamClip[i].AudioID, m_StreamClip[i].beginMs);
      PlayStream(m_StreamClip[i].AudioID, 0);
    }
  }
}
示例#4
0
// This should just start playing a stream
void
PlayTrack (void)
{
    if (!sound_sample)
        return; // nothing to play

    LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
    tracks_length = tracks_end_time ();
    // decoder will be set in OnStreamStart()
    cur_chunk = chunks_head;
    // Always scope the speech data, we may need it
    PlayStream (sound_sample, SPEECH_SOURCE, false, true, true);
    UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
示例#5
0
void
snd_PlaySpeech (MUSIC_REF SpeechRef)
{
	TFB_SoundSample **pmus = SpeechRef;

	if (pmus)
	{
		LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
		// Do not need to scope the music-as-speech as of now
		PlayStream (*pmus, SPEECH_SOURCE, false, false, true);
		UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
		
		curSpeechRef = SpeechRef;
	}
}
示例#6
0
void
PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority)
{
	TFB_SoundSample **pmus = MusicRef;

	if (pmus)
	{
		LockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
		// Always scope the music data, we may need it
		PlayStream ((*pmus), MUSIC_SOURCE, Continuous, true, true);
		UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
		
		curMusicRef = MusicRef;
	}

	(void) Priority;  /* Satisfy compiler because of unused variable */
}
示例#7
0
void cSoundStreamRenderer::UpdateStreams()
{
    RemoveUnmarkedBindings();

    for(unsigned int i = 0; i < m_DataBindings.size(); ++i)
    {
        sStreamBinding &str = m_DataBindings[i];

        if(!str.m_Source || !str.m_Stream)
        {
            ClearBinding(str);
            continue;
        }

        while(OpenAL::Get().GetProcessedBuffersCount(str.m_Source->Get()) > 0)
        {
            ALuint buffer = OpenAL::Get().PopBufferQueue(str.m_Source->Get());
            str.m_RawBuffers.Return(buffer);
        }

        vSoundStreamProperties *props = dynamic_cast<vSoundStreamProperties*>(str.m_Stream->GetRenderingProperties());
        if(!props)
            continue;
    
        switch(props->GetWantedState())
        {
        case ESourceState::Playing: PlayStream(str); break;
        case ESourceState::Stopped: StopStream(str); break;
        case ESourceState::Paused:  PauseStream(str); break;
        default: break;
        }
    }


    for(unsigned int i = 0; i < m_DataBindings.size(); ++i)
    {
        sStreamBinding &str = m_DataBindings[i];
        vSoundStreamProperties *props = dynamic_cast<vSoundStreamProperties*>(str.m_Stream->GetRenderingProperties());

        props->SetState(OpenAL::Get().GetSourceState(str.m_Source->Get()));

        str.m_Stream->Synchronize(props);
    }
};
示例#8
0
void
FastReverse_Page (void)
{
    TFB_SoundChunk *prev;

    if (!sound_sample)
        return; // nothing is playing, so.. bye!

    LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
    prev = find_prev_page (cur_sub_chunk);
    if (prev)
    {   // Set the chunk to be played
        cur_chunk = prev;
        cur_sub_chunk = prev;
        // Decoder will be set in OnStreamStart()
        PlayStream (sound_sample, SPEECH_SOURCE, false, true, true);
    }
    UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
示例#9
0
void
FastReverse_Smooth (void)
{
    sint32 offset;

    if (!sound_sample)
        return; // nothing is playing, so.. bye!

    LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);

    offset = get_current_track_pos ();
    offset -= ACCEL_SCROLL_SPEED;
    seek_track (offset);

    // Restart the stream in case it ended previously
    if (!PlayingStream (SPEECH_SOURCE))
        PlayStream (sound_sample, SPEECH_SOURCE, false, true, false);
    UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}
示例#10
0
void
FastForward_Page (void)
{
    TFB_SoundChunk *next;

    if (!sound_sample)
        return; // nothing is playing, so.. bye!

    LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
    next = find_next_page (cur_sub_chunk);
    if (next)
    {   // Set the chunk to be played
        cur_chunk = next;
        cur_sub_chunk = next;
        // Decoder will be set in OnStreamStart()
        PlayStream (sound_sample, SPEECH_SOURCE, false, true, true);
    }
    else
    {   // End of the tracks (pun intended)
        seek_track (tracks_length + 1);
    }
    UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
}