ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/doomfrontend/doomfrontend
(Generate patch)

Comparing doomfrontend/doomfrontend (file contents):
Revision 1.1 by root, Sat Mar 25 16:27:19 2023 UTC vs.
Revision 1.3 by root, Mon Apr 17 12:32:17 2023 UTC

10 10
11 11
12BEGIN { 12BEGIN {
13 if ($ARGV[0] eq "-=reloaded=-") { 13 if ($ARGV[0] eq "-=reloaded=-") {
14 shift; 14 shift;
15 } elsif (-e "/root/mlockall.so" && $ENV{LD_PRELOAD} !~ /libmimalloc/) { 15 } elsif (-e "/root/mlockall.so") {
16 $ENV{LD_PRELOAD} = "/root/mlockall.so:/root/libmimalloc.so.1.7"; 16 $ENV{LD_PRELOAD} = "/root/mlockall.so:/root/libmimalloc.so.1.7";
17 $ENV{MIMALLOC_LARGE_OS_PAGES} = 1; 17 $ENV{MIMALLOC_LARGE_OS_PAGES} = 1;
18 system "echo always >/sys/kernel/mm/transparent_hugepage/defrag"; 18 system "echo always >/sys/kernel/mm/transparent_hugepage/defrag";
19 system "echo 3 > /proc/sys/vm/drop_caches"; 19 system "echo 3 > /proc/sys/vm/drop_caches";
20 system "echo 1 > /proc/sys/vm/compact_memory"; 20 system "echo 1 > /proc/sys/vm/compact_memory";
21 exec "nice", "-n-20", "ionice", "-c1", $0, "-=reloaded=-", @ARGV; 21 exec "taskset", "-c", "12-15", "nice", "-n-20", "ionice", "-c1", $0, "-=reloaded=-", @ARGV;
22 exit 255; 22 exit 255;
23 } 23 }
24} 24}
25 25
26use common::sense; 26use common::sense;
80# MUST be canonical, same as dfe 80# MUST be canonical, same as dfe
81our $STATE_FILE = "/fs/doom/db/doomfrontend.state"; 81our $STATE_FILE = "/fs/doom/db/doomfrontend.state";
82our $STATE_SHM = "/dev/shm/doomfrontend.state"; 82our $STATE_SHM = "/dev/shm/doomfrontend.state";
83our @LIRC = ("unix/", "/run/lirc/lircd"); 83our @LIRC = ("unix/", "/run/lirc/lircd");
84our $CONF_FILE = "/fs/doom/root/dfe.conf"; 84our $CONF_FILE = "/fs/doom/root/dfe.conf";
85our $VIDEO_DIR = "/fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds"; 85our $VIDEO_DIR = "/fs/doom/root/00_distant_worlds";
86our $ARCHIVE_DIR = "/fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds/00_archive"; 86our $ARCHIVE_DIR = "/fs/doom/root/00_distant_worlds/00_archive"; # was /fs/doom/var/lib/mythvideo/02_ytd/00_distant_worlds/00_archive
87our $MYTHTV_DIR = "/fs/doom/var/lib/mythtv"; 87our $MYTHTV_DIR = "/fs/doom/var/lib/mythtv";
88our $MEDIAINFO = "/usr/bin/mediainfo"; 88our $MEDIAINFO = "/usr/bin/mediainfo";
89our $MPV = "mpv"; 89our $MPV = "mpv";
90our @MPV_ARGS = qw( 90our @MPV_ARGS = qw(
91 --audio-client-name=doomfrontend 91 --audio-client-name=doomfrontend
883 } 883 }
884} 884}
885 885
886############################################################################# 886#############################################################################
887 887
888sub canonpath { 888sub _canonpath {
889 my $path = $_[0]; 889 my $path = $_[0];
890
891 my $file;
892
893 unless (-d $path) {
894 $path =~ s/((?:^|\/)[^\/]+\z)//;
895 $file = $1;
896 }
890 897
891 $path = Cwd::realpath $path; 898 $path = Cwd::realpath $path;
892 $path = "/fs/$NODENAME$path" unless $path =~ /^\/fs\//; 899 $path = "/fs/$NODENAME$path" unless $path =~ /^\/fs\//;
893 900
901 "$path$file"
902}
903
904our $VIDEO_DIR_CANON = _canonpath $VIDEO_DIR;
905
906sub canonpath {
907 my $path = _canonpath $_[0];
908 $path =~ s/^\Q$VIDEO_DIR_CANON\E(\z|\/)/$VIDEO_DIR$1/;
894 $path 909 $path
895} 910}
896 911
897# check path for mythtv 912# check path for mythtv
898sub is_myth($) { 913sub is_myth($) {
917 $k = "/$k"; 932 $k = "/$k";
918 933
919 push @CONF_PLAYLIST_ORDER, $k 934 push @CONF_PLAYLIST_ORDER, $k
920 unless $v->{hide}; 935 unless $v->{hide};
921 936
922 $v->{cwd} = canonpath $v->{cwd} // $VIDEO_DIR; 937 $v->{cwd} = $v->{cwd} ? canonpath $v->{cwd} : $VIDEO_DIR;
923 938
924 my $state = $STATE{$k} //= {}; 939 my $state = $STATE{$k} //= {};
925 $CONF_PLAYLIST{$k} = $v; 940 $CONF_PLAYLIST{$k} = $v;
926 $state->{from_conf} = 1; 941 $state->{from_conf} = 1;
927 } 942 }
1055sub scan_00_distant_worlds { 1070sub scan_00_distant_worlds {
1056 ( 1071 (
1057 "", 1072 "",
1058 [ 1073 [
1059 video_sort #d# 1074 video_sort #d#
1060 @{ scan_video_dir "/fs/doom/root/00_distant_worlds" }, 1075 @{ scan_video_dir $VIDEO_DIR },
1061 @{ scan_video_dir "/fs/doom/root/ytnew" }, 1076 @{ scan_video_dir "/fs/doom/root/ytnew" },
1062 @{ scan_video_dir "/seagate2tb/sinatar" }, 1077 @{ scan_video_dir "/seagate2tb/sinatar" },
1063 ] 1078 ]
1064 ) 1079 )
1065} 1080}
1094 my $scan = sub { 1109 my $scan = sub {
1095 my ($path, $display) = @_; 1110 my ($path, $display) = @_;
1096 1111
1097 my @dirs; 1112 my @dirs;
1098 1113
1114 $path = canonpath $path;
1115
1099 opendir my $fh, $path 1116 opendir my $fh, $path
1100 or return; 1117 or return;
1101 for (sort readdir $fh) { 1118 for (sort readdir $fh) {
1102 next if /^\.\.?$/; 1119 next if /^\.\.?$/;
1103 stat "$path/$_" or next; 1120 stat "$path/$_" or next;
1108 1125
1109 push @dirs, ["$path/$_", "$display/$dis"]; 1126 push @dirs, ["$path/$_", "$display/$dis"];
1110 1127
1111 } elsif (-f _) { 1128 } elsif (-f _) {
1112 my $dis = dec $_; 1129 my $dis = dec $_;
1113 push @list, [(substr "$display/$dis", 1), canonpath "$path/$_"]; 1130 push @list, [(substr "$display/$dis", 1), "$path/$_"];
1114 } 1131 }
1115 } 1132 }
1116 1133
1117 __SUB__->(@$_) 1134 __SUB__->(@$_)
1118 for @dirs; 1135 for @dirs;
1260} 1277}
1261 1278
1262sub play_video { 1279sub play_video {
1263 ($PLAYING_STATE, $PLAYING_PATH, my $continue) = @_; 1280 ($PLAYING_STATE, $PLAYING_PATH, my $continue) = @_;
1264 1281
1265 my $playback_start; 1282 my $playback_start = 0;
1266 1283
1267 if ($continue) { 1284 if ($continue) {
1268 $playback_start = $PLAYING_STATE->{curpos} // 0; 1285 $playback_start = $PLAYING_STATE->{curpos} // 0;
1269 } else { 1286 } else {
1270 my @menu = ([beginning => 0], [cancel => undef]); 1287 my @menu = ([beginning => 0], [cancel => undef]);
1314 1331
1315 $mpv->cmd ("script-message", "osc-visibility", "never", "dummy"); 1332 $mpv->cmd ("script-message", "osc-visibility", "never", "dummy");
1316 $mpv->cmd ("set", "vid", "auto"); 1333 $mpv->cmd ("set", "vid", "auto");
1317 $mpv->cmd ("set", "aid", "auto"); 1334 $mpv->cmd ("set", "aid", "auto");
1318 $mpv->cmd ("set", "sid", "no"); 1335 $mpv->cmd ("set", "sid", "no");
1336 #$mpv->cmd ("set", "sub-delay", "-19.100");
1337 #$mpv->cmd ("set", "sub-codepage", "UTF-8-BROKEN");
1319 $mpv->cmd ("set", "file-local-options/chapters-file", $mpv->escape_binary ("$mpv_path.chapters")); 1338 $mpv->cmd ("set", "file-local-options/chapters-file", $mpv->escape_binary ("$mpv_path.chapters"));
1339 $mpv->cmd ("set", "options/start" => "$playback_start"); # file-local-options, or just start do not work
1320 $mpv->cmd ("loadfile", $mpv->escape_binary ($mpv_path)); 1340 $mpv->cmd ("loadfile", $mpv->escape_binary ($mpv_path));
1321 $mpv->cmd ("script-message", "osc-visibility", "auto", "dummy"); 1341 $mpv->cmd ("script-message", "osc-visibility", "auto", "dummy");
1322 #$mpv->cmd ("playlist-clear"); 1342 #$mpv->cmd ("playlist-clear");
1323 1343
1324 my $oid = 100; 1344 my $oid = 100;
1361 } elsif ($INPUT eq "return") { 1381 } elsif ($INPUT eq "return") {
1362 $status = 1; 1382 $status = 1;
1363 last; 1383 last;
1364 1384
1365 } elsif ($INPUT eq "mpv/file-loaded") { # start playing, configure video 1385 } elsif ($INPUT eq "mpv/file-loaded") { # start playing, configure video
1366 $mpv->cmd ("seek", $playback_start, "absolute+exact") if $playback_start > 0; 1386 #$mpv->cmd ("seek", $playback_start, "absolute+exact") if $playback_start > 0;
1367 1387
1368 my $target_fps = eval { $mpv->cmd_recv ("get_property", "container-fps") } || 60; 1388 my $target_fps = eval { $mpv->cmd_recv ("get_property", "container-fps") } || 60;
1369 $target_fps *= play_video_speed_mult; 1389 $target_fps *= play_video_speed_mult;
1370 set_fps $target_fps; 1390 set_fps $target_fps;
1371 1391
1418 } else { # HHMMSS 1438 } else { # HHMMSS
1419 $arg = sprintf "%02d:%02d:%02d", $arg / 100 / 100, $arg / 100 % 100, $arg % 100; 1439 $arg = sprintf "%02d:%02d:%02d", $arg / 100 / 100, $arg / 100 % 100, $arg % 100;
1420 } 1440 }
1421 $mpv->cmd ("osd-msg", "seek", $arg, "absolute+exact"); 1441 $mpv->cmd ("osd-msg", "seek", $arg, "absolute+exact");
1422 } else { 1442 } else {
1423 $mpv->cmd ("osd-msg-bar", "show-progress"); 1443 #$mpv->cmd ("osd-msg-bar", "show-progress");
1444 $mpv->cmd ("script-binding", "stats/display-stats-toggle");
1424 } 1445 }
1425 1446
1426 } elsif ($INPUT eq "yellow") { 1447 } elsif ($INPUT eq "yellow") {
1427 $mpv->cmd ("osd-auto", "cycle-values", "osd-level", "2", "3", "0", "1"); 1448 $mpv->cmd ("osd-auto", "cycle-values", "osd-level", "2", "3", "0", "1");
1428 1449
1533 } 1554 }
1534 1555
1535 $mpv->cmd_recv ("stop"); 1556 $mpv->cmd_recv ("stop");
1536 1557
1537 # make sure state is clean, even if its slower 1558 # make sure state is clean, even if its slower
1538 $mpv->stop; 1559 #$mpv->stop;
1539 mpv_init; 1560 #mpv_init;
1540 1561
1541 #if ($DPMS_DISABLE) { 1562 #if ($DPMS_DISABLE) {
1542 # system "xse", "-dpms"; 1563 # system "xse", "-dpms";
1543 #} 1564 #}
1544} 1565}
2273 $pl->{cwd} = canonpath $args->[0]; 2294 $pl->{cwd} = canonpath $args->[0];
2274 2295
2275 } else { 2296 } else {
2276 # playlist, must be all files => create playlist with files 2297 # playlist, must be all files => create playlist with files
2277 2298
2278 $pl->{full_list} = [map { ref ? $_ : stat_video $_ } @$args]; 2299 $pl->{full_list} = [map { ref ? $_ : stat_video canonpath $_ } @$args];
2279 2300
2280 ::input_feed "enter" if @$args == 1; #d# hack: auto-play when single video 2301 ::input_feed "enter" if @$args == 1; #d# hack: auto-play when single video
2281 } 2302 }
2282 } 2303 }
2283 2304

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines