Make the "Play last 500ms of selection" command always play to the end of the selection as it did in 2.1

Originally committed to SVN as r6171.
This commit is contained in:
Thomas Goyne 2011-12-27 02:23:04 +00:00
parent 935e5544d5
commit eda90a15fb
3 changed files with 19 additions and 3 deletions

View File

@ -429,6 +429,16 @@ void AudioController::PlayPrimaryRange()
playback_mode = PM_PrimaryRange;
}
void AudioController::PlayToEndOfPrimary(int64_t start_sample)
{
if (!IsAudioOpen()) return;
player->Play(start_sample, GetPrimaryPlaybackRange().end() - start_sample);
playback_mode = PM_PrimaryRange;
playback_timer.Start(20);
AnnouncePlaybackPosition(start_sample);
}
void AudioController::PlayToEnd(int64_t start_sample)
{

View File

@ -306,6 +306,13 @@ public:
/// The playback end can not be changed in any other way.
void PlayPrimaryRange();
/// @brief Start or restart audio playback, playing from a point to the end of of the primary playback range
/// @param start_sample Index of the sample to start playback at
///
/// This behaves like PlayPrimaryRange, but the start point can differ from
/// the beginning of the primary range.
void PlayToEndOfPrimary(int64_t start_sample);
/// @brief Start or restart audio playback, playing from a point to the end of stream
/// @param start_sample Index of the sample to start playback at
///

View File

@ -290,11 +290,10 @@ struct audio_play_end : public validate_audio_open {
void operator()(agi::Context *c) {
c->videoController->Stop();
SampleRange times(c->audioController->GetPrimaryPlaybackRange());
c->audioController->PlayRange(SampleRange(
c->audioController->PlayToEndOfPrimary(
times.end() - std::min(
c->audioController->SamplesFromMilliseconds(500),
times.length()),
times.end()));
times.length()));
}
};