An unforgiving API

(May 16, 2006)

When writing a program for an iPod, the first and foremost thing to implement is, of course, sound. I, for one, did some of the graphical bells and whistles first, because that’s where my real business is, but today, I wanted to add a little bit of music. It was going to be a smooth ride, I thought, as iPodLinux’ native sound API is just plain and simple OSS.

To make a long story short, I ended up in about three hours of debugging. My iPod application simply wouldn’t play the primitive uncompressed WAV file I used for testing. The same application, using the very same sound code, run without any problems on ALSA’s OSS emulation on my notebook. Even better, it run without buffer underruns, which is a thing almost no OSS application manages to do because of ALSA’s incredibly crappy emulation code. But I digress.

I checked about every possibility: Mixer settings, not-so-fancy buffer management, filling the buffer with noise instead of the file’s audio data … to no avail. The file and the iPod were OK, because Podzilla played the very same file without problems. Initialization via Podzilla and starting my program afterwards didn’t help, either. I read about every sample OSS playback source I could find. Until I finally discovered it:

I opened /dev/dsp in O_RDWR (read/write) mode instead of O_WRONLY (write only)!

Sometimes, these little bugs can ruin your whole day :/

Post a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


By submitting the comment, you agree to the terms of the Privacy Policy.