Monday, December 25, 2006

Static Libraries dependent upon static libraries in XCode

Just a helpful hint to try and prevent your wasting time like we did at my day job. We have a large C++ application which has several different levels (Standard, Pro, Ultra....). So to speed compilation and linking, we put large chunks of code common to all the levels into separately compiled static libraries. Thus, we only have to compile that code once every time we build all the applications, resulting in a massive time savings.

Unfortunately, this was not working under XCode as when we linked in our libraries, there was always some symbol or other which was not available, and we ended up putting large amounts of code into the main project and compiling it for each application level (making our build process at least twice as long as it should have been).

My boss finally got so sick of this he spent a couple days tracking down the problem, and it was that our static libraries were dependent upon other static libraries, but those libraries were not linked in until the application as a whole was linked. Somehow, this confused the XCode linker (ld) and it ended up missing symbols. The trick was to link the other sub-dependent libraries into the libraries static libraries and not directly from the main project.

I know the above is confusing. Here's a more graphical description.
(Before)

  • Main Project

    • Static Library 1 Project (needs Static Library 2 & 3)

    • Static Library 2 Project

    • Static Library 3 Project


(Now)
  • Main Project

    • Static Library 1 Project (needs Static Library 2 & 3)

      • Static Library 2 Project

      • Static Library 3 Project

Saturday, December 02, 2006

HDHomeRun - Networked HDTV Tuner

[Update: check out Signal GH, an iPhone utility for monitoring the signal quality of an HDHomerun].

I have a PCHDTV 3000 PCI card in the Dell Dimension which serves as my MythTV. Since DVB drivers became part of the standard Fedora install, it has been problem-free. But, it doesn't meet all of my needs.

First, there are occasions when the broadcast networks show 2 or even 3 good shows at once. I'd like to be able to catch these rare alignments, but my PCHDTV can only record one show at once. I could buy another, but that would be the last open PCI slot in the Dimension, and what if I wanted to expand internal storage later with an SATA card? Second, the MythTV was banished to the basement for excessive noise, which means it is about 80 feet of RG6 cable from the main antenna splitter in the second bedroom, meaning it is getting less signal, and noisier signal than an upstairs device. Third, to be useful, the MythTV has to be on all the time, which means draining a minimum of $9/month of electricity. Fourth, I've never been able to figure how to access a PCHDTV card with non-root level privileges; I'm sure it's possible, I just can't figure it out, which means I run the mythtv backend as root. This is frowned upon.

Then, I came across the HDHomeRun networked digital TV tuner (both ATSC and QAM). This simultaneously overcomes all 4 problems with the PCHDTV.
  • It has 2 tuners.
  • It doesn't use up a PCI slot.
  • It can be located as close to the antenna as I like.
  • It can be accessed via any user account with network access.
  • I can access the data stream directly from my MacBook, albeit kludgily, even when my MythTV is off. [Update: It is no longer cludgy on the Mac. You can buy an HDHomerun bundled with El Gato's slick EyeTV application.]



It does cost more than a PCHDTV, but less than two.

I held out for a while, but I finally ordered one. It came Wednesday. I've been happy.

MythTV 0.20 has built in support for this device. However, be warned that you have to open your firewall to its traffic. If you try to run mythtv-setup and you can't get it to scan for channels. Maybe it's your firewall.

I was amazed by how well my MythTV box pumped massive amounts of data. At one time, I simultaneously recorded 3 HD programs over the air--2 over Ethernet from the HDHomeRun, and 1 via the PCHDTV--while watching a recording of Day Break from the night before, and it was smooth as silk. There have been a lot of improvements in MythTV over the last year; I don't think it could have taken all this back then on my aging hardware.

Lately, whenever I buy new hardware, I measure it's electrical usage. There is a hidden cost to every gadget we buy. According to my Kill-A-Watt, my HDHomeRun draws 6 Watts at all times, whether capturing or not [Update: I've heard that subsequent revisions (those you would buy new today) use less power] . A low power mode while awaiting network commands would be nice, but the usage isn't bad compared to the 90 Watts the MythTV box draws. So it's less than a dollar a month to power it. However low the power, it does get a little warm, and I worry about it's life span, but time will tell.

In order to control the device from my Mac, I downloaded the hdhomerun_config source code from the Silicon Dust Forum. It was a simple matter to create an XCode project and compile the command line tool for Mac OS X, and I could then use the instructions for using VLC to watch TV directly from the device on my MacBook. Entering a series of obscure command line commands is much too klunky, and I hope VLC will absorb these functions, but it did work and looked great on the 13.3 inch screen.

Monday, November 06, 2006

Dell 2005FPW with the LG LST-3510A HDTV receiver

I have a two year old Dell 20.1" widescreen LCD display (2005FPW). I also have three LG LST-3510A HDTV receiver/DVD players. Just so any Googlers might be curious, yes you can watch HDTV on your DVI capable LCD monitor and this receiver. No, you can't watch upconverted DVDs, at least not with the firmware in this particular 3510A (1.93), it gives me a warning about needing a HDCP connection and refuses to play. HDTV is a little distorted, as the 2005FPW is not a true 16:9 monitor (closer to 16:10), but it looks fine driven at 720p.

I like the 3510A as an HDTV receiver. I bought this particular unit for $49 shipped via an eBay auction, The low price due to the description saying it couldn't play DVDs well. Well, guess what? I don't care. It's a sensitive, reliable, flexible HDTV tuner and that is what matters to me. I can hook it up with DVI, VGA or component connectors to any number of display devices. Plus, it has both coax and optical digital audio connectors. I got another one cheap (not as cheap) with the preferred 1.91 firmware because the seller didn't know how to get it out of Spanish menu mode.

Here's its manual.

As is typical, neither eBay units came with remotes. Luckily, my third unit has a remote. Also, you can get most (not all, the DVD arrow keys are wrong) of the functionality from a cheap One-For-All remote. The One-For-All even has the codes for a proper fast forward/reverse on the DVD player, which the original remote does not have. Even the Harmony remote database has a few holes, so I'm glad to have at least one master remote.

Actually, I have little clue how people choose the proper eBay price for one of these things. I just saw an auction close for $58+shipping on a unit which was clearly marked as broken and being sold for salvage/repair. But it did come with a remote.

I don't really need 3 HDTV receivers. This third one is a family gift.

Sunday, October 29, 2006

XCode debugger exited with status (1)

All of a sudden an XCode project which I was sharing with a collaborator refused to be debugged. The debugger was evidently exiting unexpectedly with "exited with status (1)" message. 

It took a long while to figure this out, but the project had been modified by my collaborator to hard code ppc generation. There were 3 such references in the project file. Had to change that to get the debugger to work again.

Wednesday, October 25, 2006

How not to use the boost singleton class

This is an odd and frustrating warning I was seeing while using the templated singleton class which comes with the boost C++ libraries while compiling under Visual Studio 2005. I used the following code to define a class which would be controlling a thread. It worked, but I was scared by the warning.



template< class T > class MySingleton : public boost::detail::thread::singleton < T >
{
};

class MyPayloadThread : public MySingleton< class MyPayload >
{

};



1>c:\src\hdrs\MySingleton.h(133) : warning C4624: 'MySingleton < T > ' : destructor could not be generated because a base class destructor is inaccessible
1> with
1> [
1> T=MyPayload
1> ]
1> c:\src\MySingleton.cpp(16) : see reference to class template instantiation 'MySingleTon < T > ' being compiled
1> with
1> [
1> T=MyPayload
1> ]


I did a lot of googling and couldn't find a direct answer to how I was supposed to give access to the singleton's private destructor. Then I had an epiphany about how I was supposed to use this class. The proper usage is:


typedef boost::detail::thread::singleton < class MyPayload > MyPayloadThread;

In retrospect, it's obvious that I couldn't sub-class singleton, I had to make use of it as a pure template.

Sunday, October 22, 2006

Wednesday, October 11, 2006

Tuesday, October 03, 2006

Setting up a Cheap Version Control Server for XCode

If you program, you need a version control system. We've all heard it, we all know it. But it's a trouble to setup and a pain in the pocketbook to dedicate a server, and even if you have a used computer free for the asking, it's still going to take up space and $10/month for electricity.

Because of a collaborative project, I felt an acute need for a version control system. My collaborator and I were spending much too much time stepping on each other's code trying to maintain a collection of source files via diffs and hand editing. So Sunday morning, I woke up with the resolve to set up a system.

My first thought was just to run a version control system on the Linux box I use for MythTV, but I've been rebooting into Windows XP every couple days to play Madden 06, and during the summer, when nothing much is on TV, I often turn it off to save energy. So it wouldn't be an ideal situation.

I thought of posts I've read about hacking NAS boxen to run Linux and a quick bit of googling came up with the consensus winner, the Linksys Storage Link for USB 2.0 Disk Drives NSLU2. This is a really cheap ($80), amazingly small, embedded Linux computer with 100 Base-T ethernet and 2 USB 2.0 ports. Plus it has an active development community of hackers extending what it can do.


I also decided to use a popular open source version control system Subversion (svn), if for no other reason that it isn't CVS, which I hate, or Perforce, which hates me.

Disclaimer: I am not a Linux expert. I am a decent Mac coder and software designer. You could very easily end up with a $80 paper weight, and not a good paper weight at that. Be careful.

Setting up the NSLU2
I am not going to go deep into setting up an NSLU2. I used the Unslung firmware, the instructions which came with the firmware, and the NSLU2-Linux HowTo.

Some important warnings about the process: test out the NSLU2 before modifying it. Bring it up in its unhacked form. Have it format your drive as EXT3. Make sure it works. Mount the shared volume on your Mac, copy some files, etc. The ethernet on the first unit I bought failed moments before I was going to flash its firmware, saving me from returning it modified. Think about your needs when it comes to hardware, I had a 60GB notebook drive in a compact USB 2.0 case lying on my desk; the capacity is fine for running a version control system, it's low power (it's actually powered by the two USB ports in the NSLU2), and I already had it. I used a cable tie to attach it to the NSLU2, and it became one, very portable solution. My Kill-A-Watt says the NSLU2 and the hard drive together draw 4W idling (9VA).
NSLU2+Hard Drive
NSLU2+Hard Drive Back

[Update:
One thing I didn't take into account while setting this up is spinning the drive down to save noise and wear. According to this page, this is problematic and should be looked into before settling on a drive. I'm sitting at my desk 3 feet from the NSLU2 and I can definitely hear a bit of sandy whirl coming from the drive. Of course, the beauty of a server is that I can store it anywhere with an ethernet port and a electrical socket, like next to the upstairs router.]

[Update: I replaced the 2.5 inch drive with a standard 3.5 inch external USB drive, and that has been going strong for 2 years now. Having said that, I should look into backing it up.]

Use the NSLU2 web interface to give yourself an account with the same name as your account on your Mac. This will make ssh'ing into the unit just a bit easier. In the text below, I will use "jim" as a user name.

Again using the web interface, Give the NSLU2 a static IP address in the range used by your router, for example 192.168.0.21 if your router uses 192.168.0.x IP addresses which is common.

Change the password for the admin account to something more secure.

Also make a group for all the collaborators of your project. Add yourself and the collaborator accounts to this group. This can all be done from the web interface. Make sure to give all these new accounts their own private folder.

At this point, you should have installed the new firmware, "unslung" Linux from running embedded to running off the USB 2.0 hard drive and been able to telnet into the box (Enable telnet from the web interface), and know your root password. Your NSLU2 is not going back to its old self, it's married to its hard drive.

I'm going to take over with the instructions.

Installing OpenSSH.
  • Telnet as root into the NSLU2 and install the OpenSSH package.
#ipgk update
#ipkg install unslung-feeds
#ipkg update
#ipkg install openssh
  • Reboot (unplug the NSLU2, plug it back in, push the on button, wait)
  • Turn Telnet back on via the Web Interface.
  • Telnet into the NSLU2
  • Edit the ssh server configuration file at /opt/etc/openssh/sshd_config (I used #sudo vi /opt/etc/openssh/sshd_config)

...
#LoginGraceTime 2m
PermitRootLogin no
#StrictModes no
MaxAuthTries 6
RSAAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
...
  • If you like the bash shell, then
    #ipkg install bash
  • Make sure your user account is setup to take you to your home directory with your favorite shell by editting /etc/passwd
jim:sc0MOzL8dVGa6:2003:501::sc3B6pVbVCgxc:/dev/null
to
jim:sc0MOzL8dVGa6:2000:501::/jim/:/opt/bin/bash


  • Edit /opt/etc/init.d/S40sshd by changing
/opt/sbin/sshd
to
/opt/sbin/sshd -f /opt/etc/openssh/sshd_config
  • Restart the NSLU2


So at this time, you should be able to ssh into the NSLU2 via a command like: ssh jim@192.168.0.21 Confirm this is so, and if not remember that you can probably get back in via telnet. A point about what we have done. We disabled ssh as root because hackers might get lucky guessing your root password. My /var/log/messages file is filled with miscreants trying to get in as root.

Setting up public/private keys
Y
[Update: I had had outdated instructions for setting up certificate based login here. OS X Leopard makes it much easier. Instructions Here.]

At this time, you should be able to ssh into your server without being asked for a password or passphrase as long as you are running SSH Agent. Now it's time to install svn.

Setting up the svn server
Subversion is a version control system. Version control systems are complex and have a high learning curve. Subversion is complex and has a high learning curve. There is a free O'Reilly book which covers its usage pretty well. At least read the Getting Started Chapter.
  • Install the svn package

#ipkg install svn


  • Copy the directory tree of the project for which you are starting source control onto the NSLU2 (let's say in /tmp/myproject)[Update: don't copy the build directory]
  • If you haven't already, create a directory for your project.
  • Make sure that your project group has access to this new directory.
  • Import the project under the control of svn

#mkdir /MyProject
#chown jim:myprojectgroup /MyProject
#cd /MyProject
#svnadmin create /MyProject
#svn import /tmp/myproject file:///MyProject/myproject -m "initial import"


At this time you should have a project under version control. You just need to be able to access it from your Mac.
Setting up the svn client on the Mac

[Update: Try to install the same version of subversion on your Mac as you do on the NSLU2. I had trouble with version 1.4 on the Mac and 1.3.2 on the NSLU2.
svn --version
]
Here are two ways to install Subversion:

1) Go this page on apple.com.

2) Install Fink and use Fink Commander to keep installing packages until svn-client and svn-shlibs are listed as current. I found that fink balked at compiling all the pre-requisite libraries, but I could install those from binary and finally get svn itself to compile. It will take a while to compile.

At this point, you should have the svn client installed in your /sw/bin/ directory and be ready to checkout your project.

Checking out your project
  • Create a clean directory into which you want to check out your project.
  • Open up a Terminal window and cd into the newly created directory.
$svn checkout svn+ssh://192.168.0.21/MyProject This is where it was important that you use the same user name for both the NSLU2 and your Mac. Notice I didn't have to specify "jim@". It was all implied.

At this point, you should have your project checked out onto your Mac.

Setting up XCode
  • Open up the XCode project file in your checked out project directory.
  • In the Groups And Files panel, choose the topmost blue project icon.
  • Right click on the project; select Get Info
  • In the General tab, choose Subversion as the SCM System
  • In the General tab, click the Edit... button. Enter /sw/bin/svn
  • In the General tab, click Enable SCM.


At this point, you should be able to commit changes, revert changes, and other basic source control functions from XCode's SCM menu.

Allowing outside collaborators access to the svn server
Obviously, a big part of source control is allowing outside collaborators access to your code. That's one of the big reasons we've gone to the trouble of using the ssh tunneling method for accessing the svn server. It should allow safer access to your network. But people outside your local area network will need to locate the NSLU2 from the Internet.

To do this, you will have to have a router which supports DynDNS. I have a previous blog entry about setting up a DynDNS account. In addition to the setup there, you will have to have your router redirect port 22 (ssh) traffic to the NSLU2. Do not do this until you are satisfied you are secure; it's a jungle out there.

Also, your collaborators will have to setup their own DSA public/private keys for their own accounts on the NSLU2. An easy way to download their private key is via CyberDuck. I had initially recommended the old standby Fugu, but I didn't have a Universal binary version of Fugu and when I looked for one, found a lot of positive feedback for CyberDuck. Just be sure to choose the SFTP option for the new connection.


At this point, you should have a network setup where a collaborator could checkout your project using a command like:
$svn checkout svn+ssh://mydomain.homeip.net/MyProject

Good luck, and sorry if I missed anything.

Thursday, August 24, 2006

Throwing RAM at XCode Linking

In my day job, I spend a lot of time compiling and linking a fairly large commercial C++ application. My PowerBook G4 was not up to the task of compiling the whole thing in a reasonable time, although I could distribute the compilation to two G5 desktops when I was at work. But this did not help when I worked from home, nor did it help with linking. And no, zero-link never seems to work for me.


So I bought a MacBook, and home compiles are now peppy. But linking is still fairly slow, especially if I'm running my normal selection of apps, and I rarely compile the whole application, but I have to re-link it every time I want to test a change. I ran the Utility Monitor utility while linking and I was shocked to see that linking, which drags my whole computer down to a crawl, was only using 10% of the CPU; it was crawling because even in 1GB of RAM, linking caused a horrible virtual memory paging thrash. Well, one of the nice things about a MacBook is it is upgradeable to 2GB.


I first measured my linking speed on my 1GB 1.83GHz MacBook with a 5400 rpm SATA 120GB Momentus hard drive. It actually wasn't too bad, linking my work application in an average of 150 seconds. If it was like that all the time, I might not have seen the need to upgrade my memory, but adding applications running concurrently makes linking time progressively worse. Launching Safari, iTunes, and iPhoto and doing light browsing while the link completes, bumps it up to 197 seconds, adding Skype to the mix increases the time to 248 seconds. (150/197/248)


Then I upgraded the RAM to 1.5 GB and the times improved markedly. (91/110/102)


Then I upgraded the RAM to 2.0 GB and the times really got fast. (39/54/61).


XCode Linking Speed versus MacBook RAM

I noticed that as the times got quicker, the fraction of the CPU taken up by the linker (ld) went up. At 1GB of RAM, ld was using at most 14% of the CPU, at 2GB, it was up to 50%. It wasn't spending all it's time paging out. In fact, Activity Monitor
showed only 7 page outs after my testing versus hundreds of thousands of page outs after the 1GB testing.


You might have noticed, I didn't mention the size of my application. That is because, the size of my application is irrelevant to you. The point is, I was having slow linking, and upgrading my memory capacity improved my linking speed by around 4x for an investment of $165 (shipped) in name brand RAM. If you are having a slow linking problem, maybe you will get similar results; but you will have to measure to find out.


My brother Joe also has a RAM hungry program he relies upon, Parallels Desktop, and he tells me that bumping his MacBook to 2GB made it the fastest Windows XP computer he's ever used. (And that's with one core tied behind its back.)

Tuesday, August 15, 2006

Windmill vs. New Refrigerator

Must resist urge to use the word tilting


I recently bought a Kill A Watt energy consumption measuring device, and have become an enthusiast for saving electrical power. Several co-workers have borrowed it and now have a better understanding of how they can conserve power.


In the course of my evangelism, I fell into a conversation with a co-worker who planned to buy and install a windmill on his property in New Hampshire. He feels this is a good way to both save resources and money. I asked him how much electricty he could generate, and he replied that his measurements indicated he could generate an average of 450 Watts. At $0.15 per kWh, this would be around $45 a month in energy. I asked him how much a windmill costs: $4000. How long would it last: 30 years with little maintenance.


By way of comparison, I had lent my Kill-A-Watt to another fellow, who reported back that his 15+ year old refrigerator was using $45 a month in energy. My refrigerator uses $12 a month in electricity, so this person could save $33 a month if he were only to buy as efficient a refrigerator as mine. Checking online, indicates a refrigerator should last for 15 years, and a top rated model (by Consumer Reports) such as the Whirlpool ET1FHTXMQ costs $750.


So the question is: If I had $4000 should I get a new refrigerator, or a windmill? (this thought experiment does not take into account subsidies, inflation or taxes). Interest income calculated using this online calculator.

Scenario 1 (buy windmill)
Initial investment account balance: $0
Return on energy generated: $45/month
Investment account balance after 30 years (assuming 8% return):$67513


Scenario 2: (buy $750 refrigerator and replace it again in 15 years)
Initial investment account balance: $3250
Return on energy saved: $33/month
Investment account balance after 30 years (assuming 8% return):$82571


Scenario 3: (buy neither)
Initial investment account balance: $4000
Investment account balance after 30 years (assuming 8% return):$43743


So, from a purely monetary point of view, investing in a new refrigerator is better than buying a windmill if your old refrigerator needs replacing. And if you have both an old refrigerator and an old dehumidifier, I suspect you will end up saving as much energy as a windmill generates at a fraction of the price. The guy with the bad refrigerator was also spending $60 per month on dehumidification.


The amazing thing for me is that the 50+% return you can get from buying a new refrigerator makes it such an incredibly good deal if your old refrigerator is inefficient. (Over 15 years you save $6000 in energy costs, which if invested at 8% would yield $11,500) Obviously, not everyone has such an old clunker as my co-worker. Your mileage may vary, but I highly recommend getting a Kill-A-Watt and finding out.

Monday, July 31, 2006

Brenthaven Laptop Bags: MacBook Slim

I purchased a MacBook two weeks ago. I am replacing my trusty PowerBook simply because the MacBook is so much faster and Apple no longer sells a Pro compact laptop. Believe me, if there was a MacBook Pro 12 or a MacBook Pro 13.3, I would have bought one. Which means replacing my Brenthaven Pro File 12 shoulder bag. And since I have such a fond regard for the Brenthaven—compact, well constructed, protective of my computer, attractive—getting another.


Therefore, I went to www.brenthaven.com and what do I see but their featured laptop bag, the MacBook Slim. The name evoked compactness, and the picture appeared to be a clone of my Pro File 12, so I mustered up the will to spend $100 on a bag, and ordered one.


It came Friday, and it is beautiful, and well constructed. And I sent it back Saturday morning. The thing is huge. Great for frequent travelers who keep their office in their bag, not so great for me, who slips his laptop into its case every morning and every evening and needs only enough extra storage for an iPod. Moral of the story: read the dimensions in product descriptions. I've asked BrentHaven to replace the Slim (width = 17.2 inches) with a Glove (width = 13.5 inches) and I'll see how that works out.


By the way, Brenthaven makes returns easy. The box they shipped me already had a pre-printed RMA address label, which I just slapped on the box and brought to the post office. (I did have to pay postage.)


Another BTW, my wife thinks my tiny Pro File 12 bag is somewhat unmasculine, and I should get a bag more in proportion to my physique. Well, I'm not that vain, I guess.

[Update: After more than two years of use, I'm quite pleased with the Brenthaven Glove as a bag for my MacBook. I shows little wear, has comfortable handles, and has protected my MacBook well against numerous bumps and the occasional short drop. Highly recommended. ]

Friday, July 28, 2006

Advice to the 30 year old car buyer

And now for something completely different. Advice on buying cars.

Three years ago, I was single, dating, and car shopping. I had always driven manual transmission two door coupes; and could easily have bought another. But I was dating with intent to marry, and had to envision what my needs might be over the course of the 5-10 years I might own my new car.

A friend of mine had started her married life with a two door, with the daily grind of dealing with a back seat baby seat. Given my plans at the time, I planned for the future and bought a four door sedan (a Honda Civic LX). Someone asked my future wife what kind of car I had bought, and on hearing the choice had said, "He must be serious then."

What I did not take into consideration, but should have, is that fewer and fewer people are adept at driving a stick shift, and my wife to be was one of them. In fact, she can't drive at all, but would like to. You might prefer a manual transmission, but your future spouse most likely will not. So my advice for anyone dating with intent to marry and shopping for a new car: buy something with at least 4 doors and an automatic transmission. You're going to have to live with your purchase for a long while.

Saturday, July 01, 2006

The Ongoing Expense of MythTV (or why is my electric bill $105 with no air conditioning?)

A few months ago, I purchased a Kill-A-Watt power monitoring device, and today I went around the house and measured the power usage of my various devices and appliances. I wanted to figure out where the 19 kilowatt hours of electricity I was using per day was going. The results surprised me.


First, I measured my refrigerator, a Sears Frigidaire which came with the house. As it's energy use varies depending on whether its compressor is running, I used the Kill-A-Watt to monitor its energy usage for an hour. After an hour, it had used .110 kilowatt hours, so it used an average of 110 Watts. Assuming this is representative of a month's usage and at 15 cents per kilowatt, in a 30 day Month I pay (0.11*24*30*0.15 )$12 keeping myself in cold raspberry ice tea.


I also measured my TiVo (32W/$3.46), and satellite receiver (28W/$2.92) as they are also on all the time. My TV and speaker system are not on all the time (really, I swear), but assuming they were on 1/3 of the time then I am spending 0.33*(.090kW+0.037kW)*24*30*0.15=$4.50 per month for the energy used by my speaker and TV systems, for a grand total of TV room energy usage of around $11, very close to my refrigeration costs.


Which brings me to the MythTV in the basement. It's a Dell 2GHz Pentium 4. Just sitting there doing nothing it draws 90 Watts. If MythTV's preview panel is showing a thumbnail preview of 720p content, it draws 120W (the same as if it were actually showing 720p content), if it's 1080i content it draws 133W. If I turn on "CPU Friendly" preview, it draws 110 Watts. Yes, that's right, whether or not the monitor is on or not, whether or not the blank screen-saver is on, the preview is using a minimum of 20W. Assuming my MythTV spends most of the month doing "CPU friendly" previewing, it's costing me $2.16/month extra just for the previewing. Therefore, I turn off previewing. Previewing or not, the computer is still drawing 90 Watts just sitting there, costing $9.72/month.


My MythTV is attached to two monitors, a 15" Sony LCD, and a 20" Dell Widescreen LCD. While on, the Dell draws 40 Watts, and the Sony draws 20. KDE had been set to use the "blank" screen saver after 2 hours inactivity. You would think, this would cause the monitors to use less electricity; not according to the Kill-A-Watt. Assuming I neglected to turn off the monitors half the time, I was spending $3.25/month powering unwatched monitors. I opened the display control panel and told Linux to power down the monitors after 2 hours which will eliminate most of this expense. Also, I often neglect to turn off my speakers (24W on/12W "off"), indicating I'm spending $2/month powering unheard speakers.


Adding this all up, and my MythTV had been costing me $17 a month in electrical costs. Turning off previewing and having the system power down the monitors should bring this down to $12 which is precisely the same amount of money I spend on my refrigerator, and coincidentally is the same amount of power used by the upstairs TV room. Now if I could only figure out where the other 11 kilowatt hours a day is going.


[Update: My MythTV box has two internal hard drives. Drive /dev/hda is used when I boot into Windows or when I want to share files with Windows. Drive /dev/hdb is used when I'm running Linux. It occurred to me I could put the unused drive into standby mode (not sleep mode) using the Linux hdparm utility, doing so saved an additional 7W. So now my MythTV computer is drawing 83W instead of 90W; I hope it's just a bit quieter now.

The following line tells my unused drive to go into standby mode after 30 minutes. I'll have to figure out which command file to put this to make it automatic.
#sudo /sbin/hdparm -S 241 /dev/hda
]

Sunday, June 11, 2006

Channel Master 7775 versus Radio Shack In-line Amplifier

In my, seemingly, never ending quest for reliable reception of the Boston Fox affiliate, I decided to upgrade my rooftop antenna's (Winegard 9032) pre-amp. I had been using a Radio Shack In-line Amplifier. As people on AVS Forum like Channel Master pre-amps, all my local stations are UHF, and my antenna is UHF only, I purchased a Channel Master 7775 UHF only pre-amp from Solid Signal. The Channel Master pre-amp costs $19 more than the Radio Shack model (plus shipping differences).


My hope was that by substituting a higher quality UHF only pre-amp, I would get somewhat less noise, somewhat more signal and have fewer hours when Fox pixelates.


By the way, this is not a definitive comparison. Atmospheric conditions might have changed significantly between the time I checked signals with the Radio Shack and when I finished installing the 7775. I did mow the lawn in the interim. However, I hope this report will help anyone wondering if the higher priced pre-amp is worth the money.


I receive 9 digital over the air channels. The following are of the form Network channel# (True channel#) Strength

PBS 2 (19) Strong
CBS 4 (30) Strong
ABC 5 (20) Strong
NBC 7 (42) Mediocre
FOX 25 (31) Intermittent
UPN 38 (39) Mediocre
PBS 44 (43) Mediocre
WB 56 (41) Intermittent
TFA 66 (23) Mediocre

According to AntennaWeb.org these are all UHF stations (higher than channel 13), as 2, 4, 5, 7, are actually broadcasting on UHF channels 19, 30, 29, and 42. I'm about 31 miles away from the antenna farm and all of these transmitters are in the same general direction. I have a three way splitter which sends half the signal to my TV Room and a quarter each to my bedroom and my basement office.


Late this morning, I wrote down the "signal strength" for each of these channels from the Dish Network 411 receiver in my TV room, I then disconnected the Radio Shack in-line amplifier and recorded the signal strength without any pre-amp. And finally, I installed the Channel Master 7775 and recorded the results. I do not know what the receiver means by signal strength; I do know if it drops below 58 it will pixelate, stutter, show a signal loss dialog, and sometimes even crash the receiver making me unplug and restart it. BTW, the Dish Network 411 is an unreliable piece of junk.

The following is of the form Network Channel#: Signal with no pre-amp, Signal with RS in-line, Signal with CM 7775. NS means no signal.
PBS 2: 74, 83, 84
CBS 4: 74, 87, 88
ABC 5: 74, 86, 79
NBC 7: NS, 74, 76
FOX 25: NS, 58, 65
UPN 38: NS, 69, 74
PBS 44: NS, 62, 73
WB 56: NS, 59, 66
TFA 66: NS, 73, 79


From this data, we can see a few things. Without a pre-amp, I would only get 3 stations. The 7775 is not appreciably better than the Radio Shack for the strong UHF stations, and is even a good deal worse on ABC 5 (actually 20). But these channels are more than strong enough either way. More importantly, it is noticeably better at boosting the signal of the marginal and intermittent stations with which I've been having trouble. In particular, it boosted FOX and WB above the magic 58 level. I've been watching the signal on Fox and it oscillates within a range of 60-68 over an hour. I suppose that with the Radio Shack, the range was something like 56-64, resulting in frequent picture loss. At least the current operating range is all good enough, although a little close for comfort. My stronger channels oscillate by a point or two at most.


I've also started getting the Manchester N.H. ABC affiliate with reasonable strength ~65 despite my directional antenna being pointed in the opposite direction. Of course, other than local news, which I do not watch, there is little difference between the programming on ABC Boston versus ABC New Hampshire.


These numbers drift over the course of the year as tree leaves grow to block my angle, and then fall. Hopefully, summer has the worst conditions and this upgrade will be good enough to keep me in tacky reality programming till the leaves fall in autumn.

Saturday, May 27, 2006

Signal Strength Script for EyeTV 2.2.1

[Update: check out Signal GH, an iPhone utility for monitoring the signal quality of an HDHomerun].


The following script works with EyeTV 2.2.1 to speak the signal strength every 5 seconds. I'm posting this because the script I posted a few weeks ago was broken by the new release.


repeat
tell application "System Events"
if UI elements enabled then
tell process "EyeTV"
-- make sure everything between "tell" and ""EyeTV Preferences"" is
-- on one line when you copy and paste
tell progress indicator 1 of UI element 1 of group 1 of tab group 1 of UI element 1 of UI element 4 of UI element 6 of window "EyeTV Preferences"
set mySignal to get value
set mySignal to mySignal * 100
set mySignalInt to mySignal as integer
end tell
end tell
else
display alert "Enable GUI scripting in the AppleScript Utility"
end if
end tell
say mySignalInt
delay 5
end repeat

Monday, May 22, 2006

Tuner card versus an HDTV receiver

A coworker, who knows I am an HDTV know-it-all, asked me whether he should get a tuner card for his desktop PC or buy an ATSC tuner box for use with his new 1080p LCD monitor. He wasn't going to build or buy a specialized media PC, and in the beginning he just wanted to watch TV with no DVR functionality. Nor does he want to pay for cable or satellite. I immediately told him to buy a standalone receiver, and recommended the Samsung SIR T-451 based on comments on the AVS Forum.


For many years, I did not own a TV, but I watched a lot of TV. In the days of Mac OS 7, 8 and 9 I used my desktop Mac (first a Performa 6214 and then a PowerMac 7600) to watch cable TV via a tuner card. It became tiresome waiting for my "TV" to boot, or worse reboot. Plus, it was noisy. Then I bought a NTSC tuner box sold by ViewSonic to which I could hook to my TiVo, my DVD player, my computer, and analog cable; this was quite a step up as I could still use my VGA monitor, but I didn't have to boot my TV.


When it looked like the dreaded broadcast flag was going into affect, I bought a pcHDTV card for my Dell, and started playing around with MythTV and was hooked on the quality. Then I bought an LCD HDTV ready TV, and hooked my MythTV computer to it, and it was good. But it was noisy; and in exchange for perhaps an hour a night of watched HDTV programming, my TV room was noisy 24/7 with the sound of cooling fans. Thus the banishment of the MythTV computer to the basement. The upstairs TV gets its HDTV programming via a Dish Network receiver, and my TV room is blessedly quiet.


The same thing with the digital TV I threw together for the bedroom using an LG HDTV receiver. It's quiet, boots in seconds, and doesn't drain my electrical bill while off.


There is a place for media PCs in the entertainment center, but they should be quiet, specialized PCs (or of course iMacs or Mac Minis), not cheap, noisy, general purpose boxes. If you aren't in a position to shell out the big bucks for a new PC, a standalone OTA receiver is a good value and a good match for the "HD Ready" TV.

Don't act like a tourist in New York

My friend Mindy has another blog site exploring New York City both day and night. It's New York City Nomad.

I read her first post about visiting the new flagship Apple store, and later finding good Korean food, and think she's off to a fine start as a blogger.

[Update: My friend has lost this domain, so this post is no longer operative.]

Saturday, May 13, 2006

SphereX versus Logitech Z-5500 5.1 Speaker Systems

After banishing my noisy MythTV Linux box to the basement, and returning that sweet iMac to work, I had no way of watching recorded programming on the MythTV, or rather no way to listen to recorded programming. I needed a speaker system downstairs which would take TOSLink in and decode Dolby Digital. I considered buying another Z-5500 set, but the price was a little too high for me to pull the trigger. Then one day, I saw a mention on AVS Forum of several low price SphereX 5.1 surround speakers being sold on eBay (the lot has since sold out). These are XBox branded computer speakers, but do not require an XBox, and with shipping were selling for less than half the Amazon price. I'm only human, I pulled the trigger and bid on a set. Did I mention I have a wonderfully forgiving wife?


After happily playing with them for the last day, I decided to write a comparison between the SphereX and the Logitech Z-5500s, as anyone who was considering buying the one would should be considering buying the other.


Images eyeballed to scale.
Logitech Z-5500 Control Unit


SphereX Display Unit

Clear advantages of the Z-5500:

  • Cheaper. Amazon price $240 versus $380.

  • Can be controlled without the remote, including big, beautiful volume knob.

  • Has 3 analog inputs versus 1 on the SphereX.

  • Uses standard bare speaker wire, easy to replace and substitute longer runs.

  • Uses English words instead of red and green dots to give information.

  • Conveniently located headphone jack.

  • The satellite speakers are lighter at 800 grams versus 1180 grams.


Clear advantages of the SphereX:

  • 2 optical inputs versus 1.

  • Finer grained volume control.

  • Potentially upgradable via either firmware upgrade or expansion card.

  • X-Box users can use the USB port instead of an optical port.

  • Power usage. See below.

Sames:

  • 1 digital coax port

  • Decodes Dolby Digital, dts, PCM and Dolby Pro-Logic

  • 5.1 surround sound


I used a Kill-A-Watt energy meter to measure typical usage (for me), and found the SphereX used less energy at the loudness levels I prefer. 29 Watts versus 37 W while playing optical. 29 W versus 39W playing analog, and 21W versus 24W muted. The SphereX did use more energy when "off" at 12W versus 9W.

Subjective differences:
I think the THX certified Logitechs create more accurate sound, but I have no proof of this, and I could probably tweak the SphereX to do less processing. On the other hand, I feel the SphereX fills space better; if you like an immersive experience, you'd probably prefer the SphereX. Spherex claims their hi-tech speakers are tolerant of placement errors, and that does appear to be true. Regardless, I like how both systems sound.


Value:
If you can get the SphereX for $70 less than the Z-5500, as I did, the SphereX is a better value. If you pay full price for both, then the (cheaper) Z-5500 is a better value. If you visit the SphereX page on Amazon.com, you will see that 82% of visitors who end up buying speakers buy the Logitech versus 2% who buy the SphereX. This seems a bit excessive, but is indicative of the value equation. If they were the same price, it would be a contest between a person's need for immersion and the value placed on human interface. But they aren't the same price and the Logitechs win on value.


BTW, Dell sometimes sells the Z-5500 at a discount; as low as $205 with free shipping. Check DealMac for such specials.


Summary:
I like both. If you can get the SphereX cheaper than the Z-5500s or if you absolutely must have an extra optical port, then buy the SphereX. (Or the Logitech Z-5450 which does have 2 optical inputs, but which I don't own.) Otherwise, Logitech's human friendly wired controller, cheaper price and good sound make it the clear value winner.


BTW, don't remove the integrated stand from a Logitech satellite if you want to get it back on again, because you won't be able to. The nut inside the shell will fall off and rattle around uselessly.


Here is a picture of one of each system's satellite speakers with the Logitech on the left (both with the covers off).
SphereX and Logitech Z-5500

Here is a picture of each system's remote with the Logitech on the left. Many of the SphereX buttons are useless unless you have an X-Box.
SphereX and Logitech Z-5500 remotes

[UPDATE: A year and a half of use later.
I recommend the Z-5500 over the SphereX. The lack of head unit controls on the SphereX is the deal breaker. Many has been the time I've scrambled around my little basement office looking for the remote control to drop the volume; whereas upstairs I can always just jump up and twist the big knob. Also, I just don't like the SphereX assuming stereo input is Dolby Pro-Logic encoded—when it never is—forcing me to look for the 2.1 button on the remote rather than hearing the oddly distorted, mildly nauseating sound of mis-interpreted stereo.

Also, I banished my noisy MythTV once again, this time to the laundry room. Now my SphereX speakers are driven by an ever so quiet Mac Mini.
]

Sunday, May 07, 2006

Cool looking product

This is interesting, a container for a Mac Mini which mounts on the VESA mounting holes flat panel monitors and TVs. The mount effectively give any compatible monitor the form factor of an iMac. I wonder if you could extend the mount, and make a TV/Mac Mini/Wall sandwich. Wouldn't be able to use the DVD drive if you did, I bet. [Via MacIntouch ]

Saturday, May 06, 2006

Using EyeTV 2.1 to Orient a Roof Antenna

[Update: check out Signal GH, an iPhone utility for monitoring the signal quality of an HDHomerun].


[Update: also works with the 2.2 update]
If you own an EyeTV, you should know that the Preferences dialog, of all places, displays the signal strength and signal quality.

EyeTV signal strength Dialog

There's even a nice little check box to speak the signal quality with the Mac's text to speech service. It occurred to me that I could put a phone next to my computer, call my cell phone and listen to the signal quality change as I adjusted my antenna on the roof.


EyeTV Tuning Tools

Unfortunately, in my setup, signal quality is useless. When I tune into a marginal channel, the signal quality bounces between 0% and 100% with nothing in between. The signal strength, on the other hand, oscillates in a meaningful range. But there is no check box for speaking the signal strength. If only I could have the computer speak the value of the signal strength indicator. There must be a way.


First, I looked into Apple's Voice Over universal access software. Command-f5 starts the computer speaking the text for everything the mouse rolls over. Unfortunately, I wouldn't be there to roll the mouse back and forth.


Second, I looked at AppleScript. Perhaps, El Gato had made the signal strength property part of its AppleScript dictionary. No luck, but in looking in my AppleScript folder, I stumbled on the solution.

AppleScript Utility

I accidently launched the AppleScript Utility application, and was struck by the checkbox "Enable GUI Scripting" What was that? There were sample scripts under "UI ELement Scripts" in the global scripting menu, and they appeared to enable scriptors to access widgets buried in otherwise unscripted applications.


I launched EyeTV 2.1, and brought up the Preferences Dialog, and through trial and error, came up with this script:

[UPDATE: I've posted a slight modification of this script that works with EyeTV 2.2.1]

repeat
tell application "System Events"
if UI elements enabled then
tell process "EyeTV"
tell progress indicator 1 of UI element 1 of group 1 of tab group 1 of UI element 1 of UI element 1 of UI element 6 of window "EyeTV Preferences"
set mySignal to get value
set mySignal to mySignal * 100
set mySignalInt to mySignal as integer
end tell
end tell
else
display alert "Enable GUI scripting in the AppleScript Utility"
end if
end tell
say mySignalInt
delay 5
end repeat




Running this script in the AppleScript Editor will cause the signal strength to be spoken once every 5 seconds until you tell it to stop. I set EyeTV to display a marginal channel (in my case the Boston Fox affiliate) and started my script. Then I connected two cell phones together, leaving one next to my computer's speakers, and attaching a head set to the other. I listened to it as I made my way to the roof "58, 58, 56, 58, 54, 58, ..." always an even number for some reason. Then I adjusted my antenna until I was satisfied it wasn't going to get any better "62, 64, 64, 66, 62, 64, 64...". I had improved my antenna orientation just enough that EyeTV could now watch Fox consistently as it was over the magic 60 level. Success.


I would not be surprised if the script breaks with a different version of EyeTV. It depends on the window hierarchy being just so.

Monday, May 01, 2006

On redecorating a small apartment

My friend Mindy has started her own blog, concentrating on personalizing her first home: a condominium in Brooklyn. Small Space Big Idea If you want ideas on paint, opinions on movers, or just want to see the glamour of living in the big city, give her a click.

Sunday, April 30, 2006

The iMac Dual Core as a media PC

I have updated this post since its original incarnation, and may update it without notice in the future.

Requirements


I've been dissatisified with my Linux computer as a media PC. Primarily, my 3 year old Dell desktop is not up to the strain of 24/7 service; it is much too noisy for the living room. But it's also painful to make any modification to either MythTV or Linux, a recent upgrade of the NVidia driver ended up being a 3 hour trip on the xorg.conf merry-go-round, and I have absolutely no clue about getting analog audio out of it. At one time, I figured out how to get TOSLink audio out and now I can't just take the computer into the basement and hook it up to cheap desktop speakers; I need an optical port.


As soon as the money is available, I'd like to get an Intel based Mac for my TV room to both serve as a testing and development platform, and as a media PC. When people think Mac OS X media PC, they think Mac Mini, but I see serious limitations.


  • The Mac Mini's graphic hardware is inferior. I want a dedicated graphic card with dedicated VRAM.

  • The Mac Mini supports only one monitor. I'd like a small auxillary monitor for when I'm using the computer as a computer.

  • The small laptop drives in a Mac Mini lack capacity and speed. You end up with noisy, bulky, potentially unreliable external drives.




Therefore, baring dropping $2K on a Macbook Pro, I'm left with the iMac Dual Core. There is surprisingly little verbage on the web about using an iMac as a media PC, so I decided to borrow one from my day job, and check it out.


iMac Dual Core


The 20" iMac is big, nearly as big as my 26" TV. It's too big for what I want: a discrete workstation on which I can find recipes or answer "What have I seen that actress in?" type questions on imdb. The 17" fits better. The second problem is the brightness of the whiteness. I want the area around my TV dark and subdued, even to the point of spray painting the ethernet port's wall plate black. A black iMac would fit right in.


Setup


I collected useful auxillary devices with which to test the iMac: an EyeTV 500 HDTV tuner module, The Ball Bluetooth trackball, an ATI Remote Wonder wireless remote control, a Harmony 520 universal remote, and a set of Logitech Z-5500 speakers.

Various Remotes


The Apple iMac remote is sufficient while running Apple's FrontRow application, but I also wanted to run El Gato's EyeTV PVR software, and watch programs recorded by the MythTV server in the basement, all while controlling my speakers and TV. The Apple remote was useless for that. In fact, I had no way to control everything via one remote. My Harmony infrared remote could control my speakers, TV, FrontRow, and EyeTV, but could not control the MythTV frontend. My Remote Wonder could control everything on the Mac but not the speakers or the TV. ATI had good technical reasons for using the more robust radio frequency system over infrared, but if they had used infrared, I could control everything from my Harmony universal remote. As it is, I need two remotes.

ATI Remote Wonder

Harmony 520


By the way, when setting up the Remote Wonder, it is useful to know that FrontRow is located in the /System/Library/CoreServices/ directory of your hard drive. I don't know why it isn't under Applications. I also don't know how to launch FrontRow from the Remote Wonder, there must be a script or helper application which actually launchs the application.


Another by the way, the EyeTV 500 is located under PVRs in the Harmony online database, but the record is not very good, and I ended up manually adding the codes. I also manually added the codes for the Apple remote.


I made good use of The Ball, it shines for across the room web browsing and given more hands on control when needed.


As I've written before, my Syntax Olevia TV, with its 1368x768 native resolution and obtuse DVI implementation is not computer friendly. I ended up driving it at 720p (1280x720) over a VGA connection after DisplayConfigX couldn't save custom resolutions. I had been running the TV at 1366x768 with my Linux box, but I didn't want to fight that fight anymore. It looks fine. Let the TV do the scaling; it's good at it.


The iMac has an optical audio out port, which I plugged into the Inday SPDIF 4x1 Digital Audio Switch which leads to the Z-500's single optical port. I am quite happy Apple has brought digital audio support to the iMac. It just plugged in and worked (sort of, see below.)

Logitech Z-5500 speakers


My next problem was the stupidity of how most media software handle dual monitors. I would like the menu bar on the iMac's built in display; I would like video to appear on my TV. Thus, I could be watching TV and still be able to browse the web or even run a compilation on the little monitor. Having the menu bar appear on the TV is nearly useless. However, most of the media applications I tried assume I want my video on the monitor with the menu bar. FrontRow blanks out the auxillary monitor, while MythTV justs takes over the main monitor. Only EyeTV works correctly. So, to work around this, I made the TV the main monitor, but I hope future versions behave better.



Performance


I know this will sound silly in a few years, but the Dual Core iMac has amazingly good performance, both in comparison to the Pentium 4 Linux machine it would replace, and my other Mac, a 1.33 GHz PowerBook G4. The native MythTV frontend for Mac OS X is smooth as silk. EyeTV playback is skip free.


Just as important, the iMac is blessedly quiet. I cannot hear it from the couch. This is critical in a home theatre PC; and the iMac passes the test. It isn't noise free, I can hear it late at night when everything else is off, but quiet.


It is not without problems, however, de-interlacing is not functional on the MythTV frontend, so watching NBC's 1080i content was distracting, while watching FOX 720p content was delightful as I caught up on 3 weeks of 24. EyeTV shows some annoying tearing. Also, the only application which is making proper use of AC3 passthrough mode to my audio receiver is the Apple DVD Player. Neither MythTV nor EyeTV sends raw surround tracks over the optical connection. But these are problems which can be addressed. If push came to shove, I could get the source to MythTV and fix it myself, and I'm sure El Gato is working hard to improve performance on Intel. [Update: version 2.2 of the EyeTV software is out with claimed support for digital audio on Intel based Macs.]


The version of the MythTV frontend I downloaded was not full featured; I don't really care about the lack of most features (weather would by nice) but I would like the saved videos feature. A ripped DVD server would be good. And, the iMac couldn't do anything about the lousy Live TV performance by the MythTV server. FrontRow stopped responding to the infrared remote control once, but control came back after a restart. Again, no big deal if it only happens every now and then.


By the way, my own Remote Remote GH for MythTV works quite well with the Mac MythTV frontend, just remember to let port 6546 through the firewall. It came in quite useful when I misplaced the Remote Wonder.


Cost


Let's look at the total outlay for system and peripherals between a Mac Mini and an iMac. Obviously, you don't end up with equivalent systems in the end. With an iMac you end up with a 17" monitor, a slightly faster processor, a much better video sub-system, and a large internal hard drive. With a Mac Mini, you end up with a potentially noisy external drive and no chance of a 2nd monitor, but a much smaller overall size. With a price difference of $277 (18% of the total package cost), I'd say the iMac is very competitive.

=== Keep scrolling. Blogger doesn't like my table ====
























































Feature

iMac Dual Core

Mac Mini Dual Core

Refurbished System

$1099

$849

Upgrade to 1GB RAM

$45

included

Upgrade to 500GB HD

$275

$264

Apple Keyboard

included

$29

The Ball Trackball

$69

ditto

ATI Remote Wonder

$28

ditto

Refurbished EyeTV 500

$199

ditto

Harmony 520 Remote

$99

ditto

Total

$1814

$1537



Total HD space does not include 100GB internal drive on the Mac Mini, or selling the original iMac drive. This is just a rough price comparison. In fact, I probably wouldn't upgrade the iMacs original 160 GB until it was full, or large SATA drives were much cheaper.

Summary


In terms of hardware, the iMac Dual Core has everything needed to fit into my TV room. It is quiet, powerful, and flexible. I wish for a single remote control solution, but I do have a two remote control (and a trackball) solution. The software has a few rough edges, but this does not affect a decision between getting a Mac Mini or an iMac. Overall, I think the iMac (with a few pieces of hardware) an excellent choice as a media PC, and will only get better as Apple, El Gato, and the MythTV community improve their offerings.


It is especially good when compared to my Linux experience. I tried 5 separate media applications; not one had a problem outputting stereo sound. I did not have to tweak hidden .asoundrc files, or recompile video drivers. There were problems with individual applications, but OS X reliably delivered services to the application without any input from me. That was the gratifying part, that I installed 3 pieces of hardware, and 3 third party software packages, and they all worked on the first try; try that with Linux.

Sunday, April 23, 2006

Putting out a first release-Remote Remote GH for MythTV

As I said a few weeks ago, I was writing a small Cocoa application to remotely control my MythTV frontend over my local area network in my home. And I finally got it to the point where it was reasonably stable and reasonably useful. The name of my company is Generally Helpful, and when a product matches that description, it's time to push it out the door.


So, I needed to update my website, which I had not done in years. As an expediency, I just did it all in iWeb using the travel template. It looks quite nice, although I'm sure there will be serious deja vu for people who've seen their share of .Mac pages. And I put together a few help pages using BBEdit so the Help menu would have some content. It's a simple enough to do. Then I had to put together a simple ReadMe in Pages, which I printed out to a PDF file. I like ReadMes which are in PDF format, anybody can read them, they are read-only, they are one file (unlike HTML pages) and you can put any number of pictures and font changes you want. Finally, I built one last Release build, and made sure it actually ran on my system. Sometimes you put out a release build, and there is some dynamic library which is missing and it won't run on any system but your own; I hope that didn't happen.


Then it was a trip to the Disk Utilities "New Image from Folder..." command to create a compressed .dmg file, and I had all the parts needed to publish the site and get going. Then I made announcements to the MythTV user mailing list and the Linux chat section of AVS Forum. I tried to put a posting on Version Tracker, but it has been too long and I couldn't figure out how to report a new product. [Update: I found the Version Tracker submission form.]


Now, I will either get a flood of bug reports and suggestions, or the three people with both PowerBooks and MythTV installations will miss my postings.

Here is the product page.

Thursday, April 13, 2006

Throwing together a digital TV

My wife and I bought our first house recently, which we love. It's a great ranch style brick house in South Nashua, NH. Quiet, sturdy, and expansive.


And I can get along without Comcast, and explore the world of Satellite TV, and high quality over the air broadcast HDTV, while saving money every month; I've a mortgage to pay. I subscribed to Dish Network, and put up a Winegard 9032 UHF roof antenna on the same roof mast the satellite installers mounted the dish. The biggest expense was having an electrician run pairs of RG6 coax cable into wallplates in the TV room and the bedrooms. (If you need some electrical work done in the Nashua area, I can recommend James Electric, he does polished work.)

Winegard 9032 antenna

As I said, we're trying to save on my monthly expenses, which means a basic channel package from Dish, with no HD channels and no locals. I will receive local HDTV programming via my antenna, which also means I will get the finest picture quality; in a strange twist of economics the cheapest programming source, over the air, is the best. And it also means only renting one satellite receiver for the Syntax 26" LT26HVX LCD TV mounted on the wall of the TV room. You can easily end up spending $70 per month on TV just by adding $10 and $5 additions.


It'd be nice to watch some TV in the bedroom, and I did have the electrician wire the bedrooms... But I don't have another TV and while my wife may tolerate my spendy ways, another $900 for an HDTV with an ATSC tuner would be too much both in what we could afford and what little use we'd get out of it. So no new TVs.


But as it happens I had all the components needed to watch digital TV. Most importantly, I had purchased a refurbished LG 3510a HDTV Tuner a few months ago on a whim. Oh, I remember the days when I had whim money... This has a VGA output—it's labeled an RGB output—which I plugged into a 17 inch Viewsonic CRT I haven't gotten around to throwing away, and a digital coax audio port which I plugged into the digital input of a set of unused, but nice, 2.1 computer speakers. The receiver can be set to convert AC3 streams to PCM, which the speakers understand. And I can drape the corded speaker remote around the headboard for easy access; as I can't control the audio via the receiver's remote.


LG 3510A Back

So, for an outlay of $159 for the tuner, and stuff for which I had no other use, I have a small hi-def digital TV. The LG 3510a is also a QAM tuner, so if I were to go back to regular cable, I could watch HD locals via the cable company. And when I eventually upgrade the main TV, the Syntax can move to the bedroom and get its content from the 3510A.


LG 3510A

Finally, it looks and sounds good. LCD TVs do not show standard definition programming well; my CRT monitor does. HiDef content looks amazing in both richness of color and clarity, although it might be a little scrunched. And the digital sound is rich and clear. The tuner has a built in DVD player too, but my firmware revision doesn't allow DVD content via the RGB port, in an attempt to limit theft by pirates too stupid to either bitwise copy the DVD or rip it. Oh well, the 3510A's DVD player never worked well anyway.

Tuesday, March 21, 2006

XCode - Linking Different Static Library Architectures

This had me scratching my head. If you have a static library you want to link into your universal binary, and the library comes in two different files of the same name but in different directories, one for PowerPC and one for Intel i386, then how do you add them both into XCode? Won't the linker find one version first and stop looking and later give an error about missing symbols? Well there are two solutions:

1) Use the lipo utility to join your two static libraries into one universal binary library. This is fine, but you either have to write a script to automate the process or you have to manually run lipo. This is what I did earlier with the gpc runtime library.

2) Make use of the CURRENT_ARCH environment variable. When a universal binary is being built, XCode will set this variable first to "i386", and then later to "ppc". You can use this to set (via XCode's project or target build configuration pane) your library pathnames properly for each half of the build, as in ../mylibs/$(CURRENT_ARCH) which will give a path to your ../mylibs/ppc directory during the PowerPC build and your ../mylibs/i386 directory during the Intel portion. Of course, this requires you arrange your environment in such a fashion. And the directory doesn't even have to be i386/ppc it could be mac_i386/mac_ppc if you used ../mylibs/mac_$(CURRENT_ARCH)

The same thing works for header paths.

One trick I figured out today, if you need to know an XCode environment variable, start a build and look at the beginning of the Build Results log. You'll see all the variables XCode sets. It's a lot faster than trying to guess what to google. A lot faster.

Sunday, March 05, 2006

Actual Cocoa Development

Back in graduate school we had two Macs in the lab. One Mac was fast (for 1993); the other had a CD drive. I wanted to use the fast one, but I also wanted to listen to my small CD collection. So I did what any geekish sort does, I wrote an AppleScript extension, audioCDgh, which allowed me to write short scripts to start the CD playing. That was sort of OK, but not very Mac-like running little scripts when a GUI application was possible. So I wrote my first C++ application, Remote Remote GH, which worked quite well, and started me on over a decade of semi-steady work writing C++ applications.


Well, version 0.19 of MythTV can be controlled via telnet with simple text commands, and I quickly decided it would be very cool to renovate the Remote Remote GH brand with a MythTV edition. So, my nights and weekends have been filled with glorious Cocoa development. Not the trudgery of making a living C++, but honest to goodness, delightfully simple and powerful Objective-C; it's been wonderful and reminded me of why I left chemistry for computers so long ago.


And I'm close to being done. Just this afternoon, I got the TCP socket code working, and have been sending keystrokes to the MythTV box on my local network; it's still very rough, but all the hard stuff is behind me, and just polish and completeness ahead of me. Look for it in a couple weeks.






I've written numerous multimedia controllers over the years, and the one thing I think people miss is that real CD players have buttons for play, stop, fast forward, etc. because they have no alternative; they are limited by their physicality. Computers are less limited. Therefore, RRgh for MythTV will have no such buttons, users will type to send the same commands you would from the Linux keyboard, or double click tables, or navigate via a popup menu; all things a physical CD player's designer could only imagine. Which is a partial shame, as I became quite good at designing play button icons.

Saturday, February 18, 2006

Compiling MythTV 0.19 With Firewire enabled

I had trouble compiling a version of MythTV 0.19 with Firewire enabled. I downloaded the source and invoked the configure script with the following command line:

./configure --disable-distcc --enable-xvmc --enable-dvb --dvb-path=/usr/src/kernels/2.6.15-1.1831_FC4-i686/include/ --enable-opengl-vsync --enable-proc-opt --enable-firewire --enable-dvd --libdir=/usr/lib

This should have enabled firewire, but no dice. Looking in the script, I found that it was using pkg-config to determine the version of three libraries: libraw1394, libiec61883, and libavc1394. The strange thing was that I appeared to have recent versions of all these libraries installed, yet pkg-config didn't think they were recent enough.

A large amount of googling and thinking later, I realized that pkg-config relies upon rpm installers placing ".pc" files into the /usr/lib/pkgconfig/ directory, and I had no ".pc" files for any of the three critical libraries. I downloaded the source trees for each library and discovered that libiec61883.pc, libavc1394.pc, and libraw1394.pc were located in their respective packages. So I copied them into /usr/lib/pkgconfig, and now mythtv configured properly. I was able to make and install a version with Firewire enabled.

We'll see how that turns out.

Friday, February 17, 2006

Linux - Problems updating NVidia driver

So I decided to up grade to 0.19 of MythTV. I downloaded the source, configured and discovered I couldn't compile with firewire cable box support without libavc1394 greater than or equal to version 0.5.0. And of course, I couldn't easily find this particular libary. And I decided it might be easier if I was running an updated my system, so I went with the notorious yum update which updated my kernel to 2.6.15-1.1831_FC4 which, of course, killed my nvidia driver setup because nvidia refuses to open source their drivers which requires barely Linux literate geeks like myself to run their installer every time we bump our kernel up.

So I downloaded and installed my kernel sources and ran:

./NVIDIA-Linux-x86-1.0-7676-pkg1.run --kernel-source-path=/usr/src/kernels/2.6.15-1.1831_FC4-i686


And rebooted, and it didn't work. /var/log/Xorg.0.log says that it "Failed to load the NVIDIA kernel module". modprobe didn't know what nvidia was. lsmod didn't know either. dmesg showed nothing about it. I did a lot of googling and came across this message which indicated someone with a similar problem had noticed there were multiple copies of nvidia related object files in his /usr/X11R6/lib/modules/drivers/ directory and that removing them and re-running the installer and editing my /etc/modprobe.conf to the following:

alias eth0 e100
alias snd-card-0 snd-ice1724
options snd-card-0 index=0
options snd-ice1724 index=0
remove snd-ice1724 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modpro
be -r --ignore-remove snd-ice1724
alias char-major-81 cx8800
alias usb-controller ehci-hcd
alias usb-controller1 uhci-hcd
alias ieee1394-controller ohci1394
install ohci1394 /sbin/modprobe --ignore-install ohci1394; /sbin/modprobe raw1394

# all wonder remote

alias char-major-61 lirc_atiusb
alias lirc_dev lirc_atiusb
# nvidia kernel module
alias char-major-195 nvidia
#alias nvidia nvidia-1_0-7676

solved my problem. Your mileage will probably vary, but its something to try.

Oh, and I still haven't gotten firewire working with MythTV.

Thursday, January 26, 2006

The OS X Intel Transition: Pascal library

I'm solely responsible for transitioning a fairly large, old, OS X C++ Carbon application to the new world of XCode, and beyond that to an Intel/PowerPC universal binary. Most of this is fairly standard stuff, and as before I recommend attending a Universal Binary Workshop if one comes to a town near you, or at a minimum watching all the videos on Apple's transition resource page.


But of course, every transition is different and has one snag that takes up a disproportionate amount of time, and in my case that was a medium sized library written in Pascal which had not been compiled since Metrowerks briefly shipped a Pascal compiler capable of generating a Carbon compliant CFM binary.


I had a bunch of Pascal source code written in an archaic dialect (Mac Pascal?, MPW Pascal? Think Pascal?) with obsolete extensions and run time libraries (StringOf, PLStringOfSet, etc.), no Apple supplied compiler, and I have to generate a universal binary. So I googled around and found GNU Pascal for Mac OS X, which promised XCode integration and universal binary generation. So, I downloaded the binaries and got to work. I decided I would just use the command line for compilation, as there were complications with XCode integration, so I started by issuing the following command:

glenn% gpc -c --automake -funit-path=/Developer/Pascal/GPCPInterfaces/ MySource.p

Which of course spat out hundreds of warnings and errors, and I was forced to walk though each of the dozens of Pascal source files included by the automake directive and get rid of the errors and some of the more scary warnings, replaced the function StringOf with the procedure WriteStr, change almost all the file handing routines, etc. The old code had relied on being passed old fashioned Mac paths with colon separation, GNU Pascal likes / separators. The old code assumed integers were 16 bit, GNU Pascal assumes they are 32 bit. The old code would blithely add an integer to a set, GNU Pascal would like to be assured you don't really want a set 4GBits in size. And since I was making a universal binary, I made sure to make use of the big endian specific file routines to make sure I didn't mangle my input files. It was a lot of work, but eventually it compiled. Yeah.


Then it was time to package a universal binary.


glenn% rm *.o
glenn% rm *.a
glenn% rm *.gpi
glenn% gpc-i386 -c --automake -funit-path=/Developer/Pascal/GPCPInterfaces/ MySource.p
glenn% libtool -static *.o -o MyLib386.a
glenn% rm *.o
glenn% rm *.gpi
glenn% gpc -c --automake -funit-path=/Developer/Pascal/GPCPInterfaces/ MySource.p
glenn% libtool -static *.o -o MyLibPPC.a
glenn% lipo *.a -create -output MyLib.a


I included MyLib.a into my application, and of course it couldn't link because I needed a universal version of the Pascal runtime libraries:


glenn% lipo /Developer/Pascal/gpc345u2/lib/gcc/i386-apple-darwin8/3.4.5/libgpc.a /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple-darwin8/3.4.5/libgpc.a -create -output libgpcUniversal.a


Now everything linked into the C++ application but calls into the library quickly crashed. Subscribed to the GNU mailing list, had GNU Pascal guru Adriaan van Os gently tell me to read the README. Oops had to initialize the Pascal runtime:

extern "C" void _p_initialize (int argc, char **argv, char **envp, int options);
extern "C" void _p_finalize ();

int main (int argc, char **argv, char **envp)
{
_p_initialize (argc, argv, envp, 0);
....
_p_finalize ();
}


It still crashed. I needed to debug in situ. Therefore I added the -g flag to my compilation above:

glenn% gpc -c -g --automake -funit-path=/Developer/Pascal/GPCPInterfaces/ MySource.p

I could now step into my source code. The Assign runtime method was crashing. I had to make the runtime debuggable, which meant compiling gpc from scratch. This is amazingly easy, just a matter of downloading the source package, putting it in a directory whose path has no spaces and commanding:

glenn% sudo ./build-on-powerpc-10-4.command


And repeat my packaging of gpc:


glenn% lipo /Developer/Pascal/gpc345u2/lib/gcc/i386-apple-darwin8/3.4.5/libgpc.a /Developer/Pascal/gpc345u2/lib/gcc/powerpc-apple-darwin8/3.4.5/libgpc.a -create -output libgpcUniversal.a


Now I could step into the runtime, where I soon figured out I had neglected to allocate a pointer or some such silliness. So now I have a working library that needs a little debugging, but is no longer stopping my transition to XCode from CodeWarrior and no longer stopping me from testing on Intel hardware.