aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bachmann <manuel.bachmann@iot.bzh>2016-05-27 14:16:54 +0200
committerManuel Bachmann <manuel.bachmann@iot.bzh>2016-05-27 14:16:54 +0200
commita1ed2c12ac2a305a54f35a3dad99b85cbe3113e6 (patch)
tree8fb3358952ce31f85f75c6ba1ea2c113f2aefa13
parented6b81ea46629ae69176e77aec14844257dc36af (diff)
Improve Audio plugin PulseAudio backend
>100 return values are strangely returned by PulseAudio when doing an initial connection from afb-daemon. Just ignore them, because it breaks the logic. Allow 2 seconds of initial asynchronous connection (it should return earlier anyways). Signed-off-by: Manuel Bachmann <manuel.bachmann@iot.bzh>
-rw-r--r--plugins/audio/audio-pulse.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/plugins/audio/audio-pulse.c b/plugins/audio/audio-pulse.c
index 50ddf40c..739b3774 100644
--- a/plugins/audio/audio-pulse.c
+++ b/plugins/audio/audio-pulse.c
@@ -58,14 +58,16 @@ unsigned char _pulse_init (const char *name, audioCtxHandleT *ctx) {
/* 1 second should be sufficient to retrieve sink info */
gettimeofday (&tv_start, NULL);
gettimeofday (&tv_now, NULL);
- while (tv_now.tv_sec - tv_start.tv_sec <= 1) {
+ while (tv_now.tv_sec - tv_start.tv_sec <= 2) {
pa_mainloop_iterate (pa_loop, 0, &ret);
if (ret == -1) {
fprintf (stderr, "Stopping PulseAudio backend...\n");
return 0;
}
- if (ret > 0) {
+
+ /* 0 and >100 are returned by PulseAudio itself */
+ if ((ret > 0)&&(ret < 100)) {
/* found a matching sink from callback */
fprintf (stderr, "Success : using sink n.%d\n", ret-1);
ctx->audio_dev = (void*)dev_ctx_p[ret-1];
@@ -395,7 +397,6 @@ void _pulse_sink_list_cb (pa_context *context, const pa_sink_info *info,
found = strstr (device, ":");
if (found) device[found-device] = '\0';
-fprintf(stderr, "BEFORE PULSE_FIND_CARDS\n");
/* new sink, find all the cards it manages, fail if none */
cards = _pulse_find_cards (device);
free (device);
@@ -403,7 +404,6 @@ fprintf(stderr, "BEFORE PULSE_FIND_CARDS\n");
return;
/* everything is well, register it in global array */
-fprintf(stderr, "NEW SINK IN GLOBAL ARRAY\n");
dev_ctx_p_t->sink_name = strdup (info->name);
dev_ctx_p_t->card_name = cards;
dev_ctx_p_t->mute = info->mute;