MediaRoster: Don't call NodeRegistered before FinishCreate

* A TimeSource need an additional hook called FinishCreate to be
able to create it's transfer area. This hook was called after the
node registration making room for potential mismatch of the transfer
buffer. Most media nodes such as an event looper call
begin to work with time related functions just once the registration
happens. It could cause shadowed timesource objects initialization
to fail too.
* Add a debugger call to prevent any node to use an unitialized
TimeSource area, that would help to identify any remaining issue.
This commit is contained in:
Dario Casalinuovo 2017-01-25 19:03:03 +01:00
parent 0d47491d66
commit 11ed4f9fa1
2 changed files with 10 additions and 9 deletions

View File

@ -2153,11 +2153,6 @@ BMediaRosterEx::RegisterNode(BMediaNode* node, media_addon_id addOnID,
ASSERT(reply.node_id == node->Node().node); ASSERT(reply.node_id == node->Node().node);
ASSERT(reply.node_id == node->ID()); ASSERT(reply.node_id == node->ID());
// call the callback
node->NodeRegistered();
TRACE("BMediaRoster::RegisterNode: NodeRegistered callback finished\n");
// if the BMediaNode also inherits from BTimeSource, we need to call // if the BMediaNode also inherits from BTimeSource, we need to call
// BTimeSource::FinishCreate() // BTimeSource::FinishCreate()
if ((node->Kinds() & B_TIME_SOURCE) != 0) { if ((node->Kinds() & B_TIME_SOURCE) != 0) {
@ -2165,6 +2160,11 @@ BMediaRosterEx::RegisterNode(BMediaNode* node, media_addon_id addOnID,
timeSource->FinishCreate(); timeSource->FinishCreate();
} }
// call the callback
node->NodeRegistered();
TRACE("BMediaRoster::RegisterNode: NodeRegistered callback finished\n");
TRACE("BMediaRoster::RegisterNode: publishing inputs/outputs\n"); TRACE("BMediaRoster::RegisterNode: publishing inputs/outputs\n");
// register existing inputs and outputs with the // register existing inputs and outputs with the

View File

@ -227,8 +227,10 @@ BTimeSource::GetTime(bigtime_t* performance_time,
return B_OK; return B_OK;
} }
int32 index; if (fBuf == NULL)
index = _atomic_read(&fBuf->readindex); debugger("BTimeSource::GetTime: fBuf == NULL");
int32 index = _atomic_read(&fBuf->readindex);
index &= (TS_INDEX_COUNT - 1); index &= (TS_INDEX_COUNT - 1);
*real_time = fBuf->realtime[index]; *real_time = fBuf->realtime[index];
*performance_time = fBuf->perftime[index]; *performance_time = fBuf->perftime[index];
@ -359,8 +361,7 @@ BTimeSource::PublishTime(bigtime_t performance_time,
return; return;
} }
int32 index; int32 index = atomic_add(&fBuf->writeindex, 1);
index = atomic_add(&fBuf->writeindex, 1);
index &= (TS_INDEX_COUNT - 1); index &= (TS_INDEX_COUNT - 1);
fBuf->realtime[index] = real_time; fBuf->realtime[index] = real_time;
fBuf->perftime[index] = performance_time; fBuf->perftime[index] = performance_time;