AGetAFileAttributes(3X)
NAME
AGetAFileAttributes − get audio attributes of specified file
SYNOPSIS
#include <Alib.h> AFileFormat
AGetAFileAttributes (
Audio ∗ audio,
char ∗ name,
long ∗ offset,
long ∗ data_length,
AByteOrder ∗ file_byte_order,
AudioAttrMask ∗ mask,
AudioAttributes ∗ file_attr,
long ∗ status_return );
DESCRIPTION
AGetAFileAttributes() returns the file format of the file specified in name. The routine also fills in an attributes structure describing the audio attributes of the file.
If the file is a raw audio data file (no header information) the Audio library makes assumptions about the file based on the file extension. The mask parameter indicates which values in the attributes structure were taken explicitly from the header or the file extension and which were inferred.
audio specifies the Audio structure associated with this connection.
name the pathname of the audio data file to be queried.
offset receives the number of bytes into the file where the audio samples begin.
data_length receives the length (in bytes) of the audio data.
file_byte_order receives the byte order (relevant only for l16 data). One of the following values:
ALSBFirst − Least significant byte first.
AMSBFirst − Most significant byte first.
mask receives the information indicating how the attributes were determined. One or more of the mask values listed in the Structures section.
A mask bit set to 1 indicates that the attribute was determined from the file header or file extension.
A mask bit set to 0 indicates that the attribute was determined by inference. For example, the Audio library assumes that a raw audio data file with a “.l16” extension is a mono file. It also assumes that a “.u” file without an explicit sample rate in the file extension uses 8000 samples per second.
file_attr receives the audio attribute information.
status_return receives the returned status of the operation, unless this parameter is passed in as a NULL pointer. If status_return is set to NULL, Alib will do the error handling.
RETURN VALUE
Upon successful completion, AGetAFileAttributes() returns the file type of the file specified in name. AFFUnknown is returned if the format type cannot be determined.
STRUCTURES
The following are defined in /opt/audio/include/Alib.h.
typedef long AudioAttrMask;
#define ASDataFormatMask ( 1 << ASAFDataFormat )
#define ASBitsPerSampleMask ( 1 << ASAFBitsPerSample )
#define ASSamplingRateMask ( 1 << ASAFSamplingRate )
#define ASChannelsMask ( 1 << ASAFChannels )
#define ASInterleaveMask ( 1 << ASAFInterleave )
#define ASDurationMask ( 1 << ASAFDuration )
ERRORS
If status_return is not set to NULL, it can return one of the following values:
0 AENoError No error - the call completed successfully.
1 AESystemCall A file read, write, or open failed with an error other than File Not Found.
2 AEBadAudio The audio structure is invalid. A pointer to a valid audio structure may be missing (use AOpenAudio() to get a valid pointer).
8 AEFileNotFound The Audio Library could not find the specified file.
11 AEBadFileHdr The specified file type requires a header, but the file lacks a valid header for that file type.
EXAMPLE
The following example queries the file attributes of the file /myhome/a_dir/a_file.
AFileFormat file_fmt; /* file format */
Audio *audio; /* audio connection */
long offset; /* offset where data begins */
long data_length; /* returned data length */
AByteOrder byte_order; /* returned byte order */
AudioAttrMask attr_mask; /* attr found in hdr or .ext */
AudioAttributes attribs; /* returned attributes */
long status; /* status */
char fname[] = "/myhome/a_dir/a_file";
.
.
.
/* get attributes of /myhome/a_dir/a_file */
file_fmt = AGetAFileAttributes(audio, fname, &offset, &data_len,
&byte_order, &attr_mask, &attribs, &status);
NOTE
In order to ensure that the compiler finds the Audio Library (libAlib.sl) and the Alib.h header file, you must add the following switches:
-L /opt/audio/lib
-I/opt/audio/include
DEPENDENCIES
This function belongs to the Audio Library of functions that manage connections to an audio server. The audio server must run on a system that has audio hardware. To find out whether or not your system has audio hardware, refer to Using the Audio Developer’s Kit or the online help for the Audio control panel. For information about the audio capabilities of a particular system use the online example audioinfo.c.
AUTHOR
AGetAFileAttributes() was developed by HP.
SEE ALSO
Hewlett-Packard Company — Audio Library: February, 1995