[totem] Fix possible playback problems in WebKit browsers
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem] Fix possible playback problems in WebKit browsers
- Date: Thu, 24 Sep 2009 18:30:06 +0000 (UTC)
commit 2e358177f4d81c94cc6e83c16e7f4bbcb79f504f
Author: Bastien Nocera <hadess hadess net>
Date: Thu Sep 24 19:25:50 2009 +0100
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.
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 e8634b7..c555b8c 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]