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

View File

@ -7,7 +7,7 @@ Server media_server :
AppManager.cpp
BufferManager.cpp
NodeManager.cpp
NotificationProcessor.cpp
NotificationManager.cpp
Queue.cpp
;
LinkSharedOSLibs media_server : be libmedia.so root ;

View File

@ -4,10 +4,9 @@
#include <Messenger.h>
#include <MediaNode.h>
#include <Debug.h>
#include "NotificationManager.h"
#include "NotificationProcessor.h"
#include "ServerInterface.h"
#include "DataExchange.h"
#include "Notifications.h"
#include "NotificationManager.h"
#include "Queue.h"
#define NOTIFICATION_THREAD_PRIORITY 19
@ -20,16 +19,16 @@ struct RegisteredHandler
team_id team;
};
NotificationProcessor::NotificationProcessor()
NotificationManager::NotificationManager()
: fNotificationQueue(new Queue),
fNotificationThreadId(-1),
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);
}
NotificationProcessor::~NotificationProcessor()
NotificationManager::~NotificationManager()
{
// properly terminate the queue and wait until the worker thread has finished
status_t dummy;
@ -40,63 +39,63 @@ NotificationProcessor::~NotificationProcessor()
}
void
NotificationProcessor::EnqueueMessage(BMessage *msg)
NotificationManager::EnqueueMessage(BMessage *msg)
{
// queue a copy of the message to be processed later
fNotificationQueue->AddItem(new BMessage(*msg));
}
void
NotificationProcessor::RequestNotifications(BMessage *msg)
NotificationManager::RequestNotifications(BMessage *msg)
{
BMessenger messenger;
const media_node *node;
ssize_t nodesize;
team_id team;
int32 mask;
int32 what;
msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger);
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);
ASSERT(nodesize == sizeof(node));
}
void
NotificationProcessor::CancelNotifications(BMessage *msg)
NotificationManager::CancelNotifications(BMessage *msg)
{
BMessenger messenger;
const media_node *node;
ssize_t nodesize;
team_id team;
int32 mask;
int32 what;
msg->FindMessenger(NOTIFICATION_PARAM_MESSENGER, &messenger);
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);
ASSERT(nodesize == sizeof(node));
}
void
NotificationProcessor::SendNotifications(BMessage *msg)
NotificationManager::SendNotifications(BMessage *msg)
{
}
void
NotificationProcessor::CleanupTeam(team_id team)
NotificationManager::CleanupTeam(team_id team)
{
}
void
NotificationProcessor::BroadcastMessages(BMessage *msg)
NotificationManager::BroadcastMessages(BMessage *msg)
{
}
void
NotificationProcessor::WorkerThread()
NotificationManager::WorkerThread()
{
BMessage *msg;
while (NULL != (msg = static_cast<BMessage *>(fNotificationQueue->RemoveItem()))) {
@ -118,8 +117,8 @@ NotificationProcessor::WorkerThread()
}
int32
NotificationProcessor::worker_thread(void *arg)
NotificationManager::worker_thread(void *arg)
{
static_cast<NotificationProcessor *>(arg)->WorkerThread();
static_cast<NotificationManager *>(arg)->WorkerThread();
return 0;
}

View File

@ -1,11 +1,11 @@
class Queue;
class NotificationProcessor
class NotificationManager
{
public:
NotificationProcessor();
~NotificationProcessor();
NotificationManager();
~NotificationManager();
void EnqueueMessage(BMessage *msg);

View File

@ -4,7 +4,7 @@
#include <MediaDefs.h>
#include <MediaFormats.h>
#include <Autolock.h>
#include "NotificationProcessor.h"
#include "NotificationManager.h"
#include "ServerInterface.h"
#include "DataExchange.h"
#include "BufferManager.h"
@ -107,7 +107,7 @@ private:
port_id control_port;
thread_id control_thread;
NotificationProcessor *fNotificationProcessor;
NotificationManager *fNotificationManager;
BufferManager *fBufferManager;
AppManager *fAppManager;
NodeManager *fNodeManager;
@ -122,7 +122,7 @@ private:
ServerApp::ServerApp()
: BApplication(NEW_MEDIA_SERVER_SIGNATURE),
fNotificationProcessor(new NotificationProcessor),
fNotificationManager(new NotificationManager),
fBufferManager(new BufferManager),
fAppManager(new AppManager),
fNodeManager(new NodeManager),
@ -140,7 +140,7 @@ ServerApp::ServerApp()
ServerApp::~ServerApp()
{
delete fNotificationProcessor;
delete fNotificationManager;
delete fBufferManager;
delete fAppManager;
delete fNodeManager;
@ -548,9 +548,9 @@ void ServerApp::MessageReceived(BMessage *msg)
case MEDIA_SERVER_GET_SHARED_BUFFER_AREA: GetSharedBufferArea(msg); break;
case MEDIA_SERVER_REGISTER_BUFFER: RegisterBuffer(msg); break;
case MEDIA_SERVER_UNREGISTER_BUFFER: UnregisterBuffer(msg); break;
case MEDIA_SERVER_REQUEST_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break;
case MEDIA_SERVER_CANCEL_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break;
case MEDIA_SERVER_SEND_NOTIFICATIONS: fNotificationProcessor->EnqueueMessage(msg); break;
case MEDIA_SERVER_REQUEST_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_CANCEL_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_SEND_NOTIFICATIONS: fNotificationManager->EnqueueMessage(msg); break;
case MEDIA_SERVER_GET_NODE_ID: GetNodeID(msg); break;