From 31cf9d6f30889217deb2ef50eb3bb562407a13ce Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sun, 5 Feb 2012 16:15:15 +0300 Subject: [PATCH] padsp: wait for context initialization in ioctl(SNDCTL_DSP_GETOSPACE) Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=45643 Signed-off-by: Sergei Trofimovich --- src/utils/padsp.c | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/src/utils/padsp.c b/src/utils/padsp.c index a8bc8d2..91b5790 100644 --- a/src/utils/padsp.c +++ b/src/utils/padsp.c @@ -2215,6 +2215,23 @@ static int dsp_ioctl(fd_info *i, unsigned long request, void*argp, int *_errno) pa_threaded_mainloop_lock(i->mainloop); + /* If I/O is just started context may be not initialized yet. */ + for (;;) { + pa_context_state_t state; + + state = pa_context_get_state(i->context); + + if (state == PA_CONTEXT_READY) + break; + if (!PA_CONTEXT_IS_GOOD(state)) + { + break; + } + + /* Wait until the context is ready */ + pa_threaded_mainloop_wait(i->mainloop); + } + fix_metrics(i); if (request == SNDCTL_DSP_GETOSPACE) { -- 1.7.8.4