#ifndef MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
#define MEDIA_AUDIO_FAKE_AUDIO_INPUT_STREAM_H_
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread.h"
#include "base/time/time.h"
#include "media/audio/audio_io.h"
#include "media/audio/audio_parameters.h"
namespace media {
class AudioManagerBase;
class MEDIA_EXPORT FakeAudioInputStream
: public AudioInputStream {
public:
static AudioInputStream* MakeFakeStream(AudioManagerBase* manager,
const AudioParameters& params);
virtual bool Open() OVERRIDE;
virtual void Start(AudioInputCallback* callback) OVERRIDE;
virtual void Stop() OVERRIDE;
virtual void Close() OVERRIDE;
virtual double GetMaxVolume() OVERRIDE;
virtual void SetVolume(double volume) OVERRIDE;
virtual double GetVolume() OVERRIDE;
virtual void SetAutomaticGainControl(bool enabled) OVERRIDE;
virtual bool GetAutomaticGainControl() OVERRIDE;
static void BeepOnce();
private:
FakeAudioInputStream(AudioManagerBase* manager,
const AudioParameters& params);
virtual ~FakeAudioInputStream();
void DoCallback();
AudioManagerBase* audio_manager_;
AudioInputCallback* callback_;
scoped_ptr<uint8[]> buffer_;
int buffer_size_;
AudioParameters params_;
base::Thread thread_;
base::TimeTicks last_callback_time_;
base::TimeDelta callback_interval_;
int beep_duration_in_buffers_;
int beep_generated_in_buffers_;
int beep_period_in_frames_;
int frames_elapsed_;
DISALLOW_COPY_AND_ASSIGN(FakeAudioInputStream);
};
}
#endif