All of lore.kernel.org
 help / color / mirror / Atom feed
* about ioctl calls
@ 2011-05-26 10:07 Lorenzo Fundaró
  2011-05-26 10:28 ` Clemens Ladisch
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Fundaró @ 2011-05-26 10:07 UTC (permalink / raw)
  To: alsa-devel

Hi folks,

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 ?

Thanks in advance,

Lorenzo Fundaró García
Université de Technologie de Compiègne
Génie Informatique

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about ioctl calls
  2011-05-26 10:07 about ioctl calls Lorenzo Fundaró
@ 2011-05-26 10:28 ` Clemens Ladisch
  2011-05-26 12:37   ` Lorenzo Fundaró
  0 siblings, 1 reply; 3+ messages in thread
From: Clemens Ladisch @ 2011-05-26 10:28 UTC (permalink / raw)
  To: Lorenzo Fundaró; +Cc: alsa-devel

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.

This is SNDRV_PCM_IOCTL_HWSYNC.

> 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
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: about ioctl calls
  2011-05-26 10:28 ` Clemens Ladisch
@ 2011-05-26 12:37   ` Lorenzo Fundaró
  0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Fundaró @ 2011-05-26 12:37 UTC (permalink / raw)
  To: Clemens Ladisch; +Cc: alsa-devel

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
follows:

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
result.
  }
  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@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.
>
> This is SNDRV_PCM_IOCTL_HWSYNC.
>
> > 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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-26 12:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 10:07 about ioctl calls Lorenzo Fundaró
2011-05-26 10:28 ` Clemens Ladisch
2011-05-26 12:37   ` Lorenzo Fundaró

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.