diff options
Diffstat (limited to 'apps/playlist.c')
-rw-r--r-- | apps/playlist.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index ae6ea900d2..367e935006 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -103,6 +103,7 @@ | |||
103 | #include "splash.h" | 103 | #include "splash.h" |
104 | #include "rbunicode.h" | 104 | #include "rbunicode.h" |
105 | #include "root_menu.h" | 105 | #include "root_menu.h" |
106 | #include "plugin.h" /* To borrow a temp buffer to rewrite a .m3u8 file */ | ||
106 | 107 | ||
107 | #define PLAYLIST_CONTROL_FILE_VERSION 2 | 108 | #define PLAYLIST_CONTROL_FILE_VERSION 2 |
108 | 109 | ||
@@ -3369,6 +3370,8 @@ int playlist_save(struct playlist_info* playlist, char *filename) | |||
3369 | int result = 0; | 3370 | int result = 0; |
3370 | bool overwrite_current = false; | 3371 | bool overwrite_current = false; |
3371 | int* index_buf = NULL; | 3372 | int* index_buf = NULL; |
3373 | char* old_buffer = NULL; | ||
3374 | size_t old_buffer_size = 0; | ||
3372 | 3375 | ||
3373 | if (!playlist) | 3376 | if (!playlist) |
3374 | playlist = ¤t_playlist; | 3377 | playlist = ¤t_playlist; |
@@ -3388,8 +3391,17 @@ int playlist_save(struct playlist_info* playlist, char *filename) | |||
3388 | if (playlist->buffer_size < (int)(playlist->amount * sizeof(int))) | 3391 | if (playlist->buffer_size < (int)(playlist->amount * sizeof(int))) |
3389 | { | 3392 | { |
3390 | /* not enough buffer space to store updated indices */ | 3393 | /* not enough buffer space to store updated indices */ |
3391 | splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); | 3394 | /* Try to get a buffer */ |
3392 | return -1; | 3395 | old_buffer = playlist->buffer; |
3396 | old_buffer_size = playlist->buffer_size; | ||
3397 | playlist->buffer = plugin_get_buffer((size_t*)&playlist->buffer_size); | ||
3398 | if (playlist->buffer_size < (int)(playlist->amount * sizeof(int))) | ||
3399 | { | ||
3400 | playlist->buffer = old_buffer; | ||
3401 | playlist->buffer_size = old_buffer_size; | ||
3402 | splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); | ||
3403 | return -1; | ||
3404 | } | ||
3393 | } | 3405 | } |
3394 | 3406 | ||
3395 | /* in_ram buffer is unused for m3u files so we'll use for storing | 3407 | /* in_ram buffer is unused for m3u files so we'll use for storing |
@@ -3413,6 +3425,11 @@ int playlist_save(struct playlist_info* playlist, char *filename) | |||
3413 | if (fd < 0) | 3425 | if (fd < 0) |
3414 | { | 3426 | { |
3415 | splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); | 3427 | splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR)); |
3428 | if (old_buffer != NULL) | ||
3429 | { | ||
3430 | playlist->buffer = old_buffer; | ||
3431 | playlist->buffer_size = old_buffer_size; | ||
3432 | } | ||
3416 | return -1; | 3433 | return -1; |
3417 | } | 3434 | } |
3418 | 3435 | ||
@@ -3513,6 +3530,11 @@ int playlist_save(struct playlist_info* playlist, char *filename) | |||
3513 | } | 3530 | } |
3514 | 3531 | ||
3515 | cpu_boost(false); | 3532 | cpu_boost(false); |
3533 | if (old_buffer != NULL) | ||
3534 | { | ||
3535 | playlist->buffer = old_buffer; | ||
3536 | playlist->buffer_size = old_buffer_size; | ||
3537 | } | ||
3516 | 3538 | ||
3517 | return result; | 3539 | return result; |
3518 | } | 3540 | } |