mirror of
https://github.com/love2d/love.git
synced 2026-08-21 21:15:09 +02:00
added an endianness check in VorbisDecoder.cpp
This commit is contained in:
@@ -35,6 +35,14 @@
|
||||
# define LOVE_MACOS 1
|
||||
#endif
|
||||
|
||||
// Endianness.
|
||||
#if defined(__i386__) || defined(__i386)
|
||||
# define LOVE_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
#if defined(__ppc__) || defined(__ppc)
|
||||
# define LOVE_BIG_ENDIAN 1
|
||||
#endif
|
||||
|
||||
// Warnings.
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
# define _CRT_SECURE_NO_WARNINGS
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "VorbisDecoder.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <common/config.h>
|
||||
#include <common/Exception.h>
|
||||
|
||||
namespace love
|
||||
@@ -133,6 +134,13 @@ namespace lullaby
|
||||
vorbisCallbacks.read_func = vorbisRead;
|
||||
vorbisCallbacks.tell_func = vorbisTell;
|
||||
|
||||
// Check endianness
|
||||
#ifdef LOVE_BIG_ENDIAN
|
||||
endian = 1;
|
||||
#else
|
||||
endian = 0;
|
||||
#endif
|
||||
|
||||
// Initialize OGG file
|
||||
oggFile.dataPtr = (char *) data->getData();
|
||||
oggFile.dataSize = data->getSize();
|
||||
@@ -186,7 +194,7 @@ namespace lullaby
|
||||
|
||||
while(size < bufferSize)
|
||||
{
|
||||
result = ov_read(&handle, (char*) buffer + size, bufferSize - size, 0, bits, 1, §ion);
|
||||
result = ov_read(&handle, (char*) buffer + size, bufferSize - size, endian, bits, 1, §ion);
|
||||
|
||||
if(result > 0)
|
||||
size += result;
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace lullaby
|
||||
OggVorbis_File handle; // Handle to the file
|
||||
vorbis_info * vorbisInfo; // Info
|
||||
vorbis_comment * vorbisComment; // Comments
|
||||
int endian; // Endianness
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user