[IMPROVE] Buffer: add low and enough subbuffers callbacks to the buffer 37/14137/3
authorAlexander Aksenov <a.aksenov@samsung.com>
Tue, 24 Dec 2013 10:31:32 +0000 (14:31 +0400)
committerVyacheslav Cherkashin <v.cherkashin@samsung.com>
Thu, 27 Feb 2014 12:41:18 +0000 (04:41 -0800)
Change-Id: I2927d5a8f48dddc35f00b491b038086f8a088341
Signed-off-by: Alexander Aksenov <a.aksenov@samsung.com>
buffer/swap_buffer_module.c

index 3f3880a..fb0f72b 100644 (file)
@@ -197,6 +197,13 @@ ssize_t swap_buffer_write(void *data, size_t size)
 
        result = size;
 
+       if ((get_writable_buf_cnt() < min_writable_bufs) &&
+           !(swap_buffer_status & BUFFER_PAUSE)) {
+               swap_buffer_status |= BUFFER_PAUSE;
+               if (low_mem_cb != NULL)
+                       low_mem_cb();
+       }
+
        /* Unlock sync (Locked in get_from_write_list()) */
 buf_write_sem_post:
        sync_unlock(&buffer_to_write->buffer_sync);
@@ -245,6 +252,13 @@ int swap_buffer_release(struct swap_subbuffer **subbuffer)
        /* Add to write list */
        add_to_write_list(*subbuffer);
 
+       if ((swap_buffer_status & BUFFER_PAUSE) &&
+           (get_writable_buf_cnt() >= enough_writable_bufs)) {
+               swap_buffer_status &= ~BUFFER_PAUSE;
+               if (enough_mem_cb != NULL)
+                       enough_mem_cb();
+       }
+
        return E_SB_SUCCESS;
 }
 EXPORT_SYMBOL_GPL(swap_buffer_release);