Go me

July 17th 2008

So I just returned from a trip to Washington, D.C.

The trip was the culmination of about 8 weeks of study for the series of exam and interviews required to graduate the Navy Prospective Nuclear Engineer Officer (PNEO) curriculum. You basically take all the stuff that you already know about the plant from having operated on it, and then go and really dig into how everything really works. It’s not good enough to know that a procedure tells you to do something in the event of a casualty. You have to know why the procedure is written that way (i.e. what do these steps prevent, what could go wrong if you don’t do the procedure right?). It’s not always about operations either, almost more important is learning about the various maintenance responsibilities that way when you’re the guy actually responsible for supervising the entire department’s maintenance schedule you’ll understand what’s coming across your desk.

After passing a comprehensive written exam a student is sent to Washington D.C. to interview with the smart guys at Naval Reactors to judge your worthiness to be the Engineer Officer. If you also pass that screening then you’re done, if not you get to try again (up to a finite number of times).

It sounds demanding (and it is) but most people put in the time and effort required to make it so most people generally pass, even if it takes a second attempt. But it’s nice to have it knocked out of the way early, especially since in my case my command had to get a waiver approved for me to go earlier than normal. Had I not qualified we would only have 1 Engineer-qualified division officer on the boat which we try to avoid. :)

Posted by mpyne under Navy & Personal | 1 Comment »

kdesvn-build 1.6.2

July 11th 2008

kdesvn-build 1.6.1 had some issues in the sample configuration regarding the build order of phonon and kdesupport so I’ve taken that fix and a few others and have released kdesvn-build 1.6.2. It’s also the first kdesvn-build that I’ve digitally signed. I’ve had a GPG key for awhile now but I’ve not put the effort into signing the code because it didn’t seem necessary. Someday I’ll actually get to go to Akademy and thereby get my key signed but until then at least there’s a bit more trust you can associate with the code.

As far as future directions for kdesvn-build, what I’m working on now is code to allow kdesvn-build to have a persistent data store. This will be initially to support wish 157992, to avoid the bother of running make/make install if no source update occurred. I envision keeping track of the last time a module was successfully built and installed for each module and using that to implement the feature.

But is there any other bit of data that would be useful to retain about modules and what gets built? Note that I’m referring to things that are not easily looked up after the fact. The revision on disk, for instance, is easily queried.

One other kdesvn-build nit is that the program currently will automatically approve the KDE SVN SSL signature for those using https:// since otherwise the program may freeze forever waiting for a user confirmation which the user can’t see (normally output is logged and not sent to tty). I don’t really like the idea of doing that but the alternatives are to have the user cache the authorization for the KDE SSL server instead of kdesvn-build or to configure Subversion not to prompt for KDE’s SSL certificate (either by local configuration or by KDE somehow obtaining a cert that OpenSSL can trust by default). Either way is work I’d rather avoid putting the user through. Thoughts/suggestions are appreciated.

One last thing, kdesvn-build will require at least Perl 5.8 in the future (and may already as I have no 5.6 to test against). In addition if anyone wants to look at the documentation and give me recommendations for improvement (or better yet, patches ;) I’d appreciate it.

Posted by mpyne under KDE & Programming & kdesvn-build | No Comments »

Gamers today

July 3rd 2008

I was reading news on some video gaming sites today, and these sites typically have places for their readers to leave comments.

So I was going through the comments and one thing that strikes me is how offended some people are at the success of Nintendo, as if it was an affront to all that is holy for people to buy more copies of Wii Fit than Metal Gear Solid 4.

I am completely confused by this line of reasoning, and probably more confused as to why some people are so bitter. I could almost understand it 6 years ago when it was 3 video game systems competing for basically the same audience. Nintendo wisely decided that they weren’t going to out-muscle Sony and Microsoft and re-tooled their product line to where they thought the money was… and succeeded, probably far above their highest expectations. But that hasn’t killed Sony or Microsoft, they are still tending to that market. The Wii itself isn’t useless for a hardcore gamer but there’s a large list of titles for Wii that many “gamers” would never play.

The reason for the success of Nintendo is obvious (to me) in retrospect: They appeal directly to those with the money. Parents and older adults have more money than teenagers and young adults. So when Nintendo found a way to deliver a product that was enjoyable but the older age group they were practically guaranteed success, the only question is whether they completely get rid of their younger audience or not. I think as long as you drop pre-conceptions and allow yourself to play a game because it is fun and not just because it’s flashy that you’ll find stuff to like on the Wii no matter what your age.

In my case, ever since I was old enough to buy my own hardware and software I had at least whatever Nintendo was offering (I later picked up a PS2 as well). When I didn’t have money to buy games I noticed that Nintendo’s software (for the NES, SNES, and N64) was almost uniformly fun. Even though the characters for the major franchises (Mario, Zelda, Metroid) would be re-used from game to game, the game itself was generally much different, which avoided the feeling of playing a rehash.

So when Wii came out I picked it up, along with Zelda: Twilight Princess. And then… not much. But that was OK, I still had quite the GameCube backlog to finish. But then I noticed something weird. Although I had always encouraged my wife to play video games, there weren’t many she liked (although she could probably utterly destroy 2/3rds of you in Super Mario Bros.). But when I returned home on the patrol after we bought the Wii she had a couple of games for it… and didn’t want me to take the Wii underway when I left again. :)

Now she plays the Wii more than I do. And perhaps more to the point, I don’t have the time now to play games like I could before even if I wanted. The GameCube backlog is still valid, and now I can throw on all the Wii games I have. In fact, the last period of time I had for playing video games was probably when I was in high school with my parents buying video games for Christmas. But now those same parents are able to buy games for themselves that they actually enjoy with the Wii, and they are not ungodly expensive either.

So even though I only have a few “gamer’s game” titles on Wii it’s already more than enough. I’ve got Guitar Hero III, Super Smash Bros. Brawl, Rock Band (sort of; more on that later), Super Mario Galaxy, Metroid Prime 3, Twilight Princess, and Mario Kart Wii. I don’t even have time to play through all of these like I want to. So even though there’s probably some XBox 360 or PS3 games I’d enjoy there’s no reason for me to spend money on these systems, as I don’t have time to play the games I own.

But instead of people criticizing Wii by saying that people pick it up just to play Wii Sports for two hours and forget about it, which the sales numbers prove wrong (not to mention Nintendo Channel results), I wish people would congratulate Nintendo for opening up a new gaming market. These kids are insulted that they’re grandparents are able to play Wii Bowling, I’m happy that more people find it fun to play at all.

Posted by mpyne under KDE | No Comments »

kdesvn-build 1.6.1

June 28th 2008

kdesvn-build 1.6.1 has been released. It’s basically a compilation of bugfixes but it also makes it easier to build Phonon 4.2 instead of Qt’s or kdesupport’s Phonon as well.

Posted by mpyne under KDE & Personal & kdesvn-build | No Comments »

It’s the end of the world as we know it?

June 23rd 2008

On Slashdot (don’t run!), there is an article about whether or not a particle accelerator being built called the Large Hadron Collider (LHC) could actually generate particles that “might destroy the world”.

I thought the very notion sounded stupid on its face, but had no non-intuitive way to explain way. But someone went and made a more logical argument based on the fact that the Earth is being constantly bombarded by much more powerful streams of energy constantly (called cosmic rays). I’d known about cosmic rays since in theory they can show up on our radiation detectors, and indeed you could tell if we were submerged or surfaced based just on the radiacs in the engine room thanks to the shielding provided by the ocean.

The more powerful cosmic rays are many, many times more powerful than anything the LHC would be able to produce, and since no particles have been created in the upper atmosphere that went and “destroyed the world” in the millions of years the planet has been around, seems like an open-and-shut case to conclude that the LHC wouldn’t be able to do any worse.

But ARGH, lots of the commenters on Slashdot seem to have some kind of logical disconnect. One guy says that LHC is still dangerous because it has “multiple high-energy” particles, as if cosmic rays were single-threaded or something and the atmosphere only every has had one cosmic ray at a time?? Apparently this is also “the most important experiment in human history”. Whiskey. Tango. Foxtrot, over. Some other armchair expert in particle physics has decided that the difference between LHC and cosmic rays is that cosmic rays and the particle produced from their collisions travel faster and therefore this is somehow waaaaay different from LHC. But collisions is not the concern as any kind of collision or series of collisions that could destroy the Earth would require much much more energy than LHC could deliver based just on conservation of energy and momentum. If he’s worried about black hole production, then that’s something that would have already happened by now if it were a valid physical mode of interaction.

Luckily the article does have a lot of insightful comments overall, including some of the variety “well if a black hole *could* do us in, here’s how it would happen”.

Posted by mpyne under Personal | 1 Comment »

Improved crossfadiness

June 16th 2008

So I’ve made a few more changes to the crossfading code in JuK. This should hopefully fix crossfading issues completely for people. However, life is weird sometimes. phonon-gst went from being completely unusable (it would crash with JuK) to being the best option right now (perfect crossfading, at least here). phonon-xine, due to the way crossfading is now implemented sounds slightly crackly sometimes while playing music back. Even with the new crossfading routine, incoming music starts out at a high volume before fading in, although it does sound smoother.

Basically what used to happen is that JuK would pipe the music directly from the file to the Audio Output object. Phonon allows you to insert effects into that audio path, which is how crossfading works. You simply start playing the next song with a fader effect, set to fade in, and at the same time insert a fader effect into your currently playing stream set to fade out. Unfortunately phonon-gst has issues with removing effects from an audio path it looks like, which is why I was getting crashes. Even when I fixed the crashes by simply leaking the object as an experiment, the crossfading was horrid under phonon-gst as it takes seemingly forever to setup the fader and insert it into the audio path.

So what I’ve done is to simply insert the fader effect into the path from the start, and simply tell it to fade at the right time. Presto! Except that doing this seems to cause artifacts with phonon-xine output sometimes… *sigh*. But for now now it looks like phonon-gst has gone from unsupported to the best option for JuK at this point, hopefully all the backends will work equally well by KDE 4.1 though.

In other news, kdesvn-build in /trunk will allow you to build the Phonon pseudo-module. I say pseudo because there is no phonon module. It is developed in kdesupport. However I’ve been informed that the correct place for most users to build phonon from would be /branches/phonon/4.2. kdesvn-build has a couple of hacks that would support pulling it from the right location but still wouldn’t be able to build it due to the module layout. So I’ve added a bit of special support for it. I also changed the sample rc file to show how to build Phonon 4.2. If it’s important enough I’ll go ahead and make a 1.6.1 release.

Is there anyone looking forward to C++0x more than I am right now? :) The linked Wikipedia page has tons of changes, some which worry me a bit due to syntax (for example, lambda functions). Then again, I’ve never seen a good syntax for lambda functions, although I’m sure it’s just me.

But things like an auto keyword to allow for automatic type deduction? Very nice. For example, instead of doing:

for ( QList<QWidget *>::ConstIterator it = list.begin(); it != list.end(); ++it() ) {
  // use *it
}

you could do:

for ( auto it = list.constBegin(); it != list.constEnd(); ++it ) {
  // use *it
}

I did have to change begin/end to constBegin/constEnd to make sure that the non-detaching forms of the iterator are used, but this may be something that g++ is able to deduce as well someday.

Probably the biggest other feature I’m looking forward to is the “rvalue references”, which will allow for constructors that “move” data instead of having to copy them over. Qt has kind of mitigated the problem somewhat in their shared classes but you can benefit from this even in non-Qt-using code. There’s many other improvements too, I just wonder how long they’ll take to get into a g++ which we can use for KDE development. :)

Posted by mpyne under C++ & KDE | 2 Comments »

Hey, check it out

June 13th 2008

Apparently someone has decided that the best use of their advertising money would be to purchase ads on the term “KDE”. Ads that have nothing to do with KDE, but everything to do with programming with Gtk/WebKit…

Now obviously this was likely not paid for by the GNOME foundation or even anyone associated with the GNOME project as they’re all around a good crowd in my experience. But I’d be interested in knowing who is doing this, as it is very poor form.

This kind of thing has happened before apparently, before my time. There was an article on Linux.com. And Kurt Granroth, who was one of the people who noticed the first time still has his page about it up.

Update 02:34: Not as soon as I’ve posted it, and it disappears on me. I don’t know if it was taken down, expired, too many people clicked on it, or if Google rotates ad words or something. But I’m still intrigued…

Posted by mpyne under KDE | 1 Comment »

Programming tips

June 3rd 2008

So I finally fixed a bug which has been causing some people a bit of grief, bug 160284. This bug involves crashes due to a couple of different things:

  1. A memory address was casted to a larger sized type, which was not aligned properly for that size.
  2. In addition, there were issues handling memory which was mapped from a file using mmap(2).

What’s the deal with alignment you ask? It deals with computer architecture. Pretty much every major computer architecture I can think of requires memory accesses of a datatype of a certain size to be on a memory address that is a multiple of the datatype’s size. For instance, if you were trying to read a 32-bit integer, the CPU would expect a memory address to be divisible by 4, since the integer takes up 4 bytes in memory.

Note that this is a glossing-over. Just because a datatype is 4 bytes long doesn’t mean that as long as your memory address is divisible by 4 that it’s good. An architecture could require all memory access to happen on 8 or 16 byte boundaries for instance. In addition, the predominant architecture, x86, for the most part does not have these restrictions. Certain instructions do require aligned memory however, and unaligned memory access is slower even when it’s allowed.

The reason you never hear about this is that the compiler knows about the alignment restrictions for the architecture it’s building for, and takes care of it for you. Unless you try and go around it…

In our case, we had code to read in a file by mmap-ing it. The first 17 or so bytes were read to ensure that the file we were reading in is correct. Then the very next 4 bytes were cast to a 32-bit integer for a version check. This access is unaligned, but works for most systems since x86 does not crash, but instead is merely slower.

The solution is to add padding between the 17-byte magic string and the version integer. There are two obvious ways of doing that:

  1. Do it yourself. Calculate the next memory address that the CPU expects an integer access to fall on and insert padding until you get there. Unfortunately there is no easy way to determine alignment restrictions at build or run time that I can see.
  2. Let the compiler do it for you. What you need to do is make your header data a struct or class. By default each member will be correctly aligned, and better yet if you simply read and write a header at a time you won’t need to do tricky pointer arithmetic. The hard part is ensuring that the struct / class contains the character data and not merely a character pointer.

What I used in my fix was something like this:

static const char KPC_MAGIC[] = “KDE PIXMAP CACHE DEUX”;
struct KPixmapCacheDataHeader
{
    KPixmapCacheDataHeader() :
        cacheVersion(0),
        size(sizeof(*this))
    {
        magic[0] = ‘\0′; // In case of inadvertent strcpy or something.
    }

    // -1 from sizeof so we don’t write out the trailing null.
    char    magic[sizeof(KPC_MAGIC) - 1];
    quint32 cacheVersion;
    quint32 size;
};

Other fun programming tips:

  • Dealing with endianness conversions? Don’t reimplement it yourself! Qt includes template functions to do it for you in QtGlobal.
  • Want to know the alignment of a datatype at compile time? Tom Lokovic has an interesting C++ solution.
  • Are you using QDataStream? Please make sure that unless your data types are the C++ basic types (i.e. basically the Qt integer types) that you are explicitly setting a binary version on your QDataStream and sticking with it. This is all described in QDataStream’s documentation. I’ve fallen afoul of this before which broke JuK in KDE 4.0 where you couldn’t load KDE 3.5 data, and I’ve seen a lot of non-trivial uses of QDataStream without setting the version. If you don’t set a version then Qt will pick one for you, and it’s likely to change without notice. It’s up to you to do it, Qt doesn’t/can’t encode QDataStream version info into the stream.
  • Although I wasn’t required to go this route, if you want to create a C++ object in shared memory (like a QMutex for shared mutual exclusion) then placement new might be for you. With placement new you handle allocating the memory, all new does is create the object where you tell it to. Of course, you’ll have to manually destruct the object too…
  • The corollary to the compiler handling alignment of structs is that if you make a struct intended to reflect a file header, you may have to tell the compiler to keep the struct “packed”. The flag to do so is implementation dependent however. Your program won’t crash if you do this as the compiler will insert code to fix up unaligned references as necessary. So if you were wondering why the sizeof a struct is different than what you expect, it could be due to alignment.

BTW, if you were annoyed at JuK’s track announcement popup going weird places, it’s fixed now.

Posted by mpyne under C++ & KDE & Programming & Tutorial | 6 Comments »

$200 computers

May 25th 2008

So, I went down to visit my sister the other day. When I called to ask if they were going to be there they informed me that it was a good thing I called. Her grandmother had been using an old computer for her to use for school and email, which crapped the bucket.

Grandma goes to the store to see about replacing the computer with something inexpensive. Really inexpensive. Cheapest thing you’ve got that can check email and browse the Web. I’ve got the monitor, printer, everything, I just need the PC.

The KMart store clerk looks around and shows off the $600 or so PC, which was not in her target price range. After a bit more asking the clerk goes, “Well, we do have 1 machine in the back. Every store has only gotten one, but it’s only $200.

She asks to see it, and he brings it out. Says something about having Firefox, goes onto Facebook, Google Mail, has office tools, etc. She goes, “that’ll work for me” and promptly buys it.

Of course, it turned out that it runs Linux, not Windows, which my uncle gave her some ribbing about. When I asked how useful it had been they replied that my sister didn’t seem to have any trouble getting onto the Internet or using Firefox, but they had one page that wouldn’t work, and could I look at it? I told them I would, and that they might even see something with my name on it. (No, as it turned out).

So when I went down it turned out that it was running something called gOS, a Ubuntu derivative. My sister knew the passwords and stuff and had been able to half-navigate around the desktop. I installed Java and tested the site… and it still didn’t work. I don’t know if this is a gOS or Ubuntu (or Debian) hiccup but after installing the javaplugin package for mozilla I still had to symlink it into the plugins directory. After that, the Java site worked fine and my sister and her friend were able to play some game called Runescape. Only other software package she wanted to see was “that fish screensaver you showed me“. I didn’t want to install kdelibs just for one screensaver so I looked for the original. But the system didn’t have Term::Animation packaged and I didn’t want to mess with CPAN. Maybe next time though.

I also had to make their printer work. gOS actually came really close but since there was no driver included for her model printer it defaulted to Generic Text Only. A similar driver was available which I tried, and worked. There is a specific driver to use from Canon but you have to go through a bunch of hoops to get it to work so I simply didn’t bother.

Other than that, from my use the system was responsive enough, included enough software, and seemed at least reasonably achievable to browse around for someone who had never used Linux. I explained some Linux concepts for my sister and put an xterm icon on her desktop. I also ran the Synaptic Update process… and saw 117 or so security packages, including the OpenSSL fix. I don’t know what else the gOS guys are doing but they really need to make security packages update by default, or at the very least auto-download and then start blaring sirens saying that an update is needed. Windows is much better in that regard on default installations so that’s pretty embarrassing.

However, given all that is included, my grandmother and sister were pretty ecstatic. My uncle (a long time computer nerd) was kind of off-put by not being used to the system and pointed out everything that didn’t work but in the end it was either a 90% useful system for my sister or nothing and so both my grandmother and sister were pretty happy to have the system. I pointed out the support bookmarks in Firefox for my sister so she can mess around and other than that I guess I’ll have to train her a bit whenever I go down. But as long as an update doesn’t break anything they should have a useful system for quite a few years now, which makes me feel good about the work I put in supporting Linux and the F/OSS ecosystem as a whole. We’re not on top yet but for a lot of people we are certainly better than merely good enough now.

Posted by mpyne under Computing Troubles & Personal | 5 Comments »

Improved crossfading

May 19th 2008

I’ve been improving JuK a lot over the past week or so trying to get it into better shape for KDE 4.1 (and 4.0.5).

What I’ve worked on today was the issue with crossfading where the volume differential between the songs would go haywire initially. I think I’ve got it as good as I can get it from JuK, but now there’s something else I need.

I have posted an email to kde-multimedia detailing my problem, but basically I want to use the gstreamer phonon backend to test whether the problem lies with JuK or with phonon-xine.

The first problem was that JuK wouldn’t work with phonon-gst because JuK made some inaccurate assumptions about when Phonon would actually start playing after being told. (Hint: Not immediately, the backend has to setup first).

That is fixed in both the 4.0 and trunk branches now. But when using phonon-gst to playback a song, any time I switch to the next track JuK crashes on an assertion in phonon-gst. This happens even if I do not allow crossfading. This does *not* happen if I slow it down in gdb by single stepping. So I think it’s a timing issue.

Anyone out there use phonon-gst and could tell me what I’m doing wrong?

Posted by mpyne under Computing Troubles & KDE & Programming | No Comments »

Next »