NAME
YSetAudioModeValues - Audio values setting
SYNTAX
#include <Y2/Y.h>
#include <Y2/Ylib.h>
int YSetAudioModeValues(
YConnection *connection,
int sample_size,
int channels,
int sample_rate,
int direction,
int allow_fragmenting,
int num_fragments,
int fragment_size
)
ARGUMENTS
connection
Specifies the connection to the Y server, obtained by a call to
YOpenConnection.
sample_size
Specifies the sample size in bits, valid values are 8 or 16.
channels
Specifies the number of channels, valid values are 1 or 2.
(mono and stereo respectivly).
sample_rate
Specifies the same rate in Hz. Setting this value to 0 has a
special meaning (see description farther below).
direction
Specifies to play or record, 0 for play and 1 for record. Note
that record has not been fully implmented yet as of Y2, most Y
servers do not support it!
allow_fragmenting
Specifies whether to allow fragmenting of buffers (this is an
OSS compliancy option). This should always be set to 1 (true) to
comply with OSS.
num_fragments
Specifies the number of buffer fragments, a value of 2 is the
default.
fragment_size
Specifies the size of each buffer fragment in bytes.
DESCRIPTION
Audio to the values specified. Any sound objects currently being played
will be killed and the owning Y clients will be notified.
If sample_rate is set to 0, then the recorder will be shelled out.
Allowing other direct programs to use the recorder’s devices (DSP
device, mixer, etc). Y clients will not notice any differance, the Y
server will emulate (but not actually perform) normal operations
(including the playing of sound objects).
To unshell the recorder, simply call YSetAudioModeValues or
YChangeAudioModePreset with valid values.
RETURN VALUE
The YSetAudioModeValues function returns -1 on error/invalid value or 0
on success.
EXAMPLE
#include <stdio.h>
#include <Y2/Y.h>
#include <Y2/Ylib.h>
int main(int argc, char *argv[])
{
YConnection *con = YOpenConnection(
"/usr/sbin/starty",
"127.0.0.1:9433"
);
if(con == NULL)
return(1);
if(YSetAudioModeValues(
con, /* Connection. */
8, /* Sample size. */
2, /* Channels. */
11025, /* Sample rate. */
0, /* Play. */
True, /* Allow fragmenting. */
2, /* Number of buf frags. */
1024 /* Buffer frag size in bytes. */
))
printf("Failed.\n");
else
printf("Success.\n");
YCloseConnection(con, False);
return(0);
}
SEE ALSO
YChangeAudioModePreset(3) YGetAudioStats(3)