Added experimental copying of the left channel from either input 1 or 0,
there seem to be some resampling related bugs git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <TimeSource.h>
|
||||
#include <Buffer.h>
|
||||
#include <BufferGroup.h>
|
||||
#include <string.h>
|
||||
#include "MixerCore.h"
|
||||
#include "MixerInput.h"
|
||||
#include "MixerOutput.h"
|
||||
@@ -12,7 +13,7 @@
|
||||
#include "Resampler.h"
|
||||
#include "Debug.h"
|
||||
|
||||
#define DOUBLE_RATE_MIXING 1
|
||||
#define DOUBLE_RATE_MIXING 0
|
||||
|
||||
#define ASSERT_LOCKED() if (fLocker->IsLocked()) {} else debugger("core not locked, meltdown occurred")
|
||||
|
||||
@@ -340,13 +341,47 @@ MixerCore::MixThread()
|
||||
// mix all data from all inputs into the mix buffer
|
||||
ASSERT((frame_base + frame_pos) % fMixBufferFrameCount == 0);
|
||||
|
||||
printf("create new buffer event at %Ld, reading input frames at %Ld\n", event_time, frame_base + frame_pos);
|
||||
|
||||
// printf("create new buffer event at %Ld, reading input frames at %Ld\n", event_time, frame_base + frame_pos);
|
||||
/*
|
||||
for (int i = 0; i < fMixBufferChannelCount; i++) {
|
||||
for (int j = 0; j < fMixBufferFrameCount; j++) {
|
||||
fMixBuffer[(i * fMixBufferChannelCount)+j] = (i*j) / (float)(fMixBufferChannelCount * fMixBufferFrameCount);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// XXX this is a test, copy the the left channel from input 1 or 0
|
||||
Lock();
|
||||
|
||||
MixerInput *input = Input(1);
|
||||
if (!input)
|
||||
input = Input(0);
|
||||
|
||||
if (input) {
|
||||
const float *buffer;
|
||||
uint32 src_sample_offset;
|
||||
int type;
|
||||
float gain;
|
||||
|
||||
printf("data reading for %15Ld to %15Ld, ", event_time, event_time + duration_for_frames(fMixBufferFrameRate, fMixBufferFrameCount));
|
||||
|
||||
int64 cur_framepos = frame_base + frame_pos;
|
||||
input->GetMixerChannelInfo(0, cur_framepos, &buffer, &src_sample_offset, &type, &gain);
|
||||
|
||||
memset(fMixBuffer, 0, fMixBufferChannelCount * fMixBufferFrameCount * sizeof(float));
|
||||
|
||||
uint32 dst_sample_offset;
|
||||
|
||||
char *src = (char *)buffer;
|
||||
char *dst = (char *)fMixBuffer;
|
||||
dst_sample_offset = fMixBufferChannelCount * sizeof(float);
|
||||
|
||||
for (int i = 0; i < fMixBufferFrameCount; i++) {
|
||||
*(float *)dst = *(float *)src;
|
||||
dst += dst_sample_offset;
|
||||
src += src_sample_offset;
|
||||
}
|
||||
}
|
||||
Unlock();
|
||||
|
||||
// request a buffer
|
||||
BBuffer* buf = fBufferGroup->RequestBuffer(fOutput->MediaOutput().format.u.raw_audio.buffer_size, 10000);
|
||||
@@ -377,7 +412,7 @@ MixerCore::MixThread()
|
||||
}
|
||||
}
|
||||
|
||||
// shedule next event
|
||||
// schedule next event
|
||||
frame_pos += fMixBufferFrameCount;
|
||||
event_time = time_base + bigtime_t((1000000LL * frame_pos) / fMixBufferFrameRate);
|
||||
}
|
||||
|
||||
@@ -105,10 +105,12 @@ MixerInput::BufferReceived(BBuffer *buffer)
|
||||
|
||||
int32 offset = frames_for_duration(fMixBufferFrameRate, start - fMixBufferStartTime) % fMixBufferFrameCount;
|
||||
|
||||
printf("MixerInput::BufferReceived: mix buffer start %14Ld, buffer start %14Ld, offset %6d\n", fMixBufferStartTime, start, offset);
|
||||
// printf("MixerInput::BufferReceived: mix buffer start %14Ld, buffer start %14Ld, offset %6d\n", fMixBufferStartTime, start, offset);
|
||||
|
||||
int in_frames = frames_per_buffer(fInput.format.u.raw_audio); // XXX use size
|
||||
int out_frames = (int)((in_frames * fMixBufferFrameRate) / fInput.format.u.raw_audio.frame_rate); // XXX losing fractions
|
||||
|
||||
//printf("data arrived for %15Ld to %15Ld, storing at frames %ld to %ld\n", start, start + duration_for_frames(fInput.format.u.raw_audio.frame_rate, frames_per_buffer(fInput.format.u.raw_audio)), offset, offset + out_frames);
|
||||
|
||||
if (offset + out_frames > fMixBufferFrameCount) {
|
||||
|
||||
@@ -117,8 +119,10 @@ MixerInput::BufferReceived(BBuffer *buffer)
|
||||
int in_frames1 = (out_frames1 * in_frames) / out_frames;
|
||||
int in_frames2 = in_frames - in_frames1;
|
||||
|
||||
printf(" in_frames %5d, out_frames %5d, in_frames1 %5d, out_frames1 %5d, in_frames2 %5d, out_frames2 %5d\n",
|
||||
in_frames, out_frames, in_frames1, out_frames1, in_frames2, out_frames2);
|
||||
printf("data arrived for %15Ld to %15Ld, storing at frames %ld to %ld and %ld to %ld\n", start, start + duration_for_frames(fInput.format.u.raw_audio.frame_rate, frames_per_buffer(fInput.format.u.raw_audio)), offset, offset + out_frames1, 0, out_frames2);
|
||||
|
||||
// printf(" in_frames %5d, out_frames %5d, in_frames1 %5d, out_frames1 %5d, in_frames2 %5d, out_frames2 %5d\n",
|
||||
// in_frames, out_frames, in_frames1, out_frames1, in_frames2, out_frames2);
|
||||
|
||||
for (int i = 0; i < fInputChannelCount; i++) {
|
||||
fResampler[i]->Resample(reinterpret_cast<char *>(data) + i * bytes_per_sample(fInput.format.u.raw_audio),
|
||||
@@ -139,7 +143,8 @@ MixerInput::BufferReceived(BBuffer *buffer)
|
||||
}
|
||||
} else {
|
||||
|
||||
printf(" in_frames %5d, out_frames %5d\n", in_frames, out_frames);
|
||||
// printf(" in_frames %5d, out_frames %5d\n", in_frames, out_frames);
|
||||
printf("data arrived for %15Ld to %15Ld, storing at frames %ld to %ld\n", start, start + duration_for_frames(fInput.format.u.raw_audio.frame_rate, frames_per_buffer(fInput.format.u.raw_audio)), offset, offset + out_frames);
|
||||
|
||||
for (int i = 0; i < fInputChannelCount; i++) {
|
||||
fResampler[i]->Resample(reinterpret_cast<char *>(data) + i * bytes_per_sample(fInput.format.u.raw_audio),
|
||||
@@ -369,6 +374,7 @@ MixerInput::GetMixerChannelInfo(int channel, int64 framepos, const float **buffe
|
||||
ASSERT(fMixBuffer);
|
||||
ASSERT(channel >= 0 && channel < fMixerChannelCount);
|
||||
int32 offset = framepos % fMixBufferFrameCount;
|
||||
printf("GetMixerChannelInfo: frames %ld to %ld\n", offset, offset + debugMixBufferFrames);
|
||||
*buffer = reinterpret_cast<float *>(reinterpret_cast<char *>(fMixerChannelInfo[channel].buffer_base) + (offset * sizeof(float) * fInputChannelCount));
|
||||
*sample_offset = sizeof(float) * fInputChannelCount;
|
||||
*type = fMixerChannelInfo[channel].type;
|
||||
@@ -398,6 +404,7 @@ MixerInput::SetMixBufferFormat(int32 framerate, int32 frames, bigtime_t starttim
|
||||
{
|
||||
fMixBufferFrameRate = framerate;
|
||||
fMixBufferStartTime = starttime;
|
||||
debugMixBufferFrames = frames;
|
||||
|
||||
printf("MixerInput::SetMixBufferFormat: framerate %ld, frames %ld, starttime %Ld\n", framerate, frames, starttime);
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ private:
|
||||
Resampler **fResampler; // array
|
||||
|
||||
bool fUserOverridesChannelDesignations;
|
||||
|
||||
int32 debugMixBufferFrames;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user