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