implemented muting of the master output

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3780 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2003-07-01 00:49:23 +00:00
parent 2cb2bc4111
commit b326a30e21
4 changed files with 24 additions and 8 deletions
@@ -868,11 +868,10 @@ AudioMixer::GetParameterValue(int32 id, bigtime_t *last_change,
goto err; goto err;
if (PARAM_IS_MUTE(id)) { if (PARAM_IS_MUTE(id)) {
// output mute control // output mute control
printf("get output mute control size %d\n", *ioSize);
if (*ioSize < sizeof(int32)) if (*ioSize < sizeof(int32))
goto err; goto err;
*ioSize = sizeof(int32); *ioSize = sizeof(int32);
static_cast<int32 *>(value)[0] = 0; static_cast<int32 *>(value)[0] = output->IsMuted();
} }
if (PARAM_IS_GAIN(id)) { if (PARAM_IS_GAIN(id)) {
// output gain control // output gain control
@@ -926,9 +925,9 @@ AudioMixer::SetParameterValue(int32 id, bigtime_t when,
goto err; goto err;
if (PARAM_IS_MUTE(id)) { if (PARAM_IS_MUTE(id)) {
// output mute control // output mute control
printf("set output mute control size %d\n", size);
if (size != sizeof(int32)) if (size != sizeof(int32))
goto err; goto err;
output->SetMuted(static_cast<const int32 *>(value)[0]);
} }
if (PARAM_IS_GAIN(id)) { if (PARAM_IS_GAIN(id)) {
// output gain control // output gain control
@@ -984,10 +983,10 @@ AudioMixer::UpdateParameterWeb()
group = output->MakeGroup(""); group = output->MakeGroup("");
out = fCore->Output(); out = fCore->Output();
if (!out) { if (!out) {
group->MakeNullParameter(PARAM_INPUT(0), B_MEDIA_RAW_AUDIO, "Master Gain", B_WEB_BUFFER_INPUT); group->MakeNullParameter(PARAM_INPUT(0), B_MEDIA_RAW_AUDIO, "Master Output", B_WEB_BUFFER_INPUT);
group->MakeNullParameter(PARAM_FORMAT(0), B_MEDIA_RAW_AUDIO, "not connected", B_GENERIC); group->MakeNullParameter(PARAM_FORMAT(0), B_MEDIA_RAW_AUDIO, "not connected", B_GENERIC);
} else { } else {
group->MakeNullParameter(PARAM_INPUT(0), B_MEDIA_RAW_AUDIO, "Master Gain", B_WEB_BUFFER_INPUT); group->MakeNullParameter(PARAM_INPUT(0), B_MEDIA_RAW_AUDIO, "Master Output", B_WEB_BUFFER_INPUT);
group->MakeNullParameter(PARAM_FORMAT(0), B_MEDIA_RAW_AUDIO, StringForFormat(out), B_GENERIC); group->MakeNullParameter(PARAM_FORMAT(0), B_MEDIA_RAW_AUDIO, StringForFormat(out), B_GENERIC);
group->MakeDiscreteParameter(PARAM_MUTE(0), B_MEDIA_RAW_AUDIO, "Mute", B_MUTE); group->MakeDiscreteParameter(PARAM_MUTE(0), B_MEDIA_RAW_AUDIO, "Mute", B_MUTE);
group->MakeContinuousParameter(PARAM_GAIN(0), B_MEDIA_RAW_AUDIO, "Gain", B_MASTER_GAIN, "dB", -60.0, 18.0, 0.5) group->MakeContinuousParameter(PARAM_GAIN(0), B_MEDIA_RAW_AUDIO, "Gain", B_MASTER_GAIN, "dB", -60.0, 18.0, 0.5)
@@ -436,8 +436,8 @@ MixerCore::MixThread()
if (!LockWithTimeout(10000)) if (!LockWithTimeout(10000))
continue; continue;
// no inputs, skip further processing and just send an empty buffer // no inputs or output muted, skip further processing and just send an empty buffer
if (fInputs->IsEmpty()) { if (fInputs->IsEmpty() || fOutput->IsMuted()) {
int size = fOutput->MediaOutput().format.u.raw_audio.buffer_size; int size = fOutput->MediaOutput().format.u.raw_audio.buffer_size;
BBuffer* buf = fBufferGroup->RequestBuffer(size, 5000); BBuffer* buf = fBufferGroup->RequestBuffer(size, 5000);
if (buf) { if (buf) {
@@ -9,7 +9,8 @@ MixerOutput::MixerOutput(MixerCore *core, const media_output &output)
fOutput(output), fOutput(output),
fOutputChannelCount(0), fOutputChannelCount(0),
fOutputChannelInfo(0), fOutputChannelInfo(0),
fOutputByteSwap(0) fOutputByteSwap(0),
fMuted(false)
{ {
fix_multiaudio_format(&fOutput.format.u.raw_audio); fix_multiaudio_format(&fOutput.format.u.raw_audio);
PRINT_OUTPUT("MixerOutput::MixerOutput", fOutput); PRINT_OUTPUT("MixerOutput::MixerOutput", fOutput);
@@ -313,3 +314,9 @@ MixerOutput::GetOutputChannelSourceAt(int channel, int index, uint32 *source_des
*source_gain = fOutputChannelInfo[channel].source_gain[index]; *source_gain = fOutputChannelInfo[channel].source_gain[index];
*source_designation = ChannelTypeToChannelMask(fOutputChannelInfo[channel].source_type[index]); *source_designation = ChannelTypeToChannelMask(fOutputChannelInfo[channel].source_type[index]);
} }
void
MixerOutput::SetMuted(bool yesno)
{
fMuted = yesno;
}
@@ -31,6 +31,9 @@ public:
float GetOutputChannelSourceGain(int channel, uint32 source_designation); float GetOutputChannelSourceGain(int channel, uint32 source_designation);
void GetOutputChannelSourceAt(int channel, int index, uint32 *source_designation, float *source_gain); void GetOutputChannelSourceAt(int channel, int index, uint32 *source_designation, float *source_gain);
void SetMuted(bool yesno);
bool IsMuted();
// only for use by MixerCore // only for use by MixerCore
void GetMixerChannelInfo(int channel, int index, int *type, float *gain); void GetMixerChannelInfo(int channel, int index, int *type, float *gain);
void AdjustByteOrder(BBuffer *buffer); void AdjustByteOrder(BBuffer *buffer);
@@ -55,6 +58,8 @@ private:
uint32 fOutputChannelCount; uint32 fOutputChannelCount;
output_chan_info *fOutputChannelInfo; //array output_chan_info *fOutputChannelInfo; //array
ByteSwap *fOutputByteSwap; ByteSwap *fOutputByteSwap;
bool fMuted;
}; };
inline uint32 MixerOutput::GetOutputChannelCount() inline uint32 MixerOutput::GetOutputChannelCount()
@@ -90,4 +95,9 @@ inline void MixerOutput::AdjustByteOrder(BBuffer *buffer)
fOutputByteSwap->Swap(buffer->Data(), buffer->SizeUsed()); fOutputByteSwap->Swap(buffer->Data(), buffer->SizeUsed());
} }
inline bool MixerOutput::IsMuted()
{
return fMuted;
}
#endif #endif