| | Open Sound System OSS 4.x Programmer's Guide |
SNDCTL_DSP_CURRENT_IPTR
Returns the current recording position
Usage
oss_count_t ptr;
ioctl(fd, SNDCTL_DSP_CURRENT_IPTR, &ptr)
The above code fragment lacks all error checks for clarity. Real world applications must always check for the errors and handle them as described below. Also most OSS ioctl calls will return information in the argument variable and it's usually necessary to check it too.
Description
This ioctl call returns the recording position as precisely as possible measured as number of samples since the recording operation started. The returned pointer has two parts. ptr.samples (long long) is the number of samples that have been received in the driver level buffer. ptr.fifo_samples (int) is the number of samples currently buffered in the device level FIFO. The precision of this call depends on the device and is usually somewhere between 0 and 64 samples. To get the exact time in microseconds the application can use the following formula: {code time=(ptr.samples+ptr.fifo_samples) * usecs_per_sample}.
Related ioctl calls
Compatibility issues
This is a new call introduced in version 4.0 of OSS. It's not supported by the older implementations (errno=EINVAL will be returned). Special care must be taken when using this call if compatibility with older OSS versions is required. A good backup strategy might be using SNDCTL_DSP_GETIPTR if this call doesn't appear to be available.
Related links
Audio timing considerations Please look at the When OSS audio ioctl calls can be made section for information about DSP ioctl call ordering.
OSS ioctl return values
The return value from the OSS ioctl calls will be -1 if a fatal error occurred. Other values mean that the ioctl call was more or less successful. However in most cases the application must check the value returned in the argument to see what was the accepted value.
Please see the Possible error codes (errno) returned by OSS calls section for more info about the error codes returned by OSS.
Sample programs
No sample programs available
Copyright (C) 4Front Technologies, 2007. All rights reserved. Back to index OSS web site