device_null.h

Go to the documentation of this file.
00001 #ifndef DEVICE_NULL_H
00002 #define DEVICE_NULL_H
00003 
00004 
00005 #include <list>
00006 #include "audiere.h"
00007 #include "device.h"
00008 #include "internal.h"
00009 #include "threads.h"
00010 #include "types.h"
00011 #include "utility.h"
00012 
00013 
00014 namespace audiere {
00015 
00016   class NullOutputStream;
00017 
00018   class NullAudioDevice : public AbstractDevice, public Mutex {
00019   public:
00020     static NullAudioDevice* create(const ParameterList& parameters);
00021 
00022   private:
00023     NullAudioDevice();
00024     ~NullAudioDevice();
00025 
00026   public:
00027     void ADR_CALL update();
00028     OutputStream* ADR_CALL openStream(SampleSource* source);
00029     OutputStream* ADR_CALL openBuffer(
00030       void* samples, int frame_count,
00031       int channel_count, int sample_rate, SampleFormat sample_format);
00032     const char* ADR_CALL getName();
00033 
00034   private:
00035     void removeStream(NullOutputStream* stream);
00036 
00037     typedef std::list<NullOutputStream*> StreamList;
00038     StreamList m_streams;
00039 
00040     friend class NullOutputStream;
00041   };
00042 
00043   class NullOutputStream : public RefImplementation<OutputStream> {
00044   private:
00045     NullOutputStream(NullAudioDevice* device, SampleSource* source);
00046     ~NullOutputStream();
00047 
00048   public:
00049     void ADR_CALL play();
00050     void ADR_CALL stop();
00051     void ADR_CALL reset();
00052     bool ADR_CALL isPlaying();
00053 
00054     void ADR_CALL setRepeat(bool repeat);
00055     bool ADR_CALL getRepeat();
00056 
00057     void  ADR_CALL setVolume(float volume);
00058     float ADR_CALL getVolume();
00059     void  ADR_CALL setPan(float pan);
00060     float ADR_CALL getPan();
00061     void  ADR_CALL setPitchShift(float shift);
00062     float ADR_CALL getPitchShift();
00063 
00064     bool ADR_CALL isSeekable();
00065     int  ADR_CALL getLength();
00066     void ADR_CALL setPosition(int position);
00067     int  ADR_CALL getPosition();
00068 
00069   private:
00070     void doStop(bool internal);
00071     void resetTimer();
00072     void update();
00073     int dummyRead(int samples_to_read);
00074 
00075     RefPtr<NullAudioDevice> m_device;
00076                           
00077     SampleSourcePtr m_source;
00078     int m_channel_count;           //
00079     int m_sample_rate;             // cached stream format
00080     SampleFormat m_sample_format;  //
00081 
00082     bool m_is_playing;
00083     float m_volume;
00084     float m_pan;
00085     float m_shift;
00086 
00087     u64 m_last_update;
00088 
00089     friend class NullAudioDevice;
00090   };
00091 
00092 }
00093 
00094 
00095 #endif

Generated on Mon Feb 13 23:07:46 2006 for audiere by  doxygen 1.4.6