fix empty samples eating memory
when DPCM is requested, Furnace would waste 500MB of memory per empty sample that's why it had to be signed!
This commit is contained in:
parent
2739b5af54
commit
6b83f399f0
2 changed files with 12 additions and 5 deletions
|
|
@ -543,7 +543,11 @@ bool DivSample::saveRaw(const char* path) {
|
|||
}
|
||||
|
||||
// 16-bit memory is padded to 512, to make things easier for ADPCM-A/B.
|
||||
bool DivSample::initInternal(DivSampleDepth d, unsigned int count) {
|
||||
bool DivSample::initInternal(DivSampleDepth d, int count) {
|
||||
if (count<0) {
|
||||
logE("initInternal(%d,%d) - NEGATIVE!",(int)d,count);
|
||||
return false;
|
||||
}
|
||||
logV("initInternal(%d,%d)",(int)d,count);
|
||||
switch (d) {
|
||||
case DIV_SAMPLE_DEPTH_1BIT: // 1-bit
|
||||
|
|
@ -650,8 +654,11 @@ bool DivSample::initInternal(DivSampleDepth d, unsigned int count) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DivSample::init(unsigned int count) {
|
||||
if (count>16777215) return false;
|
||||
bool DivSample::init(int count) {
|
||||
if (count<0 || count>16777215) {
|
||||
logE("tried to init sample with length %d!",count);
|
||||
return false;
|
||||
}
|
||||
if (!initInternal(depth,count)) return false;
|
||||
setSampleCount(count);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -236,14 +236,14 @@ struct DivSample {
|
|||
* @param count number of samples.
|
||||
* @return whether it was successful.
|
||||
*/
|
||||
bool initInternal(DivSampleDepth d, unsigned int count);
|
||||
bool initInternal(DivSampleDepth d, int count);
|
||||
|
||||
/**
|
||||
* initialize sample data. make sure you have set `depth` before doing so.
|
||||
* @param count number of samples.
|
||||
* @return whether it was successful.
|
||||
*/
|
||||
bool init(unsigned int count);
|
||||
bool init(int count);
|
||||
|
||||
/**
|
||||
* resize sample data. make sure the sample has been initialized before doing so.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue