2010-12-08 04:36:10 +01:00
|
|
|
// Copyright (c) 2009-2010, Niels Martin Hansen
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
// * Neither the name of the Aegisub Group nor the names of its contributors
|
|
|
|
// may be used to endorse or promote products derived from this software
|
|
|
|
// without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
/// @file audio_controller.cpp
|
|
|
|
/// @brief Manage open audio and abstract state away from display
|
|
|
|
/// @ingroup audio_ui
|
|
|
|
///
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include "audio_controller.h"
|
2011-01-16 08:18:00 +01:00
|
|
|
|
2011-09-28 21:51:35 +02:00
|
|
|
#include "ass_file.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "audio_timing.h"
|
|
|
|
#include "compat.h"
|
2014-03-25 17:51:38 +01:00
|
|
|
#include "dialog_progress.h"
|
2011-07-15 06:04:13 +02:00
|
|
|
#include "include/aegisub/audio_player.h"
|
|
|
|
#include "include/aegisub/audio_provider.h"
|
2011-09-28 21:51:35 +02:00
|
|
|
#include "include/aegisub/context.h"
|
2011-10-19 06:19:01 +02:00
|
|
|
#include "pen.h"
|
2013-01-07 02:50:09 +01:00
|
|
|
#include "options.h"
|
2011-07-15 06:04:13 +02:00
|
|
|
#include "selection_controller.h"
|
2013-01-26 02:57:46 +01:00
|
|
|
#include "subs_controller.h"
|
2012-04-21 17:13:40 +02:00
|
|
|
#include "utils.h"
|
2010-12-08 04:36:10 +01:00
|
|
|
#include "video_context.h"
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
#include <libaegisub/io.h>
|
|
|
|
#include <libaegisub/path.h>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2011-09-28 21:51:35 +02:00
|
|
|
AudioController::AudioController(agi::Context *context)
|
|
|
|
: context(context)
|
2013-01-26 02:57:46 +01:00
|
|
|
, subtitle_save_slot(context->subsController->AddFileSaveListener(&AudioController::OnSubtitlesSave, this))
|
2010-12-08 04:36:10 +01:00
|
|
|
, playback_mode(PM_NotPlaying)
|
|
|
|
, playback_timer(this)
|
|
|
|
{
|
2011-01-01 00:53:36 +01:00
|
|
|
Bind(wxEVT_TIMER, &AudioController::OnPlaybackTimer, this, playback_timer.GetId());
|
2010-12-08 04:36:10 +01:00
|
|
|
|
|
|
|
#ifdef wxHAS_POWER_EVENTS
|
2011-01-01 00:53:36 +01:00
|
|
|
Bind(wxEVT_POWER_SUSPENDED, &AudioController::OnComputerSuspending, this);
|
|
|
|
Bind(wxEVT_POWER_RESUME, &AudioController::OnComputerResuming, this);
|
2010-12-08 04:36:10 +01:00
|
|
|
#endif
|
2011-11-19 02:14:42 +01:00
|
|
|
|
|
|
|
OPT_SUB("Audio/Player", &AudioController::OnAudioPlayerChanged, this);
|
|
|
|
OPT_SUB("Audio/Provider", &AudioController::OnAudioProviderChanged, this);
|
2011-11-19 05:57:14 +01:00
|
|
|
OPT_SUB("Audio/Cache/Type", &AudioController::OnAudioProviderChanged, this);
|
2012-06-07 23:03:11 +02:00
|
|
|
|
|
|
|
#ifdef WITH_FFMS2
|
|
|
|
// As with the video ones, it'd be nice to figure out a decent way to move
|
|
|
|
// this to the provider itself
|
|
|
|
OPT_SUB("Provider/Audio/FFmpegSource/Decode Error Handling", &AudioController::OnAudioProviderChanged, this);
|
|
|
|
#endif
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
AudioController::~AudioController()
|
|
|
|
{
|
|
|
|
CloseAudio();
|
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void AudioController::OnPlaybackTimer(wxTimerEvent &)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
int64_t pos = player->GetCurrentPosition();
|
|
|
|
|
|
|
|
if (!player->IsPlaying() ||
|
|
|
|
(playback_mode != PM_ToEnd && pos >= player->GetEndPosition()+200))
|
|
|
|
{
|
2011-01-01 00:53:36 +01:00
|
|
|
// The +200 is to allow the player to end the sound output cleanly,
|
|
|
|
// otherwise a popping artifact can sometimes be heard.
|
2010-12-08 04:36:10 +01:00
|
|
|
Stop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-02 00:58:58 +01:00
|
|
|
AnnouncePlaybackPosition(MillisecondsFromSamples(pos));
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef wxHAS_POWER_EVENTS
|
2011-12-22 22:09:31 +01:00
|
|
|
void AudioController::OnComputerSuspending(wxPowerEvent &)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
Stop();
|
2013-06-08 06:19:40 +02:00
|
|
|
player.reset();
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
2011-12-22 22:09:31 +01:00
|
|
|
void AudioController::OnComputerResuming(wxPowerEvent &)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
if (provider)
|
2012-03-20 00:31:33 +01:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2014-03-25 17:51:38 +01:00
|
|
|
player = AudioPlayerFactory::GetAudioPlayer(provider.get(), context->parent);
|
2012-03-20 00:31:33 +01:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
CloseAudio();
|
|
|
|
}
|
|
|
|
}
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-11-19 02:14:42 +01:00
|
|
|
void AudioController::OnAudioPlayerChanged()
|
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
|
|
|
|
Stop();
|
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
player.reset();
|
2011-11-19 02:14:42 +01:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2014-03-25 17:51:38 +01:00
|
|
|
player = AudioPlayerFactory::GetAudioPlayer(provider.get(), context->parent);
|
2011-11-19 02:14:42 +01:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
CloseAudio();
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::OnAudioProviderChanged()
|
|
|
|
{
|
|
|
|
if (IsAudioOpen())
|
|
|
|
// url is cloned because CloseAudio clears it and OpenAudio takes a const reference
|
2013-01-04 16:01:50 +01:00
|
|
|
OpenAudio(agi::fs::path(audio_url));
|
2011-11-19 02:14:42 +01:00
|
|
|
}
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
void AudioController::OpenAudio(agi::fs::path const& url)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
2013-01-04 16:01:50 +01:00
|
|
|
if (url.empty())
|
2013-11-21 18:13:36 +01:00
|
|
|
throw agi::InternalError("AudioController::OpenAudio() was passed an empty string. This must not happen.", nullptr);
|
2010-12-08 04:36:10 +01:00
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
std::unique_ptr<AudioProvider> new_provider;
|
2012-12-22 18:30:47 +01:00
|
|
|
try {
|
2014-03-25 17:51:38 +01:00
|
|
|
DialogProgress progress(context->parent);
|
|
|
|
new_provider = AudioProviderFactory::GetProvider(url, &progress);
|
2013-01-04 16:01:50 +01:00
|
|
|
config::path->SetToken("?audio", url);
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
2012-12-22 18:30:47 +01:00
|
|
|
catch (agi::UserCancelException const&) {
|
|
|
|
throw;
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
2012-12-22 18:30:47 +01:00
|
|
|
catch (...) {
|
2013-01-04 16:01:50 +01:00
|
|
|
config::mru->Remove("Audio", url);
|
2012-12-22 18:30:47 +01:00
|
|
|
throw;
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
2012-05-02 02:31:38 +02:00
|
|
|
CloseAudio();
|
2013-06-08 06:19:40 +02:00
|
|
|
provider = std::move(new_provider);
|
2012-05-02 02:31:38 +02:00
|
|
|
|
2010-12-08 04:36:10 +01:00
|
|
|
try
|
|
|
|
{
|
2014-03-25 17:51:38 +01:00
|
|
|
player = AudioPlayerFactory::GetAudioPlayer(provider.get(), context->parent);
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
2013-06-08 06:19:40 +02:00
|
|
|
provider.reset();
|
2010-12-08 04:36:10 +01:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
2010-12-08 09:09:25 +01:00
|
|
|
audio_url = url;
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
config::mru->Add("Audio", url);
|
2011-09-28 21:51:18 +02:00
|
|
|
|
2011-11-30 05:28:03 +01:00
|
|
|
try
|
|
|
|
{
|
2013-06-08 06:19:40 +02:00
|
|
|
AnnounceAudioOpen(provider.get());
|
2011-11-30 05:28:03 +01:00
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
CloseAudio();
|
|
|
|
throw;
|
|
|
|
}
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::CloseAudio()
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
|
2013-06-08 06:19:40 +02:00
|
|
|
player.reset();
|
|
|
|
provider.reset();
|
2013-11-21 18:13:36 +01:00
|
|
|
player = nullptr;
|
|
|
|
provider = nullptr;
|
2010-12-08 04:36:10 +01:00
|
|
|
|
2010-12-08 09:09:25 +01:00
|
|
|
audio_url.clear();
|
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
config::path->SetToken("?audio", "");
|
2011-09-28 21:51:26 +02:00
|
|
|
|
2010-12-08 09:09:16 +01:00
|
|
|
AnnounceAudioClose();
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AudioController::IsAudioOpen() const
|
|
|
|
{
|
|
|
|
return player && provider;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::SetTimingController(AudioTimingController *new_controller)
|
|
|
|
{
|
2010-12-08 09:09:16 +01:00
|
|
|
if (timing_controller.get() != new_controller) {
|
|
|
|
timing_controller.reset(new_controller);
|
2011-11-18 23:58:22 +01:00
|
|
|
if (timing_controller)
|
|
|
|
{
|
|
|
|
timing_controller->AddUpdatedPrimaryRangeListener(&AudioController::OnTimingControllerUpdatedPrimaryRange, this);
|
|
|
|
}
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
2010-12-08 09:09:16 +01:00
|
|
|
|
|
|
|
AnnounceTimingControllerChanged();
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
2010-12-08 09:09:16 +01:00
|
|
|
void AudioController::OnTimingControllerUpdatedPrimaryRange()
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
if (playback_mode == PM_PrimaryRange)
|
2012-02-12 05:16:21 +01:00
|
|
|
player->SetEndPosition(SamplesFromMilliseconds(timing_controller->GetPrimaryPlaybackRange().end()));
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
2011-09-28 21:51:35 +02:00
|
|
|
void AudioController::OnSubtitlesSave()
|
|
|
|
{
|
|
|
|
if (IsAudioOpen())
|
2013-01-04 16:01:50 +01:00
|
|
|
context->ass->SetScriptInfo("Audio URI", config::path->MakeRelative(audio_url, "?script").generic_string());
|
2011-09-28 21:51:35 +02:00
|
|
|
else
|
|
|
|
context->ass->SetScriptInfo("Audio URI", "");
|
|
|
|
}
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
void AudioController::PlayRange(const TimeRange &range)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
player->Play(SamplesFromMilliseconds(range.begin()), SamplesFromMilliseconds(range.length()));
|
2010-12-08 04:36:10 +01:00
|
|
|
playback_mode = PM_Range;
|
|
|
|
playback_timer.Start(20);
|
|
|
|
|
2010-12-08 09:09:16 +01:00
|
|
|
AnnouncePlaybackPosition(range.begin());
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::PlayPrimaryRange()
|
|
|
|
{
|
|
|
|
PlayRange(GetPrimaryPlaybackRange());
|
|
|
|
if (playback_mode == PM_Range)
|
|
|
|
playback_mode = PM_PrimaryRange;
|
|
|
|
}
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
void AudioController::PlayToEndOfPrimary(int start_ms)
|
2011-12-27 03:23:04 +01:00
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
PlayRange(TimeRange(start_ms, GetPrimaryPlaybackRange().end()));
|
|
|
|
if (playback_mode == PM_Range)
|
|
|
|
playback_mode = PM_PrimaryRange;
|
2011-12-27 03:23:04 +01:00
|
|
|
}
|
2010-12-08 04:36:10 +01:00
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
void AudioController::PlayToEnd(int start_ms)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
int64_t start_sample = SamplesFromMilliseconds(start_ms);
|
2010-12-08 04:36:10 +01:00
|
|
|
player->Play(start_sample, provider->GetNumSamples()-start_sample);
|
|
|
|
playback_mode = PM_ToEnd;
|
|
|
|
playback_timer.Start(20);
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
AnnouncePlaybackPosition(start_ms);
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::Stop()
|
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
|
|
|
|
player->Stop();
|
|
|
|
playback_mode = PM_NotPlaying;
|
|
|
|
playback_timer.Stop();
|
|
|
|
|
2010-12-08 09:09:16 +01:00
|
|
|
AnnouncePlaybackStop();
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AudioController::IsPlaying()
|
|
|
|
{
|
|
|
|
return IsAudioOpen() && playback_mode != PM_NotPlaying;
|
|
|
|
}
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
int AudioController::GetPlaybackPosition()
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
if (!IsPlaying()) return 0;
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
return MillisecondsFromSamples(player->GetCurrentPosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
int AudioController::GetDuration() const
|
|
|
|
{
|
|
|
|
if (!provider) return 0;
|
|
|
|
|
|
|
|
return (provider->GetNumSamples() * 1000 + provider->GetSampleRate() - 1) / provider->GetSampleRate();
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
|
2012-02-02 00:58:58 +01:00
|
|
|
TimeRange AudioController::GetPrimaryPlaybackRange() const
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
2011-11-18 23:58:22 +01:00
|
|
|
if (timing_controller)
|
2010-12-08 04:36:10 +01:00
|
|
|
{
|
|
|
|
return timing_controller->GetPrimaryPlaybackRange();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-02 00:58:58 +01:00
|
|
|
return TimeRange(0, 0);
|
2010-12-08 04:36:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioController::SetVolume(double volume)
|
|
|
|
{
|
|
|
|
if (!IsAudioOpen()) return;
|
|
|
|
player->SetVolume(volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t AudioController::SamplesFromMilliseconds(int64_t ms) const
|
|
|
|
{
|
|
|
|
/// @todo There might be some subtle rounding errors here.
|
|
|
|
|
|
|
|
if (!provider) return 0;
|
|
|
|
|
|
|
|
int64_t sr = provider->GetSampleRate();
|
|
|
|
|
|
|
|
int64_t millisamples = ms * sr;
|
|
|
|
|
|
|
|
return (millisamples + 999) / 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
int64_t AudioController::MillisecondsFromSamples(int64_t samples) const
|
|
|
|
{
|
|
|
|
/// @todo There might be some subtle rounding errors here.
|
|
|
|
|
|
|
|
if (!provider) return 0;
|
|
|
|
|
|
|
|
int64_t sr = provider->GetSampleRate();
|
|
|
|
|
|
|
|
int64_t millisamples = samples * 1000;
|
|
|
|
|
|
|
|
return millisamples / sr;
|
|
|
|
}
|
2011-01-16 08:18:00 +01:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
void AudioController::SaveClip(agi::fs::path const& filename, TimeRange const& range) const
|
2011-01-16 08:18:00 +01:00
|
|
|
{
|
2012-02-02 00:58:58 +01:00
|
|
|
int64_t start_sample = SamplesFromMilliseconds(range.begin());
|
|
|
|
int64_t end_sample = SamplesFromMilliseconds(range.end());
|
|
|
|
if (filename.empty() || start_sample > provider->GetNumSamples() || range.length() == 0) return;
|
2011-01-16 08:18:00 +01:00
|
|
|
|
2013-01-04 16:01:50 +01:00
|
|
|
agi::io::Save outfile(filename, true);
|
2014-03-21 22:23:52 +01:00
|
|
|
std::ostream& out(outfile.Get());
|
2011-01-16 08:18:00 +01:00
|
|
|
|
|
|
|
size_t bytes_per_sample = provider->GetBytesPerSample() * provider->GetChannels();
|
2012-02-02 00:58:58 +01:00
|
|
|
size_t bufsize = (end_sample - start_sample) * bytes_per_sample;
|
2011-01-16 08:18:00 +01:00
|
|
|
|
|
|
|
int intval;
|
|
|
|
short shortval;
|
|
|
|
|
|
|
|
out << "RIFF";
|
|
|
|
out.write((char*)&(intval=bufsize+36),4);
|
|
|
|
out<< "WAVEfmt ";
|
|
|
|
out.write((char*)&(intval=16),4);
|
|
|
|
out.write((char*)&(shortval=1),2);
|
|
|
|
out.write((char*)&(shortval=provider->GetChannels()),2);
|
|
|
|
out.write((char*)&(intval=provider->GetSampleRate()),4);
|
|
|
|
out.write((char*)&(intval=provider->GetSampleRate()*provider->GetChannels()*provider->GetBytesPerSample()),4);
|
|
|
|
out.write((char*)&(intval=provider->GetChannels()*provider->GetBytesPerSample()),2);
|
|
|
|
out.write((char*)&(shortval=provider->GetBytesPerSample()<<3),2);
|
|
|
|
out << "data";
|
|
|
|
out.write((char*)&bufsize,4);
|
|
|
|
|
|
|
|
//samples per read
|
|
|
|
size_t spr = 65536 / bytes_per_sample;
|
|
|
|
std::vector<char> buf(bufsize);
|
2012-02-02 00:58:58 +01:00
|
|
|
for(int64_t i = start_sample; i < end_sample; i += spr) {
|
|
|
|
size_t len = std::min<size_t>(spr, end_sample - i);
|
2011-01-16 08:18:00 +01:00
|
|
|
provider->GetAudio(&buf[0], i, len);
|
|
|
|
out.write(&buf[0], len * bytes_per_sample);
|
|
|
|
}
|
|
|
|
}
|