[mythtv-users] suggestions for improving my external channel changing script
Joe Auty
joe at netmusician.org
Thu Oct 25 05:49:52 UTC 2007
Hello,
Often times my IR blaster external channel changing script does not
change to the correct channels. When the script is invoked, video
becomes very jerky as if the CPU is temporarily pegged, and therefore
timing is often messed up. Sleep times seem inconsistent, and therefore
the results of this script are inconsistent.
I've tried tweaking it as much as I can, but I thought I would see if
there is a way to either speed up execution of irsend commands, whether
I can reduce the overhead so that CPU stutters do not affect execution,
or whether there are some other tricks I could try...
Your ideas are most welcome, even the most inelegant of hacks... Getting
consistent channel changing here trumps elegance!
Thanks in advance!
#!/usr/bin/perl
# make sure to set this string to
# the corresponding remote in /etc/lircd.conf
$remote_name = "dish";
#hires allows finer timing resolution on the sleep command
use Time::HiRes;
$delay = "1.5";
$channel=$ARGV[0];
sub change_channel {
my($channel_digit) = @_;
system ("irsend --device=/dev/lircd1 SEND_ONCE $remote_name
$channel_digit");
}
#sleep 4;
if (length($channel) > 2) {
change_channel(substr($channel,0,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,1,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,2,1));
} elsif (length($channel) > 1) {
change_channel(substr($channel,0,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,1,1));
} else {
change_channel(substr($channel,0,1));
}
system("irsend --device=/dev/lircd1 SEND_ONCE $remote_name select");
# I run the channel change command again since it seems to run better
# the second time, just in case it misses the first channel change
sleep 4;
if (length($channel) > 2) {
change_channel(substr($channel,0,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,1,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,2,1));
} elsif (length($channel) > 1) {
change_channel(substr($channel,0,1));
Time::HiRes::sleep($delay);
change_channel(substr($channel,1,1));
} else {
change_channel(substr($channel,0,1));
}
system("irsend --device=/dev/lircd1 SEND_ONCE $remote_name select");
--
Joe Auty
NetMusician: web publishing software for musicians
http://www.netmusician.org
joe at netmusician.org
More information about the mythtv-users
mailing list