forked from bandrews/mqttaudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsamplemanager.cpp
executable file
·46 lines (41 loc) · 954 Bytes
/
samplemanager.cpp
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
#include "samplemanager.h"
Sample* SampleManager::GetSample(const char * uri)
{
if (_database.find(uri) != _database.end())
{
return _database[uri];
}
else
{
Sample* sample = new Sample(uri);
if (sample->isValid())
{
std::string key = uri;
_database.insert({key, sample});
return sample;
}
else
{
return 0;
}
}
}
void SampleManager::RemoveSample(const std::string& filename)
{
auto it = _database.find(filename);
if (it != _database.end())
{
delete it->second; // Libera la memoria asociada con el sample
_database.erase(it); // Elimina la entrada del caché
if (verbose)
{
printf("Sample '%s' removed from cache.\n", filename.c_str());
}
}
}
void SampleManager::FreeAll()
{
for( const auto& s : _database ) {
s.second->Free();
}
}