quipkit

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 »

Making an RPG with Quipkit (Hypothetically)

tung's picture

Quipkit is a work-in-progress (read: not even near finished) indie RPG dev kit. This blog entry describes how we might make an RPG using Quipkit.

1. Vague Game Description

Most games start as vague ideas, and indie RPGs are no exception. Here's one for our hypothetical RPG:

You play a guy in a traditional fantasy RPG. You walk around a map of grass and water, and every so often you encounter a monster. You exchange blows with said monster in the battle system until either you or it dies. If you win, you gain experience. With enough experience, the guy can gain a level and grow in strength. This continues until the player chooses to exit.

It shall be dubbed... Island Dude.

How would be breathe life into this little RPG? Read on!

Read more »

How do I autoconf?

tung's picture

I was working on a project when general upgrade instability caused it to stop working on my development machine (read: starting OpenGL kills X for some reason). Off of Arch and onto Ubuntu 9.04, and I find that my Linux-based project won't build under Linux.

Autoconf is a set of tools that smooths over differences in build environments, like different file system conventions, library names, search paths, tool chains, and so on.

The following is based on a series of long articles over at the Free Software Magazine: the only tutorial/guide that didn't attempt to shove 20 years of history down my throat from the get-go. It's my personal reference and I'll update it as I learn.

Read more »
Syndicate content