changed the notification support

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1341 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2002-10-02 12:01:37 +00:00
parent 3cfbf2cf23
commit 1d616657b9
4 changed files with 29 additions and 30 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ Server media_server :
AppManager.cpp AppManager.cpp
BufferManager.cpp BufferManager.cpp
NodeManager.cpp NodeManager.cpp
NotificationProcessor.cpp NotificationManager.cpp
Queue.cpp Queue.cpp
; ;
LinkSharedOSLibs media_server : be libmedia.so root ; LinkSharedOSLibs media_server : be libmedia.so root ;
@@ -4,10 +4,9 @@
#include <Messenger.h> #include <Messenger.h>
#include <MediaNode.h> #include <MediaNode.h>
#include <Debug.h> #include <Debug.h>
#include "NotificationManager.h"
#include "NotificationProcessor.h"
#include "ServerInterface.h"
#include "DataExchange.h" #include "DataExchange.h"
#include "Notifications.h"
#include "NotificationManager.h"
#include "Queue.h" #include "Queue.h"
#define NOTIFICATION_THREAD_PRIORITY 19 #define NOTIFICATION_THREAD_PRIORITY 19
@@ -20,16 +19,16 @@ struct RegisteredHandler
team_id team; team_id team;
}; };
NotificationProcessor::NotificationProcessor() NotificationManager::NotificationManager()
: fNotificationQueue(new Queue), : fNotificationQueue(new Queue),
fNotificationThreadId(-1), fNotificationThreadId(-1),
fLocker(new BLocker) fLocker(new BLocker)
{ {
fNotificationThreadId = spawn_thread(NotificationProcessor::worker_thread, "notification broadcast", NOTIFICATION_THREAD_PRIORITY, this); fNotificationThreadId = spawn_thread(NotificationManager::worker_thread, "notification broadcast", NOTIFICATION_THREAD_PRIORITY, this);
resume_thread(fNotificationThreadId); resume_thread(fNotificationThreadId);
} }
NotificationProcessor::~NotificationProcessor() NotificationManager::~NotificationManager()
{ {
// properly terminate the queue and wait until the worker thread has finished // properly terminate the queue and wait until the worker thread has finished
status_t dummy; status_t dummy;
@@ -40,63 +39,63 @@ NotificationProcessor::~NotificationProcessor()
} }
void void
NotificationProcessor::EnqueueMessage(BMessage *msg) NotificationManager::EnqueueMessage(BMessage *msg)
{ {
// queue a copy of the message to be processed later // queue a copy of the message to be processed later
fNotificationQueue->AddItem(new BMessage(*msg)); fNotificationQueue->AddItem(new BMessage(*msg));
} }
void void
NotificationProcessor::RequestNotifications(BMessage *msg) NotificationManager::RequestNotifications(BMessage *msg)
{ {
BMessenger messenger; BMessenger messenger;
const media_node *node; const media_node *node;
ssize_t nodesize; ssize_t nodesize;
team_id team; team_id team;
int32 mask; int32 what;
msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger); msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger);
msg->FindInt32(NOTIFICATION_PARAM_TEAM, &team); msg->FindInt32(NOTIFICATION_PARAM_TEAM, &team);
msg->FindInt32(NOTIFICATION_PARAM_MASK, &mask); msg->FindInt32(NOTIFICATION_PARAM_WHAT, &what);
msg->FindData("node", B_RAW_TYPE, reinterpret_cast<const void **>(&node), &nodesize); msg->FindData("node", B_RAW_TYPE, reinterpret_cast<const void **>(&node), &nodesize);
ASSERT(nodesize == sizeof(node)); ASSERT(nodesize == sizeof(node));
} }
void void
NotificationProcessor::CancelNotifications(BMessage *msg) NotificationManager::CancelNotifications(BMessage *msg)
{ {
BMessenger messenger; BMessenger messenger;
const media_node *node; const media_node *node;
ssize_t nodesize; ssize_t nodesize;
team_id team; team_id team;
int32 mask; int32 what;
msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger); msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger);
msg->FindInt32(NOTIFICATION_PARAM_TEAM, &team); msg->FindInt32(NOTIFICATION_PARAM_TEAM, &team);
msg->FindInt32(NOTIFICATION_PARAM_MASK, &mask); msg->FindInt32(NOTIFICATION_PARAM_WHAT, &what);
msg->FindData("node", B_RAW_TYPE, reinterpret_cast<const void **>(&node), &nodesize); msg->FindData("node", B_RAW_TYPE, reinterpret_cast<const void **>(&node), &nodesize);
ASSERT(nodesize == sizeof(node)); ASSERT(nodesize == sizeof(node));
} }
void void
NotificationProcessor::SendNotifications(BMessage *msg) NotificationManager::SendNotifications(BMessage *msg)
{ {
} }
void void
NotificationProcessor::CleanupTeam(team_id team) NotificationManager::CleanupTeam(team_id team)
{ {
} }
void void
NotificationProcessor::BroadcastMessages(BMessage *msg) NotificationManager::BroadcastMessages(BMessage *msg)
{ {
} }
void void
NotificationProcessor::WorkerThread() NotificationManager::WorkerThread()
{ {
BMessage *msg; BMessage *msg;
while (NULL != (msg = static_cast<BMessage *>(fNotificationQueue->RemoveItem()))) { while (NULL != (msg = static_cast<BMessage *>(fNotificationQueue->RemoveItem()))) {
@@ -118,8 +117,8 @@ NotificationProcessor::WorkerThread()
} }
int32 int32
NotificationProcessor::worker_thread(void *arg) NotificationManager::worker_thread(void *arg)
{ {
static_cast<NotificationProcessor *>(arg)->WorkerThread(); static_cast<NotificationManager *>(arg)->WorkerThread();
return 0; return 0;
} }
@@ -1,11 +1,11 @@
class Queue; class Queue;
class NotificationProcessor class NotificationManager
{ {
public: public:
NotificationProcessor(); NotificationManager();
~NotificationProcessor(); ~NotificationManager();
void EnqueueMessage(BMessage *msg); void EnqueueMessage(BMessage *msg);
+7 -7
View File
@@ -4,7 +4,7 @@
#include <MediaDefs.h> #include <MediaDefs.h>
#include <MediaFormats.h> #include <MediaFormats.h>
#include <Autolock.h> #include <Autolock.h>
#include "NotificationProcessor.h" #include "NotificationManager.h"
#include "ServerInterface.h" #include "ServerInterface.h"
#include "DataExchange.h" #include "DataExchange.h"
#include "BufferManager.h" #include "BufferManager.h"
@@ -107,7 +107,7 @@ private:
port_id control_port; port_id control_port;
thread_id control_thread; thread_id control_thread;
NotificationProcessor *fNotificationProcessor; NotificationManager *fNotificationManager;
BufferManager *fBufferManager; BufferManager *fBufferManager;
AppManager *fAppManager; AppManager *fAppManager;
NodeManager *fNodeManager; NodeManager *fNodeManager;
@@ -122,7 +122,7 @@ private:
ServerApp::ServerApp() ServerApp::ServerApp()
: BApplication(NEW_MEDIA_SERVER_SIGNATURE), : BApplication(NEW_MEDIA_SERVER_SIGNATURE),
fNotificationProcessor(new NotificationProcessor), fNotificationManager(new NotificationManager),
fBufferManager(new BufferManager), fBufferManager(new BufferManager),
fAppManager(new AppManager), fAppManager(new AppManager),
fNodeManager(new NodeManager), fNodeManager(new NodeManager),
@@ -140,7 +140,7 @@ ServerApp::ServerApp()
ServerApp::~ServerApp() ServerApp::~ServerApp()
{ {
delete fNotificationProcessor; delete fNotificationManager;
delete fBufferManager; delete fBufferManager;
delete fAppManager; delete fAppManager;
delete fNodeManager; delete fNodeManager;
@@ -548,9 +548,9 @@ void ServerApp::MessageReceived(BMessage *msg)
case MEDIA_SERVER_GET_SHARED_BUFFER_AREA: GetSharedBufferArea(msg); break; case MEDIA_SERVER_GET_SHARED_BUFFER_AREA: GetSharedBufferArea(msg); break;
case MEDIA_SERVER_REGISTER_BUFFER: RegisterBuffer(msg); break; case MEDIA_SERVER_REGISTER_BUFFER: RegisterBuffer(msg); break;
case MEDIA_SERVER_UNREGISTER_BUFFER: UnregisterBuffer(msg); break; case MEDIA_SERVER_UNREGISTER_BUFFER: UnregisterBuffer(msg); break;
case MEDIA_SERVER_REQUEST_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break; case MEDIA_SERVER_REQUEST_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_CANCEL_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break; case MEDIA_SERVER_CANCEL_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_SEND_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break; case MEDIA_SERVER_SEND_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_GET_NODE_ID: GetNodeID(msg); break; case MEDIA_SERVER_GET_NODE_ID: GetNodeID(msg); break;