Main Page   Compound List   File List   Compound Members   File Members  

cslpcm.h

Go to the documentation of this file.
00001 /* CSL - Common Sound Layer
00002  * Copyright (C) 2000-2001 Stefan Westerfeld and Tim Janik
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Lesser General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General
00015  * Public License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 #ifndef __CSL_PCM_H__
00020 #define __CSL_PCM_H__
00021 
00022 
00023 #include        <csl/csldefs.h>
00024 #include        <csl/cslmain.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif /* __cplusplus */
00029 
00035 /* --- CSL PCM API --- */
00036 
00042 typedef struct _CslPcmStream    CslPcmStream;
00043 
00049 typedef struct _CslPcmStatus    CslPcmStatus;
00050 
00059 typedef enum            /* keep in sync with cslarts.idl */
00060 {
00062   CSL_PCM_FORMAT_SIZE_8                         = 0x0008,
00063   CSL_PCM_FORMAT_SIZE_16                        = 0x0010,
00064   CSL_PCM_FORMAT_SIZE_32                        = 0x0020,
00065   CSL_PCM_FORMAT_SIZE_MASK                      = 0x00FF,
00066   
00068   CSL_PCM_FORMAT_ENDIAN_LE                      = 0x0100,
00069   CSL_PCM_FORMAT_ENDIAN_BE                      = 0x0200,
00070   CSL_PCM_FORMAT_ENDIAN_MASK                    = 0x0F00,
00071   
00073   CSL_PCM_FORMAT_ENCODING_LINEAR_SIGNED         = 0x1000,
00074   CSL_PCM_FORMAT_ENCODING_LINEAR_UNSIGNED       = 0x2000,
00075   CSL_PCM_FORMAT_ENCODING_FLOAT                 = 0x3000,
00076   CSL_PCM_FORMAT_ENCODING_MASK                  = 0xF000,
00077   
00079   CSL_PCM_FORMAT_U8                             = 0x2008,
00080   CSL_PCM_FORMAT_S16_LE                         = 0x1110,
00081   CSL_PCM_FORMAT_S16_BE                         = 0x1210,
00082   CSL_PCM_FORMAT_FLOAT_LE                       = 0x3120,
00083   CSL_PCM_FORMAT_FLOAT_BE                       = 0x3220,
00084 } CslPcmFormatType;
00085 
00086 /* defines for host endianess */
00087 #if CSL_BYTE_ORDER == CSL_LITTLE_ENDIAN
00088 #define CSL_PCM_FORMAT_S16_HE           CSL_PCM_FORMAT_S16_LE
00089 #define CSL_PCM_FORMAT_FLOAT_HE         CSL_PCM_FORMAT_FLOAT_LE
00090 #else /* CSL_BYTE_ORDER == CSL_LITTLE_ENDIAN */
00091 #define CSL_PCM_FORMAT_S16_HE           CSL_PCM_FORMAT_S16_BE
00092 #define CSL_PCM_FORMAT_FLOAT_HE         CSL_PCM_FORMAT_FLOAT_BE
00093 #endif
00094 
00101 struct _CslPcmStatus
00102 {
00104   unsigned int     rate;
00106   unsigned int     n_channels;
00108   unsigned int     n_bits;
00109   CslPcmFormatType format;
00111   unsigned int     buffer_size; /* in bytes */
00113   unsigned int     n_bytes_available;
00114   unsigned int     packet_size;
00115   unsigned int     n_buffer_packets;
00117   unsigned int     n_packets_available;
00118   unsigned int     padding[128];
00119   /* server side latency in seconds
00120    * (rate*server_latency==n_values_queued_on_server)
00121    */
00122   float            server_latency;
00123 };
00124 
00125 CslErrorType csl_pcm_open_output                (CslDriver       *driver,
00126                                                  const char      *role,
00127                                                  unsigned int     rate,
00128                                                  unsigned int     n_channels,
00129                                                  CslPcmFormatType format,
00130                                                  CslPcmStream   **stream_p);
00131 CslErrorType csl_pcm_open_input                 (CslDriver       *driver,
00132                                                  const char      *role,
00133                                                  unsigned int     rate,
00134                                                  unsigned int     n_channels,
00135                                                  CslPcmFormatType format,
00136                                                  CslPcmStream   **stream_p);
00137 /* for coupled streams:
00138  * flush affects all
00139  * sync affects all
00140  * behaviour for in-streams:
00141  * flush: empty capture queue
00142  * sync: NOP? (flush?)
00143  */
00144 CslPcmFormatType csl_pcm_get_format             (CslPcmStream    *stream);
00145 void             csl_pcm_close                  (CslPcmStream    *stream);
00146 
00147 /* return n_bytes processed or -1==error (FIXME: need is_broken()) */
00148 int              csl_pcm_read                   (CslPcmStream    *stream,
00149                                                  unsigned int     n_bytes,
00150                                                  void            *bytes);
00151 int              csl_pcm_write                  (CslPcmStream    *stream,
00152                                                  unsigned int     n_bytes,
00153                                                  void            *bytes);
00154 
00155 CslErrorType     csl_pcm_get_status             (CslPcmStream    *stream,
00156                                                  CslPcmStatus    *status);
00157 CslErrorType     csl_pcm_flush                  (CslPcmStream    *stream);
00158 CslErrorType     csl_pcm_sync                   (CslPcmStream    *stream);
00159 
00160 
00161 /* --- advanced API --- */
00162 /* buffer_size always in n_bytes */
00163 CslErrorType    csl_pcm_set_title               (CslPcmStream   *stream,
00164                                                  const char     *title);
00165 char*           csl_pcm_dup_title               (CslPcmStream   *stream); /* needs csl_free() */
00166 CslErrorType    csl_pcm_set_stream_mode         (CslPcmStream   *stream,
00167                                                  unsigned int    buffer_size,
00168                                                  unsigned int    byte_watermark);
00169 void            csl_pcm_get_stream_settings     (CslPcmStream   *stream,
00170                                                  unsigned int   *buffer_size_p,
00171                                                  unsigned int   *byte_watermark_p);
00172 CslErrorType    csl_pcm_set_packet_mode         (CslPcmStream   *stream,
00173                                                  unsigned int    n_packets,
00174                                                  unsigned int    packet_size,
00175                                                  unsigned int    packet_watermark);
00176 void            csl_pcm_get_packet_settings     (CslPcmStream   *stream,
00177                                                  unsigned int   *n_packets_p,
00178                                                  unsigned int   *packet_size_p,
00179                                                  unsigned int   *packet_watermark_p);
00180 
00181 
00182 /* --- proposed --- */
00183 #define CSL_PCM_CHANNEL_FRONT_LEFT      "<front-left>"
00184 #define CSL_PCM_CHANNEL_FRONT_RIGHT     "<front-right>"
00185 #define CSL_PCM_CHANNEL_CENTER          "<center>"
00186 #define CSL_PCM_CHANNEL_REAR_LEFT       "<rear-left>"
00187 #define CSL_PCM_CHANNEL_REAR_RIGHT      "<rear-right>"
00188 #define CSL_PCM_CHANNEL_SUB_WOOFER      "<sub-woofer>"
00189 #if 0
00190 
00200 CslErrorType    csl_pcm_set_channel_mapping     (CslPcmStream   *stream,
00201                                                  unsigned int    channel,
00202                                                  const char     *mapping);
00203 char*           csl_pcm_dup_channel_mapping     (CslPcmStream   *stream,
00204                                                  unsigned int    channel);
00205 char**          csl_pcm_list_channel_mappings   (CslDriver      *driver,
00206                                                  unsigned int   *n_maps_p);
00207 #endif
00208 
00209 #ifdef __cplusplus
00210 }
00211 #endif /* __cplusplus */
00212 
00213 #endif /* __CSL_PCM_H__ */ /* vim:set ts=8 sw=2 sts=2: */

Generated on Wed Oct 31 18:45:21 2001 for CSL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001