partiallydisassembled.net

The takeaway

2009-02-20 10:26:21

When did this become the hip new word for "conclusion"? It irks me.

Anathem

2008-10-11 20:36:51

"Our opponent is an alien starship packed with atomic bombs," I said. "We have a protractor."

Alan Green writes:

Ooh, ooh. I know. We wait until they reach out to press the "fire" button, then we stab them in the hand, right?

Jesse Archer writes:

Perhaps there's another angle we could approach this problem from.

Apple C header licenses

2008-10-08 23:19:24

Seen in the prelude of the Kernel.framework/Versions/A/Headers/IOKit/hid/*.h files... "[...] APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. [...]" Not fit for quiet enjoyment? Oh, my.

What slows down development...

2008-08-16 17:00:22

... Vista bluescreening every time I terminate a hung Python process that has a lock ("Process has locked pages"). Yep, I can trigger it consistently and reliably. Makes.. me.. angry!

Multithreaded goodness for pyglet

2008-08-12 00:01:13

I've finally gotten some good results after spending the last few months (on and off) refactoring the pyglet.media module in pyglet to use multiple threads. There were two main reasons for attempting this: to make better use of multi-core machines (pyglet is currently single threaded), and to avoid having to schedule audio pump in the main event loop (in pyglet 1.0 this was explicit, in 1.1 it's done on the clock). The problem with having the audio pump in the main loop is that it requires application developers to manually tune their programs to keep the audio buffer full -- and this is obviously very dependent on the hardware and drivers available. One motivating example was my last PyWeek entry, which had background music that stalled during long loading times (I managed to get this down to just the initial loading time, and smooth for the rest of the game, but this was a lot of effort, and removing the initial pause proved too difficult). The redesigned media module is still residing in the experimental/mt_media directory of SVN trunk. Only the OpenAL driver is anywhere near complete. The DirectSound driver has yet to be ported to the multithreaded API, and the ALSA driver has been deprecated in favour of a new PulseAudio driver. PulseAudio is proving far more reliable and capable than the ALSA user-space daemon, and has been the default audio server in both Ubuntu and Fedora Core for some time. The PulseAudio driver is mostly complete, but has no 3D capability (Linux users can still choose to use OpenAL as an alternative). The audio driver modules are required to pump themselves now. The PulseAudio driver does this using the built-in PA thread runloop, whereas the OpenAL driver creates a Python thread that periodically wakes. Much of the shared code between drivers regarding video frame synchronisation has been moved into the base classes. This should greatly reduce the amount of effort required to develop a new audio driver. Audio drivers dispatch events to the Player object when a new video frame should be displayed. New methods on pyglet.app make it easy to post events from one thread into the main event loop safely (these also automatically wake up the main event loop if it's sleeping, allowing more opportunities for people to integrate multithreaded code into their pyglet applications). The AVbin source driver also now spawns a worker thread for decoding video frames. Since most of the work in decoding the frame is done outside of Python (in FFmpeg), this is a great chance for pyglet to do some real multiprocessing. Quite a lot of work went into ensuring the queue of video frames to be decoded is kept up-to-date with what's needed on-screen; without an excessive preroll period or memory usage. I've done most development on my 900MHz iBook, which is incapable enough that it can't even play YouTube videos in real time (though pyglet can play them just fine once downloaded, thanks to FFmpeg). This has forced me to make the implementation efficient enough to work on old computers; the overhead of the extra thread processing is significant and required several manual context switches to get everything playing (almost) as well as the old, single-threaded code. On newer computers the performance is fantastic. I did a quick benchmark test on my 1.8GHz Core 2 Duo Mac Mini. It happily plays 7 SD videos simultaneously (DivX or Xvid encoding) without sweating, whereas the old code could only play 3 videos. Watching the activity monitor shows that both cores are now being utilised fully when needed (and run each at around 5% when playing a single video). Expect to see this new code in pyglet 1.2. I'll introduce some more of the new features over the next few weeks. I'll also be talking about pyglet 1.2 at OSDC 2008 in Sydney in December.
login