Change: Add debug messages for errors encountered reading sounds. (#14810)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include "misc/autorelease.hpp"
|
||||
#include "random_access_file_type.h"
|
||||
#include "sound_type.h"
|
||||
@@ -54,7 +55,10 @@ public:
|
||||
|
||||
int error = 0;
|
||||
auto of = AutoRelease<OggOpusFile, op_free>(op_open_memory(tmp.data(), tmp.size(), &error));
|
||||
if (error != 0) return false;
|
||||
if (error != 0) {
|
||||
Debug(grf, 0, "SoundLoader_Opus: Unable to open stream.");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t datapos = 0;
|
||||
for (;;) {
|
||||
@@ -64,8 +68,15 @@ public:
|
||||
int read = op_read(of.get(), reinterpret_cast<opus_int16 *>(&data[datapos]), DECODE_BUFFER_BYTES, &link_index);
|
||||
if (read == 0) break;
|
||||
|
||||
if (read < 0 || op_channel_count(of.get(), link_index) != 1) {
|
||||
/* Error reading, or incorrect channel count. */
|
||||
if (read < 0) {
|
||||
Debug(grf, 0, "SoundLoader_Opus: Unexpected end of stream.");
|
||||
data.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
int channels = op_channel_count(of.get(), link_index);
|
||||
if (channels != 1) {
|
||||
Debug(grf, 0, "SoundLoader_Opus: Unsupported channels {}, expected 1.", channels);
|
||||
data.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user