Gnash  0.8.10
AuxStream.h
Go to the documentation of this file.
00001 // AuxStream.h - external sound input stream
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 #ifndef SOUND_AUXSTREAM_H
00021 #define SOUND_AUXSTREAM_H
00022 
00023 #include "InputStream.h" // for inheritance
00024 
00025 #include <boost/cstdint.hpp> // For C99 int types
00026 
00027 namespace gnash {
00028 namespace sound {
00029 
00031 typedef unsigned int (*aux_streamer_ptr)(void *udata,
00032         boost::int16_t* samples, unsigned int nSamples, bool& eof);
00033 
00034 class AuxStream : public InputStream {
00035 public:
00036     AuxStream(aux_streamer_ptr cb, void* arg)
00037         :
00038         _samplesFetched(0),
00039         _eof(false),
00040         _cb(cb),
00041         _cbArg(arg)
00042     {}
00043 
00044     // See dox in InputStream.h
00045     unsigned int fetchSamples(boost::int16_t* to, unsigned int nSamples)
00046     {
00047         unsigned int wrote = _cb(_cbArg, to, nSamples, _eof);
00048         _samplesFetched += wrote;
00049         return wrote;
00050     }
00051 
00052     // See dox in InputStream.h
00053     unsigned int samplesFetched() const
00054     {
00055         return _samplesFetched;
00056     }
00057 
00058     // See dox in InputStream.h
00059     bool eof() const 
00060     {
00061         return _eof;
00062     }
00063 
00064 private:
00065     unsigned int _samplesFetched;
00066     bool _eof;
00067     aux_streamer_ptr _cb;
00068     void* _cbArg;
00069 };
00070 
00071 } // gnash.sound namespace 
00072 } // namespace gnash
00073 
00074 #endif // SOUND_AUXSTREAM_H