2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "threads/CriticalSection.h"
12 #include "utils/RingBuffer.h"
18 #define PACKET_SIZE 3840 // audio packet size - we keep 1 in reserve for gapless playback
19 // using a multiple of 1, 2, 3, 4, 5, 6 to guarantee track alignment
20 // note that 7 or higher channels won't work too well.
22 #define INPUT_SIZE PACKET_SIZE * 3 // input data size we read from the codecs at a time
23 // * 3 to allow 24 bit audio
25 #define OUTPUT_SAMPLES PACKET_SIZE // max number of output samples
26 #define INPUT_SAMPLES PACKET_SIZE // number of input samples (distributed over channels)
28 #define STATUS_NO_FILE 0
29 #define STATUS_QUEUING 1
30 #define STATUS_QUEUED 2
31 #define STATUS_PLAYING 3
32 #define STATUS_ENDING 4
33 #define STATUS_ENDED 5
35 // return codes from decoders
46 bool Create(const CFileItem
&file
, int64_t seekOffset
);
49 int ReadSamples(int numsamples
);
52 int64_t Seek(int64_t time
);
54 void SetTotalTime(int64_t time
);
55 void Start() { m_canPlay
= true;}; // cause a pre-buffered stream to start.
56 int GetStatus() { return m_status
; }
57 void SetStatus(int status
) { m_status
= status
; }
59 AEAudioFormat
GetFormat();
60 unsigned int GetChannels();
62 unsigned int GetDataSize(bool checkPktSize
);
63 void *GetData(unsigned int samples
);
64 uint8_t* GetRawData(int &size
);
65 ICodec
*GetCodec() const { return m_codec
; }
66 float GetReplayGain(float &peakVal
);
70 CRingBuffer m_pcmBuffer
;
72 // output buffer (for transferring data from the Pcm Buffer to the rest of the audio chain)
73 float m_outputBuffer
[OUTPUT_SAMPLES
];
75 // input buffer (for transferring data from the Codecs to our Pcm Ringbuffer
76 uint8_t m_pcmInputBuffer
[INPUT_SIZE
];
77 float m_inputBuffer
[INPUT_SAMPLES
];
87 // the codec we're using
90 CCriticalSection m_critSection
;