@@ -400,7 +400,7 @@ void AudioBackendOAL::Source_IsLoopingChanged(uint32 sourceID, bool loop)
|
||||
void AudioBackendOAL::Source_SpatialSetupChanged(uint32 sourceID, bool spatial, float attenuation, float minDistance, float doppler)
|
||||
{
|
||||
ALC::Locker.Lock();
|
||||
const bool pan = ALC::SourcesData[sourceID].Spatial;
|
||||
const float pan = ALC::SourcesData[sourceID].Pan;
|
||||
ALC::Locker.Unlock();
|
||||
if (spatial)
|
||||
{
|
||||
|
||||
@@ -672,7 +672,7 @@ bool AudioBackendXAudio2::Base_Init()
|
||||
HRESULT hr = XAudio2Create(&XAudio2::Instance, 0, XAUDIO2_DEFAULT_PROCESSOR);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LOG(Error, "Failed to initalize XAudio2. Error: 0x{0:x}", hr);
|
||||
LOG(Error, "Failed to initialize XAudio2. Error: 0x{0:x}", hr);
|
||||
return true;
|
||||
}
|
||||
XAudio2::Instance->RegisterForCallbacks(&XAudio2::Callback);
|
||||
@@ -681,7 +681,7 @@ bool AudioBackendXAudio2::Base_Init()
|
||||
hr = XAudio2::Instance->CreateMasteringVoice(&XAudio2::MasteringVoice);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
LOG(Error, "Failed to initalize XAudio2 mastering voice. Error: 0x{0:x}", hr);
|
||||
LOG(Error, "Failed to initialize XAudio2 mastering voice. Error: 0x{0:x}", hr);
|
||||
return true;
|
||||
}
|
||||
XAUDIO2_VOICE_DETAILS details;
|
||||
|
||||
@@ -47,6 +47,8 @@ struct VideoPlayerMF
|
||||
namespace MF
|
||||
{
|
||||
Array<VideoBackendPlayer*> Players;
|
||||
TimeSpan UpdateDeltaTime;
|
||||
double UpdateTime;
|
||||
|
||||
bool Configure(VideoBackendPlayer& player, VideoPlayerMF& playerMF, DWORD streamIndex)
|
||||
{
|
||||
@@ -395,13 +397,6 @@ namespace MF
|
||||
if (!playerMF.Playing && !playerMF.Seek)
|
||||
return;
|
||||
|
||||
bool useTimeScale = true;
|
||||
#if USE_EDITOR
|
||||
if (!Editor::IsPlayMode)
|
||||
useTimeScale = false;
|
||||
#endif
|
||||
TimeSpan dt = useTimeScale ? Time::Update.DeltaTime : Time::Update.UnscaledDeltaTime;
|
||||
|
||||
// Update playback time
|
||||
if (playerMF.FirstFrame)
|
||||
{
|
||||
@@ -410,9 +405,9 @@ namespace MF
|
||||
}
|
||||
else if (playerMF.Playing)
|
||||
{
|
||||
playerMF.Time += dt;
|
||||
playerMF.Time += UpdateDeltaTime;
|
||||
}
|
||||
if (playerMF.Time > player.Duration)
|
||||
if (playerMF.Time > player.Duration && player.Duration.Ticks != 0)
|
||||
{
|
||||
if (playerMF.Loop)
|
||||
{
|
||||
@@ -452,7 +447,7 @@ namespace MF
|
||||
}
|
||||
|
||||
// Update streams
|
||||
if (ReadStream(player, playerMF, MF_SOURCE_READER_FIRST_VIDEO_STREAM, dt))
|
||||
if (ReadStream(player, playerMF, MF_SOURCE_READER_FIRST_VIDEO_STREAM, UpdateDeltaTime))
|
||||
{
|
||||
// Failed to pick a valid sample so try again with seeking
|
||||
playerMF.Seek = 1;
|
||||
@@ -464,7 +459,7 @@ namespace MF
|
||||
}
|
||||
}
|
||||
if (player.AudioInfo.BitDepth != 0)
|
||||
ReadStream(player, playerMF, MF_SOURCE_READER_FIRST_AUDIO_STREAM, dt);
|
||||
ReadStream(player, playerMF, MF_SOURCE_READER_FIRST_AUDIO_STREAM, UpdateDeltaTime);
|
||||
|
||||
player.Tick();
|
||||
}
|
||||
@@ -610,12 +605,17 @@ bool VideoBackendMF::Base_Init()
|
||||
VIDEO_API_MF_ERROR(MFStartup, hr);
|
||||
return true;
|
||||
}
|
||||
MF::UpdateTime = Platform::GetTimeSeconds();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void VideoBackendMF::Base_Update(TaskGraph* graph)
|
||||
{
|
||||
double time = Platform::GetTimeSeconds();
|
||||
MF::UpdateDeltaTime = TimeSpan::FromSeconds(time - MF::UpdateTime);
|
||||
MF::UpdateTime = time;
|
||||
|
||||
// Schedule work to update all videos in async
|
||||
Function<void(int32)> job;
|
||||
job.Bind(MF::UpdatePlayer);
|
||||
|
||||
@@ -133,7 +133,9 @@ void VideoPlayer::SetTime(float time)
|
||||
if (_state == States::Stopped || _player.Backend == nullptr)
|
||||
return;
|
||||
TimeSpan timeSpan = TimeSpan::FromSeconds(time);
|
||||
timeSpan.Ticks = Math::Clamp<int64>(timeSpan.Ticks, 0, _player.Duration.Ticks);
|
||||
timeSpan.Ticks = Math::Max<int64>(timeSpan.Ticks, 0);
|
||||
if (_player.Duration.Ticks > 0)
|
||||
timeSpan.Ticks = Math::Min<int64>(timeSpan.Ticks, _player.Duration.Ticks);
|
||||
_player.Backend->Player_Seek(_player, timeSpan);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user