audio: Escape filepaths before loading

This is for filepaths containing special characters.

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-01-29 23:13:51 -05:00 committed by Anna Schumaker
parent bf010f2a84
commit dfbb98b2c6

View File

@ -83,7 +83,7 @@ static bool change_state(GstState state)
static bool load_song(library :: Song &song) static bool load_song(library :: Song &song)
{ {
GstState state; GstState state;
gchar *escaped; gchar *escaped, *uri;
std::string filepath = song.library->root_path + "/" + song.track->filepath; std::string filepath = song.library->root_path + "/" + song.track->filepath;
if (o_should_pause == true) { if (o_should_pause == true) {
@ -95,9 +95,11 @@ static bool load_song(library :: Song &song)
} }
change_state(GST_STATE_NULL); change_state(GST_STATE_NULL);
escaped = gst_filename_to_uri(filepath.c_str(), NULL); escaped = g_markup_escape_text(filepath.c_str(), filepath.size());
g_object_set(G_OBJECT(ocarina_player), "uri", escaped, NULL); uri = gst_filename_to_uri(escaped, NULL);
g_object_set(G_OBJECT(ocarina_player), "uri", uri, NULL);
g_free(escaped); g_free(escaped);
g_free(uri);
get_callbacks()->on_track_loaded(song); get_callbacks()->on_track_loaded(song);
return change_state(state); return change_state(state);