blob: e2aff528aa1146ee3eb1f48d6e002067075d71dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "cores/AudioEngine/Interfaces/AE.h"
#include "cores/AudioEngine/Interfaces/AEStream.h"
#include "cores/AudioEngine/Utils/AEChannelInfo.h"
#include "threads/CriticalSection.h"
#include <atomic>
#include <mutex>
#include "PlatformDefs.h"
extern "C" {
#include <libavcodec/avcodec.h>
}
typedef struct stDVDAudioFrame DVDAudioFrame;
class CDVDClock;
class CAudioSinkAE : IAEClockCallback
{
public:
explicit CAudioSinkAE(CDVDClock *clock);
~CAudioSinkAE() override;
void SetVolume(float fVolume);
void SetDynamicRangeCompression(long drc);
void Pause();
void Resume();
bool Create(const DVDAudioFrame &audioframe, AVCodecID codec, bool needresampler);
bool IsValidFormat(const DVDAudioFrame &audioframe);
void Destroy(bool finish);
unsigned int AddPackets(const DVDAudioFrame &audioframe);
double GetPlayingPts();
double GetCacheTime();
double GetCacheTotal(); // returns total time a stream can buffer
double GetMaxDelay(); // returns total time of audio in AE for the stream
double GetDelay(); // returns the time it takes to play a packet if we add one at this time
double GetSyncError();
void SetSyncErrorCorrection(double correction);
/*!
* \brief Returns the resample ratio, or 0.0 if unknown/invalid
*/
double GetResampleRatio();
void SetResampleMode(int mode);
void Flush();
void Drain();
void AbortAddPackets();
double GetClock() override;
double GetClockSpeed() override;
CAEStreamInfo::DataType GetPassthroughStreamType(AVCodecID codecId, int samplerate, int profile);
protected:
IAE::StreamPtr m_pAudioStream;
double m_playingPts;
double m_timeOfPts;
double m_syncError;
unsigned int m_syncErrorTime;
double m_resampleRatio = 0.0; // invalid
CCriticalSection m_critSection;
AEDataFormat m_dataFormat;
unsigned int m_sampleRate;
int m_iBitsPerSample;
bool m_bPassthrough;
CAEChannelInfo m_channelLayout;
CAEStreamInfo::DataType m_dataType;
bool m_bPaused;
std::atomic_bool m_bAbort;
CDVDClock *m_pClock;
};
|