Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • Vorbis Vorbis
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 25
    • Issues 25
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Xiph.Org
  • VorbisVorbis
  • Issues
  • #292
Closed
Open
Created Dec 05, 2002 by AdamDobson@AdamDobson

ov_pcm_total(&file, -1) says there's one more sample than there actually is

// Decode file to buffer
// Hardcoded for 16-bit stereo
void decode(OggVorbis_File *pFile, void *pBuffer)
{
	int nLength = ov_pcm_total(pFile, -1) * 4;

	int nTotalRead = 0;
	int current_section;

	while (nLength > 0)
	{
		int nBytesRead = ov_read(pFile, ((char *)pBuffer) + nTotalRead, 
nBytesToRead, 0, 2, 1, &current_section);

		if (nBytesRead > 0)
		{
			nTotalRead += nBytesRead;
			nLength -= nBytesRead;
		}
		else if (nBytesRead == 0)
		{
			OutputDebugString("EOF reached\n");
			return;
		}
		else
		{
			OutputDebugString("Error in stream detected\n");
		}
	}

	// We never get here EOF is always reached first
	OutputDebugString("It worked\n");
}

This was done using the 1.0 win32 sdk (using static linked release libs) and 
the files were encoded with oggdropXPd v1.1 (Compiled 20020719).

To make it work as expected I needed to change the first line to read:

int nLength = (ov_pcm_total(pFile, -1) - 1) * 4;
Assignee
Assign to
Time tracking