ALgetframetime(3dm) ALgetframetime(3dm)
ALgetframetime - (obsolete) Get the time at which a sample frame came in
or will go out
#include <dmedia/audio.h>
int ALgetframetime(const ALport port, unsigned long long *fnum, unsigned long long *time)
port expects the ALport structure for the audio port for which you wish
to know the sample frame number. This structure is the returned
value of the ALopenport(3dm) call.
fnum expects a pointer to an unsigned 64-bit value which is to contain
the resultant sample-frame number.
time expects a pointer to an unsigned 64-bit value which is to contain
the resultant sample-frame time, in nanoseconds.
ALgetframetime is obsolete and is provided for backward compatibility.
The preferred function is alGetFrameTime(3dm).
ALgetframetime returns an atomic pair of (fnum, time). For an input port,
the time returned is the time at which the returned sample frame arrived
at the electrical input on the machine. For an output port, the time
returned is the time at which the returned sample frame will arrive at
the electrical output on the machine. ALgetframetime therefore accounts
for all the latency within the machine, including the group delay of the
A/D and D/A converters.
The returned sample frame number is not guaranteed to be in any
application's port. For example, an input sample frame as returned by
ALgetframetime may be "in the future": it has not yet arrived in any
application's port. Similarly, an output sample frame may be "in the
past": it has already gone out of some application's port. In order to
relate the sample frame numbers to those of a particular application's
audio port, the ALgetframenumber call must be used.
ALgetframetime uses the Unadjusted System Time (UST) as its timeline.
This allows it to relate to other media which also use UST. See the man
page for dmGetUST(3dm) for more information on UST.
ALgetframetime can fail for the following reasons:
AL_BAD_PORT [Toc] [Back]
port is invalid.
AL_BAD_NOT_IMPLEMENTED [Toc] [Back]
the feature is not implemented on the given machine. ALgetframetime
is not implemented on Indigo (IP12), 4D/35 (IP12), and Indigo R4K
Page 1
ALgetframetime(3dm) ALgetframetime(3dm)
(IP20) systems.
Upon successful completion, ALgetframetime(3dm) returns 0. Otherwise
ALgetframetime(3dm) returns -1 and sets an error number which can be
retrieved with oserror(3C).
dmGetUST(3dm), ALgetframenumber(3A), oserror(3C)
alGetFrameTime(3dm) alGetFrameTime(3dm)
alGetFrameTime - Get the time at which a sample frame came in or will go
out
#include <dmedia/audio.h>
int alGetFrameTime(const ALport port, stamp_t *fnum, stamp_t *time)
port expects the ALport structure for the audio port for which you wish
to know the sample frame number. This structure is the returned
value of the alOpenPort(3dm) call.
fnum expects a pointer to an unsigned 64-bit value which is to contain
the resultant sample-frame number.
time expects a pointer to an unsigned 64-bit value which is to contain
the resultant sample-frame time, in nanoseconds.
alGetFrameTime returns an atomic pair of (fnum, time) for the device to
which port is connected. For an input device, the time returned is the
time at which the returned sample frame arrived at the electrical input
on the machine. For an output device, the time returned is the time at
which the returned sample frame will arrive at the electrical output on
the machine.
The application cannot request a specific pair of values; alGetFrameTime
merely returns the most recent pair available. It is up to the
application to use this pair to calculate the time associated with a
particular sample-frame, or the sample-frame number associated with a
particular time, if desired.
In general, the returned sample frame will not currently be in any
application's port. For example, an input sample frame as returned by
alGetFrameTime may be "in the future": it has not yet arrived in any
application's port. Similarly, an output sample frame may be "in the
past": it has already gone out of some application's port. In order to
relate the sample frame numbers to those of a particular application's
audio port, the alGetFrameNumber call must be used.
alGetFrameTime uses the Unadjusted System Time (UST) as its timeline.
This allows it to relate to other media which also use UST. See the man
page for dmGetUST(3dm) for more information on UST.
Page 1
alGetFrameTime(3dm) alGetFrameTime(3dm)
stamp_t fn, t;
stamp_t fnd,td;
double nanosec_per_frame = 1000000000.0 / rate_in_Hz;
/*
* Get the device sample frame number associated with the next
* audio sample frame I'm going to read or write from this port
*/
alGetFrameNumber(port, &fn);
/*
* Get some recent pair of (frame number, time) from the audio
* device to which my port is connected. time is on a timeline
* called UST which is given in nanoseconds and shared with the
* other audio devices and with other media.
*/
alGetFrameTime(port, &fnd, &td);
/*
* Calculate the UST associated with fn, the next sample frame
* we're going to read or write. Because this is signed
* arithmetic, this code works for both input and output ports.
*/
t = td + (stamp_t) ((double)(fn - fnd) * nanosec_per_frame);
/*
* If my port is not in an underflow or overflow state, I can do an
* alReadFrames or alWriteFrames here and know that t is the time
* associated with the first sample frame of the buffer I read or
* write.
*/
Upon successful completion, alGetFrameTime returns 0. Otherwise
alGetFrameTime returns -1 and sets an error number which can be retrieved
with oserror(3C).
alGetFrameTime can fail for the following reasons:
AL_BAD_PORT [Toc] [Back]
port is invalid.
AL_BAD_NOT_IMPLEMENTED [Toc] [Back]
the feature is not implemented on the given machine. alGetFrameTime
is not implemented on Indigo R4K (IP20) systems.
dmGetUST(3dm), alGetFrameNumber(3A), oserror(3C)
PPPPaaaaggggeeee 2222 [ Back ]
|