DALIB(3)

NAME
da_control - Control the state of a DAT device

SYNOPSIS
#include dataudiolib.h

int
da_control( int datfd , int code [,void *arg] )

DESCRIPTION
The da_control() function controls the state of a datfiledescriptor and the associated device. Depending on code and arg it initiates actions, returns or sets internal state information and the like.
Possible values of code and their respective actions are:

DA_GET_SAMPLERATE
    Returns the current samplerate. arg is a long* pointing to a long integer where to samplerate will be stored.

DA_SET_SAMPLERATE
    Sets the samplerate of the datfiledescriptor to the value passed by arg. arg is a long* pointing to a long integer containing the new samplerate. Possible values are 44100, 48000 and 32000 (Hz). Using other values will cause da_control to fail with EINVAL.

DA_GET_CHANNELS
    Gets the number of channels of an open datfiledescriptor. arg is long* pointing to a long integer containing the current number of channels.

DA_SET_CHANNELS
    Sets the number of channels to the value passed by arg. arg is a long* pointing to a long integer containing the new number of channels. Possible values are 2 and 4. (Note that 4 is only valid using 32kHz packed format.)

DA_GET_PACKED
    Gets the packed-flag of an open datfiledescriptor. arg is a long* pointing to a long integer containing either 0 or 1 (0 means not packed).

DA_SET_PACKED
    Sets the packed flag to the value passed by arg. arg is a long* pointing to a long integer containing the new packed-flag. Possible values are 0 and 1. (Note that 1 is only valid using 32kHz samplerate.)

DA_GET_PRERECORDED
    Returns the current prerecorded state in a long integer pointed to by arg ( long * ). It will be either be 1 or 0. There is currently not much difference between prerecorded and not prerecorded state.

DA_SET_PRERECORDED
    Sets the prerecorded state to the value pointed to by arg ( long* ).

DA_GET_PROGNR
    Gets the current programnumber of the datfiledescriptor. arg is a long* pointing to a long integer, where the programnumber will be stored in. The programnumber will have been converted from BCD to integer.

DA_SET_PROGNR
    Sets the current programnumber to the value passed by arg. arg is a long* pointing to a long integer containing the new programnumber.

DA_GET_PROGTIME
    Returns the current program time in a struct da_time pointed to by arg. arg is a struct da_time* which will be filled by da_control.

DA_SET_PROGTIME
    Sets the current programtime using the struct da_time pointed to by arg.

DA_GET_ABSTIME
    Gets the current absolute time in a struct da_time pointed to by arg. See above for the format of the struct da_time.

DA_SET_ABSTIME
    Sets the current absolute time using the struct da_time pointed to by arg.

DA_GET_RECORDDATE
    Gets the current record date associated with datfd into a struct da_date pointed to by arg.

DA_SET_RECORDDATE
    Sets the current recorddate of datfd. arg is a pointer to a struct da_date with the new date.

DA_GET_ISRC
    Returns the current ISRC (International Standard Recording Code) of datfd in a struct da_isrc pointed to by arg.

DA_SET_ISRC
    Sets the current ISRC of datfd. arg is a struct da_isrc* pointing to a struct da_isrc.

DA_GET_CATALOG
    Returns the current catalog number (usually the EAN or UPC barcode of the sold tape) in a struct da_catalog pointed to by arg.

DA_SET_CATALOG
    Sets the current catalog number. arg is a struct da_catalog* pointing to the new information.

DA_GET_TOCENTRY
    Returns the TOC (table of contents) entry specified by prognr and value in the struct da_tocentry pointed to by arg. The other values of the struct will be filled on return.
    There are some special programnumber entries marking length of tape, beginning etc. Please refer to the Postcript manual for their meanings. You may use DA_TOC_AA,DA_TOC_BB,DA_TOC_CC,DA_TOC_EE,DA_TOC_B0,DA_TOC_A0,DA_TOC_A1,DA_TOC_C0 and DA_TOC_C1 to refer to those entries.

DA_SET_TOCENTRY
    Adds the TOC entry passed using arg as a struct da_tocentry* to the table of contents. The table of contents is added to the subcode area while writing the tape.

DA_ABORT
    Abort current tape operation (like a running locate or rewind). This command will generate a SCSI ABORT message to the SCSI tapedevice.

DA_EJECT
    Ejects the tape (if datfd represents a real device). You should close the datfiledescriptor right after that.

DA_REWIND
    Rewind the tape (if datfd represents a real device).

DA_WRITE_LEADIN
    Writes a leadin zone on the datfiledescriptor.

DA_WRITE_LEADOUT
    Writes a leadout zone on the datfiledescriptor.

DA_LOCATE
    Seeks forward or backward to a position specified by the struct da_locate pointed to by arg. type can be DA_LOC_PROGNR,DA_LOC_ABSTIME,DA_LOC_RECTIME or DA_LOC_PROGTIME. Except for DA_LOG_PROGNR, the struct da_time part of the union will be used.
    DA_LOCATE behaves differently depending on the value of nextop and if the datfiledescriptor was opened with the flag O_NDELAY. nextop can be DA_LOC_NEXTOP_READ or DA_LOC_NEXTOP_WRITE (depending on which action the caller wants to do next, if unsure, use DA_LOC_NEXTOP_WRITE).
    If the datfd was opened with O_NDELAY the library will start a LOCATE operation and return immediately (with the tape still seeking). Any further reads will return immediately with a length of 0 bytes read until the tape has stopped at the target position.
    A program number of 0xAAA will seek to the beginning of the tape, a program number of 0xBBB will seek to the end of the tape.

DA_READ_POSITION
    Uses the SCSI command READ POSITION to read the current position of the tape and stores it into the internal state and returns it in a struct da_position.

DA_SET_TRACKNAME
    Sets the trackname to the parameters passed in a struct da_trackname. The tracknames will be stored in a special format on the tape.

DA_GET_TRACKNAME
    Returns the trackname for the track specified by prognr in the struct da_trackname pointed to by arg.

DA_GET_TRACKTIME
    Returns the tracktime for the current track in a struct da_time pointed to by arg.

DA_SET_TRACKTIME
    Set the tracktime for this track using the struct da_time pointed to by arg.

PARAMETERS

  Input Parameters

datfd
    A datfiledescriptor returned by either da_init or da_open.

code
    What action to do.

arg Depends on code , usually a pointer to a struct or a long integer.

RETURN VALUE

arg Depends on code , usually a pointer to a struct or a long integer.
    When an error condition arises, this routine returns -1 and sets errno to indicate the reason for the error. Possible values of errno are:

EINVAL
    The datfd is invalid.

other
    A lot of other errors.

USAGE EXAMPLE

		int datfd;
		datfd=da_init(fileno(stdin));

SEE ALSO
da_intro(3),da_init(3)

AUTHOR
Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de>