1 #ifndef _MIXER_OUTPUT_H 2 #define _MIXER_OUTPUT_H 3 4 #include "debug.h" 5 #include "ByteSwap.h" 6 #include <Buffer.h> 7 8 #define MAX_SOURCES 20 9 10 class MixerCore; 11 12 class MixerOutput 13 { 14 public: 15 MixerOutput(MixerCore *core, const media_output &output); 16 ~MixerOutput(); 17 18 media_output & MediaOutput(); 19 20 void ChangeFormat(const media_multi_audio_format &format); 21 22 uint32 GetOutputChannelCount(); 23 uint32 GetOutputChannelDesignation(int channel); 24 void SetOutputChannelGain(int channel, float gain); 25 float GetOutputChannelGain(int channel); 26 27 uint32 GetOutputChannelSourceCount(int channel); 28 void AddOutputChannelSource(int channel, uint32 source_designation, float source_gain); 29 void RemoveOutputChannelSource(int channel, uint32 source_designation); 30 void SetOutputChannelSourceGain(int channel, uint32 source_designation, float source_gain); 31 float GetOutputChannelSourceGain(int channel, uint32 source_designation); 32 void GetOutputChannelSourceAt(int channel, int index, uint32 *source_designation, float *source_gain); 33 34 // only for use by MixerCore 35 void GetMixerChannelInfo(int channel, int index, int *type, float *gain); 36 void AdjustByteOrder(BBuffer *buffer); 37 38 private: 39 void UpdateByteOrderSwap(); 40 void UpdateOutputChannels(); 41 void AssignDefaultSources(); 42 43 private: 44 struct output_chan_info { 45 uint32 designation; // only one bit set 46 float gain; 47 int source_count; 48 float source_gain[MAX_SOURCES]; 49 int source_type[MAX_SOURCES]; 50 }; 51 52 MixerCore *fCore; 53 media_output fOutput; 54 55 uint32 fOutputChannelCount; 56 output_chan_info *fOutputChannelInfo; //array 57 ByteSwap *fOutputByteSwap; 58 }; 59 60 inline uint32 MixerOutput::GetOutputChannelCount() 61 { 62 return fOutputChannelCount; 63 } 64 65 inline float MixerOutput::GetOutputChannelGain(int channel) 66 { 67 if (channel < 0 || channel >= fOutputChannelCount) 68 return 1.0; 69 return fOutputChannelInfo[channel].gain; 70 } 71 72 inline uint32 MixerOutput::GetOutputChannelSourceCount(int channel) 73 { 74 if (channel < 0 || channel >= fOutputChannelCount) 75 return 0; 76 return fOutputChannelInfo[channel].source_count; 77 } 78 79 inline void MixerOutput::GetMixerChannelInfo(int channel, int index, int *type, float *gain) 80 { 81 ASSERT(channel >= 0 && channel < fOutputChannelCount); 82 ASSERT(index >= 0 && index < fOutputChannelInfo[channel].source_count); 83 *type = fOutputChannelInfo[channel].source_type[index]; 84 *gain = fOutputChannelInfo[channel].source_gain[index]; 85 } 86 87 inline void MixerOutput::AdjustByteOrder(BBuffer *buffer) 88 { 89 if (fOutputByteSwap) 90 fOutputByteSwap->Swap(buffer->Data(), buffer->SizeUsed()); 91 } 92 93 #endif 94