Source:clone fixes;

Clones no longer try to create converters if they aren't needed, which
was causing an error.

Also handle malloc failure.
This commit is contained in:
bjorn 2021-04-03 09:48:42 -06:00
parent 62eb47d9a6
commit 024498b964
1 changed files with 6 additions and 3 deletions

View File

@ -452,9 +452,12 @@ Source* lovrSourceClone(Source* source) {
clone->dipolePower = source->dipolePower;
clone->effects = source->effects;
clone->looping = source->looping;
clone->converter = malloc(sizeof(ma_data_converter));
ma_result status = ma_data_converter_init(&source->converter->config, clone->converter);
lovrAssert(status == MA_SUCCESS, "Problem creating Source data converter: %s (%d)", ma_result_description(status), status);
if (source->converter) {
clone->converter = malloc(sizeof(ma_data_converter));
lovrAssert(clone->converter, "Out of memory");
ma_result status = ma_data_converter_init(&source->converter->config, clone->converter);
lovrAssert(status == MA_SUCCESS, "Problem creating Source data converter: %s (%d)", ma_result_description(status), status);
}
return clone;
}