XnStatus PlayerImpl::SetSource(XnRecordMedium sourceType, const XnChar* strSource)
{
	XnStatus nRetVal = XN_STATUS_OK;

	// NOTE: we don't want playback speed to affect getting to the first frame, so perform this
	// without playback speed
	XnDouble dPlaybackSpeed = GetPlaybackSpeed();
	SetPlaybackSpeed(XN_PLAYBACK_SPEED_FASTEST);

	//Right now the only record medium we support is a file
	
	m_sourceType = sourceType;

	switch (m_sourceType)
	{
		case XN_RECORD_MEDIUM_FILE:
		{
			nRetVal = xnOSStrCopy(m_strSource, strSource, sizeof(m_strSource));
			XN_IS_STATUS_OK(nRetVal);
			nRetVal = ModulePlayer().SetInputStream(ModuleHandle(), this, &s_fileInputStream);
			XN_IS_STATUS_OK(nRetVal);
			break;
		}
		default:
			XN_ASSERT(FALSE);
			return XN_STATUS_BAD_PARAM;
	}

	// now re-set playback speed
	nRetVal = SetPlaybackSpeed(dPlaybackSpeed);
	XN_IS_STATUS_OK(nRetVal);

	return XN_STATUS_OK;
}
Beispiel #2
0
PlayerStatus_t Player_Generic_c::SetPlaybackSpeed(
	PlayerPlayback_t Playback,
	Rational_t Speed,
	PlayDirection_t Direction)
{
	PlayerStatus_t Status;
	unsigned long long Now;
	unsigned long long NormalizedTimeAtStartOfDrain;
	bool ReTimeQueuedFrames;
	PlayerStream_t Stream;
	unsigned char Policy;
	//
	// Ensure that the playback interval is not cluttered by reversal clamps
	//
	Playback->PresentationIntervalReversalLimitStartNormalizedTime = INVALID_TIME;
	Playback->PresentationIntervalReversalLimitEndNormalizedTime = INVALID_TIME;
	//
	// Are we performing a direction flip
	//
	if (Playback->Direction != Direction)
	{
		//
		// Find the current playback time
		//
		Now = OS_GetTimeInMicroSeconds();
		Status = Playback->OutputCoordinator->TranslateSystemTimeToPlayback(PlaybackContext, Now, &NormalizedTimeAtStartOfDrain);
		if (Status != PlayerNoError)
		{
			report(severity_error, "Player_Generic_c::SetPlaybackSpeed - Failed to translate system time to playback time.\n");
			NormalizedTimeAtStartOfDrain = INVALID_TIME;
		}
		//
		// Drain with prejudice, but ensuring all frames are parsed
		//
		if (Playback->Speed == 0)
			SetPlaybackSpeed(Playback, 1, Playback->Direction);
		InternalDrainPlayback(Playback, (PlayerPolicy_t)PolicyPlayoutAlwaysDiscard, true);
		//
		// Find the current frames on display, and clamp the play
		// interval to ensure we don't go too far in the flip.
		//
		Policy = PolicyValue(Playback, PlayerAllStreams, PolicyClampPlaybackIntervalOnPlaybackDirectionChange);
		if (Policy == PolicyValueApply)
		{
			if (Direction == PlayForward)
				Playback->PresentationIntervalReversalLimitStartNormalizedTime = NormalizedTimeAtStartOfDrain;
			else
				Playback->PresentationIntervalReversalLimitEndNormalizedTime = NormalizedTimeAtStartOfDrain;
		}
	}
	//
	// Do we need to re-time the queued frames
	//
	ReTimeQueuedFrames = (Playback->Direction == Direction) &&
			     (Playback->Speed != Speed);
	//
	// Record the new speed and direction
	//
	Playback->Speed = Speed;
	Playback->Direction = Direction;
	//
	// Specifically inform the output coordinator of the change
	//
	Status = Playback->OutputCoordinator->SetPlaybackSpeed(PlaybackContext, Speed, Direction);
	if (Status != PlayerNoError)
	{
		report(severity_info, "Player_Generic_c::SetPlaybackSpeed - failed to inform output cordinator of speed change.\n");
		return Status;
	}
	//
	// Perform queued frame re-timing, and release any single step waiters
	//
	for (Stream = Playback->ListOfStreams;
			Stream != NULL;
			Stream = Stream->Next)
	{
		if (ReTimeQueuedFrames)
		{
			Stream->ReTimeStart = OS_GetTimeInMicroSeconds();
			Stream->ReTimeQueuedFrames = true;
			Stream->Manifestor->ReleaseQueuedDecodeBuffers();
		}
		OS_SetEvent(&Stream->SingleStepMayHaveHappened);
	}
//
	return PlayerNoError;
}
Beispiel #3
0
void WrapperDLL::Sound_SetPlaybackSpeed(void* self,int32_t id,float playbackSpeed){
	auto self_ = (Sound*)self;
	auto arg0 = id;
	auto arg1 = playbackSpeed;
	self_->SetPlaybackSpeed(arg0,arg1);
};