152a38012Sejakowatz /*********************************************************************** 252a38012Sejakowatz * AUTHOR: Marcus Overhagen 352a38012Sejakowatz * FILE: BufferProducer.cpp 452a38012Sejakowatz * DESCR: 552a38012Sejakowatz ***********************************************************************/ 652a38012Sejakowatz #include <BufferProducer.h> 752a38012Sejakowatz #include <BufferGroup.h> 852a38012Sejakowatz #include <Buffer.h> 952a38012Sejakowatz #include "PortPool.h" 1052a38012Sejakowatz #include "debug.h" 118c6a6096Sbeveloper #include "DataExchange.h" 120a483e72SIngo Weinhold #include "ServerInterface.h" 1352a38012Sejakowatz 1452a38012Sejakowatz /************************************************************* 1552a38012Sejakowatz * protected BBufferProducer 1652a38012Sejakowatz *************************************************************/ 1752a38012Sejakowatz 1852a38012Sejakowatz BBufferProducer::~BBufferProducer() 1952a38012Sejakowatz { 2052a38012Sejakowatz CALLED(); 2152a38012Sejakowatz } 2252a38012Sejakowatz 2352a38012Sejakowatz /************************************************************* 2452a38012Sejakowatz * public BBufferProducer 2552a38012Sejakowatz *************************************************************/ 2652a38012Sejakowatz 2752a38012Sejakowatz /* static */ status_t 2852a38012Sejakowatz BBufferProducer::ClipDataToRegion(int32 format, 2952a38012Sejakowatz int32 size, 30*63ffaa3eSbeveloper const void *data, 3152a38012Sejakowatz BRegion *region) 3252a38012Sejakowatz { 3352a38012Sejakowatz CALLED(); 3452a38012Sejakowatz 3552a38012Sejakowatz if (format != B_CLIP_SHORT_RUNS) 3652a38012Sejakowatz return B_MEDIA_BAD_CLIP_FORMAT; 3752a38012Sejakowatz 38*63ffaa3eSbeveloper return clip_shorts_to_region((const int16 *)data, size / sizeof(int16), region); 3952a38012Sejakowatz } 4052a38012Sejakowatz 4152a38012Sejakowatz media_type 4252a38012Sejakowatz BBufferProducer::ProducerType() 4352a38012Sejakowatz { 4452a38012Sejakowatz CALLED(); 4552a38012Sejakowatz return fProducerType; 4652a38012Sejakowatz } 4752a38012Sejakowatz 4852a38012Sejakowatz /************************************************************* 4952a38012Sejakowatz * protected BBufferProducer 5052a38012Sejakowatz *************************************************************/ 5152a38012Sejakowatz 5252a38012Sejakowatz /* explicit */ 5352a38012Sejakowatz BBufferProducer::BBufferProducer(media_type producer_type) : 5452a38012Sejakowatz BMediaNode("called by BBufferProducer"), 5552a38012Sejakowatz fProducerType(producer_type), 5652a38012Sejakowatz fInitialLatency(0), 5752a38012Sejakowatz fInitialFlags(0) 5852a38012Sejakowatz { 5952a38012Sejakowatz CALLED(); 6052a38012Sejakowatz 6152a38012Sejakowatz AddNodeKind(B_BUFFER_PRODUCER); 6252a38012Sejakowatz } 6352a38012Sejakowatz 6452a38012Sejakowatz 6552a38012Sejakowatz status_t 6652a38012Sejakowatz BBufferProducer::VideoClippingChanged(const media_source &for_source, 6752a38012Sejakowatz int16 num_shorts, 6852a38012Sejakowatz int16 *clip_data, 6952a38012Sejakowatz const media_video_display_info &display, 7052a38012Sejakowatz int32 *_deprecated_) 7152a38012Sejakowatz { 7252a38012Sejakowatz CALLED(); 7352a38012Sejakowatz // may be implemented by derived classes 7452a38012Sejakowatz return B_ERROR; 7552a38012Sejakowatz } 7652a38012Sejakowatz 7752a38012Sejakowatz 7852a38012Sejakowatz status_t 7952a38012Sejakowatz BBufferProducer::GetLatency(bigtime_t *out_lantency) 8052a38012Sejakowatz { 8152a38012Sejakowatz UNIMPLEMENTED(); 8252a38012Sejakowatz 8352a38012Sejakowatz // XXX The default implementation of GetLatency() finds the maximum 8452a38012Sejakowatz // latency of your currently-available outputs by iterating over 8552a38012Sejakowatz // them, and returns that value in outLatency 8652a38012Sejakowatz 8752a38012Sejakowatz return B_ERROR; 8852a38012Sejakowatz } 8952a38012Sejakowatz 9052a38012Sejakowatz 9152a38012Sejakowatz status_t 9252a38012Sejakowatz BBufferProducer::SetPlayRate(int32 numer, 9352a38012Sejakowatz int32 denom) 9452a38012Sejakowatz { 9552a38012Sejakowatz CALLED(); 9652a38012Sejakowatz // may be implemented by derived classes 9752a38012Sejakowatz return B_ERROR; 9852a38012Sejakowatz } 9952a38012Sejakowatz 10052a38012Sejakowatz 10152a38012Sejakowatz status_t 10252a38012Sejakowatz BBufferProducer::HandleMessage(int32 message, 10352a38012Sejakowatz const void *rawdata, 10452a38012Sejakowatz size_t size) 10552a38012Sejakowatz { 10652a38012Sejakowatz CALLED(); 1078c6a6096Sbeveloper status_t rv; 10852a38012Sejakowatz switch (message) { 10952a38012Sejakowatz 11052a38012Sejakowatz case PRODUCER_FORMAT_SUGGESTION_REQUESTED: 11152a38012Sejakowatz { 1128c6a6096Sbeveloper const xfer_producer_format_suggestion_requested *request = (const xfer_producer_format_suggestion_requested *)rawdata; 11352a38012Sejakowatz xfer_producer_format_suggestion_requested_reply reply; 1148c6a6096Sbeveloper reply.result = FormatSuggestionRequested(request->type, request->quality, &reply.format); 1158c6a6096Sbeveloper write_port(request->reply_port, 0, &reply, sizeof(reply)); 11652a38012Sejakowatz return B_OK; 11752a38012Sejakowatz } 11852a38012Sejakowatz 11952a38012Sejakowatz case PRODUCER_FORMAT_PROPOSAL: 12052a38012Sejakowatz { 1218c6a6096Sbeveloper const producer_format_proposal_request *request = (const producer_format_proposal_request *)rawdata; 1228c6a6096Sbeveloper producer_format_proposal_reply reply; 1238c6a6096Sbeveloper reply.format = request->format; 1248c6a6096Sbeveloper rv = FormatProposal(request->output, &reply.format); 1258c6a6096Sbeveloper request->SendReply(rv, &reply, sizeof(reply)); 12652a38012Sejakowatz return B_OK; 12752a38012Sejakowatz } 12852a38012Sejakowatz 12952a38012Sejakowatz case PRODUCER_PREPARE_TO_CONNECT: 13052a38012Sejakowatz { 1318c6a6096Sbeveloper const producer_prepare_to_connect_request *request = (const producer_prepare_to_connect_request *)rawdata; 1328c6a6096Sbeveloper producer_prepare_to_connect_reply reply; 1338c6a6096Sbeveloper reply.format = request->format; 1348c6a6096Sbeveloper memcpy(reply.name, request->name, B_MEDIA_NAME_LENGTH); 1358c6a6096Sbeveloper rv = PrepareToConnect(request->source, request->destination, &reply.format, &reply.out_source, reply.name); 1368c6a6096Sbeveloper request->SendReply(rv, &reply, sizeof(reply)); 13752a38012Sejakowatz return B_OK; 13852a38012Sejakowatz } 13952a38012Sejakowatz 14052a38012Sejakowatz case PRODUCER_CONNECT: 14152a38012Sejakowatz { 1428c6a6096Sbeveloper const producer_connect_request *request = (const producer_connect_request *)rawdata; 1438c6a6096Sbeveloper producer_connect_reply reply; 1448c6a6096Sbeveloper memcpy(reply.name, request->name, B_MEDIA_NAME_LENGTH); 1458c6a6096Sbeveloper Connect(request->error, request->source, request->destination, request->format, reply.name); 1468c6a6096Sbeveloper request->SendReply(B_OK, &reply, sizeof(reply)); 14752a38012Sejakowatz return B_OK; 14852a38012Sejakowatz } 14952a38012Sejakowatz 15052a38012Sejakowatz case PRODUCER_DISCONNECT: 15152a38012Sejakowatz { 1528c6a6096Sbeveloper const xfer_producer_disconnect *request = (const xfer_producer_disconnect *)rawdata; 1538c6a6096Sbeveloper Disconnect(request->source, request->destination); 15452a38012Sejakowatz return B_OK; 15552a38012Sejakowatz } 15652a38012Sejakowatz 15752a38012Sejakowatz case PRODUCER_GET_INITIAL_LATENCY: 15852a38012Sejakowatz { 1598c6a6096Sbeveloper const xfer_producer_get_initial_latency *request = (const xfer_producer_get_initial_latency *)rawdata; 16052a38012Sejakowatz xfer_producer_get_initial_latency_reply reply; 16152a38012Sejakowatz reply.initial_latency = fInitialLatency; 16252a38012Sejakowatz reply.flags = fInitialFlags; 1638c6a6096Sbeveloper write_port(request->reply_port, 0, &reply, sizeof(reply)); 16452a38012Sejakowatz return B_OK; 16552a38012Sejakowatz } 16652a38012Sejakowatz 16752a38012Sejakowatz case PRODUCER_SET_PLAY_RATE: 16852a38012Sejakowatz { 1698c6a6096Sbeveloper const xfer_producer_set_play_rate *request = (const xfer_producer_set_play_rate *)rawdata; 17052a38012Sejakowatz xfer_producer_set_play_rate_reply reply; 1718c6a6096Sbeveloper reply.result = SetPlayRate(request->numer, request->denom); 1728c6a6096Sbeveloper write_port(request->reply_port, 0, &reply, sizeof(reply)); 17352a38012Sejakowatz return B_OK; 17452a38012Sejakowatz } 17552a38012Sejakowatz 17652a38012Sejakowatz case PRODUCER_GET_LATENCY: 17752a38012Sejakowatz { 1788c6a6096Sbeveloper const xfer_producer_get_latency *request = (const xfer_producer_get_latency *)rawdata; 17952a38012Sejakowatz xfer_producer_get_latency_reply reply; 18052a38012Sejakowatz reply.result = GetLatency(&reply.latency); 1818c6a6096Sbeveloper write_port(request->reply_port, 0, &reply, sizeof(reply)); 18252a38012Sejakowatz return B_OK; 18352a38012Sejakowatz } 18452a38012Sejakowatz 18552a38012Sejakowatz case PRODUCER_GET_NEXT_OUTPUT: 18652a38012Sejakowatz { 1878c6a6096Sbeveloper const xfer_producer_get_next_output *request = (const xfer_producer_get_next_output *)rawdata; 18852a38012Sejakowatz xfer_producer_get_next_output_reply reply; 1898c6a6096Sbeveloper reply.cookie = request->cookie; 19052a38012Sejakowatz reply.result = GetNextOutput(&reply.cookie, &reply.output); 1918c6a6096Sbeveloper write_port(request->reply_port, 0, &reply, sizeof(reply)); 19252a38012Sejakowatz return B_OK; 19352a38012Sejakowatz } 19452a38012Sejakowatz 19552a38012Sejakowatz case PRODUCER_DISPOSE_OUTPUT_COOKIE: 19652a38012Sejakowatz { 1978c6a6096Sbeveloper const xfer_producer_dispose_output_cookie *request = (const xfer_producer_dispose_output_cookie *)rawdata; 1988c6a6096Sbeveloper DisposeOutputCookie(request->cookie); 19952a38012Sejakowatz return B_OK; 20052a38012Sejakowatz } 20152a38012Sejakowatz 20252a38012Sejakowatz case PRODUCER_SET_BUFFER_GROUP: 20352a38012Sejakowatz { 2048c6a6096Sbeveloper const xfer_producer_set_buffer_group *request = (const xfer_producer_set_buffer_group *)rawdata; 20552a38012Sejakowatz xfer_node_request_completed reply; 20652a38012Sejakowatz BBufferGroup *group; 20752a38012Sejakowatz status_t rv; 2088c6a6096Sbeveloper group = request->buffer_count != 0 ? new BBufferGroup(request->buffer_count, request->buffers) : NULL; 2098c6a6096Sbeveloper rv = SetBufferGroup(request->source, group); 2108c6a6096Sbeveloper if (request->destination == media_destination::null) 21152a38012Sejakowatz return B_OK; 21252a38012Sejakowatz reply.info.what = media_request_info::B_SET_OUTPUT_BUFFERS_FOR; 2138c6a6096Sbeveloper reply.info.change_tag = request->change_tag; 21452a38012Sejakowatz reply.info.status = rv; 21552a38012Sejakowatz reply.info.cookie = (int32)group; 2168c6a6096Sbeveloper reply.info.user_data = request->user_data; 2178c6a6096Sbeveloper reply.info.source = request->source; 2188c6a6096Sbeveloper reply.info.destination = request->destination; 2198c6a6096Sbeveloper write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply)); 22052a38012Sejakowatz return B_OK; 22152a38012Sejakowatz } 22252a38012Sejakowatz 22352a38012Sejakowatz case PRODUCER_FORMAT_CHANGE_REQUESTED: 22452a38012Sejakowatz { 2258c6a6096Sbeveloper const xfer_producer_format_change_requested *request = (const xfer_producer_format_change_requested *)rawdata; 22652a38012Sejakowatz xfer_node_request_completed reply; 22752a38012Sejakowatz status_t rv; 2288c6a6096Sbeveloper reply.info.format = request->format; 2298c6a6096Sbeveloper rv = FormatChangeRequested(request->source, request->destination, &reply.info.format, NULL); 2308c6a6096Sbeveloper if (request->destination == media_destination::null) 23152a38012Sejakowatz return B_OK; 23252a38012Sejakowatz reply.info.what = media_request_info::B_REQUEST_FORMAT_CHANGE; 2338c6a6096Sbeveloper reply.info.change_tag = request->change_tag; 23452a38012Sejakowatz reply.info.status = rv; 23552a38012Sejakowatz //reply.info.cookie 2368c6a6096Sbeveloper reply.info.user_data = request->user_data; 2378c6a6096Sbeveloper reply.info.source = request->source; 2388c6a6096Sbeveloper reply.info.destination = request->destination; 2398c6a6096Sbeveloper write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply)); 24052a38012Sejakowatz return B_OK; 24152a38012Sejakowatz } 24252a38012Sejakowatz 24352a38012Sejakowatz 24452a38012Sejakowatz case PRODUCER_VIDEO_CLIPPING_CHANGED: 24552a38012Sejakowatz { 2468c6a6096Sbeveloper const xfer_producer_video_clipping_changed *request = (const xfer_producer_video_clipping_changed *)rawdata; 24752a38012Sejakowatz xfer_node_request_completed reply; 24852a38012Sejakowatz status_t rv; 2498c6a6096Sbeveloper rv = VideoClippingChanged(request->source, request->short_count, (int16 *)request->shorts, request->display, NULL); 2508c6a6096Sbeveloper if (request->destination == media_destination::null) 25152a38012Sejakowatz return B_OK; 25252a38012Sejakowatz reply.info.what = media_request_info::B_SET_VIDEO_CLIPPING_FOR; 2538c6a6096Sbeveloper reply.info.change_tag = request->change_tag; 25452a38012Sejakowatz reply.info.status = rv; 25552a38012Sejakowatz //reply.info.cookie 2568c6a6096Sbeveloper reply.info.user_data = request->user_data; 2578c6a6096Sbeveloper reply.info.source = request->source; 2588c6a6096Sbeveloper reply.info.destination = request->destination; 25952a38012Sejakowatz reply.info.format.type = B_MEDIA_RAW_VIDEO; 2608c6a6096Sbeveloper reply.info.format.u.raw_video.display = request->display; 2618c6a6096Sbeveloper write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply)); 26252a38012Sejakowatz return B_OK; 26352a38012Sejakowatz } 26452a38012Sejakowatz 26552a38012Sejakowatz case PRODUCER_ADDITIONAL_BUFFER_REQUESTED: 26652a38012Sejakowatz { 2678c6a6096Sbeveloper const xfer_producer_additional_buffer_requested *request = (const xfer_producer_additional_buffer_requested *)rawdata; 2688c6a6096Sbeveloper AdditionalBufferRequested(request->source, request->prev_buffer, request->prev_time, request->has_seek_tag ? &request->prev_tag : NULL); 26952a38012Sejakowatz return B_OK; 27052a38012Sejakowatz } 27152a38012Sejakowatz 27252a38012Sejakowatz case PRODUCER_LATENCY_CHANGED: 27352a38012Sejakowatz { 2748c6a6096Sbeveloper const xfer_producer_latency_changed *request = (const xfer_producer_latency_changed *)rawdata; 2758c6a6096Sbeveloper LatencyChanged(request->source, request->destination, request->latency, request->flags); 27652a38012Sejakowatz return B_OK; 27752a38012Sejakowatz } 27852a38012Sejakowatz 27952a38012Sejakowatz case PRODUCER_LATE_NOTICE_RECEIVED: 28052a38012Sejakowatz { 2818c6a6096Sbeveloper const xfer_producer_late_notice_received *request = (const xfer_producer_late_notice_received *)rawdata; 2828c6a6096Sbeveloper LateNoticeReceived(request->source, request->how_much, request->performance_time); 28352a38012Sejakowatz return B_OK; 28452a38012Sejakowatz } 28552a38012Sejakowatz 28652a38012Sejakowatz case PRODUCER_ENABLE_OUTPUT: 28752a38012Sejakowatz { 2888c6a6096Sbeveloper const xfer_producer_enable_output *request = (const xfer_producer_enable_output *)rawdata; 28952a38012Sejakowatz xfer_node_request_completed reply; 2908c6a6096Sbeveloper EnableOutput(request->source, request->enabled, NULL); 2918c6a6096Sbeveloper if (request->destination == media_destination::null) 29252a38012Sejakowatz return B_OK; 29352a38012Sejakowatz reply.info.what = media_request_info::B_SET_OUTPUT_ENABLED; 2948c6a6096Sbeveloper reply.info.change_tag = request->change_tag; 29552a38012Sejakowatz reply.info.status = B_OK; 29652a38012Sejakowatz //reply.info.cookie 2978c6a6096Sbeveloper reply.info.user_data = request->user_data; 2988c6a6096Sbeveloper reply.info.source = request->source; 2998c6a6096Sbeveloper reply.info.destination = request->destination; 30052a38012Sejakowatz //reply.info.format 3018c6a6096Sbeveloper write_port(request->destination.port, NODE_REQUEST_COMPLETED, &reply, sizeof(reply)); 30252a38012Sejakowatz return B_OK; 30352a38012Sejakowatz } 30452a38012Sejakowatz 30552a38012Sejakowatz }; 30652a38012Sejakowatz return B_ERROR; 30752a38012Sejakowatz } 30852a38012Sejakowatz 30952a38012Sejakowatz 31052a38012Sejakowatz void 31152a38012Sejakowatz BBufferProducer::AdditionalBufferRequested(const media_source &source, 31252a38012Sejakowatz media_buffer_id prev_buffer, 31352a38012Sejakowatz bigtime_t prev_time, 31452a38012Sejakowatz const media_seek_tag *prev_tag) 31552a38012Sejakowatz { 31652a38012Sejakowatz CALLED(); 31752a38012Sejakowatz // may be implemented by derived classes 31852a38012Sejakowatz } 31952a38012Sejakowatz 32052a38012Sejakowatz 32152a38012Sejakowatz void 32252a38012Sejakowatz BBufferProducer::LatencyChanged(const media_source &source, 32352a38012Sejakowatz const media_destination &destination, 32452a38012Sejakowatz bigtime_t new_latency, 32552a38012Sejakowatz uint32 flags) 32652a38012Sejakowatz { 32752a38012Sejakowatz CALLED(); 32852a38012Sejakowatz // may be implemented by derived classes 32952a38012Sejakowatz } 33052a38012Sejakowatz 33152a38012Sejakowatz 33252a38012Sejakowatz status_t 33352a38012Sejakowatz BBufferProducer::SendBuffer(BBuffer *buffer, 33452a38012Sejakowatz const media_destination &destination) 33552a38012Sejakowatz { 33652a38012Sejakowatz CALLED(); 33752a38012Sejakowatz if (destination == media_destination::null) 33852a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 33952a38012Sejakowatz if (buffer == NULL) 34052a38012Sejakowatz return B_BAD_VALUE; 34152a38012Sejakowatz 3428c6a6096Sbeveloper xfer_consumer_buffer_received request; 3438c6a6096Sbeveloper request.buffer = buffer->ID(); 3448c6a6096Sbeveloper request.header = *(buffer->Header()); 3458c6a6096Sbeveloper request.header.buffer = request.buffer; 3468c6a6096Sbeveloper request.header.destination = destination.id; 34752a38012Sejakowatz 3488c6a6096Sbeveloper return write_port(destination.port, CONSUMER_BUFFER_RECEIVED, &request, sizeof(request)); 34952a38012Sejakowatz } 35052a38012Sejakowatz 35152a38012Sejakowatz 35252a38012Sejakowatz status_t 35352a38012Sejakowatz BBufferProducer::SendDataStatus(int32 status, 35452a38012Sejakowatz const media_destination &destination, 35552a38012Sejakowatz bigtime_t at_time) 35652a38012Sejakowatz { 35752a38012Sejakowatz CALLED(); 35852a38012Sejakowatz if (destination == media_destination::null) 35952a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 36052a38012Sejakowatz 3618c6a6096Sbeveloper xfer_consumer_producer_data_status request; 3628c6a6096Sbeveloper request.for_whom = destination; 3638c6a6096Sbeveloper request.status = status; 3648c6a6096Sbeveloper request.at_performance_time = at_time; 36552a38012Sejakowatz 3668c6a6096Sbeveloper return write_port(destination.port, CONSUMER_PRODUCER_DATA_STATUS, &request, sizeof(request)); 36752a38012Sejakowatz } 36852a38012Sejakowatz 36952a38012Sejakowatz 37052a38012Sejakowatz status_t 37152a38012Sejakowatz BBufferProducer::ProposeFormatChange(media_format *format, 37252a38012Sejakowatz const media_destination &for_destination) 37352a38012Sejakowatz { 37452a38012Sejakowatz CALLED(); 37552a38012Sejakowatz if (for_destination == media_destination::null) 37652a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 37752a38012Sejakowatz 3788c6a6096Sbeveloper consumer_accept_format_request request; 3798c6a6096Sbeveloper consumer_accept_format_reply reply; 38052a38012Sejakowatz status_t rv; 38152a38012Sejakowatz 3828c6a6096Sbeveloper request.dest = for_destination; 3838c6a6096Sbeveloper request.format = *format; 3848c6a6096Sbeveloper rv = QueryPort(for_destination.port, CONSUMER_ACCEPT_FORMAT, &request, sizeof(request), &reply, sizeof(reply)); 3858c6a6096Sbeveloper if (rv != B_OK) 38652a38012Sejakowatz return rv; 38752a38012Sejakowatz 38852a38012Sejakowatz *format = reply.format; 3898c6a6096Sbeveloper return B_OK; 39052a38012Sejakowatz } 39152a38012Sejakowatz 39252a38012Sejakowatz 39352a38012Sejakowatz status_t 39452a38012Sejakowatz BBufferProducer::ChangeFormat(const media_source &for_source, 39552a38012Sejakowatz const media_destination &for_destination, 39652a38012Sejakowatz media_format *format) 39752a38012Sejakowatz { 39852a38012Sejakowatz CALLED(); 39952a38012Sejakowatz if (for_source == media_source::null) 40052a38012Sejakowatz return B_MEDIA_BAD_SOURCE; 40152a38012Sejakowatz if (for_destination == media_destination::null) 40252a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 40352a38012Sejakowatz 40452a38012Sejakowatz status_t rv; 40552a38012Sejakowatz int32 code; 4068c6a6096Sbeveloper xfer_consumer_format_changed request; 40752a38012Sejakowatz xfer_consumer_format_changed_reply reply; 40852a38012Sejakowatz 4098c6a6096Sbeveloper request.producer = for_source; 4108c6a6096Sbeveloper request.consumer = for_destination; 4118c6a6096Sbeveloper request.format = *format; 4128c6a6096Sbeveloper request.reply_port = _PortPool->GetPort(); 41352a38012Sejakowatz 4148c6a6096Sbeveloper rv = write_port(for_destination.port, CONSUMER_FORMAT_CHANGED, &request, sizeof(request)); 41552a38012Sejakowatz if (rv != B_OK) { 4168c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 41752a38012Sejakowatz return rv; 41852a38012Sejakowatz } 41952a38012Sejakowatz 4208c6a6096Sbeveloper rv = read_port(request.reply_port, &code, &reply, sizeof(reply)); 4218c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 42252a38012Sejakowatz if (rv < B_OK) 42352a38012Sejakowatz return rv; 42452a38012Sejakowatz 42552a38012Sejakowatz return reply.result; 42652a38012Sejakowatz } 42752a38012Sejakowatz 42852a38012Sejakowatz 42952a38012Sejakowatz status_t 43052a38012Sejakowatz BBufferProducer::FindLatencyFor(const media_destination &for_destination, 43152a38012Sejakowatz bigtime_t *out_latency, 43252a38012Sejakowatz media_node_id *out_timesource) 43352a38012Sejakowatz { 43452a38012Sejakowatz CALLED(); 43552a38012Sejakowatz if (for_destination == media_destination::null) 43652a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 43752a38012Sejakowatz 43852a38012Sejakowatz status_t rv; 43952a38012Sejakowatz int32 code; 4408c6a6096Sbeveloper xfer_consumer_get_latency_for request; 44152a38012Sejakowatz xfer_consumer_get_latency_for_reply reply; 44252a38012Sejakowatz 4438c6a6096Sbeveloper request.for_whom = for_destination; 4448c6a6096Sbeveloper request.reply_port = _PortPool->GetPort(); 44552a38012Sejakowatz 4468c6a6096Sbeveloper rv = write_port(for_destination.port, CONSUMER_GET_LATENCY_FOR, &request, sizeof(request)); 44752a38012Sejakowatz if (rv != B_OK) { 4488c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 44952a38012Sejakowatz return rv; 45052a38012Sejakowatz } 45152a38012Sejakowatz 4528c6a6096Sbeveloper rv = read_port(request.reply_port, &code, &reply, sizeof(reply)); 4538c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 45452a38012Sejakowatz if (rv < B_OK) 45552a38012Sejakowatz return rv; 45652a38012Sejakowatz 45752a38012Sejakowatz *out_latency = reply.latency; 45852a38012Sejakowatz *out_timesource = reply.timesource; 45952a38012Sejakowatz 46052a38012Sejakowatz return reply.result; 46152a38012Sejakowatz } 46252a38012Sejakowatz 46352a38012Sejakowatz 46452a38012Sejakowatz status_t 46552a38012Sejakowatz BBufferProducer::FindSeekTag(const media_destination &for_destination, 46652a38012Sejakowatz bigtime_t in_target_time, 46752a38012Sejakowatz media_seek_tag *out_tag, 46852a38012Sejakowatz bigtime_t *out_tagged_time, 46952a38012Sejakowatz uint32 *out_flags, 47052a38012Sejakowatz uint32 in_flags) 47152a38012Sejakowatz { 47252a38012Sejakowatz CALLED(); 47352a38012Sejakowatz if (for_destination == media_destination::null) 47452a38012Sejakowatz return B_MEDIA_BAD_DESTINATION; 47552a38012Sejakowatz 47652a38012Sejakowatz status_t rv; 47752a38012Sejakowatz int32 code; 4788c6a6096Sbeveloper xfer_consumer_seek_tag_requested request; 47952a38012Sejakowatz xfer_consumer_seek_tag_requested_reply reply; 48052a38012Sejakowatz 4818c6a6096Sbeveloper request.destination = for_destination; 4828c6a6096Sbeveloper request.target_time = in_target_time; 4838c6a6096Sbeveloper request.flags = in_flags; 4848c6a6096Sbeveloper request.reply_port = _PortPool->GetPort(); 48552a38012Sejakowatz 4868c6a6096Sbeveloper rv = write_port(for_destination.port, CONSUMER_SEEK_TAG_REQUESTED, &request, sizeof(request)); 48752a38012Sejakowatz if (rv != B_OK) { 4888c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 48952a38012Sejakowatz return rv; 49052a38012Sejakowatz } 49152a38012Sejakowatz 4928c6a6096Sbeveloper rv = read_port(request.reply_port, &code, &reply, sizeof(reply)); 4938c6a6096Sbeveloper _PortPool->PutPort(request.reply_port); 49452a38012Sejakowatz if (rv < B_OK) 49552a38012Sejakowatz return rv; 49652a38012Sejakowatz 49752a38012Sejakowatz *out_tag = reply.seek_tag; 49852a38012Sejakowatz *out_tagged_time = reply.tagged_time; 49952a38012Sejakowatz *out_flags = reply.flags; 50052a38012Sejakowatz 50152a38012Sejakowatz return reply.result; 50252a38012Sejakowatz } 50352a38012Sejakowatz 50452a38012Sejakowatz 50552a38012Sejakowatz void 50652a38012Sejakowatz BBufferProducer::SetInitialLatency(bigtime_t inInitialLatency, 50752a38012Sejakowatz uint32 flags) 50852a38012Sejakowatz { 50952a38012Sejakowatz fInitialLatency = inInitialLatency; 51052a38012Sejakowatz fInitialFlags = flags; 51152a38012Sejakowatz } 51252a38012Sejakowatz 51352a38012Sejakowatz /************************************************************* 51452a38012Sejakowatz * private BBufferProducer 51552a38012Sejakowatz *************************************************************/ 51652a38012Sejakowatz 51752a38012Sejakowatz /* 51852a38012Sejakowatz private unimplemented 51952a38012Sejakowatz BBufferProducer::BBufferProducer() 52052a38012Sejakowatz BBufferProducer::BBufferProducer(const BBufferProducer &clone) 52152a38012Sejakowatz BBufferProducer & BBufferProducer::operator=(const BBufferProducer &clone) 52252a38012Sejakowatz */ 52352a38012Sejakowatz 52452a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_0(void *) { return B_ERROR; } 52552a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_1(void *) { return B_ERROR; } 52652a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_2(void *) { return B_ERROR; } 52752a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_3(void *) { return B_ERROR; } 52852a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_4(void *) { return B_ERROR; } 52952a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_5(void *) { return B_ERROR; } 53052a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_6(void *) { return B_ERROR; } 53152a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_7(void *) { return B_ERROR; } 53252a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_8(void *) { return B_ERROR; } 53352a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_9(void *) { return B_ERROR; } 53452a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_10(void *) { return B_ERROR; } 53552a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_11(void *) { return B_ERROR; } 53652a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_12(void *) { return B_ERROR; } 53752a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_13(void *) { return B_ERROR; } 53852a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_14(void *) { return B_ERROR; } 53952a38012Sejakowatz status_t BBufferProducer::_Reserved_BufferProducer_15(void *) { return B_ERROR; } 54052a38012Sejakowatz 54152a38012Sejakowatz 54252a38012Sejakowatz status_t 543*63ffaa3eSbeveloper BBufferProducer::clip_shorts_to_region(const int16 *data, 54452a38012Sejakowatz int count, 54552a38012Sejakowatz BRegion *output) 54652a38012Sejakowatz { 54752a38012Sejakowatz UNIMPLEMENTED(); 54852a38012Sejakowatz 54952a38012Sejakowatz return B_ERROR; 55052a38012Sejakowatz } 55152a38012Sejakowatz 55252a38012Sejakowatz 55352a38012Sejakowatz status_t 55452a38012Sejakowatz BBufferProducer::clip_region_to_shorts(const BRegion *input, 555*63ffaa3eSbeveloper int16 *data, 55652a38012Sejakowatz int max_count, 55752a38012Sejakowatz int *out_count) 55852a38012Sejakowatz { 55952a38012Sejakowatz UNIMPLEMENTED(); 56052a38012Sejakowatz 56152a38012Sejakowatz return B_ERROR; 56252a38012Sejakowatz } 56352a38012Sejakowatz 564