mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 10:05:44 -04:00
Show clearer error messages when trying to play audio files that don't use a supported codec
This commit is contained in:
parent
47867b7778
commit
18ab062c68
@ -886,7 +886,10 @@ static cc_result Sound_ReadWaveData(struct Stream* stream, struct Sound* snd) {
|
|||||||
|
|
||||||
if ((res = Stream_Read(stream, tmp, 12))) return res;
|
if ((res = Stream_Read(stream, tmp, 12))) return res;
|
||||||
fourCC = Stream_GetU32_BE(tmp + 0);
|
fourCC = Stream_GetU32_BE(tmp + 0);
|
||||||
if (fourCC != WAV_FourCC('R','I','F','F')) return WAV_ERR_STREAM_HDR;
|
if (fourCC == WAV_FourCC('I', 'D', '3', 2)) return AUDIO_ERR_MP3_SIG; /* ID3 v2.2 tags header */
|
||||||
|
if (fourCC == WAV_FourCC('I', 'D', '3', 3)) return AUDIO_ERR_MP3_SIG; /* ID3 v2.3 tags header */
|
||||||
|
if (fourCC != WAV_FourCC('R','I','F','F')) return WAV_ERR_STREAM_HDR;
|
||||||
|
|
||||||
/* tmp[4] (4) file size */
|
/* tmp[4] (4) file size */
|
||||||
fourCC = Stream_GetU32_BE(tmp + 8);
|
fourCC = Stream_GetU32_BE(tmp + 8);
|
||||||
if (fourCC != WAV_FourCC('W','A','V','E')) return WAV_ERR_STREAM_TYPE;
|
if (fourCC != WAV_FourCC('W','A','V','E')) return WAV_ERR_STREAM_TYPE;
|
||||||
|
@ -19,9 +19,11 @@ enum CC_ERRORS {
|
|||||||
WAV_ERR_STREAM_HDR = 0xCCDED007UL, /* Bytes #1-#4 aren't "RIFF" */
|
WAV_ERR_STREAM_HDR = 0xCCDED007UL, /* Bytes #1-#4 aren't "RIFF" */
|
||||||
WAV_ERR_STREAM_TYPE = 0xCCDED008UL, /* Bytes #9-#12 aren't "WAV " */
|
WAV_ERR_STREAM_TYPE = 0xCCDED008UL, /* Bytes #9-#12 aren't "WAV " */
|
||||||
WAV_ERR_DATA_TYPE = 0xCCDED009UL, /* Audio data type isn't 1 (PCM) */
|
WAV_ERR_DATA_TYPE = 0xCCDED009UL, /* Audio data type isn't 1 (PCM) */
|
||||||
/*WAV_ERR_NO_DATA = 0xCCDED00AUL, no longer used */
|
/*WAV_ERR_NO_DATA = 0xCCDED00AUL, repurposed for AUDIO_ERR_MP3_SIG */
|
||||||
WAV_ERR_SAMPLE_BITS = 0xCCDED00BUL, /* Bits per sample isn't 16 */
|
WAV_ERR_SAMPLE_BITS = 0xCCDED00BUL, /* Bits per sample isn't 16 */
|
||||||
|
|
||||||
|
AUDIO_ERR_MP3_SIG = 0xCCDED00AUL, /* Signature bytes are "ID3" (repurposed WAV_ERR_NO_DATA) */
|
||||||
|
|
||||||
/*VORBIS_ERR_HEADER = 0xCCDED00CUL, no longer used */
|
/*VORBIS_ERR_HEADER = 0xCCDED00CUL, no longer used */
|
||||||
VORBIS_ERR_WRONG_HEADER = 0xCCDED00DUL, /* Packet header doesn't match expected type */
|
VORBIS_ERR_WRONG_HEADER = 0xCCDED00DUL, /* Packet header doesn't match expected type */
|
||||||
VORBIS_ERR_FRAMING = 0xCCDED00EUL, /* Framing flag doesn't match expected value */
|
VORBIS_ERR_FRAMING = 0xCCDED00EUL, /* Framing flag doesn't match expected value */
|
||||||
|
@ -59,10 +59,11 @@ static const char* GetCCErrorDesc(cc_result res) {
|
|||||||
case ERR_INVALID_ARGUMENT: return "Invalid argument";
|
case ERR_INVALID_ARGUMENT: return "Invalid argument";
|
||||||
case ERR_OUT_OF_MEMORY: return "Out of memory";
|
case ERR_OUT_OF_MEMORY: return "Out of memory";
|
||||||
|
|
||||||
case OGG_ERR_INVALID_SIG: return "Invalid OGG signature";
|
case OGG_ERR_INVALID_SIG: return "Only OGG music files supported";
|
||||||
case OGG_ERR_VERSION: return "Invalid OGG format version";
|
case OGG_ERR_VERSION: return "Invalid OGG format version";
|
||||||
|
case AUDIO_ERR_MP3_SIG: return "MP3 audio files are not supported";
|
||||||
|
|
||||||
case WAV_ERR_STREAM_HDR: return "Invalid WAV header";
|
case WAV_ERR_STREAM_HDR: return "Only WAV sound files supported";
|
||||||
case WAV_ERR_STREAM_TYPE: return "Invalid WAV type";
|
case WAV_ERR_STREAM_TYPE: return "Invalid WAV type";
|
||||||
case WAV_ERR_DATA_TYPE: return "Unsupported WAV audio format";
|
case WAV_ERR_DATA_TYPE: return "Unsupported WAV audio format";
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "Drawer.h"
|
#include "Drawer.h"
|
||||||
#include "Block.h"
|
#include "Block.h"
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include "Funcs.h"
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
struct _ModelsData Models;
|
struct _ModelsData Models;
|
||||||
|
@ -52,6 +52,8 @@ static cc_result Ogg_NextPage(struct OggState* ctx) {
|
|||||||
if ((res = Stream_Read(source, header, sizeof(header)))) return res;
|
if ((res = Stream_Read(source, header, sizeof(header)))) return res;
|
||||||
|
|
||||||
sig = Stream_GetU32_BE(&header[0]);
|
sig = Stream_GetU32_BE(&header[0]);
|
||||||
|
if (sig == OGG_FourCC('I','D','3', 2)) return AUDIO_ERR_MP3_SIG; /* ID3 v2.2 tags header */
|
||||||
|
if (sig == OGG_FourCC('I','D','3', 3)) return AUDIO_ERR_MP3_SIG; /* ID3 v2.3 tags header */
|
||||||
if (sig != OGG_FourCC('O','g','g','S')) return OGG_ERR_INVALID_SIG;
|
if (sig != OGG_FourCC('O','g','g','S')) return OGG_ERR_INVALID_SIG;
|
||||||
if (header[4] != 0) return OGG_ERR_VERSION;
|
if (header[4] != 0) return OGG_ERR_VERSION;
|
||||||
|
|
||||||
|
@ -10,10 +10,20 @@ extern "C" {
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <AppKit.h>
|
// AppKit
|
||||||
#include <InterfaceKit.h>
|
#include <Application.h>
|
||||||
#include <OpenGLKit.h>
|
#include <Clipboard.h>
|
||||||
#include <StorageKit.h>
|
#include <Message.h>
|
||||||
|
// GLKit
|
||||||
|
#include <GL/gl.h>
|
||||||
|
#include <GLView.h>
|
||||||
|
// InterfaceKit
|
||||||
|
#include <Alert.h>
|
||||||
|
#include <Bitmap.h>
|
||||||
|
#include <Screen.h>
|
||||||
|
// StorageKit
|
||||||
|
#include <FilePanel.h>
|
||||||
|
#include <Path.h>
|
||||||
|
|
||||||
static BApplication* app_handle;
|
static BApplication* app_handle;
|
||||||
static BWindow* win_handle;
|
static BWindow* win_handle;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user