re[Openal] ading data
Chris Robinson
chris.kcat at gmail.com
Sun May 18 22:43:24 PDT 2008
On Sunday 18 May 2008 10:09:06 pm bonanza wrote:
> is the size (ALsizei size) not the same as the offset in
> int offset;
> alGetSourcei(Source, AL_BYTE_OFFSET, &offset); ???
Measuring the size by constantly reading and using the largest offset may not
always work. Once the mixer is done reading from the buffer (ie. it's byte
pointer is at the end), its automatically put into a stopped state. And once
the source is stopped, the reported offset will be 0.
Also, the byte offset in particulatr may not be reliable because the
implementation is free to convert the data into a playable format (eg.
converts 8-bit to 16-bit). The sample offset may also be affected (eg.
resamples 32khz to 48khz).
The best way to "follow" the current playing position is to read the seconds
offset:
ALfloat stime;
alGetSourcef(Source, AL_SEC_OFFSET, &stime);
int offset = (int)(stime*freq) * channels * bytes_per_sample;
where 'channels' and 'bytes_per_sample' are derived from the format (eg.
AL_FORMAT_MONO16 has channels=1 and bytes_per_sample=2).
More information about the Openal
mailing list