diff options
| author | Marc-André Lureau <marc-andre.lureau@nokia.com> | 2011-04-04 14:33:35 +0300 | 
|---|---|---|
| committer | Colin Guthrie <colin@mageia.org> | 2011-04-04 13:33:56 +0100 | 
| commit | 5d43aba3d5e61756b4336fafc90b92dc1796286d (patch) | |
| tree | 15d0ad9280194008fd09152286e419fe1f4e1d79 | |
| parent | 6ed3a7dcc9de81469c5d35a5256e5f50bd48f804 (diff) | |
bluetooth: drop data every 500ms on oor condition
| -rw-r--r-- | src/modules/bluetooth/module-bluetooth-device.c | 25 | 
1 files changed, 14 insertions, 11 deletions
| diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index e4a2ceff..bd1511bf 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -1671,17 +1671,20 @@ static void thread_func(void *userdata) {                      writable = FALSE;                  } -                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0 && writable) { -                    pa_usec_t time_passed, next_write_at, sleep_for; - -                    /* Hmm, there is no input stream we could synchronize -                     * to. So let's estimate when we need to wake up the latest */ - -                    time_passed = pa_rtclock_now() - u->started_at; -                    next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec); -                    sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0; - -/*                 pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */ +                if ((!u->source || !PA_SOURCE_IS_LINKED(u->source->thread_info.state)) && do_write <= 0) { +                    pa_usec_t sleep_for; +                    pa_usec_t time_passed, next_write_at; + +                    if (writable) { +                        /* Hmm, there is no input stream we could synchronize +                         * to. So let's estimate when we need to wake up the latest */ +                        time_passed = pa_rtclock_now() - u->started_at; +                        next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec); +                        sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0; +                        /* pa_log("Sleeping for %lu; time passed %lu, next write at %lu", (unsigned long) sleep_for, (unsigned long) time_passed, (unsigned long)next_write_at); */ +                    } else +                        /* drop stream every 500 ms */ +                        sleep_for = PA_USEC_PER_MSEC * 500;                      pa_rtpoll_set_timer_relative(u->rtpoll, sleep_for);                      disable_timer = FALSE; | 
