[vorbis-dev] Streaming buffers/ov_read question
akdjr at softhome.net
Sat Jul 7 18:08:22 PDT 2001
Ok, I went through the code. Problem A was actually a stupid
calculation error on my part and a misinterpretation of how Lock works.
I have verified that the ov_read does get called (and it does). Problem
B, I think I have fixed. However, using my new code - I still get
garbage noise. Nothing that is played sounds remotely like my test ogg
file. I am stumped on this one. This is new code I have:
The variable begPlay is initially set to true, while bStop is initially
// fill more data into the buffer;
bytes_to_read = 4096;
while (bytes_to_read > 0)
retVal = ov_read(&vorbisFile, pcmData + (4096 -
bytes_to_read), bytes_to_read, 0, 2, 1, ¤tSection);
if (retVal == 0)
eof = true;
else if (retVal < 0)
// Hole in data
bytes_to_read -= retVal;
lpdsBuffer->Lock(0, 4096, (void **)&ptr1, &len1, (void
**)&ptr2, &len2, DSBLOCK_FROMWRITECURSOR);
memcpy(ptr1, pcmData, len1);
if (ptr2 != NULL)
memcpy(ptr2, pcmData+len1, len2);
lpdsBuffer->Unlock((void **)&ptr1, len1, (void **)&ptr2,
lpdsBuffer->Play(0, 0, DSBPLAY_LOOPING);
begPlay = false;
Thanks for any help.
From: owner-vorbis-dev at xiph.org [mailto:owner-vorbis-dev at xiph.org] On
Behalf Of Monty
Sent: Saturday, July 07, 2001 10:41 AM
To: vorbis-dev at xiph.org
Subject: Re: [vorbis-dev] Streaming buffers/ov_read question
On Thu, Jul 05, 2001 at 11:36:16AM -0700, Akshay Dhalwala wrote:
> Has anyone had experience using ov_read in a thread with streaming
> directsound buffers? i have tried the following, but it just produces
> repeating garbage noise. i would appreciate some help.
"Your code is buggy". I can spot two major problems with either of
your loops functioning as intended right off the bat. Problem A: [I
may not be intuiting lpdsBuffer->Lock behavior properly but] it looks
like none of the Ogg code is actually getting called. Once that's
fixed (or verified working properly), Problem B: you're not adjusting
the buffer segment passed to ov_read based on bytes already read.
That's just from reading it once through. There may be more problems
lurking; spend some time with a debugger please.
--- >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