diff options
author | Bastien Nocera <hadess@hadess.net> | 2009-09-24 19:25:50 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2009-09-24 19:25:50 +0100 |
commit | 2e358177f4d81c94cc6e83c16e7f4bbcb79f504f (patch) | |
tree | 69c4c7a8b5dbadf8a0d4b25ad9e45bec0803b9b1 | |
parent | 9639fa75e6b2ed726e7bc9e92ae0e0c71123421e (diff) | |
download | totem-2e358177f4d81c94cc6e83c16e7f4bbcb79f504f.tar.gz |
Fix possible playback problems in WebKit browsers
When we're passed a cached file, WebKit _will_ remove it
straight after the end of StreamAsFile as it has absolutely
no cache implementation.
Work-around that by keeping the file opened with a file
descriptor.
-rw-r--r-- | browser-plugin/totem-plugin-viewer.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/browser-plugin/totem-plugin-viewer.c b/browser-plugin/totem-plugin-viewer.c index e8634b733..c555b8cd7 100644 --- a/browser-plugin/totem-plugin-viewer.c +++ b/browser-plugin/totem-plugin-viewer.c @@ -24,8 +24,11 @@ #include <stdlib.h> #include <string.h> +#include <sys/stat.h> +#include <fcntl.h> #include <sys/types.h> #include <unistd.h> +#include <errno.h> #include <glib.h> #include <glib/gi18n.h> @@ -641,6 +644,12 @@ totem_embedded_set_uri (TotemEmbedded *emb, else g_print ("Emptying current_uri\n"); + if (old_uri != NULL && + g_str_has_prefix (old_uri, "fd://") != FALSE) { + int fd; + fd = strtol (old_uri + strlen ("fd://"), NULL, 0); + close (fd); + } g_free (old_uri); g_free (old_base); g_free (old_href); @@ -900,18 +909,23 @@ totem_embedded_set_local_cache (TotemEmbedded *emb, const char *path, GError **error) { - char *file_uri; + int fd; /* FIXME Should also handle playlists */ if (!emb->is_browser_stream) return TRUE; - file_uri = g_filename_to_uri (path, NULL, error); - if (!file_uri) + /* Keep the temporary file open, so that StreamAsFile + * doesn't remove it from under us */ + fd = open (path, O_RDONLY); + if (fd < 0) { + g_message ("Failed to open local cache file '%s': %s", + path, g_strerror (errno)); return FALSE; + } emb->stream_uri = emb->current_uri; - emb->current_uri = file_uri; + emb->current_uri = g_strdup_printf ("fd://%d", fd); return TRUE; } |