forked from jfchapman/VUPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DecoderCDDA.h
55 lines (40 loc) · 1.48 KB
/
DecoderCDDA.h
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
#pragma once
#include "Decoder.h"
#include "CDDAMedia.h"
#include <string>
class DecoderCDDA : public Decoder
{
public:
// 'cddaMedia' - CD audio disc information.
// 'track' - track number.
// Throws a std::runtime_error exception if the file could not be loaded.
DecoderCDDA( const CDDAMedia& cddaMedia, const long track );
~DecoderCDDA() override;
// Reads sample data.
// 'buffer' - output buffer (floating point format scaled to +/-1.0f).
// 'sampleCount' - number of samples to read.
// Returns the number of samples read, or zero if the stream has ended.
long Read( float* buffer, const long sampleCount ) override;
// Seeks to a 'position' in the stream, in seconds.
// Returns the new position in seconds.
float Seek( const float position ) override;
// Returns the track gain, in dB, or nullopt if the calculation failed.
// 'canContinue' - callback which returns whether the calculation can continue.
// 'secondslimit' - number of seconds to devote to calculating an estimate, or 0 to perform a complete calculation.
std::optional<float> CalculateTrackGain( CanContinue canContinue, const float secondsLimit = 0 ) override;
private:
// CD audio disc information.
const CDDAMedia m_CDDAMedia;
// Start sector.
const long m_SectorStart;
// End sector.
const long m_SectorEnd;
// CD audio handle.
const HANDLE m_Handle;
// Data buffer.
CDDAMedia::Data m_Buffer;
// Current sector.
long m_CurrentSector;
// Current buffer position.
size_t m_CurrentBufPos;
};