MythTV  master
mythplayeraudioui.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythcorecontext.h"
3 #include "tv_play.h"
4 #include "audioplayer.h"
5 #include "mythmainwindow.h"
6 #include "mythplayeraudioui.h"
7 
8 #define LOC QString("PlayerAudio: ")
9 
32  : MythPlayerOverlayUI(MainWindow, Tv, Context, Flags)
33 {
34  // Register our types for signal usage
35  qRegisterMetaType<MythAudioPlayerState>();
36  qRegisterMetaType<MythAudioState>();
37 
38  // Setup audio graph
40 
41  // Connect incoming signals
49 
50  // Connect outgoing signals
53 
54  // Setup
57 }
58 
61 {
62  LOG(VB_GENERAL, LOG_INFO, LOC + "Initialising audio");
63  ReinitAudio();
65 }
66 
68 {
70 }
71 
73 {
74  m_audio.Reset();
76 }
77 
79 {
80  (void)m_audio.ReinitAudio();
82 }
83 
85 {
86  return m_audioGraph;
87 }
88 
89 void MythPlayerAudioUI::SetupAudioGraph(double VideoFrameRate)
90 {
91  uint samplerate = static_cast<uint>(m_audio.GetSampleRate());
92  m_audioGraph.SetSampleRate(samplerate);
93  m_audioGraph.SetSampleCount(static_cast<unsigned>(samplerate / VideoFrameRate));
95 }
96 
98 {
101 }
102 
103 void MythPlayerAudioUI::ChangeVolume(bool Direction, int Volume)
104 {
105  uint oldvolume = m_audio.GetVolume();
106 
107  if (Volume < 0)
108  m_audio.AdjustVolume(Direction ? 2 : -2);
109  else
110  m_audio.SetVolume(Volume);
111 
112  if (!(m_browsing || m_editing))
113  {
114  uint volume = m_audio.GetVolume();
115  UpdateOSDStatus(tr("Adjust Volume"), tr("Volume"), QString::number(volume),
116  kOSDFunctionalType_PictureAdjust, "%", static_cast<int>(volume * 10),
119  }
120 
121  if (m_audio.GetVolume() != oldvolume)
123 }
124 
125 void MythPlayerAudioUI::ChangeMuteState(bool CycleChannels)
126 {
128  return;
129 
130  MuteState oldstate = m_audio.GetMuteState();
131 
132  if (CycleChannels)
134  else
136 
137  QString text;
138  MuteState mute = m_audio.GetMuteState();
139  switch (mute)
140  {
141  case kMuteOff: text = tr("Mute Off"); break;
142  case kMuteAll: text = tr("Mute On"); break;
143  case kMuteLeft: text = tr("Left Channel Muted"); break;
144  case kMuteRight: text = tr("Right Channel Muted"); break;
145  }
146 
147  UpdateOSDMessage(text);
148 
149  if (m_audio.GetMuteState() != oldstate)
151 }
152 
153 void MythPlayerAudioUI::EnableUpmix(bool Enable, bool Toggle)
154 {
155  if (!m_audio.HasAudioOut())
156  return;
157 
158  bool oldupmixing = m_audio.IsUpmixing();
159  m_audio.EnableUpmix(Enable, Toggle);
161  bool newupmixing = m_audio.IsUpmixing();
162 
163  UpdateOSDMessage(newupmixing ? tr("Upmixer On") : tr("Upmixer Off"));
164 
165  if (newupmixing != oldupmixing)
167 }
168 
170 {
172 }
173 
175 {
176  QString passthru = gCoreContext->GetBoolSetting("PassThruDeviceOverride", false) ?
177  gCoreContext->GetSetting("PassThruOutputDevice") : QString();
178  m_audio.SetAudioInfo(gCoreContext->GetSetting("AudioOutputDevice"), passthru,
179  static_cast<uint>(gCoreContext->GetNumSetting("AudioSampleRate", 44100)));
181 }
182 
183 void MythPlayerAudioUI::AdjustAudioTimecodeOffset(int64_t Delta, int Value)
184 {
185  int64_t oldwrap = m_tcWrap[TC_AUDIO];
186 
187  if ((Value >= -1000) && (Value <= 1000))
188  m_tcWrap[TC_AUDIO] = Value;
189  else
190  m_tcWrap[TC_AUDIO] += Delta;
191 
192  int64_t newwrap = m_tcWrap[TC_AUDIO];
193  if (!(m_browsing || m_editing))
194  {
195  UpdateOSDStatus(tr("Adjust Audio Sync"), tr("Audio Sync"),
196  QString::number(newwrap), kOSDFunctionalType_AudioSyncAdjust,
197  "ms", (static_cast<int>(newwrap) / 2) + 500, kOSDTimeout_None);
199  }
200 
201  if (newwrap != oldwrap)
202  emit AudioStateChanged({ &m_audio, newwrap });
203 }
204 
MythPlayerAudioUI::EnableUpmix
void EnableUpmix(bool Enable, bool Toggle=false)
Definition: mythplayeraudioui.cpp:153
AudioPlayer::addVisual
void addVisual(MythTV::Visual *vis)
Definition: audioplayer.cpp:25
TVPlaybackState::AudioPlayerStateChanged
void AudioPlayerStateChanged(const MythAudioPlayerState &AudioPlayerState)
Definition: tvplaybackstate.cpp:23
MythPlayerAudioUI::MythPlayerAudioUI
MythPlayerAudioUI(MythMainWindow *MainWindow, TV *Tv, PlayerContext *Context, PlayerFlags Flags)
Definition: mythplayeraudioui.cpp:30
AudioPlayer::Reset
void Reset(void)
Definition: audioplayer.cpp:83
MythPlayerAudioUI::m_audioGraph
AudioOutputGraph m_audioGraph
Definition: mythplayeraudioui.h:40
MythPlayerAudioUI::SetupAudioGraph
void SetupAudioGraph(double VideoFrameRate)
Definition: mythplayeraudioui.cpp:89
AudioPlayer::ReinitAudio
QString ReinitAudio(void)
Definition: audioplayer.cpp:104
kMuteRight
@ kMuteRight
Definition: volumebase.h:9
AudioOutputGraph::SetSampleRate
void SetSampleRate(unsigned sample_rate)
Definition: audiooutputgraph.cpp:225
AudioOutputGraph
Definition: audiooutputgraph.h:14
MythPlayerAudioUI::ClearAudioGraph
void ClearAudioGraph()
Definition: mythplayeraudioui.cpp:97
TimeStretch
Definition: playgroup.cpp:94
AudioPlayer::EnableUpmix
bool EnableUpmix(bool enable, bool toggle=false)
Definition: audioplayer.cpp:351
AudioPlayer::AudioPlayerStateChanged
void AudioPlayerStateChanged(MythAudioPlayerState State)
mythplayeraudioui.h
AudioPlayer::GetVolume
uint GetVolume(void)
Definition: audioplayer.cpp:214
AudioPlayer::SetStretchFactor
void SetStretchFactor(float factor)
Definition: audioplayer.cpp:369
Context
QHash< QString, Action * > Context
Definition: action.h:77
MythPlayerAudioUI::PauseAudioUntilBuffered
void PauseAudioUntilBuffered()
Definition: mythplayeraudioui.cpp:169
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
AudioPlayer::HasAudioOut
bool HasAudioOut(void) const
Definition: audioplayer.h:54
PlayerFlags
PlayerFlags
Definition: mythplayer.h:62
MythPlayerUIBase::InitialiseState
virtual void InitialiseState()
Definition: mythplayeruibase.cpp:22
kOSDTimeout_None
@ kOSDTimeout_None
Definition: osd.h:59
AudioPlayer::SetMuted
bool SetMuted(bool mute)
Definition: audioplayer.cpp:270
AudioPlayer::GetMuteState
MuteState GetMuteState(void)
Definition: audioplayer.cpp:309
AudioOutputGraph::SetPainter
void SetPainter(MythPainter *)
Definition: audiooutputgraph.cpp:219
AudioPlayer::ControlsVolume
bool ControlsVolume(void) const
Definition: audioplayer.h:55
MythPlayerAudioUI::AdjustAudioTimecodeOffset
void AdjustAudioTimecodeOffset(int64_t Delta, int Value)
Definition: mythplayeraudioui.cpp:183
MuteState
MuteState
Definition: volumebase.h:6
AudioPlayer::SetAudioInfo
void SetAudioInfo(const QString &main_device, const QString &passthru_device, uint samplerate, int codec_profile=-1)
Set audio output device parameters.
Definition: audioplayer.cpp:226
MythPlayer::m_audio
AudioPlayer m_audio
Definition: mythplayer.h:477
MythPlayerOverlayUI::UpdateOSDMessage
void UpdateOSDMessage(const QString &Message)
Definition: mythplayeroverlayui.cpp:71
AudioOutputGraph::Reset
void Reset()
Definition: audiooutputgraph.cpp:253
AudioPlayer::SetVolume
uint SetVolume(int newvolume)
Definition: audioplayer.cpp:326
MythPlayerOverlayUI
Definition: mythplayeroverlayui.h:8
MythPlayerAudioUI::InitialiseState
void InitialiseState() override
Initialise audio and signal initial state.
Definition: mythplayeraudioui.cpp:60
LOC
#define LOC
Definition: mythplayeraudioui.cpp:8
MythPlayer::m_tcWrap
tctype_arr m_tcWrap
Definition: mythplayer.h:499
MythPlayerAudioUI::AudioStateChanged
void AudioStateChanged(MythAudioState State)
MythPlayerAudioUI::ResetAudio
void ResetAudio()
Definition: mythplayeraudioui.cpp:72
AudioPlayer::AdjustVolume
uint AdjustVolume(int change)
Definition: audioplayer.cpp:317
MythPlayerOverlayUI::ChangeOSDPositionUpdates
void ChangeOSDPositionUpdates(bool Enable)
Definition: mythplayeroverlayui.cpp:38
MythPlayerOverlayUI::m_editing
bool m_editing
Definition: mythplayeroverlayui.h:46
MythPlayerUIBase::m_painter
MythPainter * m_painter
Definition: mythplayeruibase.h:17
AudioPlayer::IsUpmixing
bool IsUpmixing(void)
Definition: audioplayer.cpp:343
AudioPlayer::IncrMuteState
MuteState IncrMuteState(void)
Definition: audioplayer.cpp:302
TVPlaybackState::AudioStateChanged
void AudioStateChanged(const MythAudioState &AudioState)
Definition: tvplaybackstate.cpp:28
MythPlayerOverlayUI::m_browsing
bool m_browsing
Definition: mythplayeroverlayui.h:45
TVPlaybackState::ResetAudio
void ResetAudio()
AudioPlayer::IsMuted
bool IsMuted(void)
Definition: audioplayer.h:88
kMuteLeft
@ kMuteLeft
Definition: volumebase.h:8
kMuteOff
@ kMuteOff
Definition: volumebase.h:7
uint
unsigned int uint
Definition: compat.h:141
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:933
MythPlayerAudioUI::GetAudioGraph
const AudioOutputGraph & GetAudioGraph() const
Definition: mythplayeraudioui.cpp:84
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:927
AudioPlayer::removeVisual
void removeVisual(MythTV::Visual *vis)
Definition: audioplayer.cpp:39
kOSDFunctionalType_AudioSyncAdjust
@ kOSDFunctionalType_AudioSyncAdjust
Definition: osd.h:51
TVPlaybackState::ChangeUpmix
void ChangeUpmix(bool Enable, bool Toggle=false)
mythcorecontext.h
AudioPlayer::GetSampleRate
int GetSampleRate(void) const
Definition: audioplayer.h:62
kOSDFunctionalType_PictureAdjust
@ kOSDFunctionalType_PictureAdjust
Definition: osd.h:48
TC_AUDIO
@ TC_AUDIO
Definition: mythplayer.h:54
MythPlayerAudioUI::ReinitAudio
void ReinitAudio()
Definition: mythplayeraudioui.cpp:78
MythPlayerAudioUI::ChangeMuteState
void ChangeMuteState(bool CycleChannels)
Definition: mythplayeraudioui.cpp:125
MythPlayerUIBase::m_tv
TV * m_tv
Definition: mythplayeruibase.h:15
TVPlaybackState::ChangeMuteState
void ChangeMuteState(bool CycleChannels=false)
MythPlayerAudioUI::RefreshAudioState
void RefreshAudioState()
Definition: mythplayeraudioui.cpp:67
PlayerContext
Definition: playercontext.h:49
audioplayer.h
MythPlayerOverlayUI::UpdateOSDStatus
void UpdateOSDStatus(osdInfo &Info, int Type, enum OSDTimeout Timeout)
Definition: mythplayeroverlayui.cpp:96
MythPlayer::ForceSetupAudioStream
void ForceSetupAudioStream(void)
Definition: mythplayer.cpp:2011
MythPlayerAudioUI::SetupAudioOutput
void SetupAudioOutput(float TimeStretch)
Definition: mythplayeraudioui.cpp:174
TVPlaybackState::ChangeAudioOffset
void ChangeAudioOffset(int64_t Delta, int Value=-9999)
TVPlaybackState::ChangeVolume
void ChangeVolume(bool Direction, int Volume)
kMuteAll
@ kMuteAll
Definition: volumebase.h:10
AudioPlayer::PauseAudioUntilBuffered
void PauseAudioUntilBuffered(void)
Definition: audioplayer.cpp:196
mythmainwindow.h
AudioOutputGraph::SetSampleCount
void SetSampleCount(unsigned sample_count)
Definition: audiooutputgraph.cpp:234
TVPlaybackState::PauseAudioUntilReady
void PauseAudioUntilReady()
kOSDTimeout_Med
@ kOSDTimeout_Med
Definition: osd.h:61
MythPlayerAudioUI::ChangeVolume
void ChangeVolume(bool Direction, int Volume)
Definition: mythplayeraudioui.cpp:103
MythMainWindow
Definition: mythmainwindow.h:35
TVPlaybackState::ReinitAudio
void ReinitAudio()
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:919
tv_play.h
TV
Control TV playback.
Definition: tv_play.h:153