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.

Sunday, December 25, 2005

The Ball: A Bluetooth Trackball by Chwang Yi

This is a mini-review of a piece of niche equipment: The Ball Bluetooth trackball.

I'm a trackball user. My second computer was a PowerBook 100, the slow, brittle, lightweight, brilliant, quantum leap of a computer PowerBook 100 with its large trackball, not the grape sized trackball trackball of the Duo, but the big as an owl's eyeball trackball of the 100. In the interest of space, modern PowerBooks have trackpads, which are fine and precise, but I still like trackballs.


My favored trackball, probably because I'm used to it, is the Logitech Trackman series. I'm quite adept at using a TrackMan, I can hold it in mid-air with my pinky and thumb and still scroll through a webpage with the scroll wheel, or push it against the top of my back with my hands behind my neck as I lean back and read source code. Basically, what I like about trackballs is how they free me from my desk.


And in terms of freeing me from my desk, I'd like to occasionally browse the Internet from my couch using my HDTV as a monitor. Actually, the TrackMan has a long enough USB cable I could do so, while risking tripping my wife; I want a wireless solution. Something to take advantage of the Bluetooth module in my PowerBook. And so every few months I would google "bluetooth trackball" and it would always be the same: people asking for this product and no companies creating one. And, the vaporous promise and picture of something called "The Ball" which always seemed two months from release. Company problems, you see, and no knowing if things would get straightened out and the product shipped.


And then one day, I was surfing MacSurfer and what should I come across but an AppleLink Review of "The Ball" by Chwang Yi. There was now an actual product you could order, so I did.


The Ball


The charging station is a small USB powered device, which is convenient if you have an available powered USB port, on a hub for example, and inconvenient if you don't. Just plop The Ball onto the charger and wait for the flashing blue light on the charger to go from flashing to constant.


After pairing with my PowerBook, it worked fairly reliably, easily useable from the couch. I did have to turn my mouse tracking speed down to the middle setting as the cursor movement was just too fast, and I kept overshooting my targets. Unfortunately, at this low speed it's hard to throw the cursor at the menu bar as Mac users are wont. Experience with the Trackman does not help with this device. The Trackman is a thumb wheel device, The Ball is an index or middle finger device. I can use the scroll wheel in mid-air, but little else, The Ball likes flat surfaces, so my thigh or tummy are OK, but behind my head is a bit cumbersome. And it will take a while getting used to click dragging, if I ever do. The Ball uses the Apple style zero buttons approach: you move the entire upper shell to click left or right virtual buttons.


I really like the feel of the scroll wheel solid and quiet.


The Ball goes to sleep after a few minutes, so get used to clicking it awake or you'll be wondering why the cursor won't move.

I wish The Ball had Mighty Mouse style side buttons to bring up Expose.


I've dropped The Ball several time with no ill affect. Once the ball popped out, but it popped right back in. It seems tough enough.


In conclusion, I think The Ball a decent product. If your Mac Mini is attached to a big screen TV, and your butt is attached to a couch, this might be your tool to browse the web in comfort. Just be ready to go through a few days of miss-selected menus and overshot links; as with most pointing devices, it takes some acclimating.

Update: Well I did pair it with my HDTV-attached Fedora Core 4 Linux box, at least temporarily as the pairing is lost when the trackball goes into low power mode. And it, is sort of relaxing sitting in my easy chair and browsing the Internet with just three fingers of my right hand. I did set the font size quite high, and I'm only 7 feet from my 26" screen, but it is certainly doable for the most passive mode of browsing. I'll figure out how to get a longer term pairing later.

Update 2: I've been using The Ball in my home office for general computer use: browsing the web, editing source, etc, and I've mostly gotten the hang of using it. The nicest part is the scroll wheel, very convenient for scrolling through web pages or source while leaning back in my chair. I believe the Logitech mechanism is superior in terms of accuracy and range of mouse speed; the unique dot pattern on Logitech balls gives stability, speed and accuracy, with no problem throwing the mouse at the menu bar with a sharp swipe of the thumb. You can't move the mouse cursor with The Ball both fast and accurately.

But I do like having the freedom of position The Ball gives me, and it is smaller. So, I'll keep this on my desk and be fairly happy.

Friday, November 25, 2005

Airport Extreme Base Station Fails (Bad Power Supply)

My three year old Airport Extreme Base Station stopped working last week. It was dead with no blinking lights. My first impulse was to tear it open and see if there was a loose power connector, but after getting the bottom off, I saw difficulty in disassembling it further. Luckily, it occurred to me to attach my multi-meter to the station's power supply, and eureka, no voltage. The external power supply had failed not the hub itself.

Looking around the web, it seems most places are out of of stock for the AirPort Extreme Base Station Power Adapter (Part number M9479LL). Perhaps many are failing right now. But the Apple online store has it in stock, so I ordered one for $20 and problem solved.

Wednesday, November 23, 2005

DVI and the Syntax 26" LT26HVX HDTV

I am not quite sure why HDTV manufacturers put DVI inputs in their sets if they insist on doing it in the most useless way possible, and with no particular advantage over the picture from high quality component inputs. A case in point is my Syntax LT26HVX. And I'm not saying that Syntax is any worse in this regard then any other manufacturer, a search of the AVS Forum will convince anyone that DVI is not used optimally on HDTVs, be they from Sharp, LQ, Syntax or whomever.

You would think companies would realize that there is a market out there for people who want to connect a MacMini up to their huge TV, do a little light web browsing from the couch, watch a DVD, watch their photo slideshows, maybe even hook up an EyeTV 500 and watch some recorded HDTV. These are people who are used to connecting up a DVI cable to their comptuter and have it "just work," not people who will download DisplayConfigX and play around with the horizontal back porch.

And yet, here we have a TV whose native resolution is a useless (not divisible by 8) 1366x768 pixels, and whose DVI EDID block apparently claims its resolution is 1280x768. There is no way we can blame Apple, NVidia or ATI for not working out of the box with such a device.

Anyway, I was curious as to whether I could get this monitor to work with the DVI output of my PowerBook G4 (NVidia Go5200 chipset), and so I downloaded DisplayConfigX, paid Harald his $12, and started playing around. I finally got a set of parameters which look OK, even if the picture is hiding maybe 10 pixels on the right hand edge. And I have to boot the computer first before plugging in the monitor or everybody gets confused.

So here are my DisplayConfigX settings. Use at your own risk, knowing that I don't know what these really mean. [Update: I don't think this looks very good. If you set up this monitor better, please e-mail me the improved settings.] [Update 2: I would say this looks pretty darn awful, so I'm removing these settings.]

I should also say that I have very few complaints about the LT26HVX as a TV, or as a VGA monitor with my MythTV setup (after going through all the trouble to get it just so.). Hi-Def input from either VGA or component inputs looks great. I do complain about the remote setup. I wish that all devices had a dedicated on, and a dedicated off command so my Harmony 520 infrared remote wouldn't turn it off when it was already on. And it would be nice if the TV had dedicated remote codes for each of its inputs, again so the Harmony wouldn't have to go though the fragile process of keeping track of the current input.

[Update 3: From this thread on lcd-tv-reviews, I learn that older Syntax models can be fooled into behaving sort of correctly by setting the aspect ratio menu item to 4:3. Unfortunately, the LT26HVX and other newer models do not let you change the aspect ratio of DVI content. Thus, you cannot turn off the scaler, and DVI signals from a PC will always look lousy.]

Wednesday, November 09, 2005

xorg.conf file for Dual Headed Linux With NVIDIA FX5200

I recently purchased a Syntax 26" LT26HVX HDTV for use as my main TV viewing monitor. I bought the Syntax for its good performance, low price, and good variety of input connectors. Right now I have it hooked up via VGA to my MythTV PC, s-video to my TiVo, s-video to my DVD player, co-axial to my regular analog TV, and I will be connecting a digital Comcast box to either the DVI port, or one of the component inputs.


It was troublesome, to say the least, getting the TV hooked up to my MythTV PC's video card (a Chaintech Geforce FX5200 AGPx4). First, its resolution is an odd 1366x768, which my NVIDIA driver does not like (1366 is not an even multiple of 8), and apparently the DVI connection is reporting the wrong maximum resolution, so I ended up attaching the VGA output of my video card to the TV and the DVI output to my Dell 2005FPW (1680x1050) LCD monitor; which is fine. And I ended up driving the TV at 1360x768, which is fine: I'm not going to scream about 6 pixels, and it really does look great.


Then there were the complications of getting two screens at once. And once everything was working, there was the realization that the system was not up to the task of displaying full screen video on the TV while doing anything, and I do mean anything, on the Dell. I may have to spring for a sprightlier video card. I had gotten the FX5200 because it was fanless and could handle my original single-headed system.


Regardless, it was quite a bit of work getting it to work, so I'm sharing my /etc/X11/xorg.conf file which works on my system (Fedora Core 4), and may be helpful to you. This all presupposes that you have a working NVIDIA driver installed (which is another big can of worms).


# Xorg configuration created by system-config-display

Section "ServerLayout"
Identifier "dual head configuration"
Screen 0 "Screen0" RightOf "Screen1"
Screen 1 "Screen1" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse1" "CorePointer"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules/extensions/nvidia"
ModulePath "/usr/X11R6/lib/modules/extensions"
ModulePath "/usr/X11R6/lib/modules"
FontPath "unix/:7100"
EndSection

Section "Module"
Load "dbe"
Load "extmod"
Load "fbdevhw"
Load "glx"
Load "record"
Load "freetype"
Load "type1"
Load "v4l"
Load "dri"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "IMPS/2"
Option "Device" "/dev/input/mice"
Option "ZAxisMapping" "4 5"
Option "Emulate3Buttons" "yes"
EndSection

Section "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Device" "/dev/lircm"
Option "Protocol" "IMPS/2"
Option "SendCoreEvents"
Option "Buttons" "5"
Option "ZAxisMapping" "4 5"
EndSection

Section "Modes"

# 1680x1050 @ 60 Hz
# Horizontal pixels
# Front porch: 104 Back porch: 280 Sync width: 176
# Sync polarity: - Scan rate: 65.29kHz Active pixels: 1680
# Vertical lines:
# Front porch: 3 Back porch: 30 Sync width: 6
# Sync polarity + Refresh rate 59.954Hz Active pixels: 1050
# Pixel clock: 146.25MHz
# Pixel clock digital: 119 MHz
Identifier "16:10"
Modeline "digital:1680x1050@60" 119.0 1680 1728 1760 1840 1050 1053 1059 1080 -hsync +vsync
Modeline "1680x1050@60" 154.20 1680 1712 2296 2328 1050 1071 1081 1103
ModeLine "analog:1680x1050" 146.2 1680 1960 2136 2240 1050 1080 1086 1089 -hsync +vsync
Modeline "1360x768@60" 84.50 1360 1392 1712 1744 768 783 791 807
EndSection

Section "Modes"
Identifier "HDTV"
Modeline "1360x768@60" 84.50 1360 1392 1712 1744 768 783 791 807
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "Dell"
ModelName "DELL 2005FPW"
UseModes "16:10"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 75.0
Option "dpms"
Option "XVideoBlitterSyncToVBlank" "0"
Option "XVideoTextureSyncToVBlank" "0"
EndSection

Section "Monitor"
Identifier "Monitor1"
VendorName "Syntax"
ModelName "Olevia 26 HVX"
UseModes "HDTV"
HorizSync 30.0 - 83.0
VertRefresh 56.0 - 75.0
Option "dpms"
Option "XVideoBlitterSyncToVBlank" "0"
Option "XVideoTextureSyncToVBlank" "0"

EndSection

Section "Device"
Identifier "Videocard0"
Driver "nvidia"
Option "ConnectedMonitor" "DLP"
VendorName "Videocard vendor"
Option "ExactModeTimingsDVI" "True"
BoardName "NVIDIA GeForce FX (generic)"
BusID "PCI:1:0:0"
Option "ConnectedMonitor" "DFP, CRT"
Option "IgnoreEDID" "1"
Screen 0
EndSection

Section "Device"
Identifier "Videocard1"
Driver "nvidia"
VendorName "Videocard vendor"
BusID "PCI:1:0:0"
Option "ConnectedMonitor" "DFP, CRT"
BoardName "NVIDIA GeForce FX (generic)"
Option "ConnectedMonitor" "CRT"
Option "IgnoreEDID" "1"
Screen 1
EndSection


Section "Screen"
Identifier "Screen1"
Device "Videocard1"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 16
Modes "digital:1680x1050@60" "1280x768" "800x600" "640x480"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 24
Modes "digital:1680x1050@60" "1280x768" "1024x768" "800x600" "640x480"
EndSubSection
EndSection

Section "Screen"
Identifier "Screen0"
Device "Videocard0"
Monitor "Monitor1"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 16
Modes "1360x768@60" "800x600" "640x480"
EndSubSection
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1360x768@60" "1024x768" "800x600" "640x480"
EndSubSection
EndSection

Section "DRI"
Group 0
Mode 0666
EndSection

Wednesday, October 19, 2005

Remote MythFrontend for Mac OS X

I have a policy of reporting on my blog the result of any research which took me some serious yahooing to discover. Here's one such entry.


On a whim, I tried the Myth Frontend for Mac OS X, and of course there was trouble from the start connecting to the backend running on my Linux Fedora Core 4 desktop machine.

First, you have to have mysql setup to allow remote usage. If you followed the Wilson Myth(TV)ology instructions, it will be almost there, but you have to give access to the other machines on your local network (which in my case has the assigned IP address pattern of 192.168.0.x, where x is between 1 and 15; your's might be different. So on the Linux box, you have to do the following:


$mysql -u root mythconverg -p

(enter password)



mysql>grant all on mythconverg.* to mythtv@"192.168.0.%" identified by "yourpassword";

mysql>flush privileges;

mysql>exit



Then you have to make sure the firewall allows the three ports you need for this job. So again on Linux (KDE) open up the Security Level control panel from the System Settings menu, and add the following to the "Other ports" field:


mysql:tcp, 6543:tcp, 6544:tcp



Then I was able to run the mythfrontend for Mac OS X and discover my 1.33GHz Powerbook G4 is not up to the task of displaying the stream, it's worse than the EyeTV performance, which is actually viewable on the same hardware.


Oh, how I am looking forward to Intel based Mac Minis. I've got a little space here next to the monitor just for one.

Sunday, October 09, 2005

The Intel Transition

I spent Thursday and Friday at a workshop Apple put on to help developers transition their code onto Mac OS X for Intel. I won't get into the technical aspects of the workshop, as that was labled as confidential (although I have no idea why), but I would like to say that the Apple employees were great. They are comitted to the success of the transition, and know it is important to have plenty of native software available at first hardware launch. They were helpful, and never condescending in the face of ignorance. If you are a Mac developer, and get offered a chance to go to one of these events, go. It's a rare and immensely valuable experience.

Also, DTS engineers have some interesting side jobs.

Saturday, October 01, 2005

could not get file information for /dev/lirc

I ended up ruining my Mythtv setup and reinstalling from scratch. The Wilson Myth(TV)ology instructions have moved on to using Fedora Core 4. Frustration was around every corner, as little things were missing. For example, it wasn't mentioned that you had to download and install the firmware for the pcHDTV capture board.

But the longest running problem was getting my ATI Remote Wonder working again. The OS recognized the existence of the USB receiver, and it worked as a mouse, but everytime I tried running irw, irw would immediately quit, and in the process lockup the lircd daemon. If I looked in the log files, I would see the warning "could not get file information for /dev/lirc" and true enough, the only device for the lirc framework was the /dev/lircd interface, no lirc or lirc0 nodes as every online tutorial said there would be after the install.

I did a lot of googling, and finally found this posting on the MythTV website. Basically, it said, I couldn't use both the module which gave me mouse functionality (ati_remote), and the module which allowed lirc to read from the device (lirc_atiusb). Sure enough

#/sbin/lsmod

said that both modules were loaded. I had to disable the ati_remote module, so I first found it:

#locate ati_remote
#/lib/modules/2.6.12-1.1447_FC4/kernel/drivers/usb/input/ati_remote.ko

So, I went in and changed the name of the ati_remote.ko kernel extension to ati_remote_disabled, rebooted, and all of a sudden lirc could see the Remote Wonder.

Wednesday, September 14, 2005

Image Tricks - Free & Fun

This morning, I downloaded a cool application by BeLight Software called Image Tricks which leverages Cocoa and Core Image.

The Kaleidoscope effect amused me, and I used Snapz Pro to capture a movie while playing with the kaleidoscope count parameter.


Sunday, September 11, 2005

My ATI Remote Wonder Stopped Working

Just a quick note about a problem I had (and have partially fixed) with the ATI Remote Wonder I bought to control my MythTV using Fedora Core 3. I had initially installed it a couple weeks ago, and it worked as a mouse, and would send recognizable keystrokes to the irw utility, and I could create a .xmodmaprc to map the buttons to special keystrokes in the mythfronted application.

Then I rebooted and it stopped working entirely. No mouse. No keystrokes. No controlling MythTV.

I did a lot of web searching, and tried a lot of things. Then I found some mention of using the irrecord utility to create my own lircd.conf file. I already had such a file, which I downloaded from somewhere, but at least with irrecord, I can see if the device was doing anything at all. So:

#irrecord lircd_temp.conf

After going through the irrecord wizard, I compared the generated file with the one I had downloaded, I found that 1) the "gap" value was different, and 2) that all the key codes were off by one in the most significant hex digit, such that the OK button, for instance, was 0xF31E instead of 0xE31E. I edited my original /etc/lircd.conf file to use the appropriate gap, and updated key codes, and after restarting the lircd daemon, the remote started working with my ~/.mythtv/lircrc mapping file to allow me to control mythtv.

I still don't get mouse motion, mouse buttons or keystrokes out of the remote. So I assume there is some other configuration file somewhere which has the wrong key codes in it.

And I don't know why the codes changed, or whether they will do so again in the future, but I thought I'd let the universe know what I discovered.

Saturday, August 27, 2005

PVC Furniture

I'm enthusiastic about Make Magazine. It's always an interesting and inspiring read.

For example, a few weeks ago on the Make blog, there was mention of using PVC tubing to make furniture. As it happens, my mother-in-law had been pestering me for a small chair, of very specific dimensions, so she could sit and wash my son, or clean vegetables near the floor. Local stores had no chairs of the proper dimensions or stability for an adult, and in an off moment I told her I'd build her one. How I planned to do this was unclear, as I have no wood shaping tools. Thank goodness, I came across the blog entry, as I was able to make a seat to the precise dimensions my mother-in-law required.

PVC Stool

PVC pipe is fairly cheap: $0.50 per foot of 1¼" diameter tubing. It's the joints which add up; I paid $2.20 per joint at the "PVC Store" display at the hardware store, but I'm sure I could have gotten a much better price. I sawed each segment roughly (no precision required) and fit everything together by hand. Then I attached a surplus shelf from a DVD rack as a seat.

Presto, one made to order, sturdy, unique miniature chair. Thanks, Make Magazine.

Wednesday, August 24, 2005

MythTV - A User's Impression

After 3 weeks of weekends, I have a fairly functional MythTV box running. I jumped hurdle after hurdle: ungainly audio support, package managers, the pickiness of gcc 4.0, lack of support for Fedora Core 4, weak broadcast strength, out of spec cable data streams, uncooperative Comcast, odd video defects, and unwanted clipping. And now, I can watch and record beautiful high definition television, with crystal clear digital sound, all added at a cost of perhaps $275 to my existing desktop system.

I'm in a position to give informed opinions.

My time is not valueless; I want a working system. I appreciate the educational value of learning the ins and outs of Linux audio mixing, mysql database maintenance, parameters to chmod, but the amount of effort I was looking for was around the level of: insert tuner card, attach cables, insert CD, type in ZIP code, watch TV; not install Linux twice, scour the web for the contents of a .asoundrc file for a Chaintech AV710 sound card, spend two hours trying to figure out why the scan channels button is disabled, etc. Basically, all I want to do is watch some TV. I've a TiVo. It's based on Linux and similar to MythTV (minus the Hi-Def); it just works. My son will be using it before he's three. MythTV has to get to that point before I like it.

I have an El Gato EyeTV 500 HDTV tuner box for my Mac. It just works, or it would work if my computer was up to the task of decoding 1080i signals. It auto-tuned all my channels and displays them without distortion: even PBS-HD. It's text overlay is flicker free and beautiful. It's a Mac product, and acts as Mac users expect. When a channel is unavailable, it displays "No Signal"; it doesn't lockup for 20 seconds and not allow me to change channels.

From a commercial developer's point of view, I think there is a lot right and a lot wrong with the whole MythTV project. It is immature to waste time on such features as theme's. Choose an appearance, optimize the heck out of it, and live with it. Do not waste a minute of precious development time working out some lame bitmapped based system of pluginable skins. Figure out the core needs of the product, and focus on those. For instance, getting the auto-tuner to handle out of spec QAM streams. Also, what's the deal with having separate modes for watching live TV, and watching recordings? If I want to watch something being recorded right now, I shouldn't have to go one level up and three levels down from the live TV panel. Or how am I supposed to change the channel if something is wrong with the default channel? Do you really mean, I have to quit the frontend, quit the backend, and re-run the setup application because my default station isn't broadcasting? Watching TV is the core functionality of the application, get that right first.

To be fair, it is free. The images and sound, when they work at all, are fantastic. Once you do have it setup it's serviceable. If you are a cheap techno-geek with time on his hands, it's a gratifying project.

Thursday, August 11, 2005

NVidia versus 2005FPW in MythTV

I've been consumed the last few weeks with trying to get a working HD PVR working in my Dell desktop. I haven't been posting on this subject, because I think it's pretty well covered elsewhere on the web, and I am too confused much of the time to give coherent advise to anyone. However, I came across a problem which others might be beating themselves up on.

My PVR is composed of a Dell Dimension with a 2 GHz Pentium 4, a pcHDTV-3000 tuner card, an NVidia GeForce FX 5200 video card, and a Chaintech AV710 audio card. I'm using DVI to output to my desktop monitor, a Dell 20" widescreen 2005FPW with a native resolution of 1680x1050. I'm using Fedora Core 3 Linux (Core 4 is out but not well supported by all the other things you want to install, believe me, I've tried). I've installed NVidia's native Linux drivers.

Anyway, the unusual problem is whenever I want to display HD content from my local PBS HD station, which I think is in the 1080i format, it is distorted in a funny way. Every centimeter or so, there is a a wavelike distortion, like someone dragged their fingers through cake frosting. It's horrible.

I did some Yahoo searching. By the way, Yahoo is much more likely to find all the web pages you are interested in than Google. And it turns out someone else was having the exact same problem, and he had tracked it down to the 1680x1050 resolution that MythTV was trying to display content at. Practically any other resolution would be fine, but not 1680x1050. If I go into the MythTV setup, and I tell the GUI to use 1648x1050 with a 16 pixel X inset, it will play without distortion and look beautiful, although there will be these 16 pixel bands on either side of the MythTV where the Linux desktop shows through. I believe the problem must lie with the drivers, something with how they handle de-interlacing and scaling.

I'm still not finished. The audio over SPDIF from the AV710 card stutters horribly, and is not in the proper format for my receiver. It looks like the player is having to slow itself down to try to convert the audio, so everything is in slow motion. I thought the audio was in AC3 format, so it shouldn't convert at all. So I've been up to my ears in .asoundrc files, and getting alsamixer just so, I'm sure I will try this and that, and think of new searches and someday it will just work, and I'll be able to watch some live TV, and it will be very satisfying, but until then it's pure frustration.

Update: I can get full 1680x1050 video display if I use the VGA connector instead of the DVI. I don't know how much quality is lost when using the analog connector, especially with possibly annoying flicker.

Tuesday, July 26, 2005

"Why is the fan so loud on my PowerBook?"

I asked myself that a few seconds ago. I'm in bed. My 12" Powerbook is on my chest, and the fan is on full blast. Which means its running hot. Which means it's doing something processor intensive. But what could that be? I'm just browsing the web. I'm not even listening to iTunes. There is no reason for this.

Luckily, as a developer, I've installed Apple's free development tools. (If you bought Mac OS X, they are on the separate CD) and I can run the "top" utility. So I launch the "Terminal" application, and type in:

top -o cpu

And what do I see, but that Sherlock is using up half my CPU doing nothing but pausing a movie trailer:

[Lefler:/System/Library/Extensions] glenn% top -o cpu

Processes: 79 total, 6 running, 73 sleeping... 280 threads 07:52:47
Load Avg: 1.81, 0.89, 1.07 CPU usage: 62.7% user, 37.3% sys, 0.0% idle
SharedLibs: num = 238, resident = 42.7M code, 4.61M data, 4.86M LinkEdit
MemRegions: num = 15609, resident = 457M + 12.0M private, 138M shared
PhysMem: 132M wired, 416M active, 318M inactive, 867M used, 285M free
VM: 7.38G + 151M 410626(15) pageins, 308443(0) pageouts

PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE
2637 Sherlock 41.4% 0:21.33 14 235 336 15.3M+ 17.5M 25.4M+
782 DashboardC 11.8% 4:20.41 4 105 210 5.97M+ 7.52M 12.1M+


What would a typical user do in this situation? How would they know which of dozens of applications is killing the performance of their expensive toy? I know enough to feel the symptoms and run top, but what would someone else do? It might not even be an application taking up all the cycles. The installer for my HP printer installs a background process which occasionally goes crazy and uses 60% of my cycles. It's inconceivable that the typical user would know how to make their computer speedy again. They would just have a poor experience with Mac OS X.

And what is wrong with Sherlock that it can't idle a QuickTime movie properly? QuickTime does all the work for you these days making efficient use of idle time. It's not like the old days when you set your sleep time to zero and gave QuickTime idle time every pass through your WaitNextEvent loop. QuickTime can now register its own Carbon Event timer. It's very nice. It practically writes itself.

[Update: The "Activity Monitor" application under Applications/Utilities is a more user friendly, and informative, way to find out what application is soaking up cycles.]

Saturday, July 16, 2005

Remote Desktop Setup

Another how-to posting.

Out of frustration with Windows and Wintel notebooks, my brother Joe bought an iBook. Unfortunately, he still needed a few pieces of critical Windows software, thus Virtual PC, thus Window's style kludge and instability ruining his otherwise decent Mac OS X experience. He's very close to giving up and getting another real Wintel notebook, but we are experimenting with the other way to add Windows functionality to a Mac: Microsoft Remote Desktop. As long as you have an IP connection, you can keep a cheap desktop PC anywhere in the world to run Windows software natively, without destabilizing your Mac.

Things Needed:

  • A PC running Windows XP Professional. Microsoft does not give this to XP Home users.

  • A router capable of both port mapping and Dynamic DNS.

I purchased a used Netgear RT314 router from a merchant on Amazon for $27 shipped. This is an older router, and quite big, but when updated to the 3.25 firmware version does everything I want.
Netgear RT314
I created a free account at www.dyndns.com and created a host name named yoursite.homeip.net (not the actual name).

I hooked up my network in the following topology, turned off DNS serving in my Airport Extreme hub, and relied on the RT314 to handle DNS.

Topology
I logged into the router through the web interface, and configured it for Dynamic DNS using my new account.
Dynamic DNS RT314Now the DynDNS servers will know the IP address Comcast has given my router, and the yoursite.homeip.net address maps to that IP address.

But of course, I don't usually want to talk with my router, I want to log into my PC using Remote Desktop. So I have to configure the router to route port 3389 traffic to my PC. So I configure that page under "Advanced" options on the router.
Port Mapping RT314
But what IP address, should I forward it to? My PC has a local IP address that the router assigned it, but the next time I turn it on, it might get another. I need to force the PC to always have the same IP address, so I have to configure my PC.

First, find my active network connection.

Second, click on the "Properties" button of Connection Status dialog.

Third, select the Internet Protocol (TCP/IP) item of the Local Area Connection dialog and hit the "Properties" button.

Fourth, enter an IP address high in the range of local addresses will distribute, as there are only 6 networked devices in my home, and the range starts at 192.168.0.1, I went with 192.168.0.15. My router (192.168.0.1) is also the default gateway and in charge of getting DNS information.

Make sure this fixed IP address is the one in your router's port mapping page.

If all went well, you will now be able to run the Remote Desktop Connection software and log into your PC from around the world, just by typing the yoursite.homeip.net address (or whatever you chose). There is, of course a version of Remote Desktop Connection for Windows, and it's installed by default on all XP boxes.

Anywhere in the world, but your own home, however, as you have to be upstream of your router in order to have this work. (Inside your home, you can use the 192.168.0.15 address). Or your ISP might filter port 3389, or any number of things could go wrong, but if your PC is running XP Professional, it's pretty cheap to try, especially if you have mission critical software to run which doesn't require lightning fast screen redraws.

If you have a .Mac account, you can even use the iDisk Utility for Windows XP to provide a shared disk to ease transferring files from the remoted XP box to your Mac. Just drag a file onto the iDisk from the PC and drag it off onto your Mac.



Of course, having done this, I noticed a security advisory against Remote Desktop. So opening up that port in the router and enabling Remote Desktop access might be dangerous, especially given my brother's typical luck with computers.

Saturday, July 09, 2005

Adding Auxiliary Inputs for my iPod in my Civic

This doesn't have anything to do with programming, but it might be of use to Googlers.

I have a 2003 Honda Civic 4 door sedan, with a 5 speed manual transmission. It would be agreeable to listen to my iPod while commuting, or allow my wife to listen to movies playing on my PowerBook, through the built in speakers of the car. Of course, the factory original stereo has no auxiliary inputs, and I'd rather not tear out a perfectly good stereo to put in some ugly after market monstrosity. So a googling, I did go.

Logjam Electronics carries a variety of converter boxes which fool OEM stereo's into thinking they have trunk CD Changers, while in fact, they have auxiliary inputs. So I ordered a Blitzsafe for my Civic. Other manufacturers were available, but this one seems to have a good following, and doesn't have the ground loop noise problem (when charging the iPod) for which other units are known.



The Blitzsafe comes with female RCA jacks, and most people use converter cabling to add a ⅛th inch mini-jack to their dashboard, but I felt it would be more flexible to put a pair of RCA jacks on my console, and converting to mini-jacks in the cable from the console to my iPod or Powerbook. I went to Radio Shack and found a wall plate with 3 RCA jacks, the jacks themselves were female/female connectors and came threaded and with nuts. I'd just have to drill some holes, and use a male/male cable (of which I have many).



I was concerned with stability, so I decided to put a metal strip on the other side of the console to give support whilst pushing cables onto the connector. I took a PCI slot blank out of my Dell and chopped it to give a metal strip (perhaps 1¼ inches long) I drilled two ⅜th holes for the RCA jacks, and one 11/64th hole for a small bolt. I wish I had a drill press, as I managed to cut up my left index finger a bit when I spun the metal, and I found my cordless drill wasn't really up to the task, so I ended up reaming out the larger holes with a flat headed screw driver. But i did get my little bracket. I didn't take a photo, but it looked something like the following, the holes were just separated enough that I could get the nuts in without overlap if they were twisted just so.




Next, I had to figure out how to get to my stereo. Cheap Honda Parts has a variety of installation manuals, and I chose the one for installing a keyless entry system. At that time, I decided to kill two birds with one stone, and I ordered a keyless entry system to install at the same time.

Unfortunately, as I have a manual transmission, the instructions were not quite accurate. For instance, it said to remove the ring around the leather of my stick shift while that was not necessary, and I ended up breaking (a thankfully invisible) area around a hidden screw. I should have known, the ring in the diagram was a round rectangle, while the ring in my car is an oval. But I was able to pop the assembly off, get into the area below the stereo, reach up and find the connector socket and plug the Blitzsafe into place. Then it was a simple matter of taking the lower console into the house and drilling out the 3 holes (2xRCA jacks and 1 bolt hole) to mount my little metal bracket. Thankfully, it looks pretty slick.





I mounted the jacks to the right of the cigarette lighter jack, as I wanted some chance of not blocking the passenger cup holder, and also because the flip top of the lighter jack would have blocked mounting it below.

I also installed the keyless entry system, and that was pretty much according to the instructions, except it was pretty hard finding the loose connector with "the blue tape." But digging around inside the console found it hiding amongst some other cables. Also, the keyless module would not click into place in it's tab..

Oh, and it works great. My iPod is on a long enough cable that my wife can use it in the back seat.

I'll be listening to podcasts on my way to work for sure.