* Renamed the xfer_* structures to fit the rest, and let them inherit from the
usual structures. * Also, they now use the QueryServer()/SendToServer() functions instead of duplicating them. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34596 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -640,21 +640,19 @@ struct server_get_codec_info_reply : reply_data {
|
|||||||
// the codec info matching the cookie
|
// the codec info matching the cookie
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfer_server_get_dormant_flavor_info {
|
struct server_get_dormant_flavor_info_request : request_data {
|
||||||
media_addon_id add_on_id;
|
media_addon_id add_on_id;
|
||||||
int32 flavor_id;
|
int32 flavor_id;
|
||||||
port_id reply_port;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfer_server_get_dormant_flavor_info_reply {
|
struct server_get_dormant_flavor_info_reply : reply_data {
|
||||||
status_t result;
|
|
||||||
type_code type; // the flatten type_code
|
type_code type; // the flatten type_code
|
||||||
size_t flattened_size;
|
size_t flattened_size;
|
||||||
char flattened_data[1];
|
char flattened_data[1];
|
||||||
// a flattened dormant_flavor_info, flattened_size large
|
// a flattened dormant_flavor_info, flattened_size large
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfer_server_get_dormant_nodes {
|
struct server_get_dormant_nodes_request : request_data {
|
||||||
int32 max_count;
|
int32 max_count;
|
||||||
bool has_input;
|
bool has_input;
|
||||||
media_format input_format;
|
media_format input_format;
|
||||||
@@ -664,17 +662,15 @@ struct xfer_server_get_dormant_nodes {
|
|||||||
char name[B_MEDIA_NAME_LENGTH + 1]; // 1 for a trailing "*"
|
char name[B_MEDIA_NAME_LENGTH + 1]; // 1 for a trailing "*"
|
||||||
uint64 require_kinds;
|
uint64 require_kinds;
|
||||||
uint64 deny_kinds;
|
uint64 deny_kinds;
|
||||||
port_id reply_port;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfer_server_get_dormant_nodes_reply {
|
struct server_get_dormant_nodes_reply : reply_data {
|
||||||
status_t result;
|
|
||||||
int32 count;
|
int32 count;
|
||||||
// if count > 0, a second reply containing count dormant_node_infos
|
// if count > 0, a second reply containing count dormant_node_infos
|
||||||
// is send
|
// is send
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xfer_server_register_dormant_node {
|
struct server_register_dormant_node_command : command_data {
|
||||||
media_addon_id purge_id;
|
media_addon_id purge_id;
|
||||||
// if > 0, server must first remove all dormant_flavor_infos
|
// if > 0, server must first remove all dormant_flavor_infos
|
||||||
// belonging to that id
|
// belonging to that id
|
||||||
|
|||||||
@@ -2249,65 +2249,50 @@ BMediaRoster::GetDormantNodes(dormant_node_info* _info, int32* _count,
|
|||||||
if (_info == NULL || _count == NULL || *_count <= 0)
|
if (_info == NULL || _count == NULL || *_count <= 0)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
xfer_server_get_dormant_nodes msg;
|
server_get_dormant_nodes_request request;
|
||||||
port_id port;
|
request.max_count = *_count;
|
||||||
status_t rv;
|
request.has_input = hasInput != NULL;
|
||||||
|
|
||||||
port = find_port(MEDIA_SERVER_PORT_NAME);
|
|
||||||
if (port <= B_OK)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
msg.max_count = *_count;
|
|
||||||
msg.has_input = hasInput != NULL;
|
|
||||||
if (hasInput != NULL) {
|
if (hasInput != NULL) {
|
||||||
// TODO: we should not make a flat copy of media_format
|
// TODO: we should not make a flat copy of media_format
|
||||||
msg.input_format = *hasInput;
|
request.input_format = *hasInput;
|
||||||
}
|
}
|
||||||
msg.has_output = hasOutput != NULL;
|
request.has_output = hasOutput != NULL;
|
||||||
if (hasOutput != NULL) {
|
if (hasOutput != NULL) {
|
||||||
// TODO: we should not make a flat copy of media_format
|
// TODO: we should not make a flat copy of media_format
|
||||||
msg.output_format = *hasOutput;
|
request.output_format = *hasOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.has_name = name != NULL;
|
request.has_name = name != NULL;
|
||||||
if (name != NULL) {
|
if (name != NULL)
|
||||||
int len = strlen(name);
|
strlcpy(request.name, name, sizeof(request.name));
|
||||||
len = min_c(len, (int)sizeof(msg.name) - 1);
|
|
||||||
memcpy(msg.name, name, len);
|
|
||||||
msg.name[len] = 0;
|
|
||||||
}
|
|
||||||
msg.require_kinds = requireKinds;
|
|
||||||
msg.deny_kinds = denyKinds;
|
|
||||||
msg.reply_port = gPortPool->GetPort();
|
|
||||||
|
|
||||||
rv = write_port(port, SERVER_GET_DORMANT_NODES, &msg, sizeof(msg));
|
request.require_kinds = requireKinds;
|
||||||
if (rv != B_OK) {
|
request.deny_kinds = denyKinds;
|
||||||
gPortPool->PutPort(msg.reply_port);
|
request.reply_port = gPortPool->GetPort();
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
xfer_server_get_dormant_nodes_reply reply;
|
server_get_dormant_nodes_reply reply;
|
||||||
int32 code;
|
status_t status = QueryServer(SERVER_GET_DORMANT_NODES, &request,
|
||||||
|
sizeof(request), &reply, sizeof(reply));
|
||||||
rv = read_port(msg.reply_port, &code, &reply, sizeof(reply));
|
if (status != B_OK) {
|
||||||
if (rv < B_OK) {
|
gPortPool->PutPort(request.reply_port);
|
||||||
gPortPool->PutPort(msg.reply_port);
|
return status;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*_count = reply.count;
|
*_count = reply.count;
|
||||||
|
|
||||||
if (*_count > 0) {
|
if (reply.count > 0) {
|
||||||
rv = read_port(msg.reply_port, &code, _info,
|
int32 code;
|
||||||
*_count * sizeof(dormant_node_info));
|
status = read_port(request.reply_port, &code, _info,
|
||||||
if (rv < B_OK)
|
reply.count * sizeof(dormant_node_info));
|
||||||
reply.result = rv;
|
if (status < B_OK)
|
||||||
|
reply.result = status;
|
||||||
}
|
}
|
||||||
gPortPool->PutPort(msg.reply_port);
|
gPortPool->PutPort(request.reply_port);
|
||||||
|
|
||||||
return reply.result;
|
return reply.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! This function is used to do the real work of instantiating a dormant node.
|
/*! This function is used to do the real work of instantiating a dormant node.
|
||||||
It is either called by the media_addon_server to instantiate a global node,
|
It is either called by the media_addon_server to instantiate a global node,
|
||||||
or it gets called from BMediaRoster::InstantiateDormantNode() to create a
|
or it gets called from BMediaRoster::InstantiateDormantNode() to create a
|
||||||
@@ -2592,32 +2577,24 @@ BMediaRosterEx::GetDormantFlavorInfo(media_addon_id addonID, int32 flavorID,
|
|||||||
if (_flavor == NULL)
|
if (_flavor == NULL)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
port_id port = find_port(MEDIA_SERVER_PORT_NAME);
|
// TODO: better use an area here as well!
|
||||||
if (port < 0)
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
xfer_server_get_dormant_flavor_info_reply* reply
|
server_get_dormant_flavor_info_reply* reply
|
||||||
= (xfer_server_get_dormant_flavor_info_reply*)malloc(16300);
|
= (server_get_dormant_flavor_info_reply*)malloc(16300);
|
||||||
if (reply == NULL)
|
if (reply == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
xfer_server_get_dormant_flavor_info msg;
|
server_get_dormant_flavor_info_request request;
|
||||||
msg.add_on_id = addonID;
|
request.add_on_id = addonID;
|
||||||
msg.flavor_id = flavorID;
|
request.flavor_id = flavorID;
|
||||||
msg.reply_port = gPortPool->GetPort();
|
request.reply_port = gPortPool->GetPort();
|
||||||
status_t status = write_port(port, SERVER_GET_DORMANT_FLAVOR_INFO, &msg,
|
|
||||||
sizeof(msg));
|
status_t status = QueryServer(SERVER_GET_DORMANT_FLAVOR_INFO, &request,
|
||||||
|
sizeof(request), reply, 16300);
|
||||||
|
|
||||||
|
gPortPool->PutPort(request.reply_port);
|
||||||
|
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
free(reply);
|
|
||||||
gPortPool->PutPort(msg.reply_port);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 code;
|
|
||||||
status = read_port(msg.reply_port, &code, reply, 16000);
|
|
||||||
gPortPool->PutPort(msg.reply_port);
|
|
||||||
|
|
||||||
if (status < B_OK) {
|
|
||||||
free(reply);
|
free(reply);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -600,14 +600,14 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
|||||||
|
|
||||||
case SERVER_REGISTER_DORMANT_NODE:
|
case SERVER_REGISTER_DORMANT_NODE:
|
||||||
{
|
{
|
||||||
xfer_server_register_dormant_node& request
|
server_register_dormant_node_command& command
|
||||||
= *static_cast<xfer_server_register_dormant_node*>(data);
|
= *static_cast<server_register_dormant_node_command*>(data);
|
||||||
if (request.purge_id > 0)
|
if (command.purge_id > 0)
|
||||||
gNodeManager->InvalidateDormantFlavorInfo(request.purge_id);
|
gNodeManager->InvalidateDormantFlavorInfo(command.purge_id);
|
||||||
|
|
||||||
dormant_flavor_info dormantFlavorInfo;
|
dormant_flavor_info dormantFlavorInfo;
|
||||||
status_t status = dormantFlavorInfo.Unflatten(request.type,
|
status_t status = dormantFlavorInfo.Unflatten(command.type,
|
||||||
request.flattened_data, request.flattened_size);
|
command.flattened_data, command.flattened_size);
|
||||||
if (status == B_OK)
|
if (status == B_OK)
|
||||||
gNodeManager->AddDormantFlavorInfo(dormantFlavorInfo);
|
gNodeManager->AddDormantFlavorInfo(dormantFlavorInfo);
|
||||||
break;
|
break;
|
||||||
@@ -615,10 +615,10 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
|||||||
|
|
||||||
case SERVER_GET_DORMANT_NODES:
|
case SERVER_GET_DORMANT_NODES:
|
||||||
{
|
{
|
||||||
xfer_server_get_dormant_nodes& request
|
server_get_dormant_nodes_request& request
|
||||||
= *static_cast<xfer_server_get_dormant_nodes*>(data);
|
= *static_cast<server_get_dormant_nodes_request*>(data);
|
||||||
|
|
||||||
xfer_server_get_dormant_nodes_reply reply;
|
server_get_dormant_nodes_reply reply;
|
||||||
reply.count = request.max_count;
|
reply.count = request.max_count;
|
||||||
|
|
||||||
dormant_node_info* infos
|
dormant_node_info* infos
|
||||||
@@ -635,7 +635,8 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
|||||||
|
|
||||||
if (reply.result != B_OK)
|
if (reply.result != B_OK)
|
||||||
reply.count = 0;
|
reply.count = 0;
|
||||||
write_port(request.reply_port, 0, &reply, sizeof(reply));
|
|
||||||
|
request.SendReply(reply.result, &reply, sizeof(reply));
|
||||||
if (reply.count > 0) {
|
if (reply.count > 0) {
|
||||||
write_port(request.reply_port, 0, infos,
|
write_port(request.reply_port, 0, infos,
|
||||||
reply.count * sizeof(dormant_node_info));
|
reply.count * sizeof(dormant_node_info));
|
||||||
@@ -646,22 +647,22 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
|||||||
|
|
||||||
case SERVER_GET_DORMANT_FLAVOR_INFO:
|
case SERVER_GET_DORMANT_FLAVOR_INFO:
|
||||||
{
|
{
|
||||||
xfer_server_get_dormant_flavor_info& request
|
server_get_dormant_flavor_info_request& request
|
||||||
= *static_cast<xfer_server_get_dormant_flavor_info*>(data);
|
= *static_cast<server_get_dormant_flavor_info_request*>(data);
|
||||||
dormant_flavor_info dormantFlavorInfo;
|
dormant_flavor_info dormantFlavorInfo;
|
||||||
|
|
||||||
status_t status = gNodeManager->GetDormantFlavorInfoFor(
|
status_t status = gNodeManager->GetDormantFlavorInfoFor(
|
||||||
request.add_on_id, request.flavor_id, &dormantFlavorInfo);
|
request.add_on_id, request.flavor_id, &dormantFlavorInfo);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
xfer_server_get_dormant_flavor_info_reply reply;
|
server_get_dormant_flavor_info_reply reply;
|
||||||
reply.result = status;
|
reply.result = status;
|
||||||
write_port(request.reply_port, 0, &reply, sizeof(reply));
|
request.SendReply(reply.result, &reply, sizeof(reply));
|
||||||
} else {
|
} else {
|
||||||
size_t replySize
|
size_t replySize
|
||||||
= sizeof(xfer_server_get_dormant_flavor_info_reply)
|
= sizeof(server_get_dormant_flavor_info_reply)
|
||||||
+ dormantFlavorInfo.FlattenedSize();
|
+ dormantFlavorInfo.FlattenedSize();
|
||||||
xfer_server_get_dormant_flavor_info_reply* reply
|
server_get_dormant_flavor_info_reply* reply
|
||||||
= (xfer_server_get_dormant_flavor_info_reply*)malloc(
|
= (server_get_dormant_flavor_info_reply*)malloc(
|
||||||
replySize);
|
replySize);
|
||||||
if (reply != NULL) {
|
if (reply != NULL) {
|
||||||
reply->type = dormantFlavorInfo.TypeCode();
|
reply->type = dormantFlavorInfo.TypeCode();
|
||||||
@@ -669,12 +670,12 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
|||||||
reply->result = dormantFlavorInfo.Flatten(
|
reply->result = dormantFlavorInfo.Flatten(
|
||||||
reply->flattened_data, reply->flattened_size);
|
reply->flattened_data, reply->flattened_size);
|
||||||
|
|
||||||
write_port(request.reply_port, 0, reply, replySize);
|
request.SendReply(reply->result, reply, replySize);
|
||||||
free(reply);
|
free(reply);
|
||||||
} else {
|
} else {
|
||||||
xfer_server_get_dormant_flavor_info_reply reply;
|
server_get_dormant_flavor_info_reply reply;
|
||||||
reply.result = B_NO_MEMORY;
|
reply.result = B_NO_MEMORY;
|
||||||
write_port(request.reply_port, 0, &reply, sizeof(reply));
|
request.SendReply(reply.result, &reply, sizeof(reply));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -451,12 +451,6 @@ MediaAddonServer::_ScanAddOnFlavors(BMediaAddOn* addon)
|
|||||||
|
|
||||||
TRACE("MediaAddonServer::_ScanAddOnFlavors: id %ld\n", addon->AddonID());
|
TRACE("MediaAddonServer::_ScanAddOnFlavors: id %ld\n", addon->AddonID());
|
||||||
|
|
||||||
port_id port = find_port(MEDIA_SERVER_PORT_NAME);
|
|
||||||
if (port <= B_OK) {
|
|
||||||
ERROR("couldn't find media_server port\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// cache the media_addon_id in a local variable to avoid
|
// cache the media_addon_id in a local variable to avoid
|
||||||
// calling BMediaAddOn::AddonID() too often
|
// calling BMediaAddOn::AddonID() too often
|
||||||
media_addon_id addonID = addon->AddonID();
|
media_addon_id addonID = addon->AddonID();
|
||||||
@@ -496,9 +490,9 @@ MediaAddonServer::_ScanAddOnFlavors(BMediaAddOn* addon)
|
|||||||
|
|
||||||
size_t flattenedSize = dormantFlavorInfo.FlattenedSize();
|
size_t flattenedSize = dormantFlavorInfo.FlattenedSize();
|
||||||
size_t messageSize = flattenedSize
|
size_t messageSize = flattenedSize
|
||||||
+ sizeof(xfer_server_register_dormant_node);
|
+ sizeof(server_register_dormant_node_command);
|
||||||
xfer_server_register_dormant_node* message
|
server_register_dormant_node_command* message
|
||||||
= (xfer_server_register_dormant_node*)malloc(messageSize);
|
= (server_register_dormant_node_command*)malloc(messageSize);
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -511,7 +505,7 @@ MediaAddonServer::_ScanAddOnFlavors(BMediaAddOn* addon)
|
|||||||
message->flattened_size = flattenedSize;
|
message->flattened_size = flattenedSize;
|
||||||
dormantFlavorInfo.Flatten(message->flattened_data, flattenedSize);
|
dormantFlavorInfo.Flatten(message->flattened_data, flattenedSize);
|
||||||
|
|
||||||
status_t status = write_port(port, SERVER_REGISTER_DORMANT_NODE,
|
status_t status = SendToServer(SERVER_REGISTER_DORMANT_NODE,
|
||||||
message, messageSize);
|
message, messageSize);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
ERROR("MediaAddonServer::_ScanAddOnFlavors: couldn't register "
|
ERROR("MediaAddonServer::_ScanAddOnFlavors: couldn't register "
|
||||||
|
|||||||
Reference in New Issue
Block a user