00001 #ifndef MIXER_HPP
00002 #define MIXER_HPP
00003
00004
00005 #include <map>
00006 #include "config.h"
00007 #include "input.hpp"
00008
00009
00010
00011 class Mixer : public ISampleSource
00012 {
00013 public:
00014 Mixer();
00015 ~Mixer();
00016
00017 void GetFormat(int& channel_count, int& sample_rate, int& bits_per_sample);
00018 int Read(int sample_count, void* samples);
00019 bool Reset();
00020
00021 void AddSource(ISampleSource* source);
00022 void RemoveSource(ISampleSource* source);
00023
00024 bool IsPlaying(ISampleSource* source);
00025 void SetPlaying(ISampleSource* source, bool is_playing);
00026
00027 int GetVolume(ISampleSource* source);
00028 void SetVolume(ISampleSource* source, int volume);
00029
00030 private:
00031 struct SourceAttributes {
00032
00033 ISampleSource* resampler;
00034 adr_s16 last_l;
00035 adr_s16 last_r;
00036
00037
00038 bool is_playing;
00039 int volume;
00040 };
00041
00042 typedef std::map<ISampleSource*, SourceAttributes> SourceMap;
00043
00044 private:
00045 void Read(ISampleSource* source,
00046 SourceAttributes& attr,
00047 int to_mix,
00048 adr_s16* buffer);
00049
00050 private:
00051 SourceMap m_sources;
00052 };
00053
00054
00055 #endif