Shaka Player Embedded
Public Member Functions | Protected Member Functions | Friends | List of all members
shaka::media::AudioRendererCommon Class Referenceabstract

#include <audio_renderer_common.h>

Inheritance diagram for shaka::media::AudioRendererCommon:
shaka::media::AudioRenderer shaka::media::MediaPlayer::Client shaka::media::Renderer shaka::media::AppleAudioRenderer::Impl shaka::media::SdlAudioRenderer::Impl

Public Member Functions

 AudioRendererCommon ()
 
 ~AudioRendererCommon () override
 
void SetPlayer (const MediaPlayer *player) override
 
void Attach (const DecodedStream *stream) override
 
void Detach () override
 
double Volume () const override
 
void SetVolume (double volume) override
 
bool Muted () const override
 
void SetMuted (bool muted) override
 
- Public Member Functions inherited from shaka::media::Renderer
 Renderer ()
 
virtual ~ Renderer ()
 
 Renderer (const Renderer &)=delete
 
Rendereroperator= (const Renderer &)=delete
 
 Renderer (Renderer &&)=delete
 
Rendereroperator= (Renderer &&)=delete
 

Protected Member Functions

void Stop ()
 

Friends

class AudioRendererCommonTest
 

Detailed Description

Holds common code between our AudioRenderer types. This handles time tracking, choosing the correct frames, and A/V sync. The derived class must implement the pure-virtual functions to interact with the audio device.

An audio device is something that plays from a single buffer of samples. Samples are appended to the end of the buffer and are played at a constant rate (i.e. the sample rate). We fill the buffer ahead of what is actually being played, so we need to predict which frames need to be played. This class handles the synchronization and predictions, the derived classes handle how to talk to the device.

When we are paused or seek, we need to resynchronize. This will pick the current frame based on the current time and start filling there. From that point forward, we will just append new frames sequentially. This will also handle the unlikely case of not having enough data or too much data to match the frame times.

This renderer only supports playing content the audio device natively supports. This cannot convert to a different sample format.

This type is fully thread-safe; all the pure-virtual methods are called with a lock held, so derived classes do not need to use locks.

Definition at line 56 of file audio_renderer_common.h.

Constructor & Destructor Documentation

§ AudioRendererCommon()

shaka::media::AudioRendererCommon::AudioRendererCommon ( )

Definition at line 100 of file audio_renderer_common.cc.

§ ~AudioRendererCommon()

shaka::media::AudioRendererCommon::~AudioRendererCommon ( )
override

Definition at line 113 of file audio_renderer_common.cc.

Member Function Documentation

§ Attach()

void shaka::media::AudioRendererCommon::Attach ( const DecodedStream stream)
overridevirtual

Attaches to the given stream. This object will now pull full-frames from the given stream to play content. The stream will live as long as this object, or until a call to Detach.

Parameters
streamThe stream to pull frames from.

Implements shaka::media::Renderer.

Definition at line 133 of file audio_renderer_common.cc.

§ Detach()

void shaka::media::AudioRendererCommon::Detach ( )
overridevirtual

Detaches playback from the current stream. The current stream will no longer be used to play content.

Implements shaka::media::Renderer.

Reimplemented in shaka::media::SdlAudioRenderer::Impl.

Definition at line 141 of file audio_renderer_common.cc.

§ Muted()

bool shaka::media::AudioRendererCommon::Muted ( ) const
overridevirtual
Returns
Whether the audio is muted.

Implements shaka::media::AudioRenderer.

Definition at line 158 of file audio_renderer_common.cc.

§ SetMuted()

void shaka::media::AudioRendererCommon::SetMuted ( bool  muted)
overridevirtual

Sets whether the audio is muted.

Implements shaka::media::AudioRenderer.

Definition at line 163 of file audio_renderer_common.cc.

§ SetPlayer()

void shaka::media::AudioRendererCommon::SetPlayer ( const MediaPlayer player)
overridevirtual

Sets the MediaPlayer that is controlling this renderer. This will be used by the Renderer to query the current time and playback state.

Parameters
playerThe MediaPlayer instance controlling this object.

Implements shaka::media::Renderer.

Definition at line 120 of file audio_renderer_common.cc.

§ SetVolume()

void shaka::media::AudioRendererCommon::SetVolume ( double  volume)
overridevirtual

Sets the volume [0, 1] to render audio at.

Implements shaka::media::AudioRenderer.

Definition at line 152 of file audio_renderer_common.cc.

§ Stop()

void shaka::media::AudioRendererCommon::Stop ( )
protected

Stops the internal thread. This needs to be called in the derived class' destructor so this doesn't try to reset the device while destroying.

Definition at line 169 of file audio_renderer_common.cc.

§ Volume()

double shaka::media::AudioRendererCommon::Volume ( ) const
overridevirtual
Returns
The current volume [0, 1].

Implements shaka::media::AudioRenderer.

Definition at line 147 of file audio_renderer_common.cc.

Friends And Related Function Documentation

§ AudioRendererCommonTest

friend class AudioRendererCommonTest
friend

Definition at line 153 of file audio_renderer_common.h.


The documentation for this class was generated from the following files: