char *MIDIrequestPortName(struct Tracker_Windows *window, ReqType reqtype, bool is_input){ int num_ports; char **portnames=MIDI_getPortNames(&num_ports, is_input); vector_t v={0}; int i; #if defined(FOR_WINDOWS) if(num_ports==0) return NULL; #endif for(i=0;i<num_ports;i++) VECTOR_push_back(&v,portnames[i]); #if !defined(FOR_WINDOWS) VECTOR_push_back(&v,"Create new port"); #endif int sel=GFX_Menu(window,reqtype,"Select port",&v); if(sel==-1) return NULL; if(sel==num_ports){ char *ret=NULL; while(ret==NULL) ret = GFX_GetString(NULL,reqtype,"Name: "); return ret; } return portnames[sel]; }
static struct FX *selectFX( struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack ){ struct Tracks *track = wtrack->track; struct Patch *patch = track->patch; if(patch==NULL) { PATCH_select_patch_for_track(window,wtrack,true); //GFX_Message(NULL, "No instrument set for track %d\n",wtrack->l.num); return NULL; } struct FX *fx; int num_usedFX=getNumUsedFX(track); if(num_usedFX>0){ int lokke; vector_t v={0}; for(lokke=0;lokke<num_usedFX;lokke++) VECTOR_push_back(&v,getTrackFX(track,lokke)->name); #if 0 for(lokke=0;lokke<10000;lokke++) VECTOR_push_back(&v,talloc_format("extra %d",lokke)); #endif VECTOR_push_back(&v,"New FX"); int selection=GFX_Menu(window,NULL,"Select FX",&v); if(selection==-1) return NULL; if(selection<num_usedFX) return getTrackFX(track,selection); } fx=talloc(sizeof(struct FX)); fx->color = newFXColor(); fx->patch = patch; if( patch->instrument->getFX(window,track,fx) == FX_FAILED ){ return NULL; } fx->slider_automation_value = OS_SLIDER_obtain_automation_value_pointer(patch,fx->effect_num); fx->slider_automation_color = OS_SLIDER_obtain_automation_color_pointer(patch,fx->effect_num); return fx; }
void Window_config( struct Tracker_Windows *window ){ ReqType reqtype=GFX_OpenReq(window,30,12,"Window Config"); vector_t v={0}; VECTOR_push_back(&v,"Left Slider width"); VECTOR_push_back(&v,"Bottom Slider height"); VECTOR_push_back(&v, "First Beat Line color opacity"); VECTOR_push_back(&v, "Beat Line color opacity"); VECTOR_push_back(&v, "Line separate color opacity"); //VECTOR_push_back(&v,"Minimum node-size"); int sel=GFX_Menu(window,reqtype,"Select operation",&v); switch(sel){ case -1: break; #if 0 case 0: SelectEditFont(window); break; #endif case 0: SelectLeftSliderWidth(window,reqtype); break; case 1: SelectBottomSliderHeight(window,reqtype); break; case 2: SetFirstBeatOpacity(window, reqtype); break; case 3: SetBeatOpacity(window, reqtype); break; case 4: SetLineOpacity(window, reqtype); break; #if 0 case 5: SelectMinNodeSize(window,reqtype); break; #endif } GFX_CloseReq(window,reqtype); if (sel != -1) Window_config(window); }
// Called from main thread static void GE_fill_in_shared_variables(SharedVariables *sv){ struct Tracker_Windows *window = root->song->tracker_windows; struct WBlocks *wblock = window->wblock; struct Blocks *block = wblock->block; sv->top_realline = wblock->top_realline; sv->num_reallines = wblock->num_reallines; sv->curr_realline = wblock->curr_realline; sv->fontheight = window->fontheight; sv->reltempo = block->reltempo; sv->block_duration = getBlockSTimeLength(block); sv->scrollbar_height = get_scrollbar_y2(window,wblock) - get_scrollbar_y1(window,wblock); sv->scrollbar_scroller_height = get_scrollbar_scroller_height(window,wblock); sv->block = block; sv->times = block->times; { radium::ScopedMutex locker(&vector_mutex); VECTOR_push_back(&g_times_storage, sv->times); } sv->realline_places = (Place*)V_malloc(sv->num_reallines * sizeof(Place)); for(int i=0;i<sv->num_reallines;i++){ sv->realline_places[i] = wblock->reallines[i]->l.p; } }
static VECTOR_HANDLE VECTOR_copy(VECTOR_HANDLE vector) { VECTOR_HANDLE new_vector = VECTOR_create(sizeof(STRING_HANDLE)); size_t size = VECTOR_size(vector); for (size_t index = 0; index < size && new_vector != NULL; index++) { STRING_HANDLE* str = VECTOR_element(vector, index); if (str == NULL) { VECTOR_destroy(new_vector); new_vector = NULL; } else { STRING_HANDLE new_str = STRING_clone(*str); if (new_str == NULL) { VECTOR_destroy(new_vector); new_vector = NULL; } else { if (VECTOR_push_back(new_vector, &new_str, 1) != 0) { STRING_delete(new_str); VECTOR_destroy(new_vector); new_vector = NULL; } } } } return new_vector; }
void CopyRange_fxs( vector_t *tofxs, vector_t *das_fromfxs, Place *p1, Place *p2 ) { VECTOR_FOR_EACH(struct FXs *fromfxs, das_fromfxs){ R_ASSERT_RETURN_IF_FALSE(fromfxs->fx->patch->is_usable); #if 0 // This thing should perhaps be moved into co_CB_PasteTrack. if (!fromfxs->fx->patch->is_usable) { fromfxs->fx->patch = PATCH_create_audio(NULL, NULL, fromfxs->fx->patch->name, fromfxs->fx->patch->state); R_ASSERT_RETURN_IF_FALSE(fromfxs->fx->patch->patchdata != NULL); } #endif struct FXs *fxs=talloc(sizeof(struct FXs)); fxs->fx=tcopy(fromfxs->fx, sizeof(struct FX)); // Why not just reference the existing fx? (fx is modified) VECTOR_push_back(tofxs,fxs); CopyRange_fxnodelines(&fxs->fxnodelines,fromfxs->fxnodelines,NULL,*p1,*p2); }END_VECTOR_FOR_EACH;
vector_t *VECTOR_list1_to_vector(const struct ListHeader1 *list){ vector_t *v = talloc(sizeof(vector_t)); while(list!=NULL){ VECTOR_push_back(v,list); list=list->next; } return v; }
const vector_t *get_nodeline_nodes(const struct NodeLine *nodelines, float y_offset){ vector_t *vector = (vector_t*)talloc(sizeof(vector_t)); while(nodelines != NULL) { if (nodelines->is_node) VECTOR_push_back(vector, get_node_from_nodeline1(nodelines, y_offset)); struct NodeLine *next = nodelines->next; if (next==NULL) { VECTOR_push_back(vector, get_node_from_nodeline2(nodelines, y_offset)); break; }else{ nodelines = next; } } return vector; }
void Window_config( struct Tracker_Windows *window ){ ReqType reqtype=GFX_OpenReq(window,30,12,"Select which variable to modify:"); vector_t v={}; int leftsliderwidth = VECTOR_push_back(&v,"Left Slider width"); int bottomsliderheight = VECTOR_push_back(&v,"Bottom Slider height"); int firstbeat = VECTOR_push_back(&v, "First Beat Line color opacity"); int beatlineopacity = VECTOR_push_back(&v, "Beat Line color opacity"); int linecoloropacity = VECTOR_push_back(&v, "Line separate color opacity"); //VECTOR_push_back(&v,"Minimum node-size"); int sel=GFX_Menu(window,reqtype,"",v,true); #if 0 // case 0: SelectEditFont(window); break; #endif if (sel==leftsliderwidth) SelectLeftSliderWidth(window,reqtype); else if (sel==bottomsliderheight) SelectBottomSliderHeight(window,reqtype); else if (sel==firstbeat) SetFirstBeatOpacity(window, reqtype); else if (sel==beatlineopacity) SetBeatOpacity(window, reqtype); else if (sel==linecoloropacity) SetLineOpacity(window, reqtype); #if 0 else if (sel==selminnodesize) SelectMinNodeSize(window,reqtype); #endif GFX_CloseReq(window,reqtype); if (sel != -1) Window_config(window); }
static vector_t *create_instruments_widget_state(void){ vector_t *state = (vector_t *)talloc(sizeof(vector_t)); //vector_t *names = (vector_t *)talloc(sizeof(vector_t)); vector_t *pages = (vector_t *)talloc(sizeof(vector_t)); //VECTOR_push_back(state, names); VECTOR_push_back(state, pages); QStackedWidget* tabs = instruments_widget->tabs; for(int i=0;i<tabs->count();i++){ //VECTOR_push_back(names, talloc_strdup(tabs->tabText(i).toUtf8().constData())); VECTOR_push_back(pages, tabs->widget(i)); } VECTOR_push_back(state, tabs->currentWidget()); return state; }
static vector_t get_elements(const hash_t *hash){ vector_t vector = {0}; int i; for(i=0;i<hash->elements_size;i++){ hash_element_t *element = hash->elements[i]; while(element!=NULL){ VECTOR_push_back(&vector, element); element=element->next; } } return vector; }
static void show_message(int type, char *message){ static double last_ignore = -3000.0; // don't want to ignore errors the first two seconds. static bool ignore_rest_of_the_program = false; char *typestring = type==IS_ERROR?"Error":"Warning"; if(ignore_rest_of_the_program==true) return; if(TIME_get_ms()-last_ignore < 2000) return; char full_message[1000]; sprintf(full_message,"%s: %s", typestring, message); #if 0 // Always use SYSTEM_show_message. vector_t v = {0}; VECTOR_push_back(&v, "continue"); VECTOR_push_back(&v, "quit"); VECTOR_push_back(&v, "ignore warnings and errors for two seconds"); VECTOR_push_back(&v, "ignore warnings and errors for the rest of the program"); int ret = GFX_Message(&v, full_message); if (ret==-1) ret = SYSTEM_show_message(full_message); #else int ret = SYSTEM_show_message(full_message); #endif switch(ret){ case 0: break; case 1: { char *hello = NULL; hello[0] = 50; abort(); } case 2: last_ignore=TIME_get_ms(); break; case 3: ignore_rest_of_the_program=true; break; } }
void VECTOR_insert_place(vector_t *v, const Place *p){ int i; for(i=0 ; i<v->num_elements ; i++){ // could be optimized by using binary search, but binary search is hard to get correct. That speedup is not needed for now anyway. Place *element = v->elements[i]; if (PlaceLessThan(p, element)) { VECTOR_insert(v, p, i); return; } } VECTOR_push_back(v, p); }
static void IoTHubDeviceTwin_LL_CreatebasicModel_WithData15_inertPath(void) { STRICT_EXPECTED_CALL(Schema_GetSchemaForModel("basicModel_WithData15")); STRICT_EXPECTED_CALL(Schema_GetMetadata(TEST_SCHEMA_HANDLE)); STRICT_EXPECTED_CALL(Schema_GetModelByName(TEST_SCHEMA_HANDLE, "basicModel_WithData15")); STRICT_EXPECTED_CALL(CodeFirst_CreateDevice(TEST_SCHEMA_MODEL_TYPE_HANDLE, &ALL_REFLECTED(basic15), sizeof(basicModel_WithData15), true)); STRICT_EXPECTED_CALL(IoTHubClient_LL_SetDeviceTwinCallback(TEST_IOTHUB_CLIENT_LL_HANDLE, serializer_ingest, TEST_DEVICE_HANDLE)); STRICT_EXPECTED_CALL(IoTHubClient_LL_SetDeviceMethodCallback(TEST_IOTHUB_CLIENT_LL_HANDLE, deviceMethodCallback, TEST_DEVICE_HANDLE)); STRICT_EXPECTED_CALL(VECTOR_create(sizeof(SERIALIZER_DEVICETWIN_PROTOHANDLE))); STRICT_EXPECTED_CALL(VECTOR_push_back(IGNORED_PTR_ARG, IGNORED_PTR_ARG, 1)) .IgnoreArgument_handle() .IgnoreArgument_elements(); }
void VECTOR_insert_list3(vector_t *v, const struct ListHeader3 *element){ const Place *p = &element->p; int i; for(i=0 ; i<v->num_elements ; i++){ // could be optimized by using binary search, but binary search is hard to get correct. That speedup is not needed for now anyway. struct ListHeader3 *l3 = (struct ListHeader3*)v->elements[i]; if (PlaceLessThan(p, &l3->p)) { VECTOR_insert(v, element, i); return; } } VECTOR_push_back(v, element); }
static void *get_pianorollheader(int tracknum, bool create_new){ if (tracknum < 200 && tracknum>= g_pianorollheaders.num_elements) R_ASSERT("INIT_Pianoroll_headers not called"); if (tracknum >= g_pianorollheaders.num_elements) { if (create_new) while (tracknum >= g_pianorollheaders.num_elements) VECTOR_push_back(&g_pianorollheaders, PIANOROLLHEADER_create()); else return NULL; } return g_pianorollheaders.elements[tracknum]; }
static MODULE_LOADER_RESULT add_module_loader(const MODULE_LOADER* loader) { MODULE_LOADER_RESULT result; if (VECTOR_push_back(g_module_loaders.module_loaders, &loader, 1) == 0) { result = MODULE_LOADER_SUCCESS; } else { LogError("VECTOR_push_back failed"); result = MODULE_LOADER_ERROR; } return result; }
vector_t *get_all_ranged_notes(struct WBlocks *wblock){ vector_t *v=talloc(sizeof(vector_t)); struct WTracks *wtrack = wblock->wtracks; while(wtrack!=NULL){ struct Tracks *track = wtrack->track; if(is_track_ranged(wblock,wtrack)){ struct Notes *note = track->notes; while(note!=NULL){ if(isPlaceRanged(wblock,¬e->l.p)) VECTOR_push_back(v, note); note=NextNote(note); } } wtrack=NextWTrack(wtrack); } return v; }
/*obs: value is already cloned at the time of calling this function */ static int createOrUpdateOption(HTTPAPIEX_HANDLE_DATA* handleData, const char* optionName, const void* value) { /*this function is called after the option value has been saved (cloned)*/ int result; /*decide bwtween update or create*/ HTTPAPIEX_SAVED_OPTION* whereIsIt = VECTOR_find_if(handleData->savedOptions, sameName, optionName); if (whereIsIt != NULL) { free((void*)(whereIsIt->value)); whereIsIt->value = value; result = 0; } else { HTTPAPIEX_SAVED_OPTION newOption; if (mallocAndStrcpy_s((char**)&(newOption.optionName), optionName) != 0) { free((void*)value); result = __LINE__; } else { newOption.value = value; if (VECTOR_push_back(handleData->savedOptions, &newOption, 1) != 0) { LogError("unable to VECTOR_push_back\r\n"); free((void*)newOption.optionName); free((void*)value); result = __LINE__; } else { result = 0; } } } return result; }
static IOTHUB_CLIENT_RESULT start_worker_if_needed(TRANSPORT_HANDLE_DATA * transportData, IOTHUB_CLIENT_HANDLE clientHandle) { IOTHUB_CLIENT_RESULT result; if (transportData->workerThreadHandle == NULL) { /*Codes_SRS_IOTHUBTRANSPORT_17_018: [ If the worker thread does not exist, IoTHubTransport_StartWorkerThread shall start the thread using ThreadAPI_Create. ]*/ transportData->stopThread = 0; if (ThreadAPI_Create(&transportData->workerThreadHandle, transport_worker_thread, transportData) != THREADAPI_OK) { transportData->workerThreadHandle = NULL; } } if (transportData->workerThreadHandle != NULL) { /*Codes_SRS_IOTHUBTRANSPORT_17_020: [ IoTHubTransport_StartWorkerThread shall search for IoTHubClient clientHandle in the list of IoTHubClient handles. ]*/ bool addToList = ((VECTOR_size(transportData->clients) == 0) || (VECTOR_find_if(transportData->clients, find_by_handle, clientHandle) == NULL)); if (addToList) { /*Codes_SRS_IOTHUBTRANSPORT_17_021: [ If handle is not found, then clientHandle shall be added to the list. ]*/ if (VECTOR_push_back(transportData->clients, &clientHandle, 1) != 0) { /*Codes_SRS_IOTHUBTRANSPORT_17_042: [ If Adding to the client list fails, IoTHubTransport_StartWorkerThread shall return IOTHUB_CLIENT_ERROR. ]*/ result = IOTHUB_CLIENT_ERROR; } else { result = IOTHUB_CLIENT_OK; } } else { result = IOTHUB_CLIENT_OK; } } else { result = IOTHUB_CLIENT_ERROR; } return result; }
void CB_PasteTrack_CurrPos(struct Tracker_Windows *window){ struct WBlocks *wblock=window->wblock; struct Blocks *block=wblock->block; struct WTracks *wtrack=wblock->wtrack; Place lastplace; PlaceSetLastPos(wblock->block,&lastplace); PC_Pause(); switch(window->curr_track){ case SIGNATURETRACK: if(cb_signature==NULL) goto exit; ADD_UNDO(Signatures_CurrPos(window)); block->signatures=CB_CopySignatures(cb_signature); CutListAt_a(&block->signatures,&lastplace); UpdateWBlockWidths(window, wblock); UpdateBeats(block); //UpdateSTimes(block); //UpdateWLPBs(window,wblock); break; case LPBTRACK: if(cb_lpb==NULL) goto exit; ADD_UNDO(LPBs_CurrPos(window)); block->lpbs=CB_CopyLPBs(cb_lpb); CutListAt_a(&block->lpbs,&lastplace); UpdateSTimes(block); //UpdateWLPBs(window,wblock); UpdateBeats(block); #if !USE_OPENGL DrawUpLPBs(window,wblock); #endif break; case TEMPOTRACK: if(cb_tempo==NULL) goto exit; ADD_UNDO(Tempos_CurrPos(window)); block->tempos=CB_CopyTempos(cb_tempo); CutListAt_a(&block->tempos,&lastplace); //UpdateWTempos(window,wblock); #if !USE_OPENGL DrawUpTempos(window,wblock); #endif UpdateSTimes(block); break; case TEMPONODETRACK: if(cb_temponode==NULL) goto exit; ADD_UNDO(TempoNodes_CurrPos(window)); block->temponodes=CB_CopyTempoNodes(cb_temponode); CutListAt_a(&block->temponodes,&lastplace); LegalizeTempoNodes(block); #if !USE_OPENGL ///UpdateWTempoNodes(window,wblock); DrawUpWTempoNodes(window,wblock); #endif UpdateSTimes(block); break; default: if(cb_wtrack==NULL) goto exit; Undo_Open_rec();{ printf("curr_track_sub: %d\n",window->curr_track_sub); ADD_UNDO(Track_CurrPos(window)); if(window->curr_track_sub==-1 && cb_wtrack_only_contains_one_fxs==false){ // copy all printf("aaa\n"); if(co_CB_PasteTrack(wblock,cb_wtrack,wtrack)){ #if !USE_OPENGL UpdateFXNodeLines(window,wblock,wtrack); #endif window->must_redraw = true; }else{ #if !USE_OPENGL UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, wblock, window->curr_track, window->curr_track ); #endif } }else{ printf("bbb\n"); // only copy fx struct WTracks *fromwtrack = cb_wtrack; if (cb_wtrack_only_contains_one_fxs==true){ // only copy one fx R_ASSERT(cb_wtrack->track->fxs.num_elements==1); struct FXs *fxs = cb_wtrack->track->fxs.elements[0]; vector_t *fxss = VECTOR_copy(&wtrack->track->fxs); remove_fxs_from_fxss(fxss, fxs); VECTOR_push_back(fxss, fxs); fromwtrack = CB_CopyTrack(wblock, cb_wtrack); fromwtrack->track->fxs = *VECTOR_copy(fxss); } if(co_CB_PasteTrackFX(wblock,fromwtrack,wtrack)){ #if !USE_OPENGL UpdateFXNodeLines(window,wblock,wtrack); #endif window->must_redraw = true; }else{ #if !USE_OPENGL UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, wblock, window->curr_track, window->curr_track ); #endif } } }Undo_Close(); break; } SetNotePolyphonyAttributes(wtrack->track); ValidateCursorPos(window); exit: PC_StopPause(window); }
vector_t *get_windows_command_lines(void){ vector_t *ret = talloc(sizeof(vector_t)); HRESULT hr = 0; IWbemLocator *WbemLocator = NULL; IWbemServices *WbemServices = NULL; IEnumWbemClassObject *EnumWbem = NULL; //initializate the Windows security hr = CoInitializeEx(0, COINIT_MULTITHREADED); hr = CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL); hr = CoCreateInstance(&CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, &IID_IWbemLocator, (LPVOID *) &WbemLocator); if (WbemLocator == NULL) goto exit; //connect to the WMI hr = WbemLocator->lpVtbl->ConnectServer(WbemLocator, L"ROOT\\CIMV2", NULL, NULL, NULL, 0, NULL, NULL, &WbemServices); if (WbemServices == NULL) goto exit; //Run the WQL Query hr = WbemServices->lpVtbl->ExecQuery(WbemServices, L"WQL", L"SELECT ProcessId,CommandLine FROM Win32_Process", WBEM_FLAG_FORWARD_ONLY, NULL, &EnumWbem); if (EnumWbem == NULL) goto exit; // Iterate over the enumerator IWbemClassObject *result = NULL; ULONG returnedCount = 0; while((hr = EnumWbem->lpVtbl->Next(EnumWbem, WBEM_INFINITE, 1, &result, &returnedCount)) == S_OK) { VARIANT ProcessId; VARIANT CommandLine; // access the properties hr = result->lpVtbl->Get(result, L"ProcessId", 0, &ProcessId, 0, 0); hr = result->lpVtbl->Get(result, L"CommandLine", 0, &CommandLine, 0, 0); if (!(CommandLine.vt==VT_NULL)){ wprintf(L"%u %s \r\n", ProcessId.uintVal, CommandLine.bstrVal); VECTOR_push_back(ret, bstr_to_str(CommandLine.bstrVal)); } result->lpVtbl->Release(result); } exit: if (EnumWbem != NULL) EnumWbem->lpVtbl->Release(EnumWbem); if (WbemServices != NULL) WbemServices->lpVtbl->Release(WbemServices); if (WbemLocator != NULL) WbemLocator->lpVtbl->Release(WbemLocator); CoUninitialize(); //getchar(); return ret; }
DATA_PUBLISHER_RESULT DataPublisher_PublishTransacted_ReportedProperty(REPORTED_PROPERTIES_TRANSACTION_HANDLE transactionHandle, const char* reportedPropertyPath, const AGENT_DATA_TYPE* data) { DATA_PUBLISHER_RESULT result; /*Codes_SRS_DATA_PUBLISHER_02_009: [ If argument transactionHandle is NULL then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_INVALID_ARG. ]*/ /*Codes_SRS_DATA_PUBLISHER_02_010: [ If argument reportedPropertyPath is NULL then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_INVALID_ARG. ]*/ /*Codes_SRS_DATA_PUBLISHER_02_011: [ If argument data is NULL then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_INVALID_ARG. ]*/ if ( (transactionHandle == NULL) || (reportedPropertyPath == NULL) || (data == NULL) ) { LogError("invalid argument REPORTED_PROPERTIES_TRANSACTION_HANDLE transactionHandle=%p, const char* reportedPropertyPath=%p, const AGENT_DATA_TYPE* data=%p", transactionHandle, reportedPropertyPath, data); result = DATA_PUBLISHER_INVALID_ARG; } else { REPORTED_PROPERTIES_TRANSACTION_HANDLE_DATA* handleData = (REPORTED_PROPERTIES_TRANSACTION_HANDLE_DATA*)transactionHandle; /*Codes_SRS_DATA_PUBLISHER_02_012: [ DataPublisher_PublishTransacted_ReportedProperty shall verify that a reported property having the path reportedPropertyPath exists in the model by calling Schema_ModelReportedPropertyByPathExists ]*/ if (!Schema_ModelReportedPropertyByPathExists(handleData->DataPublisherInstance->ModelHandle, reportedPropertyPath)) { /*Codes_SRS_DATA_PUBLISHER_02_013: [ If a reported property with path reportedPropertyPath does not exist in the model then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_INVALID_ARG. ]*/ LogError("unable to find a reported property by path \"%s\"", reportedPropertyPath); result = DATA_PUBLISHER_INVALID_ARG; } else { DATA_MARSHALLER_VALUE** existingValue = VECTOR_find_if(handleData->value, reportedPropertyExistsByPath, reportedPropertyPath); if(existingValue != NULL) { /*Codes_SRS_DATA_PUBLISHER_02_014: [ If the same (by reportedPropertypath) reported property has already been added to the transaction, then DataPublisher_PublishTransacted_ReportedProperty shall overwrite the previous reported property. ]*/ AGENT_DATA_TYPE *clone = (AGENT_DATA_TYPE *)malloc(sizeof(AGENT_DATA_TYPE)); if(clone == NULL) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. ]*/ LogError("unable to malloc"); result = DATA_PUBLISHER_ERROR; } else { if (Create_AGENT_DATA_TYPE_from_AGENT_DATA_TYPE(clone, data) != AGENT_DATA_TYPES_OK) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. ]*/ LogError("unable to Create_AGENT_DATA_TYPE_from_AGENT_DATA_TYPE"); free(clone); result = DATA_PUBLISHER_ERROR; } else { /*Codes_SRS_DATA_PUBLISHER_02_017: [ Otherwise DataPublisher_PublishTransacted_ReportedProperty shall succeed and return DATA_PUBLISHER_OK. ]*/ Destroy_AGENT_DATA_TYPE((AGENT_DATA_TYPE*)((*existingValue)->Value)); free((void*)((*existingValue)->Value)); (*existingValue)->Value = clone; result = DATA_PUBLISHER_OK; } } } else { /*totally new reported property*/ DATA_MARSHALLER_VALUE* newValue = (DATA_MARSHALLER_VALUE*)malloc(sizeof(DATA_MARSHALLER_VALUE)); if (newValue == NULL) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. ]*/ LogError("unable to malloc"); result = DATA_PUBLISHER_ERROR; } else { if (mallocAndStrcpy_s((char**)&(newValue->PropertyPath), reportedPropertyPath) != 0) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. ]*/ LogError("unable to mallocAndStrcpy_s"); free(newValue); result = DATA_PUBLISHER_ERROR; } else { if ((newValue->Value = (AGENT_DATA_TYPE*)malloc(sizeof(AGENT_DATA_TYPE))) == NULL) { LogError("unable to malloc"); free((void*)newValue->PropertyPath); free(newValue); result = DATA_PUBLISHER_ERROR; } else { if (Create_AGENT_DATA_TYPE_from_AGENT_DATA_TYPE((AGENT_DATA_TYPE*)newValue->Value, data) != AGENT_DATA_TYPES_OK) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. ]*/ LogError("unable to Create_AGENT_DATA_TYPE_from_AGENT_DATA_TYPE"); free((void*)newValue->Value); free((void*)newValue->PropertyPath); free(newValue); result = DATA_PUBLISHER_ERROR; } else { /*Codes_SRS_DATA_PUBLISHER_02_015: [ DataPublisher_PublishTransacted_ReportedProperty shall add a new DATA_MARSHALLER_VALUE to the VECTOR_HANDLE. ]*/ if (VECTOR_push_back(handleData->value, &newValue, 1) != 0) { /*Codes_SRS_DATA_PUBLISHER_02_016: [ If any error occurs then DataPublisher_PublishTransacted_ReportedProperty shall fail and return DATA_PUBLISHER_ERROR. */ LogError("unable to VECTOR_push_back"); Destroy_AGENT_DATA_TYPE((AGENT_DATA_TYPE*)newValue->Value); free((void*)newValue->Value); free((void*)newValue->PropertyPath); free(newValue); result = DATA_PUBLISHER_ERROR; } else { /*Codes_SRS_DATA_PUBLISHER_02_017: [ Otherwise DataPublisher_PublishTransacted_ReportedProperty shall succeed and return DATA_PUBLISHER_OK. ]*/ result = DATA_PUBLISHER_OK; } } } } } } } } return result; }
hash_t *HASH_load(disk_t *file){ wchar_t *line = L""; while(STRING_starts_with(line, "#") || STRING_equals2(STRING_trim(line), L"")) line = READ_LINE(file); int version; if(STRING_equals(line,">> HASH MAP BEGIN")){ version = 1; } else if (STRING_equals(line,">> HASH MAP V2 BEGIN")){ version = 2; } else if (STRING_equals(line,">> HASH MAP V3 BEGIN")){ version = 3; } else if (STRING_starts_with(line, ">> HASH MAP V")){ version = 3; vector_t v = {0}; int try_anyway = VECTOR_push_back(&v, "Try anyway (program might crash and/or behave unstable)"); int ok = VECTOR_push_back(&v, "Ok"); int res = GFX_Message(&v, "Need a newer version of Radium to load this file"); if (res!=try_anyway) return NULL; (void)ok; } else { GFX_Message(NULL, "Trying to load something which is not a hash map. First line: \"%S\"", line); return NULL; } line = READ_LINE(file); int elements_size = STRING_get_int(line); hash_t *hash=HASH_create(elements_size); hash->version = version; line = READ_LINE(file); while(!STRING_equals(line,"<< HASH MAP END") && !STRING_equals(line,"<< HASH MAP V2 END") && !STRING_equals(line,"<< HASH MAP V3 END")){ const char *key = STRING_get_chars(line); int i = 0; if(version > 1){ line = READ_LINE(file); i = STRING_get_int(line); int new_size = i+1; if(new_size > hash->num_array_elements) hash->num_array_elements = new_size; } else if(!strncmp(key,"<int hash>",strlen("<int hash>"))) { sscanf(key, "<int hash> %d", &i); key = ""; hash->num_array_elements++; } bool success; dyn_t dyn = DYN_load(file, &success); if (!success) return NULL; put_dyn(hash, key, i, dyn); line = READ_LINE(file); } return hash; }
void TRACK_split_into_monophonic_tracks(struct Tracker_Windows *window, struct WBlocks *wblock, struct WTracks *wtrack){ PlayStop(); // This function is too chaotic. Don't bother pausing player. vector_t notesvector = {0}; struct Tracks *track = wtrack->track; struct Notes *notes = track->notes; struct Notes *notes_nexttrack = NULL; bool have_made_undo = false; if (NOTES_sorted_by_pitch_questionmark(track->notes)==false) { ADD_UNDO(Block_CurrPos(window)); have_made_undo = true; notes = NOTES_sort_by_pitch(notes); } while(notes != NULL){ struct Notes *notes_root = notes; while(notes != NULL) { struct Notes *next = NextNote(notes); if (next==NULL) break; if (PlaceGreaterThan(¬es->end, &next->l.p)){ if (have_made_undo==false) { have_made_undo=true; } ListRemoveElement3(¬es, &next->l); ListAddElement3_a(¬es_nexttrack, &next->l); } else notes = next; } VECTOR_push_back(¬esvector, notes_root); notes = notes_nexttrack; notes_nexttrack = NULL; } if (have_made_undo==false){ GFX_Message(NULL, "Track is already monophonic"); return; } int num_tracks = notesvector.num_elements; track->notes = NULL; struct WTracks *wtrack_copy = CB_CopyTrack(wblock,wtrack); VECTOR_clean(&wtrack_copy->track->fxs); InsertTracks(window, wblock, wtrack->l.num+1, num_tracks-1); printf("Vector length: %d\n",num_tracks); int i; for(i=0;i<num_tracks;i++){ struct Notes *notes = notesvector.elements[i]; printf(" %d: %d\n", i, ListFindNumElements3(¬es->l)); while(notes != NULL){ printf(" %s\n",NotesTexts3[(int)notes->note]); notes = NextNote(notes); } struct WTracks *towtrack = ListFindElement1(&wblock->wtracks->l, wtrack->l.num+i); if (i>0) co_CB_PasteTrack(wblock, wtrack_copy, towtrack); towtrack->track->notes = notesvector.elements[i]; } window->must_redraw = true; }
struct WSignatures *WSignatures_get( const struct Tracker_Windows *window, const struct WBlocks *wblock ) { struct WSignatures *wsignatures = (struct WSignatures *)talloc_atomic_clean(sizeof(struct WSignatures)*wblock->num_reallines); int realline=0; int last_written_realline = -1; int last_written_new_bar_realline = -1; struct Beats *beat = wblock->block->beats; while(beat!=NULL){ realline=FindRealLineFor(wblock,realline,&beat->l.p); bool is_new_bar = beat->beat_num==1; if(PlaceNotEqual(&wblock->reallines[realline]->l.p,&beat->l.p)) { wsignatures[realline].type=SIGNATURE_BELOW; float *f = (float*)talloc_atomic(sizeof(float)); float y1 = p_float(wblock->reallines[realline]->l.p); float y2 = realline==wblock->num_reallines-1 ? wblock->num_reallines : p_float(wblock->reallines[realline+1]->l.p); *f = scale( p_float(beat->l.p), y1, y2, 0,1); VECTOR_push_back(&wsignatures[realline].how_much_below, f); } /* if (realline==1) { printf("1: %s %d %d %s\n", ratio_to_string(beat->signature), beat->bar_num, beat->beat_num, wsignatures[realline].type != SIGNATURE_MUL ? "true" : "false" ); } */ if (is_new_bar && realline != last_written_new_bar_realline) { // Unlike the multi-behavior for other wxxx-types, we show the first element, and not the last. wsignatures[realline].signature = beat->signature; wsignatures[realline].bar_num = beat->bar_num; wsignatures[realline].beat_num = beat->beat_num; } else if (realline != last_written_realline) { wsignatures[realline].signature = beat->signature; wsignatures[realline].bar_num = beat->bar_num; wsignatures[realline].beat_num = beat->beat_num; } else { wsignatures[realline].type=SIGNATURE_MUL; } last_written_realline = realline; if (is_new_bar) last_written_new_bar_realline = realline; beat = NextBeat(beat); } return wsignatures; }
SoundPluginType *PR_get_plugin_type_by_name(const char *container_name, const char *type_name, const char *plugin_name){ for(SoundPluginType *plugin_type : g_plugin_types) if(!strcmp(plugin_type->type_name,type_name)) if(!strcmp(plugin_type->name,plugin_name)) return plugin_type; // check if the container needs to be populated. if (container_name != NULL) for(auto container : g_plugin_type_containers) if (!container->is_populated) if(!strcmp(container->type_name,type_name)) if(!strcmp(container->name,container_name)){ container->populate(container); return PR_get_plugin_type_by_name(container_name, type_name, plugin_name); } // Older songs didn't store vst container names (because there were no containers). Try to set container_name to plugin_name and try again. if(!strcmp(type_name,"VST") && container_name==NULL){ return PR_get_plugin_type_by_name(plugin_name,type_name,plugin_name); } if(!strcmp(type_name,"VST")){ while(true){ vector_t v = {0}; VECTOR_push_back(&v, "Select plugin file"); VECTOR_push_back(&v, "Use different plugin"); VECTOR_push_back(&v, "Replace with pipe"); int ret = GFX_Message(&v, ("VST Plugin " + QString(plugin_name) + " not found.").toUtf8().constData()); if (ret==0) { QString filename = QFileDialog::getOpenFileName(NULL, plugin_name); QFileInfo info(filename); QString basename = info.fileName(); basename.resize(basename.size()-strlen(VST_SUFFIX)-1); // if(basename==QString(plugin_name) && info.exists()){ VST_add_path(info.dir().path()); PR_init_plugin_types(); return PR_get_plugin_type_by_name(container_name, type_name, plugin_name); //} } else if (ret==1) { SoundPluginType *plugintype = MW_popup_plugin_selector(NULL, 0, 0, false); if (plugintype==NULL) break; else return plugintype; } else break; } }else if(!strcmp(type_name,"Pd") && strcmp(plugin_name, "")){ // type_name doesn't mean anything for already saved files. Without this excpetion, plugins would be replaced by pipes if a pd patch file was renamed. return PR_get_plugin_type_by_name("Pd", ""); }else{ QMessageBox msgBox; msgBox.setText("Plugin " + QString(type_name) + " / " + QString(plugin_name) + " not found. Replacing with a Pipe."); if(!strcmp(type_name,"Ladspa") && getenv("LADSPA_PATH")==NULL) msgBox.setInformativeText("(LADSPA_PATH is not set)"); msgBox.setDefaultButton(QMessageBox::Ok); safeExec(msgBox); } return PR_get_plugin_type_by_name("Pipe","Pipe"); }
vector_t *VECTOR_append(vector_t *v1, vector_t *v2){ int i; for(i=0;i<v2->num_elements;i++) VECTOR_push_back(v1,v2->elements[i]); return v1; }
SoundPluginType *PR_get_plugin_type_by_name(const char *container_name, const char *type_name, const char *plugin_name){ // Compatibility with older songs if (!strcmp(type_name, "Patchbay") && !strcmp(plugin_name, "Patchbay")) plugin_name = "Patchbay 8x8"; for(SoundPluginType *plugin_type : g_plugin_types) if(!strcmp(plugin_type->type_name,type_name)) if(!strcmp(plugin_type->name,plugin_name)) return plugin_type; // check if the container needs to be populated. if (container_name != NULL) for(auto container : g_plugin_type_containers) if (!container->is_populated) if(!strcmp(container->type_name,type_name)) if(!strcmp(container->name,container_name)){ container->populate(container); return PR_get_plugin_type_by_name(container_name, type_name, plugin_name); } // Older songs didn't store vst container names (because there were no containers). Try to set container_name to plugin_name and try again. if(!strcmp(type_name,"VST") && container_name==NULL){ return PR_get_plugin_type_by_name(plugin_name,type_name,plugin_name); } if(!strcmp(type_name,"VST") || !strcmp(type_name,"VST3") || !strcmp(type_name,"AudioUnit")){ while(true){ vector_t v = {}; // c++ way of zero-initialization without getting missing-field-initializers warning. int select_plugin_file = VECTOR_push_back(&v, "Select plugin file"); int use_different_plugin = VECTOR_push_back(&v, "Use different plugin"); int replace_with_pipe = VECTOR_push_back(&v, "Replace with pipe"); (void)replace_with_pipe; // default int ret = GFX_Message(&v, ("VST Plugin " + QString(plugin_name) + " not found.").toUtf8().constData()); if (ret==select_plugin_file) { QString filename; { R_ASSERT(g_radium_runs_custom_exec==false); radium::ScopedExec scopedExec; filename = QFileDialog::getOpenFileName(NULL, plugin_name, QString(), QString(), 0, QFileDialog::DontUseCustomDirectoryIcons | (useNativeFileRequesters() ? (QFileDialog::Option)0 : QFileDialog::DontUseNativeDialog) ); } QFileInfo info(filename); QString basename = info.fileName(); basename.resize(basename.size()-strlen(VST_SUFFIX)-1); // if(basename==QString(plugin_name) && info.exists()){ VST_add_path(info.dir().path()); PR_init_plugin_types(); return PR_get_plugin_type_by_name(container_name, type_name, plugin_name); //} } else if (ret==use_different_plugin) { SoundPluginType *plugintype = MW_popup_plugin_type_selector(); if (plugintype==NULL) break; else return plugintype; } else break; } }else if(!strcmp(type_name,"Pd") && strcmp(plugin_name, "")){ // type_name doesn't mean anything for already saved files. Without this excpetion, plugins would be replaced by pipes if a pd patch file was renamed. return PR_get_plugin_type_by_name("Pd", ""); }else{ MyQMessageBox msgBox; msgBox.setText("Plugin " + QString(type_name) + " / " + QString(plugin_name) + " not found. Replacing with a Pipe."); if(!strcmp(type_name,"Ladspa") && getenv("LADSPA_PATH")==NULL) msgBox.setInformativeText("(LADSPA_PATH is not set)"); EVENTLOG_add_event(strdup(msgBox.text().toUtf8().constData())); msgBox.setDefaultButton(QMessageBox::Ok); safeExec(msgBox); } return PR_get_plugin_type_by_name("Pipe","Pipe"); }