[alsa-devel] about ioctl calls

Lorenzo Fundaró lfundaro at etu.utc.fr
Thu May 26 14:37:31 CEST 2011

Thanks for your reply,

I want to be able to take the samples and do something with them before the
program touches them. To do so, I am overloading the mmap function as

static void* (*_mmap) (void*, size_t, int, int, int, off_t) = NULL;

void* mmap(void* addr, size_t length, int prot, int flags, int fd, off_t
offset) {

  /* First call, load the original mmap function */
  if (_mmap == NULL) {
    _mmap = dlsym(RTLD_NEXT, "mmap");

  /* Trigger original mmap */
  void* result = _mmap(addr, length, prot, flags, fd, offset);

  /* Check if file descriptor fd corresponds to that of the sound card
device */
  if (fd == FD_SOUND_DEVICE) {
    sound.fd = fd;
    sound.size  = length;
    sound.addr  = result;    // I'll later use the data contained within
  return result;

So now that things are clearer, the question will be, what's in the mapped
address returned by mmap ? What's the form of this structure so I can take
the samples and work with them.

Note: I am forced to do this workaround since the program does not give me
any interface to work with the samples.

Cheers !

Lorenzo Fundaró García
Université de Technologie de Compiègne
Génie Informatique
Tel: +33 6 86 69 56 11

On Thu, May 26, 2011 at 12:28 PM, Clemens Ladisch <clemens at ladisch.de>wrote:

> Lorenzo Fundaró wrote:
> > I have a program that constantly make ioctl calls like this:
> >
> > ioctl(4, 0x4122, 0x8b703)
> > ioctl(4, 0x4122, 0xbfb65768)
> >
> > I suspect that this call pertains to ALSA, since I have straced other
> > programs that play music and they always use in the ioctl request field
> the
> > 0x4122 code.
> > I am interested on finding out what's in the third argument of the ioctl
> > call,
> > is it a sort of struct that contains the audio samples ?
> The samples and some control structures are in mmap()ed memory.
> This ioctl tells the kernel to synchronize and update hardware status.
> There is no third parameter; the values shown are random stack contents.
> Regards,
> Clemens

More information about the Alsa-devel mailing list