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:
Dario Casalinuovo
2015-11-28 16:35:04 +01:00
parent 05962bb1e1
commit 67060664c9
2 changed files with 52 additions and 0 deletions
+3
View File
@@ -92,6 +92,9 @@ public:
status_t BuildConnections();
void RegisterLocalNode(BMediaNode* node);
void UnregisterLocalNode(BMediaNode* node);
private:
friend class BMediaRoster;
};
+49
View File
@@ -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)
{