diff --git a/executables/nr-ue.c b/executables/nr-ue.c index e2882b4224..f72a63d33b 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -851,8 +851,11 @@ void *UE_thread(void *arg) stream_status = STREAM_STATUS_UNSYNC; } else { if (IS_SOFTMODEM_IQPLAYER || IS_SOFTMODEM_IQRECORDER) { - // For IQ recorder-player we force synchronization to happen in 280 ms - while (trashed_frames != 28) { + /* For IQ recorder-player we force synchronization to happen in a fixed duration so that + the replay runs in sync with recorded samples. + */ + const unsigned int sync_in_frames = UE->rfdevice.openair0_cfg->recplay_conf->u_f_sync; + while (trashed_frames != sync_in_frames) { readFrame(UE, &sync_timestamp, true); trashed_frames += 2; } diff --git a/radio/COMMON/record_player.h b/radio/COMMON/record_player.h index 4e6640b561..686fe83d31 100644 --- a/radio/COMMON/record_player.h +++ b/radio/COMMON/record_player.h @@ -72,6 +72,7 @@ typedef struct { #define DEF_SF_DELAY_READ 700 // default read delay µs (860=real) #define DEF_SF_DELAY_WRITE 15 // default write delay µs (15=real) #define DEF_SF_NB_LOOP 5 // default nb loops +#define DEF_F_SYNC 28 // default frames to sync in (280ms) /* help strings definition for config options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ @@ -83,6 +84,9 @@ typedef struct { #define CONFIG_HLP_SF_RDELAY "Delay in microseconds to read a subframe in replay mode" #define CONFIG_HLP_SF_WDELAY "Delay in microseconds to write a subframe in replay mode" #define CONFIG_HLP_USE_MMAP "In replay mode, map iq file in memory before replaying" +#define CONFIG_HLP_F_SYNC "Number of frames the synchronization is forced to complete. Some b200 with worser \ + internal clock drift will not be able to stay synchronized and will require value \ + lesser than 28. Lesser values will require faster machine." /* keyword strings for config options, used in CMDLINE_XXX_DESC macros and printed when -h option is used */ #define CONFIG_OPT_SF_FILE "subframes-file" #define CONFIG_OPT_SF_REC "subframes-record" @@ -93,6 +97,7 @@ typedef struct { #define CONFIG_OPT_SF_WDELAY "subframes-write-delay" #define CONFIG_OPT_USE_MMAP "use-mmap" #define DEVICE_RECPLAY_SECTION "device.recplay" +#define CONFIG_OPT_F_SYNC "sync-in-frames" /* For information only - the macro is not usable in C++ */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ /* command line parameters for USRP record/playback */ @@ -107,6 +112,7 @@ typedef struct { {CONFIG_OPT_SF_RDELAY, CONFIG_HLP_SF_RDELAY, 0, .uptr=&((*recplay_conf)->u_sf_read_delay), .defintval=DEF_SF_DELAY_READ, TYPE_UINT, 0}, \ {CONFIG_OPT_SF_WDELAY, CONFIG_HLP_SF_WDELAY, 0, .uptr=&((*recplay_conf)->u_sf_write_delay), .defintval=DEF_SF_DELAY_WRITE, TYPE_UINT, 0}, \ {CONFIG_OPT_USE_MMAP, CONFIG_HLP_USE_MMAP, PARAMFLAG_BOOL, .uptr=&((*recplay_conf)->use_mmap), .defuintval=1, TYPE_UINT, 0}, \ + {CONFIG_OPT_F_SYNC, CONFIG_HLP_F_SYNC, 0, .uptr=&((*recplay_conf)->u_f_sync), .defuintval=DEF_F_SYNC, TYPE_UINT, 0}, \ }/*! \brief Record Player Configuration and state */ typedef struct { char *u_sf_filename; // subframes file path @@ -117,6 +123,7 @@ typedef struct { unsigned int use_mmap; // default is to use mmap unsigned int u_sf_replay; // replay mode (if 1) unsigned int u_sf_record; // record mode (if 1) + unsigned int u_f_sync; // number of frames sync will complete } recplay_conf_t; typedef struct {