bongo-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bongo-patches] Audio CD fixes


From: Daniel Jensen
Subject: [bongo-patches] Audio CD fixes
Date: Thu, 04 Jan 2007 07:09:08 +0100
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.90 (gnu/linux)

So I finally got around to testing the CDDA code a little.

Notes:

  * `bongo-libcddb-cdda-info' must not give track lengths by calling
    `bongo-libcddb-cddb-info'. This ignores `bongo-use-cddb' and is
    probably a bad idea anyway.

  * `bongo-libcddb-cdda-info' checks for an ID that the `cddb_query
    calc' command only will find for valid CDs, to prevent 255
    inserted tracks when no CD is in the tray. Daniel, you removed
    this earlier for some reason.

  * `bongo-cdtool-cdda-info' detects a data CD, to prevent another
    unwanted track insertion.

  * `bongo-cdtool-cddb-info' handles multiple matches from the server
    by always selecting a first match.

Plus other minor changes.

diff -Naur old-bongo/bongo.el new-bongo/bongo.el
--- old-bongo/bongo.el  2007-01-04 06:46:43.000000000 +0100
+++ new-bongo/bongo.el  2007-01-04 06:56:33.000000000 +0100
@@ -4693,20 +4693,18 @@
 
 (defun bongo-libcddb-cdda-info (&optional device omit-lengths)
   "Use `cddb_query' to find the number of tracks on an audio CD.
+Track lengths are not retrieved. OMIT-LENGTHS is ignored.
 This function is a suitable value for `bongo-cdda-info-function'."
-  (if omit-lengths
-      (with-temp-buffer
-        (apply 'call-process bongo-libcddb-cddb-query-program-name nil t nil
-               (nconc (when (or device bongo-cd-device)
-                        (list "-i" (or device bongo-cd-device)))
-                      (list "calc")))
-        (goto-char (point-min))
-        (when (re-search-forward "^CD contains \\(.+\\) track" nil t)
-          (string-to-number (match-string 1))))
-    (let ((cddb-info (bongo-libcddb-cddb-info device)))
-      (when cddb-info
-        (cons (cadr cddb-info)
-              (mapcar 'cdr (cddr cddb-info)))))))
+  (with-temp-buffer
+    (apply 'call-process bongo-libcddb-cddb-query-program-name nil t nil
+           (nconc (when (or device bongo-cd-device)
+                    (list "-i" (or device bongo-cd-device)))
+                  (list "calc")))
+    (goto-char (point-min))
+    (when (re-search-forward "^CD contains \\(.+\\) track" nil t)
+      (let ((count (string-to-number (match-string 1))))
+        (when (search-forward "CD disc ID is" nil t) ; valid CDDAs only
+          (cons count nil))))))
 
 (defun bongo-libcddb-cddb-info (&optional device omit-lengths)
   "Use `cddb_query' to find CDDB information about an audio CD.
@@ -4754,19 +4752,22 @@
     (when (re-search-forward "\\<in \\(.+\\) tracks\\>" nil t)
       (let ((track-count (string-to-number (match-string 1)))
             (track-lengths nil))
-        (unless omit-lengths
-          (while (re-search-forward "^\\s-+\\([0-9:.]+\\)" nil t)
-            (push (bongo-parse-time (match-string 1)) track-lengths)))
-        (cons track-count track-lengths)))))
+        (unless (and (= track-count 1)
+                     (save-excursion (search-forward "[DATA]" nil t)))
+          (unless omit-lengths
+            (while (re-search-forward "^\\s-+\\([0-9:.]+\\)" nil t)
+              (push (bongo-parse-time (match-string 1)) track-lengths)))
+          (cons track-count track-lengths))))))
 
 (defun bongo-cdtool-cddb-info (&optional device omit-lengths)
   "Use `cdown' to find CDDB information about an audio CD.
 This function is a suitable value for `bongo-cddb-info-function'.
-Note that this function cannot report album release year information.
-It also has problems with multiple CDDB matches."
+Note that this function cannot report album release year information."
   (with-current-buffer (get-buffer-create " *CDDB query*")
     (erase-buffer)
-    (apply 'call-process bongo-cdtool-cdown-program-name nil t nil
+    (insert "1\n")                      ; always pick first alternative
+    (apply 'call-process-region (point-min) (point)
+           bongo-cdtool-cdown-program-name t t nil
            (nconc (when (or device bongo-cd-device)
                     (list "-d" (or device bongo-cd-device)))
                   (when bongo-cddb-server
@@ -4799,7 +4800,7 @@
 Return a CD device name or nil."
   (let ((file-name
          (read-file-name (format "CD device name (default `%s'): "
-                                 bongo-cd-device)
+                                 (or bongo-cd-device "unspecified"))
                          "/dev/" bongo-cd-device t)))
     (unless (string-equal file-name "")
       (expand-file-name file-name))))
@@ -4863,10 +4864,7 @@
 With a numerical prefix argument, insert only that particular track."
   (interactive
    (list (when (consp current-prefix-arg)
-           (expand-file-name
-            (read-file-name (format "Audio CD device (default `%s'): "
-                                    bongo-cd-device)
-                            "/dev/" bongo-cd-device t)))))
+           (bongo-read-cd-device-name))))
   (when (null device)
     (setq device bongo-cd-device))
   (if (integerp current-prefix-arg)
@@ -4882,7 +4880,7 @@
         (if (null track-count)
             (error (concat "Cannot read audio CD"
                            (when device
-                             (format "in `%s'" device))))
+                             (format " in `%s'" device))))
           (with-bongo-buffer
             (let ((beginning (point))
                   (cddb-info (if bongo-use-cddb

reply via email to

[Prev in Thread] Current Thread [Next in Thread]