Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeated attempts at input stream request #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Linux/Makefile
8 changes: 8 additions & 0 deletions Linux/env64.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

EBDIR=$( readlink -f -- $(dirname $BASH_SOURCE) )/

# export CPATH=$CPATH:/usr/include/libxml2/
export TARGET_PLATFORM=x86_64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${EBDIR}lib64/
export EBCLIENT=${EBDIR}ebclient

19 changes: 15 additions & 4 deletions Linux/src/exampleClientBidir.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ int main (int argc, char * argv[]) {
S2S_Time startT;
S2S_Time stopT;

int inputRequestAttempts = 2; // Attempt input stream request to Mediator up to N times
int inputRequestAttemptTimeoutMS = 2000; // Wait N milliseconds in between attempts

static struct option lopt[] = {
{"serverHost", 1, NULL, 's'},
Expand Down Expand Up @@ -662,11 +664,20 @@ int main (int argc, char * argv[]) {
if ( !inputType ) inputType = strdup ("speech");
for (i=0; i<inputStreamN; i++) {
char info[2048];
if ( mcloudRequestInputStream (cloudP, inputType, inputStreamA[i], "speech", info, 2048) != S2S_Success ) {
fprintf (stderr, "ERROR unable to request input stream.\n");
return -1;
int attempt;
for (attempt = inputRequestAttempts;; attempt--) {
if ( mcloudRequestInputStream (cloudP, inputType, inputStreamA[i], "speech", info, 2048) == S2S_Success ) {
fprintf(stderr, "INFO: %s\n", info);
break;
}
if (attempt < 2) {
fprintf (stderr, "ERROR unable to request input stream after %d attempts. Giving up.\n", inputRequestAttempts);
return -1; // After the last attempt, we give up
}
fprintf (stderr, "ERROR unable to request input stream after %d of %d attempts. Retrying in %dms\n",
inputRequestAttempts -attempt +1, inputRequestAttempts, inputRequestAttemptTimeoutMS);
Sleep(inputRequestAttemptTimeoutMS);
}
fprintf(stderr, "INFO: %s\n", info);
}
mcloudSetErrorCallback (cloudP, MCloudProcessingQueue, errorCallback, &recvUserData);
mcloudSetBreakCallback (cloudP, MCloudProcessingQueue, breakCallback, &recvUserData);
Expand Down