various small changes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2071 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper 2002-11-24 00:27:09 +00:00
parent a4cd2d3f33
commit 41ba915d42
15 changed files with 67 additions and 16 deletions

View File

@ -70,7 +70,7 @@ void
BBuffer::SetSizeUsed(size_t size_used) BBuffer::SetSizeUsed(size_t size_used)
{ {
CALLED(); CALLED();
fMediaHeader.size_used = min_c(size_used,fSize); fMediaHeader.size_used = min_c(size_used, fSize);
} }

View File

@ -17,6 +17,7 @@
status_t status_t
BBufferGroup::InitBufferGroup() BBufferGroup::InitBufferGroup()
{ {
CALLED();
area_id id; area_id id;
// some defaults // some defaults

View File

@ -41,7 +41,7 @@ namespace media {
DormantNodeManager::DormantNodeManager() DormantNodeManager::DormantNodeManager()
{ {
fLock = new BLocker(); fLock = new BLocker("dormant node manager locker");
fAddonmap = new Map<media_addon_id,loaded_addon_info>; fAddonmap = new Map<media_addon_id,loaded_addon_info>;
} }

View File

@ -309,7 +309,7 @@ BMediaFormats::find_addons(
int32 BMediaFormats::s_cleared; int32 BMediaFormats::s_cleared;
BMessenger BMediaFormats::s_server; BMessenger BMediaFormats::s_server;
BList BMediaFormats::s_formats; BList BMediaFormats::s_formats;
BLocker BMediaFormats::s_lock; BLocker BMediaFormats::s_lock("BMediaFormats locker");
/************************************************************* /*************************************************************
* *

View File

@ -50,12 +50,13 @@ _shared_buffer_list::Clone(area_id id)
//TRACE("cloned area, id = 0x%08lx, ptr = 0x%08x\n",status,(int)adr); //TRACE("cloned area, id = 0x%08lx, ptr = 0x%08x\n",status,(int)adr);
} }
return (status < B_OK) ? NULL : adr; return (status < B_OK) ? NULL : adr;
} }
void void
_shared_buffer_list::Unmap() _shared_buffer_list::Unmap()
{ {
CALLED();
// unmap the memory used by this struct // unmap the memory used by this struct
// XXX is this save? // XXX is this save?
area_id id; area_id id;

View File

@ -16,7 +16,7 @@
#include "debug.h" #include "debug.h"
_event_queue_imp::_event_queue_imp() : _event_queue_imp::_event_queue_imp() :
fLock("BTimedEventQueue locker"), fLock(new BLocker("BTimedEventQueue locker")),
fEventCount(0), fEventCount(0),
fFirstEntry(NULL), fFirstEntry(NULL),
fLastEntry(NULL), fLastEntry(NULL),
@ -36,6 +36,7 @@ _event_queue_imp::~_event_queue_imp()
entry = entry->next; entry = entry->next;
delete deleteme; delete deleteme;
} }
delete fLock;
} }

View File

@ -67,7 +67,7 @@ private:
event_queue_entry *GetEnd_BeforeTime(bigtime_t eventTime, bool inclusive); event_queue_entry *GetEnd_BeforeTime(bigtime_t eventTime, bool inclusive);
event_queue_entry *GetStart_AfterTime(bigtime_t eventTime, bool inclusive); event_queue_entry *GetStart_AfterTime(bigtime_t eventTime, bool inclusive);
BLocker fLock; BLocker * fLock;
int32 fEventCount; int32 fEventCount;
event_queue_entry *fFirstEntry; event_queue_entry *fFirstEntry;
event_queue_entry *fLastEntry; event_queue_entry *fLastEntry;

View File

@ -15,12 +15,16 @@
#include <stdio.h> #include <stdio.h>
#include <Debug.h> #include <Debug.h>
#include "AppManager.h" #include "AppManager.h"
#include "NodeManager.h"
#include "BufferManager.h"
#include "NotificationManager.h"
#include "media_server.h"
AppManager::AppManager() AppManager::AppManager()
: fAddonServer(-1) : fAddonServer(-1)
{ {
fAppMap = new Map<team_id, App>; fAppMap = new Map<team_id, App>;
fLocker = new BLocker; fLocker = new BLocker("app manager locker");
fQuit = create_sem(0, "big brother waits"); fQuit = create_sem(0, "big brother waits");
fBigBrother = spawn_thread(bigbrother, "big brother is watching you", B_NORMAL_PRIORITY, this); fBigBrother = spawn_thread(bigbrother, "big brother is watching you", B_NORMAL_PRIORITY, this);
resume_thread(fBigBrother); resume_thread(fBigBrother);
@ -174,6 +178,9 @@ void AppManager::CleanupTeam(team_id team)
printf("AppManager: cleaning up team %ld\n", team); printf("AppManager: cleaning up team %ld\n", team);
gNodeManager->CleanupTeam(team);
gBufferManager->CleanupTeam(team);
gNotificationManager->CleanupTeam(team);
} }
void AppManager::CleanupAddonServer() void AppManager::CleanupAddonServer()

View File

@ -1,4 +1,4 @@
/* /*
* Copyright 2002, Marcus Overhagen. All rights reserved. * Copyright 2002, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@ -134,6 +134,12 @@ BufferManager::UnregisterBuffer(team_id teamid, media_buffer_id bufferid)
return B_ERROR; return B_ERROR;
} }
void
BufferManager::CleanupTeam(team_id teamid)
{
}
void void
BufferManager::PrintToStream() BufferManager::PrintToStream()
{ {

View File

@ -19,6 +19,8 @@ public:
media_buffer_id *bufferid); media_buffer_id *bufferid);
status_t UnregisterBuffer(team_id teamid, media_buffer_id bufferid); status_t UnregisterBuffer(team_id teamid, media_buffer_id bufferid);
void CleanupTeam(team_id teamid);
void PrintToStream(); void PrintToStream();

View File

@ -5,6 +5,8 @@
#include <OS.h> #include <OS.h>
#include <Entry.h> #include <Entry.h>
#include <Message.h> #include <Message.h>
#include <Locker.h>
#include <Autolock.h>
#include <Messenger.h> #include <Messenger.h>
#include <MediaDefs.h> #include <MediaDefs.h>
#include <MediaAddOn.h> #include <MediaAddOn.h>
@ -13,12 +15,11 @@
#include "debug.h" #include "debug.h"
#include "NodeManager.h" #include "NodeManager.h"
// XXX locking is missing
NodeManager::NodeManager() : NodeManager::NodeManager() :
nextaddonid(1), nextaddonid(1),
nextnodeid(1) nextnodeid(1)
{ {
fLocker = new BLocker("node manager locker");
fDormantFlavorList = new List<dormant_flavor_info>; fDormantFlavorList = new List<dormant_flavor_info>;
fAddonPathMap = new Map<media_addon_id,entry_ref>; fAddonPathMap = new Map<media_addon_id,entry_ref>;
fRegisteredNodeMap = new Map<media_node_id,registered_node>; fRegisteredNodeMap = new Map<media_node_id,registered_node>;
@ -27,6 +28,7 @@ NodeManager::NodeManager() :
NodeManager::~NodeManager() NodeManager::~NodeManager()
{ {
delete fLocker;
delete fDormantFlavorList; delete fDormantFlavorList;
delete fAddonPathMap; delete fAddonPathMap;
delete fRegisteredNodeMap; delete fRegisteredNodeMap;
@ -36,6 +38,7 @@ NodeManager::~NodeManager()
status_t status_t
NodeManager::RegisterNode(media_node_id *nodeid, media_addon_id addon_id, int32 addon_flavor_id, const char *name, uint64 kinds, port_id port, team_id team) NodeManager::RegisterNode(media_node_id *nodeid, media_addon_id addon_id, int32 addon_flavor_id, const char *name, uint64 kinds, port_id port, team_id team)
{ {
BAutolock lock(fLocker);
bool b; bool b;
registered_node rn; registered_node rn;
rn.nodeid = nextnodeid; rn.nodeid = nextnodeid;
@ -60,6 +63,7 @@ NodeManager::RegisterNode(media_node_id *nodeid, media_addon_id addon_id, int32
status_t status_t
NodeManager::UnregisterNode(media_addon_id *addon_id, media_node_id nodeid, team_id team) NodeManager::UnregisterNode(media_addon_id *addon_id, media_node_id nodeid, team_id team)
{ {
BAutolock lock(fLocker);
bool b; bool b;
registered_node *rn; registered_node *rn;
TRACE("NodeManager::UnregisterNode enter: node %ld, team %ld\n", nodeid, team); TRACE("NodeManager::UnregisterNode enter: node %ld, team %ld\n", nodeid, team);
@ -87,6 +91,7 @@ NodeManager::UnregisterNode(media_addon_id *addon_id, media_node_id nodeid, team
status_t status_t
NodeManager::IncrementGlobalRefCount(media_node_id nodeid, team_id team) NodeManager::IncrementGlobalRefCount(media_node_id nodeid, team_id team)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
bool b; bool b;
TRACE("NodeManager::IncrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team); TRACE("NodeManager::IncrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team);
@ -115,6 +120,7 @@ NodeManager::IncrementGlobalRefCount(media_node_id nodeid, team_id team)
status_t status_t
NodeManager::DecrementGlobalRefCount(media_node_id nodeid, team_id team) NodeManager::DecrementGlobalRefCount(media_node_id nodeid, team_id team)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
bool b; bool b;
TRACE("NodeManager::DecrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team); TRACE("NodeManager::DecrementGlobalRefCount enter: node %ld, team %ld\n", nodeid, team);
@ -144,6 +150,7 @@ NodeManager::DecrementGlobalRefCount(media_node_id nodeid, team_id team)
status_t status_t
NodeManager::GetCloneForId(media_node *node, media_node_id nodeid, team_id team) NodeManager::GetCloneForId(media_node *node, media_node_id nodeid, team_id team)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
bool b; bool b;
TRACE("NodeManager::GetCloneForId enter: node %ld team %ld\n", nodeid, team); TRACE("NodeManager::GetCloneForId enter: node %ld team %ld\n", nodeid, team);
@ -171,6 +178,7 @@ NodeManager::GetCloneForId(media_node *node, media_node_id nodeid, team_id team)
status_t status_t
NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_type type, team_id team) NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_type type, team_id team)
{ {
BAutolock lock(fLocker);
TRACE("!!! NodeManager::GetClone not implemented\n"); TRACE("!!! NodeManager::GetClone not implemented\n");
*node = media_node::null; *node = media_node::null;
return B_ERROR; return B_ERROR;
@ -180,6 +188,7 @@ NodeManager::GetClone(media_node *node, char *input_name, int32 *input_id, node_
status_t status_t
NodeManager::ReleaseNode(const media_node &node, team_id team) NodeManager::ReleaseNode(const media_node &node, team_id team)
{ {
BAutolock lock(fLocker);
TRACE("NodeManager::ReleaseNode enter: node %ld team %ld\n", node.node, team); TRACE("NodeManager::ReleaseNode enter: node %ld team %ld\n", node.node, team);
if (B_OK != DecrementGlobalRefCount(node.node, team)) { if (B_OK != DecrementGlobalRefCount(node.node, team)) {
TRACE("!!! NodeManager::ReleaseNode: Error: couldn't decrement node %ld team %ld ref count\n", node.node, team); TRACE("!!! NodeManager::ReleaseNode: Error: couldn't decrement node %ld team %ld ref count\n", node.node, team);
@ -192,6 +201,7 @@ NodeManager::ReleaseNode(const media_node &node, team_id team)
status_t status_t
NodeManager::PublishInputs(const media_node &node, const media_input *inputs, int32 count) NodeManager::PublishInputs(const media_node &node, const media_input *inputs, int32 count)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
bool b; bool b;
b = fRegisteredNodeMap->GetPointer(node.node, &rn); b = fRegisteredNodeMap->GetPointer(node.node, &rn);
@ -209,6 +219,7 @@ NodeManager::PublishInputs(const media_node &node, const media_input *inputs, in
status_t status_t
NodeManager::PublishOutputs(const media_node &node, const media_output *outputs, int32 count) NodeManager::PublishOutputs(const media_node &node, const media_output *outputs, int32 count)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
bool b; bool b;
b = fRegisteredNodeMap->GetPointer(node.node, &rn); b = fRegisteredNodeMap->GetPointer(node.node, &rn);
@ -226,6 +237,7 @@ NodeManager::PublishOutputs(const media_node &node, const media_output *outputs,
status_t status_t
NodeManager::FindNodeId(media_node_id *nodeid, port_id port) NodeManager::FindNodeId(media_node_id *nodeid, port_id port)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) { for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) {
if (rn->port == port) { if (rn->port == port) {
@ -258,6 +270,7 @@ NodeManager::FindNodeId(media_node_id *nodeid, port_id port)
status_t status_t
NodeManager::GetLiveNodeInfo(live_node_info *live_info, const media_node &node) NodeManager::GetLiveNodeInfo(live_node_info *live_info, const media_node &node)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) { for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) {
if (rn->nodeid == node.node) { if (rn->nodeid == node.node) {
@ -278,6 +291,7 @@ NodeManager::GetLiveNodeInfo(live_node_info *live_info, const media_node &node)
status_t status_t
NodeManager::GetInstances(media_node_id *node_ids, int32* count, int32 maxcount, media_addon_id addon_id, int32 addon_flavor_id) NodeManager::GetInstances(media_node_id *node_ids, int32* count, int32 maxcount, media_addon_id addon_id, int32 addon_flavor_id)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
*count = 0; *count = 0;
for (int32 i = 0; (maxcount > 0) && fRegisteredNodeMap->GetPointerAt(i, &rn); i++) { for (int32 i = 0; (maxcount > 0) && fRegisteredNodeMap->GetPointerAt(i, &rn); i++) {
@ -295,6 +309,7 @@ NodeManager::GetInstances(media_node_id *node_ids, int32* count, int32 maxcount,
status_t status_t
NodeManager::GetLiveNodes(Stack<live_node_info> *livenodes, int32 maxcount, const media_format *inputformat /* = NULL */, const media_format *outputformat /* = NULL */, const char* name /* = NULL */, uint64 require_kinds /* = 0 */) NodeManager::GetLiveNodes(Stack<live_node_info> *livenodes, int32 maxcount, const media_format *inputformat /* = NULL */, const media_format *outputformat /* = NULL */, const char* name /* = NULL */, uint64 require_kinds /* = 0 */)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
int namelen; int namelen;
@ -358,6 +373,7 @@ NodeManager::GetLiveNodes(Stack<live_node_info> *livenodes, int32 maxcount, cons
status_t status_t
NodeManager::GetDormantNodeInfo(dormant_node_info *node_info, const media_node &node) NodeManager::GetDormantNodeInfo(dormant_node_info *node_info, const media_node &node)
{ {
BAutolock lock(fLocker);
// XXX not sure if this is correct // XXX not sure if this is correct
registered_node *rn; registered_node *rn;
for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) { for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) {
@ -382,6 +398,7 @@ NodeManager::GetDormantNodeInfo(dormant_node_info *node_info, const media_node &
status_t status_t
NodeManager::GetLiveNodes(BMessage *msg) NodeManager::GetLiveNodes(BMessage *msg)
{ {
BAutolock lock(fLocker);
registered_node *rn; registered_node *rn;
for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++) for (int32 i = 0; fRegisteredNodeMap->GetPointerAt(i, &rn); i++)
msg->AddInt32("media_node_id", rn->nodeid); msg->AddInt32("media_node_id", rn->nodeid);
@ -391,6 +408,7 @@ NodeManager::GetLiveNodes(BMessage *msg)
void void
NodeManager::RegisterAddon(const entry_ref &ref, media_addon_id *newid) NodeManager::RegisterAddon(const entry_ref &ref, media_addon_id *newid)
{ {
BAutolock lock(fLocker);
media_addon_id id; media_addon_id id;
id = nextaddonid; id = nextaddonid;
nextaddonid += 1; nextaddonid += 1;
@ -402,6 +420,7 @@ NodeManager::RegisterAddon(const entry_ref &ref, media_addon_id *newid)
void void
NodeManager::UnregisterAddon(media_addon_id id) NodeManager::UnregisterAddon(media_addon_id id)
{ {
BAutolock lock(fLocker);
RemoveDormantFlavorInfo(id); RemoveDormantFlavorInfo(id);
fAddonPathMap->Remove(id); fAddonPathMap->Remove(id);
} }
@ -409,18 +428,21 @@ NodeManager::UnregisterAddon(media_addon_id id)
void void
NodeManager::AddDormantFlavorInfo(const dormant_flavor_info &dfi) NodeManager::AddDormantFlavorInfo(const dormant_flavor_info &dfi)
{ {
BAutolock lock(fLocker);
fDormantFlavorList->Insert(dfi); fDormantFlavorList->Insert(dfi);
} }
void void
NodeManager::RemoveDormantFlavorInfo(media_addon_id id) NodeManager::RemoveDormantFlavorInfo(media_addon_id id)
{ {
BAutolock lock(fLocker);
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
status_t status_t
NodeManager::GetAddonRef(entry_ref *ref, media_addon_id id) NodeManager::GetAddonRef(entry_ref *ref, media_addon_id id)
{ {
BAutolock lock(fLocker);
return fAddonPathMap->Get(id, ref) ? B_OK : B_ERROR; return fAddonPathMap->Get(id, ref) ? B_OK : B_ERROR;
} }
@ -433,6 +455,7 @@ NodeManager::GetDormantNodes(dormant_node_info * out_info,
uint64 require_kinds /* = NULL */, uint64 require_kinds /* = NULL */,
uint64 deny_kinds /* = NULL */) uint64 deny_kinds /* = NULL */)
{ {
BAutolock lock(fLocker);
int32 maxcount; int32 maxcount;
int32 index; int32 index;
dormant_flavor_info dfi; dormant_flavor_info dfi;
@ -492,9 +515,16 @@ NodeManager::GetDormantFlavorInfoFor(media_addon_id addon,
int32 flavor_id, int32 flavor_id,
dormant_flavor_info *outFlavor) dormant_flavor_info *outFlavor)
{ {
BAutolock lock(fLocker);
for (int32 index = 0; fDormantFlavorList->GetAt(index, outFlavor); index++) { for (int32 index = 0; fDormantFlavorList->GetAt(index, outFlavor); index++) {
if (outFlavor->node_info.addon == addon && outFlavor->node_info.flavor_id == flavor_id) if (outFlavor->node_info.addon == addon && outFlavor->node_info.flavor_id == flavor_id)
return B_OK; return B_OK;
} }
return B_ERROR; return B_ERROR;
} }
void
NodeManager::CleanupTeam(team_id team)
{
BAutolock lock(fLocker);
}

View File

@ -83,10 +83,13 @@ public:
int32 flavor_id, int32 flavor_id,
dormant_flavor_info *outFlavor); dormant_flavor_info *outFlavor);
void CleanupTeam(team_id team);
private: private:
media_addon_id nextaddonid; media_addon_id nextaddonid;
media_node_id nextnodeid; media_node_id nextnodeid;
BLocker *fLocker;
List<dormant_flavor_info> *fDormantFlavorList; List<dormant_flavor_info> *fDormantFlavorList;
Map<media_addon_id,entry_ref> *fAddonPathMap; Map<media_addon_id,entry_ref> *fAddonPathMap;
Map<media_node_id,registered_node> *fRegisteredNodeMap; Map<media_node_id,registered_node> *fRegisteredNodeMap;

View File

@ -13,10 +13,9 @@
#include "DataExchange.h" #include "DataExchange.h"
#include "Notifications.h" #include "Notifications.h"
#include "NotificationManager.h" #include "NotificationManager.h"
#include "media_server.h"
#include "Queue.h" #include "Queue.h"
extern NodeManager *gNodeManager;
#define NOTIFICATION_THREAD_PRIORITY 19 #define NOTIFICATION_THREAD_PRIORITY 19
#define TIMEOUT 100000 #define TIMEOUT 100000
@ -24,7 +23,7 @@ extern NodeManager *gNodeManager;
NotificationManager::NotificationManager() NotificationManager::NotificationManager()
: fNotificationQueue(new Queue), : fNotificationQueue(new Queue),
fNotificationThreadId(-1), fNotificationThreadId(-1),
fLocker(new BLocker), fLocker(new BLocker("notification manager locker")),
fNotificationList(new List<Notification>) fNotificationList(new List<Notification>)
{ {
fNotificationThreadId = spawn_thread(NotificationManager::worker_thread, "notification broadcast", NOTIFICATION_THREAD_PRIORITY, this); fNotificationThreadId = spawn_thread(NotificationManager::worker_thread, "notification broadcast", NOTIFICATION_THREAD_PRIORITY, this);

View File

@ -20,8 +20,8 @@
Queue::Queue() Queue::Queue()
: fList(new BList), : fList(new BList),
fLocker(new BLocker), fLocker(new BLocker("queue locker")),
fSem(create_sem(0,"queue sem")) fSem(create_sem(0, "queue sem"))
{ {
} }

View File

@ -10,6 +10,7 @@
#include "BufferManager.h" #include "BufferManager.h"
#include "NodeManager.h" #include "NodeManager.h"
#include "AppManager.h" #include "AppManager.h"
#include "media_server.h"
#define DEBUG 1 #define DEBUG 1
#include <Debug.h> #include <Debug.h>
#include "debug.h" #include "debug.h"
@ -86,7 +87,7 @@ private:
ServerApp::ServerApp() ServerApp::ServerApp()
: BApplication(NEW_MEDIA_SERVER_SIGNATURE), : BApplication(NEW_MEDIA_SERVER_SIGNATURE),
fLocker(new BLocker("server locker")) fLocker(new BLocker("media server locker"))
{ {
//load volume settings from config file //load volume settings from config file
//mVolumeLeft = ???; //mVolumeLeft = ???;