#include "third_party/blink/renderer/modules/mediastream/track_audio_renderer.h"
#include <utility>
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "base/trace_event/trace_event.h"
#include "media/audio/audio_sink_parameters.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_latency.h"
#include "media/base/audio_shifter.h"
#include "third_party/blink/public/platform/modules/mediastream/web_media_stream_track.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/web/web_local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_audio_track.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_copier_base.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
namespace WTF {
template <>
struct CrossThreadCopier<media::AudioParameters> { … };
}
namespace blink {
namespace {
base::TimeDelta ComputeTotalElapsedRenderTime(
base::TimeDelta prior_elapsed_render_time,
int64_t num_samples_rendered,
int sample_rate) { … }
WebLocalFrame* ToWebLocalFrame(LocalFrame* frame) { … }
bool RequiresSinkReconfig(const media::AudioParameters& old_format,
const media::AudioParameters& new_format) { … }
}
TrackAudioRenderer::PendingData::PendingData(const media::AudioBus& audio_bus,
base::TimeTicks ref_time)
: … { … }
TrackAudioRenderer::PendingReconfig::PendingReconfig(
const media::AudioParameters& format,
int reconfig_number)
: … { … }
int TrackAudioRenderer::Render(base::TimeDelta delay,
base::TimeTicks delay_timestamp,
const media::AudioGlitchInfo& glitch_info,
media::AudioBus* audio_bus) { … }
void TrackAudioRenderer::OnRenderErrorCrossThread() { … }
void TrackAudioRenderer::OnRenderError() { … }
void TrackAudioRenderer::OnData(const media::AudioBus& audio_bus,
base::TimeTicks reference_time) { … }
void TrackAudioRenderer::OnSetFormat(const media::AudioParameters& params) { … }
TrackAudioRenderer::TrackAudioRenderer(
MediaStreamComponent* audio_component,
LocalFrame& playout_frame,
const String& device_id,
base::RepeatingClosure on_render_error_callback)
: … { … }
TrackAudioRenderer::~TrackAudioRenderer() { … }
void TrackAudioRenderer::Start() { … }
void TrackAudioRenderer::Stop() { … }
void TrackAudioRenderer::Play() { … }
void TrackAudioRenderer::Pause() { … }
void TrackAudioRenderer::SetVolume(float volume) { … }
base::TimeDelta TrackAudioRenderer::GetCurrentRenderTime() { … }
void TrackAudioRenderer::SwitchOutputDevice(
const std::string& device_id,
media::OutputDeviceStatusCB callback) { … }
void TrackAudioRenderer::MaybeStartSink(bool reconfiguring) { … }
void TrackAudioRenderer::ReconfigureSink(
const media::AudioParameters new_format,
int reconfig_number) { … }
void TrackAudioRenderer::CreateAudioShifter(bool reconfiguring) { … }
void TrackAudioRenderer::HaltAudioFlow_Locked() { … }
void TrackAudioRenderer::ConsumePendingReconfigsFront_Locked() { … }
void TrackAudioRenderer::PushDataIntoShifter_Locked(
std::unique_ptr<media::AudioBus> data,
base::TimeTicks reference_time) { … }
int TrackAudioRenderer::TotalFramesPushedForTesting() const { … }
int TrackAudioRenderer::FramesInAudioShifterForTesting() const { … }
}