mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
Fix FS#8656 - Error saving non-current playlist file
Use the plugin buffer to save the playlist copy if there isnt enough buffer already allocated to the inram copy of the playlist git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30184 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
a7c37ea2d0
commit
d1fd4f08f5
46 changed files with 217 additions and 173 deletions
|
|
@ -103,6 +103,7 @@
|
|||
#include "splash.h"
|
||||
#include "rbunicode.h"
|
||||
#include "root_menu.h"
|
||||
#include "plugin.h" /* To borrow a temp buffer to rewrite a .m3u8 file */
|
||||
|
||||
#define PLAYLIST_CONTROL_FILE_VERSION 2
|
||||
|
||||
|
|
@ -3369,6 +3370,8 @@ int playlist_save(struct playlist_info* playlist, char *filename)
|
|||
int result = 0;
|
||||
bool overwrite_current = false;
|
||||
int* index_buf = NULL;
|
||||
char* old_buffer = NULL;
|
||||
size_t old_buffer_size = 0;
|
||||
|
||||
if (!playlist)
|
||||
playlist = ¤t_playlist;
|
||||
|
|
@ -3388,8 +3391,17 @@ int playlist_save(struct playlist_info* playlist, char *filename)
|
|||
if (playlist->buffer_size < (int)(playlist->amount * sizeof(int)))
|
||||
{
|
||||
/* not enough buffer space to store updated indices */
|
||||
splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
|
||||
return -1;
|
||||
/* Try to get a buffer */
|
||||
old_buffer = playlist->buffer;
|
||||
old_buffer_size = playlist->buffer_size;
|
||||
playlist->buffer = plugin_get_buffer((size_t*)&playlist->buffer_size);
|
||||
if (playlist->buffer_size < (int)(playlist->amount * sizeof(int)))
|
||||
{
|
||||
playlist->buffer = old_buffer;
|
||||
playlist->buffer_size = old_buffer_size;
|
||||
splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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)
|
|||
if (fd < 0)
|
||||
{
|
||||
splash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
|
||||
if (old_buffer != NULL)
|
||||
{
|
||||
playlist->buffer = old_buffer;
|
||||
playlist->buffer_size = old_buffer_size;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
@ -3513,6 +3530,11 @@ int playlist_save(struct playlist_info* playlist, char *filename)
|
|||
}
|
||||
|
||||
cpu_boost(false);
|
||||
if (old_buffer != NULL)
|
||||
{
|
||||
playlist->buffer = old_buffer;
|
||||
playlist->buffer_size = old_buffer_size;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue