64 lines
1.2 KiB
C++
64 lines
1.2 KiB
C++
/* -----------------------------------------------------------------------------
|
|
GSFramework
|
|
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
|
|
----------------------------------------------------------------------------- */
|
|
|
|
|
|
#ifndef __AUDIOOGGSTREAM__
|
|
#define __AUDIOOGGSTREAM__
|
|
|
|
|
|
#include "filesystem/io_handle.h"
|
|
#define STB_VORBIS_HEADER_ONLY
|
|
#include "stb_vorbis.c"
|
|
#undef STB_VORBIS_HEADER_ONLY
|
|
#include "audio/stream_interface.h"
|
|
#include "memory/ring_buffer.h"
|
|
#include "memory/nauto_ptr.h"
|
|
|
|
|
|
namespace GS {
|
|
|
|
/*
|
|
@short OGG audio stream.
|
|
@author Emmanuel Julien (ejulien@nworks.fr)
|
|
*/
|
|
class AudioStreamOGG : public IAudioStream
|
|
{
|
|
protected:
|
|
|
|
AutoPtr <IO::Handle> h;
|
|
Array <char> buffer;
|
|
size_t byte_left;
|
|
|
|
size_t RefillBuffer();
|
|
void ConsumeBuffer(size_t);
|
|
|
|
int seek_correction, consumed, err;
|
|
|
|
stb_vorbis_info vorbis_info;
|
|
stb_vorbis *vf;
|
|
|
|
public:
|
|
|
|
/// Return the stream data format (eg. "OGG").
|
|
const char *GetFormat() { return "OGG"; }
|
|
|
|
bool Seek(int t_ms = 0);
|
|
bool IsEOF() const;
|
|
|
|
size_t GetPCM(void *);
|
|
size_t GetPCMBufferSize() const;
|
|
|
|
bool Open(const char *uri);
|
|
void Close();
|
|
|
|
AudioStreamOGG();
|
|
~AudioStreamOGG();
|
|
};
|
|
|
|
} // GS
|
|
|
|
|
|
#endif // __AUDIOOGGSTREAM__
|