code cleanup

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1833 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper 2002-11-03 16:03:23 +00:00
parent c852811405
commit dfb2ad6148
13 changed files with 651 additions and 596 deletions

View File

@ -17,21 +17,22 @@ namespace dataexchange {
struct reply_data;
struct request_data;
struct command_data;
// BMessage based data exchange with the media_server
status_t SendToServer(BMessage *msg);
status_t QueryServer(BMessage *request, BMessage *reply);
// Raw data based data exchange with the media_server
status_t SendToServer(int32 msgcode, void *msg, int size);
status_t SendToServer(int32 msgcode, command_data *msg, int size);
status_t QueryServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
// Raw data based data exchange with the media_addon_server
status_t SendToAddonServer(int32 msgcode, void *msg, int size);
status_t SendToAddonServer(int32 msgcode, command_data *msg, int size);
status_t QueryAddonServer(int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
// Raw data based data exchange with the media_server
status_t SendToPort(port_id sendport, int32 msgcode, void *msg, int size);
status_t SendToPort(port_id sendport, int32 msgcode, command_data *msg, int size);
status_t QueryPort(port_id requestport, int32 msgcode, request_data *request, int requestsize, reply_data *reply, int replysize);
// The base struct used for all raw requests
@ -48,6 +49,11 @@ struct reply_data
status_t result;
};
// The base struct used for all raw commands (asynchronous, no answer)
struct command_data
{
// yes, it's empty ;)
};
}; // dataexchange
}; // media
@ -140,6 +146,39 @@ enum {
TIMESOURECE_MESSAGE_END,
};
/* We can't send an entry_ref through a port to another team,
* but we can assign it to an xfer_entry_ref and send this one,
* when we receive it we can assign it to a normal entry_ref
*/
struct xfer_entry_ref
{
public:
xfer_entry_ref()
{
device = -1;
directory = -1;
name[0] = 0;
}
operator entry_ref() const
{
entry_ref ref(device, directory, name);
return ref;
}
void operator=(const entry_ref &ref)
{
device = ref.device;
directory = ref.directory;
strcpy(name, ref.name);
}
private:
dev_t device;
ino_t directory;
char name[B_FILE_NAME_LENGTH];
};
// used by SERVER_GET_NODE and SERVER_SET_NODE
enum node_type
{
@ -251,6 +290,165 @@ struct producer_connect_reply : public reply_data
{
char name[B_MEDIA_NAME_LENGTH];
};
struct producer_disconnect_request : public request_data
{
media_source source;
media_destination destination;
};
struct producer_disconnect_reply : public reply_data
{
};
struct producer_format_suggestion_requested_request : public request_data
{
media_type type;
int32 quality;
};
struct producer_format_suggestion_requested_reply : public reply_data
{
media_format format;
};
struct producer_set_play_rate_request : public request_data
{
int32 numer;
int32 denom;
};
struct producer_set_play_rate_reply : public reply_data
{
};
struct producer_get_initial_latency_request : public request_data
{
};
struct producer_get_initial_latency_reply : public reply_data
{
bigtime_t initial_latency;
uint32 flags;
};
struct producer_get_latency_request : public request_data
{
};
struct producer_get_latency_reply : public reply_data
{
bigtime_t latency;
};
struct producer_set_buffer_group_command : public command_data
{
media_source source;
media_destination destination;
void *user_data;
int32 change_tag;
int32 buffer_count;
media_buffer_id buffers[1];
};
struct producer_format_change_requested_command : public command_data
{
media_source source;
media_destination destination;
media_format format;
void *user_data;
int32 change_tag;
};
struct producer_video_clipping_changed_command : public command_data
{
media_source source;
media_destination destination;
media_video_display_info display;
void *user_data;
int32 change_tag;
int32 short_count;
int16 shorts[1];
};
struct producer_additional_buffer_requested_command : public command_data
{
media_source source;
media_buffer_id prev_buffer;
bigtime_t prev_time;
bool has_seek_tag;
media_seek_tag prev_tag;
};
struct producer_latency_changed_command : public command_data
{
media_source source;
media_destination destination;
bigtime_t latency;
uint32 flags;
};
struct producer_enable_output_command : public command_data
{
media_source source;
media_destination destination;
bool enabled;
void *user_data;
int32 change_tag;
};
struct producer_late_notice_received_command : public command_data
{
media_source source;
bigtime_t how_much;
bigtime_t performance_time;
};
struct consumer_accept_format_request : public request_data
{
@ -353,16 +551,88 @@ struct consumer_disconnected_reply : public reply_data
{
};
struct producer_disconnect_request : public request_data
struct consumer_buffer_received_command : public command_data
{
media_source source;
media_destination destination;
media_buffer_id buffer;
media_header header;
};
struct producer_disconnect_reply : public reply_data
struct consumer_producer_data_status_command : public command_data
{
media_destination for_whom;
int32 status;
bigtime_t at_performance_time;
};
struct consumer_get_latency_for_request : public request_data
{
media_destination for_whom;
};
struct consumer_get_latency_for_reply : public reply_data
{
bigtime_t latency;
media_node_id timesource;
};
struct consumer_format_changed_request : public request_data
{
media_source producer;
media_destination consumer;
int32 change_tag;
media_format format;
};
struct consumer_format_changed_reply : public reply_data
{
};
struct consumer_seek_tag_requested_request : public request_data
{
media_destination destination;
bigtime_t target_time;
uint32 flags;
};
struct consumer_seek_tag_requested_reply : public reply_data
{
media_seek_tag seek_tag;
bigtime_t tagged_time;
uint32 flags;
};
struct server_register_node_request : public request_data
{
media_addon_id addon_id;
@ -474,4 +744,89 @@ struct server_get_instances_for_reply : public reply_data
};
struct addonserver_rescan_mediaaddon_flavors_command : public command_data
{
media_addon_id addonid;
};
struct server_register_mediaaddon_request : public request_data
{
xfer_entry_ref ref; // a ref to the file
};
struct server_register_mediaaddon_reply : public reply_data
{
media_addon_id addonid;
};
struct server_unregister_mediaaddon_command : public command_data
{
media_addon_id addonid;
};
struct server_get_mediaaddon_ref_request : public request_data
{
media_addon_id addonid;
};
struct server_get_mediaaddon_ref_reply : public reply_data
{
xfer_entry_ref ref; // a ref to the file
};
struct node_request_completed_command : public command_data
{
media_request_info info;
};
struct node_start_command : public command_data
{
bigtime_t performance_time;
};
struct node_stop_command : public command_data
{
bigtime_t performance_time;
bool immediate;
};
struct node_seek_command : public command_data
{
bigtime_t media_time;
bigtime_t performance_time;
};
struct node_set_run_mode_command : public command_data
{
BMediaNode::run_mode mode;
};
struct node_time_warp_command : public command_data
{
bigtime_t at_real_time;
bigtime_t to_performance_time;
};
struct node_set_timesource_command : public command_data
{
media_node_id timesource_id;
};
#endif // _DATA_EXCHANGE_H

View File

@ -11,7 +11,6 @@
#define DEBUG 3
#include "debug.h"
#include "DataExchange.h"
#include "ServerInterface.h"
#include "BufferIdCache.h"
/*************************************************************
@ -52,7 +51,7 @@ BBufferConsumer::RegionToClipData(const BRegion *region,
int count;
count = *ioSize / sizeof(int16);
rv = BBufferProducer::clip_region_to_shorts(region, (int16 *)data, count, &count);
rv = BBufferProducer::clip_region_to_shorts(region, static_cast<int16 *>(data), count, &count);
*ioSize = count * sizeof(int16);
*format = BBufferProducer::B_CLIP_SHORT_RUNS;
@ -85,12 +84,12 @@ BBufferConsumer::NotifyLateProducer(const media_source &what_source,
if (what_source == media_source::null)
return;
xfer_producer_late_notice_received request;
request.source = what_source;
request.how_much = how_much;
request.performance_time = performance_time;
producer_late_notice_received_command command;
command.source = what_source;
command.how_much = how_much;
command.performance_time = performance_time;
write_port(what_source.port, PRODUCER_LATE_NOTICE_RECEIVED, &request, sizeof(request));
SendToPort(what_source.port, PRODUCER_LATE_NOTICE_RECEIVED, &command, sizeof(command));
}
@ -109,27 +108,27 @@ BBufferConsumer::SetVideoClippingFor(const media_source &output,
return B_MEDIA_BAD_SOURCE;
if (destination == media_destination::null)
return B_MEDIA_BAD_DESTINATION;
if (short_count > int(B_MEDIA_MESSAGE_SIZE - sizeof(xfer_producer_video_clipping_changed)) / 2)
if (short_count > int(B_MEDIA_MESSAGE_SIZE - sizeof(producer_video_clipping_changed_command)) / 2)
debugger("BBufferConsumer::SetVideoClippingFor short_count too large (8000 limit)\n");
xfer_producer_video_clipping_changed *request;
producer_video_clipping_changed_command *command;
size_t size;
status_t rv;
size = sizeof(xfer_producer_video_clipping_changed) + short_count * 2;
request = (xfer_producer_video_clipping_changed *) malloc(size);
request->source = output;
request->destination = destination;
request->display = display;
request->user_data = user_data;
request->change_tag = NewChangeTag();
request->short_count = short_count;
memcpy(request->shorts, shorts, short_count * 2);
size = sizeof(producer_video_clipping_changed_command) + short_count * sizeof(short);
command = static_cast<producer_video_clipping_changed_command *>(malloc(size));
command->source = output;
command->destination = destination;
command->display = display;
command->user_data = user_data;
command->change_tag = NewChangeTag();
command->short_count = short_count;
memcpy(command->shorts, shorts, short_count * sizeof(short));
if (change_tag != NULL)
*change_tag = request->change_tag;
*change_tag = command->change_tag;
rv = write_port(output.port, PRODUCER_VIDEO_CLIPPING_CHANGED, request, size);
free(request);
rv = SendToPort(output.port, PRODUCER_VIDEO_CLIPPING_CHANGED, command, size);
free(command);
return rv;
}
@ -148,17 +147,17 @@ BBufferConsumer::SetOutputEnabled(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_enable_output request;
producer_enable_output_command command;
request.source = source;
request.destination = destination;
request.enabled = enabled;
request.user_data = user_data;
request.change_tag = NewChangeTag();
command.source = source;
command.destination = destination;
command.enabled = enabled;
command.user_data = user_data;
command.change_tag = NewChangeTag();
if (change_tag != NULL)
*change_tag = request.change_tag;
*change_tag = command.change_tag;
return write_port(source.port, PRODUCER_ENABLE_OUTPUT, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_ENABLE_OUTPUT, &command, sizeof(command));
}
@ -176,17 +175,17 @@ BBufferConsumer::RequestFormatChange(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_format_change_requested request;
producer_format_change_requested_command command;
request.source = source;
request.destination = destination;
request.format = to_format;
request.user_data = user_data;
request.change_tag = NewChangeTag();
command.source = source;
command.destination = destination;
command.format = to_format;
command.user_data = user_data;
command.change_tag = NewChangeTag();
if (change_tag != NULL)
*change_tag = request.change_tag;
*change_tag = command.change_tag;
return write_port(source.port, PRODUCER_FORMAT_CHANGE_REQUESTED, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_FORMAT_CHANGE_REQUESTED, &command, sizeof(command));
}
@ -199,15 +198,15 @@ BBufferConsumer::RequestAdditionalBuffer(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_additional_buffer_requested request;
producer_additional_buffer_requested_command command;
request.source = source;
request.prev_buffer = prev_buffer->ID();
request.prev_time = 0;
request.has_seek_tag = false;
//request.prev_tag =
command.source = source;
command.prev_buffer = prev_buffer->ID();
command.prev_time = 0;
command.has_seek_tag = false;
//command.prev_tag =
return write_port(source.port, PRODUCER_ADDITIONAL_BUFFER_REQUESTED, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_ADDITIONAL_BUFFER_REQUESTED, &command, sizeof(command));
}
@ -220,15 +219,15 @@ BBufferConsumer::RequestAdditionalBuffer(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_additional_buffer_requested request;
producer_additional_buffer_requested_command command;
request.source = source;
request.prev_buffer = 0;
request.prev_time = start_time;
request.has_seek_tag = false;
//request.prev_tag =
command.source = source;
command.prev_buffer = 0;
command.prev_time = start_time;
command.has_seek_tag = false;
//command.prev_tag =
return write_port(source.port, PRODUCER_ADDITIONAL_BUFFER_REQUESTED, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_ADDITIONAL_BUFFER_REQUESTED, &command, sizeof(command));
}
@ -248,7 +247,7 @@ BBufferConsumer::SetOutputBuffersFor(const media_source &source,
if (destination == media_destination::null)
return B_MEDIA_BAD_DESTINATION;
xfer_producer_set_buffer_group *request;
producer_set_buffer_group_command *command;
BBuffer **buffers;
int32 buffer_count;
size_t size;
@ -263,32 +262,34 @@ BBufferConsumer::SetOutputBuffersFor(const media_source &source,
if (buffer_count != 0) {
buffers = new BBuffer * [buffer_count];
if (B_OK != group->GetBufferList(buffer_count,buffers)) {
delete buffers;
if (B_OK != group->GetBufferList(buffer_count, buffers)) {
delete [] buffers;
return B_ERROR;
}
} else {
buffers = NULL;
}
size = sizeof(xfer_producer_set_buffer_group) + buffer_count * sizeof(media_buffer_id);
request = (xfer_producer_set_buffer_group *) malloc(size);
request->source = source;
request->destination = destination;
request->user_data = user_data;
request->change_tag = NewChangeTag();
request->buffer_count = buffer_count;
size = sizeof(producer_set_buffer_group_command) + buffer_count * sizeof(media_buffer_id);
command = static_cast<producer_set_buffer_group_command *>(malloc(size));
command->source = source;
command->destination = destination;
command->user_data = user_data;
command->change_tag = NewChangeTag();
command->buffer_count = buffer_count;
for (int32 i = 0; i < buffer_count; i++)
request->buffers[i] = buffers[i]->ID();
if (change_tag != NULL)
*change_tag = request->change_tag;
rv = write_port(source.port, PRODUCER_SET_BUFFER_GROUP, request, size);
free(request);
command->buffers[i] = buffers[i]->ID();
delete [] buffers;
if (change_tag != NULL)
*change_tag = command->change_tag;
rv = SendToPort(source.port, PRODUCER_SET_BUFFER_GROUP, command, size);
free(command);
if (rv == B_OK) {
if (fDeleteBufferGroup)
if (fDeleteBufferGroup) // XXX will leak memory if port write failed
delete fDeleteBufferGroup;
fDeleteBufferGroup = will_reclaim ? group : NULL;
}
@ -308,14 +309,14 @@ BBufferConsumer::SendLatencyChange(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_latency_changed request;
producer_latency_changed_command command;
request.source = source;
request.destination = destination;
request.latency = my_new_latency;
request.flags = flags;
command.source = source;
command.destination = destination;
command.latency = my_new_latency;
command.flags = flags;
return write_port(source.port, PRODUCER_LATENCY_CHANGED, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_LATENCY_CHANGED, &command, sizeof(command));
}
/*************************************************************
@ -324,16 +325,15 @@ BBufferConsumer::SendLatencyChange(const media_source &source,
/* virtual */ status_t
BBufferConsumer::HandleMessage(int32 message,
const void *rawdata,
const void *data,
size_t size)
{
// CALLED();
TRACE("BBufferConsumer::HandleMessage %#lx, node %ld\n", message, ID());
status_t rv;
switch (message) {
case CONSUMER_ACCEPT_FORMAT:
{
const consumer_accept_format_request *request = (const consumer_accept_format_request *)rawdata;
const consumer_accept_format_request *request = static_cast<const consumer_accept_format_request *>(data);
consumer_accept_format_reply reply;
reply.format = request->format;
rv = AcceptFormat(request->dest, &reply.format);
@ -343,7 +343,7 @@ BBufferConsumer::HandleMessage(int32 message,
case CONSUMER_GET_NEXT_INPUT:
{
const consumer_get_next_input_request *request = (const consumer_get_next_input_request *)rawdata;
const consumer_get_next_input_request *request = static_cast<const consumer_get_next_input_request *>(data);
consumer_get_next_input_reply reply;
reply.cookie = request->cookie;
rv = GetNextInput(&reply.cookie, &reply.input);
@ -353,7 +353,7 @@ BBufferConsumer::HandleMessage(int32 message,
case CONSUMER_DISPOSE_INPUT_COOKIE:
{
const consumer_dispose_input_cookie_request *request = (const consumer_dispose_input_cookie_request *)rawdata;
const consumer_dispose_input_cookie_request *request = static_cast<const consumer_dispose_input_cookie_request *>(data);
consumer_dispose_input_cookie_reply reply;
DisposeInputCookie(request->cookie);
request->SendReply(B_OK, &reply, sizeof(reply));
@ -362,33 +362,33 @@ BBufferConsumer::HandleMessage(int32 message,
case CONSUMER_BUFFER_RECEIVED:
{
const xfer_consumer_buffer_received *request = (const xfer_consumer_buffer_received *)rawdata;
const consumer_buffer_received_command *command = static_cast<const consumer_buffer_received_command *>(data);
BBuffer *buffer;
buffer = fBufferCache->GetBuffer(request->buffer);
buffer->SetHeader(&request->header);
buffer = fBufferCache->GetBuffer(command->buffer);
buffer->SetHeader(&command->header);
BufferReceived(buffer);
return B_OK;
}
case CONSUMER_PRODUCER_DATA_STATUS:
{
const xfer_consumer_producer_data_status *request = (const xfer_consumer_producer_data_status *)rawdata;
ProducerDataStatus(request->for_whom, request->status, request->at_performance_time);
const consumer_producer_data_status_command *command = static_cast<const consumer_producer_data_status_command *>(data);
ProducerDataStatus(command->for_whom, command->status, command->at_performance_time);
return B_OK;
}
case CONSUMER_GET_LATENCY_FOR:
{
const xfer_consumer_get_latency_for *request = (const xfer_consumer_get_latency_for *)rawdata;
xfer_consumer_get_latency_for_reply reply;
reply.result = GetLatencyFor(request->for_whom, &reply.latency, &reply.timesource);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const consumer_get_latency_for_request *request = static_cast<const consumer_get_latency_for_request *>(data);
consumer_get_latency_for_reply reply;
rv = GetLatencyFor(request->for_whom, &reply.latency, &reply.timesource);
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
case CONSUMER_CONNECTED:
{
const consumer_connected_request *request = (const consumer_connected_request *)rawdata;
const consumer_connected_request *request = static_cast<const consumer_connected_request *>(data);
consumer_connected_reply reply;
rv = Connected(request->producer, request->where, request->with_format, &reply.input);
request->SendReply(rv, &reply, sizeof(reply));
@ -397,7 +397,7 @@ BBufferConsumer::HandleMessage(int32 message,
case CONSUMER_DISCONNECTED:
{
const consumer_disconnected_request *request = (const consumer_disconnected_request *)rawdata;
const consumer_disconnected_request *request = static_cast<const consumer_disconnected_request *>(data);
consumer_disconnected_reply reply;
Disconnected(request->source, request->destination);
request->SendReply(B_OK, &reply, sizeof(reply));
@ -406,31 +406,31 @@ BBufferConsumer::HandleMessage(int32 message,
case CONSUMER_FORMAT_CHANGED:
{
const xfer_consumer_format_changed *request = (const xfer_consumer_format_changed *)rawdata;
xfer_consumer_format_changed_reply reply;
reply.result = FormatChanged(request->producer, request->consumer, request->change_tag, request->format);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const consumer_format_changed_request *request = static_cast<const consumer_format_changed_request *>(data);
consumer_format_changed_reply reply;
rv = FormatChanged(request->producer, request->consumer, request->change_tag, request->format);
request->SendReply(rv, &reply, sizeof(reply));
// XXX is this RequestCompleted() correct?
xfer_node_request_completed completed;
completed.info.what = media_request_info::B_FORMAT_CHANGED;
completed.info.change_tag = request->change_tag;
completed.info.status = reply.result;
//completed.info.cookie
completed.info.user_data = 0;
completed.info.source = request->producer;
completed.info.destination = request->consumer;
completed.info.format = request->format;
write_port(request->consumer.port, NODE_REQUEST_COMPLETED, &completed, sizeof(completed));
node_request_completed_command completedcommand;
completedcommand.info.what = media_request_info::B_FORMAT_CHANGED;
completedcommand.info.change_tag = request->change_tag;
completedcommand.info.status = reply.result;
//completedcommand.info.cookie
completedcommand.info.user_data = 0;
completedcommand.info.source = request->producer;
completedcommand.info.destination = request->consumer;
completedcommand.info.format = request->format;
SendToPort(request->consumer.port, NODE_REQUEST_COMPLETED, &completedcommand, sizeof(completedcommand));
return B_OK;
}
case CONSUMER_SEEK_TAG_REQUESTED:
{
const xfer_consumer_seek_tag_requested *request = (const xfer_consumer_seek_tag_requested *)rawdata;
xfer_consumer_seek_tag_requested_reply reply;
reply.result = SeekTagRequested(request->destination, request->target_time, request->flags, &reply.seek_tag, &reply.tagged_time, &reply.flags);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const consumer_seek_tag_requested_request *request = static_cast<const consumer_seek_tag_requested_request *>(data);
consumer_seek_tag_requested_reply reply;
rv = SeekTagRequested(request->destination, request->target_time, request->flags, &reply.seek_tag, &reply.tagged_time, &reply.flags);
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
@ -473,27 +473,27 @@ BBufferConsumer::SetVideoClippingFor(const media_source &output,
CALLED();
if (output == media_source::null)
return B_MEDIA_BAD_SOURCE;
if (short_count > int(B_MEDIA_MESSAGE_SIZE - sizeof(xfer_producer_video_clipping_changed)) / 2)
if (short_count > int(B_MEDIA_MESSAGE_SIZE - sizeof(producer_video_clipping_changed_command)) / 2)
debugger("BBufferConsumer::SetVideoClippingFor short_count too large (8000 limit)\n");
xfer_producer_video_clipping_changed *request;
producer_video_clipping_changed_command *command;
size_t size;
status_t rv;
size = sizeof(xfer_producer_video_clipping_changed) + short_count * 2;
request = (xfer_producer_video_clipping_changed *) malloc(size);
request->source = output;
request->destination = media_destination::null;
request->display = display;
request->user_data = 0;
request->change_tag = NewChangeTag();
request->short_count = short_count;
memcpy(request->shorts, shorts, short_count * 2);
size = sizeof(producer_video_clipping_changed_command) + short_count * sizeof(short);
command = static_cast<producer_video_clipping_changed_command *>(malloc(size));
command->source = output;
command->destination = media_destination::null;
command->display = display;
command->user_data = 0;
command->change_tag = NewChangeTag();
command->short_count = short_count;
memcpy(command->shorts, shorts, short_count * sizeof(short));
if (change_tag != NULL)
*change_tag = request->change_tag;
*change_tag = command->change_tag;
rv = write_port(output.port, PRODUCER_VIDEO_CLIPPING_CHANGED, request, size);
free(request);
rv = SendToPort(output.port, PRODUCER_VIDEO_CLIPPING_CHANGED, command, size);
free(command);
return rv;
}
@ -511,17 +511,17 @@ BBufferConsumer::RequestFormatChange(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_format_change_requested request;
producer_format_change_requested_command command;
request.source = source;
request.destination = destination;
request.format = *in_to_format;
request.user_data = 0;
request.change_tag = NewChangeTag();
command.source = source;
command.destination = destination;
command.format = *in_to_format;
command.user_data = 0;
command.change_tag = NewChangeTag();
if (change_tag != NULL)
*change_tag = request.change_tag;
*change_tag = command.change_tag;
return write_port(source.port, PRODUCER_FORMAT_CHANGE_REQUESTED, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_FORMAT_CHANGE_REQUESTED, &command, sizeof(command));
}
@ -535,17 +535,17 @@ BBufferConsumer::SetOutputEnabled(const media_source &source,
if (source == media_source::null)
return B_MEDIA_BAD_SOURCE;
xfer_producer_enable_output request;
producer_enable_output_command command;
request.source = source;
request.destination = media_destination::null;
request.enabled = enabled;
request.user_data = 0;
request.change_tag = NewChangeTag();
command.source = source;
command.destination = media_destination::null;
command.enabled = enabled;
command.user_data = 0;
command.change_tag = NewChangeTag();
if (change_tag != NULL)
*change_tag = request.change_tag;
*change_tag = command.change_tag;
return write_port(source.port, PRODUCER_ENABLE_OUTPUT, &request, sizeof(request));
return SendToPort(source.port, PRODUCER_ENABLE_OUTPUT, &command, sizeof(command));
}

View File

@ -8,9 +8,7 @@
#include <Buffer.h>
#define DEBUG 3
#include "debug.h"
#include "PortPool.h"
#include "DataExchange.h"
#include "ServerInterface.h"
/*************************************************************
* protected BBufferProducer
@ -101,26 +99,25 @@ BBufferProducer::SetPlayRate(int32 numer,
status_t
BBufferProducer::HandleMessage(int32 message,
const void *rawdata,
const void *data,
size_t size)
{
// CALLED();
TRACE("BBufferProducer::HandleMessage %#lx, node %ld\n", message, fNodeID);
status_t rv;
switch (message) {
case PRODUCER_FORMAT_SUGGESTION_REQUESTED:
{
const xfer_producer_format_suggestion_requested *request = (const xfer_producer_format_suggestion_requested *)rawdata;
xfer_producer_format_suggestion_requested_reply reply;
reply.result = FormatSuggestionRequested(request->type, request->quality, &reply.format);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const producer_format_suggestion_requested_request *request = static_cast<const producer_format_suggestion_requested_request *>(data);
producer_format_suggestion_requested_reply reply;
rv = FormatSuggestionRequested(request->type, request->quality, &reply.format);
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
case PRODUCER_FORMAT_PROPOSAL:
{
const producer_format_proposal_request *request = (const producer_format_proposal_request *)rawdata;
const producer_format_proposal_request *request = static_cast<const producer_format_proposal_request *>(data);
producer_format_proposal_reply reply;
reply.format = request->format;
rv = FormatProposal(request->output, &reply.format);
@ -130,7 +127,7 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_PREPARE_TO_CONNECT:
{
const producer_prepare_to_connect_request *request = (const producer_prepare_to_connect_request *)rawdata;
const producer_prepare_to_connect_request *request = static_cast<const producer_prepare_to_connect_request *>(data);
producer_prepare_to_connect_reply reply;
reply.format = request->format;
memcpy(reply.name, request->name, B_MEDIA_NAME_LENGTH);
@ -141,7 +138,7 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_CONNECT:
{
const producer_connect_request *request = (const producer_connect_request *)rawdata;
const producer_connect_request *request = static_cast<const producer_connect_request *>(data);
producer_connect_reply reply;
memcpy(reply.name, request->name, B_MEDIA_NAME_LENGTH);
Connect(request->error, request->source, request->destination, request->format, reply.name);
@ -151,7 +148,7 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_DISCONNECT:
{
const producer_disconnect_request *request = (const producer_disconnect_request *)rawdata;
const producer_disconnect_request *request = static_cast<const producer_disconnect_request *>(data);
producer_disconnect_reply reply;
Disconnect(request->source, request->destination);
request->SendReply(B_OK, &reply, sizeof(reply));
@ -160,35 +157,35 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_GET_INITIAL_LATENCY:
{
const xfer_producer_get_initial_latency *request = (const xfer_producer_get_initial_latency *)rawdata;
xfer_producer_get_initial_latency_reply reply;
const producer_get_initial_latency_request *request = static_cast<const producer_get_initial_latency_request *>(data);
producer_get_initial_latency_reply reply;
reply.initial_latency = fInitialLatency;
reply.flags = fInitialFlags;
write_port(request->reply_port, 0, &reply, sizeof(reply));
request->SendReply(B_OK, &reply, sizeof(reply));
return B_OK;
}
case PRODUCER_SET_PLAY_RATE:
{
const xfer_producer_set_play_rate *request = (const xfer_producer_set_play_rate *)rawdata;
xfer_producer_set_play_rate_reply reply;
reply.result = SetPlayRate(request->numer, request->denom);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const producer_set_play_rate_request *request = static_cast<const producer_set_play_rate_request *>(data);
producer_set_play_rate_reply reply;
rv = SetPlayRate(request->numer, request->denom);
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
case PRODUCER_GET_LATENCY:
{
const xfer_producer_get_latency *request = (const xfer_producer_get_latency *)rawdata;
xfer_producer_get_latency_reply reply;
reply.result = GetLatency(&reply.latency);
write_port(request->reply_port, 0, &reply, sizeof(reply));
const producer_get_latency_request *request = static_cast<const producer_get_latency_request *>(data);
producer_get_latency_reply reply;
rv = GetLatency(&reply.latency);
request->SendReply(rv, &reply, sizeof(reply));
return B_OK;
}
case PRODUCER_GET_NEXT_OUTPUT:
{
const producer_get_next_output_request *request = (const producer_get_next_output_request *)rawdata;
const producer_get_next_output_request *request = static_cast<const producer_get_next_output_request *>(data);
producer_get_next_output_reply reply;
reply.cookie = request->cookie;
rv = GetNextOutput(&reply.cookie, &reply.output);
@ -198,7 +195,7 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_DISPOSE_OUTPUT_COOKIE:
{
const producer_dispose_output_cookie_request *request = (const producer_dispose_output_cookie_request *)rawdata;
const producer_dispose_output_cookie_request *request = static_cast<const producer_dispose_output_cookie_request *>(data);
producer_dispose_output_cookie_reply reply;
DisposeOutputCookie(request->cookie);
request->SendReply(B_OK, &reply, sizeof(reply));
@ -207,104 +204,101 @@ BBufferProducer::HandleMessage(int32 message,
case PRODUCER_SET_BUFFER_GROUP:
{
const xfer_producer_set_buffer_group *request = (const xfer_producer_set_buffer_group *)rawdata;
xfer_node_request_completed reply;
const producer_set_buffer_group_command *command = static_cast<const producer_set_buffer_group_command *>(data);
node_request_completed_command replycommand;
BBufferGroup *group;
status_t rv;
group = request->buffer_count != 0 ? new BBufferGroup(request->buffer_count, request->buffers) : NULL;
rv = SetBufferGroup(request->source, group);
if (request->destination == media_destination::null)
group = command->buffer_count != 0 ? new BBufferGroup(command->buffer_count, command->buffers) : NULL;
rv = SetBufferGroup(command->source, group);
if (command->destination == media_destination::null)
return B_OK;
reply.info.what = media_request_info::B_SET_OUTPUT_BUFFERS_FOR;
reply.info.change_tag = request->change_tag;
reply.info.status = rv;
reply.info.cookie = (int32)group;
reply.info.user_data = request->user_data;
reply.info.source = request->source;
reply.info.destination = request->destination;
write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply));
replycommand.info.what = media_request_info::B_SET_OUTPUT_BUFFERS_FOR;
replycommand.info.change_tag = command->change_tag;
replycommand.info.status = rv;
replycommand.info.cookie = (int32)group;
replycommand.info.user_data = command->user_data;
replycommand.info.source = command->source;
replycommand.info.destination = command->destination;
SendToPort(command->destination.port, NODE_REQUEST_COMPLETED, &replycommand, sizeof(replycommand));
return B_OK;
}
case PRODUCER_FORMAT_CHANGE_REQUESTED:
{
const xfer_producer_format_change_requested *request = (const xfer_producer_format_change_requested *)rawdata;
xfer_node_request_completed reply;
status_t rv;
reply.info.format = request->format;
rv = FormatChangeRequested(request->source, request->destination, &reply.info.format, NULL);
if (request->destination == media_destination::null)
const producer_format_change_requested_command *command = static_cast<const producer_format_change_requested_command *>(data);
node_request_completed_command replycommand;
replycommand.info.format = command->format;
rv = FormatChangeRequested(command->source, command->destination, &replycommand.info.format, NULL);
if (command->destination == media_destination::null)
return B_OK;
reply.info.what = media_request_info::B_REQUEST_FORMAT_CHANGE;
reply.info.change_tag = request->change_tag;
reply.info.status = rv;
//reply.info.cookie
reply.info.user_data = request->user_data;
reply.info.source = request->source;
reply.info.destination = request->destination;
write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply));
replycommand.info.what = media_request_info::B_REQUEST_FORMAT_CHANGE;
replycommand.info.change_tag = command->change_tag;
replycommand.info.status = rv;
//replycommand.info.cookie
replycommand.info.user_data = command->user_data;
replycommand.info.source = command->source;
replycommand.info.destination = command->destination;
SendToPort(command->destination.port, NODE_REQUEST_COMPLETED, &replycommand, sizeof(replycommand));
return B_OK;
}
case PRODUCER_VIDEO_CLIPPING_CHANGED:
{
const xfer_producer_video_clipping_changed *request = (const xfer_producer_video_clipping_changed *)rawdata;
xfer_node_request_completed reply;
status_t rv;
rv = VideoClippingChanged(request->source, request->short_count, (int16 *)request->shorts, request->display, NULL);
if (request->destination == media_destination::null)
const producer_video_clipping_changed_command *command = static_cast<const producer_video_clipping_changed_command *>(data);
node_request_completed_command replycommand;
rv = VideoClippingChanged(command->source, command->short_count, (int16 *)command->shorts, command->display, NULL);
if (command->destination == media_destination::null)
return B_OK;
reply.info.what = media_request_info::B_SET_VIDEO_CLIPPING_FOR;
reply.info.change_tag = request->change_tag;
reply.info.status = rv;
//reply.info.cookie
reply.info.user_data = request->user_data;
reply.info.source = request->source;
reply.info.destination = request->destination;
reply.info.format.type = B_MEDIA_RAW_VIDEO;
reply.info.format.u.raw_video.display = request->display;
write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply));
replycommand.info.what = media_request_info::B_SET_VIDEO_CLIPPING_FOR;
replycommand.info.change_tag = command->change_tag;
replycommand.info.status = rv;
//replycommand.info.cookie
replycommand.info.user_data = command->user_data;
replycommand.info.source = command->source;
replycommand.info.destination = command->destination;
replycommand.info.format.type = B_MEDIA_RAW_VIDEO;
replycommand.info.format.u.raw_video.display = command->display;
SendToPort(command->destination.port, NODE_REQUEST_COMPLETED, &replycommand, sizeof(replycommand));
return B_OK;
}
case PRODUCER_ADDITIONAL_BUFFER_REQUESTED:
{
const xfer_producer_additional_buffer_requested *request = (const xfer_producer_additional_buffer_requested *)rawdata;
AdditionalBufferRequested(request->source, request->prev_buffer, request->prev_time, request->has_seek_tag ? &request->prev_tag : NULL);
const producer_additional_buffer_requested_command *command = static_cast<const producer_additional_buffer_requested_command *>(data);
AdditionalBufferRequested(command->source, command->prev_buffer, command->prev_time, command->has_seek_tag ? &command->prev_tag : NULL);
return B_OK;
}
case PRODUCER_LATENCY_CHANGED:
{
const xfer_producer_latency_changed *request = (const xfer_producer_latency_changed *)rawdata;
LatencyChanged(request->source, request->destination, request->latency, request->flags);
const producer_latency_changed_command *command = static_cast<const producer_latency_changed_command *>(data);
LatencyChanged(command->source, command->destination, command->latency, command->flags);
return B_OK;
}
case PRODUCER_LATE_NOTICE_RECEIVED:
{
const xfer_producer_late_notice_received *request = (const xfer_producer_late_notice_received *)rawdata;
LateNoticeReceived(request->source, request->how_much, request->performance_time);
const producer_late_notice_received_command *command = static_cast<const producer_late_notice_received_command *>(data);
LateNoticeReceived(command->source, command->how_much, command->performance_time);
return B_OK;
}
case PRODUCER_ENABLE_OUTPUT:
{
const xfer_producer_enable_output *request = (const xfer_producer_enable_output *)rawdata;
xfer_node_request_completed reply;
EnableOutput(request->source, request->enabled, NULL);
if (request->destination == media_destination::null)
const producer_enable_output_command *command = static_cast<const producer_enable_output_command *>(data);
node_request_completed_command replycommand;
EnableOutput(command->source, command->enabled, NULL);
if (command->destination == media_destination::null)
return B_OK;
reply.info.what = media_request_info::B_SET_OUTPUT_ENABLED;
reply.info.change_tag = request->change_tag;
reply.info.status = B_OK;
//reply.info.cookie
reply.info.user_data = request->user_data;
reply.info.source = request->source;
reply.info.destination = request->destination;
//reply.info.format
write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply));
replycommand.info.what = media_request_info::B_SET_OUTPUT_ENABLED;
replycommand.info.change_tag = command->change_tag;
replycommand.info.status = B_OK;
//replycommand.info.cookie
replycommand.info.user_data = command->user_data;
replycommand.info.source = command->source;
replycommand.info.destination = command->destination;
//replycommand.info.format
SendToPort(command->destination.port, NODE_REQUEST_COMPLETED, &replycommand, sizeof(replycommand));
return B_OK;
}
@ -345,13 +339,13 @@ BBufferProducer::SendBuffer(BBuffer *buffer,
if (buffer == NULL)
return B_BAD_VALUE;
xfer_consumer_buffer_received request;
request.buffer = buffer->ID();
request.header = *(buffer->Header());
request.header.buffer = request.buffer;
request.header.destination = destination.id;
consumer_buffer_received_command command;
command.buffer = buffer->ID();
command.header = *(buffer->Header());
command.header.buffer = command.buffer; // buffer->ID();
command.header.destination = destination.id;
return write_port(destination.port, CONSUMER_BUFFER_RECEIVED, &request, sizeof(request));
return SendToPort(destination.port, CONSUMER_BUFFER_RECEIVED, &command, sizeof(command));
}
@ -364,12 +358,12 @@ BBufferProducer::SendDataStatus(int32 status,
if (destination == media_destination::null)
return B_MEDIA_BAD_DESTINATION;
xfer_consumer_producer_data_status request;
request.for_whom = destination;
request.status = status;
request.at_performance_time = at_time;
consumer_producer_data_status_command command;
command.for_whom = destination;
command.status = status;
command.at_performance_time = at_time;
return write_port(destination.port, CONSUMER_PRODUCER_DATA_STATUS, &request, sizeof(request));
return SendToPort(destination.port, CONSUMER_PRODUCER_DATA_STATUS, &command, sizeof(command));
}
@ -407,28 +401,15 @@ BBufferProducer::ChangeFormat(const media_source &for_source,
if (for_destination == media_destination::null)
return B_MEDIA_BAD_DESTINATION;
status_t rv;
int32 code;
xfer_consumer_format_changed request;
xfer_consumer_format_changed_reply reply;
consumer_format_changed_request request;
consumer_format_changed_reply reply;
request.producer = for_source;
request.consumer = for_destination;
request.format = *format;
request.reply_port = _PortPool->GetPort();
rv = write_port(for_destination.port, CONSUMER_FORMAT_CHANGED, &request, sizeof(request));
if (rv != B_OK) {
_PortPool->PutPort(request.reply_port);
return rv;
}
rv = read_port(request.reply_port, &code, &reply, sizeof(reply));
_PortPool->PutPort(request.reply_port);
if (rv < B_OK)
return rv;
return reply.result;
// we use a request/reply to make this synchronous
return QueryPort(for_destination.port, CONSUMER_FORMAT_CHANGED, &request, sizeof(request), &reply, sizeof(reply));
}
@ -442,28 +423,18 @@ BBufferProducer::FindLatencyFor(const media_destination &for_destination,
return B_MEDIA_BAD_DESTINATION;
status_t rv;
int32 code;
xfer_consumer_get_latency_for request;
xfer_consumer_get_latency_for_reply reply;
consumer_get_latency_for_request request;
consumer_get_latency_for_reply reply;
request.for_whom = for_destination;
request.reply_port = _PortPool->GetPort();
rv = write_port(for_destination.port, CONSUMER_GET_LATENCY_FOR, &request, sizeof(request));
if (rv != B_OK) {
_PortPool->PutPort(request.reply_port);
rv = QueryPort(for_destination.port, CONSUMER_GET_LATENCY_FOR, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK)
return rv;
}
rv = read_port(request.reply_port, &code, &reply, sizeof(reply));
_PortPool->PutPort(request.reply_port);
if (rv < B_OK)
return rv;
*out_latency = reply.latency;
*out_timesource = reply.timesource;
return reply.result;
return rv;
}
@ -480,31 +451,21 @@ BBufferProducer::FindSeekTag(const media_destination &for_destination,
return B_MEDIA_BAD_DESTINATION;
status_t rv;
int32 code;
xfer_consumer_seek_tag_requested request;
xfer_consumer_seek_tag_requested_reply reply;
consumer_seek_tag_requested_request request;
consumer_seek_tag_requested_reply reply;
request.destination = for_destination;
request.target_time = in_target_time;
request.flags = in_flags;
request.reply_port = _PortPool->GetPort();
rv = write_port(for_destination.port, CONSUMER_SEEK_TAG_REQUESTED, &request, sizeof(request));
if (rv != B_OK) {
_PortPool->PutPort(request.reply_port);
return rv;
}
rv = read_port(request.reply_port, &code, &reply, sizeof(reply));
_PortPool->PutPort(request.reply_port);
if (rv < B_OK)
rv = QueryPort(for_destination.port, CONSUMER_SEEK_TAG_REQUESTED, &request, sizeof(request), &reply, sizeof(reply));
if (rv != B_OK)
return rv;
*out_tag = reply.seek_tag;
*out_tagged_time = reply.tagged_time;
*out_flags = reply.flags;
return reply.result;
return rv;
}

View File

@ -49,7 +49,8 @@ status_t
request_data::SendReply(status_t result, reply_data *reply, int replysize) const
{
reply->result = result;
return SendToPort(reply_port, 0, reply, replysize);
// we cheat and use the (command_data *) version of SendToPort
return SendToPort(reply_port, 0, reinterpret_cast<command_data *>(reply), replysize);
}
@ -75,7 +76,7 @@ status_t QueryServer(BMessage *request, BMessage *reply)
// Raw data based data exchange with the media_server
status_t SendToServer(int32 msgcode, void *msg, int size)
status_t SendToServer(int32 msgcode, command_data *msg, int size)
{
return SendToPort(MediaServerPort, msgcode, msg, size);
}
@ -87,7 +88,7 @@ status_t QueryServer(int32 msgcode, request_data *request, int requestsize, repl
// Raw data based data exchange with the media_addon_server
status_t SendToAddonServer(int32 msgcode, void *msg, int size)
status_t SendToAddonServer(int32 msgcode, command_data *msg, int size)
{
return SendToPort(MediaAddonServerPort, msgcode, msg, size);
}
@ -100,7 +101,7 @@ status_t QueryAddonServer(int32 msgcode, request_data *request, int requestsize,
// Raw data based data exchange with the media_server
status_t SendToPort(port_id sendport, int32 msgcode, void *msg, int size)
status_t SendToPort(port_id sendport, int32 msgcode, command_data *msg, int size)
{
status_t rv;
rv = write_port_etc(sendport, msgcode, msg, size, B_RELATIVE_TIMEOUT, TIMEOUT);

View File

@ -30,6 +30,7 @@
#include "debug.h"
#include "PortPool.h"
#include "ServerInterface.h"
#include "DataExchange.h"
#include "DormantNodeManager.h"
static BPrivate::media::DormantNodeManager manager;
@ -164,8 +165,8 @@ DormantNodeManager::PutAddon(media_addon_id id)
media_addon_id
DormantNodeManager::RegisterAddon(const char *path)
{
xfer_server_register_mediaaddon msg;
xfer_server_register_mediaaddon_reply reply;
server_register_mediaaddon_request msg;
server_register_mediaaddon_reply reply;
port_id port;
status_t rv;
int32 code;
@ -201,7 +202,7 @@ void
DormantNodeManager::UnregisterAddon(media_addon_id id)
{
ASSERT(id > 0);
xfer_server_unregister_mediaaddon msg;
server_unregister_mediaaddon_command msg;
printf("DormantNodeManager::UnregisterAddon id %ld\n",id);
@ -217,8 +218,8 @@ DormantNodeManager::UnregisterAddon(media_addon_id id)
status_t
DormantNodeManager::FindAddonPath(BPath *path, media_addon_id id)
{
xfer_server_get_mediaaddon_ref msg;
xfer_server_get_mediaaddon_ref_reply reply;
server_get_mediaaddon_ref_request msg;
server_get_mediaaddon_ref_reply reply;
port_id port;
entry_ref tempref;
status_t rv;

View File

@ -10,6 +10,7 @@
#include "debug.h"
#include "PortPool.h"
#include "ServerInterface.h"
#include "DataExchange.h"
/*
* some little helper function
@ -543,7 +544,7 @@ BMediaAddOn::NotifyFlavorChange()
if (port <= B_OK)
return B_ERROR;
xfer_addonserver_rescan_mediaaddon_flavors msg;
addonserver_rescan_mediaaddon_flavors_command msg;
msg.addonid = fAddon;
return write_port(port, ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS, &msg, sizeof(msg));
}

View File

@ -327,7 +327,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
return B_OK;
}
if (fControllableThis && message > CONTROLLABLE_MESSAGE_START && message < CONTROLLABLE_MESSAGE_END) {
if (message > CONTROLLABLE_MESSAGE_START && message < CONTROLLABLE_MESSAGE_END) {
if (!fControllableThis)
fControllableThis = dynamic_cast<BControllable *>(this);
TRACE("BMediaNode::WaitForMessage calling BControllable %p\n", fControllableThis);
@ -335,7 +335,7 @@ BMediaNode::WaitForMessage(bigtime_t waitUntil,
return B_OK;
}
if (fTimeSourceThis && message > TIMESOURECE_MESSAGE_START && message < TIMESOURECE_MESSAGE_END) {
if (message > TIMESOURECE_MESSAGE_START && message < TIMESOURECE_MESSAGE_END) {
if (!fTimeSourceThis)
fTimeSourceThis = dynamic_cast<BTimeSource *>(this);
TRACE("BMediaNode::WaitForMessage calling BTimeSource %p\n", fTimeSourceThis);
@ -466,37 +466,37 @@ BMediaNode::HandleMessage(int32 message,
switch (message) {
case NODE_START:
{
const xfer_node_start *request = (const xfer_node_start *)data;
Start(request->performance_time);
const node_start_command *command = static_cast<const node_start_command *>(data);
Start(command->performance_time);
return B_OK;
}
case NODE_STOP:
{
const xfer_node_stop *request = (const xfer_node_stop *)data;
Stop(request->performance_time, request->immediate);
const node_stop_command *command = static_cast<const node_stop_command *>(data);
Stop(command->performance_time, command->immediate);
return B_OK;
}
case NODE_SEEK:
{
const xfer_node_seek *request = (const xfer_node_seek *)data;
Seek(request->media_time, request->performance_time);
const node_seek_command *command = static_cast<const node_seek_command *>(data);
Seek(command->media_time, command->performance_time);
return B_OK;
}
case NODE_SET_RUN_MODE:
{
const xfer_node_set_run_mode *request = (const xfer_node_set_run_mode *)data;
fRunMode = request->mode;
const node_set_run_mode_command *command = static_cast<const node_set_run_mode_command *>(data);
fRunMode = command->mode;
SetRunMode(fRunMode);
return B_OK;
}
case NODE_TIME_WARP:
{
const xfer_node_time_warp *request = (const xfer_node_time_warp *)data;
TimeWarp(request->at_real_time,request->to_performance_time);
const node_time_warp_command *command = static_cast<const node_time_warp_command *>(data);
TimeWarp(command->at_real_time, command->to_performance_time);
return B_OK;
}
@ -508,11 +508,11 @@ BMediaNode::HandleMessage(int32 message,
case NODE_SET_TIMESOURCE:
{
const xfer_node_set_timesource *request = (const xfer_node_set_timesource *)data;
const node_set_timesource_command *command = static_cast<const node_set_timesource_command *>(data);
bool first = (fTimeSourceID == 0);
if (fTimeSource)
fTimeSource->Release();
fTimeSourceID = request->timesource_id;
fTimeSourceID = command->timesource_id;
fTimeSource = 0; // XXX create timesource object here
fTimeSource = new _SysTimeSource;
if (!first)
@ -522,8 +522,8 @@ BMediaNode::HandleMessage(int32 message,
case NODE_REQUEST_COMPLETED:
{
const xfer_node_request_completed *request = (const xfer_node_request_completed *)data;
RequestCompleted(request->info);
const node_request_completed_command *command = static_cast<const node_request_completed_command *>(data);
RequestCompleted(command->info);
return B_OK;
}

View File

@ -662,7 +662,7 @@ BMediaRoster::StartNode(const media_node & node,
if (node.node <= 0)
return B_MEDIA_BAD_NODE;
xfer_node_start msg;
node_start_command msg;
msg.performance_time = at_performance_time;
return write_port(node.port, NODE_START, &msg, sizeof(msg));
@ -678,7 +678,7 @@ BMediaRoster::StopNode(const media_node & node,
if (node.node <= 0)
return B_MEDIA_BAD_NODE;
xfer_node_stop msg;
node_stop_command msg;
msg.performance_time = at_performance_time;
msg.immediate = immediate;
@ -695,7 +695,7 @@ BMediaRoster::SeekNode(const media_node & node,
if (node.node <= 0)
return B_MEDIA_BAD_NODE;
xfer_node_seek msg;
node_seek_command msg;
msg.media_time = to_media_time;
msg.performance_time = at_performance_time;
@ -778,7 +778,7 @@ BMediaRoster::SetRunModeNode(const media_node & node,
if (node.node <= 0)
return B_MEDIA_BAD_NODE;
xfer_node_set_run_mode msg;
node_set_run_mode_command msg;
msg.mode = mode;
return write_port(node.port, NODE_SET_RUN_MODE, &msg, sizeof(msg));
@ -829,8 +829,8 @@ BMediaRoster::SetProducerRate(const media_node & producer,
if ((producer.kind & B_BUFFER_PRODUCER) == 0)
return B_MEDIA_BAD_NODE;
xfer_producer_set_play_rate msg;
xfer_producer_set_play_rate_reply reply;
producer_set_play_rate_request msg;
producer_set_play_rate_reply reply;
status_t rv;
int32 code;

View File

@ -123,7 +123,7 @@ BTimeSource::BTimeSource() :
status_t
BTimeSource::HandleMessage(int32 message,
const void *rawdata,
const void *data,
size_t size)
{
TRACE("BTimeSource::HandleMessage %#lx, node %ld\n", message, fNodeID);
@ -131,7 +131,7 @@ BTimeSource::HandleMessage(int32 message,
switch (message) {
case TIMESOURCE_OP:
{
const time_source_op_info *data = (const time_source_op_info *)rawdata;
const time_source_op_info *data = static_cast<const time_source_op_info *>(data);
status_t result;
result = TimeSourceOp(*data, NULL);
return B_OK;

View File

@ -180,7 +180,7 @@ BTrackReader::ReadFrames(void *in_buffer, int32 frame_count)
{
CALLED();
uint8 *buffer = (uint8 *)in_buffer;
uint8 *buffer = static_cast<uint8 *>(in_buffer);
int32 bytes_to_read = frame_count * fFrameSize;
status_t last_status = B_OK;

View File

@ -65,36 +65,6 @@ enum {
};
/* We can't send an entry_ref through a port to another team,
* but we can assign it to an xfer_entry_ref and send this one,
* when we receive it we can assign it to a normal entry_ref
*/
struct xfer_entry_ref
{
public:
xfer_entry_ref()
{
device = -1;
directory = -1;
name[0] = 0;
}
operator entry_ref() const
{
entry_ref ref(device, directory, name);
return ref;
}
void operator=(const entry_ref &ref)
{
device = ref.device;
directory = ref.directory;
strcpy(name, ref.name);
}
private:
dev_t device;
ino_t directory;
char name[B_FILE_NAME_LENGTH];
};
struct xfer_server_get_dormant_flavor_info
{
@ -139,242 +109,8 @@ struct xfer_server_register_dormant_node
char dfi[1]; // a flattened dormant_flavor_info, dfi_size large
};
struct xfer_addonserver_rescan_mediaaddon_flavors
{
media_addon_id addonid;
};
struct xfer_server_register_mediaaddon
{
port_id reply_port;
xfer_entry_ref ref; // a ref to the file
};
struct xfer_server_register_mediaaddon_reply
{
media_addon_id addonid;
};
struct xfer_server_unregister_mediaaddon
{
media_addon_id addonid;
};
struct xfer_server_get_mediaaddon_ref
{
media_addon_id addonid;
port_id reply_port;
};
struct xfer_server_get_mediaaddon_ref_reply
{
status_t result;
xfer_entry_ref ref; // a ref to the file
};
struct xfer_producer_format_suggestion_requested
{
media_type type;
int32 quality;
port_id reply_port;
};
struct xfer_producer_format_suggestion_requested_reply
{
media_format format;
status_t result;
};
struct xfer_producer_set_play_rate
{
int32 numer;
int32 denom;
port_id reply_port;
};
struct xfer_producer_set_play_rate_reply
{
status_t result;
};
struct xfer_producer_get_initial_latency
{
port_id reply_port;
};
struct xfer_producer_get_initial_latency_reply
{
bigtime_t initial_latency;
uint32 flags;
};
struct xfer_producer_get_latency
{
port_id reply_port;
};
struct xfer_producer_get_latency_reply
{
bigtime_t latency;
status_t result;
};
struct xfer_producer_set_buffer_group
{
media_source source;
media_destination destination;
void *user_data;
int32 change_tag;
int32 buffer_count;
media_buffer_id buffers[1];
};
struct xfer_producer_format_change_requested
{
media_source source;
media_destination destination;
media_format format;
void *user_data;
int32 change_tag;
};
struct xfer_producer_video_clipping_changed
{
media_source source;
media_destination destination;
media_video_display_info display;
void *user_data;
int32 change_tag;
int32 short_count;
int16 shorts[1];
};
struct xfer_producer_additional_buffer_requested
{
media_source source;
media_buffer_id prev_buffer;
bigtime_t prev_time;
bool has_seek_tag;
media_seek_tag prev_tag;
};
struct xfer_producer_latency_changed
{
media_source source;
media_destination destination;
bigtime_t latency;
uint32 flags;
};
struct xfer_node_request_completed
{
media_request_info info;
};
struct xfer_producer_enable_output
{
media_source source;
media_destination destination;
bool enabled;
void *user_data;
int32 change_tag;
};
struct xfer_producer_late_notice_received
{
media_source source;
bigtime_t how_much;
bigtime_t performance_time;
};
struct xfer_node_start
{
bigtime_t performance_time;
};
struct xfer_node_stop
{
bigtime_t performance_time;
bool immediate;
};
struct xfer_node_seek
{
bigtime_t media_time;
bigtime_t performance_time;
};
struct xfer_node_set_run_mode
{
BMediaNode::run_mode mode;
};
struct xfer_node_time_warp
{
bigtime_t at_real_time;
bigtime_t to_performance_time;
};
struct xfer_node_set_timesource
{
media_node_id timesource_id;
};
struct xfer_consumer_buffer_received
{
media_buffer_id buffer;
media_header header;
};
struct xfer_consumer_producer_data_status
{
media_destination for_whom;
int32 status;
bigtime_t at_performance_time;
};
struct xfer_consumer_get_latency_for
{
media_destination for_whom;
port_id reply_port;
};
struct xfer_consumer_get_latency_for_reply
{
bigtime_t latency;
media_node_id timesource;
status_t result;
};
struct xfer_consumer_format_changed
{
media_source producer;
media_destination consumer;
int32 change_tag;
media_format format;
port_id reply_port;
};
struct xfer_consumer_format_changed_reply
{
status_t result;
};
struct xfer_consumer_seek_tag_requested
{
media_destination destination;
bigtime_t target_time;
uint32 flags;
port_id reply_port;
};
struct xfer_consumer_seek_tag_requested_reply
{
media_seek_tag seek_tag;
bigtime_t tagged_time;
uint32 flags;
status_t result;
};
namespace BPrivate { namespace media { namespace dataexchange {
status_t QueryServer(BMessage *query, BMessage *reply);

View File

@ -92,7 +92,7 @@ public:
00014e1c T _ServerApp::~_ServerApp(void)
00014ff4 T _ServerApp::MessageReceived(BMessage *);
00015840 T _ServerApp::QuitRequested(void)
00015b50 T _ServerApp::_DoNotify(notify_data *)
00015b50 T _ServerApp::_DoNotify(command_data *)
00015d18 T _ServerApp::_UnregisterApp(long, bool)
00018e90 T _ServerApp::AddOnHost(void)
00019530 T _ServerApp::AboutRequested(void)
@ -162,8 +162,8 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
switch (code) {
case SERVER_GET_MEDIAADDON_REF:
{
xfer_server_get_mediaaddon_ref *msg = (xfer_server_get_mediaaddon_ref *)data;
xfer_server_get_mediaaddon_ref_reply reply;
server_get_mediaaddon_ref_request *msg = (server_get_mediaaddon_ref_request *)data;
server_get_mediaaddon_ref_reply reply;
entry_ref tempref;
reply.result = gNodeManager->GetAddonRef(&tempref, msg->addonid);
reply.ref = tempref;
@ -349,8 +349,8 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
case SERVER_REGISTER_MEDIAADDON:
{
xfer_server_register_mediaaddon *msg = (xfer_server_register_mediaaddon *)data;
xfer_server_register_mediaaddon_reply reply;
server_register_mediaaddon_request *msg = (server_register_mediaaddon_request *)data;
server_register_mediaaddon_reply reply;
gNodeManager->RegisterAddon(msg->ref, &reply.addonid);
write_port(msg->reply_port, 0, &reply, sizeof(reply));
break;
@ -358,7 +358,7 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
case SERVER_UNREGISTER_MEDIAADDON:
{
xfer_server_unregister_mediaaddon *msg = (xfer_server_unregister_mediaaddon *)data;
server_unregister_mediaaddon_command *msg = (server_unregister_mediaaddon_command *)data;
gNodeManager->UnregisterAddon(msg->addonid);
break;
}

View File

@ -91,7 +91,7 @@ MediaAddonServer::HandleMessage(int32 code, void *data, size_t size)
case ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS:
{
const xfer_addonserver_rescan_mediaaddon_flavors *msg = (const xfer_addonserver_rescan_mediaaddon_flavors *)data;
const addonserver_rescan_mediaaddon_flavors_command *msg = (const addonserver_rescan_mediaaddon_flavors_command *)data;
BMediaAddOn *addon;
addon = _DormantNodeManager->GetAddon(msg->addonid);
if (!addon) {