Commit a4cbaafd authored by Max Kellermann's avatar Max Kellermann

decoder/flac: use error messages from libFLAC

parent c5f2cdb8
...@@ -139,26 +139,13 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block, ...@@ -139,26 +139,13 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
} }
} }
void flac_error_common_cb(const char *plugin, void flac_error_common_cb(const FLAC__StreamDecoderErrorStatus status,
const FLAC__StreamDecoderErrorStatus status,
struct flac_data *data) struct flac_data *data)
{ {
if (decoder_get_command(data->decoder) == DECODE_COMMAND_STOP) if (decoder_get_command(data->decoder) == DECODE_COMMAND_STOP)
return; return;
switch (status) { g_warning("%s", FLAC__StreamDecoderErrorStatusString[status]);
case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC:
g_warning("%s lost sync\n", plugin);
break;
case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER:
g_warning("bad %s header\n", plugin);
break;
case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH:
g_warning("%s crc mismatch\n", plugin);
break;
default:
g_warning("unknown %s error\n", plugin);
}
} }
/** /**
......
...@@ -94,8 +94,7 @@ flac_data_deinit(struct flac_data *data); ...@@ -94,8 +94,7 @@ flac_data_deinit(struct flac_data *data);
void flac_metadata_common_cb(const FLAC__StreamMetadata * block, void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
struct flac_data *data); struct flac_data *data);
void flac_error_common_cb(const char *plugin, void flac_error_common_cb(FLAC__StreamDecoderErrorStatus status,
FLAC__StreamDecoderErrorStatus status,
struct flac_data *data); struct flac_data *data);
FLAC__StreamDecoderWriteStatus FLAC__StreamDecoderWriteStatus
......
...@@ -117,46 +117,33 @@ static void ...@@ -117,46 +117,33 @@ static void
flac_error_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd, flac_error_cb(G_GNUC_UNUSED const FLAC__StreamDecoder *fd,
FLAC__StreamDecoderErrorStatus status, void *fdata) FLAC__StreamDecoderErrorStatus status, void *fdata)
{ {
flac_error_common_cb("flac", status, (struct flac_data *) fdata); flac_error_common_cb(status, (struct flac_data *) fdata);
} }
#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7 #if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state) static void flacPrintErroredState(FLAC__SeekableStreamDecoderState state)
{ {
const char *str = ""; /* "" to silence compiler warning */
switch (state) { switch (state) {
case FLAC__SEEKABLE_STREAM_DECODER_OK: case FLAC__SEEKABLE_STREAM_DECODER_OK:
case FLAC__SEEKABLE_STREAM_DECODER_SEEKING: case FLAC__SEEKABLE_STREAM_DECODER_SEEKING:
case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM: case FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM:
return; return;
case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR: case FLAC__SEEKABLE_STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
str = "allocation error";
break;
case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR: case FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR:
str = "read error";
break;
case FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR: case FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR:
str = "seek error";
break;
case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR: case FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR:
str = "seekable stream error";
break;
case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED: case FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED:
str = "decoder already initialized";
break;
case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK: case FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK:
str = "invalid callback";
break;
case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED: case FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED:
str = "decoder uninitialized"; break;
} }
g_warning("%s\n", str); g_warning("%s\n", FLAC__SeekableStreamDecoderStateString[state]);
} }
#else /* FLAC_API_VERSION_CURRENT >= 7 */ #else /* FLAC_API_VERSION_CURRENT >= 7 */
static void flacPrintErroredState(FLAC__StreamDecoderState state) static void flacPrintErroredState(FLAC__StreamDecoderState state)
{ {
const char *str = ""; /* "" to silence compiler warning */
switch (state) { switch (state) {
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA: case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
case FLAC__STREAM_DECODER_READ_METADATA: case FLAC__STREAM_DECODER_READ_METADATA:
...@@ -164,23 +151,16 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state) ...@@ -164,23 +151,16 @@ static void flacPrintErroredState(FLAC__StreamDecoderState state)
case FLAC__STREAM_DECODER_READ_FRAME: case FLAC__STREAM_DECODER_READ_FRAME:
case FLAC__STREAM_DECODER_END_OF_STREAM: case FLAC__STREAM_DECODER_END_OF_STREAM:
return; return;
case FLAC__STREAM_DECODER_OGG_ERROR: case FLAC__STREAM_DECODER_OGG_ERROR:
str = "error in the Ogg layer";
break;
case FLAC__STREAM_DECODER_SEEK_ERROR: case FLAC__STREAM_DECODER_SEEK_ERROR:
str = "seek error";
break;
case FLAC__STREAM_DECODER_ABORTED: case FLAC__STREAM_DECODER_ABORTED:
str = "decoder aborted by read";
break;
case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR: case FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR:
str = "allocation error";
break;
case FLAC__STREAM_DECODER_UNINITIALIZED: case FLAC__STREAM_DECODER_UNINITIALIZED:
str = "decoder uninitialized"; break;
} }
g_warning("%s\n", str); g_warning("%s\n", FLAC__StreamDecoderStateString[state]);
} }
#endif /* FLAC_API_VERSION_CURRENT >= 7 */ #endif /* FLAC_API_VERSION_CURRENT >= 7 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment