MythTV  master
audioplayer.h
Go to the documentation of this file.
1 #ifndef AUDIOPLAYER_H
2 #define AUDIOPLAYER_H
3 
4 #include "mythplayerstate.h"
5 
6 #include <QCoreApplication>
7 #include <QRecursiveMutex>
8 
9 #include <cstdint>
10 #include <vector>
11 
12 class MythPlayer;
13 class AudioOutput;
14 struct AVCodecContext;
15 struct AVPacket;
16 
17 namespace MythTV
18 {
19  class Visual;
20 }
21 
22 class MTV_PUBLIC AudioPlayer : public QObject
23 {
24  Q_OBJECT
25 
26  signals:
27  void AudioPlayerStateChanged(MythAudioPlayerState State);
28 
29  public:
30  AudioPlayer(MythPlayer *parent, bool muted);
31  ~AudioPlayer() override;
32 
33  void addVisual(MythTV::Visual *vis);
34  void removeVisual(MythTV::Visual *vis);
35 
36  void Reset(void);
37  void DeleteOutput(void);
38  QString ReinitAudio(void);
39  void SetAudioOutput(AudioOutput *ao);
40  void SetAudioInfo(const QString &main_device,
41  const QString &passthru_device,
42  uint samplerate,
43  int codec_profile = -1);
44  void SetAudioParams(AudioFormat format, int orig_channels, int channels,
45  AVCodecID codec, int samplerate, bool passthru,
46  int codec_profile = -1);
47  void SetEffDsp(int dsprate);
48 
49  void CheckFormat(void);
50  void SetNoAudio(void) { m_noAudioOut = true; }
51  bool HasAudioIn(void) const { return !m_noAudioIn; }
52  bool HasAudioOut(void) const { return !m_noAudioOut; }
53  bool ControlsVolume(void) const { return m_controlsVolume; }
54 
55  bool Pause(bool pause);
56  bool IsPaused(void);
57  void PauseAudioUntilBuffered(void);
58  AVCodecID GetCodec(void) const { return m_state.m_codec; }
59  int GetOrigChannels(void) const { return m_state.m_origChannels; }
60  int GetSampleRate(void) const { return m_state.m_sampleRate; }
61  uint GetVolume(void);
62  uint AdjustVolume(int change);
63  uint SetVolume(int newvolume);
64  float GetStretchFactor(void) const { return m_stretchFactor; }
65  void SetStretchFactor(float factor);
66  bool IsUpmixing(void);
67  bool EnableUpmix(bool enable, bool toggle = false);
68  bool CanUpmix(void);
69  bool CanPassthrough(int samplerate, int channels, AVCodecID codec, int profile);
70  bool CanDownmix(void);
71  bool CanAC3(void);
72  bool CanDTS(void);
73  bool CanEAC3(void);
74  bool CanTrueHD(void);
75  bool CanDTSHD(void);
76  uint GetMaxChannels(void);
77  int GetMaxHDRate(void);
78  std::chrono::milliseconds GetAudioTime(void);
79  AudioFormat GetFormat(void) const { return m_state.m_format; }
80  bool CanProcess(AudioFormat fmt);
81  uint32_t CanProcess(void);
82  int DecodeAudio(AVCodecContext *ctx,
83  uint8_t *buffer, int &data_size,
84  const AVPacket *pkt);
85 
86  bool IsMuted(void) { return GetMuteState() == kMuteAll; }
87  bool SetMuted(bool mute);
88  MuteState GetMuteState(void);
89  MuteState SetMuteState(MuteState mstate);
90  MuteState IncrMuteState(void);
91 
92  void AddAudioData(char *buffer, int len, std::chrono::milliseconds timecode, int frames);
93  bool NeedDecodingBeforePassthrough(void);
94  std::chrono::milliseconds LengthLastData(void);
95  bool GetBufferStatus(uint &fill, uint &total);
96  bool IsBufferAlmostFull(void);
97  std::chrono::milliseconds GetAudioBufferedTime(void);
98 
102  AudioOutput *GetAudioOutput(void) const { return m_audioOutput; }
103 
104  private:
105  void AddVisuals(void);
106  void RemoveVisuals(void);
107  void ResetVisuals(void);
108 
109  private:
110  MythPlayer *m_parent {nullptr};
111  AudioOutput *m_audioOutput {nullptr};
112  MythAudioPlayerState m_state { };
113  float m_stretchFactor {1.0F};
114  QRecursiveMutex m_lock;
115  bool m_mutedOnCreation {false};
116  QString m_mainDevice;
118  bool m_noAudioIn {false};
119  bool m_noAudioOut {true};
120  bool m_controlsVolume {true};
121  std::vector<MythTV::Visual*> m_visuals;
122 };
123 
124 #endif // AUDIOPLAYER_H
mythplayerstate.h
AudioPlayer::SetNoAudio
void SetNoAudio(void)
Definition: audioplayer.h:50
AudioPlayer
Definition: audioplayer.h:22
AudioPlayer::HasAudioOut
bool HasAudioOut(void) const
Definition: audioplayer.h:52
AudioPlayer::m_mainDevice
QString m_mainDevice
Definition: audioplayer.h:116
MythPlayer
Definition: mythplayer.h:83
AudioPlayer::m_visuals
std::vector< MythTV::Visual * > m_visuals
Definition: audioplayer.h:121
AudioPlayer::ControlsVolume
bool ControlsVolume(void) const
Definition: audioplayer.h:53
AudioPlayer::GetOrigChannels
int GetOrigChannels(void) const
Definition: audioplayer.h:59
AudioPlayer::GetFormat
AudioFormat GetFormat(void) const
Definition: audioplayer.h:79
State
State
Definition: zmserver.h:68
AudioPlayer::m_lock
QRecursiveMutex m_lock
Definition: audioplayer.h:114
MythTV::Visual
Definition: visual.h:16
AudioOutput
Definition: audiooutput.h:25
MythTV
Definition: output.h:27
hardwareprofile.scan.profile
profile
Definition: scan.py:97
AudioPlayer::HasAudioIn
bool HasAudioIn(void) const
Definition: audioplayer.h:51
AudioPlayer::IsMuted
bool IsMuted(void)
Definition: audioplayer.h:86
MuteState
MuteState
Definition: volumebase.h:8
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
AudioPlayer::GetAudioOutput
AudioOutput * GetAudioOutput(void) const
Return internal AudioOutput object.
Definition: audioplayer.h:102
AudioPlayer::GetCodec
AVCodecID GetCodec(void) const
Definition: audioplayer.h:58
AudioPlayer::GetSampleRate
int GetSampleRate(void) const
Definition: audioplayer.h:60
AudioFormat
AudioFormat
Definition: audiooutputsettings.h:24
AudioPlayer::GetStretchFactor
float GetStretchFactor(void) const
Definition: audioplayer.h:64
AudioPlayer::m_passthruDevice
QString m_passthruDevice
Definition: audioplayer.h:117
kMuteAll
@ kMuteAll
Definition: volumebase.h:12
uint
unsigned int uint
Definition: freesurround.h:24
MythAudioPlayerState
Definition: mythplayerstate.h:31