MythTV  0.26-pre
FIFOSamplePipe.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 //
00020 // Last changed  : $Date$
00021 // File revision : $Revision$
00022 //
00023 // $Id$
00024 //
00026 //
00027 // License :
00028 //
00029 //  SoundTouch audio processing library
00030 //  Copyright (c) Olli Parviainen
00031 //
00032 //  This library is free software; you can redistribute it and/or
00033 //  modify it under the terms of the GNU Lesser General Public
00034 //  License as published by the Free Software Foundation; either
00035 //  version 2.1 of the License, or (at your option) any later version.
00036 //
00037 //  This library is distributed in the hope that it will be useful,
00038 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00039 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00040 //  Lesser General Public License for more details.
00041 //
00042 //  You should have received a copy of the GNU Lesser General Public
00043 //  License along with this library; if not, write to the Free Software
00044 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00045 //
00047 
00048 #ifndef FIFOSamplePipe_H
00049 #define FIFOSamplePipe_H
00050 
00051 #include <assert.h>
00052 #include <stdlib.h>
00053 #include "STTypes.h"
00054 
00056 class FIFOSamplePipe
00057 {
00058 public:
00066     virtual soundtouch::SAMPLETYPE *ptrBegin() const = 0;
00067 
00070     virtual void putSamples(const soundtouch::SAMPLETYPE *samples,  
00071                             uint numSamples                         
00072                             ) = 0;
00073 
00074 
00075     // Moves samples from the 'other' pipe instance to this instance.
00076     void moveSamples(FIFOSamplePipe &other  
00077          )
00078     {
00079         int oNumSamples = other.numSamples();
00080 
00081         putSamples(other.ptrBegin(), oNumSamples);
00082         other.receiveSamples(oNumSamples);
00083     };
00084 
00090     virtual uint receiveSamples(soundtouch::SAMPLETYPE *output, 
00091                                 uint maxSamples                 
00092                                 ) = 0;
00093 
00099     virtual uint receiveSamples(uint maxSamples   
00100                                 ) = 0;
00101 
00103     virtual uint numSamples() const = 0;
00104 
00105     // Returns nonzero if there aren't any samples available for outputting.
00106     virtual int isEmpty() const = 0;
00107 
00109     virtual void clear() = 0;
00110 
00112     virtual ~FIFOSamplePipe() {}
00113 };
00114 
00115 
00116 
00125 class FIFOProcessor :public FIFOSamplePipe
00126 {
00127 protected:
00129     FIFOSamplePipe *output;
00130 
00132     void setOutPipe(FIFOSamplePipe *pOutput)
00133     {
00134         assert(output == NULL);
00135         assert(pOutput != NULL);
00136         output = pOutput;
00137     }
00138 
00139 
00142     FIFOProcessor()
00143     {
00144         output = NULL;
00145     }
00146 
00147 
00149     FIFOProcessor(FIFOSamplePipe *pOutput   
00150                  )
00151     {
00152         output = pOutput;
00153     }
00154 
00155 
00157     virtual ~FIFOProcessor()
00158     {
00159     }
00160 
00161 
00169     virtual soundtouch::SAMPLETYPE *ptrBegin() const
00170     {
00171         return output->ptrBegin();
00172     }
00173 
00174 public:
00175 
00181     virtual uint receiveSamples(soundtouch::SAMPLETYPE *outBuffer, 
00182                                 uint maxSamples                    
00183                                 )
00184     {
00185         return output->receiveSamples(outBuffer, maxSamples);
00186     }
00187 
00188 
00194     virtual uint receiveSamples(uint maxSamples   
00195                                 )
00196     {
00197         return output->receiveSamples(maxSamples);
00198     }
00199 
00200 
00202     virtual uint numSamples() const
00203     {
00204         return output->numSamples();
00205     }
00206 
00207 
00209     virtual int isEmpty() const
00210     {
00211         return output->isEmpty();
00212     }
00213 };
00214 
00215 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends