emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/emms a372976 20/80: Fix Opus channel mapping decoding


From: Stefan Monnier
Subject: [elpa] externals/emms a372976 20/80: Fix Opus channel mapping decoding
Date: Wed, 17 Mar 2021 18:42:22 -0400 (EDT)

branch: externals/emms
commit a3729763e260a9ae2e7d1b9e49c27b83ca92f7a7
Author: Petteri Hintsanen <petterih@iki.fi>
Commit: Petteri Hintsanen <petterih@iki.fi>

    Fix Opus channel mapping decoding
    
    It seems that bindat specs cannot refer outside themselves, so use a
    special variable ‘emms-info-native--opus-channel-count’ with dynamic
    binding to keep track of channel count.
---
 emms-info-native.el | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/emms-info-native.el b/emms-info-native.el
index 669f3f3..dc2bbbd 100644
--- a/emms-info-native.el
+++ b/emms-info-native.el
@@ -189,8 +189,9 @@ Return a structure that corresponds to either
          (bindat-unpack emms-info-native--vorbis-headers-bindat-spec
                         packets))
         ((eq stream-type 'opus)
-         (bindat-unpack emms-info-native--opus-headers-bindat-spec
-                        packets))
+         (let (emms-info-native--opus-channel-count)
+           (bindat-unpack emms-info-native--opus-headers-bindat-spec
+                          packets)))
         (t (error "Unknown stream type %s" stream-type))))
 
 ;;;; Vorbis code
@@ -355,6 +356,11 @@ lower case and VALUE is the decoded value."
 
 ;;;; Opus code
 
+(defvar emms-info-native--opus-channel-count 0
+  "Last decoded Opus channel count.
+This is a kludge; it is needed because bindat spec cannot refer
+outside itself.")
+
 (defconst emms-info-native--opus-head-magic-array
   [79 112 117 115 72 101 97 100]
   "Opus identification header magic pattern ‘OpusHead’.")
@@ -366,7 +372,7 @@ lower case and VALUE is the decoded value."
 (defconst emms-info-native--opus-channel-mapping-table
   '((stream-count u8)
     (coupled-count u8)
-    (channel-mapping vec (channel-count)))
+    (channel-mapping vec (eval emms-info-native--opus-channel-count)))
   "Opus channel mapping table specification.")
 
 (defconst emms-info-native--opus-identification-header-bindat-spec
@@ -380,11 +386,14 @@ lower case and VALUE is the decoded value."
             (error "Opus version mismatch: expected < 16, got %s"
                    last)))
     (channel-count u8)
+    (eval (setq emms-info-native--opus-channel-count last))
     (pre-skip u16r)
     (sample-rate u32r)
     (output-gain u16r)
     (channel-mapping-family u8)
-    (eval (> last 0) (struct opus-channel-mapping-table)))
+    (union (channel-mapping-family)
+           (0 nil)
+           (t (struct emms-info-native--opus-channel-mapping-table))))
   "Opus identification header specification.")
 
 (defconst emms-info-native--opus-comment-header-bindat-spec



reply via email to

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