[mythtv-users] External Channel Change Script Contention

Michael Halcrow mike at halcrow.us
Fri Mar 3 01:25:30 UTC 2006


I have an IR blaster that I use from MythTV to change channels on my
external satellite receiver. The script is derived from something I
found somewhere on the 'net:

---
for digit in $(echo $1 | sed -e 's/./& /g'); do
        /usr/local/lirc-ledxmit/bin/ledxmit-irsend SEND_ONCE 3100 $digit
        sleep 0.4
done
---

I have two problems. The first is that whatever video I am watching
from MythTV freezes for .4 seconds for each digit transmitted. For
instance, if I am watching a video in MPlayer and MythTV kicks in for
a scheduled recording, the video in MPlayer will freeze for each digit
of the channel. I have tried to get around that by wrapping the call
to the script in another script and backgrounding the channel changing
script. This are still a little jumpy during a channel change, but not
quite as bad.

Then there is the problem of multiple simultaneous instances of the
channel changing script if one hits the ``channel up'' or ``channel
down'' key multiple times before the script(s) can finish. Then that
causes contention between multiple instances of the channel changing
script, and the channel gets changed to some strange value; for
instance, if one channel is 120 and the other is 36, then I may wind
up on channel 13260. Mayhem ensues. I am addressing that with a lock
file, and I'm sleeping a couple more seconds for the satellite
receiver to accept the fact that the channel needs changing:

---
lockfile -r 2 /tmp/change_channel.txt
if [ $? == 0 ]; then
    for digit in $(echo $1 | sed -e 's/./& /g'); do
        /usr/local/lirc-ledxmit/bin/ledxmit-irsend SEND_ONCE 3100 $digit
        sleep 0.4
    done
    sleep 2
    rm -f /tmp/change_channel.txt
else
    echo "Lock failure" >> ~/change_chan.log
fi
---

So that seems to work well enough. Of course, it's a race condition if
the channel is changed multiple times in sequence. If I go through
channel 18, 36, 120, and 150, then I may wind up first at channel 18,
then 150, then 36, then 120. Something more intelligent can use a
daemon and queue requests and what not, but then this raises my main
concern about all this: I feel like I'm jumping through a lot of hoops
that a shouldn't have to. For instance, I would expect MythTV to be
able to prevent multiple simultaneous copies of the channel changing
script from running.

Thanks,
Mike
.___________________________________________________________________.
"Pedro offers you his protection."
 - Napolean Dynamite
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://mythtv.org/pipermail/mythtv-users/attachments/20060302/6382b8d9/attachment.pgp 


More information about the mythtv-users mailing list