Skip to content

Commit

Permalink
1) Added caps for sync clock technology devices
Browse files Browse the repository at this point in the history
2) Added system_ready function in generic wrapper to request activation of default device if there is none
3) Extended request command to support type to request state switch and classes to combine stateswitch with ident to select a device
4) Realized automatic device activation in QT audio host
  • Loading branch information
hkhauke committed Mar 4, 2024
1 parent 4b5efa2 commit dc61631
Show file tree
Hide file tree
Showing 15 changed files with 248 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,14 @@ SECTION PROPERTIES
DESCRIPTOR = "JVX_GENW_NUM_OUTPUT_DUMMIES";
GENERATE_ENTRY_CONFIG_FILE = "yes";
INIT_SET = 0;
};
};

SECTION triggerActivateDefaultDevice
{
DESCRIPTION = "Trigger activation of default device at startup"; // Defaults to NAME if not present
TYPE = "JVX_DATAFORMAT_BOOL";
INIT_SET = 0;
};

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,82 @@ CjvxGenericWrapperTechnology::get_configuration(jvxCallManagerConfiguration* cal
return(JVX_NO_ERROR);
}

jvxErrorType
CjvxGenericWrapperTechnology::system_ready()
{
jvxBool anySelected = false;

if (genGenericWrapper_technology::properties_selected_active.triggerActivateDefaultDevice.value == c_true)
{
for (auto& elm : _common_tech_set.lstDevices)
{
jvxState stat = JVX_STATE_NONE;
elm.hdlDev->state(&stat);
if (stat > JVX_STATE_NONE)
{
anySelected = true;
break;
}
}

if (!anySelected)
{
jvxBool doneSelect = false;
jvxSize checkCapsDevices[2] =
{
(jvxSize)jvxDeviceCapabilityTypeShift::JVX_DEVICE_CAPABILITY_DUPLEX_SHIFT,
(jvxSize)jvxDeviceCapabilityTypeShift::JVX_DEVICE_CAPABILITY_OUTPUT_SHIFT
};
for (int i = 0; i < 2; i++)
{
for (auto& elm : _common_tech_set.lstDevices)
{
jvxDeviceCapabilities caps;
elm.hdlDev->capabilities_device(caps);
if (jvx_bitTest(caps.capsFlags, checkCapsDevices[i]))
{
if (jvx_bitTest(caps.flags, (int)jvxDeviceCapabilityFlagsShift::JVX_DEVICE_CAPABILITY_FLAGS_DEFAULT_DEVICE_SHIFT))
{
jvxApiString nm;
jvxComponentIdentification id;
elm.hdlDev->name(&nm);
elm.hdlDev->request_specialization(nullptr, &id, nullptr);
id.slotid = _common_set.theComponentType.slotid;
CjvxReportCommandRequest_ss_id req(jvxReportCommandRequest::JVX_REPORT_COMMAND_REQUEST_COMPONENT_STATESWITCH, id, jvxStateSwitch::JVX_STATE_SWITCH_SELECT, nm.c_str());
_request_command(req);
doneSelect = true;
break;
}
}
}
if (doneSelect)
{
break;
}
}

if (!doneSelect)
{
for (auto& elm : _common_tech_set.lstDevices)
{
jvxDeviceCapabilities caps;
elm.hdlDev->capabilities_device(caps);
if (jvx_bitTest(caps.flags, (int)jvxDeviceCapabilityFlagsShift::JVX_DEVICE_CAPABILITY_FLAGS_DEFAULT_DEVICE_SHIFT))
{
jvxApiString nm;
elm.hdlDev->name(&nm);
CjvxReportCommandRequest_ss_id req(jvxReportCommandRequest::JVX_REPORT_COMMAND_REQUEST_COMPONENT_STATESWITCH, _common_set.theComponentType, jvxStateSwitch::JVX_STATE_SWITCH_SELECT, nm.c_str());
_request_command(req);
doneSelect = true;
break;
}
}
}
}
}
return(JVX_NO_ERROR);
}

jvxErrorType
CjvxGenericWrapperTechnology::set_property(
jvxCallManagerProperties& callGate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ enum class jvxWavFileType

// class CjvxGenericWrapperDevice;

class CjvxGenericWrapperTechnology: public JVX_MY_BASE_CLASS_T, public IjvxConfiguration, public IjvxExternalAudioChannels, public genGenericWrapper_technology
class CjvxGenericWrapperTechnology: public JVX_MY_BASE_CLASS_T, public IjvxConfiguration,
public IjvxExternalAudioChannels, public genGenericWrapper_technology
{
friend CjvxGenericWrapperTechnology_hostRelocator;
friend CjvxGenericWrapperDevice;
Expand Down Expand Up @@ -84,6 +85,7 @@ class CjvxGenericWrapperTechnology: public JVX_MY_BASE_CLASS_T, public IjvxConfi
virtual jvxErrorType JVX_CALLINGCONVENTION get_configuration(jvxCallManagerConfiguration* callConf,
IjvxConfigProcessor* processor, jvxHandle* sectionWhereToAddAllSubsections)override;

virtual jvxErrorType JVX_CALLINGCONVENTION system_ready() override;

virtual jvxErrorType JVX_CALLINGCONVENTION register_one_set(jvxBool is_input, jvxSize num_channels, jvxInt32 sRate, jvxSize* register_id, IjvxExternalAudioChannels_data* ref, const char*)override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ CjvxAudioSyncClockDevice::init(CjvxAudioSyncClockTechnology* ptr)
numInChannelsMax = ptr->genSyncClock_technology::config_select.init_number_in_channels_max.value;
numOutChannelsMax = ptr->genSyncClock_technology::config_select.init_number_out_channels_max.value;

// Set the device capabilities
jvx_bitZSet(_common_set_device.caps.capsFlags, (int)jvxDeviceCapabilityTypeShift::JVX_DEVICE_CAPABILITY_DUPLEX_SHIFT);
jvx_bitZSet<jvxCBitField16>(_common_set_device.caps.flags, (int)jvxDeviceCapabilityFlagsShift::JVX_DEVICE_CAPABILITY_FLAGS_DEFAULT_DEVICE_SHIFT);
_common_set_device.report = static_cast<IjvxDevice_report*>(parentTech);

}

jvxErrorType
Expand Down Expand Up @@ -282,7 +287,11 @@ CjvxAudioSyncClockDevice::core_buffer_run()
assert(res == JVX_NO_ERROR);
}


jvxErrorType
CjvxAudioSyncClockDevice::done_configuration()
{
return JVX_NO_ERROR;
}

void
CjvxAudioSyncClockDevice::timerCallback()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class CjvxAudioSyncClockTechnology;

class CjvxAudioSyncClockDevice : public CjvxAudioDevice,
class CjvxAudioSyncClockDevice : public CjvxAudioDevice, public IjvxConfigurationDone,
#ifndef JVX_SYNCED_CLOCK_WINDOWS
public IjvxThreads_report,
#endif
Expand Down Expand Up @@ -73,6 +73,10 @@ class CjvxAudioSyncClockDevice : public CjvxAudioDevice,
JVX_CONNECTION_FEEDBACK_TYPE(fdb)) override;

// ===================================================================================

virtual jvxErrorType JVX_CALLINGCONVENTION done_configuration() override;

// ===================================================================================

virtual jvxErrorType JVX_CALLINGCONVENTION process_start_icon(
jvxSize pipeline_offset , jvxSize* idx_stage,
Expand All @@ -98,6 +102,15 @@ class CjvxAudioSyncClockDevice : public CjvxAudioDevice,
jvxErrorType wokeup(jvxInt64 timestamp_us, jvxSize* delta_ms) override;
jvxErrorType stopped(jvxInt64 timestamp_us) override;
#endif


#define JVX_INTERFACE_SUPPORT_CONFIGURATION_DONE
#define JVX_INTERFACE_SUPPORT_BASE_CLASS CjvxAudioDevice

#include "codeFragments/simplify/jvxHiddenInterface_simplify.h"

#undef JVX_INTERFACE_SUPPORT_CONFIGURATION_DONE
#undef JVX_INTERFACE_SUPPORT_BASE_CLASS
};

#endif
2 changes: 1 addition & 1 deletion sources/jvxHosts/jvxHAppHost/src/CjvxAppHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ CjvxAppHost::attach_configuration_submodule(const char* prefix, IjvxConfiguratio
}

jvxErrorType
CjvxAppHost::JVX_CALLINGCONVENTION detach_configuration_submodule(IjvxConfiguration* cfg)
CjvxAppHost::detach_configuration_submodule(IjvxConfiguration* cfg)
{
auto elm = std::find_if(registeredConfigSubmodules.begin(), registeredConfigSubmodules.end(), [&](const CjvxConfigurationSubModule& elm)
{ return elm.cfgRef == cfg; });
Expand Down
3 changes: 3 additions & 0 deletions sources/jvxLibraries/jvx-helpers/src/HjvxMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6981,6 +6981,9 @@ CjvxReportCommandRequest* jvx_command_request_copy_alloc(const CjvxReportCommand
case jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS:
JVX_DSP_SAFE_ALLOCATE_OBJECT(ret, CjvxReportCommandRequest_ss(in));
break;
case jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS_ID:
JVX_DSP_SAFE_ALLOCATE_OBJECT(ret, CjvxReportCommandRequest_ss_id(in));
break;
default:
JVX_DSP_SAFE_ALLOCATE_OBJECT(ret, CjvxReportCommandRequest(in));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ const T* castCommandRequest(const CjvxReportCommandRequest& in)
{
tp = jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS;
}
else if (std::is_same<T, CjvxReportCommandRequest_ss_id>::value)
{
tp = jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS_ID;
}
in.specialization(reinterpret_cast<const jvxHandle**>(&ret), tp);
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ JVX_INTERFACE IjvxConfigurationDone
{
public:
virtual JVX_CALLINGCONVENTION ~IjvxConfigurationDone() {};

//! Note: This function is only called if there is a configuration file. You should use system_ready if the function shall be called in every situation.
virtual jvxErrorType JVX_CALLINGCONVENTION done_configuration() = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class CjvxReportCommandRequest_uid : public CjvxReportCommandRequest // , public

class CjvxReportCommandRequest_ss : public CjvxReportCommandRequest
{
protected:
jvxStateSwitch sswitch_value = JVX_STATE_SWITCH_NONE;

public:
Expand Down Expand Up @@ -315,6 +316,67 @@ class CjvxReportCommandRequest_ss : public CjvxReportCommandRequest
};
};

class CjvxReportCommandRequest_ss_id : public CjvxReportCommandRequest_ss
{
std::string ident_str;

public:

CjvxReportCommandRequest_ss_id(jvxReportCommandRequest reqArg, jvxComponentIdentification cpArg, jvxStateSwitch ssArg,
const char* ident = nullptr,
jvxReportCommandBroadcastType broadArg = jvxReportCommandBroadcastType::JVX_REPORT_COMMAND_BROADCAST_NO_FURTHER,
jvxHandle* userDataArg = NULL) :
CjvxReportCommandRequest_ss(reqArg, cpArg, ssArg, broadArg, userDataArg)
{
type = jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS_ID;
if (ident)
{
ident_str = ident;
}
};

~CjvxReportCommandRequest_ss_id()
{
};


CjvxReportCommandRequest_ss_id(const CjvxReportCommandRequest& inst) :
CjvxReportCommandRequest_ss(inst)
{
const CjvxReportCommandRequest_ss_id* spec = NULL;
inst.specialization(reinterpret_cast<const jvxHandle**>(&spec),
jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS_ID);
if (spec)
{
jvxApiString astr;
spec->ident(&astr);
ident_str = astr.std_str();

spec->sswitch(&sswitch_value);
}
}
virtual jvxErrorType specialization(const jvxHandle** dat, jvxReportCommandDataType tp) const override
{
if (tp == jvxReportCommandDataType::JVX_REPORT_COMMAND_TYPE_SS_ID)
{
if (dat)
{
*dat = static_cast<const CjvxReportCommandRequest_ss_id*>(this);
}
return JVX_NO_ERROR;
}
return JVX_ERROR_UNSUPPORTED;
};

virtual void ident(jvxApiString* astr) const
{
if (astr)
{
astr->assign(ident_str);
}
};
};

class CjvxReportCommandRequest_seq : public CjvxReportCommandRequest// , public IjvxReportCommandRequest_seq
{
TjvxSequencerEvent theEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ enum class jvxReportCommandDataType
JVX_REPORT_COMMAND_TYPE_UID, // IjvxReportCommandRequest_uid
JVX_REPORT_COMMAND_TYPE_SS, // IjvxReportCommandRequest_ss
JVX_REPORT_COMMAND_TYPE_SEQ, // IjvxReportCommandRequest_seq
JVX_REPORT_COMMAND_TYPE_SS_ID, // IjvxReportCommandRequest_ss_id
JVX_REPORT_COMMAND_TYPE_LIMIT
};

Expand Down Expand Up @@ -351,6 +352,8 @@ enum class jvxReportCommandRequest

JVX_REPORT_COMMAND_REQUEST_TEST_CHAIN_RUN,

JVX_REPORT_COMMAND_REQUEST_COMPONENT_STATESWITCH, // JVX_REPORT_COMMAND_TYPE_SS

JVX_REPORT_COMMAND_REQUEST_LIMIT
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,8 @@ static jvxTextHelpers jvxReportCommandRequest_str[(int)jvxReportCommandRequest::
{"cmdreq-proc-dis-cmplt", "JVX_REPORT_COMMAND_REQUEST_REPORT_PROCESS_DISCONNECT_COMPLETE"},
{"cmdreq-req-upd-prop", "JVX_REPORT_COMMAND_REQUEST_UPDATE_PROPERTY"},
{"cmdreq-proc-test", "JVX_REPORT_COMMAND_REQUEST_REPORT_TEST_SUCCESS"},
{"cmdreq-req-test-chain-run", "JVX_REPORT_COMMAND_REQUEST_TEST_CHAIN_RUN"}
{"cmdreq-req-test-chain-run", "JVX_REPORT_COMMAND_REQUEST_TEST_CHAIN_RUN"},
{"cmdreq-cp-sswitch", "JVX_REPORT_COMMAND_REQUEST_COMPONENT_STATESWITCH"}
};

inline const char* jvxReportCommandRequest_txt(jvxReportCommandRequest coReq)
Expand All @@ -915,7 +916,8 @@ static jvxTextHelpers jvxReportCommandDataType_str[(int)jvxReportCommandDataType
{"cmdreqtp-ident", "JVX_REPORT_COMMAND_TYPE_IDENT"},
{"cmdreqtp-uid", "JVX_REPORT_COMMAND_TYPE_UID"},
{"cmdreqtp-ss", "JVX_REPORT_COMMAND_TYPE_SS"},
{"cmdreqtp-seq", "JVX_REPORT_COMMAND_TYPE_SEQ"}
{"cmdreqtp-seq", "JVX_REPORT_COMMAND_TYPE_SEQ"},
{"cmdreqtp-ss-id", "JVX_REPORT_COMMAND_TYPE_SS_ID"}
};

inline const char* jvxReportCommandDataType_txt(jvxReportCommandDataType coTp)
Expand Down
24 changes: 24 additions & 0 deletions sources/jvxLibraries/jvxLAudioHost/src/configureAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4559,3 +4559,27 @@ configureAudio::post_allow_timer()
preAllowedTimer = false;
stop_timer();
}


void
configureAudio::trigger_select_device(jvxComponentIdentification id, const std::string& ident)
{
jvxSize num = 0;
jvxApiString nmDev;

tpAll[id.tp].slotid = id.slotid;
myParent->involvedHost.hHost->number_components_system(tpAll[id.tp], &num);
for (int i = 0; i < num; i++)
{
myParent->involvedHost.hHost->name_component_system(tpAll[id.tp], i, &nmDev);
if (jvx_compareStringsWildcard(ident, nmDev.std_str()))
{
jvxErrorType res = myParent->involvedHost.hHost->select_component(tpAll[id.tp], i);
if (res == JVX_NO_ERROR)
{
select_device(i);
}
break;
}
}
}
2 changes: 2 additions & 0 deletions sources/jvxLibraries/jvxLAudioHost/src/configureAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class configureAudio: public QDialog, public Ui::ConfigureAudio
void start_timer();
void stop_timer();

void trigger_select_device(jvxComponentIdentification id, const std::string& ident);

protected:

uMainWindow* myParent;
Expand Down
Loading

0 comments on commit dc61631

Please sign in to comment.