Rework nodes to call Run() only after registration

* While it should not be a big problem the
  bebook specify to do it after custom operations,
  most nodes also follow this way, this commit restore
  consistency.
This commit is contained in:
Dario Casalinuovo
2015-07-24 20:09:15 +02:00
parent d009f28613
commit 6d2f2ec177
13 changed files with 47 additions and 46 deletions
@@ -181,9 +181,6 @@ DVBMediaNode::DVBMediaNode(
fRequiredFormatEncAudio = fDefaultFormatEncAudio; fRequiredFormatEncAudio = fDefaultFormatEncAudio;
fRequiredFormatTS = fDefaultFormatTS; fRequiredFormatTS = fDefaultFormatTS;
// start the BMediaEventLooper control loop running
Run();
TRACE("current RunMode = %d\n", RunMode()); TRACE("current RunMode = %d\n", RunMode());
#ifdef DUMP_VIDEO #ifdef DUMP_VIDEO
@@ -350,6 +347,8 @@ DVBMediaNode::NodeRegistered()
//printf("RunMode = %d\n", RunMode()); //printf("RunMode = %d\n", RunMode());
//printf("_m_recordDelay = %Ld\n", _m_recordDelay); //printf("_m_recordDelay = %Ld\n", _m_recordDelay);
Run();
} }
@@ -66,9 +66,6 @@ EqualizerNode::HandleMessage(int32 message, const void *data, size_t size)
void void
EqualizerNode::NodeRegistered() EqualizerNode::NodeRegistered()
{ {
SetPriority(B_REAL_TIME_PRIORITY);
Run();
fPreferredFormat.type = B_MEDIA_RAW_AUDIO; fPreferredFormat.type = B_MEDIA_RAW_AUDIO;
fPreferredFormat.u.raw_audio.buffer_size = BUFF_SIZE; fPreferredFormat.u.raw_audio.buffer_size = BUFF_SIZE;
fPreferredFormat.u.raw_audio = media_raw_audio_format::wildcard; fPreferredFormat.u.raw_audio = media_raw_audio_format::wildcard;
@@ -95,6 +92,9 @@ EqualizerNode::NodeRegistered()
InitParameterValues(); InitParameterValues();
InitParameterWeb(); InitParameterWeb();
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
@@ -195,10 +195,6 @@ void ESDSinkNode::NodeRegistered(void)
return; return;
} }
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// media_input *input = new media_input; // media_input *input = new media_input;
fInput.format = fPreferredFormat; fInput.format = fPreferredFormat;
@@ -236,6 +232,9 @@ void ESDSinkNode::NodeRegistered(void)
#ifdef PRINTING #ifdef PRINTING
PRINT(("apply configuration in : %lld\n", system_time() - start)); PRINT(("apply configuration in : %lld\n", system_time() - start));
#endif #endif
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
status_t ESDSinkNode::RequestCompleted(const media_request_info &info) status_t ESDSinkNode::RequestCompleted(const media_request_info &info)
@@ -138,9 +138,6 @@ FireWireDVNode::NodeRegistered()
{ {
CALLED(); CALLED();
SetPriority(B_REAL_TIME_PRIORITY);
Run();
fOutputEncVideo.node = Node(); fOutputEncVideo.node = Node();
fOutputEncVideo.source.port = ControlPort(); fOutputEncVideo.source.port = ControlPort();
fOutputEncVideo.source.id = 0; fOutputEncVideo.source.id = 0;
@@ -149,6 +146,9 @@ FireWireDVNode::NodeRegistered()
strcpy(fOutputEncVideo.name, "encoded video"); strcpy(fOutputEncVideo.name, "encoded video");
RefreshParameterWeb(); RefreshParameterWeb();
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
@@ -17,6 +17,7 @@
#include <Buffer.h> #include <Buffer.h>
#include <Catalog.h> #include <Catalog.h>
#include <FindDirectory.h> #include <FindDirectory.h>
#include <MediaDefs.h>
#include <MediaRoster.h> #include <MediaRoster.h>
#include <ParameterWeb.h> #include <ParameterWeb.h>
#include <Path.h> #include <Path.h>
@@ -1066,9 +1067,9 @@ AudioMixer::EnableOutput(const media_source& what, bool enabled,
void void
AudioMixer::NodeRegistered() AudioMixer::NodeRegistered()
{ {
Run();
SetPriority(120);
UpdateParameterWeb(); UpdateParameterWeb();
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
@@ -168,8 +168,11 @@ node_output::~node_output()
MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const char* name, MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const char* name,
MultiAudioDevice* device, int32 internalID, BMessage* config) MultiAudioDevice* device, int32 internalID, BMessage* config)
: BMediaNode(name), BBufferConsumer(B_MEDIA_RAW_AUDIO), :
BMediaNode(name),
BBufferConsumer(B_MEDIA_RAW_AUDIO),
BBufferProducer(B_MEDIA_RAW_AUDIO), BBufferProducer(B_MEDIA_RAW_AUDIO),
BMediaEventLooper(),
fBufferLock("multi audio buffers"), fBufferLock("multi audio buffers"),
fThread(-1), fThread(-1),
fDevice(device), fDevice(device),
@@ -335,9 +338,6 @@ MultiAudioNode::NodeRegistered()
return; return;
} }
SetPriority(B_REAL_TIME_PRIORITY);
Run();
node_input *currentInput = NULL; node_input *currentInput = NULL;
int32 currentId = 0; int32 currentId = 0;
@@ -461,6 +461,9 @@ MultiAudioNode::NodeRegistered()
PRINT(("apply configuration in : %" B_PRIdBIGTIME "\n", PRINT(("apply configuration in : %" B_PRIdBIGTIME "\n",
system_time() - start)); system_time() - start));
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
@@ -448,10 +448,6 @@ OpenSoundNode::NodeRegistered()
return; return;
} }
SetPriority(B_REAL_TIME_PRIORITY);
Run();
TRACE("NodeRegistered: %d engines\n", fDevice->CountEngines()); TRACE("NodeRegistered: %d engines\n", fDevice->CountEngines());
for (int32 i = 0; i < fDevice->CountEngines(); i++) { for (int32 i = 0; i < fDevice->CountEngines(); i++) {
OpenSoundDeviceEngine* engine = fDevice->EngineAt(i); OpenSoundDeviceEngine* engine = fDevice->EngineAt(i);
@@ -576,6 +572,9 @@ OpenSoundNode::NodeRegistered()
} }
TRACE("apply configuration in : %lldµs\n", system_time() - start); TRACE("apply configuration in : %lldµs\n", system_time() - start);
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
@@ -629,16 +629,16 @@ ToneProducer::NodeRegistered()
{ {
FPRINTF(stderr, "ToneProducer::NodeRegistered\n"); FPRINTF(stderr, "ToneProducer::NodeRegistered\n");
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// output init moved to ctor // output init moved to ctor
// e.moon [4jun99] // e.moon [4jun99]
// Set up our parameter web // Set up our parameter web
mWeb = make_parameter_web(); mWeb = make_parameter_web();
SetParameterWeb(mWeb); SetParameterWeb(mWeb);
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
void void
@@ -64,9 +64,6 @@ VSTNode::HandleMessage(int32 message, const void* data, size_t size)
void void
VSTNode::NodeRegistered() VSTNode::NodeRegistered()
{ {
SetPriority(B_REAL_TIME_PRIORITY);
Run();
fPreferredFormat.type = B_MEDIA_RAW_AUDIO; fPreferredFormat.type = B_MEDIA_RAW_AUDIO;
fPreferredFormat.u.raw_audio.buffer_size = BUFF_SIZE; fPreferredFormat.u.raw_audio.buffer_size = BUFF_SIZE;
fPreferredFormat.u.raw_audio = media_raw_audio_format::wildcard; fPreferredFormat.u.raw_audio = media_raw_audio_format::wildcard;
@@ -93,6 +90,9 @@ VSTNode::NodeRegistered()
InitParameterValues(); InitParameterValues();
InitParameterWeb(); InitParameterWeb();
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
//BControllable //BControllable
@@ -227,10 +227,6 @@ void FlangerNode::NodeRegistered() {
PRINT(("FlangerNode::NodeRegistered()\n")); PRINT(("FlangerNode::NodeRegistered()\n"));
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// figure preferred ('template') format // figure preferred ('template') format
m_preferredFormat.type = B_MEDIA_RAW_AUDIO; m_preferredFormat.type = B_MEDIA_RAW_AUDIO;
getPreferredFormat(m_preferredFormat); getPreferredFormat(m_preferredFormat);
@@ -258,6 +254,10 @@ void FlangerNode::NodeRegistered() {
// init parameters // init parameters
initParameterValues(); initParameterValues();
initParameterWeb(); initParameterWeb();
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
// "Augment OfflineTime() to compute the node's current time; it's called // "Augment OfflineTime() to compute the node's current time; it's called
@@ -384,10 +384,6 @@ void AudioFilterNode::NodeRegistered() {
PRINT(("AudioFilterNode::NodeRegistered()\n")); PRINT(("AudioFilterNode::NodeRegistered()\n"));
status_t err; status_t err;
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// init input // init input
m_input.destination.port = ControlPort(); m_input.destination.port = ControlPort();
m_input.destination.id = ID_AUDIO_INPUT; m_input.destination.id = ID_AUDIO_INPUT;
@@ -414,6 +410,10 @@ void AudioFilterNode::NodeRegistered() {
// init parameters // init parameters
initParameterWeb(); initParameterWeb();
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
// "Augment OfflineTime() to compute the node's current time; it's called // "Augment OfflineTime() to compute the node's current time; it's called
@@ -587,15 +587,15 @@ AudioProducer::NodeRegistered()
{ {
TRACE("%p->AudioProducer::NodeRegistered()\n", this); TRACE("%p->AudioProducer::NodeRegistered()\n", this);
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// set up as much information about our output as we can // set up as much information about our output as we can
fOutput.source.port = ControlPort(); fOutput.source.port = ControlPort();
fOutput.source.id = 0; fOutput.source.id = 0;
fOutput.node = Node(); fOutput.node = Node();
::strcpy(fOutput.name, Name()); ::strcpy(fOutput.name, Name());
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }
+4 -4
View File
@@ -422,15 +422,15 @@ GameProducer::AdditionalBufferRequested(const media_source& source,
void void
GameProducer::NodeRegistered() GameProducer::NodeRegistered()
{ {
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
// set up as much information about our output as we can // set up as much information about our output as we can
fOutput.source.port = ControlPort(); fOutput.source.port = ControlPort();
fOutput.source.id = 0; fOutput.source.id = 0;
fOutput.node = Node(); fOutput.node = Node();
strlcpy(fOutput.name, "GameProducer Output", B_MEDIA_NAME_LENGTH); strlcpy(fOutput.name, "GameProducer Output", B_MEDIA_NAME_LENGTH);
// Start the BMediaEventLooper thread
SetPriority(B_REAL_TIME_PRIORITY);
Run();
} }