diff options
author | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-05 15:47:07 +0100 |
---|---|---|
committer | Fulup Ar Foll <fulup@iot.bzh> | 2017-11-05 15:47:07 +0100 |
commit | 0d27b111915ff9a59b4ff9e0a42b9fe4dd1010ea (patch) | |
tree | c63ee9b463e31ffa39984674384e6cabba44d92a /alsa-hook | |
parent | d52e5cf217ac3dfd348e80e26eb6d8844c78fc1e (diff) |
Many any error fatal in Synchronous mode
Diffstat (limited to 'alsa-hook')
-rw-r--r-- | alsa-hook/PolicyAlsaHook.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/alsa-hook/PolicyAlsaHook.c b/alsa-hook/PolicyAlsaHook.c index 6f88bca..f686b4c 100644 --- a/alsa-hook/PolicyAlsaHook.c +++ b/alsa-hook/PolicyAlsaHook.c @@ -95,7 +95,7 @@ typedef struct { sem_t semaphore; long timeout; int count; - int error; + int errcount; afbRequestT **request; afbRequestT **release; afbEventT **event; @@ -196,7 +196,6 @@ static void OnSuccessCB(void* UNUSED_ARG(ctx) , void* handle, json_object* respo if (afbClient->synchronous) { if (afbClient->verbose) printf("OnSuccessCB One Request Done\n"); sem_post (&afbClient->semaphore); - afbClient->error=0; } else if (afbClient->count == 0) { if (afbClient->verbose) printf("OnSuccessCB No More Waiting Request\n"); sem_post (&afbClient->semaphore); @@ -214,7 +213,7 @@ static void OnFailureCB(void* UNUSED_ARG(ctx), void* handle, const char *status, sd_event_source_unref(afbRequest->evtSource); free(afbRequest->callIdTag); - afbClient->error=1; + afbClient->errcount++; sem_post (&afbClient->semaphore); } @@ -238,7 +237,7 @@ int OnTimeoutCB (sd_event_source* source, uint64_t timer, void* handle) { SNDERR("\nON-TIMEOUT Call Request Fail URI=%s\n", afbClient->uri); // Close PCM and release waiting client - afbClient->error=1; + afbClient->errcount=1; sem_post (&afbClient->semaphore); return 0; @@ -268,7 +267,10 @@ static int CallWithTimeout(afbClientT *afbClient, afbRequestT *afbRequest, int c afbClient->count ++; // in synchronous mode we wait for CB to return - if (afbClient->synchronous) sem_wait(&afbClient->semaphore); + if (afbClient->synchronous) { + sem_wait(&afbClient->semaphore); + if (afbClient->errcount) goto OnErrorExit; + } return 0; @@ -282,6 +284,10 @@ static int LaunchCallRequest(afbClientT *afbClient, hookActionT action) { pthread_t tid; int err, idx; + // each callback on error add one to error count. + + afbClient->errcount = 0; + switch (action) { case HOOK_INSTALL: { @@ -369,7 +375,7 @@ static int AlsaCloseHook(snd_pcm_hook_t *hook) { // wait for all call request to return if (!afbClient->synchronous) sem_wait(&afbClient->semaphore); - if (afbClient->error) { + if (afbClient->errcount) { fprintf (stderr, "AlsaCloseHook: Notice exit before audio-4a response\n"); goto OnErrorExit; } @@ -646,7 +652,7 @@ int PLUGIN_ENTRY_POINT (snd_pcm_t *pcm, snd_config_t *conf) { // wait for all call request to return if (!afbClient->synchronous) sem_wait(&afbClient->semaphore); - if (afbClient->error) { + if (afbClient->errcount) { fprintf (stderr, "PCM Authorisation Deny from AAAA Controller (AGL Advanced Audio Agent)\n"); goto OnErrorExit; } |