git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3087 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2003-04-21 00:16:26 +00:00
parent 4395e32018
commit 056e08e286
2 changed files with 19 additions and 30 deletions
@@ -126,15 +126,6 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn *addon, char* name, MultiAudioDevice
AddNodeKind( B_PHYSICAL_OUTPUT ); AddNodeKind( B_PHYSICAL_OUTPUT );
AddNodeKind( B_PHYSICAL_INPUT ); AddNodeKind( B_PHYSICAL_INPUT );
// don't overwrite available space, and be sure to terminate
//strncpy(input.name,"MultiAudioNode Input",B_MEDIA_NAME_LENGTH-1);
//input.name[B_MEDIA_NAME_LENGTH-1] = '\0';
// initialize the input
//input.node = media_node::null; // until registration
//input.source = media_source::null;
//input.destination = media_destination::null; // until registration
//GetFormat(&input.format);
// initialize our preferred format object // initialize our preferred format object
fPreferredFormat.type = B_MEDIA_RAW_AUDIO; fPreferredFormat.type = B_MEDIA_RAW_AUDIO;
fPreferredFormat.u.raw_audio.format = MultiAudioDevice::convert_multiaudio_format_to_media_format(fDevice->MFI.output.format); fPreferredFormat.u.raw_audio.format = MultiAudioDevice::convert_multiaudio_format_to_media_format(fDevice->MFI.output.format);
@@ -147,10 +138,6 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn *addon, char* name, MultiAudioDevice
* (fPreferredFormat.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK) * (fPreferredFormat.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK)
* fPreferredFormat.u.raw_audio.channel_count; * fPreferredFormat.u.raw_audio.channel_count;
// we're not connected yet
//fOutput.destination = media_destination::null;
//fOutput.format = fPreferredFormat;
config->PrintToStream(); config->PrintToStream();
fInitCheckStatus = B_OK; fInitCheckStatus = B_OK;
@@ -255,11 +242,6 @@ void MultiAudioNode::NodeRegistered(void)
currentInput->fInput.format.u.raw_audio.format = media_raw_audio_format::wildcard.format; currentInput->fInput.format.u.raw_audio.format = media_raw_audio_format::wildcard.format;
} }
/*input.destination.port = ControlPort();
input.destination.id = 0;
input.node = Node();
::strcpy(input.name, "Channels 1/2");*/
node_output *currentOutput = NULL; node_output *currentOutput = NULL;
currentId = 0; currentId = 0;
@@ -534,6 +516,10 @@ status_t MultiAudioNode::Connected(
channel->fInput.source = producer; channel->fInput.source = producer;
channel->fInput.format = with_format; channel->fInput.format = with_format;
*out_input = channel->fInput; *out_input = channel->fInput;
// we are sure the thread is started
StartThread();
return B_OK; return B_OK;
} }
@@ -552,10 +538,7 @@ void MultiAudioNode::Disconnected(
fprintf(stderr,"<- B_MEDIA_BAD_SOURCE\n"); fprintf(stderr,"<- B_MEDIA_BAD_SOURCE\n");
return; return;
} }
/*if ( RunState() == B_STARTED ) {
StopThread();
}*/
channel->fInput.source = media_source::null; channel->fInput.source = media_source::null;
channel->fInput.format = channel->fPreferredFormat; channel->fInput.format = channel->fPreferredFormat;
FillWithZeros(*channel); FillWithZeros(*channel);
@@ -842,6 +825,9 @@ MultiAudioNode::Connect(status_t error, const media_source& source, const media_
// method. // method.
if (!channel->fBufferGroup) if (!channel->fBufferGroup)
AllocateBuffers(*channel); AllocateBuffers(*channel);
// we are sure the thread is started
StartThread();
} }
void void
@@ -1519,7 +1505,8 @@ MultiAudioNode::RunThread()
input->fBuffer = NULL; input->fBuffer = NULL;
} else { } else {
// put zeros in current buffer // put zeros in current buffer
WriteZeros(*input, input->fBufferCycle); if(input->fInput.source != media_source::null)
WriteZeros(*input, input->fBufferCycle);
//PRINT(("MultiAudioNode::Runthread WriteZeros\n")); //PRINT(("MultiAudioNode::Runthread WriteZeros\n"));
} }
@@ -1553,7 +1540,8 @@ MultiAudioNode::RunThread()
buffer->Recycle(); buffer->Recycle();
} else { } else {
// track how much media we've delivered so far // track how much media we've delivered so far
size_t nSamples = output->fOutput.format.u.raw_audio.buffer_size / sizeof(int16); size_t nSamples = output->fOutput.format.u.raw_audio.buffer_size
/ output->fOutput.format.u.raw_audio.format & media_raw_audio_format::B_AUDIO_SIZE_MASK;
output->fSamplesSent += nSamples; output->fSamplesSent += nSamples;
} }
} }
@@ -1761,6 +1749,10 @@ status_t
MultiAudioNode::StartThread() MultiAudioNode::StartThread()
{ {
CALLED(); CALLED();
// the thread is already started ?
if(fThread > B_OK)
return B_OK;
//allocate buffer free semaphore //allocate buffer free semaphore
fBuffer_free = create_sem( NB_BUFFERS - 1, "multi_audio out buffer free" ); fBuffer_free = create_sem( NB_BUFFERS - 1, "multi_audio out buffer free" );
@@ -1840,11 +1832,11 @@ MultiAudioNode::FillNextBuffer(multi_buffer_info &MBI, node_output &channel)
return NULL; return NULL;
if(fDevice==NULL) if(fDevice==NULL)
PRINT(("fDevice NULL\n")); fprintf(stderr,"fDevice NULL\n");
if(buffer->Header()==NULL) if(buffer->Header()==NULL)
PRINT(("buffer->Header() NULL\n")); fprintf(stderr,"buffer->Header() NULL\n");
if(TimeSource()==NULL) if(TimeSource()==NULL)
PRINT(("TimeSource() NULL\n")); fprintf(stderr,"TimeSource() NULL\n");
// now fill it with data, continuing where the last buffer left off // now fill it with data, continuing where the last buffer left off
memcpy( buffer->Data(), memcpy( buffer->Data(),
@@ -357,7 +357,6 @@ private:
BMediaAddOn *fAddOn; BMediaAddOn *fAddOn;
int32 fId; int32 fId;
//media_input input;
BList fInputs; BList fInputs;
bigtime_t fLatency; bigtime_t fLatency;
@@ -378,8 +377,6 @@ private:
MultiAudioDevice *fDevice; MultiAudioDevice *fDevice;
//int fd; //file descriptor for hw driver
//char device_name[32];
//multi_description MD; //multi_description MD;
//multi_format_info MFI; //multi_format_info MFI;
//multi_buffer_list MBL; //multi_buffer_list MBL;