StarCraft 2 on Linux: Sound problems

28. September, 2010
Wine Logo

WINE Logo

If you have sound issues in StarCraft 2 on Linux, open WINE config (winecfg) and select the “Audio” tab. Make sure that the correct sound driver is selected (use “Test sound”) and then switch “Hardware Acceleration” near the bottom to “Emulation”.


StarCraft 2 on openSUSE 11.3 [update]

13. August, 2010

As you may have heard, StarCraft 2 works on Linux. It’s even officially supported by CrossOver Games. It’s only Silver (which means “runs with minor issues”.

One of the issues is that the game crashes at startup or shortly afterwards. This seems to be a kernel bug.

To solve the issue on openSUSE 11.3, you need to install a kernel with version 2.6.35. Luckily this is pretty simple:

  1. Add the repository http://download.opensuse.org/repositories/Kernel:/HEAD/openSUSE_Factory/  with Yast2 (under “Software Repositories”). Give it any name you like.
  2. I suggest to set the priority to 120; that way, the other repositories will be considered first and entries in this new repository won’t pollute your system unless you ask for them.
  3. Open “Software Management” in Yast2
  4. Open the tab “Repositories”
  5. Select the new kernel repository
  6. Locate the package “kernel-desktop” and select it
  7. Click on the “Versions” tab at the bottom
  8. Select the one with version “2.6.35.1” (the last digit can be different).
  9. Click “Accept”

Yast2 will download the new kernel and install it. After a reboot, you can enjoy StarCraft II.

[Update] I’ve played the first six single player missions and had no major problems so far. The frame rate could be better but that’s about it.

[Update 2, 11th Nov. 2010] Kernel 2.6.36 has been released. You can find it here.


UltraViolet: Death of digital content

29. July, 2010

UV radiation is invisible but extended exposure causes sunburn. It can also cause skin cancer which leads to certain death if not treated immediately. What an appropriate name for a new DRM system.

My guess is that it will help to kill sales of digital media like no technology before it. Why?

  1. It is supported by most of the important companies, so in a few years, you won’t be able to find consumer devices which don’t support it. Outside the OSS world that is.
  2. Did you know that you buy products because you like them? If that is so, then the products you buy tell about your psyche. In which mood are you today? Did you buy ABBA or Motörhead? Hmm… Imagine who might long for such information and how much.
  3. Finally you don’t have to spend hours selecting music for a friend, a coupon is enough. You can’t buy the music for them anymore because you can’t give it away anymore. Anything you buy will be yours. And yours only. Except if they are members of your family. Finally children can know what their parents read. And which movies the parents watch after the children were sent to bed. Did you know that most parents turn to their children for help with electronic devices?
  4. At long last DVDs and BlueRay disks will “just work“. No more sitting in front of a black screen because your DVD player can’t play the disk in the drive. And you won’t get an FBI warning either. They will know where you live the instant you try to play “content” you didn’t buy and sue you. Or kick your door in. Whatever they feel like. You’re just a petty criminal, like the molesters, thieves, murderers and other scum.
  5. UV will be anywhere (like in daylight). There will be no way to avoid it. Unless you stop buying. What an odd idea. Why would you stop giving money to greed…great companies who sue toddlers? Babies stink anyway. Stop making them. They only pollute the planet even more, they take room, breathe our air, eat our food and then refuse to pay for our pension. Buy more music instead! In UV2, we’ll figure out a way to sell condoms, too. Everything for our consumers!
  6. Of course this is a very complex technology, so the company behind it has meticulously created a roadmap which makes sure the most important features are available first. Which will be the ones that are paid for. By the companies using the technology to sell you stuff. But don’t worry. Eventually, when they run out of ideas how to spend the fortune they’ll make, they will eventually consider adding features for consumers. Eventually. Housing on the moon is so expensive. But well worth it: You can’t hear the complaints. And the view is priceless.
  7. Only very few, unimportant companies like Apple and Disney aren’t on the big, happy bandwagon. But don’t fear. In a short time, they will either be out of business (like they deserve) or see the light like everyone else.

Doesn’t that sound great? At last no more aggravation that you can’t play music on your Linux PC because the MP3 codec isn’t installed. No, finally you can be sure that no digital content, even if you bought it on a DVD and physically carried it home, will be owned by you. Or can be played on Linux. The Linux community, which has been spread like a virus for years, will be reduced again to the weirdos, sociopaths and communists. McCarthy would be so happy.

There is just one tiny problem. In Europe, there are some people called “data protection commissioners”. Unlike the name suggests, they are purely evil and as soon as they learn what the companies behind UV can do with the data they collect about the valued customers, they might try to outlaw the technology! Fret not, dear reader, the stupi…insight of the masses have always worked in our favor.

It won’t take long before new governments will be elected by careful persuasion of you with a little help of the, say, more “private” or, well, “odd” purchases you make. And if that doesn’t work, it should be possible to extrapolate your income this way and gently nudge the IRS who will be thankful of the service rendered by the law-abiding[*] companies behind the great new technology Ultraviolet!

[*] Read “we are the law”! And don’t you forget it! Now buy! The tires on my Ferrari are already dusty from the ride this morning! Yuck! I need a new one! Life is so … so … unjust!


PyScan 0.6

10. October, 2009

I’ve done some more work on PyScan. Most work is under the hood but I’ve got a system to load and save projects and a bug was fixed: If you pressed the Scan button too quickly with 0.4, the last image could have been overwritten. PyScan is now based on hplip 3.9.8.

PyScan 0.6.tar.gz (16KB, MD5 Sum: 2b5e23099be438ceceb69ec23d64cec6)

See the original post for features and the system requirements.


Installing openSUSE 11.1 on an Acer Aspire 5737Z

25. July, 2009

Yesterday, I bought an Acer Aspire 5737Z for my mother. I ran into two issues while trying to install openSuSE 11.1 on it:

  1. System error -1012 during partitioning
  2. Installation of the bootloder failed with error 12: Invalid device requested.

In both cases, the openSuSE failed to enumerate the hard disk partitions correctly. The partition layout was as follows:

  • /dev/sda1 – Unknown partition (probably the recovery program)
  • /dev/sda2 – Windows C (20GB)
  • /dev/sda3 – Extended partition for linux
  • /dev/sda5 – swap partition (2GB)
  • /dev/sda6 – root partition (/ 20GB)
  • /dev/sda7 – home partition (/home rest)

The first error happens when the installer tries to set the type of /dev/sda6 to 82 (swap). That should have been /dev/sda5. The solution is to boot using the rescue system and to partition the disk manually. I suggest to use “cfdisk /dev/sda” for this. Make sure you mark the root partition as bootable.

After that has been done, tell the installer to accept the existing partitioning. You’ll still have to assign the mount points, though, and tell the installer to format the partitions.

Later, grub gets confused in a similar matter. It tries to add the Windows boot manager from (hd0,2) (which maps to sda3; grub starts counting with 0!). That should be (hd0,1). Since everything is installed, we just need to boot the rescue system and chroot to the installed system:

  1. mount /dev/sda6 /mnt – Mount the root filesystem
  2. mount -bind /dev /mnt/dev – Map (bind) the devices into the root filesystem (so that you can access the hard disk, etc)
  3. chroot /mnt bin/bash – Start a shell that behaves as if you had booted from the installed system

You can tell that you’re in a new shell by pressing “Up”. That should recall your last command (chroot). Your first task is to fix the broken grub config. Edit /etc/grub.conf. The first line should read setup --force-lba (hd0). Run grub-install. If it still fails, try to run it manually:

grub
root (hd0,5)
setup --force-lba (hd0)

Note that this will overwrite the Windows boot code. I’m not sure how to boot Windows, now, but really, I don’t care.

Next step on the path to hell is the NVidia driver. I didn’t have much luck with the precompiled one from the NVIDIA repository. Instead, I installed kernel-source and gcc. After that, you can do cd /usr/src/linux ; make oldconfig ; make and abort the build when it starts to build stuff in arch/x86/. Now, you can compile the driver from the source. Just sh ./NVIDIA-Linux-x86_64-185.18.14-pkg2.run, answer all the questions and then run sax2.

In sax2, make sure to select an “LCD monitor” with “1360×768” pixel resolution. After a moment, you should have a clean display.


Printing Big Stuff On Linux

22. June, 2009

During the weekend, I tried to print my family tree. It was pretty simple to generate with GenealogyJ but frankly, the family tree view sucks. I was constantly shifting my “root” node to be able to see the parts I was interested in, etc. And printing this sucks even more. GJ will use lots of paper, printing huge empty boxes with lots of space around them. If I reduced the size of the parts which I don’t need, the layout fell apart. In short, I needed something better.

Graphviz to the rescue. A small Python program (100 lines) read the GED file and turned it into a graph with the layout of the persons just the way I wanted them to be. dot thought about the graph for a few seconds until it emitted a nice SVG which I could then print. Or so I thought.

I opened Inkscape and clicked on print. Yeah … that looks like the document … or rather a small part of it. Where is the poster print option? Ah, there is none. Great. Export as PNG with … oh … 150 DPI. Starting GIMP. No poster printing either. lpr tries to scale the image by .114537 which results in a 87 MB file. You gotta be kidding! kprinter? Nope … unless the command poster can be found.

A word of warning: The poster for openSUSE 11.1 (which you get with zypper) is broken. I tried it with both PostScript and Encapsulated PostScript and both resulting files were unusable in GhostView, GhostScript and Okular. Use this one instead.

After installing psutils, I could rotate the file to fit better on the page, too.

Conclusion: Most programs on Linux create PostScript files but printing them is still something for the command line. The recent print dialogs all look somewhat similar (but are different in tiny, annoying ways), each version is missing some important detail and most of them fail to simply print an oversized image on a single piece of paper or spread it over several. That Inkscape spits out an empty page after the document is just a minor issue.

What’s worse: The print preview either doesn’t work or doesn’t exist, printing to file is not implemented either or isn’t persistent. In the whole process, I ruined roughly 50 sheets of paper. *sigh*

In the end, I had a process which involved six different programs (GenealogyJ, Python, graphviz, Inkscape, pstops, poster) just for this standard task. Printing on Linux has some way to go, yet. On the positive side, I could script all these tasks and I could do it.


PyScan: A Little Helper For The HP CM1312nfi MFP Scanner

18. April, 2009

Update: Find the latest version (0.6) here.

I recently bought a HP CM1312nfi MFP scanner (multi function device with scanner and color laser printer). After scanning some 1’000 pages, I’m still satisfied with the device. The document feeder (ADF) sometimes tries to eat the paper after spitting it out and the colors could be a little more brilliant but overall, a good deal for the price.

What bothered me was that the “Start scan” button doesn’t work on Linux. But someone posted a script in the bug report which can poll the button by reading the URL http://$ip/hp/device/notifications.xml (replace “$ip” with the IP address or DNS name of the scanner). This returns some XML with two interesting elements: StartScan and ADFLoaded. The first one becomes 1 when someone presses the “Start scan” button on the scanner and the second one tells us whether there is some paper in the ADF.

With that and some source code, it was simple to create a little tool that works quite like xsane but fixes a couple of things that annoyed me for a long time:

  1. The UI of xsane is dead while it scans
  2. There is no online preview of the scan; you have to open the file in some extra tool to verify that the scan looks OK
  3. xsane doesn’t know about scan “projects”
  4. xsane doesn’t start to scan when I press the button on the scanner

As with all OSS software, this thing can seriously ruin your day, so be a bit careful. One of the biggest problems is the file size: To be able to edit files without loss of quality, TIFF format is the default. Each full page scan takes 26MB, 100 pages need 2.6GB!

Plans for 0.5: Allow to edit projects in the UI, select them, save and load them. Right now, you must define your projects via the command line or by editing the source code.

Download: PyScan-0.4.tar.gz (12KB, MD5 checksum)

Dependencies (see README.txt for download links):

  • Python 2.6
  • PyQt4 4.4.3
  • Python Imaging Library 1.1.6
  • Python Imaging SANE 1.1.6 (needs included patch; see README.txt for instructions).

Features

  • Code to load images in a background thread, generate thumbnails (compatible to Konqueror/Dolphin) and display them in a list view
  • Display a (big) image with various manual and automatic zoom levels and modes (fit to window, percent) with zoom and pan
  • Online preview of scan in progress

Hideous details of the source

Again and again, I’m astonished how simple some tasks are in Python and Qt … if you’re willing to accept some “non-OO-ness” of the solution. I’ll explain some things I did here to give you an idea what’s going on.

Online preview

PyScan has an online preview of the currently active scan. If you look at the documentation, the Python Imaging SANE interface offers no way to do that. After looking at the source, I found that the SANE interface simply reads bytes from the SANE scanner module and copies these into a PIL image which was created on the Python side.

So my solution is to be notified that a scan is in progress and then copy said image every second (all 26MB) into a string. That string is then used to build a QImage which is turned into a QPixmap which is then displayed in the right pixmap view. See pilImage2QImage() for the details.

Background threads

I also moved all expensive code into threads: Loading big TIFF images, scaling them down to thumbnails, saving the images, etc. All threads have a method to add work to their input queues and they send Qt signals when they’re done. Continuing the scanning when there is paper in the ADF tray was a bit of a problem, through.

Since the saving of the images is happening in a background thread, the code could start the next scan before the saving was completed. This wasn’t such a big problem except that the “scan next image” code looks for files on the disk to determine the next filename. This would lead to overwrites. So I had to synchronize this somehow. My simple hack was to set a boolean “waiting” in the scanner thread which indicates that the scanner has more paper to process and waits for the save thread to complete. When the UI gets the “image saved” signal, it triggers the scanner to continue.

Generating thumbnails

The last hack in the code is the generation of the thumbnails. The main issue here was that I need the thumbnails for the gallery view really deep down in the Qt render code. Wasting time at that level is really a no-no but at first glance, the API offers no way to defer loading of the images and then later update the items in the list view when the data is available. Keep in mind what I need to do:

  1. Load a 26MB file from disk
  2. Scale it with antialiasing
  3. … for hundreds, possibly thousands of files!

My solution: In the render code, I create a LazyPixmap. This is just dumb object to save the filename and a placeholder pixmap which is used into the real thumbnail becomes available. The LazyPixmap will schedule a job for the LoaderThread.

In my first code, I tried to create a QPixmap in the LoaderThread but that doesn’t work: Only the UI thread is allowed to create a QPixmap. Duh. But luckily, Qt offers the QImage class which works even without a UI and which offers basically the same API as QPixmap. So the LoaderThread can load the image from disk and scale it down (to save memory and avoid heavy computation in the UI thread) right before emitting a “loaded” signal.

There are two places where a LazyPixmap is used: In the PixmapWidget (which can display and zoom a QPixmap) and in the ThumbnailDelegate which draws the thumbnails for the filenames in the GalleryModel.

In the case of the PixmapWidget, the signal will be handled in lazyLoaded(). Here, we convert the QImage into a QPixmap (in lpm.getPixmap()) and assign that pixmap, recalculate the zoom factor, realign the view, etc.

The GalleryModel, I have the problem that I need to tell Qt somehow that the pixmap has changed but the API offers nothing except rendering the whole widget by calling update(). This will render at most (on a huge screen) 30 pixmaps. Happens one time per visible pixmap, causes no flicker. Probably not worth to waste another second on it.

If you look at the code, you’ll see that a class called KDEThumbnailCache is used. This class accesses the same thumbnails als konqueror (KDE3) or Dolphin (KDE4). This means once the images are scaled down (either by my code or Dolphin), all tools can quickly load the small, precalculated thumbnails instead of having to scale the 26MB files again.

Conclusion

Well, that’s it for a small walk through the code. Feel free to give feedback if you like PyScan (or not) or when you have patches.


hpaio: unable to read device-id

21. March, 2009

I recently bought a multi-function device printer scanner (HP Color LaserJet CM1312nfi MFP). Setup on openSUSE 11.1 was pretty painless with the hplip package (version 3.9.2) from packman. The original openSUSE package would core dump. Duh.

Today, I had a strange error all of a sudden:

scan/sane/soapht.c 486: unable to open device hp:/net/HP_Color_LaserJet_CM1312nfi_MFP?ip=xxx.xxx.xxx.xxx
io/hpmud/jd.c 84: unable to read device-id

Of course, I hadn’t changed anything in my setup … until I remembered that, for security reasons, I had disabled SMNP in the web interface of the printer. Guess what, after enabling “SNMP-Lese-Schreib-Zugriff aktivieren” (“Activate SNMP-Read-Write access”), the error went away.

For the record: Most functions of the device are accessible from Linux:

  • Color printing
  • Scanner
  • Automatic document feeder (ADF)
  • Remote printing and scanning

I haven’t yet managed to make the “Scan to PC” button on the front of the device work but that’s just a minor issue for me.

The price/performance ratio is very good. The printouts look very good and the ADF could cope with all media that I’ve fed him so far (even these thin, glossy, cohesive catalogue pages; you just have to spoon feed them one at a time).

The scanner is good, but not top notch. The quality of the scans is OK, colors are pretty close to the original but the images could be sharper. The scanner uses a CCD line, so no warmup time (if you don’t have to switch on the whole machine).

If you want better quality color copies, set the resolution to 300 DPI (factory setting is a poor 150 DPI which makes thin lines really smear).


Compile VMware tools on openSUSE 10.3

27. October, 2008

I just tried to install the VMware tools on openSUSE 10.3 (Linux kernel 2.6.22.18) so the virtual machine would survive more than 10 days on an ESX server and failed. If you have the same problem, the solution is here.

Errors you’ll see during the installation otherwise:

The directory of kernel headers (version @@VMWARE@@ UTS_RELEASE) does not match your running kernel (version 2.6.22.18-0.2-default). Even if the module were to compile successfully, it would not load into the running kernel.


Lovin’ Linux? Dig This!

22. July, 2008

Want to make linux better? Ask the Linux Hater. If in doubt: He wouldn’t write 15 articles per month telling where Linux sucks if he didn’t care.


%d bloggers like this: