X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fmaemo-recorder-file.c;h=2343281510300e1651874c06a6020753b1b2ec81;hb=ec1ad6ea23636ecad14b491d98296ca93077abb5;hp=af5d07d93241398611093f7744304c712d90acb2;hpb=d414911937bd98b56be37d60f6e8904f426d709e;p=maemo-recorder diff --git a/src/maemo-recorder-file.c b/src/maemo-recorder-file.c index af5d07d..2343281 100644 --- a/src/maemo-recorder-file.c +++ b/src/maemo-recorder-file.c @@ -148,7 +148,7 @@ saveFile(const gchar *filename, const gchar *tmpfile, AudioFormat format, gchar goto save_error; /* open tmpfile(r) */ - text_uri = g_strconcat("file://", tmpfile, NULL); + text_uri = file2uri(tmpfile); if (gnome_vfs_open(&tmp_handle, text_uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK) { @@ -161,7 +161,7 @@ saveFile(const gchar *filename, const gchar *tmpfile, AudioFormat format, gchar text_uri = NULL; /* open/create newfile for writing */ - text_uri = g_strconcat("file://", newfile_tmp, NULL); + text_uri = file2uri(newfile_tmp); uri = gnome_vfs_uri_new(text_uri); g_free(text_uri); text_uri = NULL; @@ -232,7 +232,8 @@ save_error: * - the tmpfile where the raw data is (or the same file name if the file was raw) * TODO: add parameter (GError?) to report back an error string */ -gboolean openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile) +gboolean +openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile) { if (g_strrstr(filename, EXTENSION_PCMA)) { @@ -262,6 +263,7 @@ gboolean openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile) { ULOG_INFO("%s() - file was %s", G_STRFUNC, EXTENSION_WAV); *format = FORMAT_WAV; + /* TODO: we should dig out the rate, channels and stuff from the WAV file here or get the caps from some GstPad */ *tmpfile = g_strdup(filename); } else if (g_strrstr(filename, EXTENSION_ILBC)) @@ -282,7 +284,7 @@ gboolean openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile) ULOG_INFO("%s() - file was AU/SND", G_STRFUNC); /* decode and extract raw AU data */ - text_uri = g_strdup_printf("file://%s", filename); + text_uri = file2uri(filename); if (gnome_vfs_open(&from_handle, text_uri, GNOME_VFS_OPEN_READ) != GNOME_VFS_OK) { ULOG_WARN("%s() - gnome_vfs_open() failed", G_STRFUNC); @@ -362,7 +364,8 @@ gboolean openFile(const gchar *filename, AudioFormat *format, gchar **tmpfile) return TRUE; } -GnomeVFSFileSize getFileLength(const gchar *file) +GnomeVFSFileSize +getFileLength(const gchar *file) { GnomeVFSFileInfo *info; GnomeVFSResult res; @@ -372,7 +375,7 @@ GnomeVFSFileSize getFileLength(const gchar *file) if (NULL == file) return ret; - text_uri = g_strdup_printf("file://%s", file); + text_uri = file2uri(file); info = gnome_vfs_file_info_new(); res = gnome_vfs_get_file_info(text_uri, info, @@ -393,3 +396,18 @@ GnomeVFSFileSize getFileLength(const gchar *file) return ret; } + +gchar * +file2uri(const gchar *filename) +{ + if (NULL == filename) + return NULL; + + if (g_str_has_prefix(filename, "file://")) + return g_strdup(filename); + + /* + return g_strconcat("file://", filename, NULL); + */ + return g_filename_to_uri(filename, NULL, NULL); +}