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