diff options
author | James Meyer <james.meyer@operamail.com> | 2012-12-01 18:26:09 (GMT) |
---|---|---|
committer | James Meyer <james.meyer@operamail.com> | 2012-12-01 18:26:22 (GMT) |
commit | e2c33b0fae1fa4af8bbbfc917eb8e13a3ac0cb37 (patch) | |
tree | bee3fe89f2988dd244e11791755e129aa8c03b14 /abs/not_built/core/tweaker/bin/twk_RAM.pl | |
parent | 8132c218cfc1f1acb1c6d12154e0d4ca075e77f2 (diff) | |
download | linhes_pkgbuild-e2c33b0fae1fa4af8bbbfc917eb8e13a3ac0cb37.zip linhes_pkgbuild-e2c33b0fae1fa4af8bbbfc917eb8e13a3ac0cb37.tar.gz linhes_pkgbuild-e2c33b0fae1fa4af8bbbfc917eb8e13a3ac0cb37.tar.bz2 |
Mass move of uncompiled packages to abs_not_built.
The will sit here for a bit, and then will be removed completely if no one claims them.
Diffstat (limited to 'abs/not_built/core/tweaker/bin/twk_RAM.pl')
-rwxr-xr-x | abs/not_built/core/tweaker/bin/twk_RAM.pl | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/abs/not_built/core/tweaker/bin/twk_RAM.pl b/abs/not_built/core/tweaker/bin/twk_RAM.pl new file mode 100755 index 0000000..2eea598 --- /dev/null +++ b/abs/not_built/core/tweaker/bin/twk_RAM.pl @@ -0,0 +1,81 @@ +#!/usr/bin/perl -w + +# Copyright 2007-2009 Robert ("Bob") Igo of StormLogic, LLC and mythic.tv. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +use Switch; +use Tweaker::Script; +package Tweaker::Script; + +set_known_options( 'low', 'medium', 'high' ); + +# ??? Need to make this update a class variable so it only ever needs to run once. +sub determine_RAM_size() { + my $result = execute_shell_command("cat /proc/meminfo | grep MemTotal"); + if ($result =~ m/.*MemTotal:\s*(\d+) .*/) { + return $1; + } + return 0; +} + +# Try to implement the given option. +sub implement_option { + my($option) = @_; + + $dbconnectionstring = get_mythtv_connection_string(); + + if (connect_to_db("DBI:mysql:$dbconnectionstring")) { + # MythTV's GUI allows setting this value in multiples of 4700kB. + # We will arbitrarily set the HDRingbufferSize to the value that is closest to + # 3.3% of the total RAM. + my $RAM_size = determine_RAM_size(); + my $ringbuffer_size = int($RAM_size * 0.033 / 4700) * 4700; + change_or_make_setting('HDRingbufferSize', $ringbuffer_size) || exit -1; + + # change any existing mplayer cache setting to one based on available RAM size + # We will arbitrarily set the cache size to 1/16 of available RAM + my $cachesize = int($RAM_size / 16); + execute_shell_command("if [[ `grep -e cache.*=.*\$ /etc/mplayer/mplayer.conf` ]]; then sed -i 's/cache.*=.*/cache=$cachesize/g' /etc/mplayer/mplayer.conf; else echo 'cache=$cachesize' >> /etc/mplayer/mplayer.conf; fi") || exit -1; + + # If there's enough RAM, make mtd run by default. + # ??? unimplemented + } else { + exit -1; + } + disconnect_from_db(); +} + +# Poll the system to see what recommendationlevel the given option has on the system. +sub poll_options { + my($option) = @_; + my $fudge_factor = .985; + my $low_RAM = int($fudge_factor * 512*1024); # ~512MB + my $medium_RAM = int($fudge_factor * 1024*1024); # ~1GB + my $high_RAM = int($fudge_factor * 2048*1024); # ~2GB + + threshold_test($option, determine_RAM_size(), "RAM", $low_RAM, $medium_RAM, $high_RAM); +} + +# Unimplemented in 0.7 +sub check_option { + help; +} + +# Unimplemented in 0.7 +sub count_iterations { + help; +} + +process_parameters; |