Main Page   Compound List   File List   Compound Members   File Members  

cslpcm.c File Reference

#include "cslpcm.h"
#include "cslutils.h"
#include "cslprivate.h"
#include <string.h>

Functions

CslErrorType csl_pcm_open_output (CslDriver *driver, const char *role, unsigned int rate, unsigned int n_channels, CslPcmFormatType format, CslPcmStream **stream_p)
 Open PCM input stream. More...

CslErrorType csl_pcm_open_input (CslDriver *driver, const char *role, unsigned int rate, unsigned int n_channels, CslPcmFormatType format, CslPcmStream **stream_p)
 Open PCM output stream. More...

CslPcmFormatType csl_pcm_get_format (CslPcmStream *stream)
 Return stream format. More...

void csl_pcm_close (CslPcmStream *stream)
 Close PCM stream. More...

int csl_pcm_read (CslPcmStream *stream, unsigned int n_bytes, void *bytes)
 Read from a stream. More...

int csl_pcm_write (CslPcmStream *stream, unsigned int n_bytes, void *bytes)
 Write to a stream. More...

CslErrorType csl_pcm_get_status (CslPcmStream *stream, CslPcmStatus *status)
 Get stream status. More...

CslErrorType csl_pcm_flush (CslPcmStream *stream)
 Flush PCM data. More...

CslErrorType csl_pcm_sync (CslPcmStream *stream)
 Sync PCM data. More...

CslErrorType csl_pcm_activate (CslPcmStream *stream)
 Activate a PCM stream. More...

CslErrorType csl_pcm_suspend (CslPcmStream *stream)
 Suspend a PCM stream. More...

CslErrorType csl_pcm_set_title (CslPcmStream *stream, const char *title)
 Set stream title. More...

char* csl_pcm_dup_title (CslPcmStream *stream)
 Get stream title. More...

CslErrorType csl_pcm_set_stream_mode (CslPcmStream *stream, unsigned int buffer_size)
 Set stream buffer size. More...

CslErrorType csl_pcm_set_packet_mode (CslPcmStream *stream, unsigned int n_packets, unsigned int packet_size)
 Put stream in packet mode. More...

CslErrorType csl_pcm_set_stream_watermark (CslPcmStream *stream, unsigned int n_bytes)
 Set stream watermark. More...

CslErrorType csl_pcm_set_packet_watermark (CslPcmStream *stream, unsigned int n_packets)
 Set stream watermark. More...

void csl_pcm_get_stream_settings (CslPcmStream *stream, unsigned int *buffer_size_p, unsigned int *byte_watermark_p)
 Get PCM stream settings. More...

void csl_pcm_get_packet_settings (CslPcmStream *stream, unsigned int *n_packets_p, unsigned int *packet_size_p, unsigned int *packet_watermark_p)
 Get PCM stream packet settings. More...

char** csl_pcm_list_channel_mappings (CslDriver *driver, unsigned int *n_maps_p)
 List channel mappings. More...

CslErrorType csl_pcm_set_channel_mapping (CslPcmStream *stream, unsigned int channel, const char *mapping)
 Set channel mapping. More...

char* csl_pcm_dup_channel_mapping (CslPcmStream *stream, unsigned int channel)
 Duplicate channel mapping. More...


Function Documentation

CslErrorType csl_pcm_activate ( CslPcmStream * stream )
 

Activate a PCM stream.

Activate a previously suspended PCM stream, allowing it to transfer data again.

Parameters:
stream   The PCM stream to activate.
See also:
csl_pcm_suspend
Parameters:
stream  

void csl_pcm_close ( CslPcmStream * stream )
 

Close PCM stream.

Close a PCM input or output stream.

Parameters:
stream   The stream to be closed.
See also:
csl_pcm_open_output , csl_pcm_open_input
Parameters:
stream  

char* csl_pcm_dup_channel_mapping ( CslPcmStream * stream,
unsigned int channel )
 

Duplicate channel mapping.

Return the mapping of a channel name to channel number.

Warning:
This is not yet implemented and will always return NULL.
Parameters:
driver   The PCM stream.
channel   Channel number to use.
Returns:
The channel name. This is a dynamically allocated string which needs to be freed using csl_free when no longer needed.
See also:
csl_pcm_list_channel_mappings , csl_pcm_set_channel_mapping
Parameters:
stream  
channel  

char* csl_pcm_dup_title ( CslPcmStream * stream )
 

Get stream title.

Return the title string associated with a stream.

Parameters:
stream   The PCM stream.
Returns:
The stream name. This is a dynamically allocated string which needs to be freed using csl_free when no longer needed.
See also:
csl_pcm_set_title
Parameters:
stream  

CslErrorType csl_pcm_flush ( CslPcmStream * stream )
 

Flush PCM data.

Cancel any pending output written to an output stream. After a call to csl_pcm_write, data may still be stored in buffers. Calling this function will remove as many of these bytes as possible, i.e. try to stop playing immediately, cancelling already written bytes.

Warning:
Not yet implemented by all backend drivers.
Parameters:
stream   The PCM stream to flush.
Returns:
Error status code.
Parameters:
stream  

CslPcmFormatType csl_pcm_get_format ( CslPcmStream * stream )
 

Return stream format.

Return format information about a PCM stream.

Parameters:
stream   A previously opened stream.
Returns:
The stream format information.
Parameters:
stream  

void csl_pcm_get_packet_settings ( CslPcmStream * stream,
unsigned int * n_packets_p,
unsigned int * packet_size_p,
unsigned int * packet_watermark_p )
 

Get PCM stream packet settings.

Get the current stream settings for number of packets, size, and watermark.

Parameters:
stream   The PCM stream.
n_packets_p   Pointer to variable to store number of packets.
packet_size_p   Pointer to variable to store packet size, in bytes.
packet_watermark_p   Pointer to variable to store watermark setting.
Returns:
Error status code
Parameters:
stream  
n_packets_p  
packet_size_p  
packet_watermark_p  

CslErrorType csl_pcm_get_status ( CslPcmStream * stream,
CslPcmStatus * status )
 

Get stream status.

Obtains status information about a PCM stream.

Parameters:
stream   The PCM stream to query.
status   A pointer to variable to write the status information.
Returns:
Error status code.
Parameters:
stream  
status  

void csl_pcm_get_stream_settings ( CslPcmStream * stream,
unsigned int * buffer_size_p,
unsigned int * byte_watermark_p )
 

Get PCM stream settings.

Get the current stream settings for buffer size and watermark.

Parameters:
stream   The PCM stream.
buffer_size_p   Pointer to variable to store returned buffer size.
byte_watermark_p   Pointer to variable to store watermark setting.
Returns:
Error status code
Parameters:
stream  
buffer_size_p  
byte_watermark_p  

char** csl_pcm_list_channel_mappings ( CslDriver * driver,
unsigned int * n_maps_p )
 

List channel mappings.

List the mapping of channel names to channel numbers. These are the global channel names supported by a driver, and are fixed. You can dynamically assign channel names to PCM streams using csl_pcm_set_channel_mapping.

Parameters:
driver   The CSL driver (note, not a PCM stream).
n_maps_p   Pointer to variable in which to return the number of channel mapping strings returned.
Returns:
A pointer to a list of strings containing the names associated with each channel number.
See also:
csl_pcm_set_channel_mapping , csl_pcm_dup_channel_mapping
Parameters:
driver  
n_maps_p  

CslErrorType csl_pcm_open_input ( CslDriver * driver,
const char * role,
unsigned int rate,
unsigned int n_channels,
CslPcmFormatType format,
CslPcmStream ** stream_p )
 

Open PCM output stream.

Open a PCM stream for input, specifying a driver and data format.

Parameters:
driver   A pointer to a previously opened CSL driver.
role   A, identifier string that can be used by the underlying driver (see description under csl_pcm_open_output).
rate   Sampling rate in samples/second.
n_channels   Number of channels.
format   PCM data format.
stream_p   A pointer to write the opened stream.
Returns:
Error code indicating success or failure.
See also:
csl_pcm_open_input , csl_pcm_close
Parameters:
driver  
role  
rate  
n_channels  
format  
stream_p  

CslErrorType csl_pcm_open_output ( CslDriver * driver,
const char * role,
unsigned int rate,
unsigned int n_channels,
CslPcmFormatType format,
CslPcmStream ** stream_p )
 

Open PCM input stream.

Open a PCM stream for output, specifying a driver and data format.

Parameters:
driver   A pointer to a previously opened CSL driver.
role   A, identifier string used by the underlying driver. The role must be constant for a stream, should not be internationalized, and should should be different for different kinds of streams For eexample, role coul be assigned to something like "quake", "noatun", or "quake-sounds". This argument is mandatory.
rate   Sampling rate in samples/second.
n_channels   Number of channels.
format   PCM data format.
stream_p   A pointer to write the opened stream.
Returns:
Error code indicating success or failure.
See also:
csl_pcm_open_input , csl_pcm_close
Parameters:
driver  
role  
rate  
n_channels  
format  
stream_p  

int csl_pcm_read ( CslPcmStream * stream,
unsigned int n_bytes,
void * bytes )
 

Read from a stream.

Read bytes from a PCM input stream.

Parameters:
stream   The PCM stream to read.
n_bytes   Number of bytes to read.
bytes   Pointer to buffer to store the data read.
Returns:
Returns the number of bytes read or -1 if an error occurred.
See also:
csl_pcm_write
Parameters:
stream  
n_bytes  
bytes  

CslErrorType csl_pcm_set_channel_mapping ( CslPcmStream * stream,
unsigned int channel,
const char * mapping )
 

Set channel mapping.

Set the mapping of a channel name to channel number.

Warning:
This is not yet implemented and will always return an error code of CSL_ENONE.
Parameters:
driver   The PCM stream.
channel   Channel number to set.
mapping   String containing name for channel, either a literal string or a constant such as CSL_PCM_CHANNEL_FRONT_LEFT.
Returns:
Error return code.
See also:
csl_pcm_list_channel_mappings , csl_pcm_dup_channel_mapping
Parameters:
stream  
channel  
mapping  

CslErrorType csl_pcm_set_packet_mode ( CslPcmStream * stream,
unsigned int n_packets,
unsigned int packet_size )
 

Put stream in packet mode.

Put stream in real-time packet mode, setting the number of packets and packet size.

Parameters:
stream   The PCM stream.
n_packets   Number of packets.
packet_size   Size of each packet, in bytes.
Returns:
Error status code
Parameters:
stream  
n_packets  
packet_size  

CslErrorType csl_pcm_set_packet_watermark ( CslPcmStream * stream,
unsigned int n_packets )
 

Set stream watermark.

Set the watermark for a stream, i.e. the number of packets that must be pending in the buffer before the stream is written (is this accurate?).

Parameters:
stream   The PCM stream.
n_packets   Number of packets to set as watermark point.
Returns:
Error status code
See also:
csl_pcm_set_stream_watermark
Parameters:
stream  
n_packets  

CslErrorType csl_pcm_set_stream_mode ( CslPcmStream * stream,
unsigned int buffer_size )
 

Set stream buffer size.

Set the buffer size for a stream to a new value. (why is the name misleading?)

Parameters:
stream   The PCM stream.
buffer_size   The new buffer size, in bytes.
Returns:
Error status code
Parameters:
stream  
buffer_size  

CslErrorType csl_pcm_set_stream_watermark ( CslPcmStream * stream,
unsigned int n_bytes )
 

Set stream watermark.

Set the watermark for a stream, i.e. the number of bytes that must be pending in the buffer before the stream is written (is this accurate?).

Parameters:
stream   The PCM stream.
n_bytes   Number of bytes to set as watermark point.
Returns:
Error status code
See also:
csl_pcm_set_packet_watermark
Parameters:
stream  
n_bytes  

CslErrorType csl_pcm_set_title ( CslPcmStream * stream,
const char * title )
 

Set stream title.

Associate a title string with the stream. The title may be shown to the end user to describe the stream. The title should be internationalized (in UTF-8 format) and can change. If you don't assign a title, it will default to the role parameter for the stream.

Parameters:
title   String to use as the title.
stream   The PCM stream.
Returns:
Error status code
See also:
csl_pcm_dup_title
Parameters:
stream  
title  

CslErrorType csl_pcm_suspend ( CslPcmStream * stream )
 

Suspend a PCM stream.

Suspend a PCM stream, preventing it from passing any further data until activated.

Parameters:
stream   The PCM stream to suspend.
See also:
csl_pcm_activate
Parameters:
stream  

CslErrorType csl_pcm_sync ( CslPcmStream * stream )
 

Sync PCM data.

Ensure PCM data has been written to an output device. After a call to csl_pcm_write, data may still be stored in buffers. Calling this function ensures that it has actually been written to the audio output device.

Warning:
Not yet implemented by backend drivers.
Parameters:
stream   The PCM stream to sync.
Returns:
Error status code.
Parameters:
stream  

int csl_pcm_write ( CslPcmStream * stream,
unsigned int n_bytes,
void * bytes )
 

Write to a stream.

Write bytes to a PCM output stream.

Parameters:
stream   The PCM stream to write.
n_bytes   Number of bytes to write.
bytes   Pointer to buffer containing the data to be written.
Returns:
Returns the number of bytes written or -1 if an error occurred.
See also:
csl_pcm_read
Parameters:
stream  
n_bytes  
bytes  


Generated at Wed Jun 6 17:51:42 2001 for CSL by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001