Allow BMediaRoster to log local nodes
* BMediaRoster is now capable to know which nodes are instantiated in this team. This is also a first step to make them survive after media_server crashes. * A control at BMediaRoster::Quit can notify if all nodes were correctly released. Ideally at this point the local nodes list should be empty.
This commit is contained in:
@@ -92,6 +92,9 @@ public:
|
||||
|
||||
status_t BuildConnections();
|
||||
|
||||
void RegisterLocalNode(BMediaNode* node);
|
||||
void UnregisterLocalNode(BMediaNode* node);
|
||||
|
||||
private:
|
||||
friend class BMediaRoster;
|
||||
};
|
||||
|
||||
@@ -83,9 +83,30 @@ struct RosterNotification {
|
||||
};
|
||||
|
||||
|
||||
struct LocalNode {
|
||||
LocalNode(BMediaNode* local_node)
|
||||
:
|
||||
node(local_node) {}
|
||||
|
||||
LocalNode()
|
||||
:
|
||||
node(NULL) {}
|
||||
|
||||
bool operator==(const LocalNode& a)
|
||||
{
|
||||
if (a.node == this->node)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
BMediaNode* node;
|
||||
};
|
||||
|
||||
|
||||
static bool sServerIsUp = false;
|
||||
static List<RosterNotification> sNotificationList;
|
||||
static BLocker sInitLocker("BMediaRoster::Roster locker");
|
||||
static List<LocalNode> sRegisteredNodes;
|
||||
|
||||
|
||||
class MediaRosterUndertaker {
|
||||
@@ -96,6 +117,18 @@ public:
|
||||
if (BMediaRoster::CurrentRoster() != NULL
|
||||
&& BMediaRoster::CurrentRoster()->Lock()) {
|
||||
|
||||
// Detect any forgotten node
|
||||
if (sRegisteredNodes.CountItems() > 0) {
|
||||
for (int32 i = 0; i < sRegisteredNodes.CountItems(); i++) {
|
||||
LocalNode* node = NULL;
|
||||
sRegisteredNodes.Get(i, &node);
|
||||
if (node != NULL) {
|
||||
ERROR("BMediaRoster: Node with ID %" B_PRId32
|
||||
" was not released correctly\n", node->node->ID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (be_app != NULL)
|
||||
be_app->UnregisterLooper(BMediaRoster::CurrentRoster());
|
||||
|
||||
@@ -181,6 +214,22 @@ BMediaRosterEx::~BMediaRosterEx()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BMediaRosterEx::RegisterLocalNode(BMediaNode* node)
|
||||
{
|
||||
sRegisteredNodes.Insert(LocalNode(node));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BMediaRosterEx::UnregisterLocalNode(BMediaNode* node)
|
||||
{
|
||||
int32 index = sRegisteredNodes.Find(LocalNode(node));
|
||||
if (index != -1)
|
||||
sRegisteredNodes.Remove(index);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
BMediaRosterEx::SaveNodeConfiguration(BMediaNode* node)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user