internal latency = 1 buffer
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5033 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* multiaudio replacement media addon for BeOS
|
* multiaudio replacement media addon for BeOS
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002, Jerome Duval ([email protected])
|
* Copyright (c) 2002, 2003 Jerome Duval ([email protected])
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
@@ -207,8 +207,8 @@ void MultiAudioNode::NodeRegistered(void)
|
|||||||
node_input *currentInput = NULL;
|
node_input *currentInput = NULL;
|
||||||
int32 currentId = 0;
|
int32 currentId = 0;
|
||||||
|
|
||||||
for (int32 i = 0; i < fDevice->MD.output_channel_count; i++)
|
for (int32 i = 0; i < fDevice->MD.output_channel_count; i++) {
|
||||||
{
|
|
||||||
if( (currentInput == NULL)
|
if( (currentInput == NULL)
|
||||||
|| (fDevice->MD.channels[i].designations & B_CHANNEL_MONO_BUS)
|
|| (fDevice->MD.channels[i].designations & B_CHANNEL_MONO_BUS)
|
||||||
|| (fDevice->MD.channels[currentId].designations & B_CHANNEL_STEREO_BUS
|
|| (fDevice->MD.channels[currentId].designations & B_CHANNEL_STEREO_BUS
|
||||||
@@ -253,8 +253,8 @@ void MultiAudioNode::NodeRegistered(void)
|
|||||||
currentId = 0;
|
currentId = 0;
|
||||||
|
|
||||||
for (int32 i = fDevice->MD.output_channel_count;
|
for (int32 i = fDevice->MD.output_channel_count;
|
||||||
i < (fDevice->MD.output_channel_count + fDevice->MD.input_channel_count); i++)
|
i < (fDevice->MD.output_channel_count + fDevice->MD.input_channel_count); i++) {
|
||||||
{
|
|
||||||
if( (currentOutput == NULL)
|
if( (currentOutput == NULL)
|
||||||
|| (fDevice->MD.channels[i].designations & B_CHANNEL_MONO_BUS)
|
|| (fDevice->MD.channels[i].designations & B_CHANNEL_MONO_BUS)
|
||||||
|| (fDevice->MD.channels[currentId].designations & B_CHANNEL_STEREO_BUS
|
|| (fDevice->MD.channels[currentId].designations & B_CHANNEL_STEREO_BUS
|
||||||
@@ -299,6 +299,8 @@ void MultiAudioNode::NodeRegistered(void)
|
|||||||
SetParameterWeb(fWeb);
|
SetParameterWeb(fWeb);
|
||||||
|
|
||||||
/* apply configuration */
|
/* apply configuration */
|
||||||
|
bigtime_t start = system_time();
|
||||||
|
|
||||||
int32 index = 0;
|
int32 index = 0;
|
||||||
int32 parameterID = 0;
|
int32 parameterID = 0;
|
||||||
const void *data;
|
const void *data;
|
||||||
@@ -308,6 +310,8 @@ void MultiAudioNode::NodeRegistered(void)
|
|||||||
SetParameterValue(parameterID, TimeSource()->Now(), data, size);
|
SetParameterValue(parameterID, TimeSource()->Now(), data, size);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINT(("apply configuration in : %ld\n", system_time() - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t MultiAudioNode::RequestCompleted(const media_request_info &info)
|
status_t MultiAudioNode::RequestCompleted(const media_request_info &info)
|
||||||
@@ -510,21 +514,12 @@ status_t MultiAudioNode::Connected(
|
|||||||
return B_MEDIA_BAD_DESTINATION;
|
return B_MEDIA_BAD_DESTINATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute the latency or just guess
|
|
||||||
// use one buffer length latency
|
// use one buffer length latency
|
||||||
/*fInternalLatency = with_format.u.raw_audio.buffer_size * 10000 / 2
|
fInternalLatency = with_format.u.raw_audio.buffer_size * 10000 / 2
|
||||||
/ ( (with_format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
|
/ ( (with_format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
|
||||||
* with_format.u.raw_audio.channel_count)
|
* with_format.u.raw_audio.channel_count)
|
||||||
/ ((int32)(with_format.u.raw_audio.frame_rate / 100));*/
|
/ ((int32)(with_format.u.raw_audio.frame_rate / 100));
|
||||||
/*char* buffer1 = (char*)malloc(with_format.u.raw_audio.buffer_size);
|
|
||||||
char* buffer2 = (char*)malloc(with_format.u.raw_audio.buffer_size);
|
|
||||||
bigtime_t latency_start = TimeSource()->RealTime();
|
|
||||||
memcpy(buffer2, buffer1, with_format.u.raw_audio.buffer_size);
|
|
||||||
bigtime_t latency_end = TimeSource()->RealTime();
|
|
||||||
fInternalLatency = latency_end - latency_start;
|
|
||||||
*/
|
|
||||||
fInternalLatency = 50LL;
|
|
||||||
|
|
||||||
PRINT((" internal latency = %lld\n",fInternalLatency));
|
PRINT((" internal latency = %lld\n",fInternalLatency));
|
||||||
|
|
||||||
SetEventLatency(fInternalLatency);
|
SetEventLatency(fInternalLatency);
|
||||||
@@ -818,24 +813,24 @@ MultiAudioNode::Connect(status_t error, const media_source& source, const media_
|
|||||||
channel->fOutput.format = format;
|
channel->fOutput.format = format;
|
||||||
strncpy(io_name, channel->fOutput.name, B_MEDIA_NAME_LENGTH);
|
strncpy(io_name, channel->fOutput.name, B_MEDIA_NAME_LENGTH);
|
||||||
|
|
||||||
|
// reset our buffer duration, etc. to avoid later calculations
|
||||||
|
bigtime_t duration = channel->fOutput.format.u.raw_audio.buffer_size * 10000
|
||||||
|
/ ( (channel->fOutput.format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
|
||||||
|
* channel->fOutput.format.u.raw_audio.channel_count)
|
||||||
|
/ ((int32)(channel->fOutput.format.u.raw_audio.frame_rate / 100));
|
||||||
|
|
||||||
|
SetBufferDuration(duration);
|
||||||
|
|
||||||
// Now that we're connected, we can determine our downstream latency.
|
// Now that we're connected, we can determine our downstream latency.
|
||||||
// Do so, then make sure we get our events early enough.
|
// Do so, then make sure we get our events early enough.
|
||||||
media_node_id id;
|
media_node_id id;
|
||||||
FindLatencyFor(channel->fOutput.destination, &fLatency, &id);
|
FindLatencyFor(channel->fOutput.destination, &fLatency, &id);
|
||||||
PRINT(("\tdownstream latency = %Ld\n", fLatency));
|
PRINT(("\tdownstream latency = %Ld\n", fLatency));
|
||||||
|
|
||||||
fInternalLatency = 50LL;
|
fInternalLatency = BufferDuration();
|
||||||
PRINT(("\tbuffer-filling took %Ld usec on this machine\n", fInternalLatency));
|
PRINT(("\tbuffer-filling took %Ld usec on this machine\n", fInternalLatency));
|
||||||
//SetEventLatency(fLatency + fInternalLatency);
|
//SetEventLatency(fLatency + fInternalLatency);
|
||||||
|
|
||||||
// reset our buffer duration, etc. to avoid later calculations
|
|
||||||
bigtime_t duration = channel->fOutput.format.u.raw_audio.buffer_size * 10000
|
|
||||||
/ ( (channel->fOutput.format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
|
|
||||||
* channel->fOutput.format.u.raw_audio.channel_count)
|
|
||||||
/ ((int32)(channel->fOutput.format.u.raw_audio.frame_rate / 100));
|
|
||||||
//bigtime_t duration = bigtime_t(1000000) * samplesPerBuffer / bigtime_t(fOutput.format.u.raw_audio.frame_rate);
|
|
||||||
SetBufferDuration(duration);
|
|
||||||
|
|
||||||
// Set up the buffer group for our connection, as long as nobody handed us a
|
// Set up the buffer group for our connection, as long as nobody handed us a
|
||||||
// buffer group (via SetBufferGroup()) prior to this. That can happen, for example,
|
// buffer group (via SetBufferGroup()) prior to this. That can happen, for example,
|
||||||
// if the consumer calls SetOutputBuffersFor() on us from within its Connected()
|
// if the consumer calls SetOutputBuffersFor() on us from within its Connected()
|
||||||
@@ -1011,11 +1006,6 @@ status_t MultiAudioNode::HandleBuffer(
|
|||||||
return B_MEDIA_BAD_DESTINATION;
|
return B_MEDIA_BAD_DESTINATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (buffer->Header()->destination != input.destination.id) {
|
|
||||||
fprintf(stderr,"<- B_MEDIA_BAD_DESTINATION\n");
|
|
||||||
return B_MEDIA_BAD_DESTINATION;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
media_header* hdr = buffer->Header();
|
media_header* hdr = buffer->Header();
|
||||||
bigtime_t now = TimeSource()->Now();
|
bigtime_t now = TimeSource()->Now();
|
||||||
bigtime_t perf_time = hdr->start_time;
|
bigtime_t perf_time = hdr->start_time;
|
||||||
@@ -1360,7 +1350,8 @@ MultiAudioNode::MakeParameterWeb()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MultiAudioNode::ProcessGroup(BParameterGroup *group, int32 index, int32 &nbParameters) {
|
MultiAudioNode::ProcessGroup(BParameterGroup *group, int32 index, int32 &nbParameters)
|
||||||
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
multi_mix_control *parent = &fDevice->MMCI.controls[index];
|
multi_mix_control *parent = &fDevice->MMCI.controls[index];
|
||||||
multi_mix_control *MMC = fDevice->MMCI.controls;
|
multi_mix_control *MMC = fDevice->MMCI.controls;
|
||||||
@@ -1417,7 +1408,8 @@ MultiAudioNode::ProcessGroup(BParameterGroup *group, int32 index, int32 &nbParam
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MultiAudioNode::ProcessMux(BDiscreteParameter *parameter, int32 index) {
|
MultiAudioNode::ProcessMux(BDiscreteParameter *parameter, int32 index)
|
||||||
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
multi_mix_control *parent = &fDevice->MMCI.controls[index];
|
multi_mix_control *parent = &fDevice->MMCI.controls[index];
|
||||||
multi_mix_control *MMC = fDevice->MMCI.controls;
|
multi_mix_control *MMC = fDevice->MMCI.controls;
|
||||||
@@ -1444,27 +1436,6 @@ MultiAudioNode::ProcessMux(BDiscreteParameter *parameter, int32 index) {
|
|||||||
// MultiAudioNode specific functions
|
// MultiAudioNode specific functions
|
||||||
// -------------------------------------------------------- //
|
// -------------------------------------------------------- //
|
||||||
|
|
||||||
/*void
|
|
||||||
MultiAudioNode::WriteBuffer( BBuffer *buffer, node_input &input )
|
|
||||||
{*/
|
|
||||||
//CALLED();
|
|
||||||
/*
|
|
||||||
//wait for free buffer
|
|
||||||
acquire_sem( fBuffer_free );
|
|
||||||
//PRINT(("MultiAudioNode::WriteBuffer: buffer free (fBufferCycle:%li)\n", fBufferCycle));
|
|
||||||
|
|
||||||
//prepare buffer
|
|
||||||
memcpy( fDevice->fPlay[input.fBufferCycle][input.fChannelId], buffer->Data(), buffer->SizeUsed() );
|
|
||||||
//PRINT(("MultiAudioNode::WriteBuffer: output : %p\n", fPlay[fBufferCycle][0]));
|
|
||||||
//PRINT(("MultiAudioNode::WriteBuffer: buffer prepared\n")); */
|
|
||||||
|
|
||||||
/*if(input.fBuffer != NULL) {
|
|
||||||
PRINT(("MultiAudioNode::WriteBuffer recycling channelId : %i\n", input.fChannelId));
|
|
||||||
//input.fBuffer->Recycle();
|
|
||||||
} else
|
|
||||||
input.fBuffer = buffer;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
MultiAudioNode::RunThread()
|
MultiAudioNode::RunThread()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user