implemented mute support for input channel, fixed casting bugs
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3777 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -891,11 +891,10 @@ AudioMixer::GetParameterValue(int32 id, bigtime_t *last_change,
|
||||
goto err;
|
||||
if (PARAM_IS_MUTE(id)) {
|
||||
// input mute control
|
||||
printf("get input mute control size %d\n", *ioSize);
|
||||
if (*ioSize < sizeof(int32))
|
||||
goto err;
|
||||
*ioSize = sizeof(int32);
|
||||
static_cast<int32 *>(value)[0] = 0;
|
||||
static_cast<int32 *>(value)[0] = !input->IsEnabled();
|
||||
}
|
||||
if (PARAM_IS_GAIN(id)) {
|
||||
// input gain control
|
||||
@@ -936,7 +935,7 @@ AudioMixer::SetParameterValue(int32 id, bigtime_t when,
|
||||
if (size < output->GetOutputChannelCount() * sizeof(float))
|
||||
goto err;
|
||||
for (int chan = 0; chan < output->GetOutputChannelCount(); chan++)
|
||||
output->SetOutputChannelGain(chan, GAIN_TO_DB(static_cast<float *>(value)[chan]));
|
||||
output->SetOutputChannelGain(chan, GAIN_TO_DB(static_cast<const float *>(value)[chan]));
|
||||
}
|
||||
} else {
|
||||
MixerInput *input;
|
||||
@@ -947,16 +946,16 @@ AudioMixer::SetParameterValue(int32 id, bigtime_t when,
|
||||
goto err;
|
||||
if (PARAM_IS_MUTE(id)) {
|
||||
// input mute control
|
||||
printf("set input mute control size %d\n", size);
|
||||
if (size != sizeof(int32))
|
||||
goto err;
|
||||
input->SetEnabled(!static_cast<const int32 *>(value)[0]);
|
||||
}
|
||||
if (PARAM_IS_GAIN(id)) {
|
||||
// input gain control
|
||||
if (size < input->GetMixerChannelCount() * sizeof(float))
|
||||
goto err;
|
||||
for (int chan = 0; chan < input->GetMixerChannelCount(); chan++)
|
||||
input->SetMixerChannelGain(chan, GAIN_TO_DB(static_cast<float *>(value)[chan]));
|
||||
input->SetMixerChannelGain(chan, GAIN_TO_DB(static_cast<const float *>(value)[chan]));
|
||||
}
|
||||
}
|
||||
BroadcastNewParameterValue(when, id, const_cast<void *>(value), size);
|
||||
|
||||
@@ -43,7 +43,6 @@ class AudioMixer :
|
||||
// AudioMixer support
|
||||
|
||||
void UpdateParameterWeb();
|
||||
void MakeWebForInput(char *name, media_format format);
|
||||
|
||||
void HandleInputBuffer(BBuffer *buffer, bigtime_t lateness);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ MixerInput::MixerInput(MixerCore *core, const media_input &input, float mixFrame
|
||||
: fCore(core),
|
||||
fInput(input),
|
||||
fInputByteSwap(0),
|
||||
fEnabled(true),
|
||||
fInputChannelInfo(0),
|
||||
fInputChannelCount(0),
|
||||
fInputChannelMask(0),
|
||||
@@ -437,6 +438,18 @@ MixerInput::GetMixerChannelGain(int channel)
|
||||
return fMixerChannelInfo[channel].gain;
|
||||
}
|
||||
|
||||
void
|
||||
MixerInput::SetEnabled(bool yesno)
|
||||
{
|
||||
fEnabled = yesno;
|
||||
}
|
||||
|
||||
bool
|
||||
MixerInput::IsEnabled()
|
||||
{
|
||||
return fEnabled;
|
||||
}
|
||||
|
||||
void
|
||||
MixerInput::SetMixBufferFormat(int32 framerate, int32 frames)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,9 @@ public:
|
||||
uint32 GetInputChannelType(int channel);
|
||||
void SetInputChannelGain(int channel, float gain);
|
||||
float GetInputChannelGain(int channel);
|
||||
|
||||
void SetEnabled(bool yesno);
|
||||
bool IsEnabled();
|
||||
|
||||
// only for use by MixerCore
|
||||
bool GetMixerChannelInfo(int channel, int64 framepos, bigtime_t time, const float **buffer, uint32 *sample_offset, int *type, float *gain);
|
||||
@@ -61,6 +64,8 @@ private:
|
||||
MixerCore *fCore;
|
||||
media_input fInput;
|
||||
ByteSwap *fInputByteSwap;
|
||||
|
||||
bool fEnabled;
|
||||
|
||||
input_chan_info *fInputChannelInfo; // array
|
||||
uint32 fInputChannelCount;
|
||||
@@ -89,7 +94,7 @@ MixerInput::GetMixerChannelInfo(int channel, int64 framepos, bigtime_t time, con
|
||||
{
|
||||
ASSERT(fMixBuffer); // this function should not be called if we don't have a mix buffer!
|
||||
ASSERT(channel >= 0 && channel < fMixerChannelCount);
|
||||
if (time > fLastDataAvailableTime)
|
||||
if (time > fLastDataAvailableTime || !fEnabled)
|
||||
return false;
|
||||
|
||||
int32 offset = framepos % fMixBufferFrameCount;
|
||||
|
||||
Reference in New Issue
Block a user