From 4acba194b549c0db35ac7440ddb6b6081d3502cf Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Sat, 14 May 2022 23:53:23 +0200 Subject: [PATCH] - Add a new log system support, - Add LV2 log support, - Move Base & LV2_Base to global, - Remove uneeded *Base pointer aguments, - Code cleanup (to be clompleted) --- datastruct.c | 472 ++++++++++++++++++++++++----------------- datastruct.h | 585 +++++++++++++++++++++++++++++++-------------------- drummer.c | 23 +- drummer.h | 30 ++- lv2_plugin.c | 492 +++++++++++++++++++++++-------------------- lv2_plugin.h | 62 ++++-- 6 files changed, 989 insertions(+), 675 deletions(-) diff --git a/datastruct.c b/datastruct.c index 26498b0..125011c 100644 --- a/datastruct.c +++ b/datastruct.c @@ -12,6 +12,98 @@ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log_Format( char *Out_Fmt, DRT_Log_Type_Id Log_Type_Id, DRT_Log_Level Log_Level, char *Module_Name, char *File_Name, long Line_Id, bool LF_Flag, char *Log_Fmt) +{ + struct timeval cur_timeval; + struct tm *tm_ptr; + + + gettimeofday( &cur_timeval, NULL); + + if( ( tm_ptr = localtime( &( cur_timeval.tv_sec))) == NULL) + { + fprintf( DRG_Base.Log_Stream_Out, "DR_Log: %s: can't convert localtime (%d) !\n", __FILE__, errno); + + return( DRS_KO); + } + + sprintf( Out_Fmt, "%02d/%02d/%02d %02d:%02d:%02d.%04d %3s %03d %-4s %-21s %-4d %s%s", + ( tm_ptr->tm_year - 100), tm_ptr->tm_mon, tm_ptr->tm_mday, tm_ptr->tm_hour, tm_ptr->tm_min, tm_ptr->tm_sec, ( cur_timeval.tv_usec / 100), + DRG_Base.Log_Type_Name_Tab[ Log_Type_Id], Log_Level, Module_Name, File_Name, Line_Id, + Log_Fmt, + ( ( LF_Flag == true) ? "\n" : "")); + + return( DRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_list Args) +{ + int rc; + + + rc = vfprintf( DRG_Base.Log_Stream_Out, Out_Fmt, Args); + + if( rc < 0) + { + fprintf( stderr, "DR_Log: Can't log messages (%d)!!!\n", errno); + return( DRS_KO); + } + + fflush( DRG_Base.Log_Stream_Out); + + return( DRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log( DRT_Log_Type_Id Log_Type_Id, DRT_Log_Level Log_Level, char *Module_Name, char *File_Name, long Line_Id, bool LF_Flag, char *Log_Fmt, ...) +{ + va_list args; + char fmt[255]; + int rc; + DRT_Log_Writer_Ptr log_writer_ptr; + DRT_Status status; + + + if( DR_Log_Format( fmt, Log_Type_Id, Log_Level, Module_Name, File_Name, Line_Id, LF_Flag, Log_Fmt) != DRS_OK) + { + fprintf( stderr, "DR_Log: Can't format log messages (%d)!!!\n", errno); + return( DRS_KO); + } + + va_start( args, Log_Fmt); + + log_writer_ptr = ( ( DRG_Base.Log_Writer_Ptr == NULL) ? &DR_Log_Write : DRG_Base.Log_Writer_Ptr); + + status = ( *log_writer_ptr)( Log_Type_Id, fmt, args); + + va_end( args); + + return( status); +} + + + + + /*----------------------------------------------------------------------------*/ /* */ /*----------------------------------------------------------------------------*/ @@ -314,7 +406,7 @@ NDT_Status DR_Layer_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_N if( Layer_Ptr->Instrument_Ptr->Kit_Ptr->Base_Ptr->Task_Load_Layer_Flag == DRD_TRUE) { - status = DR_Task_Run( Layer_Ptr->Instrument_Ptr->Kit_Ptr->Base_Ptr, DRD_TASK_CMD_LAYER_LOAD, (void *)Layer_Ptr); + status = DR_Task_Run( DRD_TASK_CMD_LAYER_LOAD, (void *)Layer_Ptr); } else { @@ -706,7 +798,7 @@ NDT_Status DR_Instrument_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, if( Instrument_Ptr->Kit_Ptr->Base_Ptr->Task_Load_Instrument_Flag == DRD_TRUE) { - status = DR_Task_Run( Instrument_Ptr->Kit_Ptr->Base_Ptr, DRD_TASK_CMD_INSTRUMENT_LOAD, (void *)Instrument_Ptr); + status = DR_Task_Run( DRD_TASK_CMD_INSTRUMENT_LOAD, (void *)Instrument_Ptr); } else { @@ -1219,7 +1311,7 @@ NDT_Status DR_Kit_Manager( NDT_Root *Root_Ptr, NDT_Index_Id Index_Id, NDT_Nod if( Kit_Ptr->Base_Ptr->Task_Load_Kit_Flag == DRD_TRUE) { - status = DR_Task_Run( Kit_Ptr->Base_Ptr, DRD_TASK_CMD_KIT_LOAD, (void *)Kit_Ptr); + status = DR_Task_Run( DRD_TASK_CMD_KIT_LOAD, (void *)Kit_Ptr); } else { @@ -1341,7 +1433,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr) { DRT_Status status; SNDFILE *sndf_ptr; - DRT_SampleRate samplerate = Layer_Ptr->Instrument_Ptr->Kit_Ptr->Base_Ptr->SampleRate; + DRT_SampleRate samplerate = DRG_Base.SampleRate; // fprintf( stderr, "Loading: [%s]\n", Layer_Ptr->FileName); @@ -1378,7 +1470,7 @@ DRT_Status DR_Layer_Sample_Load( DRT_Layer *Layer_Ptr) if( ( sndf_ptr = sf_open( Layer_Ptr->FileName, SFM_READ, Layer_Ptr->SF_Info_Ptr)) == NULL) { - fprintf( stderr, "Can't open sample file [%s] (%ld)!\n", Layer_Ptr->FileName, (long)sf_strerror( (SNDFILE *)( Layer_Ptr->Sample_Ptr))); + DR_LOG_WARNING_2( "Can't open sample file [%s] (%ld)!", Layer_Ptr->FileName, (long)sf_strerror( (SNDFILE *)( Layer_Ptr->Sample_Ptr))); status = DRS_KO; } else @@ -1669,18 +1761,18 @@ DRT_Status DR_Kit_Add( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit *Kit /* DR_Kit_Id_Find */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_Id Kit_Id) +DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, DRT_Kit_Id Kit_Id) { - DRT_Status status; - NDT_Status nd_status; - DRT_Kit kit_template; + DRT_Status status; + NDT_Status nd_status; + DRT_Kit kit_template; + - kit_template.Id = Kit_Id; kit_template.Logical_Id = DRD_ID_UNKNOWN; kit_template.Name[0] = '\0'; - if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DRG_Base.Kit_DS_Ptr, &kit_template)) != NDS_OK) { fprintf( stderr, "DR_Kit_Id_Find: Find error: (%d)!\n", nd_status); status = DRS_KO; @@ -1709,7 +1801,7 @@ DRT_Status DR_Kit_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_I /* DR_Kit_Logical_Id_Find */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, DRT_Kit_Id Kit_Logical_Id) +DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **Kit_Ptr_Ptr, DRT_Kit_Id Kit_Logical_Id) { DRT_Status status; NDT_Status nd_status; @@ -1720,7 +1812,7 @@ DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, D kit_template.Logical_Id = Kit_Logical_Id; kit_template.Name[0] = '\0'; - if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DRG_Base.Kit_DS_Ptr, &kit_template)) != NDS_OK) { fprintf( stderr, "DR_Kit_Logical_Id_Find: Find error: (%d)!\n", nd_status); status = DRS_KO; @@ -1749,7 +1841,7 @@ DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, D /* DR_Kit_Name_Find */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, char *Kit_Name) +DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, char *Kit_Name) { DRT_Status status; NDT_Status nd_status; @@ -1760,7 +1852,7 @@ DRT_Status DR_Kit_Name_Find( DRT_Kit **Kit_Ptr_Ptr, NDT_Root *DS_Ptr, char * kit_template.Logical_Id = DRD_ID_UNKNOWN; strncpy( kit_template.Name, Kit_Name, DRD_NAME_LEN); - if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DS_Ptr, &kit_template)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Value_Find( (void **)Kit_Ptr_Ptr, DRG_Base.Kit_DS_Ptr, &kit_template)) != NDS_OK) { fprintf( stderr, "DR_Kit_Name_Find: Find error: (%d)!\n", nd_status); status = DRS_KO; @@ -1903,14 +1995,14 @@ DRT_Status DR_XML_Value_Get( char *Value_Ptr, long Max_Len, xmlDocPtr Xml_Do if( xmlXPathNodeSetIsEmpty( nodeset)) { - fprintf( stderr, "[%s] not found!\n", xpath_request); + DR_LOG_WARNING_1( "[%s] not found!", xpath_request); status = DRS_KO; } else { if( ( tmpval_ptr = (char *)xmlNodeListGetString( Xml_Doc, nodeset->nodeTab[0]->xmlChildrenNode, 1)) == NULL) { - fprintf( stderr, "[%s] value not found!\n", xpath_request); + DR_LOG_WARNING_1( "[%s] value not found!", xpath_request); status = DRS_KO; } else @@ -2020,7 +2112,7 @@ DRT_Status DR_XML_Query_Tab_Exec( void *Value_Ptr, xmlDocPtr XML_Doc, xmlXPat /* DR_Kit_Load */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName) +DRT_Status DR_Kit_Load( char *FileName) { DRT_Status status; NDT_Status nd_status; @@ -2047,13 +2139,14 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName) kit_template.Id = DRD_ID_UNKNOWN; kit_template.Logical_Id = DRD_ID_UNKNOWN; kit_template.Status = DRD_LOAD_STATUS_UNLOADED; - kit_template.Base_Ptr = Base_Ptr; + kit_template.Base_Ptr = &DRG_Base; layer_template.Sample_Ptr = NULL; layer_template.Sample_Size = 0; layer_template.SF_Info_Ptr = NULL; - fprintf( stderr, "Loading: [%s]...\n", FileName); +// fprintf( stderr, "Loading: [%s]...\n", FileName); + DR_LOG_INFO_1( "Loading: [%s]...", FileName); if( strlen( FileName) > DRD_FILENAME_LEN) { @@ -2093,7 +2186,7 @@ DRT_Status DR_Kit_Load( DRT_Base *Base_Ptr, char *FileName) { DR_XML_Query_Tab_Exec( &kit_template, xml_doc, xml_xpathCtx, DRD_XML_XPATH_DRUMKIT_BASE_STR, DRG_XML_Query_Tab_Kit); - if( ( status = DR_Kit_Add( &kit_ptr, Base_Ptr->Kit_DS_Ptr, &kit_template)) != DRS_OK) + if( ( status = DR_Kit_Add( &kit_ptr, DRG_Base.Kit_DS_Ptr, &kit_template)) != DRS_OK) { fprintf( stderr, "Can't create a new kit!\n"); } @@ -2186,11 +2279,11 @@ DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr) if( DR_LOAD_STATUS_LOADED_IS( Kit_Ptr)) { - fprintf( stderr, "Loading kit samples: [%s] Skiped!\n", Kit_Ptr->Name); + DR_LOG_INFO_1( "Loading kit samples: [%s] Skiped!", Kit_Ptr->Name); } else { - fprintf( stderr, "Loading kit samples: [%s]!\n", Kit_Ptr->Name); + DR_LOG_INFO_1( "Loading kit samples: [%s]!", Kit_Ptr->Name); if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_LOAD)) != NDS_OK) { @@ -2198,9 +2291,9 @@ DRT_Status DR_Kit_Sample_Load( DRT_Kit *Kit_Ptr) return( DRS_KO); } - if( Kit_Ptr->Base_Ptr->Task_Sync_Kit_Flag == DRD_TRUE) + if( DRG_Base.Task_Sync_Kit_Flag == DRD_TRUE) { - if( DR_Task_Wait( Kit_Ptr->Base_Ptr) != DRS_OK) + if( DR_Task_Wait() != DRS_OK) { printf( "DR_Task_Wait failed (%d)!\n"); return( DRS_KO); @@ -2228,11 +2321,11 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr) if( !DR_LOAD_STATUS_LOADED_IS( Kit_Ptr)) { - fprintf( stderr, "UnLoading kit samples: [%s] Skiped!\n", Kit_Ptr->Name); + DR_LOG_INFO_1( "UnLoading kit samples: [%s] Skiped!", Kit_Ptr->Name); } else { - fprintf( stderr, "UnLoading kit samples: [%s]!\n", Kit_Ptr->Name); + DR_LOG_INFO_1( "UnLoading kit samples: [%s]!", Kit_Ptr->Name); if( ( nd_status = ND_DataStruct_Traverse( Kit_Ptr->Instrument_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Kit_Ptr)) != NDS_OK) { @@ -2254,30 +2347,30 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *Kit_Ptr) /* DR_Kits_Sample_Load */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Sample_Load() { NDT_Status nd_status; - fprintf( stderr, "Loading kits samples!\n"); + DR_LOG_INFO_0( "Loading kits samples!"); - if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_LOAD)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Traverse( DRG_Base.Kit_DS_Ptr, NDD_CMD_SAMPLE_LOAD)) != NDS_OK) { printf( "Cant't load kit samples: ND_DataStruct_Traverse() failed (%d)!\n", nd_status); return( DRS_KO); } - if( Base_Ptr->Task_Sync_Kits_Flag == DRD_TRUE) + if( DRG_Base.Task_Sync_Kits_Flag == DRD_TRUE) { - fprintf( stderr, "Synchronising...\n"); + DR_LOG_INFO_0( "Synchronising..."); - if( DR_Task_Wait( Base_Ptr) != DRS_OK) + if( DR_Task_Wait() != DRS_OK) { fprintf( stderr, "DR_Task_Wait failed (%d)!\n"); return( DRS_KO); } - fprintf( stderr, "Sync done!\n"); + DR_LOG_INFO_0( "Sync done!"); } return( DRS_OK); @@ -2291,14 +2384,14 @@ DRT_Status DR_Kits_Sample_Load( DRT_Base *Base_Ptr) /* DR_Kits_Sample_UnLoad */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Sample_UnLoad() { NDT_Status nd_status; - fprintf( stderr, "UnLoading kits samples!\n"); + DR_LOG_INFO_0( "UnLoading kits samples!"); - if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, Base_Ptr->SampleRate)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Traverse( DRG_Base.Kit_DS_Ptr, NDD_CMD_SAMPLE_UNLOAD, DRG_Base.SampleRate)) != NDS_OK) { printf( "Cant't unload kit samples: ND_DataStruct_Traverse() failed (%d)!\n", nd_status); return( DRS_KO); @@ -2315,7 +2408,7 @@ DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *Base_Ptr) /* DR_Kits_Load */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Load() { DRT_Status status; NDT_Status nd_status; @@ -2341,20 +2434,20 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr) { // printf( "[%s]\n", glob_struct.gl_pathv[i]); - if( ( status = DR_Kit_Load( Base_Ptr, glob_struct.gl_pathv[i])) != DRS_OK) + if( ( status = DR_Kit_Load( glob_struct.gl_pathv[i])) != DRS_OK) { fprintf( stderr, "Can't load kit [%s]!\n", glob_struct.gl_pathv[i]); } } - if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_ID_REFRESH, &count)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Traverse( DRG_Base.Kit_DS_Ptr, NDD_CMD_ID_REFRESH, &count)) != NDS_OK) { printf( "Can't refresh kit id: ND_DataStruct_Traverse() failed (%d)!\n", nd_status); status = DRS_KO; } else { - if( ( nd_status = ND_DataStruct_Convert( Base_Ptr->Kit_DS_Ptr, DRG_Kit_DS_Index_Tab_Final)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Convert( DRG_Base.Kit_DS_Ptr, DRG_Kit_DS_Index_Tab_Final)) != NDS_OK) { fprintf( stderr, "ND_DataStruct_Convert() failed (%d)!\n", status); status = DRS_KO; @@ -2368,28 +2461,28 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr) globfree( &glob_struct); -// DR_Kits_Dump( Base_Ptr); +// DR_Kits_Dump(); -// Base_Ptr->SampleRate=44100; +// DRG_Base.SampleRate=44100; /* status = DR_Layer_Sample_Load( (DRT_Layer *)( ((DRT_Instrument *)( - ((DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value)) + ((DRT_Kit *)(DRG_Base.Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value)) ->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value)) ->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), - (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), Base_Ptr->SampleRate); + (DRT_Kit *)( DRG_Base.Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), DRG_Base.SampleRate); */ /* - if( Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head != NULL) + if( DRG_Base.Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head != NULL) { - status = DR_Kit_Sample_Load( (DRT_Kit *)(Base_Ptr->Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), - Base_Ptr->SampleRate); + status = DR_Kit_Sample_Load( (DRT_Kit *)(DRG_Base.Kit_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head->Value), + DRG_Base.SampleRate); } */ -// status = DR_Kits_Sample_Load( Base_Ptr); +// status = DR_Kits_Sample_Load(); return( status); } @@ -2402,7 +2495,7 @@ DRT_Status DR_Kits_Load( DRT_Base *Base_Ptr) /* DR_Kits_Stats_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Stats_Dump( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Stats_Dump() { NDT_Status nd_status; DRT_Id kit_count = 0; @@ -2411,13 +2504,13 @@ DRT_Status DR_Kits_Stats_Dump( DRT_Base *Base_Ptr) DRT_Id sample_count = 0; - if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_STATS_GET, &kit_count, &instrument_count, &layer_count, &sample_count)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Traverse( DRG_Base.Kit_DS_Ptr, NDD_CMD_STATS_GET, &kit_count, &instrument_count, &layer_count, &sample_count)) != NDS_OK) { printf( "Can't compute stats: ND_DataStruct_Traverse() failed (%d)!\n", nd_status); return( DRS_KO); } - fprintf( stderr, "Number of Kits: (%ld) Number of Instruments: (%ld) Number of Layers: (%ld) Number of Loaded Samples: (%ld)\n", kit_count, instrument_count, layer_count, sample_count); + DR_LOG_INFO_4( "Number of Kits: (%ld) Number of Instruments: (%ld) Number of Layers: (%ld) Number of Loaded Samples: (%ld)", kit_count, instrument_count, layer_count, sample_count); return( DRS_OK); } @@ -2430,24 +2523,24 @@ DRT_Status DR_Kits_Stats_Dump( DRT_Base *Base_Ptr) /* DR_Kits_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Dump() { NDT_Status nd_status; DRT_Kit_Id count = 0; fprintf( stderr, "\n"); - fprintf( stderr, "Sample Rate: (%d)\n", Base_Ptr->SampleRate); + fprintf( stderr, "Sample Rate: (%d)\n", DRG_Base.SampleRate); fprintf( stderr, "DrumKit List:\n"); - if( ( nd_status = ND_DataStruct_Value_Print( stderr, Base_Ptr->Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Value_Print( stderr, DRG_Base.Kit_DS_Ptr, NDD_RECURSIVE_MODE_PARENT_CHILD, 0, 0, &count)) != NDS_OK) { printf( "Can't dump kits: ND_DataStruct_Value_Print() failed (%d)!\n", nd_status); return( DRS_KO); } - if( DR_Kits_Stats_Dump( Base_Ptr) != DRS_OK) + if( DR_Kits_Stats_Dump() != DRS_OK) { return( DRS_KO); } @@ -2463,14 +2556,14 @@ DRT_Status DR_Kits_Dump( DRT_Base *Base_Ptr) /* DR_Kits_Graph_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Graph_Dump( DRT_Base *Base_Ptr) +DRT_Status DR_Kits_Graph_Dump() { NDT_Status nd_status; fprintf( stderr, "digraph G\n{\n node [shape = record];\n\n"); - if( ( nd_status = ND_DataStruct_Traverse( Base_Ptr->Kit_DS_Ptr, NDD_CMD_GRAPH_PRINT)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Traverse( DRG_Base.Kit_DS_Ptr, NDD_CMD_GRAPH_PRINT)) != NDS_OK) { printf( "Can't dump graph kits: ND_DataStruct_Value_Print() failed (%d)!\n", nd_status); return( DRS_KO); @@ -2489,7 +2582,7 @@ DRT_Status DR_Kits_Graph_Dump( DRT_Base *Base_Ptr) /* DR_Task_Tread */ /*----------------------------------------------------------------------------*/ -static void *DR_Task_Thread( DRT_Base *Base_Ptr) +static void *DR_Task_Thread() { pthread_t my_thread_id = pthread_self(); short task_id; @@ -2497,9 +2590,9 @@ static void *DR_Task_Thread( DRT_Base *Base_Ptr) // fprintf( stderr, "Start Task Thread (%d)!\n", my_thread_id); - for( task_id = 0; ( Base_Ptr->Task_Tab[task_id].Thread != my_thread_id) && ( task_id < Base_Ptr->Task_Number); task_id++); + for( task_id = 0; ( DRG_Base.Task_Tab[task_id].Thread != my_thread_id) && ( task_id < DRG_Base.Task_Number); task_id++); - if( task_id == Base_Ptr->Task_Number) + if( task_id == DRG_Base.Task_Number) { fprintf( stderr, "Can't find my id: (%d)!\n", my_thread_id); } @@ -2507,18 +2600,18 @@ static void *DR_Task_Thread( DRT_Base *Base_Ptr) { // fprintf( stderr, "I'm: (%02d)!\n", task_id); - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); do { - switch( Base_Ptr->Task_Tab[task_id].Command) + switch( DRG_Base.Task_Tab[task_id].Command) { case DRD_TASK_CMD_TASK_SPAWN: { // fprintf( stderr, "I'm: (%02d) Spawning!\n", task_id); - Base_Ptr->Task_Tab[task_id].Status = DRD_TASK_STATUS_RUNNING; - Base_Ptr->Task_Tab[task_id].Count = 0L; + DRG_Base.Task_Tab[task_id].Status = DRD_TASK_STATUS_RUNNING; + DRG_Base.Task_Tab[task_id].Count = 0L; break; } @@ -2526,9 +2619,9 @@ static void *DR_Task_Thread( DRT_Base *Base_Ptr) { // fprintf( stderr, "I'm: (%02d) Killing!\n", task_id); - Base_Ptr->Task_Tab[task_id].Status = DRD_TASK_STATUS_KILLED; + DRG_Base.Task_Tab[task_id].Status = DRD_TASK_STATUS_KILLED; - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); break; } @@ -2536,61 +2629,61 @@ static void *DR_Task_Thread( DRT_Base *Base_Ptr) case DRD_TASK_CMD_LAYER_LOAD: case DRD_TASK_CMD_KIT_LOAD: { - Base_Ptr->Task_Tab[task_id].Status = DRD_TASK_STATUS_RUNNING; -// Base_Ptr->Task_Count_Waiting--; + DRG_Base.Task_Tab[task_id].Status = DRD_TASK_STATUS_RUNNING; +// DRG_Base.Task_Count_Waiting--; - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); - switch( Base_Ptr->Task_Tab[task_id].Command) + switch( DRG_Base.Task_Tab[task_id].Command) { case DRD_TASK_CMD_LAYER_LOAD: { - DR_Layer_Sample_Load( (DRT_Layer *)( Base_Ptr->Task_Tab[task_id].Target_Ptr)); + DR_Layer_Sample_Load( (DRT_Layer *)( DRG_Base.Task_Tab[task_id].Target_Ptr)); break; } case DRD_TASK_CMD_INSTRUMENT_LOAD: { - DR_Instrument_Sample_Load( (DRT_Instrument *)( Base_Ptr->Task_Tab[task_id].Target_Ptr)); + DR_Instrument_Sample_Load( (DRT_Instrument *)( DRG_Base.Task_Tab[task_id].Target_Ptr)); break; } case DRD_TASK_CMD_KIT_LOAD: { - DR_Kit_Sample_Load( (DRT_Kit *)( Base_Ptr->Task_Tab[task_id].Target_Ptr)); + DR_Kit_Sample_Load( (DRT_Kit *)( DRG_Base.Task_Tab[task_id].Target_Ptr)); break; } } - Base_Ptr->Task_Tab[task_id].Count++; + DRG_Base.Task_Tab[task_id].Count++; - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); break; } default: { - printf( "DR_Task_Thread called with an undefined command [%d] [%s]\n", Base_Ptr->Task_Tab[task_id].Command, DR_TASK_CMD_ASCII_GET( &(Base_Ptr->Task_Tab[task_id]))); + printf( "DR_Task_Thread called with an undefined command [%d] [%s]\n", DRG_Base.Task_Tab[task_id].Command, DR_TASK_CMD_ASCII_GET( &(DRG_Base.Task_Tab[task_id]))); } } - if( DR_TASK_STATUS_RUNNING_IS( &( Base_Ptr->Task_Tab[task_id]))) + if( DR_TASK_STATUS_RUNNING_IS( &( DRG_Base.Task_Tab[task_id]))) { // fprintf( stderr, "I'm: (%02d) Waiting!\n", task_id); - Base_Ptr->Task_Tab[task_id].Status = DRD_TASK_STATUS_WAITING; - Base_Ptr->Task_Tab[task_id].Command = DRD_TASK_CMD_NONE; - Base_Ptr->Task_Tab[task_id].Target_Ptr = NULL; - Base_Ptr->Task_Count_Waiting++; + DRG_Base.Task_Tab[task_id].Status = DRD_TASK_STATUS_WAITING; + DRG_Base.Task_Tab[task_id].Command = DRD_TASK_CMD_NONE; + DRG_Base.Task_Tab[task_id].Target_Ptr = NULL; + DRG_Base.Task_Count_Waiting++; - pthread_cond_signal( &( Base_Ptr->Task_Cond)); - pthread_cond_wait( &( Base_Ptr->Task_Tab[task_id].Cond), &( Base_Ptr->Task_Mutex)); + pthread_cond_signal( &( DRG_Base.Task_Cond)); + pthread_cond_wait( &( DRG_Base.Task_Tab[task_id].Cond), &( DRG_Base.Task_Mutex)); } } - while( ! DR_TASK_STATUS_KILLED_IS( &( Base_Ptr->Task_Tab[task_id]))); + while( ! DR_TASK_STATUS_KILLED_IS( &( DRG_Base.Task_Tab[task_id]))); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); // fprintf( stderr, "I'm: (%02d) and killed!\n", task_id); } @@ -2606,28 +2699,28 @@ static void *DR_Task_Thread( DRT_Base *Base_Ptr) /* DR_Task_Id_Run */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Id_Run( DRT_Task_Id Task_Id, DRT_Base *Base_Ptr, DRT_Task_Command Command, void *Target_Ptr) +DRT_Status DR_Task_Id_Run( DRT_Task_Id Task_Id, DRT_Task_Command Command, void *Target_Ptr) { DRT_Status status; -// pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); +// pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - if( !DR_TASK_STATUS_WAITING_IS( &( Base_Ptr->Task_Tab[Task_Id]))) + if( !DR_TASK_STATUS_WAITING_IS( &( DRG_Base.Task_Tab[Task_Id]))) { - fprintf( stderr, "Task_Id_Run: Inconsistent task status: [%s]!\n", DR_TASK_STATUS_ASCII_GET( &( Base_Ptr->Task_Tab[Task_Id]))); -// pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + fprintf( stderr, "Task_Id_Run: Inconsistent task status: [%s]!\n", DR_TASK_STATUS_ASCII_GET( &( DRG_Base.Task_Tab[Task_Id]))); +// pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); status = DRS_KO; } else { - Base_Ptr->Task_Tab[Task_Id].Command = Command; - Base_Ptr->Task_Tab[Task_Id].Target_Ptr = Target_Ptr; - Base_Ptr->Task_Count_Waiting--; + DRG_Base.Task_Tab[Task_Id].Command = Command; + DRG_Base.Task_Tab[Task_Id].Target_Ptr = Target_Ptr; + DRG_Base.Task_Count_Waiting--; - pthread_cond_signal( &( Base_Ptr->Task_Tab[Task_Id].Cond)); -// pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_cond_signal( &( DRG_Base.Task_Tab[Task_Id].Cond)); +// pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); status = DRS_OK; @@ -2644,17 +2737,17 @@ DRT_Status DR_Task_Id_Run( DRT_Task_Id Task_Id, DRT_Base *Base_Ptr, DRT_Task_ /* DR_Task_Kill */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Id_Kill( DRT_Task_Id Task_Id, DRT_Base *Base_Ptr) +DRT_Status DR_Task_Id_Kill( DRT_Task_Id Task_Id) { DRT_Status status; - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - if( !DR_TASK_STATUS_WAITING_IS( &( Base_Ptr->Task_Tab[Task_Id]))) + if( !DR_TASK_STATUS_WAITING_IS( &( DRG_Base.Task_Tab[Task_Id]))) { - fprintf( stderr, "Task_Kill: Inconsistent task status: [%s]!\n", DR_TASK_STATUS_ASCII_GET( &( Base_Ptr->Task_Tab[Task_Id]))); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + fprintf( stderr, "Task_Kill: Inconsistent task status: [%s]!\n", DR_TASK_STATUS_ASCII_GET( &( DRG_Base.Task_Tab[Task_Id]))); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); status = DRS_KO; } @@ -2662,11 +2755,11 @@ DRT_Status DR_Task_Id_Kill( DRT_Task_Id Task_Id, DRT_Base *Base_Ptr) { // fprintf( stderr, "Killing task id: (%d)!\n", Task_Id); - Base_Ptr->Task_Tab[Task_Id].Command = DRD_TASK_CMD_TASK_KILL; - Base_Ptr->Task_Tab[Task_Id].Target_Ptr = NULL; + DRG_Base.Task_Tab[Task_Id].Command = DRD_TASK_CMD_TASK_KILL; + DRG_Base.Task_Tab[Task_Id].Target_Ptr = NULL; - pthread_cond_signal( &( Base_Ptr->Task_Tab[Task_Id].Cond)); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_cond_signal( &( DRG_Base.Task_Tab[Task_Id].Cond)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); status = DRS_OK; } @@ -2682,7 +2775,7 @@ DRT_Status DR_Task_Id_Kill( DRT_Task_Id Task_Id, DRT_Base *Base_Ptr) /* DR_Task_Run */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void *Target_Ptr) +DRT_Status DR_Task_Run( DRT_Task_Command Command, void *Target_Ptr) { DRT_Task_Id task_id; DRT_Boolean found = DRD_FALSE; @@ -2690,39 +2783,39 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * // fprintf( stderr, "Task Run: Called!\n"); - Base_Ptr->Task_Count_Run++; + DRG_Base.Task_Count_Run++; while( found != DRD_TRUE) { - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - if( Base_Ptr->Task_Count_Waiting > 0) + if( DRG_Base.Task_Count_Waiting > 0) { -// while( ( task_id < Base_Ptr->Task_Number) && ( found != DRD_TRUE)) - for( task_id = 0; ( task_id < Base_Ptr->Task_Number) && ( found != DRD_TRUE); task_id++) +// while( ( task_id < DRG_Base.Task_Number) && ( found != DRD_TRUE)) + for( task_id = 0; ( task_id < DRG_Base.Task_Number) && ( found != DRD_TRUE); task_id++) { - if( DR_TASK_STATUS_WAITING_IS( &( Base_Ptr->Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( Base_Ptr->Task_Tab[task_id]))) + if( DR_TASK_STATUS_WAITING_IS( &( DRG_Base.Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( DRG_Base.Task_Tab[task_id]))) { -// pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); +// pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); // fprintf( stderr, "Task Run: Found (%d)!\n", task_id); - if( DR_Task_Id_Run( task_id, Base_Ptr, Command, Target_Ptr) != DRS_OK) + if( DR_Task_Id_Run( task_id, Command, Target_Ptr) != DRS_OK) { fprintf( stderr, "Can't run task !\n"); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); return( DRS_KO); } - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); found = DRD_TRUE; } } if( found != DRD_TRUE) { - DR_Tasks_Dump( Base_Ptr); - Base_Ptr->Task_Count_FakeWU++; + DR_Tasks_Dump(); + DRG_Base.Task_Count_FakeWU++; } } @@ -2730,10 +2823,10 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * { // fprintf( stderr, "Task Run: Sleeping!\n"); - Base_Ptr->Task_Count_Sleep++; + DRG_Base.Task_Count_Sleep++; - pthread_cond_wait( &( Base_Ptr->Task_Cond), &( Base_Ptr->Task_Mutex)); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_cond_wait( &( DRG_Base.Task_Cond), &( DRG_Base.Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); } } @@ -2741,7 +2834,7 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * } /* -DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void *Target_Ptr) +DRT_Status DR_Task_Run( DRT_Task_Command Command, void *Target_Ptr) { DRT_Task_Id task_id; DRT_Boolean found = DRD_FALSE; @@ -2749,30 +2842,30 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * // fprintf( stderr, "Task Run: Called!\n"); - Base_Ptr->Task_Count_Run++; + DRG_Base.Task_Count_Run++; while( found != DRD_TRUE) { task_id = 0; - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - while( ( task_id < Base_Ptr->Task_Number) && ( found != DRD_TRUE)) + while( ( task_id < DRG_Base.Task_Number) && ( found != DRD_TRUE)) { - if( DR_TASK_STATUS_WAITING_IS( &( Base_Ptr->Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( Base_Ptr->Task_Tab[task_id]))) + if( DR_TASK_STATUS_WAITING_IS( &( DRG_Base.Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( DRG_Base.Task_Tab[task_id]))) { -// pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); +// pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); // fprintf( stderr, "Task Run: Found (%d)!\n", task_id); - if( DR_Task_Id_Run( task_id, Base_Ptr, Command, Target_Ptr) != DRS_OK) + if( DR_Task_Id_Run( task_id, Command, Target_Ptr) != DRS_OK) { fprintf( stderr, "Can't run task !\n"); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); return( DRS_KO); } - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); found = DRD_TRUE; } @@ -2783,10 +2876,10 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * { // fprintf( stderr, "Task Run: Sleeping!\n"); - Base_Ptr->Task_Count_Sleep++; + DRG_Base.Task_Count_Sleep++; - pthread_cond_wait( &( Base_Ptr->Task_Cond), &( Base_Ptr->Task_Mutex)); - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_cond_wait( &( DRG_Base.Task_Cond), &( DRG_Base.Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); } } @@ -2801,35 +2894,35 @@ DRT_Status DR_Task_Run( DRT_Base *Base_Ptr, DRT_Task_Command Command, void * /* DR_Task_Wait */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Wait( DRT_Base *Base_Ptr) +DRT_Status DR_Task_Wait() { DRT_Task_Id task_id, count = 0; - pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - while( count < Base_Ptr->Task_Number) + while( count < DRG_Base.Task_Number) { task_id = 0; count = 0; - for( task_id = 0; task_id < Base_Ptr->Task_Number; task_id++) + for( task_id = 0; task_id < DRG_Base.Task_Number; task_id++) { - if( DR_TASK_STATUS_WAITING_IS( &( Base_Ptr->Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( Base_Ptr->Task_Tab[task_id]))) + if( DR_TASK_STATUS_WAITING_IS( &( DRG_Base.Task_Tab[task_id])) && DR_TASK_CMD_NONE_IS( &( DRG_Base.Task_Tab[task_id]))) { count++; } } - if( count < Base_Ptr->Task_Number) + if( count < DRG_Base.Task_Number) { -// DR_Tasks_Dump( Base_Ptr); +// DR_Tasks_Dump(); - pthread_cond_wait( &( Base_Ptr->Task_Cond), &( Base_Ptr->Task_Mutex)); + pthread_cond_wait( &( DRG_Base.Task_Cond), &( DRG_Base.Task_Mutex)); } } - pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); + pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); return( DRS_OK); } @@ -2842,26 +2935,26 @@ DRT_Status DR_Task_Wait( DRT_Base *Base_Ptr) /* DR_Tasks_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Tasks_Dump( DRT_Base *Base_Ptr) +DRT_Status DR_Tasks_Dump() { DRT_Task_Id task_id; -// pthread_mutex_lock( &( Base_Ptr->Task_Mutex)); +// pthread_mutex_lock( &( DRG_Base.Task_Mutex)); - fprintf( stderr, "Task Number: (%d) Task Load Layer: [%s] Task Load Instrument: [%s] Task Load Kit: [%s] Task Sync Kit: [%s] Task Sync Kits: [%s]\n", - Base_Ptr->Task_Number, DR_BOOLEAN_VALUE_ASCII_GET( Base_Ptr->Task_Load_Layer_Flag), DR_BOOLEAN_VALUE_ASCII_GET( Base_Ptr->Task_Load_Instrument_Flag), DR_BOOLEAN_VALUE_ASCII_GET(Base_Ptr->Task_Load_Kit_Flag), DR_BOOLEAN_VALUE_ASCII_GET(Base_Ptr->Task_Sync_Kit_Flag), DR_BOOLEAN_VALUE_ASCII_GET(Base_Ptr->Task_Sync_Kits_Flag)); - fprintf( stderr, "Task Tab:\n"); + DR_LOG_INFO_6( "Task Number: (%d) Task Load Layer: [%s] Task Load Instrument: [%s] Task Load Kit: [%s] Task Sync Kit: [%s] Task Sync Kits: [%s]", + DRG_Base.Task_Number, DR_BOOLEAN_VALUE_ASCII_GET( DRG_Base.Task_Load_Layer_Flag), DR_BOOLEAN_VALUE_ASCII_GET( DRG_Base.Task_Load_Instrument_Flag), DR_BOOLEAN_VALUE_ASCII_GET( DRG_Base.Task_Load_Kit_Flag), DR_BOOLEAN_VALUE_ASCII_GET( DRG_Base.Task_Sync_Kit_Flag), DR_BOOLEAN_VALUE_ASCII_GET( DRG_Base.Task_Sync_Kits_Flag)); + DR_LOG_INFO_0( "Task Tab:"); - for( task_id = 0; task_id < Base_Ptr->Task_Number; task_id++) + for( task_id = 0; task_id < DRG_Base.Task_Number; task_id++) { - fprintf( stderr, " Id: (%02d) Status: [%s] Thread: (%ld) Command: [%s] Target Ptr: [%lx] Count: (%ld)\n", - task_id, DR_TASK_STATUS_ASCII_GET( &(Base_Ptr->Task_Tab[task_id])), (long)( Base_Ptr->Task_Tab[task_id].Thread), DR_TASK_CMD_ASCII_GET( &( Base_Ptr->Task_Tab[task_id])), Base_Ptr->Task_Tab[task_id].Target_Ptr, Base_Ptr->Task_Tab[task_id].Count); + DR_LOG_INFO_6( " Id: (%02d) Status: [%s] Thread: (%ld) Command: [%s] Target Ptr: [%lx] Count: (%ld)", + task_id, DR_TASK_STATUS_ASCII_GET( &( DRG_Base.Task_Tab[task_id])), (long)( DRG_Base.Task_Tab[task_id].Thread), DR_TASK_CMD_ASCII_GET( &( DRG_Base.Task_Tab[task_id])), DRG_Base.Task_Tab[task_id].Target_Ptr, DRG_Base.Task_Tab[task_id].Count); } - fprintf( stderr, "Task Count Waiting: (%ld) Task Count Run: (%ld) Task Count Sleep: (%ld) Task Count FakeWU: (%ld)\n", Base_Ptr->Task_Count_Waiting, Base_Ptr->Task_Count_Run, Base_Ptr->Task_Count_Sleep, Base_Ptr->Task_Count_FakeWU); + DR_LOG_INFO_4( "Task Count Waiting: (%ld) Task Count Run: (%ld) Task Count Sleep: (%ld) Task Count FakeWU: (%ld)", DRG_Base.Task_Count_Waiting, DRG_Base.Task_Count_Run, DRG_Base.Task_Count_Sleep, DRG_Base.Task_Count_FakeWU); -// pthread_mutex_unlock( &( Base_Ptr->Task_Mutex)); +// pthread_mutex_unlock( &( DRG_Base.Task_Mutex)); return( DRS_OK); } @@ -2874,63 +2967,66 @@ DRT_Status DR_Tasks_Dump( DRT_Base *Base_Ptr) /* DR_DataStruct_Init */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, DRT_SampleRate SampleRate, DRT_Task_Id Task_Number) +DRT_Status DR_DataStruct_Init( DRT_Log_Writer_Ptr Log_Writer_Ptr, DRT_SampleRate SampleRate, DRT_Task_Id Task_Number) { NDT_Status nd_status; DRT_Task_Id task_id; + DRG_Base.Log_Stream_Out = stderr; + DRG_Base.Log_Writer_Ptr = Log_Writer_Ptr; + if( ( nd_status = ND_Library_Open( NDD_TRUE)) != NDS_OK) { fprintf( stderr, "Can't open node library (%d)!\n", nd_status); return( DRS_KO); } - if( ( nd_status = ND_DataStruct_Open( &(Base_Ptr->Kit_DS_Ptr), DRD_KIT_DS_INDEX_NB, DRG_Kit_DS_Index_Tab_Initial, "Kit_Manager", DR_Kit_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Open( &( DRG_Base.Kit_DS_Ptr), DRD_KIT_DS_INDEX_NB, DRG_Kit_DS_Index_Tab_Initial, "Kit_Manager", DR_Kit_Manager, NULL, NULL, NULL, NULL, NDD_TRUE, NULL)) != NDS_OK) { fprintf( stderr, "Kit_DS: ND_DataStruct_Open() failed (%d)!\n", nd_status); return( DRS_KO); } - Base_Ptr->SampleRate = SampleRate; + DRG_Base.SampleRate = SampleRate; /* - Base_Ptr->Velocity_Ignore_Flag = DRD_VELOCITY_IGNORE_FLAG_DEFAULT; - Base_Ptr->Note_Off_Ignore_Flag = DRD_NOTE_OFF_IGNORE_FLAG_DEFAULT; - Base_Ptr->Velocity_Ignore_Note = DRD_VELOCITY_IGNORE_NOTE_DEFAULT; - Base_Ptr->Note_Off_Ignore_Note = DRD_NOTE_OFF_IGNORE_NOTE_DEFAULT; + DRG_Base.Velocity_Ignore_Flag = DRD_VELOCITY_IGNORE_FLAG_DEFAULT; + DRG_Base.Note_Off_Ignore_Flag = DRD_NOTE_OFF_IGNORE_FLAG_DEFAULT; + DRG_Base.Velocity_Ignore_Note = DRD_VELOCITY_IGNORE_NOTE_DEFAULT; + DRG_Base.Note_Off_Ignore_Note = DRD_NOTE_OFF_IGNORE_NOTE_DEFAULT; */ - Base_Ptr->Channel_Id_Ptr = NULL; - Base_Ptr->Base_Note_Ptr = NULL; - Base_Ptr->Velocity_Ignore_Note_Ptr = NULL; - Base_Ptr->Note_Off_Ignore_Note_Ptr = NULL; - Base_Ptr->Velocity_Ignore_Flag_Ptr = NULL; - Base_Ptr->Note_Off_Ignore_Flag_Ptr = NULL; - Base_Ptr->Task_Number = Task_Number; - Base_Ptr->Task_Load_Layer_Flag = DRD_TASK_LOAD_LAYER_DEFAULT; - Base_Ptr->Task_Load_Instrument_Flag = DRD_TASK_LOAD_INSTRUMENT_DEFAULT; - Base_Ptr->Task_Load_Kit_Flag = DRD_TASK_LOAD_KIT_DEFAULT; - Base_Ptr->Task_Sync_Kit_Flag = DRD_TASK_SYNC_KIT_DEFAULT; - Base_Ptr->Task_Sync_Kits_Flag = DRD_TASK_SYNC_KITS_DEFAULT; - Base_Ptr->Task_Count_Waiting = 0L; - Base_Ptr->Task_Count_Run = 0L; - Base_Ptr->Task_Count_Sleep = 0L; - Base_Ptr->Task_Count_FakeWU = 0L; + DRG_Base.Channel_Id_Ptr = NULL; + DRG_Base.Base_Note_Ptr = NULL; + DRG_Base.Velocity_Ignore_Note_Ptr = NULL; + DRG_Base.Note_Off_Ignore_Note_Ptr = NULL; + DRG_Base.Velocity_Ignore_Flag_Ptr = NULL; + DRG_Base.Note_Off_Ignore_Flag_Ptr = NULL; + DRG_Base.Task_Number = Task_Number; + DRG_Base.Task_Load_Layer_Flag = DRD_TASK_LOAD_LAYER_DEFAULT; + DRG_Base.Task_Load_Instrument_Flag = DRD_TASK_LOAD_INSTRUMENT_DEFAULT; + DRG_Base.Task_Load_Kit_Flag = DRD_TASK_LOAD_KIT_DEFAULT; + DRG_Base.Task_Sync_Kit_Flag = DRD_TASK_SYNC_KIT_DEFAULT; + DRG_Base.Task_Sync_Kits_Flag = DRD_TASK_SYNC_KITS_DEFAULT; + DRG_Base.Task_Count_Waiting = 0L; + DRG_Base.Task_Count_Run = 0L; + DRG_Base.Task_Count_Sleep = 0L; + DRG_Base.Task_Count_FakeWU = 0L; - if( ( Base_Ptr->Task_Tab = malloc( sizeof( DRT_Task) * Task_Number)) == NULL) + if( ( DRG_Base.Task_Tab = malloc( sizeof( DRT_Task) * Task_Number)) == NULL) { fprintf( stderr, "Can't allocate task tab!\n"); return( NDS_KO); } else { - if( pthread_mutex_init( &( Base_Ptr->Task_Mutex), 0)) + if( pthread_mutex_init( &( DRG_Base.Task_Mutex), 0)) { fprintf( stderr, "Could not initialize global task mutex!\n"); return( NDS_KO); } - if( pthread_cond_init( &( Base_Ptr->Task_Cond), 0)) + if( pthread_cond_init( &( DRG_Base.Task_Cond), 0)) { fprintf( stderr, "Could not initialize global task cond!\n"); return( NDS_KO); @@ -2938,18 +3034,18 @@ DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, DRT_SampleRate SampleRate, for( task_id = 0; task_id < Task_Number; task_id++) { - Base_Ptr->Task_Tab[task_id].Status = DRD_TASK_STATUS_UNSPAWNED; - Base_Ptr->Task_Tab[task_id].Command = DRD_TASK_CMD_TASK_SPAWN; - Base_Ptr->Task_Tab[task_id].Target_Ptr = NULL; - Base_Ptr->Task_Tab[task_id].Count = 0L; + DRG_Base.Task_Tab[task_id].Status = DRD_TASK_STATUS_UNSPAWNED; + DRG_Base.Task_Tab[task_id].Command = DRD_TASK_CMD_TASK_SPAWN; + DRG_Base.Task_Tab[task_id].Target_Ptr = NULL; + DRG_Base.Task_Tab[task_id].Count = 0L; - if( pthread_cond_init( &( Base_Ptr->Task_Tab[task_id].Cond), 0)) + if( pthread_cond_init( &( DRG_Base.Task_Tab[task_id].Cond), 0)) { fprintf( stderr, "Could not initialize task cond!\n"); return( NDS_KO); } - if( pthread_create( &(Base_Ptr->Task_Tab[task_id].Thread), 0, (void * (*)(void *))DR_Task_Thread, Base_Ptr)) + if( pthread_create( &(DRG_Base.Task_Tab[task_id].Thread), 0, (void * (*)(void *))DR_Task_Thread, NULL)) { fprintf( stderr, "Could not initialize task thread!\n"); return( NDS_KO); @@ -2968,15 +3064,15 @@ DRT_Status DR_DataStruct_Init( DRT_Base *Base_Ptr, DRT_SampleRate SampleRate, /* DR_DataStruct_DeInit */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr) +DRT_Status DR_DataStruct_DeInit() { NDT_Status nd_status; DRT_Task_Id task_id; - for( task_id = 0; task_id < Base_Ptr->Task_Number; task_id++) + for( task_id = 0; task_id < DRG_Base.Task_Number; task_id++) { - if( DR_Task_Id_Kill( task_id, Base_Ptr) != DRS_OK) + if( DR_Task_Id_Kill( task_id) != DRS_OK) { printf( "Can't kill task: (%d)!\n", task_id); return( NDS_KO); @@ -2985,7 +3081,7 @@ DRT_Status DR_DataStruct_DeInit( DRT_Base *Base_Ptr) // sleep(5); - if( ( nd_status = ND_DataStruct_Close( Base_Ptr->Kit_DS_Ptr)) != NDS_OK) + if( ( nd_status = ND_DataStruct_Close( DRG_Base.Kit_DS_Ptr)) != NDS_OK) { printf( "Can't close Kit_DS (%d)!\n", nd_status); return( DRS_KO); diff --git a/datastruct.h b/datastruct.h index 3217470..4a7900c 100644 --- a/datastruct.h +++ b/datastruct.h @@ -24,6 +24,8 @@ typedef struct DRT_Kit DRT_Kit; /* Global definitions */ /*----------------------------------------------------------------------------*/ +#define DRD_LOG_WRITER_DEFAULT DR_Log_Write + #define DRD_CHANNEL_ID_DEFAULT 10 #define DRD_BASE_NOTE_DEFAULT 36 #define DRD_VELOCITY_IGNORE_NOTE_DEFAULT 24 @@ -42,7 +44,70 @@ typedef struct DRT_Kit DRT_Kit; /*----------------------------------------------------------------------------*/ -/* DSl definitions */ +/* Log Definitions */ +/*----------------------------------------------------------------------------*/ + +#define DRD_LOG_TYPE_NB 5 + +typedef short DRT_Log_Type_Id; + +#define DRD_LOG_TYPE_ID_UNKNOWN ( DRT_Log_Type_Id) 0 +#define DRD_LOG_TYPE_ID_TRACE ( DRT_Log_Type_Id) 1 +#define DRD_LOG_TYPE_ID_INFO ( DRT_Log_Type_Id) 2 +#define DRD_LOG_TYPE_ID_WARNING ( DRT_Log_Type_Id) 3 +#define DRD_LOG_TYPE_ID_ERROR ( DRT_Log_Type_Id) 4 + +typedef char *DRT_Log_Type_Name; + +#define DRD_LOG_TYPE_NAME_UNKNOWN ( DRT_Log_Type_Name) "???" +#define DRD_LOG_TYPE_NAME_TRACE ( DRT_Log_Type_Name) "TRA" +#define DRD_LOG_TYPE_NAME_INFO ( DRT_Log_Type_Name) "INF" +#define DRD_LOG_TYPE_NAME_WARNING ( DRT_Log_Type_Name) "WRN" +#define DRD_LOG_TYPE_NAME_ERROR ( DRT_Log_Type_Name) "ERR" + +typedef short DRT_Log_Level; + +#define DRD_LOG_LEVEL_UNKNOWN ( DRT_Log_Level) 0 +#define DRD_LOG_LEVEL_DEFAULT ( DRT_Log_Level) 1 + +#define DR_LOG_TRACE_0( Level, Fmt) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt)) +#define DR_LOG_TRACE_1( Level, Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1)) +#define DR_LOG_TRACE_2( Level, Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2)) +#define DR_LOG_TRACE_3( Level, Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3)) +#define DR_LOG_TRACE_4( Level, Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) +#define DR_LOG_TRACE_5( Level, Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) +#define DR_LOG_TRACE_6( Level, Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_TRACE, (Level), DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6)) + +#define DR_LOG_INFO_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt)) +#define DR_LOG_INFO_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1)) +#define DR_LOG_INFO_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2)) +#define DR_LOG_INFO_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3)) +#define DR_LOG_INFO_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) +#define DR_LOG_INFO_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) +#define DR_LOG_INFO_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_INFO, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6)) + +#define DR_LOG_WARNING_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt)) +#define DR_LOG_WARNING_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1)) +#define DR_LOG_WARNING_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2)) +#define DR_LOG_WARNING_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3)) +#define DR_LOG_WARNING_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) +#define DR_LOG_WARNING_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) +#define DR_LOG_WARNING_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_WARNING, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6)) + +#define DR_LOG_ERROR_0( Fmt) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt)) +#define DR_LOG_ERROR_1( Fmt, Arg1) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1)) +#define DR_LOG_ERROR_2( Fmt, Arg1, Arg2) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2)) +#define DR_LOG_ERROR_3( Fmt, Arg1, Arg2, Arg3) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3)) +#define DR_LOG_ERROR_4( Fmt, Arg1, Arg2, Arg3, Arg4) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4)) +#define DR_LOG_ERROR_5( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5)) +#define DR_LOG_ERROR_6( Fmt, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) DR_Log( DRD_LOG_TYPE_ID_ERROR, DRD_LOG_LEVEL_DEFAULT, DRD_MODULE_NAME, __FILE__, __LINE__, true, (Fmt), (Arg1), (Arg2), (Arg3), (Arg4), (Arg5), (Arg6)) + + + + + +/*----------------------------------------------------------------------------*/ +/* Definitions */ /*----------------------------------------------------------------------------*/ #define NDD_CMD_ID_REFRESH ( NDT_Command) 65 @@ -174,35 +239,40 @@ typedef struct DRT_Task /* DRT_Base */ /*---------------------------------------------------------------------------------*/ +typedef DRT_Status (*DRT_Log_Writer_Ptr)( DRT_Log_Type_Id, char *, va_list); + typedef int DRT_SampleRate; typedef struct DRT_Base { - NDT_Root *Kit_DS_Ptr; - DRT_SampleRate SampleRate; + FILE *Log_Stream_Out; + char *Log_Type_Name_Tab[ DRD_LOG_TYPE_NB]; + DRT_Log_Writer_Ptr Log_Writer_Ptr; + + NDT_Root *Kit_DS_Ptr; + DRT_SampleRate SampleRate; //Config - float *Channel_Id_Ptr; - float *Base_Note_Ptr; - float *Velocity_Ignore_Note_Ptr; - float *Note_Off_Ignore_Note_Ptr; - float *Velocity_Ignore_Flag_Ptr; - float *Note_Off_Ignore_Flag_Ptr; - - DRT_Task_Id Task_Number; - DRT_Boolean Task_Load_Layer_Flag; - DRT_Boolean Task_Load_Instrument_Flag; - DRT_Boolean Task_Load_Kit_Flag; - DRT_Boolean Task_Sync_Kit_Flag; - DRT_Boolean Task_Sync_Kits_Flag; - DRT_Task *Task_Tab; - pthread_mutex_t Task_Mutex; - pthread_cond_t Task_Cond; - DRT_Task_Id Task_Count_Waiting; - long Task_Count_Run; - long Task_Count_Sleep; - long Task_Count_FakeWU; + float *Channel_Id_Ptr; + float *Base_Note_Ptr; + float *Velocity_Ignore_Note_Ptr; + float *Note_Off_Ignore_Note_Ptr; + float *Velocity_Ignore_Flag_Ptr; + float *Note_Off_Ignore_Flag_Ptr; + DRT_Task_Id Task_Number; + DRT_Boolean Task_Load_Layer_Flag; + DRT_Boolean Task_Load_Instrument_Flag; + DRT_Boolean Task_Load_Kit_Flag; + DRT_Boolean Task_Sync_Kit_Flag; + DRT_Boolean Task_Sync_Kits_Flag; + DRT_Task *Task_Tab; + pthread_mutex_t Task_Mutex; + pthread_cond_t Task_Cond; + DRT_Task_Id Task_Count_Waiting; + long Task_Count_Run; + long Task_Count_Sleep; + long Task_Count_FakeWU; } DRT_Base; @@ -264,6 +334,22 @@ typedef struct DRT_Kit /* Private Definitions */ /*----------------------------------------------------------------------------*/ +#define DRD_MODULE_NAME "ds" + + + +/*----------------------------------------------------------------------------*/ +/* DRT_Base */ +/*----------------------------------------------------------------------------*/ + +DRT_Base DRG_Base = +{ + NULL, + { DRD_LOG_TYPE_NAME_UNKNOWN, DRD_LOG_TYPE_NAME_TRACE, DRD_LOG_TYPE_NAME_INFO, DRD_LOG_TYPE_NAME_WARNING, DRD_LOG_TYPE_NAME_ERROR} +}; + + + /*----------------------------------------------------------------------------*/ /* Layer_DS Indexes */ /*----------------------------------------------------------------------------*/ @@ -437,194 +523,36 @@ DRT_XML_Query DRG_XML_Query_Tab_Kit[] = { NULL, NULL, DRD_XML_QUERY_VALUE_UNKNOWN, 0, 0 } }; -# endif // ifdef _DATASTRUCT_C_ - - - - - -# ifndef _DATASTRUCT_C_ - -/*----------------------------------------------------------------------------*/ -/* Public Prototypes */ -/*----------------------------------------------------------------------------*/ - -/*----------------------------------------------------------------------------*/ -/* DR_Layer_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Layer_Dump( DRT_Layer *, long); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_Kit_Id_Find */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kit_Logical_Id_Find */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_Kit_Name_Find */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Name_Find( DRT_Kit **, NDT_Root *, char *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kit_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Dump( DRT_Kit *, long); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_Kit_Load */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Load( DRT_Base *, char *); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_Kit_Sample_Load */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_Kit_Sample_UnLoad */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Sample_Load */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Sample_Load( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Sample_UnLoad */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Load */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Load( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Stats_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Stats_Dump( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Dump( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Kits_Graph_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Kits_Graph_Dump( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Task_Id_Run */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Task_Id_Kill */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Task_Run */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Task_Run( DRT_Base *, void *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Task_Wait */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Task_Wait( DRT_Base *); - - - -/*----------------------------------------------------------------------------*/ -/* DR_Tasks_Dump */ -/*----------------------------------------------------------------------------*/ - -extern DRT_Status DR_Tasks_Dump( DRT_Base *); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_DataStruct_Init */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id); - - - -/*---------------------------------------------------------------------------------*/ -/* DR_DataStruct_DeInit */ -/*---------------------------------------------------------------------------------*/ - -extern DRT_Status DR_DataStruct_DeInit( DRT_Base *); - - - -# else // ifndef _DATA_STRUCT_C_ - /*----------------------------------------------------------------------------*/ /* Private Prototypes */ /*----------------------------------------------------------------------------*/ +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log_Format( char *, DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *); + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log_Write( DRT_Log_Type_Id, char *, va_list); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Log */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_Log( DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *, ...); + + + /*---------------------------------------------------------------------------------*/ /* DS Managers */ /*---------------------------------------------------------------------------------*/ @@ -711,7 +639,7 @@ DRT_Status DR_Kit_Add( DRT_Kit **, NDT_Root *, DRT_Kit *); /* DR_Kit_Id_Find */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); +DRT_Status DR_Kit_Id_Find( DRT_Kit **, DRT_Kit_Id); @@ -719,7 +647,7 @@ DRT_Status DR_Kit_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); /* DR_Kit_Logical_Id_Find */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); +DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, DRT_Kit_Id); @@ -727,7 +655,7 @@ DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, NDT_Root *, DRT_Kit_Id); /* DR_Kit_Name_Find */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Name_Find( DRT_Kit **, NDT_Root *, char *); +DRT_Status DR_Kit_Name_Find( DRT_Kit **, char *); @@ -767,7 +695,7 @@ DRT_Status DR_XML_Value_Get( char *, long, xmlDocPtr, xmlXPathContextPtr, char /* DR_Kit_Load */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_Kit_Load( DRT_Base *, char *); +DRT_Status DR_Kit_Load( char *); @@ -791,7 +719,7 @@ DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *); /* DR_Kits_Sample_Load */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Sample_Load( DRT_Base *); +DRT_Status DR_Kits_Sample_Load(); @@ -799,7 +727,7 @@ DRT_Status DR_Kits_Sample_Load( DRT_Base *); /* DR_Kits_Sample_UnLoad */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *); +DRT_Status DR_Kits_Sample_UnLoad(); @@ -807,7 +735,7 @@ DRT_Status DR_Kits_Sample_UnLoad( DRT_Base *); /* DR_Kits_Load */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Load( DRT_Base *); +DRT_Status DR_Kits_Load(); @@ -815,7 +743,7 @@ DRT_Status DR_Kits_Load( DRT_Base *); /* DR_Kits_Stats_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Stats_Dump( DRT_Base *); +DRT_Status DR_Kits_Stats_Dump(); @@ -823,7 +751,7 @@ DRT_Status DR_Kits_Stats_Dump( DRT_Base *); /* DR_Kits_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Dump( DRT_Base *); +DRT_Status DR_Kits_Dump(); @@ -831,7 +759,7 @@ DRT_Status DR_Kits_Dump( DRT_Base *); /* DR_Kits_Graph_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Kits_Graph_Dump( DRT_Base *); +DRT_Status DR_Kits_Graph_Dump(); @@ -839,7 +767,7 @@ DRT_Status DR_Kits_Graph_Dump( DRT_Base *); /* DR_Task_Tread */ /*----------------------------------------------------------------------------*/ -static void *DR_Task_Thread( DRT_Base *); +static void *DR_Task_Thread(); @@ -847,7 +775,7 @@ static void *DR_Task_Thread( DRT_Base *); /* DR_Task_Id_Run */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *); +DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Task_Command, void *); @@ -855,7 +783,7 @@ DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Base *, DRT_Task_Command, void *) /* DR_Task_Id_Kill */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *); +DRT_Status DR_Task_Id_Kill( DRT_Task_Id); @@ -863,7 +791,7 @@ DRT_Status DR_Task_Id_Kill( DRT_Task_Id, DRT_Base *); /* DR_Task_Run */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Run( DRT_Base *, DRT_Task_Command, void *); +DRT_Status DR_Task_Run( DRT_Task_Command, void *); @@ -871,7 +799,7 @@ DRT_Status DR_Task_Run( DRT_Base *, DRT_Task_Command, void *); /* DR_Task_Wait */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Task_Wait( DRT_Base *); +DRT_Status DR_Task_Wait(); @@ -879,7 +807,7 @@ DRT_Status DR_Task_Wait( DRT_Base *); /* DR_Tasks_Dump */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Tasks_Dump( DRT_Base *); +DRT_Status DR_Tasks_Dump(); @@ -887,7 +815,7 @@ DRT_Status DR_Tasks_Dump( DRT_Base *); /* DR_DataStruct_Init */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id); +DRT_Status DR_DataStruct_Init( DRT_Log_Writer_Ptr, DRT_SampleRate, DRT_Task_Id); @@ -895,11 +823,220 @@ DRT_Status DR_DataStruct_Init( DRT_Base *, DRT_SampleRate, DRT_Task_Id); /* DR_DataStruct_DeInit */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_DataStruct_DeInit( DRT_Base *); +DRT_Status DR_DataStruct_DeInit(); -# endif // ifndef _DATASTRUCT_C_ + +# else // ifdef _DATASTRUCT_C_ + + + + + +/*----------------------------------------------------------------------------*/ +/* Public Definitions */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* DRT_Base */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Base DRG_Base; + + + + + +/*----------------------------------------------------------------------------*/ +/* Public Prototypes */ +/*----------------------------------------------------------------------------*/ + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Log_Write( DRT_Log_Type_Id, char *, va_list); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Log */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Log( DRT_Log_Type_Id, DRT_Log_Level, char *, char *, long, bool, char *, ...); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Layer_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Layer_Dump( DRT_Layer *, long); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_Kit_Id_Find */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Id_Find( DRT_Kit **, DRT_Kit_Id); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kit_Logical_Id_Find */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Logical_Id_Find( DRT_Kit **, DRT_Kit_Id); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_Kit_Name_Find */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Name_Find( DRT_Kit **, char *); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kit_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Dump( DRT_Kit *, long); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_Kit_Load */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Load( char *); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_Kit_Sample_Load */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Sample_Load( DRT_Kit *); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_Kit_Sample_UnLoad */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kit_Sample_UnLoad( DRT_Kit *); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Sample_Load */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Sample_Load(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Sample_UnLoad */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Sample_UnLoad(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Load */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Load(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Stats_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Stats_Dump(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Dump(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Kits_Graph_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Kits_Graph_Dump(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Task_Id_Run */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Task_Id_Run( DRT_Task_Id, DRT_Task_Command, void *); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Task_Id_Kill */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Task_Id_Kill( DRT_Task_Id); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Task_Run */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Task_Run( void *); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Task_Wait */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Task_Wait(); + + + +/*----------------------------------------------------------------------------*/ +/* DR_Tasks_Dump */ +/*----------------------------------------------------------------------------*/ + +extern DRT_Status DR_Tasks_Dump(); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_DataStruct_Init */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_DataStruct_Init( DRT_Log_Writer_Ptr, DRT_SampleRate, DRT_Task_Id); + + + +/*---------------------------------------------------------------------------------*/ +/* DR_DataStruct_DeInit */ +/*---------------------------------------------------------------------------------*/ + +extern DRT_Status DR_DataStruct_DeInit(); + + + +# endif // ifdef _DATASTRUCT_C_ diff --git a/drummer.c b/drummer.c index 7b24d9c..f43d603 100644 --- a/drummer.c +++ b/drummer.c @@ -16,12 +16,12 @@ /* DR_Init */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_Init( DRT_Base *Base_Ptr) +DRT_Status DR_Init() { DRT_Status status; - if( ( status = DR_DataStruct_Init( Base_Ptr, DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK) + if( ( status = DR_DataStruct_Init( DRD_LOG_WRITER_DEFAULT, DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK) { fprintf( stderr, "Can't init data structures (%d) !", status); return( status); @@ -38,12 +38,12 @@ DRT_Status DR_Init( DRT_Base *Base_Ptr) /* DR_DeInit */ /*---------------------------------------------------------------------------------*/ -DRT_Status DR_DeInit( DRT_Base *Base_Ptr) +DRT_Status DR_DeInit() { DRT_Status status; - if( ( status = DR_DataStruct_DeInit( Base_Ptr)) != DRS_OK) + if( ( status = DR_DataStruct_DeInit()) != DRS_OK) { printf( "Can't deinit data structures (%d)!\n", status); return( status); @@ -63,18 +63,17 @@ DRT_Status DR_DeInit( DRT_Base *Base_Ptr) int main( int argc, char **argv) { - DRT_Base base; DRT_Status status; DRT_Kit *kit_ptr; DRT_Id i; - if( ( status = DR_Init( &base)) != DRS_OK) + if( ( status = DR_Init()) != DRS_OK) { exit( -1); } - if( ( status = DR_Kits_Load( &base)) != DRS_OK) + if( ( status = DR_Kits_Load()) != DRS_OK) { exit( -1); } @@ -110,7 +109,7 @@ int main( int argc, char **argv) // } - DR_Kits_Sample_Load( &base); + DR_Kits_Sample_Load(); /* for( i = 0; i < 1; i++) @@ -130,7 +129,7 @@ int main( int argc, char **argv) } */ - fprintf( stderr, "hello world!\n"); + DR_LOG_INFO_0( "hello world!"); @@ -160,17 +159,17 @@ int main( int argc, char **argv) exit( -1); } */ - if( ( status = DR_Tasks_Dump( &base)) != DRS_OK) + if( ( status = DR_Tasks_Dump()) != DRS_OK) { exit( -1); } - if( ( status = DR_Kits_Stats_Dump( &base)) != DRS_OK) + if( ( status = DR_Kits_Stats_Dump()) != DRS_OK) { exit( -1); } - if( ( status = DR_DeInit( &base)) != DRS_OK) + if( ( status = DR_DeInit()) != DRS_OK) { exit( -1); } diff --git a/drummer.h b/drummer.h index 423edfa..2553033 100644 --- a/drummer.h +++ b/drummer.h @@ -15,7 +15,9 @@ #include #include #include - +#include +#include +#include #include #include @@ -94,6 +96,16 @@ typedef short DRT_Status; +# ifdef _DRUMMER_C_ + +/*----------------------------------------------------------------------------*/ +/* Private Definitions */ +/*----------------------------------------------------------------------------*/ + +#define DRD_MODULE_NAME "dru" + + + /*----------------------------------------------------------------------------*/ /* Prototypes */ /*----------------------------------------------------------------------------*/ @@ -102,7 +114,7 @@ typedef short DRT_Status; /* DR_Init */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_Init( DRT_Base *); +DRT_Status DR_Init(); @@ -110,7 +122,7 @@ DRT_Status DR_Init( DRT_Base *); /* DeInit */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_DeInit( DRT_Base *); +DRT_Status DR_DeInit(); @@ -125,9 +137,19 @@ int main( int, char **); +# else // ifdef _DRUMMER_C_ + +/*----------------------------------------------------------------------------*/ +/* Public Prototypes */ +/*----------------------------------------------------------------------------*/ + +# endif // ifdef _DRUMMER_C_ + + + /*----------------------------------------------------------------------------*/ -#endif +#endif // ifndef _DRUMMER_H_ diff --git a/lv2_plugin.c b/lv2_plugin.c index 58b5a06..0ef618b 100644 --- a/lv2_plugin.c +++ b/lv2_plugin.c @@ -21,7 +21,54 @@ static int current_kit_changed = 0; /* */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_Ptr) +DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id Log_Type_Id, char *Out_Fmt, va_list Args) +{ + switch( Log_Type_Id) + { + case DRD_LOG_TYPE_ID_UNKNOWN: + { + break; + } + + case DRD_LOG_TYPE_ID_TRACE: + { + break; + } + + case DRD_LOG_TYPE_ID_INFO: + { + lv2_log_vprintf( &(DRG_LV2_Base.Logger), DRG_LV2_Base.Logger.Note, Out_Fmt, Args); +// lv2_log_note( &(DRG_LV2_Base.Logger), "\n"); + + break; + } + + case DRD_LOG_TYPE_ID_WARNING: + { + break; + } + + case DRD_LOG_TYPE_ID_ERROR: + { + lv2_log_vprintf( &(DRG_LV2_Base.Logger), DRG_LV2_Base.Logger.Error, Out_Fmt, Args); +// lv2_log_error( &(DRG_LV2_Base.Logger), "\n"); + + break; + } + } + + return( DRS_OK); +} + + + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_LV2_Kit_Sample_Load( DRT_Kit *Kit_Ptr) { DRT_Status status; NDT_Node *cur_node_ptr; @@ -30,45 +77,45 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P if( Kit_Ptr != NULL) { -// fprintf( stderr, "Sample Rate: (%d)\n", LV2_Base_Ptr->Base.SampleRate); +// fprintf( stderr, "Sample Rate: (%d)\n", DRG_LV2_Base.Base.SampleRate); if( ( status = DR_Kit_Sample_Load( Kit_Ptr)) == DRS_OK) { - LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr; + DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr; cur_node_ptr = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Head; - pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex)); for( sample_id = 0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++) { - LV2_Base_Ptr->Samples[sample_id].Active = 0; - LV2_Base_Ptr->Samples[sample_id].Offset = 0; - LV2_Base_Ptr->Samples[sample_id].Limit = 0; - LV2_Base_Ptr->Samples[sample_id].Velocity = 0; - LV2_Base_Ptr->Samples[sample_id].Layer_Ptr = 0; - LV2_Base_Ptr->Samples[sample_id].Data_Ptr = NULL; - LV2_Base_Ptr->Samples[sample_id].Data_Offset = 0; - LV2_Base_Ptr->Samples[sample_id].Sustained = false; + DRG_LV2_Base.Samples[sample_id].Active = 0; + DRG_LV2_Base.Samples[sample_id].Offset = 0; + DRG_LV2_Base.Samples[sample_id].Limit = 0; + DRG_LV2_Base.Samples[sample_id].Velocity = 0; + DRG_LV2_Base.Samples[sample_id].Layer_Ptr = 0; + DRG_LV2_Base.Samples[sample_id].Data_Ptr = NULL; + DRG_LV2_Base.Samples[sample_id].Data_Offset = 0; + DRG_LV2_Base.Samples[sample_id].Sustained = false; if( cur_node_ptr == NULL) { // fprintf( stderr, "Skip sample\n"); - LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = NULL; + DRG_LV2_Base.Samples[sample_id].Instrument_Ptr = NULL; } else { - LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value; + DRG_LV2_Base.Samples[sample_id].Instrument_Ptr = (DRT_Instrument *)cur_node_ptr->Value; cur_node_ptr = cur_node_ptr->Right; -// fprintf( stderr, "Add sample: [%s]\n", LV2_Base_Ptr->Samples[sample_id].Instrument_Ptr->Name); +// fprintf( stderr, "Add sample: [%s]\n", DRG_LV2_Base.Samples[sample_id].Instrument_Ptr->Name); } } - pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex)); - LV2_Base_Ptr->Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; - fprintf( stderr, "Loaded: (%d) instruments!\n", LV2_Base_Ptr->Sample_Number); + DRG_LV2_Base.Sample_Number = Kit_Ptr->Instrument_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number; + DR_LOG_INFO_1( "Loaded: (%d) instruments!", DRG_LV2_Base.Sample_Number); // DR_Kit_Dump( Kit_Ptr, 0); } @@ -85,51 +132,51 @@ DRT_Status DR_LV2_Kit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr, DRT_Kit *Kit_P /* */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr) +DRT_Status DR_LV2_CurKit_Sample_Load() { DRT_Status status; DRT_Kit *Kit_Ptr; DRT_Kit_Id kit_id; - kit_id = ( LV2_Base_Ptr->Bank_Id_LSB_New * 128 + LV2_Base_Ptr->Bank_Id_MSB_New) * 128 + LV2_Base_Ptr->Program_Id_New; + kit_id = ( DRG_LV2_Base.Bank_Id_LSB_New * 128 + DRG_LV2_Base.Bank_Id_MSB_New) * 128 + DRG_LV2_Base.Program_Id_New; - if( kit_id == LV2_Base_Ptr->Kit_Id) + if( kit_id == DRG_LV2_Base.Kit_Id) { - fprintf( stderr, "Same kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n", - kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New, LV2_Base_Ptr->Kit_Cur_Ptr->Name); + DR_LOG_INFO_5( "Same kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!", + kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New, DRG_LV2_Base.Kit_Cur_Ptr->Name); status = DRS_OK; } else { - if( ( status = DR_Kit_Logical_Id_Find( &Kit_Ptr, LV2_Base_Ptr->Base.Kit_DS_Ptr, kit_id)) != DRS_OK) + if( ( status = DR_Kit_Logical_Id_Find( &Kit_Ptr, kit_id)) != DRS_OK) { fprintf( stderr, "Can't find kit id: (%d) Bank/Program: (%d/%d/%d)!\n", - kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New); + kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New); - if( LV2_Base_Ptr->Kit_Id == DRD_ID_UNKNOWN) + if( DRG_LV2_Base.Kit_Id == DRD_ID_UNKNOWN) { fprintf( stderr, "No Kit available!\n"); status=DRS_KO; } else { - fprintf( stderr, "Keep kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n", - LV2_Base_Ptr->Kit_Id, LV2_Base_Ptr->Bank_Id_LSB, LV2_Base_Ptr->Bank_Id_MSB, LV2_Base_Ptr->Program_Id, LV2_Base_Ptr->Kit_Cur_Ptr->Name); + DR_LOG_INFO_5( "Keep kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!", + DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Bank_Id_LSB, DRG_LV2_Base.Bank_Id_MSB, DRG_LV2_Base.Program_Id, DRG_LV2_Base.Kit_Cur_Ptr->Name); } } else { - fprintf( stderr, "New kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!\n", - kit_id, LV2_Base_Ptr->Bank_Id_LSB_New, LV2_Base_Ptr->Bank_Id_MSB_New, LV2_Base_Ptr->Program_Id_New, Kit_Ptr->Name); + DR_LOG_INFO_5( "New kit id: (%d) Bank/Program: (%d/%d/%d) Name: [%s]!", + kit_id, DRG_LV2_Base.Bank_Id_LSB_New, DRG_LV2_Base.Bank_Id_MSB_New, DRG_LV2_Base.Program_Id_New, Kit_Ptr->Name); - LV2_Base_Ptr->Bank_Id_LSB = LV2_Base_Ptr->Bank_Id_LSB_New; - LV2_Base_Ptr->Bank_Id_MSB = LV2_Base_Ptr->Bank_Id_MSB_New; - LV2_Base_Ptr->Program_Id = LV2_Base_Ptr->Program_Id_New; - LV2_Base_Ptr->Kit_Id = kit_id; - LV2_Base_Ptr->Kit_Cur_Ptr = Kit_Ptr; + DRG_LV2_Base.Bank_Id_LSB = DRG_LV2_Base.Bank_Id_LSB_New; + DRG_LV2_Base.Bank_Id_MSB = DRG_LV2_Base.Bank_Id_MSB_New; + DRG_LV2_Base.Program_Id = DRG_LV2_Base.Program_Id_New; + DRG_LV2_Base.Kit_Id = kit_id; + DRG_LV2_Base.Kit_Cur_Ptr = Kit_Ptr; - status = DR_LV2_Kit_Sample_Load( LV2_Base_Ptr, Kit_Ptr); + status = DR_LV2_Kit_Sample_Load( Kit_Ptr); } } @@ -142,37 +189,37 @@ DRT_Status DR_LV2_CurKit_Sample_Load( DRT_LV2_Base *LV2_Base_Ptr) /* */ /*----------------------------------------------------------------------------*/ -static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr) +static void *DR_LV2_Load_Thread() { DRT_Status status; - fprintf( stderr, "Start Load Thread!\n"); + DR_LOG_INFO_0( "Start Load Thread!"); for(;;) { - pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex)); - pthread_cond_wait( &( LV2_Base_Ptr->Load_Cond), &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex)); + pthread_cond_wait( &( DRG_LV2_Base.Load_Cond), &( DRG_LV2_Base.Load_Mutex)); fprintf( stderr, "Load_Thread: New load!\n"); - pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex)); - if( ( status = DR_LV2_CurKit_Sample_Load( LV2_Base_Ptr)) != DRS_OK) + if( ( status = DR_LV2_CurKit_Sample_Load()) != DRS_OK) { fprintf( stderr, "Can't load kit sample (%d) !", status); } - pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex)); - pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex)); + pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex)); /* -// old_samples = LV2_Base_Ptr->Samples; -// old_scount = LV2_Base_Ptr->Num_Samples; +// old_samples = DRG_LV2_Base.Samples; +// old_scount = DRG_LV2_Base.Num_Samples; - request_orig = request = LV2_Base_Ptr->Request_Buf[ LV2_Base_Ptr->CurReq]; + request_orig = request = DRG_LV2_Base.Request_Buf[ DRG_LV2_Base.CurReq]; if( !strncmp( request, "file://", 7)) { @@ -185,29 +232,29 @@ static void *DR_LV2_Load_Thread( DRT_LV2_Base *LV2_Base_Ptr) { fprintf(stderr,"Failed to load kit at: %s\n",request); - pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex)); -// LV2_Base_Ptr->Num_Samples = 0; -// LV2_Base_Ptr->Samples = NULL; +// DRG_LV2_Base.Num_Samples = 0; +// DRG_LV2_Base.Samples = NULL; - pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex)); } else { // just lock for the critical moment when we swap in the new kit printf( "loaded kit at: %s\n", request); - pthread_mutex_lock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &(DRG_LV2_Base.Load_Mutex)); -// LV2_Base_Ptr->Samples = loaded_samples; -// LV2_Base_Ptr->Num_Samples = loaded_count; +// DRG_LV2_Base.Samples = loaded_samples; +// DRG_LV2_Base.Num_Samples = loaded_count; - pthread_mutex_unlock( &(LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &(DRG_LV2_Base.Load_Mutex)); } // if( old_scount > 0) free_samples( old_samples, old_scount); - LV2_Base_Ptr->Current_Path = request_orig; + DRG_LV2_Base.Current_Path = request_orig; current_kit_changed = 1; */ } @@ -287,10 +334,10 @@ static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *LV2_Base LV2_Atom *msg; - msg = (LV2_Atom *)lv2_atom_forge_object( &( LV2_Base_Ptr->Forge), &set_frame, 1, LV2_Base_Ptr->URIS.midi_info); - lv2_atom_forge_property_head( &( LV2_Base_Ptr->Forge), LV2_Base_Ptr->URIS.midi_event, 0); - lv2_atom_forge_write( &( LV2_Base_Ptr->Forge), Data, 3); - lv2_atom_forge_pop( &( LV2_Base_Ptr->Forge), &set_frame); + msg = (LV2_Atom *)lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &set_frame, 1, DRG_LV2_Base.URIS.midi_info); + lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.midi_event, 0); + lv2_atom_forge_write( &( DRG_LV2_Base.Forge), Data, 3); + lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &set_frame); return( msg); } @@ -384,7 +431,7 @@ static inline void DR_Layer_To_Sample( DRT_Sample *Sample_Ptr, float Gain) Sample_Ptr->Limit = cur_layer_ptr->Sample_Size; Sample_Ptr->SF_Info_Ptr = cur_layer_ptr->SF_Info_Ptr; - fprintf( stderr, "Layer: (%d) MGain: (%f) Gain: (%f)\n", i, mapped_gain, Gain); + DR_LOG_INFO_3( "Layer: (%d) MGain: (%f) Gain: (%f)", i, mapped_gain, Gain); } @@ -395,45 +442,45 @@ static inline void DR_Layer_To_Sample( DRT_Sample *Sample_Ptr, float Gain) /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_Trigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_Id, uint8_t *const Data, uint32_t Offset) +static inline void DR_Sample_Trigger( int Sample_Id, uint8_t *const Data, uint32_t Offset) { // need to mutex this to avoid getting the samples array // changed after the check that the midi-note is valid - pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex)); - fprintf( stderr, "Trigger Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset); + DR_LOG_INFO_2( "Trigger Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset); - if( ( Sample_Id >= 0) && ( Sample_Id < LV2_Base_Ptr->Sample_Number)) + if( ( Sample_Id >= 0) && ( Sample_Id < DRG_LV2_Base.Sample_Number)) { /* if( Data) { - lv2_atom_forge_frame_time( &( LV2_Base_Ptr->Forge), 0); + lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0); DR_LV2_Message_Midi_Info_Build( LV2_Base_Ptr, Data); } */ - LV2_Base_Ptr->Samples[Sample_Id].Active = 1; - LV2_Base_Ptr->Samples[Sample_Id].Offset = 0; - LV2_Base_Ptr->Samples[Sample_Id].Velocity = *( LV2_Base_Ptr->Base.Velocity_Ignore_Flag_Ptr) ? 1.0f : ( (float)Data[2]) / DRD_VELOCITY_MAX; - LV2_Base_Ptr->Samples[Sample_Id].Data_Offset = Offset; - LV2_Base_Ptr->Samples[Sample_Id].Sustained = false; + DRG_LV2_Base.Samples[Sample_Id].Active = 1; + DRG_LV2_Base.Samples[Sample_Id].Offset = 0; + DRG_LV2_Base.Samples[Sample_Id].Velocity = *( DRG_Base.Velocity_Ignore_Flag_Ptr) ? 1.0f : ( (float)Data[2]) / DRD_VELOCITY_MAX; + DRG_LV2_Base.Samples[Sample_Id].Data_Offset = Offset; + DRG_LV2_Base.Samples[Sample_Id].Sustained = false; - if( LV2_Base_Ptr->Samples[Sample_Id].Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0) + if( DRG_LV2_Base.Samples[Sample_Id].Instrument_Ptr->Layer_DS_Ptr->Index_Tab[NDD_INDEX_PRIMARY].Node_Number > 0) { // drmr currently has 32 hard-coded gains so just use the last gain // to prevent a segfault int gain_idx = Sample_Id < 32 ? Sample_Id : 31; -// DR_Layer_To_Sample( &(LV2_Base_Ptr->Samples[Sample_Id]), *( LV2_Base_Ptr->Gains[ gain_idx])); - DR_Layer_To_Sample( &(LV2_Base_Ptr->Samples[Sample_Id]), LV2_Base_Ptr->Samples[Sample_Id].Velocity); +// DR_Layer_To_Sample( &(DRG_LV2_Base.Samples[Sample_Id]), *( DRG_LV2_Base.Gains[ gain_idx])); + DR_Layer_To_Sample( &(DRG_LV2_Base.Samples[Sample_Id]), DRG_LV2_Base.Samples[Sample_Id].Velocity); - if( LV2_Base_Ptr->Samples[Sample_Id].Limit == 0) - fprintf(stderr,"Failed to find layer at: %i for %f\n", Sample_Id, *( LV2_Base_Ptr->Gains[ gain_idx])); + if( DRG_LV2_Base.Samples[Sample_Id].Limit == 0) + fprintf(stderr,"Failed to find layer at: %i for %f\n", Sample_Id, *( DRG_LV2_Base.Gains[ gain_idx])); } } - pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex)); } @@ -444,20 +491,19 @@ static inline void DR_Sample_Trigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_ /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sample_Id, uint32_t Offset) +static inline void DR_Sample_Untrigger( int Sample_Id, uint32_t Offset) { - pthread_mutex_lock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_lock( &( DRG_LV2_Base.Load_Mutex)); - if( LV2_Base_Ptr->Sustain == true) + if( DRG_LV2_Base.Sustain == true) { - fprintf( stderr, "Sustains Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset); + DR_LOG_INFO_2( "Sustains Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset); - LV2_Base_Ptr->Samples[Sample_Id].Sustained = true; + DRG_LV2_Base.Samples[Sample_Id].Sustained = true; } else { - - fprintf( stderr, "UnTrigger Sample: Id: (%d) Offset: (%d)\n", Sample_Id, Offset); + DR_LOG_INFO_2( "UnTrigger Sample: Id: (%d) Offset: (%d)", Sample_Id, Offset); /* if (nn >= 0 && nn < drmr->num_samples) { @@ -470,12 +516,12 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sampl drmr->samples[nn].dataoffset = offset; } */ - LV2_Base_Ptr->Samples[Sample_Id].Active = 0; - LV2_Base_Ptr->Samples[Sample_Id].Data_Offset = Offset; - LV2_Base_Ptr->Samples[Sample_Id].Sustained = false; + DRG_LV2_Base.Samples[Sample_Id].Active = 0; + DRG_LV2_Base.Samples[Sample_Id].Data_Offset = Offset; + DRG_LV2_Base.Samples[Sample_Id].Sustained = false; } - pthread_mutex_unlock( &( LV2_Base_Ptr->Load_Mutex)); + pthread_mutex_unlock( &( DRG_LV2_Base.Load_Mutex)); } @@ -486,16 +532,16 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *LV2_Base_Ptr, int Sampl /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_UnSustain( DRT_LV2_Base *LV2_Base_Ptr, uint32_t Offset) +static inline void DR_Sample_UnSustain( uint32_t Offset) { int sample_id; for( sample_id =0; sample_id < DRD_PORT_NUMBER_MAX; sample_id++) { - if( LV2_Base_Ptr->Samples[sample_id].Sustained) + if( DRG_LV2_Base.Samples[sample_id].Sustained) { - DR_Sample_Untrigger( LV2_Base_Ptr, sample_id, Offset); + DR_Sample_Untrigger( sample_id, Offset); } } } @@ -515,158 +561,178 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descriptor { DRT_Status status; int i; - DRT_LV2_Base *lv2_base_ptr; +// DRT_LV2_Base *lv2_base_ptr; fprintf( stderr, "LV2 Instantiate\n"); - +/* if( ( lv2_base_ptr = malloc( sizeof( DRT_LV2_Base))) == NULL) { fprintf( stderr, "Can't allocate LV2 Base!\n"); return( (LV2_Handle)NULL); } +*/ + DRG_LV2_Base.Map_Ptr = NULL; + DRG_LV2_Base.Logger.log = NULL; - lv2_base_ptr->Kit_Cur_Ptr = NULL; - lv2_base_ptr->Bank_Id_LSB = -1; - lv2_base_ptr->Bank_Id_LSB = -1; - lv2_base_ptr->Program_Id = -1; - lv2_base_ptr->Bank_Id_LSB_New = 0; - lv2_base_ptr->Bank_Id_MSB_New = 0; - lv2_base_ptr->Program_Id_New = 0; - lv2_base_ptr->Kit_Id = DRD_ID_UNKNOWN; - lv2_base_ptr->Current_Path = NULL; - lv2_base_ptr->CurReq = -1; + DRG_LV2_Base.Kit_Cur_Ptr = NULL; + DRG_LV2_Base.Bank_Id_LSB = -1; + DRG_LV2_Base.Bank_Id_LSB = -1; + DRG_LV2_Base.Program_Id = -1; + DRG_LV2_Base.Bank_Id_LSB_New = 0; + DRG_LV2_Base.Bank_Id_MSB_New = 0; + DRG_LV2_Base.Program_Id_New = 0; + DRG_LV2_Base.Kit_Id = DRD_ID_UNKNOWN; + DRG_LV2_Base.Current_Path = NULL; + DRG_LV2_Base.CurReq = -1; -// lv2_base_ptr->Channel_Id = 0; - lv2_base_ptr->Zero_Position = 0; +// DRG_LV2_Base.Channel_Id = 0; + DRG_LV2_Base.Zero_Position = 0; - lv2_base_ptr->Sustain = false; + DRG_LV2_Base.Sustain = false; - lv2_base_ptr->Sample_Number = 0; + DRG_LV2_Base.Sample_Number = 0; while( *LV2_Features_Ptr != NULL) { fprintf( stderr, "Feature URI: [%s]\n", (*LV2_Features_Ptr)->URI); - if( !strcmp( (*LV2_Features_Ptr)->URI, LV2_URID_URI "#map")) + + if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_URID_URI "#map")) { - lv2_base_ptr->Map_Ptr = (LV2_URID_Map *)((*LV2_Features_Ptr)->data); + DRG_LV2_Base.Map_Ptr = (LV2_URID_Map *)( ( *LV2_Features_Ptr)->data); + } + else + { + if( !strcmp( ( *LV2_Features_Ptr)->URI, LV2_LOG__log)) + { + DRG_LV2_Base.Logger.log = (LV2_Log_Log *)( ( *LV2_Features_Ptr)->data); + } } LV2_Features_Ptr++; } - if( lv2_base_ptr->Map_Ptr == NULL) + if( ( DRG_LV2_Base.Map_Ptr == NULL) || ( DRG_LV2_Base.Logger.log == NULL)) { - fprintf( stderr, "LV2 host does not support urid#map!\n"); + if( DRG_LV2_Base.Map_Ptr == NULL) + { + fprintf( stderr, "LV2 host does not support urid#map!\n"); + } + + if( DRG_LV2_Base.Logger.log == NULL) + { + fprintf( stderr, "LV2 host does not support log#log!\n"); + } } else { - if( pthread_mutex_init( &( lv2_base_ptr->Load_Mutex), 0)) + if( ( status = DR_DataStruct_Init( DR_LV2_Log_Write, (DRT_SampleRate)SampleRate, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK) { - fprintf( stderr, "Could not initialize load_mutex!\n"); - } - else if( pthread_cond_init( &( lv2_base_ptr->Load_Cond), 0)) - { - fprintf( stderr, "Could not initialize load_cond!\n"); + fprintf( stderr, "Can't init data structures (%d)!\n", status); } else { - DR_Map_Drummer_URIS( lv2_base_ptr->Map_Ptr, &(lv2_base_ptr->URIS)); + lv2_log_error( &(DRG_LV2_Base.Logger), "Test error log <%s>!\n", "Krash!"); + DR_LOG_ERROR_1( "Test error log <%s>!", "Krash!"); - lv2_atom_forge_init( &(lv2_base_ptr->Forge), lv2_base_ptr->Map_Ptr); - - if( pthread_create( &lv2_base_ptr->Load_Thread, 0, (void * (*)(void *))DR_LV2_Load_Thread, lv2_base_ptr)) + if( pthread_mutex_init( &( DRG_LV2_Base.Load_Mutex), 0)) { - fprintf( stderr, "Could not initialize loading thread!\n"); + fprintf( stderr, "Could not initialize load_mutex!\n"); + } + else if( pthread_cond_init( &( DRG_LV2_Base.Load_Cond), 0)) + { + fprintf( stderr, "Could not initialize load_cond!\n"); } else { - if( ( lv2_base_ptr->Request_Buf = malloc( DRD_REQ_BUF_SIZE * sizeof(char *))) == NULL) + DR_Map_Drummer_URIS( DRG_LV2_Base.Map_Ptr, &(DRG_LV2_Base.URIS)); + + lv2_atom_forge_init( &(DRG_LV2_Base.Forge), DRG_LV2_Base.Map_Ptr); + + if( pthread_create( &DRG_LV2_Base.Load_Thread, 0, (void * (*)(void *))DR_LV2_Load_Thread, NULL)) { - fprintf( stderr, "Cant'allocate Request buffer!\n"); + fprintf( stderr, "Could not initialize loading thread!\n"); } else { - memset( lv2_base_ptr->Request_Buf, 0, DRD_REQ_BUF_SIZE * sizeof(char *)); - - if( ( lv2_base_ptr->Left = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) + if( ( DRG_LV2_Base.Request_Buf = malloc( DRD_REQ_BUF_SIZE * sizeof(char *))) == NULL) { - fprintf( stderr, "Cant'allocate Left buffer!\n"); - free( lv2_base_ptr); - - return( NULL); + fprintf( stderr, "Cant'allocate Request buffer!\n"); } else { - if( ( lv2_base_ptr->Right = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) + memset( DRG_LV2_Base.Request_Buf, 0, DRD_REQ_BUF_SIZE * sizeof(char *)); + + if( ( DRG_LV2_Base.Left = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) { - fprintf( stderr, "Cant'allocate Right buffer!\n"); + fprintf( stderr, "Cant'allocate Left buffer!\n"); +// free( lv2_base_ptr); + + return( NULL); } else { - if( ( lv2_base_ptr->Gains = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) + if( ( DRG_LV2_Base.Right = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) { - fprintf( stderr, "Cant'allocate Gains buffer!\n"); + fprintf( stderr, "Cant'allocate Right buffer!\n"); } else { - if( ( lv2_base_ptr->Pans = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) + if( ( DRG_LV2_Base.Gains = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) { - fprintf( stderr, "Cant'allocate Pans buffer!\n"); + fprintf( stderr, "Cant'allocate Gains buffer!\n"); } else { - for( i = 0; i < 32; i++) + if( ( DRG_LV2_Base.Pans = malloc( DRD_PORT_NUMBER_MAX * sizeof(float *))) == NULL) { - lv2_base_ptr->Gains[i] = NULL; - lv2_base_ptr->Pans[i] = NULL; - } - - if( ( status = DR_DataStruct_Init( &( lv2_base_ptr->Base), (DRT_SampleRate)SampleRate, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK) - { - fprintf( stderr, "Can't init data structures (%d)!\n", status); + fprintf( stderr, "Cant'allocate Pans buffer!\n"); } else { - if( ( status = DR_Kits_Load( & ( lv2_base_ptr->Base))) != DRS_OK) + for( i = 0; i < 32; i++) + { + DRG_LV2_Base.Gains[i] = NULL; + DRG_LV2_Base.Pans[i] = NULL; + } + + if( ( status = DR_Kits_Load()) != DRS_OK) { fprintf( stderr, "Can't load kits (%d)!\n", status); } else { - if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK) + if( ( status = DR_LV2_CurKit_Sample_Load()) != DRS_OK) { fprintf( stderr, "Can't load kit sample (%d)!\n", status); } else { - return( (LV2_Handle)lv2_base_ptr); + return( (LV2_Handle)&DRG_LV2_Base); } } - - DR_DataStruct_DeInit( &( lv2_base_ptr->Base)); } + + free( DRG_LV2_Base.Gains); } - - free( lv2_base_ptr->Gains); - } - free( lv2_base_ptr->Right); + free( DRG_LV2_Base.Right); - } + } - free( lv2_base_ptr->Left); - } + free( DRG_LV2_Base.Left); + } - free( lv2_base_ptr->Request_Buf); + free( DRG_LV2_Base.Request_Buf); + } } } + + DR_DataStruct_DeInit(); } } - free( lv2_base_ptr); - return( (LV2_Handle)NULL); } @@ -684,7 +750,7 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v DRT_Port_Index port_index = (DRT_Port_Index)Port_Id; -// fprintf( stderr, "LV2 Connect Port (%d)!\n", Port_Id); +// DR_LOG_INFO_1( "LV2 Connect Port (%d)!", Port_Id); switch( port_index) { @@ -702,37 +768,37 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v case DRD_LV2_CHANNEL_ID: { - if( Data_Ptr) lv2_base_ptr->Base.Channel_Id_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Channel_Id_Ptr = (float *)Data_Ptr; break; } case DRD_LV2_BASE_NOTE: { - if( Data_Ptr) lv2_base_ptr->Base.Base_Note_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Base_Note_Ptr = (float *)Data_Ptr; break; } case DRD_LV2_VELOCITY_IGNORE_NOTE: { - if( Data_Ptr) lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Velocity_Ignore_Note_Ptr = (float *)Data_Ptr; break; } case DRD_LV2_NOTE_OFF_IGNORE_NOTE: { - if( Data_Ptr) lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Note_Off_Ignore_Note_Ptr = (float *)Data_Ptr; break; } case DRD_LV2_VELOCITY_IGNORE_FLAG: { - if( Data_Ptr) lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Velocity_Ignore_Flag_Ptr = (float *)Data_Ptr; break; } case DRD_LV2_NOTE_OFF_IGNORE_FLAG: { - if( Data_Ptr) lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr = (float *)Data_Ptr; + if( Data_Ptr) DRG_Base.Note_Off_Ignore_Flag_Ptr = (float *)Data_Ptr; break; } @@ -789,7 +855,7 @@ static void DR_LV2_Connect_Port( LV2_Handle Instance_Ptr, uint32_t Port_Id, v static void DR_LV2_Activate( LV2_Handle instance) { - fprintf( stderr, "LV2 Activate!\n"); + DR_LOG_INFO_0( "LV2 Activate!"); } @@ -809,7 +875,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) // fprintf( stderr, "LV2 Run!\n"); - base_note = (int)floorf( *( lv2_base_ptr->Base.Base_Note_Ptr)); + base_note = (int)floorf( *( DRG_Base.Base_Note_Ptr)); const uint32_t event_capacity = lv2_base_ptr->Core_Event_Port->atom.size; @@ -820,7 +886,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) LV2_ATOM_SEQUENCE_FOREACH( lv2_base_ptr->Control_Port, ev_ptr) { - fprintf( stderr, "LV2 Event!\n"); + DR_LOG_INFO_0( "LV2 Event!"); if( ev_ptr->body.type == lv2_base_ptr->URIS.midi_event) { @@ -834,18 +900,18 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) // fprintf( stderr, " Midi Event!\n"); - if( ( *( lv2_base_ptr->Base.Channel_Id_Ptr) == 0) || ( channel == ( *( lv2_base_ptr->Base.Channel_Id_Ptr) - 1))) + if( ( *( DRG_Base.Channel_Id_Ptr) == 0) || ( channel == ( *( DRG_Base.Channel_Id_Ptr) - 1))) { switch( ( *data) >> 4) { case 8: // Note Off { - if( !*( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr)) + if( !*( DRG_Base.Note_Off_Ignore_Flag_Ptr)) { nn = data[1]; nn -= base_note; - DR_Sample_Untrigger( lv2_base_ptr, nn, offset); + DR_Sample_Untrigger( nn, offset); } break; @@ -855,25 +921,25 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) { nn = data[1]; - if( nn == *( lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr)) + if( nn == *( DRG_Base.Velocity_Ignore_Note_Ptr)) { -// *( lv2_base_ptr->Base.Velocity_Ignore_Flag) ^= true; - *( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr) = (float)( (int)*( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr) ^ true); - fprintf( stderr, "Velocity Ignore: [%f] - [%f]\n", *( lv2_base_ptr->Base.Velocity_Ignore_Flag_Ptr), *( lv2_base_ptr->Base.Velocity_Ignore_Note_Ptr)); +// *( DRG_Base.Velocity_Ignore_Flag) ^= true; + *( DRG_Base.Velocity_Ignore_Flag_Ptr) = (float)( (int)*( DRG_Base.Velocity_Ignore_Flag_Ptr) ^ true); + DR_LOG_INFO_2( "Velocity Ignore: [%f] - [%f]", *( DRG_Base.Velocity_Ignore_Flag_Ptr), *( DRG_Base.Velocity_Ignore_Note_Ptr)); } else { - if( nn == *( lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr)) + if( nn == *( DRG_Base.Note_Off_Ignore_Note_Ptr)) { -// *( lv2_base_ptr->Base.Note_Off_Ignore_Flag) ^= true; - *( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr) = (float)( (int)*( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr) ^ true); - fprintf( stderr, "Note Off Ignore: [%f] - [%f]\n", *( lv2_base_ptr->Base.Note_Off_Ignore_Flag_Ptr), *( lv2_base_ptr->Base.Note_Off_Ignore_Note_Ptr)); +// *( DRG_Base.Note_Off_Ignore_Flag) ^= true; + *( DRG_Base.Note_Off_Ignore_Flag_Ptr) = (float)( (int)*( DRG_Base.Note_Off_Ignore_Flag_Ptr) ^ true); + DR_LOG_INFO_2( "Note Off Ignore: [%f] - [%f]", *( DRG_Base.Note_Off_Ignore_Flag_Ptr), *( DRG_Base.Note_Off_Ignore_Note_Ptr)); /* LV2_Atom_Forge_Frame set_frame; LV2_Atom *msg = (LV2_Atom *)lv2_atom_forge_object( &( lv2_base_ptr->forge), &set_frame, 1, drmr->uris.ui_msg); lv2_atom_forge_property_head( &( lv2_base_ptr->forge), lv2_base_ptr->URIS.velocity_toggle, 0); - lv2_atom_forge_bool( &( lv2_base_ptr->forge), lv2_base_ptr->Base.Note_Off_Ignore_Flag ? true : false); + lv2_atom_forge_bool( &( lv2_base_ptr->forge), DRG_Base.Note_Off_Ignore_Flag ? true : false); lv2_atom_forge_pop( &( lv2_base_ptr->forge), &set_frame); */ } @@ -881,7 +947,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) { nn -= base_note; - DR_Sample_Trigger( lv2_base_ptr, nn, data, offset); + DR_Sample_Trigger( nn, data, offset); } } @@ -897,7 +963,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) { case 0: // Bank MSB Select { - fprintf( stderr, "Bank MSB select: (%d)!\n", value); + DR_LOG_INFO_1( "Bank MSB select: (%d)!", value); lv2_base_ptr->Bank_Id_MSB_New = value; break; @@ -905,7 +971,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) case 32: // Bank LSB Select { - fprintf( stderr, "Bank LSB select: (%d)!\n", value); + DR_LOG_INFO_1( "Bank LSB select: (%d)!", value); lv2_base_ptr->Bank_Id_LSB_New = value; break; @@ -913,7 +979,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) case 64: // Sustain { - fprintf( stderr, "Sustain: (%d)!\n", value); + DR_LOG_INFO_1( "Sustain: (%d)!", value); if( value == 127) { @@ -926,7 +992,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) if( !( lv2_base_ptr->Sustain)) { - DR_Sample_UnSustain( lv2_base_ptr, offset); + DR_Sample_UnSustain( offset); } break; @@ -934,7 +1000,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) default: { - fprintf( stderr, "Unhandled controler: (%d) value: (%d)!\n", controler, value); + DR_LOG_WARNING_2( "Unhandled controler: (%d) value: (%d)!", controler, value); break; } } @@ -946,33 +1012,11 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) { value = data[1]; - fprintf( stderr, "Program change: (%d)!\n", value); + DR_LOG_INFO_1( "Program change: (%d)!", value); lv2_base_ptr->Program_Id_New = value; pthread_cond_signal( &( lv2_base_ptr->Load_Cond)); - - /* - if( ( status = DR_LV2_CurKit_Sample_Load( lv2_base_ptr)) != DRS_OK) - { - fprintf( stderr, "Can't load kit sample (%d) !", status); - } - */ - - /* - int reqpos = ( lv2_base_ptr->CurReq + 1) % DRD_REQ_BUF_SIZE; - char *tmp = NULL; - - - if( reqpos >= 0 && lv2_base_ptr->Request_Buf[reqpos]) - tmp = lv2_base_ptr->Request_Buf[reqpos]; - lv2_base_ptr->Request_Buf[reqpos] = strdup( LV2_ATOM_BODY( lv2_base_ptr->Kit_Id)); - lv2_base_ptr->CurReq = reqpos; - - if( tmp) free(tmp); - - fprintf( stderr, "Path!\n"); - */ break; } @@ -987,7 +1031,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) } else if( ev_ptr->body.type == lv2_base_ptr->URIS.atom_object) { - fprintf( stderr, "LV2 AO...\n"); + DR_LOG_INFO_0( "LV2 AO..."); const LV2_Atom_Object *obj_ptr = (LV2_Atom_Object *)&(ev_ptr->body); /* @@ -1047,16 +1091,16 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) } if( ignvel) - lv2_base_ptr->Base.Velocity_Ignore_Flag = ((const LV2_Atom_Bool*)ignvel)->body; + DRG_Base.Velocity_Ignore_Flag = ((const LV2_Atom_Bool*)ignvel)->body; if( ignno) { fprintf( stderr, "Change Note Off Ignore Flag!\n"); -// lv2_base_ptr->Base.Note_Off_Ignore_Flag = ((const LV2_Atom_Bool*)ignno)->body; +// DRG_Base.Note_Off_Ignore_Flag = ((const LV2_Atom_Bool*)ignno)->body; } if( channel_id) - lv2_base_ptr->Base.Channel_Id_Ptr = ((const LV2_Atom_Int*)channel_id)->body; + DRG_Base.Channel_Id_Ptr = ((const LV2_Atom_Int*)channel_id)->body; if( zerop) lv2_base_ptr->Zero_Position = ((const LV2_Atom_Int*)zerop)->body; @@ -1090,7 +1134,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) } else { - fprintf( stderr, "Unrecognized event (%d) != (%d)\n", ev_ptr->body.type, lv2_base_ptr->URIS.atom_object); + DR_LOG_WARNING_2( "Unrecognized event (%d) != (%d)", ev_ptr->body.type, lv2_base_ptr->URIS.atom_object); } } /* @@ -1111,6 +1155,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) fprintf(stderr, "Kit Changes!\n"); } */ + lv2_atom_forge_pop( &( lv2_base_ptr->Forge), &seq_frame); pthread_mutex_lock( &( lv2_base_ptr->Load_Mutex)); @@ -1218,7 +1263,7 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) static void DR_LV2_DeActivate( LV2_Handle instance) { - fprintf( stderr, "LV2 DeActivate!\n"); + DR_LOG_INFO_0( "LV2 DeActivate!"); } @@ -1235,13 +1280,13 @@ static void DR_LV2_Cleanup( LV2_Handle Instance_Ptr) DRT_LV2_Base *lv2_base_ptr = (DRT_LV2_Base *)Instance_Ptr; - fprintf( stderr, "LV2 Cleanup!\n"); + DR_LOG_INFO_0( "LV2 Cleanup!"); - DR_Tasks_Dump( &( lv2_base_ptr->Base)); - DR_Kits_Stats_Dump( &( lv2_base_ptr->Base)); + DR_Tasks_Dump(); + DR_Kits_Stats_Dump(); - if( ( status = DR_DataStruct_DeInit( &( lv2_base_ptr->Base))) != DRS_OK) + if( ( status = DR_DataStruct_DeInit()) != DRS_OK) { printf( "Can't deinit data structures (%d)!\n", status); } @@ -1250,7 +1295,6 @@ static void DR_LV2_Cleanup( LV2_Handle Instance_Ptr) free( lv2_base_ptr->Right); free( lv2_base_ptr->Left); free( lv2_base_ptr->Request_Buf); - free( lv2_base_ptr); } @@ -1270,7 +1314,7 @@ static LV2_State_Status DR_LV2_Save_State( LV2_Handle instance LV2_State_Status lv2_status = LV2_STATE_SUCCESS; - fprintf( stderr, "LV2 Save State!\n"); + DR_LOG_INFO_0( "LV2 Save State!"); return( lv2_status); } @@ -1291,7 +1335,7 @@ static LV2_State_Status DR_LV2_Restore_State( LV2_Handle ins LV2_State_Status lv2_status = LV2_STATE_SUCCESS; - fprintf( stderr, "LV2 Restore State!\n"); + DR_LOG_INFO_0( "LV2 Restore State!"); return( lv2_status); } diff --git a/lv2_plugin.h b/lv2_plugin.h index 29493f9..1bf6011 100644 --- a/lv2_plugin.h +++ b/lv2_plugin.h @@ -261,8 +261,6 @@ typedef struct typedef struct DRT_LV2_Base { - DRT_Base Base; - // Ports float *Master_Left; float *Master_Right; @@ -286,6 +284,9 @@ typedef struct DRT_LV2_Base LV2_URID_Map *Map_Ptr; DRT_Drummer_URIS URIS; + // Logger + LV2_Log_Logger Logger; + // Kit info DRT_Kit *Kit_Cur_Ptr; uint8_t Bank_Id_LSB; @@ -361,6 +362,8 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI { URIS->atom_object = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Object); URIS->midi_event = Map_Ptr->map( Map_Ptr->handle, "http://lv2plug.in/ns/ext/midi#MidiEvent"); + + /* URIS->string_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__String); URIS->bool_urid = Map_Ptr->map( Map_Ptr->handle, LV2_ATOM__Bool); @@ -386,29 +389,19 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI # ifdef _LV2_PLUGIN_C_ - - - - /*----------------------------------------------------------------------------*/ /* Private Definitions */ /*----------------------------------------------------------------------------*/ -# endif // ifdef _LV2_PLUGIN_C_ +#define DRD_MODULE_NAME "lv2" - - -# ifndef _LV2_PLUGIN_C_ - /*----------------------------------------------------------------------------*/ -/* Public Prototypes */ +/* DRT_LV2_Base */ /*----------------------------------------------------------------------------*/ - - -# else // ifndef _LV2_PLUGIN_C_ +DRT_LV2_Base DRG_LV2_Base; @@ -417,10 +410,10 @@ static inline void DR_Map_Drummer_URIS( LV2_URID_Map *Map_Ptr, DRT_Drummer_URI /*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ -/* */ +/* DR_Log */ /*----------------------------------------------------------------------------*/ -static void *DR_LV2_Load_Thread( DRT_LV2_Base *); +DRT_Status DR_LV2_Log_Write( DRT_Log_Type_Id, char *, va_list); @@ -428,7 +421,7 @@ static void *DR_LV2_Load_Thread( DRT_LV2_Base *); /* */ /*----------------------------------------------------------------------------*/ -static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *, uint8_t *); +static void *DR_LV2_Load_Thread(); @@ -436,7 +429,7 @@ static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( DRT_LV2_Base *, uint8_ /* */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_LV2_Kit_Samples_Load( DRT_LV2_Base *, DRT_Kit *); +static inline LV2_Atom *DR_LV2_Message_Midi_Info_Build( uint8_t *); @@ -444,7 +437,15 @@ DRT_Status DR_LV2_Kit_Samples_Load( DRT_LV2_Base *, DRT_Kit *); /* */ /*----------------------------------------------------------------------------*/ -DRT_Status DR_LV2_CurKit_Samples_Load( DRT_LV2_Base *); +DRT_Status DR_LV2_Kit_Samples_Load( DRT_Kit *); + + + +/*----------------------------------------------------------------------------*/ +/* */ +/*----------------------------------------------------------------------------*/ + +DRT_Status DR_LV2_CurKit_Samples_Load(); @@ -460,7 +461,7 @@ static inline void DR_Layer_To_Sample( DRT_Sample *, float); /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_Trigger( DRT_LV2_Base *, int, uint8_t *const, uint32_t); +static inline void DR_Sample_Trigger( int, uint8_t *const, uint32_t); @@ -468,7 +469,7 @@ static inline void DR_Sample_Trigger( DRT_LV2_Base *, int, uint8_t *const, ui /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_Untrigger( DRT_LV2_Base *, int, uint32_t); +static inline void DR_Sample_Untrigger( int, uint32_t); @@ -476,7 +477,7 @@ static inline void DR_Sample_Untrigger( DRT_LV2_Base *, int, uint32_t); /* */ /*----------------------------------------------------------------------------*/ -static inline void DR_Sample_UnSustain( DRT_LV2_Base *, uint32_t); +static inline void DR_Sample_UnSustain( uint32_t); @@ -562,6 +563,21 @@ LV2_SYMBOL_EXPORT const LV2_Descriptor *lv2_descriptor( uint32_t); + + +# else // ifdef _LV2_PLUGIN_C_ + +/*----------------------------------------------------------------------------*/ +/* Public Prototypes */ +/*----------------------------------------------------------------------------*/ + + + + + + + + # endif // ifndef _LV2_PLUGIN_C_