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 #if CSL_BYTE_ORDER == CSL_LITTLE_ENDIAN
00087 #define CSL_PCM_FORMAT_S16_HE           CSL_PCM_FORMAT_S16_LE
00088 #define CSL_PCM_FORMAT_FLOAT_HE         CSL_PCM_FORMAT_FLOAT_LE
00089 #else /* CSL_BYTE_ORDER == CSL_LITTLE_ENDIAN */
00090 #define CSL_PCM_FORMAT_S16_HE           CSL_PCM_FORMAT_S16_BE
00091 #define CSL_PCM_FORMAT_FLOAT_HE         CSL_PCM_FORMAT_FLOAT_BE
00092 #endif
00093 
00100 struct _CslPcmStatus
00101 {
00103   unsigned int     rate;
00105   unsigned int     n_channels;
00107   unsigned int     n_bits;
00108   CslPcmFormatType format;
00110   unsigned int     buffer_size;
00112   unsigned int     n_bytes_available;
00113   unsigned int     packet_size;
00114   unsigned int     n_buffer_packets;
00116   unsigned int     n_packets_available;
00117   unsigned int     padding[128];
00118   /*
00119     CSL_PCM_PARAM_SERVER_LATENCY,
00120     CSL_PCM_PARAM_TOTAL_LATENCY,
00121     CSL_PCM_PARAM_BLOCKING,
00122   */
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 
00132 CslErrorType csl_pcm_open_input                 (CslDriver       *driver,
00133                                                  const char      *role,
00134                                                  unsigned int     rate,
00135                                                  unsigned int     n_channels,
00136                                                  CslPcmFormatType format,
00137                                                  CslPcmStream   **stream_p);
00138 
00139 CslPcmFormatType csl_pcm_get_format             (CslPcmStream    *stream);
00140 
00141 void             csl_pcm_close                  (CslPcmStream    *stream);
00142 
00143 /* return n_bytes processed or -1==error (FIXME: need is_broken()) */
00144 int              csl_pcm_read                   (CslPcmStream    *stream,
00145                                                  unsigned int     n_bytes,
00146                                                  void            *bytes);
00147 
00148 int              csl_pcm_write                  (CslPcmStream    *stream,
00149                                                  unsigned int     n_bytes,
00150                                                  void            *bytes);
00151 
00152 CslErrorType     csl_pcm_get_status             (CslPcmStream    *stream,
00153                                                  CslPcmStatus    *status);
00154 
00155 CslErrorType     csl_pcm_flush                  (CslPcmStream    *stream);
00156 
00157 CslErrorType     csl_pcm_sync                   (CslPcmStream    *stream);
00158 
00159 CslErrorType     csl_pcm_activate               (CslPcmStream    *stream);
00160 
00161 CslErrorType     csl_pcm_suspend                (CslPcmStream    *stream);
00162 
00163 /* --- advanced API --- */
00164 
00165 #define CSL_PCM_CHANNEL_FRONT_LEFT      "<front-left>"
00166 #define CSL_PCM_CHANNEL_FRONT_RIGHT     "<front-right>"
00167 #define CSL_PCM_CHANNEL_CENTER          "<center>"
00168 #define CSL_PCM_CHANNEL_REAR_LEFT       "<rear-left>"
00169 #define CSL_PCM_CHANNEL_REAR_RIGHT      "<rear-right>"
00170 
00179 #define CSL_PCM_CHANNEL_SUB_WOOFER      "<sub-woofer>"
00180 
00181 /* buffer_size always in n_bytes */
00182 
00183 CslErrorType    csl_pcm_set_title               (CslPcmStream   *stream,
00184                                                  const char     *title);
00185 
00186 char*           csl_pcm_dup_title               (CslPcmStream   *stream); /* needs free() */
00187 
00188 CslErrorType    csl_pcm_set_stream_mode         (CslPcmStream   *stream,
00189                                                  unsigned int    buffer_size);
00190 
00191 CslErrorType    csl_pcm_set_stream_watermark    (CslPcmStream   *stream,
00192                                                  unsigned int    n_bytes);
00193 
00194 void            csl_pcm_get_stream_settings     (CslPcmStream   *stream,
00195                                                  unsigned int   *buffer_size_p,
00196                                                  unsigned int   *byte_watermark_p);
00197 
00198 CslErrorType    csl_pcm_set_packet_mode         (CslPcmStream   *stream,
00199                                                  unsigned int    n_packets,
00200                                                  unsigned int    packet_size);
00201 
00202 CslErrorType    csl_pcm_set_packet_watermark    (CslPcmStream   *stream,
00203                                                  unsigned int    n_packets);
00204 
00205 void            csl_pcm_get_packet_settings     (CslPcmStream   *stream,
00206                                                  unsigned int   *n_packets_p,
00207                                                  unsigned int   *packet_size_p,
00208                                                  unsigned int   *packet_watermark_p);
00209 
00210 CslErrorType    csl_pcm_set_channel_mapping     (CslPcmStream   *stream,
00211                                                  unsigned int    channel,
00212                                                  const char     *mapping);
00213 
00214 char*           csl_pcm_dup_channel_mapping     (CslPcmStream   *stream,
00215                                                  unsigned int    channel);
00216 
00217 char**          csl_pcm_list_channel_mappings   (CslDriver      *driver,
00218                                                  unsigned int   *n_maps_p);
00219 
00220 #ifdef __cplusplus
00221 }
00222 #endif /* __cplusplus */
00223 
00224 #endif /* __CSL_PCM_H__ */
00225 /* vim:ts=8:sw=2:sts=2
00226  */

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