Implement BMediaRoster::SyncToNode
This commit is contained in:
@@ -90,6 +90,7 @@ enum {
|
||||
NODE_TIME_WARP,
|
||||
NODE_PREROLL,
|
||||
NODE_ROLL,
|
||||
NODE_SYNC_TO,
|
||||
NODE_SET_TIMESOURCE,
|
||||
NODE_GET_TIMESOURCE,
|
||||
NODE_REQUEST_COMPLETED,
|
||||
@@ -916,6 +917,14 @@ struct node_roll_command : command_data {
|
||||
bigtime_t seek_media_time;
|
||||
};
|
||||
|
||||
struct node_sync_to_request : request_data {
|
||||
bigtime_t performance_time;
|
||||
port_id port;
|
||||
};
|
||||
|
||||
struct node_sync_to_reply : reply_data {
|
||||
};
|
||||
|
||||
struct node_set_run_mode_command : command_data {
|
||||
BMediaNode::run_mode mode;
|
||||
};
|
||||
|
||||
@@ -157,8 +157,12 @@ BMediaEventLooper::AddTimer(bigtime_t at_performance_time,
|
||||
int32 cookie)
|
||||
{
|
||||
CALLED();
|
||||
// XXX what do we need to do here?
|
||||
return BMediaNode::AddTimer(at_performance_time,cookie);
|
||||
|
||||
media_timed_event event(at_performance_time,
|
||||
BTimedEventQueue::B_TIMER, NULL,
|
||||
BTimedEventQueue::B_EXPIRE_TIMER);
|
||||
event.data = cookie;
|
||||
return EventQueue()->AddEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -477,6 +481,10 @@ BMediaEventLooper::DispatchEvent(const media_timed_event *event,
|
||||
/* nothing */
|
||||
break;
|
||||
|
||||
case BTimedEventQueue::B_TIMER:
|
||||
TimerExpired(event->event_time, event->data);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Dario Casalinuovo
|
||||
* Copyright (c) 2002, 2003 Marcus Overhagen <[email protected]>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
@@ -327,16 +328,21 @@ BMediaNode::NodeStopped(bigtime_t whenPerformance)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Used in couple with AddTimer, this will cause the BMediaRoster::SyncToNode()
|
||||
* call that requested the timer to return to the caller with an appropriate
|
||||
* value.
|
||||
*/
|
||||
void
|
||||
BMediaNode::TimerExpired(bigtime_t notifyPoint,
|
||||
int32 cookie,
|
||||
status_t error)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
// Used with AddTimer
|
||||
// This will, in turn, cause the BMediaRoster::SyncToNode() call
|
||||
// that instigated the timer to return to the caller.
|
||||
// Probably only important to classes derived from BTimeSource.
|
||||
CALLED();
|
||||
if (write_port((port_id)cookie, 0, &error, sizeof(error)) < 0) {
|
||||
TRACE("BMediaNode::TimerExpired: error writing port" B_PRId32
|
||||
", at notifyPoint" B_PRId64 "\n", cookie, notifyPoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -649,6 +655,26 @@ BMediaNode::HandleMessage(int32 message,
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
case NODE_SYNC_TO:
|
||||
{
|
||||
const node_sync_to_request *request
|
||||
= static_cast<const node_sync_to_request *>(data);
|
||||
node_sync_to_reply reply;
|
||||
|
||||
TRACE("BMediaNode::HandleMessage NODE_SYNC_TO, node %ld\n",
|
||||
fNodeID);
|
||||
|
||||
// If AddTimer return an error the caller will know that the node
|
||||
// doesn't support this feature or there was a problem when adding
|
||||
// it, this will result in SyncToNode returning immediately
|
||||
// to the caller with an error.
|
||||
status_t status = AddTimer(request->performance_time,
|
||||
request->port);
|
||||
|
||||
request->SendReply(status, &reply, sizeof(reply));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
case NODE_SET_TIMESOURCE:
|
||||
{
|
||||
const node_set_timesource_command *command = static_cast<const node_set_timesource_command *>(data);
|
||||
@@ -878,8 +904,7 @@ BMediaNode::GetNodeAttributes(media_node_attribute *outAttributes,
|
||||
BMediaNode::AddTimer(bigtime_t at_performance_time,
|
||||
int32 cookie)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
|
||||
CALLED();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1365,8 +1365,32 @@ status_t
|
||||
BMediaRoster::SyncToNode(const media_node& node, bigtime_t atTime,
|
||||
bigtime_t timeout)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return B_OK;
|
||||
TRACE("BMediaRoster::SyncToNode, node %" B_PRId32 ", at real %" B_PRId64
|
||||
", at timeout %" B_PRId64 "\n", node.node, atTime, timeout);
|
||||
if (IS_INVALID_NODE(node))
|
||||
return B_MEDIA_BAD_NODE;
|
||||
|
||||
port_id waitPort = create_port(1, "SyncToNode wait port");
|
||||
if (waitPort < B_OK)
|
||||
return waitPort;
|
||||
|
||||
node_sync_to_request request;
|
||||
node_sync_to_reply reply;
|
||||
request.performance_time = atTime;
|
||||
request.port = waitPort;
|
||||
|
||||
status_t status = QueryPort(node.port, NODE_SYNC_TO, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
|
||||
if (status == B_OK) {
|
||||
ssize_t readSize = read_port_etc(waitPort, NULL, &status,
|
||||
sizeof(status), B_TIMEOUT, timeout);
|
||||
if (readSize < 0)
|
||||
status = readSize;
|
||||
}
|
||||
close_port(waitPort);
|
||||
delete_port(waitPort);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user