diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/puzzles/malloc.c | 38 | ||||
-rw-r--r-- | apps/plugins/puzzles/rockbox.c | 24 |
2 files changed, 55 insertions, 7 deletions
diff --git a/apps/plugins/puzzles/malloc.c b/apps/plugins/puzzles/malloc.c index d9943c6b40..47a7137459 100644 --- a/apps/plugins/puzzles/malloc.c +++ b/apps/plugins/puzzles/malloc.c | |||
@@ -14,12 +14,40 @@ | |||
14 | int allocs = 0; | 14 | int allocs = 0; |
15 | int frees = 0; | 15 | int frees = 0; |
16 | 16 | ||
17 | bool audiobuf_available = | ||
18 | #ifndef COMBINED | ||
19 | true; | ||
20 | #else | ||
21 | false; | ||
22 | #endif | ||
23 | |||
24 | static bool grab_audiobuf(void) | ||
25 | { | ||
26 | if(!audiobuf_available) | ||
27 | return false; | ||
28 | |||
29 | if(rb->audio_status()) | ||
30 | rb->audio_stop(); | ||
31 | |||
32 | size_t sz, junk; | ||
33 | void *audiobuf = rb->plugin_get_audio_buffer(&sz); | ||
34 | extern char *giant_buffer; | ||
35 | |||
36 | add_new_area(audiobuf, sz, giant_buffer); | ||
37 | audiobuf_available = false; | ||
38 | return true; | ||
39 | } | ||
40 | |||
17 | void *smalloc(size_t size) { | 41 | void *smalloc(size_t size) { |
18 | void *p; | 42 | void *p; |
19 | p = malloc(size); | 43 | p = malloc(size); |
20 | LOGF("allocs: %d", ++allocs); | 44 | LOGF("allocs: %d", ++allocs); |
21 | if (!p) | 45 | if (!p) |
22 | fatal("out of memory"); | 46 | { |
47 | if(grab_audiobuf()) | ||
48 | return smalloc(size); | ||
49 | fatal("out of memory"); | ||
50 | } | ||
23 | return p; | 51 | return p; |
24 | } | 52 | } |
25 | 53 | ||
@@ -30,7 +58,7 @@ void sfree(void *p) { | |||
30 | if (p) { | 58 | if (p) { |
31 | ++frees; | 59 | ++frees; |
32 | LOGF("frees: %d, total outstanding: %d", frees, allocs - frees); | 60 | LOGF("frees: %d, total outstanding: %d", frees, allocs - frees); |
33 | free(p); | 61 | free(p); |
34 | } | 62 | } |
35 | } | 63 | } |
36 | 64 | ||
@@ -46,7 +74,11 @@ void *srealloc(void *p, size_t size) { | |||
46 | q = malloc(size); | 74 | q = malloc(size); |
47 | } | 75 | } |
48 | if (!q) | 76 | if (!q) |
49 | fatal("out of memory"); | 77 | { |
78 | if(grab_audiobuf()) | ||
79 | return srealloc(p, size); | ||
80 | fatal("out of memory"); | ||
81 | } | ||
50 | return q; | 82 | return q; |
51 | } | 83 | } |
52 | 84 | ||
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 86dc9cffd4..3e3bd15f33 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c | |||
@@ -71,6 +71,7 @@ static void fix_size(void); | |||
71 | 71 | ||
72 | static struct viewport clip_rect; | 72 | static struct viewport clip_rect; |
73 | static bool clipped = false; | 73 | static bool clipped = false; |
74 | extern bool audiobuf_available; | ||
74 | 75 | ||
75 | static struct settings_t { | 76 | static struct settings_t { |
76 | int slowmo_factor; | 77 | int slowmo_factor; |
@@ -1026,7 +1027,10 @@ static int pausemenu_cb(int action, const struct menu_item_ex *this_item) | |||
1026 | * care, I bet */ | 1027 | * care, I bet */ |
1027 | return ACTION_EXIT_MENUITEM; | 1028 | return ACTION_EXIT_MENUITEM; |
1028 | #else | 1029 | #else |
1029 | break; | 1030 | if(audiobuf_available) |
1031 | break; | ||
1032 | else | ||
1033 | return ACTION_EXIT_MENUITEM; | ||
1030 | #endif | 1034 | #endif |
1031 | case 9: | 1035 | case 9: |
1032 | if(!midend_num_presets(me)) | 1036 | if(!midend_num_presets(me)) |
@@ -1355,10 +1359,10 @@ void deactivate_timer(frontend *fe) | |||
1355 | 1359 | ||
1356 | #ifdef COMBINED | 1360 | #ifdef COMBINED |
1357 | /* can't use audio buffer */ | 1361 | /* can't use audio buffer */ |
1358 | static char giant_buffer[1024*1024*4]; | 1362 | char giant_buffer[1024*1024*4]; |
1359 | #else | 1363 | #else |
1360 | /* points to audiobuf */ | 1364 | /* points to pluginbuf */ |
1361 | static char *giant_buffer = NULL; | 1365 | char *giant_buffer = NULL; |
1362 | #endif | 1366 | #endif |
1363 | static size_t giant_buffer_len = 0; /* set on start */ | 1367 | static size_t giant_buffer_len = 0; /* set on start */ |
1364 | 1368 | ||
@@ -1566,6 +1570,18 @@ static int mainmenu_cb(int action, const struct menu_item_ex *this_item) | |||
1566 | #else | 1570 | #else |
1567 | break; | 1571 | break; |
1568 | #endif | 1572 | #endif |
1573 | case 4: | ||
1574 | #ifdef COMBINED | ||
1575 | /* audio buf is used, so no playback */ | ||
1576 | /* TODO: neglects app builds, but not many people will | ||
1577 | * care, I bet */ | ||
1578 | return ACTION_EXIT_MENUITEM; | ||
1579 | #else | ||
1580 | if(audiobuf_available) | ||
1581 | break; | ||
1582 | else | ||
1583 | return ACTION_EXIT_MENUITEM; | ||
1584 | #endif | ||
1569 | case 5: | 1585 | case 5: |
1570 | if(!midend_num_presets(me)) | 1586 | if(!midend_num_presets(me)) |
1571 | return ACTION_EXIT_MENUITEM; | 1587 | return ACTION_EXIT_MENUITEM; |