mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-04-28 13:17:58 +03:00
retry saving to zip if saving to zip fails
This commit is contained in:
parent
c45ee055e5
commit
9cbcf55a70
2 changed files with 10 additions and 7 deletions
|
@ -56,11 +56,11 @@ size_t SfxExtractor::adjustedEndOfInput(size_t endOfInput) {
|
||||||
return endOfInput;
|
return endOfInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SfxExtractor::renderOutput(size_t endOfInput) {
|
bool SfxExtractor::renderOutput(size_t endOfInput) {
|
||||||
size_t startOfInput = adjustedStartOfInput();
|
size_t startOfInput = adjustedStartOfInput();
|
||||||
endOfInput = adjustedEndOfInput(endOfInput);
|
endOfInput = adjustedEndOfInput(endOfInput);
|
||||||
if (endOfInput <= startOfInput) {
|
if (endOfInput <= startOfInput) {
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ma_channel_converter_config config =
|
ma_channel_converter_config config =
|
||||||
|
@ -80,7 +80,7 @@ void SfxExtractor::renderOutput(size_t endOfInput) {
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
|
|
||||||
if (!drwav_init_memory_write(&wav, &mem, &size, &format, NULL))
|
if (!drwav_init_memory_write(&wav, &mem, &size, &format, NULL))
|
||||||
throw std::runtime_error("SFX Extractor: Unable to initialize wave writer.");
|
throw std::runtime_error("SfxExtractor: Unable to initialize wave writer.");
|
||||||
int16_t chunk[64];
|
int16_t chunk[64];
|
||||||
int16_t* mark = tempBuffer + startOfInput;
|
int16_t* mark = tempBuffer + startOfInput;
|
||||||
size_t samplesLeft = endOfInput - startOfInput;
|
size_t samplesLeft = endOfInput - startOfInput;
|
||||||
|
@ -94,7 +94,7 @@ void SfxExtractor::renderOutput(size_t endOfInput) {
|
||||||
drwav_uninit(&wav);
|
drwav_uninit(&wav);
|
||||||
std::vector<uint8_t> fileData((uint8_t*)mem, (uint8_t*)mem + size);
|
std::vector<uint8_t> fileData((uint8_t*)mem, (uint8_t*)mem + size);
|
||||||
drwav_free(mem, NULL);
|
drwav_free(mem, NULL);
|
||||||
archive->WriteFile(fileName.c_str(), fileData);
|
return archive->WriteFile(fileName.c_str(), fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SfxExtractor::setup() {
|
void SfxExtractor::setup() {
|
||||||
|
@ -240,8 +240,11 @@ void SfxExtractor::captureCallback() {
|
||||||
endOfInput += (SFX_EXTRACTION_ONE_FRAME * 2);
|
endOfInput += (SFX_EXTRACTION_ONE_FRAME * 2);
|
||||||
samplesLeft -= std::min<size_t>(SFX_EXTRACTION_ONE_FRAME, samplesLeft);
|
samplesLeft -= std::min<size_t>(SFX_EXTRACTION_ONE_FRAME, samplesLeft);
|
||||||
}
|
}
|
||||||
renderOutput(endOfInput);
|
if (renderOutput(endOfInput)) {
|
||||||
captureThreadState = CT_FINISHED; // Go to the next one.
|
captureThreadState = CT_FINISHED;
|
||||||
|
} else {
|
||||||
|
SPDLOG_ERROR("failed to write file to archive, trying again");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::string SfxExtractor::getExternalFileName(int16_t sfxId) {
|
std::string SfxExtractor::getExternalFileName(int16_t sfxId) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
|
@ -12,7 +12,7 @@ class SfxExtractor {
|
||||||
bool isAllZero(int16_t* buffer, size_t count);
|
bool isAllZero(int16_t* buffer, size_t count);
|
||||||
size_t adjustedStartOfInput();
|
size_t adjustedStartOfInput();
|
||||||
size_t adjustedEndOfInput(size_t endOfInput);
|
size_t adjustedEndOfInput(size_t endOfInput);
|
||||||
void renderOutput(size_t endOfInput);
|
bool renderOutput(size_t endOfInput);
|
||||||
void setup();
|
void setup();
|
||||||
void ripNextSfx();
|
void ripNextSfx();
|
||||||
void finished(); // Also handles failure.
|
void finished(); // Also handles failure.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue