Skip to content

Commit

Permalink
1) Moved functions to set environment variables to system-min lib - t…
Browse files Browse the repository at this point in the history
…o be available in C

2) Allowed to set backend and debug options for ORC in starter project
  • Loading branch information
hkhauke committed Apr 18, 2024
1 parent 215db80 commit 04a78f0
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,30 +177,6 @@ JVX_STATIC_INLINE void JVX_INIT_LOCALE(const char* newL)
std::cout << "Set LC_NUMERIC to " << locale << std::endl;
}



JVX_STATIC_INLINE bool JVX_GETENVIRONMENTVARIABLE(char* var,char* bufRet,int ll)
{
const char* varP = getenv(var);
std::string str = "";
memset(bufRet, 0, sizeof(char)*ll);
if(varP)
{
str = varP;
// for(int i = 0; i < ll; i++)
// {
// bufRet[i] = varP[i];
//if(varP[i] == 0)
// break;
// }
memcpy(bufRet, str.c_str(), sizeof(char)*str.size());
return(true);
}
return(false);
}

#define JVX_SETENVIRONMENTVARIABLE(var, value, set) setenv(var, value, set)

#define JVX_LOADLIBRARYA(a) dlopen(a, RTLD_LAZY)

JVX_STATIC_INLINE void* JVX_LOADLIBRARYA_PATH(std::string fName, std::string dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,6 @@ JVX_STATIC_INLINE void JVX_INIT_LOCALE(const char* newL)
std::cout << "Set LC_NUMERIC to " << locale << std::endl;
}



JVX_STATIC_INLINE bool JVX_GETENVIRONMENTVARIABLE(char* var,char* bufRet,int ll)
{
const char* varP = getenv(var);
std::string str = "";
memset(bufRet, 0, sizeof(char)*ll);
if(varP)
{
str = varP;
// for(int i = 0; i < ll; i++)
// {
// bufRet[i] = varP[i];
//if(varP[i] == 0)
// break;
// }
memcpy(bufRet, str.c_str(), sizeof(char)*str.size());
return(true);
}
return(false);
}

#define JVX_SETENVIRONMENTVARIABLE(var, value, set) setenv(var, value, set)

#define JVX_LOADLIBRARYA(a) dlopen(a, RTLD_LAZY)

JVX_STATIC_INLINE void* JVX_LOADLIBRARYA_PATH(std::string fName, std::string dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,28 +166,6 @@ static inline void JVX_INIT_LOCALE(const char* newL)
std::cout << "New Locale:" << oldLocale << std::endl;
}

static inline bool JVX_GETENVIRONMENTVARIABLE(char* var,char* bufRet,int ll)
{
const char* varP = getenv(var);
std::string str = "";
memset(bufRet, 0, sizeof(char)*ll);
if(varP)
{
str = varP;
// for(int i = 0; i < ll; i++)
// {
// bufRet[i] = varP[i];
//if(varP[i] == 0)
// break;
// }
memcpy(bufRet, str.c_str(), sizeof(char)*str.size());
return(true);
}
return(false);
}

#define JVX_SETENVIRONMENTVARIABLE(var, val, set) setenv(var, val, set)

#define JVX_LOADLIBRARYA(a) dlopen(a, RTLD_LAZY)

static inline void* JVX_LOADLIBRARYA_PATH(std::string fName, std::string dir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ JVX_CREATE_PROCESS_RESULT JVX_CREATE_PROCESS_WITH_ARGS(JVX_CREATE_PROCESS_HANDLE
// Everything for environment variables
//===============================================

#define JVX_GETENVIRONMENTVARIABLE(a,b,c) GetEnvironmentVariableA(a, b, c)

#define JVX_SETENVIRONMENTVARIABLE(a, b, overwrite_not_in_mswin) SetEnvironmentVariableA(a, b)

#define JVX_PASTE_ENV_VARIABLE_ATT(a, b, c) (std::string)a + JVX_SEPARATOR_DIR + c + ";" + b;

#define JVX_PASTE_ENV_VARIABLE_ADD_PATH_FRONT(a, b) (std::string)b + ";" + a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "jvx_system_threads.h"
#include "jvx_system_mutex.h"
#include "jvx_system_compute.h"
#include "jvx_system_misc.h"

#include "../../jvx_system_includes.h"

Expand Down
7 changes: 6 additions & 1 deletion sources/sub-projects/ayfstarter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ else()
include(${JVX_SUBPRODUCT_ROOT}/cmake/cmake-sdk/paths.sdk.${JVX_PRODUCT}.cmake)
endif()

if(JVX_USE_ORC)
set(AYFSTARTER_SUB_PROJECT_COMPILE_DEFINITIONS "USE_ORC" CACHE INTERNAL "local project compile options")
set(AYFSTARTER_SUB_PROJECT_PCG_FLAGS "-D;JVX_ORC_PROPERTIES" CACHE INTERNAL "local project PCG file options")
endif()

set(AYF_STARTER_STATIC_LIBS
${CMAKE_CURRENT_SOURCE_DIR}/sources/Libraries/ayfstarterlib
)
Expand All @@ -17,7 +22,7 @@ set(AYF_STARTER_AUDIONODE
${CMAKE_CURRENT_SOURCE_DIR}/sources/Components/AudioNodes/ayfAuNStarter
)
jvx_addSubdirs("Configuring shared library for ayfstarter audio node" "${AYF_STARTER_AUDIONODE}" "${JVX_FOLDER_HIERARCHIE_BASE}/AudioNode")

if(NOT JVX_RELEASE_SDK)
set(AYF_STARTER_APPLICATION "")
if(JVX_USE_PART_WEBSERVER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ set(LOCAL_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/target/componentEntry.cpp

# Add the pcg file build steps
set(LOCAL_PCG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/pcg/exports_node.pcg)
set(LOCAL_PCG_FILE_OPTIONS -I ${SUBPRODUCT_AYFSTARTER_LIBS_INCLUDE_PATH}//ayfstarterlib/pcg)
set(LOCAL_PCG_FILE_OPTIONS "${AYFSTARTER_SUB_PROJECT_PCG_FLAGS};-I;${SUBPRODUCT_AYFSTARTER_LIBS_INCLUDE_PATH}//ayfstarterlib/pcg")
# message(FATAL_ERROR "--> ${AYFSTARTER_SUB_PROJECT_PCG_FLAGS} -- ${LOCAL_PCG_FILE_OPTIONS}")

set(LOCAL_LIBS_COMMON
jvx-dsp_static
Expand All @@ -32,8 +33,11 @@ set(LOCAL_LIBS ${LOCAL_LIBS_COMMON} ayfstarterlib_static)
set(IS_JVX_COMPONENT TRUE)

#================================= Step IV =================================
set(LOCAL_COMPILE_DEFINITIONS_COPY "${LOCAL_COMPILE_DEFINITIONS}")
set(LOCAL_COMPILE_DEFINITIONS "${LOCAL_COMPILE_DEFINITIONS_COPY};JVX_PROJECT_NAMESPACE=AYFSTARTER")
set(LOCAL_COMPILE_DEFINITIONS "${LOCAL_COMPILE_DEFINITIONS};${AYFSTARTER_SUB_PROJECT_COMPILE_DEFINITIONS}")
set(LOCAL_COMPILE_DEFINITIONS_COPY "${LOCAL_COMPILE_DEFINITIONS}")

# message(FATAL_ERROR "--> ${LOCAL_COMPILE_DEFINITIONS}")

include(${JVX_CMAKE_DIR}/common_local_lib_foot.cmake)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ CayfAuNStarter::activate()
genStarter_node::register_all(static_cast<CjvxProperties*>(this));

genStarter_node::associate__properties(static_cast<CjvxProperties*>(this),
&processing_lib.prmAsync.volume, 1,
&processing_lib.prmAsync.runorc, 1
&processing_lib.prmAsync.volume, 1

#ifdef USE_ORC
,&processing_lib.prmAsync.runorc, 1
#endif
);

genStarter_node::register_callbacks(static_cast<CjvxProperties*>(this), cb_async_set, this);
Expand Down Expand Up @@ -82,6 +85,13 @@ CayfAuNStarter::local_prepare_connect_icon(JVX_CONNECTION_FEEDBACK_TYPE(fdb))
// if (res != JVX_NO_ERROR) return res;
// <- no longer in use as this call is in template class already
processing_lib.prmInit.bsize = _common_set_icon.theData_in->con_params.buffersize;

#ifdef USE_ORC
processing_lib.prmAsync.orcTokenBackend_ip = genStarter_node::properties.orcBackendIp.value.c_str();
processing_lib.prmAsync.orcTokenBackend_op = genStarter_node::properties.orcBackendOp.value.c_str();
processing_lib.prmAsync.orcTokenDebug = genStarter_node::properties.orcDebugLevel.value.c_str();
#endif

return ayf_starter_prepare(&processing_lib);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace JVX_PROJECT_NAMESPACE {

handle.prmAsync.volume = processing_lib.prmAsync.volume;

ayf_starter_prepare(&handle);
ayf_starter_prepare(&handle, "avx");

ayf_starter_process(&handle, paramIn0, paramOut0, dimInY0, dimOutY0, dimInX0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if(JVX_USE_ORC)
set(LOCAL_COMPILE_DEFINITIONS "${LOCAL_COMPILE_DEFINITIONS};USE_ORC")
set(LOCAL_COMPILE_DEFINITIONS "${LOCAL_COMPILE_DEFINITIONS};${ORC_COMPILE_DEFINITIONS}")
endif()
set(LOCAL_COMPILE_DEFINITIONS "${LOCAL_COMPILE_DEFINITIONS};${AYFSTARTER_SUB_PROJECT_COMPILE_DEFINITIONS}")

set(BUILD_STATIC TRUE)
set(IS_C_LIB TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ struct ayf_starter_init
struct ayf_starter_async
{
jvxData volume;

// Orc arguments only useful if USE_ORC. Hoiwever we do not ifdef these variables as we
// should not ifdef in header files to prevent undesired seg faults!!!
jvxCBool runorc;
const char* orcTokenBackend_ip;
const char* orcTokenBackend_op;
const char* orcTokenDebug;
};

struct ayf_starter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,36 @@ SECTION volume
CALLBACK_SET_POSTHOOK = "async_starterlib_set";
};


ifdef JVX_ORC_PROPERTIES

SECTION runorc
{
DESCRIPTION = "Flag to involve ORC";
TYPE = "JVX_DATAFORMAT_BOOL";
ASSOCIATE_EXTERNAL = "yes";
CALLBACK_SET_POSTHOOK = "async_starterlib_set";
};

SECTION orcBackendIp
{
DESCRIPTION = "Backend specification ip";
TYPE = "JVX_DATAFORMAT_STRING";
INIT_SET = "avx";
};

SECTION orcBackendOp
{
DESCRIPTION = "Backend specification op";
TYPE = "JVX_DATAFORMAT_STRING";
INIT_SET = "avx";
};

SECTION orcDebugLevel
{
DESCRIPTION = "Debug level for orc";
TYPE = "JVX_DATAFORMAT_STRING";
INIT_SET = "0";
};

endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "volume.orc.h"
#endif

#include "jvx_system.h"

struct ayf_starter_prv
{
struct ayf_starter_init prmInitCopy;
Expand All @@ -17,6 +19,11 @@ jvxDspBaseErrorType ayf_starter_init(struct ayf_starter* hdl, jvxSize bsize)
hdl->prmInit.bsize = bsize;
hdl->prmAsync.volume = 1.0;
hdl->prmAsync.runorc = c_true;

hdl->prmAsync.orcTokenBackend_ip = NULL;
hdl->prmAsync.orcTokenBackend_op = NULL;
hdl->prmAsync.orcTokenDebug = NULL;

return JVX_NO_ERROR;
}
return JVX_ERROR_WRONG_STATE;
Expand All @@ -33,6 +40,27 @@ jvxDspBaseErrorType ayf_starter_prepare(struct ayf_starter* hdl)
ptr->prmAsyncCopy = hdl->prmAsync;
ptr->prmInitCopy = hdl->prmInit;

#ifdef USE_ORC
if (hdl->prmAsync.orcTokenDebug)
{
JVX_SETENVIRONMENTVARIABLE("ORC_DEBUG", hdl->prmAsync.orcTokenDebug, "DUMMY");
}

// Initialize the first call - the backend is fixed after that
if (hdl->prmAsync.orcTokenBackend_ip)
{
// Initialize backend - will only work at the first time
JVX_SETENVIRONMENTVARIABLE("ORC_BACKEND", hdl->prmAsync.orcTokenBackend_ip, "DUMMY");
}
volume_orc_double_ip(NULL, 1.0, 0);

if (hdl->prmAsync.orcTokenBackend_op)
{
JVX_SETENVIRONMENTVARIABLE("ORC_BACKEND", hdl->prmAsync.orcTokenBackend_op, "DUMMY");
}
volume_orc_double(NULL, NULL, 1.0, 0);
#endif

hdl->prv = ptr;
return JVX_NO_ERROR;
}
Expand Down

0 comments on commit 04a78f0

Please sign in to comment.