Index: apps/buffering.c =================================================================== --- apps/buffering.c (revision 24120) +++ apps/buffering.c (working copy) @@ -1383,6 +1383,7 @@ void buffering_thread(void) { bool filling = false; + bool shrinking = false; struct queue_event ev; while (true) @@ -1391,7 +1392,7 @@ cancel_cpu_boost(); } - queue_wait_w_tmo(&buffering_queue, &ev, filling ? 5 : HZ/2); + queue_wait_w_tmo(&buffering_queue, &ev, filling ? 5 : HZ/10); switch (ev.id) { @@ -1449,48 +1450,16 @@ update_data_counters(); /* If the buffer is low, call the callbacks to get new data */ - if (num_handles > 0 && data_counters.useful <= conf_watermark) + if (num_handles > 0 && data_counters.useful <= conf_watermark && shrinking == false) { + shrink_buffer(); + shrinking = true; + filling = fill_buffer(); send_event(BUFFER_EVENT_BUFFER_LOW, 0); - -#if 0 - /* TODO: This needs to be fixed to use the idle callback, disable it - * for simplicity until its done right */ -#if MEM > 8 - /* If the disk is spinning, take advantage by filling the buffer */ - else if (storage_disk_is_active() && queue_empty(&buffering_queue)) - { - if (num_handles > 0 && data_counters.useful <= high_watermark) - send_event(BUFFER_EVENT_BUFFER_LOW, 0); - - if (data_counters.remaining > 0 && BUF_USED <= high_watermark) - { - /* This is a new fill, shrink the buffer up first */ - if (!filling) - shrink_buffer(); - filling = fill_buffer(); - update_data_counters(); - } } -#endif -#endif + if (num_handles > 0 && data_counters.useful > conf_watermark) + shrinking = false; - if (queue_empty(&buffering_queue)) { - if (filling) { - if (data_counters.remaining > 0 && BUF_USED < buffer_len) - filling = fill_buffer(); - else if (data_counters.remaining == 0) - filling = false; - } - else if (ev.id == SYS_TIMEOUT) - { - if (data_counters.remaining > 0 && - data_counters.useful <= conf_watermark) { - shrink_buffer(); - filling = fill_buffer(); - } - } - } - } + } } void buffering_init(void)