From 8ab2b94c697866402266afc4f04cebf76203463f Mon Sep 17 00:00:00 2001
From: Bob Igo <bob@stormlogic.com>
Date: Mon, 13 Jul 2009 14:33:26 -0400
Subject: initial mplayer-wrapper integration; some more mplayer tweaks;
 preliminary smplayer tweaks

---
 abs/core-testing/tweaker/PKGBUILD                  | 14 +++++-----
 abs/core-testing/tweaker/bin/twk_audio.pl          |  6 ++---
 abs/core-testing/tweaker/bin/twk_cpu.pl            | 31 ++++++++++++++++++++++
 abs/core-testing/tweaker/bin/twk_general.pl        |  8 +++---
 .../fs/home/mythtv/.config/smplayer/smplayer.ini   |  2 +-
 5 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/abs/core-testing/tweaker/PKGBUILD b/abs/core-testing/tweaker/PKGBUILD
index ebd3ed4..377edda 100644
--- a/abs/core-testing/tweaker/PKGBUILD
+++ b/abs/core-testing/tweaker/PKGBUILD
@@ -1,7 +1,7 @@
 pkgname=tweaker
 pkgver=1
-pkgrel=38
-pkgdesc=""
+pkgrel=40
+pkgdesc="applies tweaks to the baseline configuration and attempts to optimize settings for the hardware it finds"
 arch=('i686' 'x86_64')
 
 depends=('bash' 'perl' 'perl-dbi' 'perl-exception-class' 'perl-log-log4perl' 'perl-log-dispatch' 'perl-getopt-lucid' 'perl-list-member' 'perl-class-data-inheritable' 'perl-devel-stacktrace' 'perl-xml-twig') 
@@ -16,19 +16,18 @@ install=tweaker.install
 build() {
    TWEAKER_ROOT=usr/LH/tweaker
    mkdir -p $startdir/pkg/$TWEAKER_ROOT
-   mkdir -p  $startdir/pkg/$TWEAKER_ROOT/{bin,fs,tcf}
+   mkdir -p $startdir/pkg/$TWEAKER_ROOT/{bin,fs,tcf}
    mkdir -p $startdir/pkg/etc/profile.d
    mkdir -p $startdir/pkg/usr/lib/perl5/vendor_perl/Tweaker/ 
    
    cd $startdir
    # executables
    install -m0777 -D bin/*  $startdir/pkg/$TWEAKER_ROOT/bin
-    
    
    # parallel root directory structure used for seeding configuration files
-#   install -m0777  -D fs/ $startdir/pkg/$TWEAKER_ROOT/fs
-    cp -rp fs $startdir/pkg/$TWEAKER_ROOT/
-    chmod -R  0777 $startdir/pkg/$TWEAKER_ROOT/ 
+   # Ensure shell variables are configured at start; ensure $TWEAKER_ROOT/bin is in $PATH
+   cp -rp fs $startdir/pkg/$TWEAKER_ROOT/
+   chmod -R  0777 $startdir/pkg/$TWEAKER_ROOT/ 
    
    # Tweaker configuration files
    install -m0555 -D tcf/*  $startdir/pkg/$TWEAKER_ROOT/tcf
@@ -37,7 +36,6 @@ build() {
    #install -m0755 log4perl.conf $startdir/pkg/etc/log4perl.conf
    install -m0755 log4perl.conf $startdir/pkg/$TWEAKER_ROOT
 
-   # Ensure shell variables are configured at start; ensure $TWEAKER_ROOT/bin is in $PATH
    install -m0755 tweaker.sh $startdir/pkg/etc/profile.d/tweaker.sh
 
    # Copy our tweaker Perl modules for general use
diff --git a/abs/core-testing/tweaker/bin/twk_audio.pl b/abs/core-testing/tweaker/bin/twk_audio.pl
index eec7992..09676ed 100755
--- a/abs/core-testing/tweaker/bin/twk_audio.pl
+++ b/abs/core-testing/tweaker/bin/twk_audio.pl
@@ -110,9 +110,9 @@ sub implement_option {
     sub edit_mplayer_conf {
 	my($option) = @_;
 	# delete any old entries that Tweaker made, relevant to this particular edit
-	my $delete_old_tweaker_edits = "[ -e $mplayer_conf ] && sed -i '/^.*a[o,c].*=.*#TWEAKER/d' $mplayer_conf";
+	my $delete_old_tweaker_edits = "[ -e $mplayer_conf ] && sed -i '/^.*a[o,c,f].*=.*#TWEAKER/d' $mplayer_conf && sed -i '/^speed.*=.*#TWEAKER/d' $mplayer_conf";
 	# comment out old entries that some other process may have made
-	my $comment_out_external_edits = "[ -e $mplayer_conf ] && sed -i 's/^\\(a[o,c].*=.*\\)/#\\1/g' $mplayer_conf";
+	my $comment_out_external_edits = "[ -e $mplayer_conf ] && sed -i 's/^\\(a[o,c,f].*=.*\\)/#\\1/g' $mplayer_conf && sed -i 's/^\\(speed.*=.*\\)/#\\1/g' $mplayer_conf";
 	my $command1;
 	my $command2="";
 	($card, $device) = poll_for_digital_output_device;
@@ -133,7 +133,7 @@ sub implement_option {
 		# Not supported yet.
 	    }
 	    case "digital" {
-		$command2 = "echo -e 'ac=hwac3,hwdts, #TWEAKER\nao=alsa:device=plughw=$card.$device #TWEAKER' >> $mplayer_conf";
+		$command2 = "echo -e 'ac=hwac3,hwdts, #TWEAKER\nao=alsa:device=plughw=$card.$device #TWEAKER\naf=scaletempo=stride=30:overlap=.50:search=10 #TWEAKER\nspeed=1.0 #TWEAKER' >> $mplayer_conf";
 		if (my $error = execute_shell_command($command2)) {
 		    $logger->error("ERROR: $error");
 		    $logger->error("ERROR: Unable to implement option $option.");
diff --git a/abs/core-testing/tweaker/bin/twk_cpu.pl b/abs/core-testing/tweaker/bin/twk_cpu.pl
index 118bac1..8bddbe3 100755
--- a/abs/core-testing/tweaker/bin/twk_cpu.pl
+++ b/abs/core-testing/tweaker/bin/twk_cpu.pl
@@ -57,6 +57,36 @@ sub get_HDD_size {
 #    
 #}
 
+# Edit mplayer.conf to tell mplayer to drop video frames when necessary.  This should do no harm
+# on systems that don't need the option, and it should make video watchable on those that do.
+sub edit_mplayer_conf {
+    use vars qw($mplayer_conf);
+    $mplayer_conf = "/etc/mplayer/mplayer.conf";
+
+    # delete any old entries that Tweaker made, relevant to this particular edit
+    my $delete_old_tweaker_edits = "[ -e $mplayer_conf ] && sed -i '/^.*hardframedrop.*=.*#TWEAKER/d' $mplayer_conf";
+    # comment out old entries that some other process may have made
+    my $comment_out_external_edits = "[ -e $mplayer_conf ] && sed -i 's/^\\(hardframedrop.*=.*\\)/#\\1/g' $mplayer_conf";
+    my $command1;
+    my $command2="";
+    my $logger = get_logger('tweaker.script');
+
+    if (my $error = execute_shell_command("$delete_old_tweaker_edits && $comment_out_external_edits")) {
+	$logger->error("ERROR: $error");
+	$logger->error("ERROR: Unable to implement option $option.");
+	exit(-1);
+    }
+
+    $command2 = "echo -e 'hardframedrop=true #TWEAKER' >> $mplayer_conf";
+    if (my $error = execute_shell_command($command2)) {
+	$logger->error("ERROR: $error");
+	$logger->error("ERROR: Unable to implement option $option.");
+	exit(-1);
+    }
+
+    $logger->info("Edited $mplayer_conf to drop video frames when CPU is overloaded.");
+}
+
 # Try to implement the given option.
 sub implement_option {
     my($option) = @_;
@@ -106,6 +136,7 @@ sub implement_option {
 	change_or_make_setting('OSDTheme', 'blootube-osd') || exit -1;
 	change_or_make_setting('PlayBoxShading', '0') || exit -1;
 	change_or_make_setting('PlaybackExitPrompt', '2') || exit -1;
+	edit_mplayer_conf();	
     } else {
 	exit -1;
     }
diff --git a/abs/core-testing/tweaker/bin/twk_general.pl b/abs/core-testing/tweaker/bin/twk_general.pl
index 387920c..3d16f2c 100755
--- a/abs/core-testing/tweaker/bin/twk_general.pl
+++ b/abs/core-testing/tweaker/bin/twk_general.pl
@@ -87,10 +87,8 @@ sub implement_option {
 	    #
 	    # better awareness of different video extensions
 	    #
-	    change_or_make_entry("videotypes", [["playcommand", "mplayer-resumer.pl -fs -zoom -vc theora,fftheora, -vo xv %s"]], [["extension", "ogg"]]);
-	    change_or_make_entry("videotypes", [["playcommand", "mplayer-resumer.pl -fs -zoom -vc theora,fftheora, -vo xv %s"]], [["extension", "theora"]]);
-	    foreach my $video_ext ("mp2", "tp", "ts", "m2p", "nuv", "mkv") {
-		change_or_make_entry("videotypes", [["playcommand", "Internal"], ["f_ignore", "0"], ["use_default", "1"]], [["extension", $video_ext]]);
+	    foreach my $video_ext ("mp2", "tp", "ts", "m2p", "nuv", "mkv", "ogg", "theora") {
+		change_or_make_entry("videotypes", [["playcommand", "Default"], ["f_ignore", "0"], ["use_default", "1"]], [["extension", $video_ext]]);
 	    }
 	    foreach my $non_video_ext ("jpg", "par2") {
 		change_or_make_entry("videotypes", [["f_ignore", "1"]], [["extension", $non_video_ext]]);
@@ -415,7 +413,7 @@ sub implement_option {
 	    change_or_make_setting('VCDPlayerCommand', 'mplayer vcd:\/\/ -cdrom-device %d -fs -zoom -vo xv -vf pp=lb');
 	    change_or_make_setting('VideoArtworkDir', "$SQL_DirVideo/.covers");
 	    change_or_make_setting('VideoBrowserNoDB', '1');
-	    change_or_make_setting('VideoDefaultPlayer', 'mplayer-resumer.pl -fs -zoom -vo xv %s');
+	    change_or_make_setting('VideoDefaultPlayer', 'mplayer-wrapper.pl -fs -zoom %s');
 	    change_or_make_setting('VideoGalleryNoDB', '1');
 	    change_or_make_setting('VideoStartupDir', $SQL_DirVideo);
 	    change_or_make_setting('VideoTreeNoDB', '1');
diff --git a/abs/core-testing/tweaker/fs/home/mythtv/.config/smplayer/smplayer.ini b/abs/core-testing/tweaker/fs/home/mythtv/.config/smplayer/smplayer.ini
index 33439a7..9660607 100644
--- a/abs/core-testing/tweaker/fs/home/mythtv/.config/smplayer/smplayer.ini
+++ b/abs/core-testing/tweaker/fs/home/mythtv/.config/smplayer/smplayer.ini
@@ -330,7 +330,7 @@ reset_zoom=Shift+E
 auto_zoom=Shift+W
 zoom_169=Shift+A
 zoom_235=Shift+S
-exit_fullscreen=Esc
+exit_fullscreen=
 next_osd=O
 dec_contrast=1
 inc_contrast=2
-- 
cgit v0.12