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