Skip to content

Topic/rdkemw 12922 - #78

Draft
jthomp007c wants to merge 4 commits into
developfrom
topic/RDKEMW-12922
Draft

Topic/rdkemw 12922#78
jthomp007c wants to merge 4 commits into
developfrom
topic/RDKEMW-12922

Conversation

@jthomp007c

Copy link
Copy Markdown
Contributor

No description provided.

Status: Code is messy needs major clean-up, but does map FFV HAL
functionality and register callbacks for hardware failure and
keyword detection, gets privacy mode. I have removed keyword
detection from xraudio entirely because the HAL does that.
What I'm working on right now is that when the HAL reports
keyword detection, xraudio_keyword_detector_session_event()
is called which expects to have the detector->callback()
set which it is null so there is a segfault.
callback, getting keyword detection, starting to read audio from HAL
Am not correctly setting the read fd in xraudio_thread.
Am not seeing voice ended cb - did see this previously.
Am not stopping reading audio.
Audio data is trash
callback works. Keyword detection callback works. It attempts to
start a voice session upon keyword detection, but this fails in two
ways. One, the session init json is not formatted correctly so VREX
rejects the session. Two, the mic data is bad. This is what I'm
focusing on right now.
Copilot AI review requested due to automatic review settings July 9, 2026 19:37
@jthomp007c
jthomp007c requested a review from a team as a code owner July 9, 2026 19:37
@jthomp007c
jthomp007c marked this pull request as draft July 9, 2026 19:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an FFV HAL interface adapter path (non-USE_RDKV_HAL) and adds multiple USE_RDKV_HAL compile-time conditionals across xraudio and xrsr to alter keyword detection / HAL interaction behavior.

Changes:

  • Add an FFV HAL “interface plugin” adapter (vsdk_ffv_adapter.*) and update plugin loading logic to fall back to it.
  • Add USE_RDKV_HAL-gated behavior changes in keyword detection, session begin handling, and detector lifecycle logic across xrsr/xraudio.
  • Update build inputs/options to include the new adapter source.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/xr-speech-router/xrsr.c Gates keyword detector per-channel fields/logging under USE_RDKV_HAL.
src/xr-speech-router/xrsr_xraudio.c Adds USE_RDKV_HAL conditionals around detector lifecycle and event handling.
src/xr-audio/xraudio.h Makes keyword detector result struct conditional on USE_RDKV_HAL.
src/xr-audio/xraudio.c Adds non-USE_RDKV_HAL behavior in device query and sensitivity-limits API.
src/xr-audio/xraudio_thread.c Adds FFV HAL interface include and USE_RDKV_HAL conditional logic in thread processing.
src/xr-audio/xraudio_output.c Gates EOS/dsp_config init under USE_RDKV_HAL.
src/xr-audio/xraudio_input.c Adds USE_RDKV_HAL conditionals around idle/detect dispatch and open logic.
src/xr-audio/xr_ffv_hal_plugin.h Adds FFV HAL C API wrapper header (copied in-repo).
src/xr_ffv_hal_interface.h Adds FFV HAL interface function-table definitions and helpers.
src/vsdk.c Updates plugin loading to support FFV HAL interface adapter path and USE_RDKV_HAL split.
src/vsdk_ffv_adapter.h Declares the adapter API used when not USE_RDKV_HAL.
src/vsdk_ffv_adapter.c Implements adapter bridging FFV HAL interface into xraudio HAL plugin API.
src/CMakeLists.txt Adds adapter source and enables -g globally.

Comment thread src/vsdk.c
Comment on lines +531 to 535
char *error = dlerror();

#ifdef USE_RDKV_HAL
xraudio_eos_plugin_api_get_t eos_plugin_api_get = (xraudio_eos_plugin_api_get_t)dlsym(handle, "xraudio_eos_plugin_api_get");
char *error = dlerror();
Comment thread src/vsdk.c
Comment on lines +677 to +678
const char *so_path_vd = "/data/jason/usr/lib/libxr-ffv-hal.so";
const char *so_path_mw = "/data/jason/usr/usr/lib/libxr-ffv-hal.so";
Comment thread src/xr-audio/xraudio.c
Comment on lines +1448 to +1450
#else
return(XRAUDIO_RESULT_OK);
#endif
Comment on lines +195 to +200
#ifdef USE_RDKV_HAL
if(!obj->detect_active) {
XLOGD_INFO("ignore keyword detect event");
return;
}
#endif
Comment on lines 537 to +542
XLOGD_WARN("Rejecting keyword detected from source <%s>, session in progress on source <%s>. Restarting keyword detector...", xrsr_src_str(src), xrsr_src_str(current_session_src));
obj->session_rejected = true;
#ifdef USE_RDKV_HAL
xrsr_xraudio_keyword_detect_restart(obj);
//TODO inform new HAL to restart detection? The HAL might do that automatically after some time or after reading mic data, check on this
#endif
Comment thread src/xr-audio/xraudio.h
Comment on lines 226 to 233
uint32_t chan_selected;
xraudio_kwd_endpoints_t endpoints;
#ifdef USE_RDKV_HAL
xraudio_kwd_chan_result_t channels[XRAUDIO_INPUT_MAX_CHANNEL_QTY];
#endif
const char * detector_name;
const char * dsp_name;
float sensitivity;
Comment on lines +2017 to +2023
#ifdef USE_RDKV_HAL
xraudio_session_record_inst_t *instance = &state->record.instances[XRAUDIO_INPUT_SESSION_GROUP_DEFAULT];
if(!xraudio_keyword_detector_session_is_armed(&state->record.keyword_detector)) {
XLOGD_ERROR("detector is not armed");
return;
}
#endif
Comment thread src/CMakeLists.txt
xr-audio/xraudio_atomic.c)

target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror)
target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror -g)
Comment thread src/vsdk_ffv_adapter.c
Comment on lines +514 to +533
static int doit = 1;

if(eos_event != NULL) {
memset(eos_event, 0, sizeof(*eos_event));
}

ssize_t rc = read(obj->fd, data, size);
if(rc < 0) {
if((errno == EAGAIN) || (errno == EINTR)) {
return(0);
}
return(-1);
}
if(doit) {
for(uint32_t i = 0; i < (uint32_t)rc; i+=8) {
XLOGD_INFO("data[%d]: 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x", i, data[i], data[i+1], data[i+2], data[i+3], data[i+4], data[i+5], data[i+6], data[i+7]);
}
doit = 0;
}
return((int32_t)rc);
Comment thread src/xr-audio/xraudio.c
Comment on lines +307 to +310
#ifndef USE_RDKV_HAL
obj->devices_input |= *inputs;
XLOGD_INFO("obtained additional input devices from HAL plugin: <%s>", xraudio_devices_input_str(obj->devices_input));
#endif

xraudio_input_sound_focus_set(state->params.obj_input, XRAUDIO_SDF_MODE_KEYWORD_DETECTION);
#else
XLOGD_INFO("Registering callback %p at state->record.keyword_detector with param 0x%x", detect->callback, detect->param);

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 10 comments.

Comment thread src/vsdk.c
Comment on lines +531 to 535
char *error = dlerror();

#ifdef USE_RDKV_HAL
xraudio_eos_plugin_api_get_t eos_plugin_api_get = (xraudio_eos_plugin_api_get_t)dlsym(handle, "xraudio_eos_plugin_api_get");
char *error = dlerror();
Comment thread src/vsdk.c
Comment on lines +676 to +679
#else
const char *so_path_vd = "/data/jason/usr/lib/libxr-ffv-hal.so";
const char *so_path_mw = "/data/jason/usr/usr/lib/libxr-ffv-hal.so";
#endif
Comment on lines 128 to +132
obj->play_bumper = 0;
obj->dsp_config = *dsp_config;
obj->hal_plugin = vsdk_hal_plugin_get();
obj->eos_plugin = vsdk_eos_plugin_get();
obj->ovc_plugin = vsdk_ovc_plugin_get();

#ifdef USE_RDKV_HAL
obj->dsp_config = *dsp_config;

xraudio_input_sound_focus_set(state->params.obj_input, XRAUDIO_SDF_MODE_KEYWORD_DETECTION);
#else
XLOGD_INFO("Registering callback %p at state->record.keyword_detector with param 0x%x", detect->callback, detect->param);
void xraudio_msg_thread_poll(xraudio_thread_state_t *state, void *msg) {
xraudio_main_queue_msg_thread_poll_t *thread_poll = (xraudio_main_queue_msg_thread_poll_t *)msg;

XLOGD_WARN("state->params.kwd_plugin %p, state->params.out_enabled %d, state->params.hal_plugin %p", state->params.kwd_plugin, state->params.out_enabled, state->params.hal_plugin);
Comment thread src/vsdk_ffv_adapter.c
Comment on lines +76 to +81
//This is not a good test but will do for the moment
if(format.sample_size == 2) {
XLOGD_INFO("sample_size is %d, not a keyword channel", format.sample_size);
return(false);
}
return(true);
Comment thread src/vsdk_ffv_adapter.c
Comment on lines +240 to +252
FFVhalApiStatus_t status = ffv_api->get_capabilities(handle, &ffv_caps);
if(status == EX_NONE) {
caps->input_qty = 1;
caps->input_caps[0] = XRAUDIO_CAPS_INPUT_LOCAL | XRAUDIO_CAPS_INPUT_SELECT;
if(ffv_caps.channelTypes[0] != NULL || ffv_caps.channelTypes[1] != NULL) {
caps->input_caps[0] |= XRAUDIO_CAPS_INPUT_EOS_DETECTION;
}
if(ffv_caps.microphoneChannelCount > 1) {
caps->input_caps[0] |= XRAUDIO_CAPS_INPUT_LOCAL_32_BIT;
}
caps->output_qty = 0;
}
}
Comment thread src/vsdk_ffv_adapter.c
Comment on lines +493 to +498
if((obj->hal_obj->ffv_api != NULL) && (obj->hal_obj->ffv_api->close_channel != NULL) && (obj->channel_type != NULL)) {
(void)obj->hal_obj->ffv_api->close_channel(obj->hal_obj->ffv_controller, obj->channel_type);
}
if(obj->fd >= 0) {
(void)close(obj->fd);
}
Comment thread src/vsdk_ffv_adapter.c
Comment on lines +460 to +463
const char *channel = vsdk_ffv_channel_is_keyword(format) ? "KEYWORD" : "MICROPHONES";
FFVhalFileDescriptor fd = -1;
XLOGD_INFO("channel %s, device 0x%x", channel, device);
if(obj->ffv_api->open_channel(obj->ffv_controller, channel, &fd) != EX_NONE) {
Comment thread src/CMakeLists.txt
xr-audio/xraudio_atomic.c)

target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror)
target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror -g)
Comment thread src/vsdk_ffv_adapter.c
# limitations under the License.
##########################################################################
*/
#ifndef USE_RDKV_HAL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just don't compile this file at all instead of wrapping it in ifdef

Comment thread src/CMakeLists.txt
xraudio_config.h
rdkx_logger.h
vsdk.c
vsdk_ffv_adapter.c

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conditionally add this file

Comment thread src/CMakeLists.txt
xr-audio/xraudio_atomic.c)

target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror)
target_compile_options(xr-voice-sdk PUBLIC -fPIC -rdynamic -Wall -Werror -g)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding -g shouldn't be necessary. obviously don't commit this...

Comment thread src/vsdk.c
static void vsdk_parse_options(bool *curtail_xlog, bool *curtail_xraudio, bool *xraudio_allow_input_failure);
static bool vsdk_load_plugin_ffv(vsdk_ffv_plugin_handles_t *handles);
static void *vsdk_load_plugin_ffv_hal(bool *out_enabled);
#ifdef USE_RDKV_HAL //We can put these back later. Right now it's going to load the default ones along with the new HAL, so just avoiding it for the time being

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should include the entire RDKV FFV HAL (hal, kwd, alg, sdf, ovc) - completely replaced by the new FFV HAL.

Comment thread src/vsdk.c
#ifdef USE_RDKV_HAL
const char *so_path_vd = "/vendor/lib/libxraudio-ffv-hal.so";
const char *so_path_mw = "/usr/lib/libxraudio-ffv-hal.so";
#else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there is any value in trying to re-use this function for the new FFV HAL. Seems like it would be better to create a new function instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants