(defvar ad-list nil)(defun create-dual-audio-track (track)(list (get-track-pid track)(copy-string (get-track-audio-lang track))
"---"
(get-track-audio-dualmode track)))(defun set-preferred-common-lang (alist slist)(let ((alang-group) (slang-group) (cmn-lang))(if (not (and alist slist))(setf preferred-common-lang nil)(setf alang-group (find-if #'(lambda (x)(find-if #'(lambda (y)(find-if #'(lambda (z)(string-equal (get-track-audio-lang z) y))
alist))
x))
preferred-audio))(setf slang-group (find-if #'(lambda (x)(find-if #'(lambda (y)(find-if #'(lambda (z)(string-equal (get-track-subtitle-lang z) y))
slist))
x))
preferred-subtitle))(setf preferred-common-lang (if (and alang-group slang-group)
nil
(if (find-if #'(lambda (y)(find-if #'(lambda (z)(string-equal (get-track-subtitle-lang z) y))
slist))
alang-group)
alang-group
(if (find-if #'(lambda (y)(find-if #'(lambda (z)(string-equal (get-track-audio-lang z) y))
alist))
slang-group)
slang-group
(if (or alang-group slang-group)
nil
(setf cmn-lang (get-track-audio-lang (find-if #'(lambda (x)(find-if #'(lambda (y)(string-equal (get-track-subtitle-lang y) (get-track-audio-lang x)))
slist))
alist)))(if cmn-lang
(list cmn-lang)
nil)))))))))(defun get-audio-type-priority (type)(if (eq type 0)
0
(if (eq type 1)
1
2)))(defun in-lang-list-p (lang lang-lst)(let ((ret nil))(mapcar #'(lambda (el)(setf ret (string-equal lang el)))
lang-lst)
ret))(defun get-audio-type-priority-ad (track)(let ((type (get-track-audio-type track)))(if (and use-nar-ad
(string-equal "NAR" (get-track-audio-lang track))(or (eq type 0) (eq type 3)))(progn
0)(if (and use-sad
(eq (get-track-audio-sad-found track) 1)(eq (get-track-audio-sad-ed-class track) 0)(> (get-track-audio-adpid track) -1))(progn
0)(if (and (or (eq type 0) (eq type 3))
use-sad
(eq (get-track-audio-sad-found track) 1)(eq (get-track-audio-sad-mix-type track) 1)(eq (get-track-audio-sad-ed-class track) 1))(progn
0)(if (and
(or (not ad-list)(not (or
(in-lang-list-p (get-track-audio-lang track) (get-lang-list ad-list))(in-lang-list-p (get-track-audio-sad-lang-if-avail track) (get-sad-lang-list ad-list)))))
use-visual-impaired-ad
(eq type 3))(progn
0)(progn
(+ (get-audio-type-priority type) 1))))))))(defun get-audio-type-preferred-priority (preferred track)(let ((type (get-track-audio-type track)))(if (eq type preferred)(if (eq type #x03)(if (eq (get-track-audio-sad-found track) 1)(if (eq (get-track-audio-sad-mix-type track) 1)
0
(+ (get-audio-type-priority type) 1))
0)
0)(+ (get-audio-type-priority type) 1))))(defun get-aac-priority (aac-type)(if (eq aac-type #x05)
0
1))(defun get-audio-primary-tag-priority (tag)(if (= tag #x10)
0
1))(defun get-format-priority-he-aac (format-type)(if (= format-type #x11)
0
1))(defun get-preferred-priority (preferred lang)(let ((pri))(setf pri (position-if #'(lambda (x)(find-if #'(lambda (y)(string-equal lang y))
x))
preferred))(if pri
pri
(length preferred))))(defun get-preferred-priority-nar (preferred lang)(let ((preferred-tmp preferred))(unless (and use-sad
(eq (get-track-audio-sad-found track) 1)(eq (get-track-audio-sad-lang-present track) 1))(setf preferred-tmp (cons '("nar") preferred-tmp)))(get-preferred-priority preferred-tmp lang)))(defun get-lang-priority (preferred lang type)(let ((preferred-tmp nil))(mapcar #'(lambda (x)(setf preferred-tmp (cons x preferred-tmp))(if (find-if #'(lambda (y)(string-equal "eng" y))
x)(setf preferred-tmp (cons '("und") preferred-tmp))))
preferred)(get-preferred-priority (reverse preferred-tmp) lang)))(defun get-format-priority (preferred format)(let* ((mpeg-list        (list #x03 #x04))(srch-format      (if (member format mpeg-list) #x03 format))(prio-format-list (if (or is-nz (and is-aus with-hd))(if (member #x11 preferred)(list #x82 #x11 #x03 #x81)(list #x82 #x81 #x11 #x03))(if is-nordic
(list #x11 #x82 #x81 #x03)(list #x82 #x11 #x81 #x03))))(prio-format      (position srch-format prio-format-list)))(if (member format preferred)
0
(1+ prio-format))))(defun get-format-with-aaclv-priority (format aac-pr)(let* ((srch-format (if (member format (list #x03 #x04)) #x03 format))(srch-list (cons srch-format (cons aac-pr nil)))(prio-format (position-if #'(lambda (x)(and (eq (car x) (car srch-list))(eq (car (cdr x)) (car (cdr srch-list)))))
preferred-audio-format-list)))
prio-format))(defun get-subtitle-type-priority (type)(if (eq type #x10)
0
(if (eq type #x11)
1
(if (eq type #x12)
2
(if (eq type #x13)
3
4)))))(defun append-audio-track (track lst)(if (eq is-uk t)(progn
(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil) (und (list (list "und"))) (nar (list (list "nar"))))(do ((loopcount 0 (+ loopcount 1)))((> loopcount (- (length lst) 1)) loopcount)(if (= 0 (get-preferred-priority preferred-audio (get-track-audio-lang (nth loopcount lst))))(setf und nil)))(if (or (and (eq with-freesat t) (eq current-network 4))(eq current-network 1))(setf nar nil))(if (and (eq current-network 3) (ad-by-multiaudio-p track))(if ad-enable
(setf pos (position-if #'(lambda (x)(or (and (not (ad-by-multiaudio-p x))(or (= (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(< (get-preferred-priority nar (get-track-audio-sad-lang-if-avail track))(get-preferred-priority nar (get-track-audio-sad-lang-if-avail x)))))(when (ad-by-multiaudio-p x)(or (< (get-preferred-priority nar (get-track-audio-sad-lang-if-avail track))(get-preferred-priority nar (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority nar (get-track-audio-sad-lang-if-avail track))(get-preferred-priority nar (get-track-audio-sad-lang-if-avail x)))(< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x))))))))
lst))(setf pos (position-if #'(lambda (x)(when (ad-by-multiaudio-p x)(< (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))))
lst)))(setf pos (position-if #'(lambda (x)(or (and (not ad-enable) (ad-by-multiaudio-p x))(and (not (ad-by-multiaudio-p x))(or (< (get-lang-priority preferred-audio (get-track-audio-sad-lang-if-avail track) (get-track-audio-type track))(get-lang-priority preferred-audio (get-track-audio-sad-lang-if-avail x) (get-track-audio-type x)))(when (= (get-lang-priority preferred-audio (get-track-audio-sad-lang-if-avail track) (get-track-audio-type track))(get-lang-priority preferred-audio (get-track-audio-sad-lang-if-avail x) (get-track-audio-type x)))(or (< (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(and (= (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x))))))))))
lst)))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))(if (or is-nz is-asia is-aus)(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil) (preferred-lang preferred-audio))(when preferred-common-lang
(setf preferred-lang (cons preferred-common-lang preferred-audio)))(if ad-enable
(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-lang (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-lang (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority preferred-lang (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-lang (get-track-audio-sad-lang-if-avail x)))(or (< (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(and (= (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x))))))))
lst))(setf pos (position-if #'(lambda (x)(or (< (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(when (= (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(or (< (get-preferred-priority preferred-lang (get-track-audio-lang track))(get-preferred-priority preferred-lang (get-track-audio-lang x)))(and (= (get-preferred-priority preferred-lang (get-track-audio-lang track))(get-preferred-priority preferred-lang (get-track-audio-lang x)))(< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x))))))))
lst)))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track))))(if (or is-nordic is-hungary)(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil))(if ad-enable
(if (and is-ireland (eq current-network 1))(progn
(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority-nar preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority-nar preferred-audio (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority-nar preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority-nar preferred-audio (get-track-audio-sad-lang-if-avail x)))(or (< (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(when (= (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(or (< (get-format-with-aaclv-priority (get-track-audio-format track)(if (= (get-track-audio-format track) #x11)(get-aac-priority (get-track-audio-aac-type track)) 1))(get-format-with-aaclv-priority (get-track-audio-format x)(if (= (get-track-audio-format x) #x11)(get-aac-priority (get-track-audio-aac-type x)) 1)))))))))
lst)))(if is-finland
(progn
(setf pos (position-if #'(lambda (x)(or (< (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(when (= (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(or (< (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(or (< (get-format-with-aaclv-priority (get-track-audio-format track)(if (= (get-track-audio-format track) #x11)(get-aac-priority (get-track-audio-aac-type track)) 1))(get-format-with-aaclv-priority (get-track-audio-format x)(if (= (get-track-audio-format x) #x11)(get-aac-priority (get-track-audio-aac-type x)) 1)))))))))
lst)))(progn
(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(or (< (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(when (= (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(or (< (get-format-with-aaclv-priority (get-track-audio-format track)(if (= (get-track-audio-format track) #x11)(get-aac-priority (get-track-audio-aac-type track)) 1))(get-format-with-aaclv-priority (get-track-audio-format x)(if (= (get-track-audio-format x) #x11)(get-aac-priority (get-track-audio-aac-type x)) 1)))))))))
lst)))))(progn
(if is-finland
(setf pos (position-if #'(lambda (x)(or (< (get-audio-type-preferred-priority preferred-audio-type track)(get-audio-type-preferred-priority preferred-audio-type x))(when (= (get-audio-type-preferred-priority preferred-audio-type track)(get-audio-type-preferred-priority preferred-audio-type x))(or (< (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(or (< (get-format-with-aaclv-priority (get-track-audio-format track)(if (= (get-track-audio-format track) #x11)(get-aac-priority (get-track-audio-aac-type track)) 1))(get-format-with-aaclv-priority (get-track-audio-format x)(if (= (get-track-audio-format x) #x11)(get-aac-priority (get-track-audio-aac-type x)) 1)))))))))
lst))(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(or (< (get-audio-type-preferred-priority preferred-audio-type track)(get-audio-type-preferred-priority preferred-audio-type x))(when (= (get-audio-type-preferred-priority preferred-audio-type track)(get-audio-type-preferred-priority preferred-audio-type x))(or (< (get-format-with-aaclv-priority (get-track-audio-format track)(if (= (get-track-audio-format track) #x11)(get-aac-priority (get-track-audio-aac-type track)) 1))(get-format-with-aaclv-priority (get-track-audio-format x)(if (= (get-track-audio-format x) #x11)(get-aac-priority (get-track-audio-aac-type x)) 1)))))))))
lst)))))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track))))(if is-cont
(progn
(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil))(if ad-enable
(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail track))(get-preferred-priority preferred-audio (get-track-audio-sad-lang-if-avail x)))(or (< (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(when (= (get-audio-type-priority-ad track)(get-audio-type-priority-ad x))(or (< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(and (= (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(= (get-track-audio-format track) #x11)(< (get-aac-priority (get-track-audio-aac-type track))(get-aac-priority (get-track-audio-aac-type x))))))))))
lst))(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(or (< (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(when (= (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x)))(or (< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(and (= (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(= (get-track-audio-format track) #x11)(< (get-aac-priority (get-track-audio-aac-type track))(get-aac-priority (get-track-audio-aac-type x))))))))))
lst)))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))(if is-brazil
(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil))(setf pos (position-if #'(lambda (x)(or (< (get-audio-primary-tag-priority (get-track-tag track))(get-audio-primary-tag-priority (get-track-tag x)))(and (= (get-audio-primary-tag-priority (get-track-tag track))(get-audio-primary-tag-priority (get-track-tag x)))(< (get-format-priority-he-aac (get-track-audio-format track))(get-format-priority-he-aac (get-track-audio-format x))))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track))))(when (or (not audio-choice-num) (< (length lst) audio-choice-num))(let ((pos nil))(setf pos (position-if #'(lambda (x)(or (< (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(when (= (get-preferred-priority preferred-audio (get-track-audio-lang track))(get-preferred-priority preferred-audio (get-track-audio-lang x)))(or (< (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(and (= (get-format-priority preferred-audio-format (get-track-audio-format track))(get-format-priority preferred-audio-format (get-track-audio-format x)))(< (get-audio-type-priority (get-track-audio-type track))(get-audio-type-priority (get-track-audio-type x))))))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track))))))))))(defun append-subtitle-track (track lst)(if (eq is-uk t)(progn
(when (or (not subtitle-choice-num) (< (length lst) subtitle-choice-num))(let ((pos nil) (und (list (list "und"))))(do ((loopcount 0 (+ loopcount 1)))((> loopcount (- (length lst) 1)) loopcount)(if (= 0 (get-preferred-priority preferred-subtitle (get-track-subtitle-lang (nth loopcount lst))))(setf und nil)))(setf pos (position-if #'(lambda (x)(or	 (< (get-preferred-priority preferred-subtitle (get-track-subtitle-lang track))(get-preferred-priority preferred-subtitle (get-track-subtitle-lang x)))(< (get-preferred-priority und (get-track-subtitle-lang track))(get-preferred-priority und (get-track-subtitle-lang x)))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))(if (eq is-nz t)(progn
(when (or (not subtitle-choice-num) (< (length lst) subtitle-choice-num))(let ((pos nil) (preferred-lang preferred-subtitle))(when preferred-common-lang
(setf preferred-lang (cons preferred-common-lang preferred-subtitle)))(setf pos (position-if #'(lambda (x)(or	(< (get-preferred-priority preferred-lang (get-track-subtitle-lang track))(get-preferred-priority preferred-lang (get-track-subtitle-lang x)))(and (= (get-preferred-priority preferred-lang (get-track-subtitle-lang track))(get-preferred-priority preferred-lang (get-track-subtitle-lang x)))(< (get-subtitle-type-priority (get-track-subtitle-type track))(get-subtitle-type-priority (get-track-subtitle-type x))))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))(when (or (not subtitle-choice-num) (< (length lst) subtitle-choice-num))(let ((pos nil))(setf pos (position-if #'(lambda (x)(< (get-preferred-priority preferred-subtitle (get-track-subtitle-lang track))(get-preferred-priority preferred-subtitle (get-track-subtitle-lang x))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))))(defun append-teletext-track (track lst)(when (or (not teletext-choice-num) (< (length lst) teletext-choice-num))(let ((pos nil))(setf pos (position-if #'(lambda (x)(< (get-preferred-priority preferred-teletext (get-track-teletext-lang track))(get-preferred-priority preferred-teletext (get-track-teletext-lang x))))
lst))(if (not pos)(setf-cdr (last lst) (cons track nil))(setf-nthcdr pos lst (cons (nth pos lst) (nthcdr (1+ pos) lst)))(setf-nth pos lst track)))))(defun create-audio-choice-list (sym alist)(let ((new-list nil) (dual-set-list nil) (dual-pid nil) (alist-pos 0)(comp-alist-pos 0) (find-dual nil) (temp-track nil))(when (and (eq (get-audio-result sym) 'DECODE_SUCCESS) (dual-mono-p sym))(setf dual-pid (get-audio-pid sym)))(mapcar #'(lambda (alist-track)(mapcar #'(lambda (comp-alist-track)(when (and
(and
(eq (get-track-pid comp-alist-track)(get-track-pid alist-track))(not (eq alist-pos comp-alist-pos)))(eq find-dual nil))(setf find-dual t)(when (< alist-pos comp-alist-pos)(setf temp-track (copy-audio-track alist-track))(set-track-audio-dualmode temp-track 0)(if dual-set-list
(setf-cdr (last dual-set-list) (cons temp-track nil))(setf dual-set-list (cons temp-track nil))))(when (> alist-pos comp-alist-pos)(setf temp-track (copy-audio-track alist-track))(set-track-audio-dualmode temp-track 1)(if dual-set-list
(setf-cdr (last dual-set-list) (cons temp-track nil))(setf dual-set-list (cons temp-track nil)))))(setf comp-alist-pos (+ comp-alist-pos 1)))
alist)(when (eq find-dual nil)(if dual-set-list
(setf-cdr (last dual-set-list) (cons alist-track nil))(setf dual-set-list (cons alist-track nil))))(setf alist-pos (+ alist-pos 1))(setf comp-alist-pos 0)(setf find-dual nil)(setf set-dual-flg nil))
alist)(when dual-set-list
(mapcar #'(lambda (dual-set-track)(if new-list
(append-audio-track dual-set-track new-list)(setf new-list (cons dual-set-track nil))))
dual-set-list))
new-list))(defun create-dual-audio-choice-list (sym alist)(let ((dual-pid nil)  (temp-list nil)	(dual-list nil)(temp-track nil) (dec-ok nil))(setf dec-ok (eq (get-audio-result sym) 'DECODE_SUCCESS))(when (and dec-ok (dual-mono-p sym))(setf dual-pid (get-audio-pid sym)))(if (and dec-ok (dual-mono-p sym))(progn
(mapcar #'(lambda (alist-track)(when (eq (get-track-pid alist-track) dual-pid)(setf temp-track (create-dual-audio-track alist-track))(if dual-list
(setf-cdr (last dual-list) (cons temp-track nil))(setf dual-list (cons temp-track nil)))))
alist)(when (eq (length dual-list) 1)(setf temp-track (copy-list (nth 0 dual-list)))(set-track-dual-audio-dualmode temp-track 0)(setf dual-list (cons temp-track nil))(setf temp-track (copy-list temp-track))(set-track-dual-audio-dualmode temp-track 1)(setf-cdr (last dual-list) (cons temp-track nil))(setf temp-track (copy-list temp-track))(set-track-dual-audio-dualmode temp-track 2)(setf-cdr (last dual-list) (cons temp-track nil)))(when (eq (length dual-list) 2)(setf temp-list (copy-list dual-list))(mapcar #'(lambda (dual-track)(when (eq (get-track-dual-audio-dualmode dual-track) 0)(setf temp-track (copy-list dual-track))(set-track-dual-audio-dualmode temp-track 2)))
dual-list)(setf dual-list nil)(mapcar #' (lambda (x)(if (eq select-dualmode 2)(progn
(unless dual-list
(setf dual-list (cons x nil))))(when (eq (get-track-dual-audio-dualmode x) select-dualmode)(setf dual-list (cons x nil))))(when (eq (get-track-dual-audio-dualmode x) 1)(set-track-dual-audio-second-lang temp-track (get-track-dual-audio-lang x))))
temp-list)(setf-cdr (last dual-list) (cons temp-track nil))))(setf dual-list nil))
dual-list))(defun set-spdif (format)(optical-output-spdif 'tvp-optout format))
