Implement BMediaRoster::GetNodeAttributesFor
This commit is contained in:
@@ -93,6 +93,7 @@ enum {
|
|||||||
NODE_SYNC_TO,
|
NODE_SYNC_TO,
|
||||||
NODE_SET_TIMESOURCE,
|
NODE_SET_TIMESOURCE,
|
||||||
NODE_GET_TIMESOURCE,
|
NODE_GET_TIMESOURCE,
|
||||||
|
NODE_GET_ATTRIBUTES_FOR,
|
||||||
NODE_REQUEST_COMPLETED,
|
NODE_REQUEST_COMPLETED,
|
||||||
NODE_FINAL_RELEASE,
|
NODE_FINAL_RELEASE,
|
||||||
NODE_MESSAGE_END,
|
NODE_MESSAGE_END,
|
||||||
@@ -946,6 +947,15 @@ struct node_get_timesource_reply : reply_data {
|
|||||||
media_node_id timesource_id;
|
media_node_id timesource_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct node_get_attributes_for_request : request_data {
|
||||||
|
size_t count;
|
||||||
|
area_id area;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct node_get_attributes_for_reply : reply_data {
|
||||||
|
size_t filled_count;
|
||||||
|
};
|
||||||
|
|
||||||
struct node_final_release_command : command_data {
|
struct node_final_release_command : command_data {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <FileInterface.h>
|
#include <FileInterface.h>
|
||||||
#include <MediaRoster.h>
|
#include <MediaRoster.h>
|
||||||
#include <MediaNode.h>
|
#include <MediaNode.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
#include <TimeSource.h>
|
#include <TimeSource.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -707,6 +708,42 @@ BMediaNode::HandleMessage(int32 message, const void* data, size_t size)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case NODE_GET_ATTRIBUTES_FOR:
|
||||||
|
{
|
||||||
|
const node_get_attributes_for_request *request =
|
||||||
|
(const node_get_attributes_for_request*) data;
|
||||||
|
|
||||||
|
TRACE("BMediaNode::HandleMessage NODE_GET_ATTRIBUTES_FOR,"
|
||||||
|
"node %ld\n", fNodeID);
|
||||||
|
|
||||||
|
node_get_attributes_for_reply reply;
|
||||||
|
|
||||||
|
media_node_attribute* addr;
|
||||||
|
area_id dataArea = clone_area("client attributes area",
|
||||||
|
(void**)&addr, B_ANY_ADDRESS, B_WRITE_AREA,
|
||||||
|
request->area);
|
||||||
|
|
||||||
|
if (dataArea < 0) {
|
||||||
|
ERROR("NODE_GET_ATTRIBUTES_FOR can't clone area\n");
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
status_t status = GetNodeAttributes(addr, request->count);
|
||||||
|
if (status == B_OK) {
|
||||||
|
// NOTE: we do it because there's not an easy way
|
||||||
|
// to guess the number of attributes filled.
|
||||||
|
size_t i;
|
||||||
|
for (i = 0; i < request->count; i++) {
|
||||||
|
if (addr[i].what <= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
reply.filled_count = i;
|
||||||
|
}
|
||||||
|
request->SendReply(status, &reply, sizeof(reply));
|
||||||
|
delete_area(dataArea);
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
case NODE_REQUEST_COMPLETED:
|
case NODE_REQUEST_COMPLETED:
|
||||||
{
|
{
|
||||||
const node_request_completed_command* command
|
const node_request_completed_command* command
|
||||||
@@ -831,7 +868,7 @@ BMediaNode::GetNodeAttributes(media_node_attribute* outAttributes,
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
// This is implemented by derived classes that fills
|
// This is implemented by derived classes that fills
|
||||||
// it's own attributes to a max of inMaxCount size.
|
// it's own attributes to a max of inMaxCount elements.
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3123,8 +3123,41 @@ ssize_t
|
|||||||
BMediaRoster::GetNodeAttributesFor(const media_node& node,
|
BMediaRoster::GetNodeAttributesFor(const media_node& node,
|
||||||
media_node_attribute* _array, size_t maxCount)
|
media_node_attribute* _array, size_t maxCount)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
CALLED();
|
||||||
return B_ERROR;
|
|
||||||
|
if (IS_INVALID_NODE(node))
|
||||||
|
return B_MEDIA_BAD_NODE;
|
||||||
|
|
||||||
|
node_get_attributes_for_request request;
|
||||||
|
node_get_attributes_for_reply reply;
|
||||||
|
status_t status;
|
||||||
|
|
||||||
|
media_node_attribute* addr = NULL;
|
||||||
|
size_t totalSize = maxCount*sizeof(media_node_attribute);
|
||||||
|
size_t size = (totalSize + (B_PAGE_SIZE - 1)) & ~(B_PAGE_SIZE - 1);
|
||||||
|
|
||||||
|
area_id dataArea = create_area("attributes area", (void**)&addr,
|
||||||
|
B_ANY_ADDRESS, size, B_NO_LOCK,
|
||||||
|
B_READ_AREA | B_WRITE_AREA);
|
||||||
|
// No need to memset the padding
|
||||||
|
memset(addr, 0, totalSize);
|
||||||
|
|
||||||
|
if (dataArea < 0)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
request.count = maxCount;
|
||||||
|
request.area = dataArea;
|
||||||
|
|
||||||
|
status = QueryPort(node.port, NODE_GET_ATTRIBUTES_FOR, &request,
|
||||||
|
sizeof(request), &reply, sizeof(reply));
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
memcpy(_array, addr, reply.filled_count
|
||||||
|
* sizeof(media_node_attribute));
|
||||||
|
|
||||||
|
delete_area(dataArea);
|
||||||
|
return reply.filled_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user