Open Sound System
|Do you have problems with sound/audio application development? Don't panic! Click here for help!
ioctl(fd, SNDCTL_SETLABEL, lbl);
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.
This ioctl call sens a short (1-15 char) mnemonic label string whic the remote end of the link can obtain by calling SNDCTL_GETLABEL. Some devices may use the label (for example) as a tape reel name or show it as a channel identifier on the mixing console.
Under most operating systems OSS will automatically use name of the application/program as the default label. However this doesn't work under some operating systems that don't reveal the application name to the device driver. For this reason applications can (optionally) help OSS by giving argv as the initial label.
The meta data model used by OSS is bidirectional. The label set by an application will be seen by the application/driver located at the remote end of the link. For this reason the application will get the label set by the remote end (instead of the string it has set itself) when it calls SNDCTL_GETLABEL. However it must be pointed out that very few devices or virtual drivers actually support this mechanism.}
This call must be used before writing any data to the device. It's recommended to close and reopen the device if this ioctl needs to be called second time.
This ioctl call is new in OSS 4.0 and not supported by the freeware implementations based on older OSS versions. If this call returns any error then no label information can be set. The application should not show an error message if this happens.
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.