MythTV  master
audioreencodebuffer.h
Go to the documentation of this file.
1 #ifndef AUDIOREENCODEBUFFER_H
2 #define AUDIOREENCODEBUFFER_H
3 
5 #include "libmythbase/mythconfig.h"
6 
7 static constexpr size_t ABLOCK_SIZE { 8192 };
8 
10 {
11  public:
12  AudioBuffer();
13  AudioBuffer(const AudioBuffer &old);
14  ~AudioBuffer();
15 
16  void appendData(unsigned char *buffer, int len, int frames, std::chrono::milliseconds time);
17  char *data(void) const { return (char *)m_buffer; }
18  int size(void) const { return m_size; }
19 
20  uint8_t *m_buffer {nullptr};
21  size_t m_size {0};
23  int m_frames {0};
24  std::chrono::milliseconds m_time {-1ms};
25 };
26 
32 {
33  public:
34  AudioReencodeBuffer(AudioFormat audio_format, int audio_channels,
35  bool passthru);
36  ~AudioReencodeBuffer() override;
37 
38  void Reconfigure(const AudioSettings &settings) override; // AudioOutput
39  void SetEffDsp(int dsprate) override; // AudioOutput
40  void Reset(void) override; // AudioOutput
41  bool AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode) override; // AudioOutput
42  bool AddData(void *buffer, int len, std::chrono::milliseconds timecode,
43  int frames) override; // AudioOutput
44  AudioBuffer *GetData(std::chrono::milliseconds time);
45  long long GetSamples(std::chrono::milliseconds time);
46  void SetTimecode(std::chrono::milliseconds timecode) override; // AudioOutput
47  bool IsPaused(void) const override { return false; } // AudioOutput
48  void Pause(bool paused) override { (void)paused; } // AudioOutput
49  void PauseUntilBuffered(void) override { } // AudioOutput
50  void Drain(void) override { } // AudioOutput
51  std::chrono::milliseconds GetAudiotime(void) override { return m_last_audiotime; } // AudioOutput
52  int GetVolumeChannel(int /*channel*/) const override { return 100; } // VolumeBase
53  void SetVolumeChannel(int /*channel*/, int /*volume*/) override { } // VolumeBase
54  uint GetCurrentVolume(void) const override { return 100; } // VolumeBase
55  void SetCurrentVolume(int /*value*/) override { } // VolumeBase
56  void AdjustCurrentVolume(int /*change*/) override { } // VolumeBase
57  virtual void SetMute(bool /*mute */) { }
58  void ToggleMute(void) override { } // VolumeBase
59  MuteState GetMuteState(void) const override { return kMuteOff; } // VolumeBase
60  virtual MuteState IterateMutedChannels(void) { return kMuteOff; }
61  void SetSWVolume(int /*new_volume*/, bool /*save*/) override { } // VolumeBase
62  int GetSWVolume(void) override { return 100; } // VolumeBase
63  bool CanPassthrough(int /*samplerate*/, int /*channels*/, AVCodecID /*codec*/, int /*profile*/) const override // AudioOutput
64  { return m_initpassthru; }
65 
66  // These are pure virtual in AudioOutput, but we don't need them here
67  void bufferOutputData(bool /*y*/) override { } // AudioOutput
68  int readOutputData(unsigned char */*read_buffer*/,
69  size_t /*max_length*/) override { return 0; } // AudioOutput
70 
71  int m_channels {-1};
73  int m_eff_audiorate {-1};
74  std::chrono::milliseconds m_last_audiotime {0ms};
75  bool m_passthru {false};
77 
78  private:
79  bool m_initpassthru {false};
80  QMutex m_bufferMutex;
81  QList<AudioBuffer *> m_bufferList;
83 };
84 
85 #endif
86 /* vim: set expandtab tabstop=4 shiftwidth=4: */
87 
AudioBuffer::appendData
void appendData(unsigned char *buffer, int len, int frames, std::chrono::milliseconds time)
Definition: audioreencodebuffer.cpp:37
AudioReencodeBuffer::~AudioReencodeBuffer
~AudioReencodeBuffer() override
Definition: audioreencodebuffer.cpp:73
AudioBuffer::m_buffer
uint8_t * m_buffer
Definition: audioreencodebuffer.h:20
AudioReencodeBuffer
This class is to act as a fake audio output device to store the data for reencoding.
Definition: audioreencodebuffer.h:31
AudioReencodeBuffer::m_eff_audiorate
int m_eff_audiorate
Definition: audioreencodebuffer.h:73
AudioReencodeBuffer::AudioReencodeBuffer
AudioReencodeBuffer(AudioFormat audio_format, int audio_channels, bool passthru)
Definition: audioreencodebuffer.cpp:64
AudioBuffer::m_size
size_t m_size
Definition: audioreencodebuffer.h:21
AudioReencodeBuffer::SetCurrentVolume
void SetCurrentVolume(int) override
Definition: audioreencodebuffer.h:55
AudioReencodeBuffer::bufferOutputData
void bufferOutputData(bool) override
Definition: audioreencodebuffer.h:67
AudioReencodeBuffer::SetVolumeChannel
void SetVolumeChannel(int, int) override
Definition: audioreencodebuffer.h:53
MuteState
MuteState
Definition: volumebase.h:6
AudioSettings
Definition: audiosettings.h:28
AudioOutput
Definition: audiooutput.h:26
AudioBuffer::m_time
std::chrono::milliseconds m_time
Definition: audioreencodebuffer.h:24
AudioReencodeBuffer::GetMuteState
MuteState GetMuteState(void) const override
Definition: audioreencodebuffer.h:59
AudioReencodeBuffer::Reconfigure
void Reconfigure(const AudioSettings &settings) override
reconfigure sound out for new params
Definition: audioreencodebuffer.cpp:82
AudioBuffer::~AudioBuffer
~AudioBuffer()
Definition: audioreencodebuffer.cpp:32
AudioReencodeBuffer::GetData
AudioBuffer * GetData(std::chrono::milliseconds time)
Definition: audioreencodebuffer.cpp:202
AudioReencodeBuffer::m_bytes_per_frame
int m_bytes_per_frame
Definition: audioreencodebuffer.h:72
AudioReencodeBuffer::m_saveBuffer
AudioBuffer * m_saveBuffer
Definition: audioreencodebuffer.h:82
AudioReencodeBuffer::SetEffDsp
void SetEffDsp(int dsprate) override
Definition: audioreencodebuffer.cpp:96
AudioReencodeBuffer::GetAudiotime
std::chrono::milliseconds GetAudiotime(void) override
Definition: audioreencodebuffer.h:51
AudioReencodeBuffer::ToggleMute
void ToggleMute(void) override
Definition: audioreencodebuffer.h:58
AudioReencodeBuffer::readOutputData
int readOutputData(unsigned char *, size_t) override
Definition: audioreencodebuffer.h:68
AudioReencodeBuffer::m_audioFrameSize
int m_audioFrameSize
Definition: audioreencodebuffer.h:76
AudioBuffer::size
int size(void) const
Definition: audioreencodebuffer.h:18
AudioBuffer::m_realsize
size_t m_realsize
Definition: audioreencodebuffer.h:22
AudioBuffer::data
char * data(void) const
Definition: audioreencodebuffer.h:17
kMuteOff
@ kMuteOff
Definition: volumebase.h:7
uint
unsigned int uint
Definition: compat.h:79
AudioReencodeBuffer::AdjustCurrentVolume
void AdjustCurrentVolume(int) override
Definition: audioreencodebuffer.h:56
AudioReencodeBuffer::Reset
void Reset(void) override
Definition: audioreencodebuffer.cpp:101
AudioReencodeBuffer::m_initpassthru
bool m_initpassthru
Definition: audioreencodebuffer.h:79
AudioReencodeBuffer::PauseUntilBuffered
void PauseUntilBuffered(void) override
Definition: audioreencodebuffer.h:49
AudioBuffer::m_frames
int m_frames
Definition: audioreencodebuffer.h:23
AudioReencodeBuffer::AddData
bool AddData(void *buffer, int len, std::chrono::milliseconds timecode, int frames) override
Add data to the audiobuffer for playback.
Definition: audioreencodebuffer.cpp:137
AudioReencodeBuffer::Drain
void Drain(void) override
Definition: audioreencodebuffer.h:50
AudioReencodeBuffer::CanPassthrough
bool CanPassthrough(int, int, AVCodecID, int) const override
Definition: audioreencodebuffer.h:63
AudioReencodeBuffer::Pause
void Pause(bool paused) override
Definition: audioreencodebuffer.h:48
ABLOCK_SIZE
static constexpr size_t ABLOCK_SIZE
Definition: audioreencodebuffer.h:7
AudioReencodeBuffer::m_passthru
bool m_passthru
Definition: audioreencodebuffer.h:75
AudioReencodeBuffer::SetTimecode
void SetTimecode(std::chrono::milliseconds timecode) override
Definition: audioreencodebuffer.cpp:238
audiooutput.h
AudioReencodeBuffer::SetSWVolume
void SetSWVolume(int, bool) override
Definition: audioreencodebuffer.h:61
AudioReencodeBuffer::m_bufferMutex
QMutex m_bufferMutex
Definition: audioreencodebuffer.h:80
AudioReencodeBuffer::m_bufferList
QList< AudioBuffer * > m_bufferList
Definition: audioreencodebuffer.h:81
AudioReencodeBuffer::GetSWVolume
int GetSWVolume(void) override
Definition: audioreencodebuffer.h:62
AudioReencodeBuffer::m_last_audiotime
std::chrono::milliseconds m_last_audiotime
Definition: audioreencodebuffer.h:74
AudioBuffer
Definition: audioreencodebuffer.h:9
AudioReencodeBuffer::GetVolumeChannel
int GetVolumeChannel(int) const override
Definition: audioreencodebuffer.h:52
AudioBuffer::AudioBuffer
AudioBuffer()
Definition: audioreencodebuffer.cpp:11
AudioFormat
AudioFormat
Definition: audiooutputsettings.h:24
AudioReencodeBuffer::SetMute
virtual void SetMute(bool)
Definition: audioreencodebuffer.h:57
AudioReencodeBuffer::IsPaused
bool IsPaused(void) const override
Definition: audioreencodebuffer.h:47
AudioReencodeBuffer::m_channels
int m_channels
Definition: audioreencodebuffer.h:71
AudioReencodeBuffer::GetCurrentVolume
uint GetCurrentVolume(void) const override
Definition: audioreencodebuffer.h:54
AudioReencodeBuffer::AddFrames
bool AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode) override
Add frames to the audiobuffer for playback.
Definition: audioreencodebuffer.cpp:121
AudioReencodeBuffer::GetSamples
long long GetSamples(std::chrono::milliseconds time)
Definition: audioreencodebuffer.cpp:220
AudioReencodeBuffer::IterateMutedChannels
virtual MuteState IterateMutedChannels(void)
Definition: audioreencodebuffer.h:60