Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 546afad..3fa0f9b 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -1185,8 +1185,7 @@ bool create_pf_thread(void)
                            sizeof(thread_stack),
                             0,
                            "Picture load thread"
-                               IF_PRIO(, MAX(PRIORITY_USER_INTERFACE / 2,
-                                       PRIORITY_REALTIME + 1))
+                               IF_PRIO(, PRIORITY_BUFFERING)
                                IF_COP(, CPU)
                                       )
         ) == 0) {
@@ -1385,8 +1384,12 @@ static bool free_slide_prio(int prio)
  */
 int read_pfraw(char* filename, int prio)
 {
+    int ret, fh, data_size, size, hid = 0;
     struct pfraw_header bmph;
-    int fh = rb->open(filename, O_RDONLY);
+    char *bmp_data;
+    struct dim *bm;
+
+    fh = rb->open(filename, O_RDONLY);
     if( fh < 0 ) {
         cache_version = 1;
         return empty_slide_hid;
@@ -1394,31 +1397,28 @@ int read_pfraw(char* filename, int prio)
     else
         rb->read(fh, &bmph, sizeof(struct pfraw_header));

-    int size =  sizeof(struct bitmap) + sizeof( pix_t ) *
-                bmph.width * bmph.height;
+    /* size of the bmp data in the slide */
+    data_size = sizeof(pix_t) * bmph.width * bmph.height;
+    /* size of what we alloc, it adds a struct dim */
+    size      = data_size + sizeof(struct dim);

-    int hid;
-    while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio));
+    while (!(hid = buflib_alloc(&buf_ctx, size)) && free_slide_prio(prio))
+        rb->yield();

     if (!hid) {
         rb->close( fh );
         return 0;
     }

-    rb->yield(); // allow audio to play when fast scrolling
-    struct dim *bm = buflib_get_data(&buf_ctx, hid);
+    bm = buflib_get_data(&buf_ctx, hid);
+    bmp_data = &bm[1];

     bm->width = bmph.width;
     bm->height = bmph.height;
-    pix_t *data = (pix_t*)(sizeof(struct dim) + (char *)bm);
-
-    int y;
-    for( y = 0; y < bm->height; y++ )
-    {
-        rb->read( fh, data , sizeof( pix_t ) * bm->width );
-        data += bm->width;
-    }
+    ret = rb->read(fh, bmp_data, data_size);
     rb->close( fh );
+    if (ret < 0)
+        return 0;
     return hid;
 }

@@ -1804,7 +1804,7 @@ void render_slide(struct slide_data *slide, const int alpha)
                 pixel -= PIXELSTEP_Y;
             }
         }
-        rb->yield(); // allow audio to play when fast scrolling
+//        rb->yield(); // allow audio to play when fast scrolling
         bmp = surface(slide->slide_index); // resync surface due to yield
         ptr = &src[column * bmp->height];         
         p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE;