Trouble with audio device

Error message:

  • in english: "A device ID has been used that is out of range for your system"
  • in french: "Un numéro de périphérique en dehors de la portée de votre système a été employé."

This error message comes from the WinMM stack and is error code 2.

My context is as follows, but apparently this can happen with various other hardware/software combinations so this is really for the sake of reference.

VMware Player with an Ubuntu 11.04 Natty Narwahl guest on a Windows 7 64-bit host fails to connect or keep connected the guest virtual soundcard to the host. Although it does not quite matter the sound card is a Realtek HDA on a Dell XPS desktop machine.

It appears there is some sort of mismatch between what the host provides and what the guest asks for. This seems to happen when the host card and driver knows if things are pluggen in each of its jack ports, reports it to the OS, which then refuses to proceed with some sound system initialization. This can also happen when something went wrong somewhere in the driver system (e.g broken or mismatched registry settings).

The workaround for me was to disable all audio input in the virtual machine. To do so, go to Sound Preferences, go to the Hardware tab, and select a Profile in the list which matches what you want. I selected "Analog Stereo Output" instead of "Analog Stereo Duplex". This way VMware won't try to access a nonexistent microphone. I also had to reenable and then redisable the login screen sound for that sound not to play and therefore the soundcard not to disconnect when reaching the login screen, as apparently this area of the system does not respect sound settings.

Others have reported that plugging a microphone or speakers in the proper ports could fix the issue. There are also reports that disabling a number of enhancement features  like noise cancellation would work too. Another solution in case the driver system went broken somehow is to uninstall/remove the device from the Windows Device Manager and/or try to switch or reinstall drivers. For my soundcard, Realtek HDA drivers were installed and I uninstalled them, then Windows found some generic HDA ones straight from Microsoft. This last step did not fix anything for me but interestingly enough this removed the crapfest that is the Realtek sound panel.

 

Evaporative Cooling

There are some patterns that you experience and recognize, but that you fail to name or define. Then someone comes up with a picturesque name precisely capturing its essence. This is one of those:

[Evaporative Cooling] occurs when the most high value contributors to a community realize that the community is no longer serving their needs any more and so therefore, leave. When that happens, it drops the general quality of the community down such that the next most high value contributors now find the community underwhelming. Each layer of disappearances slowly reduces the average quality of the group until such a point that you reach the people who are so unskilled-and-unaware of it that they’re unable to tell that they’re part of a mediocre group.

(Via Another Way to View the “Decline” of HN)

 

Of analogies and monocultures

Analogies are great tools. Their goal is to explain stuff pertaining to a certain context to someone which has insufficient knowledge about that context, but sufficient knowledge about another one where similar stuff happens.

Basically you extract meta-stuff and put it in a known context so that you can make a point. Analogies do not make a point by themselves. Ever.

Take for example this analogy rebuttal, wherein software monocultures are equated to Ireland physical monoculture which led to a disaster.

I think that the analogy still makes some sense if you apply it to the same scale.

The biological case "Ireland farmed one species of potatoes. Said potatoes went irrevocably compromised. Ireland hungered to death." cannot be compared to a single corporate IT infrastructure.

Imagine that (admittedly non-realistic) case: "Ireland relies solely on the Microsoft ecosystem. Said ecosystem gets massively infected by a critically damaging virus. Ireland economy grinds to a screeching halt.", that is the proper analogy. If half of the companies in the country had its IT infrastructure based on another system, then half of the country would still run. Just as half of the potatoes would be palatable.

At the other end of the scale, a single corporate IT infrastructure with heterogeneous ecosystem would be more like a single farmer cropping multiple species of potatoes. It can indeed get costly as at this scale managing the peculiarities of each species (soil, maturity...) could become complicated. Yet it can still be quite worth it.

Real life example: when McAfee AV false-positived and quarantined some kernel32.sys or whatever, turning our Windows machines into useless boxes, we could still save the day thanks to our few Linux and Mac machines.

So, making a point and explaining it through analogy is valid, yet analogies do not make a point by themselves. More often than not it is a double-edged sword that might bite back while you end up being sidetracked in endless arguments irrelevant to the initial context, and therefore issue.

Therefore, make your point first. Explain the context as best as you can. Then and only then enlighten the context with a thoroughly thought analogy. Only by keeping both clearly separate can you identify the analogy shortcomings (or lack thereof).

 

Try, and try again

So I'm giving posterous a try.

Now the above phrase really is supposed to be the conclusion of the current post.

My previous blog was on Tumblr. I have been satisfied with Tumblr from a writer's point of view (Markdown!) or even a designer's point of view (those themes are really easy to customize), yet it completely fails at actually making its content available to search engines.

Now you see, Tumblr is big. Failing to percolate content through search engines means that whatever bit of information you put in Tumblr instantly accretes into its mass in a trajectory hopelessly leading well beyond its event horizon. Seriously, have you ever ended up on a tumbr page from a search engine?

Tumblr is a creepy, useless black hole.

The content I put online is often some result of research pertaining to some peculiar issue I happened to have to solve out of sheer need. By virtue of nerdiness affliction, I also happen to hate kludges and more often than not will try hard to put together a proper solution, or failing that, a supposedly nice hack. So, having spent a handful of hours sorting through a boatloat of tiny, scattered bits of information and assembling the relevant components into a working solution, I happen to think that it would actually be nice to others to not waste the processing time I just spent swimming through swarms of data carefully filtering the signal out of pure noise.

Having that content not crawlable by a search spider, folks, is the absolute deal breaker.

Now stops the rant.

Compiling SYSV_IPC python module with GCC on AIX 5.2

I had a need to use good old SYSV message queues to interoperate with a bunch of old C programs, straight from python. Come in sysv_ipc module to the rescue, which works great on a variety of systems, but I need it on AIX.

Using Perzl wonderful rpm packages for AIX, I was able to compile it with GCC 4.2 and setup it into Python 2.6.

Modify common.h to unset SHM_SIZE (Obsolete step as of sysv_ipc 0.6):

#undef SHM_SIZE

enum GET_SET_IDENTIFIERS {

Export those two vars:

LDSHARED="/opt/freeware/lib/python2.6/config/ld_so_aix gcc -bI:/opt/freeware/lib/python2.6/config/python.exp"
CC="gcc"

You can then go on and:

python setup.py install [--user]

Update: common.h should not be modified anymore.

Play a MP3 file with pymad and pyaudio

Based on the wave example from pyaudio:

import pyaudio
import mad
import sys

if len(sys.argv) < 2:
    print "Plays a wave file.\n\n" +\
          "Usage: %s filename.wav" % sys.argv[0]
    sys.exit(-1)

mf = mad.MadFile(sys.argv[1])

p = pyaudio.PyAudio()

# open stream
stream = p.open(format =
                p.get_format_from_width(pyaudio.paInt32),
                channels = 2,
                rate = mf.samplerate(),
                output = True)

# read data
data = mf.read()

# play stream
while data != None:
    stream.write(data)
    data = mf.read()

stream.close()
p.terminate()

Crash on object deletion in pyao and pyogg

The author of pyogg goofed up on python object deletion in the wrapper. This was reported.

Unfortunately libao (0.82) is also affected, and there’s no action even on the previous pyogg bug. It causes a “glibc double-free” on Linux and a “pointer being freed was not allocated” on Mac OS X.

The project seems quite dead, but is merely a wrapper to the C libs where the real action takes place, so there’s not much of a fuss to have it unmaintained.

Here is the patch against pyao:

--- src/aomodule.c.orig 2010-04-07 19:06:45.000000000 +0200
+++ src/aomodule.c  2010-04-07 19:06:56.000000000 +0200
@@ -150,7 +150,7 @@
 py_ao_dealloc(ao_Object *self)
 {
   ao_close(self->dev);
-  PyMem_DEL(self);
+  PyObject_DEL(self);
 }

 static PyObject *

And for reference, the patch against pyogg:

Index: legacy/pyvorbis/pyvorbisfile.c
===================================================================
--- legacy/pyvorbis/pyvorbisfile.c  (revision 20)
+++ legacy/pyvorbis/pyvorbisfile.c  (working copy)
@@ -173,8 +173,7 @@
   if (ret == NULL) {
     PyMem_DEL(newobj);
     return NULL;
-  } else
-    Py_DECREF(ret);
+  }

   return (PyObject *) newobj;
 }
@@ -191,11 +190,13 @@
        close */
     Py_DECREF(py_self->py_file);
   } else {
-    /* Otherwise, we opened the file and should close it. */
-    fclose(py_self->c_file);
+    /* Do NOT close the file -- ov_open() takes ownership of the FILE*,
+       and ov_close() is responsible for closing it. */
   }

-  PyMem_DEL(self);
+  free(py_self->ovf);
+
+  PyObject_DEL(self);
 }

 static PyObject *