disable node stopping on the system mixer
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3432 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5014c4dcdd
commit
545124e6a1
@ -231,7 +231,8 @@ AudioMixer::AudioMixer(BMediaAddOn *addOn)
|
||||
fFramesSent(0),
|
||||
fOutputEnabled(true),
|
||||
fBufferGroup(NULL),
|
||||
fNextFreeID(1)
|
||||
fNextFreeID(1),
|
||||
fDisableStop(false)
|
||||
|
||||
|
||||
{
|
||||
@ -289,6 +290,22 @@ AudioMixer::~AudioMixer()
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AudioMixer::DisableNodeStop()
|
||||
{
|
||||
fDisableStop = true;
|
||||
}
|
||||
|
||||
void AudioMixer::Stop(bigtime_t performance_time, bool immediate)
|
||||
{
|
||||
if (fDisableStop) {
|
||||
printf("AudioMixer STOP is disabled\n");
|
||||
return;
|
||||
} else {
|
||||
BMediaEventLooper::Stop(performance_time, immediate);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// BMediaNode methods
|
||||
//
|
||||
@ -522,6 +539,7 @@ AudioMixer::DisposeInputCookie(int32 cookie)
|
||||
void
|
||||
AudioMixer::BufferReceived(BBuffer *buffer)
|
||||
{
|
||||
|
||||
if (buffer->Header()->type == B_MEDIA_PARAMETERS) {
|
||||
printf("Control Buffer Received\n");
|
||||
ApplyParameterData(buffer->Data(), buffer->SizeUsed());
|
||||
@ -544,17 +562,18 @@ AudioMixer::BufferReceived(BBuffer *buffer)
|
||||
void
|
||||
AudioMixer::HandleInputBuffer(BBuffer *buffer, bigtime_t lateness)
|
||||
{
|
||||
static char lastIndata = 0;
|
||||
media_header *hdr = buffer->Header();
|
||||
|
||||
// printf("latency = %12Ld, event = %12Ld, sched = %5Ld, arrive at %12Ld, now %12Ld, current lateness %12Ld\n", EventLatency() + SchedulingLatency(), EventLatency(), SchedulingLatency(), buffer->Header()->start_time, TimeSource()->Now(), lateness);
|
||||
|
||||
// check input
|
||||
int inputcount = fMixerInputs.CountItems();
|
||||
|
||||
//if (inputcount == 0)
|
||||
// printf("**** input count == 0\n");
|
||||
for (int i = 0; i < inputcount; i++) {
|
||||
|
||||
mixer_input *channel = (mixer_input *)fMixerInputs.ItemAt(i);
|
||||
|
||||
|
||||
if (channel->fInput.destination.id != hdr->destination)
|
||||
continue;
|
||||
|
||||
@ -580,12 +599,17 @@ AudioMixer::HandleInputBuffer(BBuffer *buffer, bigtime_t lateness)
|
||||
*/
|
||||
if (channel->fDataSize == 0)
|
||||
break;
|
||||
|
||||
|
||||
// XXX this is probably broken now
|
||||
size_t total_offset = int(channel->fEventOffset + channel->fInput.format.u.raw_audio.buffer_size) % int(channel->fDataSize);
|
||||
|
||||
char *indata = (char *)buffer->Data();
|
||||
|
||||
|
||||
//if (indata[0] != lastIndata) {
|
||||
// printf("**** inbuffer changed to %d\n", indata[0]);
|
||||
// lastIndata = indata[0];
|
||||
//}
|
||||
|
||||
if (buffer->SizeUsed() > (channel->fDataSize - total_offset))
|
||||
{
|
||||
memcpy(channel->fData + total_offset, indata, channel->fDataSize - total_offset);
|
||||
@ -620,13 +644,21 @@ AudioMixer::SendNewBuffer(bigtime_t event_time)
|
||||
}
|
||||
|
||||
FillMixBuffer(outbuffer->Data(), outbuffer->SizeAvailable());
|
||||
|
||||
|
||||
media_header *outheader = outbuffer->Header();
|
||||
outheader->type = B_MEDIA_RAW_AUDIO;
|
||||
outheader->size_used = fOutput.format.u.raw_audio.buffer_size;
|
||||
outheader->time_source = TimeSource()->ID();
|
||||
outheader->start_time = event_time;
|
||||
|
||||
|
||||
//static char lastOutdata = 0;
|
||||
//char *outdata = (char *)outbuffer->Data();
|
||||
//if (outdata[0] != lastOutdata) {
|
||||
// printf("**** outbuffer changed to %d\n", outdata[0]);
|
||||
// lastOutdata = outdata[0];
|
||||
//}
|
||||
//printf("**** send new buffer *******\n");
|
||||
|
||||
bigtime_t start2 = system_time();
|
||||
if (B_OK != SendBuffer(outbuffer, fOutput.destination)) {
|
||||
printf("AudioMixer: Could not send buffer to output : %s\n", fOutput.name);
|
||||
|
@ -35,7 +35,10 @@ class AudioMixer :
|
||||
|
||||
AudioMixer(BMediaAddOn *addOn);
|
||||
~AudioMixer();
|
||||
|
||||
|
||||
|
||||
void DisableNodeStop();
|
||||
|
||||
// AudioMixer support
|
||||
|
||||
bool IsValidDest( media_destination dest);
|
||||
@ -60,7 +63,7 @@ class AudioMixer :
|
||||
// status_t RequestCompleted(const media_request_info & info);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
// BControllable methods
|
||||
|
||||
status_t GetParameterValue( int32 id, bigtime_t* last_change,
|
||||
@ -176,6 +179,9 @@ class AudioMixer :
|
||||
// BMediaEventLooper methods
|
||||
|
||||
virtual void NodeRegistered();
|
||||
|
||||
virtual void Stop(bigtime_t performance_time,
|
||||
bool immediate);
|
||||
|
||||
void HandleEvent( const media_timed_event *event,
|
||||
bigtime_t lateness,
|
||||
@ -215,6 +221,8 @@ class AudioMixer :
|
||||
|
||||
int fNextFreeID;
|
||||
|
||||
bool fDisableStop;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -263,7 +263,7 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
||||
} else if (mix) {
|
||||
printf("#### FillMixBuffer(): 4.Should mix from B_AUDIO_SHORT!\n");
|
||||
} else {
|
||||
printf("#### FillMixBuffer(): 4.Should copy from B_AUDIO_SHORT!\n");
|
||||
// printf("#### FillMixBuffer(): 4.Should copy from B_AUDIO_SHORT!\n");
|
||||
int baseOffset = channel->fEventOffset / 2;
|
||||
int maxOffset = int(channel->fDataSize / 2);
|
||||
|
||||
|
@ -110,6 +110,12 @@ AudioMixerAddon::AutoStart(int in_index, BMediaNode ** out_node,
|
||||
return B_ERROR;
|
||||
|
||||
*out_internal_id = 0;
|
||||
*out_node = new AudioMixer(this);
|
||||
AudioMixer *mixer = new AudioMixer(this);
|
||||
|
||||
// disable stop on the auto started (system) mixer
|
||||
mixer->DisableNodeStop();
|
||||
|
||||
*out_node = mixer;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user