some more changes to the notification support. still not finished.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@938 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -837,7 +837,8 @@ BMediaRoster::StartWatching(const BMessenger & where)
|
|||||||
TRACE("BMediaRoster::StartWatching: messenger invalid!\n");
|
TRACE("BMediaRoster::StartWatching: messenger invalid!\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
return _NotificationManager->Register(where, media_node::null, B_MEDIA_WILDCARD);
|
return _NotificationManager->Register(where, media_node::null,
|
||||||
|
BPrivate::media::NotificationManager::notification_basic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -854,7 +855,8 @@ BMediaRoster::StartWatching(const BMessenger & where,
|
|||||||
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
|
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
return _NotificationManager->Register(where, media_node::null, notificationType);
|
return _NotificationManager->Register(where, media_node::null,
|
||||||
|
BPrivate::media::NotificationManager::NotificationType2Mask(notificationType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -876,7 +878,8 @@ BMediaRoster::StartWatching(const BMessenger & where,
|
|||||||
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
|
TRACE("BMediaRoster::StartWatching: notificationType invalid!\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
return _NotificationManager->Register(where, node, notificationType);
|
return _NotificationManager->Register(where, node,
|
||||||
|
BPrivate::media::NotificationManager::NotificationType2Mask(notificationType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -885,7 +888,8 @@ BMediaRoster::StopWatching(const BMessenger & where)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
// messenger may already be invalid, so we don't check this
|
// messenger may already be invalid, so we don't check this
|
||||||
return _NotificationManager->Unregister(where, media_node::null, B_MEDIA_WILDCARD);
|
return _NotificationManager->Unregister(where, media_node::null,
|
||||||
|
BPrivate::media::NotificationManager::notification_basic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -899,7 +903,8 @@ BMediaRoster::StopWatching(const BMessenger & where,
|
|||||||
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
|
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
return _NotificationManager->Unregister(where, media_node::null, notificationType);
|
return _NotificationManager->Unregister(where, media_node::null,
|
||||||
|
BPrivate::media::NotificationManager::NotificationType2Mask(notificationType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -918,7 +923,8 @@ BMediaRoster::StopWatching(const BMessenger & where,
|
|||||||
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
|
TRACE("BMediaRoster::StopWatching: notificationType invalid!\n");
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
}
|
}
|
||||||
return _NotificationManager->Unregister(where, node, notificationType);
|
return _NotificationManager->Unregister(where, node,
|
||||||
|
BPrivate::media::NotificationManager::NotificationType2Mask(notificationType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,21 +35,19 @@ NotificationManager::~NotificationManager()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
NotificationManager::Register(const BMessenger ¬ifyHandler, const media_node &node, int32 notificationType)
|
NotificationManager::Register(const BMessenger ¬ifyHandler, const media_node &node, notification_type_mask mask)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
|
||||||
BMessage msg(MEDIA_SERVER_REQUEST_NOTIFICATIONS);
|
BMessage msg(MEDIA_SERVER_REQUEST_NOTIFICATIONS);
|
||||||
|
|
||||||
return SendMessageToMediaServer(&msg);
|
return SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
NotificationManager::Unregister(const BMessenger ¬ifyHandler, const media_node &node, int32 notificationType)
|
NotificationManager::Unregister(const BMessenger ¬ifyHandler, const media_node &node, notification_type_mask mask)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
BMessage msg(MEDIA_SERVER_CANCEL_NOTIFICATIONS);
|
BMessage msg(MEDIA_SERVER_CANCEL_NOTIFICATIONS);
|
||||||
|
|
||||||
return SendMessageToMediaServer(&msg);
|
return SendMessageToMediaServer(&msg);
|
||||||
@@ -82,8 +80,9 @@ NotificationManager::ReportError(const media_node &node, BMediaNode::node_error
|
|||||||
BMessage msg;
|
BMessage msg;
|
||||||
if (info)
|
if (info)
|
||||||
msg = *info;
|
msg = *info;
|
||||||
msg.what = what;
|
msg.what = MEDIA_SERVER_SEND_NOTIFICATIONS;
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, what);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, notification_error);
|
||||||
return SendMessageToMediaServer(&msg);
|
return SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +91,9 @@ void
|
|||||||
NotificationManager::NodesCreated(const media_node_id *ids, int32 count)
|
NotificationManager::NodesCreated(const media_node_id *ids, int32 count)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_NODE_CREATED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_NODE_CREATED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_NODE_CREATED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -102,7 +103,9 @@ void
|
|||||||
NotificationManager::NodesDeleted(const media_node_id *ids, int32 count)
|
NotificationManager::NodesDeleted(const media_node_id *ids, int32 count)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_NODE_DELETED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_NODE_DELETED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_NODE_DELETED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -112,7 +115,9 @@ void
|
|||||||
NotificationManager::ConnectionMade(const media_input &input, const media_output &output, const media_format &format)
|
NotificationManager::ConnectionMade(const media_input &input, const media_output &output, const media_format &format)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_CONNECTION_MADE);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_CONNECTION_MADE);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_CONNECTION_MADE));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -122,7 +127,9 @@ void
|
|||||||
NotificationManager::ConnectionBroken(const media_source &source, const media_destination &destination)
|
NotificationManager::ConnectionBroken(const media_source &source, const media_destination &destination)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_CONNECTION_BROKEN);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_CONNECTION_BROKEN);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_CONNECTION_BROKEN));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -132,7 +139,9 @@ void
|
|||||||
NotificationManager::BuffersCreated() // XXX fix
|
NotificationManager::BuffersCreated() // XXX fix
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_BUFFER_CREATED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_BUFFER_CREATED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_BUFFER_CREATED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -142,7 +151,9 @@ void
|
|||||||
NotificationManager::BuffersDeleted(const media_buffer_id *ids, int32 count)
|
NotificationManager::BuffersDeleted(const media_buffer_id *ids, int32 count)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_BUFFER_DELETED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_BUFFER_DELETED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_BUFFER_DELETED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -152,7 +163,9 @@ void
|
|||||||
NotificationManager::FormatChanged(const media_source &source, const media_destination &destination, const media_format &format)
|
NotificationManager::FormatChanged(const media_source &source, const media_destination &destination, const media_format &format)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_FORMAT_CHANGED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_FORMAT_CHANGED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_FORMAT_CHANGED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -162,9 +175,11 @@ status_t
|
|||||||
NotificationManager::ParameterChanged(const media_node &node, int32 parameterid)
|
NotificationManager::ParameterChanged(const media_node &node, int32 parameterid)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_PARAMETER_CHANGED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_PARAMETER_CHANGED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_PARAMETER_CHANGED));
|
||||||
|
|
||||||
return B_OK;
|
return SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,8 +187,11 @@ void
|
|||||||
NotificationManager::WebChanged(const media_node &node) // XXX fix
|
NotificationManager::WebChanged(const media_node &node) // XXX fix
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_WEB_CHANGED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_WEB_CHANGED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_WEB_CHANGED));
|
||||||
|
|
||||||
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,7 +199,9 @@ status_t
|
|||||||
NotificationManager::NewParameterValue(const media_node &node, int32 parameterid, bigtime_t when, const void *param, size_t paramsize)
|
NotificationManager::NewParameterValue(const media_node &node, int32 parameterid, bigtime_t when, const void *param, size_t paramsize)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_NEW_PARAMETER_VALUE);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_NEW_PARAMETER_VALUE);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_NEW_PARAMETER_VALUE));
|
||||||
|
|
||||||
return SendMessageToMediaServer(&msg);
|
return SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -191,7 +211,9 @@ void
|
|||||||
NotificationManager::FlavorsChanged(media_addon_id addonis, int32 newcount, int32 gonecount)
|
NotificationManager::FlavorsChanged(media_addon_id addonis, int32 newcount, int32 gonecount)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_FLAVORS_CHANGED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_FLAVORS_CHANGED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_FLAVORS_CHANGED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -200,7 +222,9 @@ void
|
|||||||
NotificationManager::NodeStopped(const media_node &node, bigtime_t when) // XXX fix
|
NotificationManager::NodeStopped(const media_node &node, bigtime_t when) // XXX fix
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BMessage msg(B_MEDIA_NODE_STOPPED);
|
BMessage msg(MEDIA_SERVER_SEND_NOTIFICATIONS);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_WHAT, B_MEDIA_NODE_STOPPED);
|
||||||
|
msg.AddInt32(NOTIFICATION_PARAM_MASK, NotificationType2Mask(B_MEDIA_NODE_STOPPED));
|
||||||
|
|
||||||
SendMessageToMediaServer(&msg);
|
SendMessageToMediaServer(&msg);
|
||||||
}
|
}
|
||||||
@@ -208,7 +232,7 @@ NotificationManager::NodeStopped(const media_node &node, bigtime_t when) // XXX
|
|||||||
status_t
|
status_t
|
||||||
NotificationManager::SendMessageToMediaServer(BMessage *msg)
|
NotificationManager::SendMessageToMediaServer(BMessage *msg)
|
||||||
{
|
{
|
||||||
#define TIMEOUT 1000000
|
#define TIMEOUT 100000
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
status_t rv;
|
status_t rv;
|
||||||
if (!fMessenger->IsValid()) {
|
if (!fMessenger->IsValid()) {
|
||||||
@@ -236,6 +260,8 @@ NotificationManager::IsValidNotificationType(int32 notificationType)
|
|||||||
case BMediaNode::B_NODE_FAILED_PREROLL:
|
case BMediaNode::B_NODE_FAILED_PREROLL:
|
||||||
case BMediaNode::B_NODE_FAILED_SET_TIME_SOURCE_FOR:
|
case BMediaNode::B_NODE_FAILED_SET_TIME_SOURCE_FOR:
|
||||||
case BMediaNode::B_NODE_IN_DISTRESS:
|
case BMediaNode::B_NODE_IN_DISTRESS:
|
||||||
|
debugger("NotificationManager::IsValidNotificationType, encountered BMediaNode Error otification\n");
|
||||||
|
return false; // XXX we consider registering for this notifications as impossible, you always get them anyway
|
||||||
case B_MEDIA_WILDCARD:
|
case B_MEDIA_WILDCARD:
|
||||||
case B_MEDIA_NODE_CREATED:
|
case B_MEDIA_NODE_CREATED:
|
||||||
case B_MEDIA_NODE_DELETED:
|
case B_MEDIA_NODE_DELETED:
|
||||||
@@ -257,5 +283,54 @@ NotificationManager::IsValidNotificationType(int32 notificationType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NotificationManager::notification_type_mask
|
||||||
|
NotificationManager::NotificationType2Mask(int32 notificationType)
|
||||||
|
{
|
||||||
|
switch (notificationType) {
|
||||||
|
case BMediaNode::B_NODE_FAILED_START:
|
||||||
|
case BMediaNode::B_NODE_FAILED_STOP:
|
||||||
|
case BMediaNode::B_NODE_FAILED_SEEK:
|
||||||
|
case BMediaNode::B_NODE_FAILED_SET_RUN_MODE:
|
||||||
|
case BMediaNode::B_NODE_FAILED_TIME_WARP:
|
||||||
|
case BMediaNode::B_NODE_FAILED_PREROLL:
|
||||||
|
case BMediaNode::B_NODE_FAILED_SET_TIME_SOURCE_FOR:
|
||||||
|
case BMediaNode::B_NODE_IN_DISTRESS:
|
||||||
|
return notification_error;
|
||||||
|
case B_MEDIA_WILDCARD:
|
||||||
|
return notification_wildcard;
|
||||||
|
case B_MEDIA_NODE_CREATED:
|
||||||
|
return notification_node_created;
|
||||||
|
case B_MEDIA_NODE_DELETED:
|
||||||
|
return notification_node_deleted;
|
||||||
|
case B_MEDIA_CONNECTION_MADE:
|
||||||
|
return notification_connection_made;
|
||||||
|
case B_MEDIA_CONNECTION_BROKEN:
|
||||||
|
return notification_connection_broken;
|
||||||
|
case B_MEDIA_BUFFER_CREATED:
|
||||||
|
return notification_buffer_created;
|
||||||
|
case B_MEDIA_BUFFER_DELETED:
|
||||||
|
return notification_buffer_deleted;
|
||||||
|
case B_MEDIA_TRANSPORT_STATE:
|
||||||
|
return notification_transport_state;
|
||||||
|
case B_MEDIA_PARAMETER_CHANGED:
|
||||||
|
return notification_parameter_changed;
|
||||||
|
case B_MEDIA_FORMAT_CHANGED:
|
||||||
|
return notification_format_change;
|
||||||
|
case B_MEDIA_WEB_CHANGED:
|
||||||
|
return notification_web_changed;
|
||||||
|
case B_MEDIA_DEFAULT_CHANGED:
|
||||||
|
return notification_default_changed;
|
||||||
|
case B_MEDIA_NEW_PARAMETER_VALUE:
|
||||||
|
return notification_new_parameter_value;
|
||||||
|
case B_MEDIA_NODE_STOPPED:
|
||||||
|
return notification_node_stopped;
|
||||||
|
case B_MEDIA_FLAVORS_CHANGED:
|
||||||
|
return notification_flavors_changed;
|
||||||
|
default:
|
||||||
|
return notification_no_mask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}; // namespace media
|
}; // namespace media
|
||||||
}; // namespace BPrivate
|
}; // namespace BPrivate
|
||||||
|
|||||||
Reference in New Issue
Block a user