Go to the documentation of this file.
9 #define LOC QString("AudioPlayer: ")
15 m_mutedOnCreation(muted)
31 QMutexLocker lock(&
m_lock);
45 QMutexLocker lock(&
m_lock);
59 QMutexLocker lock(&
m_lock);
69 QMutexLocker lock(&
m_lock);
79 QMutexLocker lock(&
m_lock);
89 QMutexLocker lock(&
m_lock);
96 QMutexLocker locker(&
m_lock);
109 QMutexLocker lock(&
m_lock);
130 errMsg = tr(
"Unable to create AudioOutput.");
148 if (!errMsg.isEmpty())
150 LOG(VB_GENERAL, LOG_NOTICE,
LOC +
"Disabling Audio" +
151 QString(
", reason is: %1").arg(errMsg));
153 AudioPlayer::tr(
"Audio Player" ), errMsg);
158 LOG(VB_GENERAL, LOG_NOTICE,
LOC +
"Enabling Audio");
184 QMutexLocker lock(&
m_lock);
193 QMutexLocker lock(&
m_lock);
201 QMutexLocker lock(&
m_lock);
219 QMutexLocker lock(&
m_lock);
228 const QString &passthru_device,
234 if (!main_device.isEmpty())
236 if (!passthru_device.isEmpty())
248 int channels, AVCodecID codec,
249 int samplerate,
bool passthru,
267 QMutexLocker lock(&
m_lock);
274 QMutexLocker lock(&
m_lock);
279 LOG(VB_AUDIO, LOG_INFO, QString(
"muting sound %1").arg(
IsMuted()));
285 LOG(VB_AUDIO, LOG_INFO, QString(
"unmuting sound %1").arg(
IsMuted()));
289 LOG(VB_AUDIO, LOG_ERR,
290 QString(
"not changing sound mute state %1").arg(
IsMuted()));
299 QMutexLocker lock(&
m_lock);
314 QMutexLocker lock(&
m_lock);
322 QMutexLocker lock(&
m_lock);
331 QMutexLocker lock(&
m_lock);
340 QMutexLocker lock(&
m_lock);
348 QMutexLocker lock(&
m_lock);
356 QMutexLocker lock(&
m_lock);
366 QMutexLocker lock(&
m_lock);
375 QMutexLocker lock(&
m_lock);
451 std::chrono::milliseconds timecode,
int frames)
463 if (frames == 0 && len > 0)
464 frames = len / samplesize;
467 LOG(VB_PLAYBACK, LOG_ERR,
LOC +
"AddAudioData(): "
468 "Audio buffer overflow, audio data lost!");
500 uint othresh = ((ototal>>1) + (ototal>>2));
539 uint8_t *buffer,
int &data_size,
QString GetError(void) const
void addVisual(MythTV::Visual *v)
void addVisual(MythTV::Visual *vis)
virtual bool AddData(void *buffer, int len, std::chrono::milliseconds timecode, int frames)=0
Add data to the audiobuffer for playback.
virtual void SetCurrentVolume(int value)
void SetEffDsp(int dsprate)
AudioOutput * m_audioOutput
void ShowNotificationError(const QString &msg, const QString &from, const QString &detail, const VNMask visibility, const MythNotification::Priority priority)
convenience utility to display error message as notification
virtual void AdjustCurrentVolume(int change)
QString ReinitAudio(void)
virtual uint GetCurrentVolume(void) const
virtual void Reset(void)=0
virtual bool PrepareAudioSample(std::chrono::milliseconds &timecode)
bool EnableUpmix(bool enable, bool toggle=false)
void AudioPlayerStateChanged(MythAudioPlayerState State)
virtual int GetBytesPerFrame(void) const
virtual MuteState SetMuteState(MuteState)
void SetStretchFactor(float factor)
MuteState SetMuteState(MuteState mstate)
virtual bool NeedDecodingBeforePassthrough(void) const
bool IsBufferAlmostFull(void)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MuteState GetMuteState(void)
void removeVisual(MythTV::Visual *v)
std::vector< MythTV::Visual * > m_visuals
virtual std::chrono::milliseconds LengthLastData(void) const
void AddAudioData(char *buffer, int len, std::chrono::milliseconds timecode, int frames)
virtual bool CanDownmix(void) const
static AudioOutput * OpenAudio(const QString &main_device, const QString &passthru_device, AudioFormat format, int channels, AVCodecID codec, int samplerate, AudioOutputSource source, bool set_initial_vol, bool passthru, int upmixer_startup=0, AudioOutputSettings *custom=nullptr)
virtual bool CanProcess(AudioFormat fmt)
virtual bool CanUpmix(void)
virtual std::chrono::milliseconds GetAudioBufferedTime(void)
report amount of audio buffered in milliseconds.
virtual void Drain(void)=0
void SetAudioInfo(const QString &main_device, const QString &passthru_device, uint samplerate, int codec_profile=-1)
Set audio output device parameters.
virtual bool CanPassthrough(int samplerate, int channels, AVCodecID codec, int profile) const
uint SetVolume(int newvolume)
bool TestDigitalFeature(AudioOutput *ao, DigitalFeature feature)
bool m_init
If set to false, AudioOutput instance will not try to initially open the audio device.
int DecodeAudio(AVCodecContext *ctx, uint8_t *buffer, int &data_size, const AVPacket *pkt)
DecodeAudio Utility routine.
virtual void Pause(bool paused)=0
int GetMaxHDRate() const
return the highest iec958 rate supported.
AudioPlayer(MythPlayer *parent, bool muted)
static const std::array< featureStruct, 7 > feature
void SetAudioParams(AudioFormat format, int orig_channels, int channels, AVCodecID codec, int samplerate, bool passthru, int codec_profile=-1)
Set audio output parameters.
int BestSupportedChannels()
uint AdjustVolume(int change)
std::chrono::milliseconds LengthLastData(void)
bool CanPassthrough(int samplerate, int channels, AVCodecID codec, int profile)
virtual MuteState GetMuteState(void) const
MuteState IncrMuteState(void)
static MuteState NextMuteState(MuteState)
virtual int DecodeAudio(AVCodecContext *ctx, uint8_t *buffer, int &data_size, const AVPacket *pkt)
Utility routine.
bool GetBufferStatus(uint &fill, uint &total)
virtual void SetEffDsp(int dsprate)=0
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
virtual std::chrono::milliseconds GetAudiotime(void)=0
void SetAudioOutput(AudioOutput *ao)
bool GetBoolSetting(const QString &key, bool defaultval=false)
uint GetMaxChannels(void)
void removeVisual(MythTV::Visual *vis)
MythAudioPlayerState m_state
std::chrono::milliseconds GetAudioBufferedTime(void)
bool NeedDecodingBeforePassthrough(void)
virtual void Reconfigure(const AudioSettings &settings)=0
virtual void GetBufferStatus(uint &fill, uint &total)
virtual void SetStretchFactor(float factor)
virtual bool IsUpmixing(void)
uint32_t CanProcess(void)
void PauseAudioUntilBuffered(void)
virtual AudioOutputSettings * GetOutputSettingsUsers(bool digital=true)
std::chrono::milliseconds GetAudioTime(void)
virtual bool ToggleUpmix(void)
virtual void PauseUntilBuffered(void)=0
virtual bool IsPaused(void) const =0
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)