Changed: Apply changes from CMusicBuffer to CAudioDecoder
--HG-- branch : sound_dev
This commit is contained in:
parent
18f75a4bd0
commit
1ab53c8bb2
1 changed files with 38 additions and 19 deletions
|
@ -494,22 +494,29 @@ uint32 CAudioDecoderVorbis::getRequiredBytes()
|
||||||
|
|
||||||
uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum)
|
uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 maximum)
|
||||||
{
|
{
|
||||||
int current_section = 0; // ???
|
sint current_section = 0; // ???
|
||||||
if (_IsMusicEnded) return 0;
|
if (_IsMusicEnded) return 0;
|
||||||
nlassert(minimum <= maximum); // can't have this..
|
nlassert(minimum <= maximum); // can't have this..
|
||||||
uint32 bytes_read = 0;
|
uint32 bytes_read = 0;
|
||||||
|
#ifdef NL_BIG_ENDIAN
|
||||||
|
sint endianness = 1;
|
||||||
|
#else
|
||||||
|
sint endianness = 0;
|
||||||
|
#endif
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// signed 16-bit or unsigned 8-bit little-endian samples
|
// signed 16-bit or unsigned 8-bit little-endian samples
|
||||||
int br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read,
|
sint br = ov_read(&_OggVorbisFile, (char *)&buffer[bytes_read], maximum - bytes_read,
|
||||||
0, // Specifies big or little endian byte packing. 0 for little endian, 1 for b ig endian. Typical value is 0.
|
endianness, // Specifies big or little endian byte packing. 0 for little endian, 1 for b ig endian. Typical value is 0.
|
||||||
getBitsPerSample() == 8 ? 1 : 2,
|
getBitsPerSample() == 8 ? 1 : 2,
|
||||||
getBitsPerSample() == 8 ? 0 : 1, // Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1.
|
getBitsPerSample() == 8 ? 0 : 1, // Signed or unsigned data. 0 for unsigned, 1 for signed. Typically 1.
|
||||||
¤t_section);
|
¤t_section);
|
||||||
// nlinfo(NLSOUND_XAUDIO2_PREFIX "current_section: %i", current_section);
|
// nlinfo(NLSOUND_XAUDIO2_PREFIX "current_section: %i", current_section);
|
||||||
if (br <= 0)
|
if (br > 0)
|
||||||
{
|
{
|
||||||
if (br == 0)
|
bytes_read += (uint32)br;
|
||||||
|
}
|
||||||
|
else if (br == 0) // EOF
|
||||||
{
|
{
|
||||||
if (_Loop)
|
if (_Loop)
|
||||||
{
|
{
|
||||||
|
@ -524,10 +531,22 @@ uint32 CAudioDecoderVorbis::getNextBytes(uint8 *buffer, uint32 minimum, uint32 m
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nlwarning("ov_read: %i", br);
|
// error
|
||||||
|
switch(br)
|
||||||
|
{
|
||||||
|
case OV_HOLE:
|
||||||
|
nlwarning("ov_read returned OV_HOLE");
|
||||||
|
break;
|
||||||
|
case OV_EINVAL:
|
||||||
|
nlwarning("ov_read returned OV_EINVAL");
|
||||||
|
break;
|
||||||
|
case OV_EBADLINK:
|
||||||
|
nlwarning("ov_read returned OV_EBADLINK");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nlwarning("ov_read returned %d", br);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else bytes_read += (uint32)br;
|
|
||||||
} while (bytes_read < minimum);
|
} while (bytes_read < minimum);
|
||||||
return bytes_read;
|
return bytes_read;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue