/*---------------------------------------------------------------------- | BLT_DecoderServer::OnSetPropertyCommand +---------------------------------------------------------------------*/ void BLT_DecoderServer::OnSetPropertyCommand(BLT_PropertyScope scope, const NPT_String& /*target*/, const NPT_String& name, const ATX_PropertyValue* value) { BLT_Result result; ATX_LOG_FINE_1("[%s]", name.GetChars()); ATX_Properties* properties = NULL; switch (scope) { case BLT_PROPERTY_SCOPE_CORE: result = BLT_Decoder_GetProperties(m_Decoder, &properties); break; case BLT_PROPERTY_SCOPE_STREAM: result = BLT_Decoder_GetStreamProperties(m_Decoder, &properties); break; default: // not handled yet result = BLT_ERROR_NOT_SUPPORTED; } if (ATX_SUCCEEDED(result) && properties != NULL) { result = ATX_Properties_SetProperty(properties, name.GetChars(), value); } SendReply(BLT_DecoderServer_Message::COMMAND_ID_SET_PROPERTY, result); }
/*---------------------------------------------------------------------- | BtPlayerServer::OnPropertyNotification +---------------------------------------------------------------------*/ void BtPlayerServer::OnPropertyNotification(BLT_PropertyScope scope, const char* /* source */, const char* name, const ATX_PropertyValue* value) { ATX_Properties* properties = NULL; switch (scope) { case BLT_PROPERTY_SCOPE_CORE: properties = m_CoreProperties; break; case BLT_PROPERTY_SCOPE_STREAM: properties = m_StreamProperties; break; default: return; } // when the name is NULL or empty, it means that all the properties in that // scope fo that source have been deleted if (name == NULL || name[0] == '\0') { ATX_Properties_Clear(properties); return; } ATX_Properties_SetProperty(properties, name, value); }
/*---------------------------------------------------------------------- | main +---------------------------------------------------------------------*/ int main(int argc, char** argv) { ATX_Properties* properties; ATX_PropertyListener* listener0; ATX_PropertyListenerHandle listener0_handle = NULL; ATX_PropertyListener* listener1; ATX_PropertyListenerHandle listener1_handle = NULL; ATX_PropertyListener* listener2; ATX_PropertyListenerHandle listener2_handle = NULL; unsigned int i; unsigned int j; ATX_Result result; ATX_COMPILER_UNUSED(argc); ATX_COMPILER_UNUSED(argv); ATX_Debug("PropertiesTest -- Start\n"); Listener_Create("Listener 0", &listener0); Listener_Create("Listener 1", &listener1); Listener_Create("Listener 2", &listener2); result = ATX_Properties_Create(&properties); Properties[2].value.fp = 0.123456789f; j = 0; for (i=0; i<10000; i++) { DumpProperties(properties); if (rand()&0x4) { ATX_Debug("** setting property '%s' [%d]\n", Properties[j].name, j); result = ATX_Properties_SetProperty(properties, Properties[j].name, Properties[j].type, &Properties[j].value); ATX_Debug("(%d)\n", result); } else { ATX_Debug("&& unsetting property '%s' [%d]\n", Properties[j].name, j); result = ATX_Properties_UnsetProperty(properties, Properties[j].name); ATX_Debug("(%d)\n", result); } j++; if (j >= sizeof(Properties)/sizeof(Properties[0])) { j = 0; } if (rand()%7 == 0) { int l = rand()%3; ATX_PropertyListener* listener; ATX_PropertyListenerHandle* listener_handle; if (l == 0) { listener = listener0; listener_handle = &listener0_handle; } else if (l == 1) { listener = listener1; listener_handle = &listener1_handle; } else { listener = listener2; listener_handle = &listener2_handle; } if (*listener_handle) { result = ATX_Properties_RemoveListener(properties, *listener_handle); ATX_Debug("## removed listener %d [%d]\n", l, result); } result = ATX_Properties_AddListener(properties, Properties[j].name, listener, listener_handle); ATX_Debug("## added listener %d on %s [%d]\n", l, Properties[j].name, result); } ATX_Debug("++++++++++++++++++++++++++++++++++++++++++++\n"); } ATX_DESTROY_OBJECT(properties); ATX_DESTROY_OBJECT(listener0); ATX_DESTROY_OBJECT(listener1); ATX_DESTROY_OBJECT(listener2); ATX_Debug("PropertiesTest -- End\n"); return 0; }