linux

C++, Threads and Linux Audio: A Brief Retrospective

tung's picture

I just spent the last few days trawling through someone else's multi-threaded C++ Linux audio code, so I thought I'd share a few of my experiences.

First: The commit.

That code converts direct audio hardware access via ALSA into newer plugin-based output. It also fixes a race condition that occurs at the seam of the two subsystems involved: the client code provided a mixer callback that used a buffer that is initialised immediately after the server spawns the thread that needs it. It's a mistake made by the code's author, but to be fair I wouldn't have spotted it either if the code hadn't segfaulted on me.

If you ever find yourself in this situation, here are some tips:

  • Print statements really work. Yes, even with threads. Especially with C++, where control flow isn't obvious.

  • In threaded code, if you just insert print statements and behaviour changes, that's almost certainly a sign of a race condition.

  • C++ is harder to grep through than C, but it still works, if less effectively. C++ adds a lot of context that makes individual identifiers less useful on the isolated lines printed by grep.

  • Persistence pays. Even if the best programmers in the world say that threaded debugging is difficult, it can still be done.

  • If you're in college/university and going the computer/software route, take the Operating Systems course(s). Threads and concurrency get a lot of good exposure in them.

Read more »

Building Redcar 0.3 under Arch Linux

tung's picture

According to its website, Redcar is "a programmer's editor for Gnome, written in Ruby and Vala. Redcar is designed to be compatible with Textmate bundles, including syntax highlighting, commands and snippets, and most keybindings are the same."

There are build instructions on GitHub, but they're skewed heavily towards the Debian-based Ubuntu distro. I use Arch, so here's what I did.

Read more »

Fixing window-picker-applet

tung's picture

As you're all too aware of, I own a netbook, and I run Arch Linux, so I'm always trying to optimise my experience by tweaking things here and there. One thing that caught my eye was the Ubuntu Netbook Remix interface, which has 6 major parts:

  1. Desktop switcher - switches between netbook/desktop modes.
  2. Go Home applet - displays the desktop window, which is the launcher window under UNR.
  3. Human Netbook Theme - Ubuntu's infamous dirt-brown colour branding.
  4. Maximus - Maximises and optionally removes decorations from windows. Remembers settings.
  5. Ubuntu Netbook Remix Launcher - The main interface, displayed instead of the normal desktop.
  6. Window Picker Applet - An alternate window switcher that shows the full title of a maximised window, and the other windows as icons.

Being a power user, I wanted #4 and #6. I don't use Maximus, but I found I could get its effects from hacking my Metacity theme. Exactly how I'll leave for another time.

Instead, I did some work on Window Picker Applet. Here are the results, at the middle-top of the screen.

My tweaked version of Window Picker Applet in action.

If you're using Window Picker Applet now, you'll notice something is amiss: how can my notes be active, and yet my VIM terminal in the back still shows in the title bar? Try it now: open and maximise a window, and then open a smaller window in front of it.

The problem here is that Window Picker Applet 0.4.21 (I haven't tested later ones yet) assume that the front/active window is the only one that matters. Since I don't use Window Picker Applet with any of the other netbook remix stuff, this made working with multiple windows a bit irritating, as if people like me hadn't been accounted for.

I've written a fix for this.

Read more »

git prompt for bash

tung's picture

I found a pretty neat tip today, and here it is in action:

git prompt screenshot

It's a custom bash prompt that shows the status of the current directory if it's a git repo. Forgive the mouse, it was an innocent bystander. Yeah, I type ls a lot.

Read more »

pdnsd: Local caching DNS

tung's picture

I love watching Firefox forever display "Looking up www.example.com...". I love it when it says it can't find a server, even when I can ping individual IPs just fine.

No, actually, I hate it.

Why doesn't my machine just remember which IP matches which domain name, even if the router or my ISP craps out? Well, looks like somebody else was thinking like I was, because that's exactly what pdnsd does: it looks up domain names, and remembers their matching IP addresses.

So here's how I set it up for myself.

Read more »

Font smoothing under Wine

tung's picture

Use Linux? Use Wine? Want smoothed fonts?

Get font smoothing in Wine.

If you don't like links, here's what you do. Put this in, say, whatever.reg:

REGEDIT4
 
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingType"=dword:00000002
"FontSmoothingGamma"=dword:00000578
"FontSmoothingOrientation"=dword:00000001

Then as a normal user run regedit whatever.reg. Done!

Why I use Linux

tung's picture

I just realised that if I were to be involved in a conversation and asked about why I prefer Linux over, say, Windows, I wouldn't have a reasonable response. It'd be something along the lines of, "I just like it better." There must be more to it than that.

I'm certainly no freetard, so there must be some practical basis to my choice of operating system. In no particular order, here they are:

Read more »

dailygrind desklet

tung's picture

Don't be the example, multiple entries can appear in each section

dailygrind is an adesklets widget that keeps you informed of repetitive tasks. Things that you do every day, you need every week, every month, every year, or even just a once-off, are all shown in a small box on your desktop.

Read more »

Arch Linux on my Eee PC 901

tung's picture

Just two days ago, I got my shiny white Asus Eee PC 901! I've been waiting a long time for this, and although it's the 12 GB WinXP model (lol Ausfailia), I've managed to set it up with Arch Linux and the GNOME DE.

Read more »

Not posting from an Eee PC ;_;

tung's picture

... because no stores seem to be stocking one that matches these specs:

  1. Asus Eee PC 901,
  2. with Linux (screw Windows and its anti-hacking regime),
  3. that's white (gloss finish == fingerprints on black surfaces).
Read more »
Syndicate content