Пример #1
0
void
hippo_image_cache_load(HippoImageCache          *cache,
                       const char               *url,
                       HippoImageCacheLoadFunc   func,
                       void                     *data)
{
    CacheEntry *entry;
    
    entry = g_hash_table_lookup(cache->weak_cache, url);
    if (entry == NULL) {
        entry = cache_entry_new(url);
        g_hash_table_replace(cache->weak_cache, entry->url, entry);
    }
    g_assert(entry != NULL);
    
    /* don't check entry->in_strong_cache here, so each load attempt 
     * has its own chance to end up in the strong cache
     */
    if (entry->pixbuf == NULL &&
        !entry->loading) {
        /* this will be newly-loaded so add our strong ref callback
         * which will add a strong ref on the pixbuf if the http 
         * request returns successfully.
         */
        StrongRefData *s;
        s = g_new0(StrongRefData, 1);
        s->cache = cache;
        s->entry = entry;
        ADD_WEAK(&s->cache);
        cache_entry_load(entry, strong_ref_on_load, s);
    }
    cache_entry_load(entry, func, data);
}
/**
 * gst_vaapi_display_cache_add:
 * @cache: the #GstVaapiDisplayCache
 * @info: the display cache info to add
 *
 * Adds a new entry with data from @info. The display @info data is
 * copied into the newly created cache entry.
 *
 * Return value: %TRUE on success
 */
gboolean
gst_vaapi_display_cache_add (GstVaapiDisplayCache * cache,
    GstVaapiDisplayInfo * info)
{
  CacheEntry *entry;

  g_return_val_if_fail (cache != NULL, FALSE);
  g_return_val_if_fail (info != NULL, FALSE);

  entry = cache_entry_new (info);
  if (!entry)
    return FALSE;

  cache->list = g_list_prepend (cache->list, entry);
  return TRUE;
}