aboutsummaryrefslogtreecommitdiff
path: root/emms.el
diff options
context:
space:
mode:
authorDamien Elmes <emms@repose.cx>2006-06-07 12:53:00 +0000
committerDamien Elmes <emms@repose.cx>2006-06-07 12:53:00 +0000
commite5beab412bc06197c77b902c4939758b2a246684 (patch)
treeb82d6d58c8e1eb387cf5a078617e591777c4327b /emms.el
parent3f3081318870f5400f339e138e0115381451575a (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.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/emms.el b/emms.el
index 42f5f8f..1070b23 100644
--- a/emms.el
+++ b/emms.el
@@ -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))