* In the MixerInput, also use the Linear resampler if requested by the
settings. (There is a common "mixing frame rate" to which all inputs resample, before the MixerCore resamples to the frame rate of the output.) * Some more coding style fixes in MixerCore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38479 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -106,7 +106,7 @@ MixerCore::~MixerCore()
|
|||||||
if (fResampler) {
|
if (fResampler) {
|
||||||
for (int i = 0; i < fMixBufferChannelCount; i++)
|
for (int i = 0; i < fMixBufferChannelCount; i++)
|
||||||
delete fResampler[i];
|
delete fResampler[i];
|
||||||
delete [] fResampler;
|
delete[] fResampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete fMixBufferChannelTypes;
|
delete fMixBufferChannelTypes;
|
||||||
@@ -133,7 +133,7 @@ MixerCore::AddInput(const media_input& input)
|
|||||||
{
|
{
|
||||||
ASSERT_LOCKED();
|
ASSERT_LOCKED();
|
||||||
MixerInput* in = new MixerInput(this, input, fMixBufferFrameRate,
|
MixerInput* in = new MixerInput(this, input, fMixBufferFrameRate,
|
||||||
fMixBufferFrameCount);
|
fMixBufferFrameCount, Settings()->ResamplingAlgorithm());
|
||||||
fInputs->AddItem(in);
|
fInputs->AddItem(in);
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
@@ -286,16 +286,17 @@ MixerCore::ApplyOutputFormat()
|
|||||||
= ChannelMaskToChannelType(GetChannelMask(i, format.channel_mask));
|
= ChannelMaskToChannelType(GetChannelMask(i, format.channel_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
fMixBuffer = (float *)rtm_alloc(NULL, sizeof(float) * fMixBufferFrameCount * fMixBufferChannelCount);
|
fMixBuffer = (float*)rtm_alloc(NULL, sizeof(float) * fMixBufferFrameCount
|
||||||
ASSERT(fMixBuffer);
|
* fMixBufferChannelCount);
|
||||||
|
ASSERT(fMixBuffer != NULL);
|
||||||
|
|
||||||
if (fResampler) {
|
if (fResampler != NULL) {
|
||||||
for (int i = 0; i < fMixBufferChannelCount; i++)
|
for (int i = 0; i < fMixBufferChannelCount; i++)
|
||||||
delete fResampler[i];
|
delete fResampler[i];
|
||||||
delete [] fResampler;
|
delete[] fResampler;
|
||||||
}
|
}
|
||||||
|
|
||||||
fResampler = new Resampler * [fMixBufferChannelCount];
|
fResampler = new Resampler*[fMixBufferChannelCount];
|
||||||
for (int i = 0; i < fMixBufferChannelCount; i++) {
|
for (int i = 0; i < fMixBufferChannelCount; i++) {
|
||||||
switch (Settings()->ResamplingAlgorithm()) {
|
switch (Settings()->ResamplingAlgorithm()) {
|
||||||
case 2:
|
case 2:
|
||||||
@@ -491,8 +492,8 @@ MixerCore::MixThread()
|
|||||||
uint64 bufferIndex = 0;
|
uint64 bufferIndex = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RtList<chan_info> InputChanInfos[MAX_CHANNEL_TYPES];
|
RtList<chan_info> inputChanInfos[MAX_CHANNEL_TYPES];
|
||||||
RtList<chan_info> MixChanInfos[fMixBufferChannelCount];
|
RtList<chan_info> mixChanInfos[fMixBufferChannelCount];
|
||||||
// TODO: this does not support changing output channel count
|
// TODO: this does not support changing output channel count
|
||||||
|
|
||||||
bigtime_t eventTime = timeBase;
|
bigtime_t eventTime = timeBase;
|
||||||
@@ -558,6 +559,7 @@ MixerCore::MixThread()
|
|||||||
PRINT(4, "create new buffer event at %Ld, reading input frames at "
|
PRINT(4, "create new buffer event at %Ld, reading input frames at "
|
||||||
"%Ld\n", eventTime, currentFramePos);
|
"%Ld\n", eventTime, currentFramePos);
|
||||||
|
|
||||||
|
// Init the channel information for each MixerInput.
|
||||||
for (int i = 0; MixerInput* input = Input(i); i++) {
|
for (int i = 0; MixerInput* input = Input(i); i++) {
|
||||||
int count = input->GetMixerChannelCount();
|
int count = input->GetMixerChannelCount();
|
||||||
for (int channel = 0; channel < count; channel++) {
|
for (int channel = 0; channel < count; channel++) {
|
||||||
@@ -571,7 +573,7 @@ MixerCore::MixThread()
|
|||||||
}
|
}
|
||||||
if (type < 0 || type >= MAX_CHANNEL_TYPES)
|
if (type < 0 || type >= MAX_CHANNEL_TYPES)
|
||||||
continue;
|
continue;
|
||||||
chan_info* info = InputChanInfos[type].Create();
|
chan_info* info = inputChanInfos[type].Create();
|
||||||
info->base = (const char*)base;
|
info->base = (const char*)base;
|
||||||
info->sample_offset = sampleOffset;
|
info->sample_offset = sampleOffset;
|
||||||
info->gain = gain;
|
info->gain = gain;
|
||||||
@@ -587,10 +589,10 @@ MixerCore::MixThread()
|
|||||||
&gain);
|
&gain);
|
||||||
if (type < 0 || type >= MAX_CHANNEL_TYPES)
|
if (type < 0 || type >= MAX_CHANNEL_TYPES)
|
||||||
continue;
|
continue;
|
||||||
int count = InputChanInfos[type].CountItems();
|
int count = inputChanInfos[type].CountItems();
|
||||||
for (int j = 0; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
chan_info* info = InputChanInfos[type].ItemAt(j);
|
chan_info* info = inputChanInfos[type].ItemAt(j);
|
||||||
chan_info* newInfo = MixChanInfos[channel].Create();
|
chan_info* newInfo = mixChanInfos[channel].Create();
|
||||||
newInfo->base = info->base;
|
newInfo->base = info->base;
|
||||||
newInfo->sample_offset = info->sample_offset;
|
newInfo->sample_offset = info->sample_offset;
|
||||||
newInfo->gain = info->gain * gain;
|
newInfo->gain = info->gain * gain;
|
||||||
@@ -602,11 +604,11 @@ MixerCore::MixThread()
|
|||||||
fMixBufferChannelCount * fMixBufferFrameCount * sizeof(float));
|
fMixBufferChannelCount * fMixBufferFrameCount * sizeof(float));
|
||||||
for (int channel = 0; channel < fMixBufferChannelCount; channel++) {
|
for (int channel = 0; channel < fMixBufferChannelCount; channel++) {
|
||||||
PRINT(5, "MixThread: channel %d has %d sources\n", channel,
|
PRINT(5, "MixThread: channel %d has %d sources\n", channel,
|
||||||
MixChanInfos[channel].CountItems());
|
mixChanInfos[channel].CountItems());
|
||||||
|
|
||||||
int count = MixChanInfos[channel].CountItems();
|
int count = mixChanInfos[channel].CountItems();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
chan_info* info = MixChanInfos[channel].ItemAt(i);
|
chan_info* info = mixChanInfos[channel].ItemAt(i);
|
||||||
PRINT(5, "MixThread: base %p, sample-offset %2d, gain %.3f\n",
|
PRINT(5, "MixThread: base %p, sample-offset %2d, gain %.3f\n",
|
||||||
info->base, info->sample_offset, info->gain);
|
info->base, info->sample_offset, info->gain);
|
||||||
// This looks slightly ugly, but the current GCC will generate
|
// This looks slightly ugly, but the current GCC will generate
|
||||||
@@ -684,9 +686,9 @@ MixerCore::MixThread()
|
|||||||
|
|
||||||
// make all lists empty
|
// make all lists empty
|
||||||
for (int i = 0; i < MAX_CHANNEL_TYPES; i++)
|
for (int i = 0; i < MAX_CHANNEL_TYPES; i++)
|
||||||
InputChanInfos[i].MakeEmpty();
|
inputChanInfos[i].MakeEmpty();
|
||||||
for (int i = 0; i < fOutput->GetOutputChannelCount(); i++)
|
for (int i = 0; i < fOutput->GetOutputChannelCount(); i++)
|
||||||
MixChanInfos[i].MakeEmpty();
|
mixChanInfos[i].MakeEmpty();
|
||||||
|
|
||||||
schedule_next_event:
|
schedule_next_event:
|
||||||
// schedule next event
|
// schedule next event
|
||||||
|
|||||||
@@ -14,13 +14,14 @@
|
|||||||
#include <TimeSource.h> // TODO: debug only
|
#include <TimeSource.h> // TODO: debug only
|
||||||
|
|
||||||
#include "ByteSwap.h"
|
#include "ByteSwap.h"
|
||||||
|
#include "Interpolate.h"
|
||||||
#include "MixerInput.h"
|
#include "MixerInput.h"
|
||||||
#include "MixerUtils.h"
|
#include "MixerUtils.h"
|
||||||
#include "Resampler.h"
|
#include "Resampler.h"
|
||||||
|
|
||||||
|
|
||||||
MixerInput::MixerInput(MixerCore *core, const media_input &input,
|
MixerInput::MixerInput(MixerCore *core, const media_input &input,
|
||||||
float mixFrameRate, int32 mixFrameCount)
|
float mixFrameRate, int32 mixFrameCount, int resamplingAlgorithm)
|
||||||
:
|
:
|
||||||
fCore(core),
|
fCore(core),
|
||||||
fInput(input),
|
fInput(input),
|
||||||
@@ -78,9 +79,17 @@ MixerInput::MixerInput(MixerCore *core, const media_input &input,
|
|||||||
// create resamplers
|
// create resamplers
|
||||||
fResampler = new Resampler * [fInputChannelCount];
|
fResampler = new Resampler * [fInputChannelCount];
|
||||||
for (int i = 0; i < fInputChannelCount; i++) {
|
for (int i = 0; i < fInputChannelCount; i++) {
|
||||||
// TODO create Interpolate instead of Resampler if the settings says so
|
switch (resamplingAlgorithm) {
|
||||||
fResampler[i] = new Resampler(fInput.format.u.raw_audio.format,
|
case 2:
|
||||||
media_raw_audio_format::B_AUDIO_FLOAT);
|
fResampler[i] = new Interpolate(
|
||||||
|
fInput.format.u.raw_audio.format,
|
||||||
|
media_raw_audio_format::B_AUDIO_FLOAT);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fResampler[i] = new Resampler(
|
||||||
|
fInput.format.u.raw_audio.format,
|
||||||
|
media_raw_audio_format::B_AUDIO_FLOAT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fMixerChannelInfo and fMixerChannelCount will be initialized by
|
// fMixerChannelInfo and fMixerChannelCount will be initialized by
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class MixerInput {
|
|||||||
public:
|
public:
|
||||||
MixerInput(MixerCore* core,
|
MixerInput(MixerCore* core,
|
||||||
const media_input& input,
|
const media_input& input,
|
||||||
float mixFrameRate, int32 mixFrameCount);
|
float mixFrameRate, int32 mixFrameCount,
|
||||||
|
int resamplingAlgorithm);
|
||||||
~MixerInput();
|
~MixerInput();
|
||||||
|
|
||||||
int32 ID();
|
int32 ID();
|
||||||
|
|||||||
Reference in New Issue
Block a user