[vorbis-dev] Small vorbis files with vorbisfile

Erik Olofsson erik at o3games.com
Thu Nov 22 22:42:26 PST 2001



I think I have bumped into the small file error, or I'm doing something
stupid. The files are short audio effects for a game (embedded in our own
data format). 

Sample info:
Vorbis packets: 1 (4 kb)
Samples: 28672
Samplerate: 22 kHz
Channels: 2

This is what I'm doing when I want to get a number of bytes from the stream:

The problem is that ov_pcm_tell always returns 0. And so does ov_read (its
only one packet so EOF)

        virtual bool GetData(void *&_pData, int &_nBytes)
        {
                int NumTimesNoData = 0;
                while(_nBytes)
                {
                        
                        long ret;

                        int StartOffset =
ov_pcm_tell(&m_pDecoder->VorbisFile);

                        if (StartOffset<0)
                                Error("Decode","Offset error");
                        
                        // uninterleave samples
                        ret = ov_read(&m_pDecoder->VorbisFile,(char
*)_pData,_nBytes,0,2,1,&m_pDecoder->Section);

                        int EndOffset =
ov_pcm_tell(&m_pDecoder->VorbisFile);
                        if (EndOffset<0)
                                Error("Decode","Offset error");

                        if (EndOffset == StartOffset)
                                ++NumTimesNoData;
                        else
                                NumTimesNoData = 0;

                        _nBytes -= EndOffset - StartOffset;
                        pData += EndOffset - StartOffset;

                        if (NumTimesNoData > 2) 
                        {
                                if (m_pDecoder->m_bLoop)
                                {
                                        if
(ov_pcm_seek(&m_pDecoder->VorbisFile, 0))
                                                Error("Decode", "Seek error
in stream");
                                }
                                return true;
                        } 
                        else if (ret < 0) 
                        {
                                return false;
                        } 
                }

                return true;
        }

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Vorbis-dev mailing list