Implemented BParameter::GetValue() and BControllable::GetParameterValue()
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3488 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dbafe172c0
commit
17488f48b1
@ -132,6 +132,34 @@ BControllable::HandleMessage(int32 message, const void *data, size_t size)
|
|||||||
|
|
||||||
status_t rv;
|
status_t rv;
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
case CONTROLLABLE_GET_PARAMETER_DATA:
|
||||||
|
{
|
||||||
|
const controllable_get_parameter_data_request *request = static_cast<const controllable_get_parameter_data_request *>(data);
|
||||||
|
controllable_get_parameter_data_reply reply;
|
||||||
|
area_id area;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
if (request->area == -1) {
|
||||||
|
// small data transfer uses buffer in reply
|
||||||
|
area = -1;
|
||||||
|
data = reply.rawdata;
|
||||||
|
} else {
|
||||||
|
// large data transfer, clone area
|
||||||
|
area = clone_area("get parameter data clone", &data, B_ANY_ADDRESS, B_READ_AREA | B_WRITE_AREA, request->area);
|
||||||
|
if (area < B_OK) {
|
||||||
|
FATAL("CONTROLLABLE_GET_PARAMETER_DATA cloning area failed\n");
|
||||||
|
request->SendReply(B_NO_MEMORY, &reply, sizeof(reply));
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reply.size = request->requestsize;
|
||||||
|
rv = GetParameterValue(request->parameter_id, &reply.last_change, data, &reply.size);
|
||||||
|
if (area != -1)
|
||||||
|
delete_area(area);
|
||||||
|
request->SendReply(rv, &reply, sizeof(reply));
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
case CONTROLLABLE_GET_PARAMETER_WEB:
|
case CONTROLLABLE_GET_PARAMETER_WEB:
|
||||||
{
|
{
|
||||||
const controllable_get_parameter_web_request *request = static_cast<const controllable_get_parameter_web_request *>(data);
|
const controllable_get_parameter_web_request *request = static_cast<const controllable_get_parameter_web_request *>(data);
|
||||||
|
@ -4,13 +4,17 @@
|
|||||||
**
|
**
|
||||||
** Author: Zousar Shaker
|
** Author: Zousar Shaker
|
||||||
** Axel Dörfler, axeld@pinc-software.de
|
** Axel Dörfler, axeld@pinc-software.de
|
||||||
|
** Marcus Overhagen
|
||||||
**
|
**
|
||||||
** This file may be used under the terms of the OpenBeOS License.
|
** This file may be used under the terms of the OpenBeOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <ParameterWeb.h>
|
#include <ParameterWeb.h>
|
||||||
|
#include <MediaNode.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "DataExchange.h"
|
||||||
|
#include "MediaMisc.h"
|
||||||
|
|
||||||
// for now!
|
// for now!
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -1328,11 +1332,64 @@ BParameter::Flags() const
|
|||||||
status_t
|
status_t
|
||||||
BParameter::GetValue(void *buffer, size_t *ioSize, bigtime_t *when)
|
BParameter::GetValue(void *buffer, size_t *ioSize, bigtime_t *when)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED();
|
CALLED();
|
||||||
/*
|
|
||||||
* XXX ToDo: call BControllable::GetControlValue() here.
|
controllable_get_parameter_data_request request;
|
||||||
*/
|
controllable_get_parameter_data_reply reply;
|
||||||
return B_BAD_VALUE;
|
media_node node;
|
||||||
|
area_id area;
|
||||||
|
status_t rv;
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
if (buffer == 0 || ioSize == 0)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
if (*ioSize <= 0)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
if (mWeb == 0) {
|
||||||
|
FATAL("BParameter::GetValue: no parent BParameterWeb\n");
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = mWeb->Node();
|
||||||
|
if (IS_INVALID_NODE(node)) {
|
||||||
|
FATAL("BParameter::GetValue: the parent BParameterWeb is not assigned to a BMediaNode\n");
|
||||||
|
return B_NO_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*ioSize > MAX_PARAMETER_DATA) {
|
||||||
|
// create an area if large data needs to be transfered
|
||||||
|
area = create_area("get parameter data", &data, B_ANY_ADDRESS, ROUND_UP_TO_PAGE(*ioSize), B_NO_LOCK, B_READ_AREA | B_WRITE_AREA);
|
||||||
|
if (area < B_OK) {
|
||||||
|
FATAL("BParameter::GetValue can't create area of %ld bytes\n", *ioSize);
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
area = -1;
|
||||||
|
data = reply.rawdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.parameter_id = mID;
|
||||||
|
request.requestsize = *ioSize;
|
||||||
|
request.area = area;
|
||||||
|
|
||||||
|
rv = QueryPort(node.port, CONTROLLABLE_GET_PARAMETER_DATA, &request, sizeof(request), &reply, sizeof(reply));
|
||||||
|
|
||||||
|
if (rv == B_OK) {
|
||||||
|
// we don't care about the reported data size and copy the full buffer
|
||||||
|
memcpy(buffer, data, *ioSize);
|
||||||
|
// store reported data size
|
||||||
|
*ioSize = reply.size;
|
||||||
|
// store last update time if when != NULL
|
||||||
|
if (when != 0)
|
||||||
|
*when = reply.last_change;
|
||||||
|
} else
|
||||||
|
FATAL("BParameter::GetValue querying node failed\n");
|
||||||
|
|
||||||
|
if (area != -1)
|
||||||
|
delete_area(area);
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user