diff options
author | Damien Elmes <emms@repose.cx> | 2006-06-07 12:53:00 +0000 |
---|---|---|
committer | Damien Elmes <emms@repose.cx> | 2006-06-07 12:53:00 +0000 |
commit | e5beab412bc06197c77b902c4939758b2a246684 (patch) | |
tree | b82d6d58c8e1eb387cf5a078617e591777c4327b /emms.el | |
parent | 3f3081318870f5400f339e138e0115381451575a (diff) |
refactor caching code into emms-cache.el
* caching support is now provided via two function vars in emms.el,
emms-cache-get-function and emms-cache-set-function
* (emms-standard) or above will enable caching support
* you'll need to remove .emms-cache or s/emms-info-cache/emms-cache-db/
darcs-hash:20060607125345-4e3e3-7d9ad8d243a395f2f2a5eea004e58ac9e239855b.gz
Diffstat (limited to 'emms.el')
-rw-r--r-- | emms.el | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -223,6 +223,11 @@ seconds the player did seek." This can be used if the source depends on the current buffer not being the playlist buffer.") +(defvar emms-cache-get-function (lambda (path)) + "A function to retrieve a track entry from the cache.") +(defvar emms-cache-set-function (lambda (path track)) + "A function to add/set a track entry from the cache.") + ;;; User Interface @@ -453,9 +458,15 @@ whenever possible." (defun emms-track (type name) "Create an EMMS track with type TYPE and name NAME." - (let ((track (emms-dictionary '*track*))) - (emms-track-set track 'type type) - (emms-track-set track 'name name) + (let (track) + ;; we assume that name is unique across types, so type is not used + ;; if we find name in the cache + (unless (setq track (funcall emms-cache-get-function name)) + (setq track (emms-dictionary '*track*)) + (emms-track-set track 'type type) + (emms-track-set track 'name name)) + ;; run any hooks regardless of a cache hit, as the entry may be + ;; old (run-hook-with-args 'emms-track-initialize-functions track) track)) |