From e1b8414c51a9e9a12532930fef55a3bedaadc2f6 Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Sat, 13 Apr 2024 09:54:07 +0200 Subject: [PATCH] - Fix Kit_Update_Reply on async sample load by using DRG_LV2_Base.Kit_Updated_Flag. --- lv2_plugin.c | 60 +++++++++++++++++++++++++++++----------------------- lv2_plugin.h | 1 + 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/lv2_plugin.c b/lv2_plugin.c index 210268c..a6e24f6 100644 --- a/lv2_plugin.c +++ b/lv2_plugin.c @@ -240,18 +240,9 @@ DRT_Status DR_LV2_CurKit_Sample_Load() status = DR_LV2_Kit_Sample_Load( Kit_Ptr); - LV2_Atom_Forge_Frame obj_frame; - + DRG_LV2_Base.Kit_Updated_Flag = true; DR_LOG_INFO_0( "Sample loaded!"); - - lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0); - lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg); - lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Update_Reply, 0); - lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Id); // Cur kit Id - lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame); - - DR_LOG_INFO_2( "Kit Update Reply: Kit_Id: (%ld) Kit_Name: [%s]", DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Kit_Ptr->Name); } } @@ -649,27 +640,28 @@ static LV2_Handle DR_LV2_Instantiate( const LV2_Descriptor *LV2_Descripto } */ - DRG_LV2_Base.Map_Ptr = NULL; - DRG_LV2_Base.Logger.log = NULL; + DRG_LV2_Base.Map_Ptr = NULL; + DRG_LV2_Base.Logger.log = NULL; - DRG_LV2_Base.Kit_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.Kit_Id_New = DRD_ID_UNKNOWN; - DRG_LV2_Base.Current_Path = NULL; - DRG_LV2_Base.CurReq = -1; + DRG_LV2_Base.Kit_Ptr = NULL; + DRG_LV2_Base.Kit_Id = DRD_ID_UNKNOWN; + DRG_LV2_Base.Kit_Id_New = DRD_ID_UNKNOWN; + 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_Updated_Flag = false; + DRG_LV2_Base.Current_Path = NULL; + DRG_LV2_Base.CurReq = -1; // DRG_LV2_Base.Channel_Id = 0; - DRG_LV2_Base.Zero_Position = 0; + DRG_LV2_Base.Zero_Position = 0; - DRG_LV2_Base.Sustain = false; + DRG_LV2_Base.Sustain = false; - DRG_LV2_Base.Sample_Number = 0; + DRG_LV2_Base.Sample_Number = 0; while( *LV2_Features_Ptr != NULL) { @@ -1336,6 +1328,22 @@ static void DR_LV2_Run( LV2_Handle Instance_Ptr, uint32_t N_Samples) pthread_cond_signal( &( lv2_base_ptr->Load_Cond)); } */ + if( lv2_base_ptr->Kit_Updated_Flag) + { + lv2_base_ptr->Kit_Updated_Flag = false; + + // Send Kit_Update_Reply + LV2_Atom_Forge_Frame obj_frame; + + lv2_atom_forge_frame_time( &( DRG_LV2_Base.Forge), 0); + lv2_atom_forge_object( &( DRG_LV2_Base.Forge), &obj_frame, 1, DRG_LV2_Base.URIS.UI_Msg); + lv2_atom_forge_property_head( &( DRG_LV2_Base.Forge), DRG_LV2_Base.URIS.Kit_Update_Reply, 0); + lv2_atom_forge_long( &( DRG_LV2_Base.Forge), DRG_LV2_Base.Kit_Id); // Cur kit Id + lv2_atom_forge_pop( &( DRG_LV2_Base.Forge), &obj_frame); + + DR_LOG_INFO_2( "Kit Update Reply: Kit_Id: (%ld) Kit_Name: [%s]", DRG_LV2_Base.Kit_Id, DRG_LV2_Base.Kit_Ptr->Name); + } + /* if( current_kit_changed) { diff --git a/lv2_plugin.h b/lv2_plugin.h index ed45d34..85c7d86 100644 --- a/lv2_plugin.h +++ b/lv2_plugin.h @@ -294,6 +294,7 @@ typedef struct DRT_LV2_Base uint8_t Bank_Id_LSB_New; uint8_t Bank_Id_MSB_New; uint8_t Program_Id_New; + int Kit_Updated_Flag; char *Current_Path; char **Request_Buf; int CurReq;