Skip to content

Commit

Permalink
Remove trace of earlier OGG decoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Piolat committed Nov 7, 2021
1 parent e3b644f commit a7e6164
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4,903 deletions.
95 changes: 16 additions & 79 deletions source/audioformats/stream.d
Expand Up @@ -15,20 +15,9 @@ import dplug.core.vec;

import audioformats.io;

version = newVorbis;

version(decodeMP3) import audioformats.minimp3_ex;
version(decodeFLAC) import audioformats.drflac;

version(newVorbis)
{
version(decodeOGG) import audioformats.stb_vorbis2;
}
else
{
version(decodeOGG) import audioformats.vorbis;
}

version(decodeOGG) import audioformats.stb_vorbis2;
version(decodeOPUS) import audioformats.dopus;
version(decodeMOD) import audioformats.pocketmod;

Expand Down Expand Up @@ -271,21 +260,10 @@ public: // This is also part of the public API

version(decodeOGG)
{
version(newVorbis)
if (_oggHandle !is null)
{
if (_oggHandle !is null)
{
stb_vorbis_close(_oggHandle);
_oggHandle = null;
}
}
else
{
if (_oggDecoder !is null)
{
destroyFree(_oggDecoder);
_oggDecoder = null;
}
stb_vorbis_close(_oggHandle);
_oggHandle = null;
}
_oggBuffer.reallocBuffer(0);
}
Expand Down Expand Up @@ -497,16 +475,8 @@ public: // This is also part of the public API
{
version(decodeOGG)
{
version(newVorbis)
{
assert(_oggHandle !is null);
return stb_vorbis_get_samples_float_interleaved(_oggHandle, _numChannels, outData, frames * _numChannels);
}
else
{
assert(_oggDecoder !is null);
return _oggDecoder.stb_vorbis_get_samples_float_interleaved(_numChannels, outData, frames * _numChannels);
}
assert(_oggHandle !is null);
return stb_vorbis_get_samples_float_interleaved(_oggHandle, _numChannels, outData, frames * _numChannels);
}
else
{
Expand Down Expand Up @@ -660,12 +630,7 @@ public: // This is also part of the public API
case ogg:
version(decodeOGG)
{
version(newVorbis)
{
return stb_vorbis_seek(_oggHandle, frame) == 1;
}
else
assert(false); // former decoder doesn't support it
return stb_vorbis_seek(_oggHandle, frame) == 1;
}
else
assert(false);
Expand Down Expand Up @@ -769,15 +734,7 @@ private:
version(decodeOGG)
{
ubyte[] _oggBuffer; // all allocations from the ogg decoder

version(newVorbis)
{
stb_vorbis* _oggHandle;
}
else
{
VorbisDecoder _oggDecoder;
}
stb_vorbis* _oggHandle;
}
version(decodeWAV)
{
Expand Down Expand Up @@ -903,38 +860,18 @@ private:

int error;

version(newVorbis)
_oggHandle = stb_vorbis_open_file(_io, userData, &error, &alloc);
if (error == VORBIS__no_error)
{
_oggHandle = stb_vorbis_open_file(_io, userData, &error, &alloc);
if (error == VORBIS__no_error)
{
_format = AudioFileFormat.ogg;
_sampleRate = _oggHandle.sample_rate;
_numChannels = _oggHandle.channels;
_lengthInFrames = stb_vorbis_stream_length_in_samples(_oggHandle);
return;
}
else
{
_oggHandle = null;
}
_format = AudioFileFormat.ogg;
_sampleRate = _oggHandle.sample_rate;
_numChannels = _oggHandle.channels;
_lengthInFrames = stb_vorbis_stream_length_in_samples(_oggHandle);
return;
}
else
{
_oggDecoder = mallocNew!VorbisDecoder(_io, userData);
if (_oggDecoder.error == STBVorbisError.no_error)
{
_format = AudioFileFormat.ogg;
_sampleRate = _oggDecoder.sampleRate;
_numChannels = _oggDecoder.chans;
_lengthInFrames = _oggDecoder.streamLengthInSamples();
return;
}
else
{
destroyFree(_oggDecoder);
_oggDecoder = null;
}
_oggHandle = null;
}
}
}
Expand Down

0 comments on commit a7e6164

Please sign in to comment.