[Swfdec-commits] libswfdec/swfdec_cache.c libswfdec/swfdec_cache.h libswfdec/swfdec_player.c
Benjamin Otte
company at kemper.freedesktop.org
Tue Jan 22 04:13:37 PST 2008
libswfdec/swfdec_cache.c | 29 +++++++++++++++++++++++------
libswfdec/swfdec_cache.h | 17 ++++++++++-------
libswfdec/swfdec_player.c | 8 ++++----
3 files changed, 37 insertions(+), 17 deletions(-)
New commits:
commit 184e9abf56eff4588a9064e30f7b075952604ec0
Author: Benjamin Otte <otte at gnome.org>
Date: Tue Jan 22 13:13:29 2008 +0100
fix the SwfdecPlayer:cache-size property
it's settable and a ulong now - can't use gsize, because there's no gsize
property
diff --git a/libswfdec/swfdec_cache.c b/libswfdec/swfdec_cache.c
index 09d58a0..48104e6 100644
--- a/libswfdec/swfdec_cache.c
+++ b/libswfdec/swfdec_cache.c
@@ -26,7 +26,7 @@
#include "swfdec_debug.h"
SwfdecCache *
-swfdec_cache_new (guint max_size)
+swfdec_cache_new (gulong max_size)
{
SwfdecCache *cache;
@@ -62,7 +62,7 @@ swfdec_cache_unref (SwfdecCache *cache)
g_free (cache);
}
-guint
+gulong
swfdec_cache_get_usage (SwfdecCache *cache)
{
g_return_val_if_fail (cache != NULL, 0);
@@ -71,7 +71,7 @@ swfdec_cache_get_usage (SwfdecCache *cache)
}
void
-swfdec_cache_shrink (SwfdecCache *cache, guint max_usage)
+swfdec_cache_shrink (SwfdecCache *cache, gulong max_usage)
{
g_return_if_fail (cache != NULL);
@@ -79,12 +79,29 @@ swfdec_cache_shrink (SwfdecCache *cache, guint max_usage)
SwfdecCacheHandle *handle = g_queue_pop_tail (cache->queue);
g_assert (handle);
cache->usage -= handle->size;
- SWFDEC_LOG ("%p removing %p (%u => %u)", cache, handle,
+ SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
cache->usage + handle->size, cache->usage);
handle->unload (handle);
}
}
+gulong
+swfdec_cache_get_size (SwfdecCache *cache)
+{
+ g_return_val_if_fail (cache != NULL, 0);
+
+ return cache->max_size;
+}
+
+void
+swfdec_cache_set_size (SwfdecCache *cache, gulong max_usage)
+{
+ g_return_if_fail (cache != NULL);
+
+ swfdec_cache_shrink (cache, max_usage);
+ cache->max_size = max_usage;
+}
+
/**
* swfdec_cache_add_handle:
* @cache: a #SwfdecCache
@@ -114,7 +131,7 @@ swfdec_cache_add_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
swfdec_cache_shrink (cache, cache->max_size - handle->size);
g_queue_push_head (cache->queue, (gpointer) handle);
cache->usage += handle->size;
- SWFDEC_LOG ("%p adding %p (%u => %u)", cache, handle,
+ SWFDEC_LOG ("%p adding %p (%lu => %lu)", cache, handle,
cache->usage - handle->size, cache->usage);
}
}
@@ -141,7 +158,7 @@ swfdec_cache_remove_handle (SwfdecCache *cache, const SwfdecCacheHandle *handle)
if (list) {
g_queue_delete_link (cache->queue, list);
cache->usage -= handle->size;
- SWFDEC_LOG ("%p removing %p (%u => %u)", cache, handle,
+ SWFDEC_LOG ("%p removing %p (%lu => %lu)", cache, handle,
cache->usage + handle->size, cache->usage);
}
}
diff --git a/libswfdec/swfdec_cache.h b/libswfdec/swfdec_cache.h
index c19be85..5e58aa4 100644
--- a/libswfdec/swfdec_cache.h
+++ b/libswfdec/swfdec_cache.h
@@ -29,26 +29,29 @@ G_BEGIN_DECLS
//typedef struct _SwfdecCacheHandle SwfdecCacheHandle;
struct _SwfdecCache {
- guint refcount; /* reference count */
- guint max_size; /* max size of cache */
- guint usage; /* current size of cache */
+ guint refcount; /* reference count */
+ gulong max_size; /* max size of cache */
+ gulong usage; /* current size of cache */
GQueue * queue; /* queue of loaded SwfdecCacheHandle, sorted by most recently used */
};
struct _SwfdecCacheHandle {
- guint size; /* size of this item */
+ gulong size; /* size of this item */
GDestroyNotify unload; /* function called when unloading this handle */
};
-SwfdecCache * swfdec_cache_new (guint max_size);
+SwfdecCache * swfdec_cache_new (gulong max_size);
void swfdec_cache_ref (SwfdecCache * cache);
void swfdec_cache_unref (SwfdecCache * cache);
-guint swfdec_cache_get_usage (SwfdecCache * cache);
+gulong swfdec_cache_get_size (SwfdecCache * cache);
+void swfdec_cache_set_size (SwfdecCache * cache,
+ gulong max_usage);
+gulong swfdec_cache_get_usage (SwfdecCache * cache);
void swfdec_cache_shrink (SwfdecCache * cache,
- guint max_usage);
+ gulong max_usage);
void swfdec_cache_add_handle (SwfdecCache * cache,
const SwfdecCacheHandle *handle);
void swfdec_cache_remove_handle (SwfdecCache * cache,
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index b41c3e6..57c9334 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -692,7 +692,7 @@ swfdec_player_get_property (GObject *object, guint param_id, GValue *value,
g_value_set_uint (value, swfdec_player_get_background_color (player));
break;
case PROP_CACHE_SIZE:
- g_value_set_uint (value, priv->cache->max_size);
+ g_value_set_ulong (value, swfdec_cache_get_size (priv->cache));
break;
case PROP_INITIALIZED:
g_value_set_boolean (value, swfdec_player_is_initialized (player));
@@ -824,7 +824,7 @@ swfdec_player_set_property (GObject *object, guint param_id, const GValue *value
swfdec_player_set_background_color (player, g_value_get_uint (value));
break;
case PROP_CACHE_SIZE:
- priv->cache->max_size = g_value_get_uint (value);
+ swfdec_cache_set_size (priv->cache, g_value_get_ulong (value));
break;
case PROP_WIDTH:
swfdec_player_set_size (player, g_value_get_int (value), priv->stage_height);
@@ -1586,8 +1586,8 @@ swfdec_player_class_init (SwfdecPlayerClass *klass)
g_param_spec_long ("next-event", "next event", "how many milliseconds until the next event or -1 when no event pending",
-1, G_MAXLONG, -1, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_CACHE_SIZE,
- g_param_spec_uint ("cache-size", "cache size", "maximum cache size in bytes",
- 0, G_MAXUINT, 50 * 1024 * 1024, G_PARAM_READABLE));
+ g_param_spec_ulong ("cache-size", "cache size", "maximum cache size in bytes",
+ 0, G_MAXUINT, 50 * 1024 * 1024, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_BACKGROUND_COLOR,
g_param_spec_uint ("background-color", "background color", "ARGB color used to draw the background",
0, G_MAXUINT, SWFDEC_COLOR_COMBINE (0xFF, 0xFF, 0xFF, 0xFF), G_PARAM_READWRITE));
More information about the Swfdec-commits
mailing list