pablio.h

00001 #ifndef _PABLIO_H
00002 #define _PABLIO_H
00003 
00004 #ifdef __cplusplus
00005 extern "C"
00006 {
00007 #endif /* __cplusplus */
00008 
00009 /*
00010  * $Id: pablio.h 94 2003-05-13 10:54:17Z rene-cvs $
00011  * PABLIO.h
00012  * Portable Audio Blocking read/write utility.
00013  *
00014  * Author: Phil Burk, http://www.softsynth.com/portaudio/
00015  *
00016  * Include file for PABLIO, the Portable Audio Blocking I/O Library.
00017  * PABLIO is built on top of PortAudio, the Portable Audio Library.
00018  * For more information see: http://www.audiomulch.com/portaudio/
00019  * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
00020  *
00021  * Permission is hereby granted, free of charge, to any person obtaining
00022  * a copy of this software and associated documentation files
00023  * (the "Software"), to deal in the Software without restriction,
00024  * including without limitation the rights to use, copy, modify, merge,
00025  * publish, distribute, sublicense, and/or sell copies of the Software,
00026  * and to permit persons to whom the Software is furnished to do so,
00027  * subject to the following conditions:
00028  *
00029  * The above copyright notice and this permission notice shall be
00030  * included in all copies or substantial portions of the Software.
00031  *
00032  * Any person wishing to distribute modifications to the Software is
00033  * requested to send the modifications to the original developer so that
00034  * they can be incorporated into the canonical version.
00035  *
00036  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00037  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00038  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00039  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00040  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00041  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00042  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00043  *
00044  */
00045 #include <stdio.h>
00046 #include <stdlib.h>
00047 #include <math.h>
00048 #include "portaudio.h"
00049 #include "ringbuffer.h"
00050 #include <string.h>
00051 
00052 typedef struct
00053 {
00054     RingBuffer   inFIFO;
00055     RingBuffer   outFIFO;
00056     PortAudioStream *stream;
00057     int          bytesPerFrame;
00058     int          samplesPerFrame;
00059 }
00060 PABLIO_Stream;
00061 
00062 /* Values for flags for OpenAudioStream(). */
00063 #define PABLIO_READ     (1<<0)
00064 #define PABLIO_WRITE    (1<<1)
00065 #define PABLIO_READ_WRITE    (PABLIO_READ|PABLIO_WRITE)
00066 #define PABLIO_MONO     (1<<2)
00067 #define PABLIO_STEREO   (1<<3)
00068 
00069 /************************************************************
00070  * Write data to ring buffer.
00071  * Will not return until all the data has been written.
00072  */
00073 long WriteAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
00074 
00075 /************************************************************
00076  * Read data from ring buffer.
00077  * Will not return until all the data has been read.
00078  */
00079 long ReadAudioStream( PABLIO_Stream *aStream, void *data, long numFrames );
00080 
00081 /************************************************************
00082  * Return the number of frames that could be written to the stream without
00083  * having to wait.
00084  */
00085 long GetAudioStreamWriteable( PABLIO_Stream *aStream );
00086 
00087 /************************************************************
00088  * Return the number of frames that are available to be read from the
00089  * stream without having to wait.
00090  */
00091 long GetAudioStreamReadable( PABLIO_Stream *aStream );
00092 
00093 /************************************************************
00094  * Opens a PortAudio stream with default characteristics.
00095  * Allocates PABLIO_Stream structure.
00096  *
00097  * flags parameter can be an ORed combination of:
00098  *    PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
00099  *    and either PABLIO_MONO or PABLIO_STEREO
00100  */
00101 PaError OpenAudioStream( PABLIO_Stream **aStreamPtr, double sampleRate,
00102                          PaSampleFormat format, long flags );
00103 
00104 PaError CloseAudioStream( PABLIO_Stream *aStream );
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif /* __cplusplus */
00109 #endif /* _PABLIO_H */

Generated on Mon Jun 5 10:20:43 2006 for Intelligence.kdevelop by  doxygen 1.4.6