Refactor code

This commit is contained in:
twinaphex 2017-11-25 22:59:47 +01:00
parent b604a1871a
commit e8b21cbafe
3 changed files with 42 additions and 11 deletions

View File

@ -1702,6 +1702,37 @@ static bool command_event_resize_windowed_scale(void)
return true;
}
void command_playlist_push_write(
void *data,
const char *path,
const char *label,
const char *core_path,
const char *core_name)
{
playlist_t *plist = (playlist_t*)data;
playlist_t *playlist = NULL;
if (plist)
playlist = plist;
#ifdef HAVE_MENU
else
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
#endif
if (!playlist)
return;
playlist_push(
playlist,
path,
label,
core_path,
core_name,
NULL,
NULL
);
playlist_write_file(playlist);
}
void command_playlist_update_write(
void *data,
size_t idx,
@ -2304,16 +2335,13 @@ TODO: Add a setting for these tweaks */
if (!string_is_empty(global->name.label))
label = global->name.label;
playlist_push(
command_playlist_push_write(
g_defaults.content_favorites,
(const char*)data,
label,
core_path,
core_name,
NULL,
NULL
core_name
);
playlist_write_file(g_defaults.content_favorites);
runloop_msg_queue_push(msg_hash_to_str(MSG_ADDED_TO_FAVORITES), 1, 180, true);
break;
}

View File

@ -259,6 +259,13 @@ bool command_free(command_t *handle);
**/
bool command_event(enum event_command action, void *data);
void command_playlist_push_write(
void *data,
const char *path,
const char *label,
const char *core_path,
const char *core_name);
void command_playlist_update_write(
void *data,
size_t idx,

View File

@ -1804,16 +1804,12 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path,
fill_pathname_join(combined_path, menu->scratch2_buf,
menu->scratch_buf, sizeof(combined_path));
playlist_push(
command_playlist_push_write(
g_defaults.music_history,
combined_path,
NULL,
"builtin",
"musicplayer",
NULL,
NULL);
playlist_write_file(g_defaults.music_history);
"musicplayer");
if(path_file_exists(combined_path))
task_push_audio_mixer_load(combined_path,