status_t ESDSinkNode::GetConfigurationFor(BMessage * into_message) { CALLED(); BParameter *parameter = NULL; void *buffer; size_t size = 128; bigtime_t last_change; status_t err; if (!into_message) return B_BAD_VALUE; buffer = malloc(size); for(int32 i=0; i<fWeb->CountParameters(); i++) { parameter = fWeb->ParameterAt(i); if(parameter->Type() != BParameter::B_CONTINUOUS_PARAMETER && parameter->Type() != BParameter::B_DISCRETE_PARAMETER) continue; PRINT(("getting parameter %li\n", parameter->ID())); size = 128; while((err = GetParameterValue(parameter->ID(), &last_change, buffer, &size))==B_NO_MEMORY) { size += 128; free(buffer); buffer = malloc(size); } if(err == B_OK && size > 0) { into_message->AddInt32("parameterID", parameter->ID()); into_message->AddData("parameterData", B_RAW_TYPE, buffer, size, false); } else { PRINT(("parameter %li err : %s\n", parameter->ID(), strerror(err))); } } //PRINT_OBJECT(*into_message); return B_OK; }
void ESDSinkNode::SetParameterValue(int32 id, bigtime_t performance_time, const void* value, size_t size) { CALLED(); PRINT(("id : %li, performance_time : %lld, size : %li\n", id, performance_time, size)); BParameter *parameter = NULL; for(int32 i=0; i<fWeb->CountParameters(); i++) { parameter = fWeb->ParameterAt(i); if(parameter->ID() == id) break; } switch (id) { case PARAM_ENABLED: if (size != sizeof(bool)) return; fEnabled = *(bool *)value; return; case PARAM_HOST: { fprintf(stderr, "set HOST: %s\n", (const char *)value); fHostname = (const char *)value; #if 0 if (fDevice && fDevice->Connected()) { if (fDevice->Connect(fHostname.String(), fPort) >= 0) { fDevice->SetCommand(); fDevice->SetFormat(ESD_FMT, 2); //fDevice->GetServerInfo(); fInitCheckStatus = fDevice->SendDefaultCommand(); } } #endif return; } case PARAM_PORT: { fprintf(stderr, "set PORT: %s\n", (const char *)value); fPort = atoi((const char *)value); #if 0 if (fDevice && fDevice->Connected()) { if (fDevice->Connect(fHostname.String(), fPort) >= 0) { fDevice->SetCommand(); fDevice->SetFormat(ESD_FMT, 2); //fDevice->GetServerInfo(); fInitCheckStatus = fDevice->SendDefaultCommand(); } } #endif return; } default: break; } }
status_t ESDSinkNode::GetParameterValue(int32 id, bigtime_t* last_change, void* value, size_t* ioSize) { CALLED(); if (!fDevice) return B_ERROR; //PRINT(("id : %i\n", id)); switch (id) { case PARAM_ENABLED: if (*ioSize < sizeof(bool)) return B_NO_MEMORY; *(bool *)value = fEnabled; *ioSize = sizeof(bool); return B_OK; case PARAM_HOST: { BString s = fDevice->Host(); *ioSize = MIN(*ioSize, s.Length()); memcpy(value, s.String(), *ioSize); return B_OK; } case PARAM_PORT: { BString s; s << fDevice->Port(); *ioSize = MIN(*ioSize, s.Length()); memcpy(value, s.String(), *ioSize); return B_OK; } default: break; } #if 0 BParameter *parameter = NULL; for(int32 i=0; i<fWeb->CountParameters(); i++) { parameter = fWeb->ParameterAt(i); if(parameter->ID() == id) break; } #endif return EINVAL; }
void VirtualRenderer::SetFilterParameters(media_node node, parameter_list *list) { BParameterWeb *web; BParameterGroup *group; BParameter *param; int i, j; parameter_list_elem *elem; BMediaRoster::Roster()->GetParameterWebFor(node, &web); group = web->GroupAt(0); for (i = 0; i < group->CountParameters(); i++) { param = group->ParameterAt(i); for (j = 0; j < list->CountItems(); j++) { elem = list->ItemAt(j); if (elem->id == param->ID()) { param->SetValue(elem->value, elem->value_size, system_time()); break; } } } }