forked from jfchapman/VUPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CDDACache.h
35 lines (25 loc) · 808 Bytes
/
CDDACache.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
#pragma once
#include "stdafx.h"
#include "CDDAMedia.h"
#include <map>
#include <queue>
// CDDA cache, to facilitate quick access to previously read sectors (used for crossfading).
class CDDACache
{
public:
// Gets CD audio 'data' for the 'sector' index, returning whether the sector data was retrieved.
bool GetData( const long sector, CDDAMedia::Data& data );
// Caches the CD audio 'data' for the 'sector' index.
void SetData( const long sector, const CDDAMedia::Data& data );
private:
// Returns whether to limit memory usage.
bool LimitMemoryUsage();
// CD audio data, mapped by sector.
std::map<long, CDDAMedia::Data> m_Cache;
// Cached sector indices.
std::queue<long> m_CachedSectors;
// Cache limiter.
size_t m_MaxCachedSectors = 0;
// Cache mutex.
std::mutex m_Mutex;
};