MHEG and Radio bugs and work-arounds

Share your success stories with others

Moderator: Pablo

Post Reply
davidm
New Member
Posts: 4
Joined: Thu Nov 30, 2006 6:12 pm

MHEG and Radio bugs and work-arounds

Post by davidm » Thu Nov 30, 2006 7:01 pm

I'm posting this as a success story although it does list some bugs I found and how I got round them.

First the success. I've had an EPIA machine as a separate frontend for some months and I've been using FC5 installed on an old laptop drive. Booting FC5 took a while and the drive is quite noisy so I was interested to try minimyth. I followed the instructions which were clear and I was surprised how easy it was to get minimyth up and running, booting over the network. It helped, perhaps, that I already had a working system on the EPIA.

It worked fine with TV but I had some problems when I changed to a radio channel with an MHEG logo.

1. The freemheg code uses FreeSans.ttf and that isn't in /usr/share/mythtv. The UK MHEG profile mandates the use of the Tiresias font but that isn't freely available so instead freemheg uses FreeSans which seems to give reasonable results. Broadcasters assume the layout of text in MHEG so changing the font isn't something that should be under the control of users.
The fix was to add FreeSans.ttf to /usr/local and add a symlink in the configuration script.

2. There seems to be a bug in the version of g++ used to compile minimyth. freemheg uses exceptions to handle rare cases in MHEG and it seems that when compiled with -Os the exception handlers in freemheg are not working. The effect is that mythfrontend dies with an uncaught exception when certain MHEG applications are encountered. The problem isn't there with gcc 4.1.1 or if a different optimisation option is used.
The work-around was to copy libmythfreemheg-0.20.so.0 from my FC5 version and install it via /usr/local and the script. I think this is the problem noted in the posting '"Interactive TV" (MHEG) support'.

3. I tried compiling from minimyth from source. It looks as though the mythstream source file you download has changed under your feet. The checksum is different and one of your patches looks as though it has already been applied.

4. This last one is really quite odd. I noticed a sort of stuttering on the radio channels that wasn't there on the television channels or on my FC5 version. I compiled minimyth with the same svn distribution of myth just to make sure. After switching back and forth between the two versions it turned out that in FC5 I had been running myth as an unprivileged user whereas in minimyth myth runs as root. Running myth as root in FC5 showed the stuttering problem. The solution was to add an unprivileged user by means of the configure script and a little bit of C code and run myth as that user. I don't understand this but it works.

I've now dispensed with the disc drive and FC5 and I'm happily running minimyth.

David

Pablo
Site Admin
Posts: 4182
Joined: Tue Dec 14, 2004 2:13 am
Location: La Jolla
Contact:

Re: MHEG and Radio bugs and work-arounds

Post by Pablo » Fri Dec 01, 2006 12:34 am

davidm wrote:I'm posting this as a success story although it does list some bugs I found and how I got round them.
Thank you for doing all this detective work and posting the results.
It worked fine with TV but I had some problems when I changed to a radio channel with an MHEG logo.

1. The freemheg code uses FreeSans.ttf and that isn't in /usr/share/mythtv. The UK MHEG profile mandates the use of the Tiresias font but that isn't freely available so instead freemheg uses FreeSans which seems to give reasonable results. Broadcasters assume the layout of text in MHEG so changing the font isn't something that should be under the control of users.
The fix was to add FreeSans.ttf to /usr/local and add a symlink in the configuration script.
I did not know that anything required the Free*.ttf fonts. I will add FreeMono.ttf and FreeSans.ttf back into MiniMyth.
2. There seems to be a bug in the version of g++ used to compile minimyth. freemheg uses exceptions to handle rare cases in MHEG and it seems that when compiled with -Os the exception handlers in freemheg are not working. The effect is that mythfrontend dies with an uncaught exception when certain MHEG applications are encountered. The problem isn't there with gcc 4.1.1 or if a different optimisation option is used.
The work-around was to copy libmythfreemheg-0.20.so.0 from my FC5 version and install it via /usr/local and the script. I think this is the problem noted in the posting '"Interactive TV" (MHEG) support'.
I can change the build system to replace -0s with -02 in the myth/mythtv-* packages. Does this problem only occur with -Os, or with other -O optimizations as well?
3. I tried compiling from minimyth from source. It looks as though the mythstream source file you download has changed under your feet. The checksum is different and one of your patches looks as though it has already been applied.
I will fix this. I wish people would change the version number when they change the source tarball.
4. This last one is really quite odd. I noticed a sort of stuttering on the radio channels that wasn't there on the television channels or on my FC5 version. I compiled minimyth with the same svn distribution of myth just to make sure. After switching back and forth between the two versions it turned out that in FC5 I had been running myth as an unprivileged user whereas in minimyth myth runs as root. Running myth as root in FC5 showed the stuttering problem. The solution was to add an unprivileged user by means of the configure script and a little bit of C code and run myth as that user. I don't understand this but it works.
Is it only mythfrontend that you needed to run as the unprivileged user, or did you run other processes/applications as the unprivileged user as well?
MiniMyth running on an Acer ApireRevo 3610 and a Zotac ZBOX-ID80-U. Find out more at my MythTV page.

Pablo
Site Admin
Posts: 4182
Joined: Tue Dec 14, 2004 2:13 am
Location: La Jolla
Contact:

Post by Pablo » Fri Dec 01, 2006 5:47 am

0.20-21b4, the latest in the download test directory, contains a fixes for everything you debugged except running as non-root. Could you test it and see whether or not it fixes your problems? Also, if you describe what you did for running as non-root, then I can add that as well.
MiniMyth running on an Acer ApireRevo 3610 and a Zotac ZBOX-ID80-U. Find out more at my MythTV page.

davidm
New Member
Posts: 4
Joined: Thu Nov 30, 2006 6:12 pm

Post by davidm » Fri Dec 01, 2006 4:01 pm

0.20-21b4, the latest in the download test directory, contains a fixes for everything you debugged except running as non-root. Could you test it and see whether or not it fixes your problems?
It seems to have fixed (1) but not (2). I still get

Code: Select all

terminate called after throwing an instance of 'char const*'
I can change the build system to replace -0s with -02 in the myth/mythtv-* packages. Does this problem only occur with -Os, or with other -O optimizations as well?
It seems to be only with -Os and only with the version of gcc you use (3.4.6). I tried building libmythfreemheg on my backend/frontend machine with various combinations of that version of gcc, gcc v4.1.1 and -Os, -O2 and -O3. Only gcc 3.4.6 and -Os generated the buggy code.
Also, if you describe what you did for running as non-root, then I can add that as well.
I only needed to run mythfrontend as an unprivileged user but that will also fork other programs. I don't have a CD/DVD on that machine so I didn't test everything. It may be necessary to make some additional devices universally readable/writable.

To run as an unpriliveged user I disabled the automatic login with

Code: Select all

MM_X_ENABLED="no"
and then ran the following in my minimyth.script

Code: Select all

echo 'tv::100:100::/root:/bin/ash' >> /etc/passwd
chmod u+s /usr/bin/X
chmod og+rw /dev/snd/*
chmod u+s /sbin/poweroff
chown -R tv /root
echo 'xinit' > /root/.profile
echo 'exit' >> /root/.profile
echo '3:2345:respawn:/sbin/agetty -n -l /usr/local/bin/autologin 9600 tty3' >> /etc/inittab
kill -1 1
The source for autologin was based on something I found here to get round restrictions in agetty. My version is

Code: Select all

#include <unistd.h>

int main() {
   execlp( "login", "login", "-f", "tv", 0);
}
There are probably other ways of doing this but this worked for me.

David.

Pablo
Site Admin
Posts: 4182
Joined: Tue Dec 14, 2004 2:13 am
Location: La Jolla
Contact:

Post by Pablo » Sat Dec 02, 2006 4:01 am

Thank you for giving it a try and describing your modifications.

I am not sure why there is still a problem with libmythfreemheg. Even though libmythfreemheg was built with -O2, it may be that building other things the impact the build of libmythfreemheg (including the compiler) with -Os causes a problem.

MiniMyth can be built with gcc 4.1.1. However, since using gcc 4.1.1 did not result in a noticeable runtime performance difference and it takes longer to build, I have been using gcc 3.4.6 instead. I will build a version of MiniMyth with gcc 4.1.1 and upload it. If using gcc 4.1.1 fixes the problem and doesn't break anything, then I will switch to gcc 4.1.1.

I used the information you provided to add the ability to run as a restricted user. I have done it somewhat differently, and I need to test it more. I will include it in the next version that I upload.
MiniMyth running on an Acer ApireRevo 3610 and a Zotac ZBOX-ID80-U. Find out more at my MythTV page.

davidm
New Member
Posts: 4
Joined: Thu Nov 30, 2006 6:12 pm

Post by davidm » Sun Dec 03, 2006 3:01 pm

Thanks for investigating this. As the author of freemheg I'm keen to get it to work in minimyth so I've spent a while looking into the problem.
I am not sure why there is still a problem with libmythfreemheg. Even though libmythfreemheg was built with -O2, it may be that building other things the impact the build of libmythfreemheg (including the compiler) with -Os causes a problem.
When I tested this previously and said it worked with -O2 and -O3 that was with the directory in the build tree for my AMP backend/frontend but using the 3.4.6 compiler from minimyth. I tried building minimyth from source and when I built libfreemheg in that directory the resulting library failed. Eventually I discovered the difference was that my Makefile used -march=pentiumpro whereas minimyth uses -march=pentium-mmx . Changing that allowed it to compile successfully, at least with -O2 but not -Os.

I've now done a complete rebuild of minimyth with mm_GARCH=pentiumpro. I had to make a few changes to the scripts and the kernel build to get it to work but the resulting code works fine. I suspect the problem has to do with conflicts in the -march flags used for myth and for the libraries, particularly qt.

Hope this is useful. If you can make a version with GCC 4.1.1 I'll be happy to test it.

David.

Pablo
Site Admin
Posts: 4182
Joined: Tue Dec 14, 2004 2:13 am
Location: La Jolla
Contact:

Post by Pablo » Sun Dec 03, 2006 6:17 pm

What hardware do you have?

My understanding is that -march=pentiumpro will cause the compiler to assume the processor supports the CMOV instruction. It is my understanding that the CMOV instruction is not supported by the c3 processor, which is used on VIA EPIA ME6000 and some early VIA EPIA M10000 boards.

---

Also, I built MiniMyth with GCC 4.1.1 and -Os. However, after doing so, MythDVD had problems. Right now, I am building with GCC 4.1.1. and -O2. With Xorg forced to -O2 rather than -Os, the savings of -Os is greatly reduced. Therefore, if GCC 4.1.1 with -O2 works, I will switch to it.
MiniMyth running on an Acer ApireRevo 3610 and a Zotac ZBOX-ID80-U. Find out more at my MythTV page.

davidm
New Member
Posts: 4
Joined: Thu Nov 30, 2006 6:12 pm

Post by davidm » Sun Dec 03, 2006 9:40 pm

I have a VIA M10000 Nehemiah which I think does have the CMOV instruction. I can see why you might not want to produce a binary that wouldn't work on some processors.

From what I can tell the problem has to do with unwinding the stack during an exception. One further thing I discovered is that removing -fomit-frame-pointer also fixes the problem. It's possible that the difference between compiling with -march=pentium-mmx and -march=pentiumpro just produces slightly different instructions and that disguises the bug.

As far as I can tell the version of GCC 4.1.1 on my main machine doesn't have this problem with any setting of -march so I would definitely try that if you can.

David.

jack
Contributor
Posts: 53
Joined: Sun Aug 07, 2005 3:42 pm

Post by jack » Wed Jan 31, 2007 12:36 am

After failing miserably to try compiling and recompiling my old minimyth install, I've just upgraded to 0.20-21, and everything I have tried with MHEG works! Thanks to you both :D

Post Reply