MythTV  master
audioreencodebuffer.h
Go to the documentation of this file.
1 #ifndef AUDIOREENCODEBUFFER_H
2 #define AUDIOREENCODEBUFFER_H
3 
4 #include "mythconfig.h"
5 #include "audiooutput.h"
6 
7 #define 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, long long 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  int m_size {0};
23  int m_frames {0};
24  long long m_time {-1};
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, int64_t timecode) override; // AudioOutput
42  bool AddData(void *buffer, int len, int64_t timecode,
43  int frames) override; // AudioOutput
44  AudioBuffer *GetData(long long time);
45  long long GetSamples(long long time);
46  void SetTimecode(int64_t 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  int64_t 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  long long m_last_audiotime {0};
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 
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
AudioReencodeBuffer::m_last_audiotime
long long m_last_audiotime
Definition: audioreencodebuffer.h:74
AudioReencodeBuffer::SetCurrentVolume
void SetCurrentVolume(int) override
Definition: audioreencodebuffer.h:55
AudioBuffer::m_realsize
int m_realsize
Definition: audioreencodebuffer.h:22
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
AudioReencodeBuffer::GetSamples
long long GetSamples(long long time)
Definition: audioreencodebuffer.cpp:220
AudioSettings
Definition: audiosettings.h:28
AudioReencodeBuffer::AddData
bool AddData(void *buffer, int len, int64_t timecode, int frames) override
Add data to the audiobuffer for playback.
Definition: audioreencodebuffer.cpp:137
ABLOCK_SIZE
#define ABLOCK_SIZE
Definition: audioreencodebuffer.h:7
AudioOutput
Definition: audiooutput.h:25
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::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::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
AudioReencodeBuffer::GetAudiotime
int64_t GetAudiotime(void) override
Definition: audioreencodebuffer.h:51
AudioBuffer::data
char * data(void) const
Definition: audioreencodebuffer.h:17
kMuteOff
@ kMuteOff
Definition: volumebase.h:7
uint
unsigned int uint
Definition: compat.h:141
AudioReencodeBuffer::AdjustCurrentVolume
void AdjustCurrentVolume(int) override
Definition: audioreencodebuffer.h:56
AudioReencodeBuffer::Reset
void Reset(void) override
Definition: audioreencodebuffer.cpp:101
AudioReencodeBuffer::SetTimecode
void SetTimecode(int64_t timecode) override
Definition: audioreencodebuffer.cpp:238
AudioBuffer::m_time
long long m_time
Definition: audioreencodebuffer.h:24
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::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
AudioBuffer::appendData
void appendData(unsigned char *buffer, int len, int frames, long long time)
Definition: audioreencodebuffer.cpp:37
AudioReencodeBuffer::m_passthru
bool m_passthru
Definition: audioreencodebuffer.h:75
audiooutput.h
AudioReencodeBuffer::GetData
AudioBuffer * GetData(long long time)
Definition: audioreencodebuffer.cpp:202
AudioReencodeBuffer::SetSWVolume
void SetSWVolume(int, bool) override
Definition: audioreencodebuffer.h:61
AudioReencodeBuffer::m_bufferMutex
QMutex m_bufferMutex
Definition: audioreencodebuffer.h:80
AudioBuffer::m_size
int m_size
Definition: audioreencodebuffer.h:21
AudioReencodeBuffer::m_bufferList
QList< AudioBuffer * > m_bufferList
Definition: audioreencodebuffer.h:81
AudioReencodeBuffer::GetSWVolume
int GetSWVolume(void) override
Definition: audioreencodebuffer.h:62
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:25
AudioReencodeBuffer::AddFrames
bool AddFrames(void *buffer, int frames, int64_t timecode) override
Add frames to the audiobuffer for playback.
Definition: audioreencodebuffer.cpp:121
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::IterateMutedChannels
virtual MuteState IterateMutedChannels(void)
Definition: audioreencodebuffer.h:60