From b9298b61e43a8facbc8a62747678b1ddd328d8ae Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Thu, 10 May 2007 22:39:17 +0000 Subject: [PATCH] FIXME comments in (almost) all audio players, neither handle time reporting fully correct: they report number of samples they have played plus start sample, instead of current sample being heard, ie. they don't take into account that the current position might get changed in mid-stream by the video player to resync audio to video. Originally committed to SVN as r1175. --- aegisub/audio_player_alsa.cpp | 2 ++ aegisub/audio_player_dsound.cpp | 2 ++ aegisub/audio_player_openal.cpp | 2 ++ aegisub/audio_player_pulse.cpp | 3 +++ 4 files changed, 9 insertions(+) diff --git a/aegisub/audio_player_alsa.cpp b/aegisub/audio_player_alsa.cpp index 84fdede52..5dc5bdccd 100644 --- a/aegisub/audio_player_alsa.cpp +++ b/aegisub/audio_player_alsa.cpp @@ -397,6 +397,8 @@ __int64 AlsaPlayer::GetEndPosition() // Get current position __int64 AlsaPlayer::GetCurrentPosition() { + // FIXME: this should be based on not duration played but actual sample being heard + // (during vidoeo playback, cur_frame might get changed to resync) snd_pcm_sframes_t delay = 0; snd_pcm_delay(pcm_handle, &delay); // don't bother catching errors here return cur_frame - delay; diff --git a/aegisub/audio_player_dsound.cpp b/aegisub/audio_player_dsound.cpp index df74806d8..7c87a060c 100644 --- a/aegisub/audio_player_dsound.cpp +++ b/aegisub/audio_player_dsound.cpp @@ -395,6 +395,8 @@ __int64 DirectSoundPlayer::GetCurrentPosition() { // Check if buffer is loaded if (!buffer || !playing) return 0; + // FIXME: this should be based on not duration played but actual sample being heard + // (during vidoeo playback, cur_frame might get changed to resync) DWORD curtime = GetTickCount(); __int64 tdiff = curtime - startTime; return startPos + tdiff * provider->GetSampleRate() / 1000; diff --git a/aegisub/audio_player_openal.cpp b/aegisub/audio_player_openal.cpp index c553198c3..574d02cce 100644 --- a/aegisub/audio_player_openal.cpp +++ b/aegisub/audio_player_openal.cpp @@ -384,6 +384,8 @@ __int64 OpenALPlayer::GetEndPosition() // Get current position __int64 OpenALPlayer::GetCurrentPosition() { + // FIXME: this should be based on not duration played but actual sample being heard + // (during vidoeo playback, cur_frame might get changed to resync) long extra = playback_segment_timer.Time(); return buffers_played * buffer_length + start_frame + extra * samplerate / 1000; } diff --git a/aegisub/audio_player_pulse.cpp b/aegisub/audio_player_pulse.cpp index 4c237b769..15e511e83 100644 --- a/aegisub/audio_player_pulse.cpp +++ b/aegisub/audio_player_pulse.cpp @@ -395,6 +395,9 @@ __int64 PulseAudioPlayer::GetCurrentPosition() { if (!is_playing) return 0; + // FIXME: this should be based on not duration played but actual sample being heard + // (during vidoeo playback, cur_frame might get changed to resync) + // Calculation duration we have played, in microseconds pa_usec_t play_cur_time; pa_stream_get_time(stream, &play_cur_time);