Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members  

pipe.h

Go to the documentation of this file.
00001 /*
00002   Copyright (c) 2001 Charles Samuels <charles@kde.org>
00003   Copyright (c) 2002-2004 Denis Rojo <jaromil@dyne.org>
00004   
00005   this pipe class was first written by Charles Samuels
00006   and almost completely rewritten by Denis "jaromil" Rojo
00007   
00008   This library is free software; you can redistribute it and/or
00009   modify it under the terms of the GNU Library General Public
00010   License as published by the Free Software Foundation; either
00011   version 2 of the License, or (at your option) any later version.
00012   
00013   This library is distributed in the hope that it will be useful,
00014   but WITHOUT ANY WARRANTY; without even the implied warranty of
00015   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016   Library General Public License for more details.
00017   
00018   You should have received a copy of the GNU Library General Public License
00019   along with this library; see the file COPYING.LIB.  If not, write to
00020   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021   Boston, MA 02111-1307, USA.
00022   
00023   $Id: pipe.h,v 1.5 2004/12/13 00:26:37 jaromil Exp $
00024 
00025 */
00026 
00032 #ifndef __PIPE_H__
00033 #define __PIPE_H__
00034 
00035 #include <pthread.h>
00036 #include <string.h>
00037 #include <inttypes.h>
00038 
00074 typedef void (pipe_copy_f)(void *src, void *dst, int samples);
00075 
00077 typedef struct pipe_copy_list {
00078   char *name;
00079   pipe_copy_f *callback;
00080   int src_samplesize;
00081   int dst_samplesize;
00082 };
00083 
00084 class Pipe {
00085 public:
00086 
00090   Pipe(int size=16384);
00092   
00093   ~Pipe();
00095 
00116   bool set_input_type(char *name);
00118   bool set_output_type(char *name);
00120 
00121   void set_block(bool input, bool output);
00123   void set_block_timeout(int input, int output);
00125 
00138   int read(int length, void *data);
00140  
00153   //  int read_float_intl(int samples, float *buf, int channels);
00154 
00163   //  int read_float_bidi(int samples, float **buf, int channels);
00165    
00175   //  int mix16stereo(int samples, int32_t *mix);
00176   
00177   //    int peek(int length, void *data, bool block=true) const; // TODO
00178  
00189   int write(int length, void *data);
00190 
00199   //  int write_float2int(int length, void *data);
00200 
00209   //  int write_int2float(int length, void *data);
00210 
00216   void block(bool val);
00217 
00218   bool blocking;
00219 
00223   int size();
00224  
00228   int space();
00229   
00230   void flush(); 
00231 
00232   void flush(int size);
00234     
00235  private:
00236   pthread_mutex_t _mutex;
00237   void _thread_init() { pthread_mutex_init (&_mutex,NULL); };
00238   void _thread_destroy() { pthread_mutex_destroy(&_mutex); };
00239   void lock() { pthread_mutex_lock(&_mutex); };
00240   void unlock() { pthread_mutex_unlock(&_mutex); };
00241   
00242   void *buffer;
00243   void *bufferEnd;
00244   
00245   void *start;
00246   void *end;
00247 
00248   pipe_copy_list *read_copy_cb;
00249   pipe_copy_list *write_copy_cb;
00250 
00251   int pipesize;
00252   
00253   bool read_blocking;
00254   bool write_blocking;
00255   int read_blocking_time;
00256   int write_blocking_time;
00257 
00258 };
00259 
00260 #endif

Generated on Thu Dec 16 12:28:21 2004 for MuSE by doxygen1.3