mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
WaveFile: don't assert-crash when the wav file couldn't be opened
__StartLogAudio ignored WaveFileWriter::Start()'s return value and set m_logAudio either way, so a wav file that couldn't be opened - read-only or full audio directory, most likely - left every subsequent mixed block calling AddStereoSamples on a closed file. That opens with _assert_msg_(file, ...). Also other minor fixes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
This commit is contained in:
1 parent
5c6fc2e69f
commit
e4613a3487
3 files changed
+15
-7
No files matched your search
+7
-4
@@ -6,8 +6,6 @@
|
||||
#include "Common/Log.h"
|
||||
#include "Core/Config.h"
|
||||
|
||||
constexpr size_t WaveFileWriter::BUFFER_SIZE;
|
||||
|
||||
WaveFileWriter::WaveFileWriter() {}
|
||||
|
||||
WaveFileWriter::~WaveFileWriter()
|
||||
@@ -78,10 +76,15 @@ void WaveFileWriter::Write4(const char* ptr)
|
||||
file.WriteBytes(ptr, 4);
|
||||
}
|
||||
|
||||
// count is the number of stereo frames, so 4 bytes each.
|
||||
void WaveFileWriter::AddStereoSamples(const short* sample_data, uint32_t count)
|
||||
{
|
||||
_assert_msg_(file, "WaveFileWriter - file not open.");
|
||||
_assert_msg_(count <= BUFFER_SIZE * 2, "WaveFileWriter - buffer too small (count = %u).", count);
|
||||
if (!file) {
|
||||
// Callers are supposed to check that Start() succeeded, but this used to assert - which
|
||||
// isn't compiled out in release builds, so a file we couldn't open crashed the emulator.
|
||||
ERROR_LOG(Log::System, "WaveFileWriter - file not open.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (skip_silence)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user