All of lore.kernel.org
 help / color / mirror / Atom feed
* Mixer chanel naming
@ 2002-03-08 13:01 Kasparek Tomas
  2002-03-08 14:26 ` Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kasparek Tomas @ 2002-03-08 13:01 UTC (permalink / raw)
  To: alsa-devel

Hi,

I've just started writing driver for Compaq iPAQ and I'm feel realy dizzy
from setting the mixer. Here is part of code:

...
static snd_kcontrol_new_t snd_h3600_controls[] = {
H3600_SINGLE("Master Playback Switch", H3600_MASTER, 15, 1, 1),
H3600_DOUBLE("Master Playback Volume", H3600_MASTER, 8, 0, 31, 1),
...

First argument is used for "name" item of snd_kcontrol_new_t structure.
It look like the name is significant when configuring this new control.

(e.g. without "playback", alsamixer shows two devices for one entry)

Where should I find information of possible names and mainly their
meaning? How functionality of such defined control depends on this name?

Thanks

--

	Tomas Kasparek (sioux, xkaspa06)
 	 Tomas.Kasparek@[seznam.cz,volny.cz]
	 Linux@dcse.fee.vutbr.cz
	student UIVT FEI VUT Brno


_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* Re: Mixer chanel naming
  2002-03-08 13:01 Mixer chanel naming Kasparek Tomas
@ 2002-03-08 14:26 ` Takashi Iwai
  2002-03-08 16:22 ` Jaroslav Kysela
  2002-04-11 15:16 ` PATCH: snd_pcm_playback_silence Sander van Leeuwen
  2 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2002-03-08 14:26 UTC (permalink / raw)
  To: Kasparek Tomas; +Cc: alsa-devel

Hi,

At Fri, 8 Mar 2002 14:01:30 +0100 (CET),
Kasparek Tomas wrote:
> 
> Hi,
> 
> I've just started writing driver for Compaq iPAQ and I'm feel realy dizzy
> from setting the mixer. Here is part of code:
> 
> ...
> static snd_kcontrol_new_t snd_h3600_controls[] = {
> H3600_SINGLE("Master Playback Switch", H3600_MASTER, 15, 1, 1),
> H3600_DOUBLE("Master Playback Volume", H3600_MASTER, 8, 0, 31, 1),
> ...
> 
> First argument is used for "name" item of snd_kcontrol_new_t structure.
> It look like the name is significant when configuring this new control.
> 
> (e.g. without "playback", alsamixer shows two devices for one entry)
> 
> Where should I find information of possible names and mainly their
> meaning? How functionality of such defined control depends on this name?

check out alsa-driver/doc/ControlNames.


Takashi

_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* Re: Mixer chanel naming
  2002-03-08 13:01 Mixer chanel naming Kasparek Tomas
  2002-03-08 14:26 ` Takashi Iwai
@ 2002-03-08 16:22 ` Jaroslav Kysela
  2002-04-11 15:16 ` PATCH: snd_pcm_playback_silence Sander van Leeuwen
  2 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Kysela @ 2002-03-08 16:22 UTC (permalink / raw)
  To: Kasparek Tomas; +Cc: alsa-devel@lists.sourceforge.net

On Fri, 8 Mar 2002, Kasparek Tomas wrote:

> Hi,
> 
> I've just started writing driver for Compaq iPAQ and I'm feel realy dizzy
> from setting the mixer. Here is part of code:
> 
> ...
> static snd_kcontrol_new_t snd_h3600_controls[] = {
> H3600_SINGLE("Master Playback Switch", H3600_MASTER, 15, 1, 1),
> H3600_DOUBLE("Master Playback Volume", H3600_MASTER, 8, 0, 31, 1),
> ...
> 
> First argument is used for "name" item of snd_kcontrol_new_t structure.
> It look like the name is significant when configuring this new control.
> 
> (e.g. without "playback", alsamixer shows two devices for one entry)
> 
> Where should I find information of possible names and mainly their
> meaning? How functionality of such defined control depends on this name?

The recommended names for controls are defined in 
the alsa-driver/doc/ControlNames document (should be probably moved to 
alsa-kernel/Documentation).

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project  http://www.alsa-project.org
SuSE Linux    http://www.suse.com


_______________________________________________
Alsa-devel mailing list
Alsa-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-devel

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

* PATCH: snd_pcm_playback_silence
  2002-03-08 13:01 Mixer chanel naming Kasparek Tomas
  2002-03-08 14:26 ` Takashi Iwai
  2002-03-08 16:22 ` Jaroslav Kysela
@ 2002-04-11 15:16 ` Sander van Leeuwen
  2002-04-12  7:06   ` Jaroslav Kysela
  2 siblings, 1 reply; 5+ messages in thread
From: Sander van Leeuwen @ 2002-04-11 15:16 UTC (permalink / raw)
  To: alsa-devel@lists.sourceforge.net

Hi,

I'm currently porting ALSA to OS/2 and have encountered a bug in
snd_pcm_playback_silence (core\pcm_lib.c)
While playing an 8 bits stereo 44.1khz wave file the system
would trap when stopping the stream. The cause was heap
corruption caused by this function. There is no check to
see if the offset + amount of frames to silence is larger
than the buffer size.
The patch below fixes this.

Sander



--- E:\Development\ALSA.Linux\alsa-kernel\core\pcm_lib.c	Wed Apr 10 21:55:18 2002
+++ E:\Development\ALSA.OS2\GPL\alsa\core\pcm_lib.c	Thu Apr 11 17:01:38 2002
@@ -60,6 +56,12 @@
 	ofs = runtime->silenced_start % runtime->buffer_size + runtime->silenced_size;
 	if (ofs >= runtime->buffer_size)
 		ofs -= runtime->buffer_size;
+#ifdef TARGET_OS2
+        if (ofs + frames > runtime->buffer_size) {
+                frames = runtime->buffer_size - ofs;
+        }
+#endif
 	if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
 	    runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
 		if (substream->ops->silence) {

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

* Re: PATCH: snd_pcm_playback_silence
  2002-04-11 15:16 ` PATCH: snd_pcm_playback_silence Sander van Leeuwen
@ 2002-04-12  7:06   ` Jaroslav Kysela
  0 siblings, 0 replies; 5+ messages in thread
From: Jaroslav Kysela @ 2002-04-12  7:06 UTC (permalink / raw)
  To: Sander van Leeuwen; +Cc: alsa-devel@lists.sourceforge.net

On Thu, 11 Apr 2002, Sander van Leeuwen wrote:

> Hi,
> 
> I'm currently porting ALSA to OS/2 and have encountered a bug in
> snd_pcm_playback_silence (core\pcm_lib.c)
> While playing an 8 bits stereo 44.1khz wave file the system
> would trap when stopping the stream. The cause was heap
> corruption caused by this function. There is no check to
> see if the offset + amount of frames to silence is larger
> than the buffer size.
> The patch below fixes this.
> 
> Sander
> 
> 
> 
> --- E:\Development\ALSA.Linux\alsa-kernel\core\pcm_lib.c	Wed Apr 10 21:55:18 2002
> +++ E:\Development\ALSA.OS2\GPL\alsa\core\pcm_lib.c	Thu Apr 11 17:01:38 2002
> @@ -60,6 +56,12 @@
>  	ofs = runtime->silenced_start % runtime->buffer_size + runtime->silenced_size;
>  	if (ofs >= runtime->buffer_size)
>  		ofs -= runtime->buffer_size;
> +#ifdef TARGET_OS2
> +        if (ofs + frames > runtime->buffer_size) {
> +                frames = runtime->buffer_size - ofs;
> +        }
> +#endif
>  	if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
>  	    runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
>  		if (substream->ops->silence) {

Above patch is not perfect, but thank you for pointing to this problem. 
I've applied this fix to CVS:

Index: pcm_lib.c
===================================================================
RCS file: /cvsroot/alsa/alsa-kernel/core/pcm_lib.c,v
retrieving revision 1.9
diff -u -r1.9 pcm_lib.c
--- pcm_lib.c	9 Apr 2002 06:53:35 -0000	1.9
+++ pcm_lib.c	12 Apr 2002 07:04:47 -0000
@@ -34,7 +34,7 @@
 void snd_pcm_playback_silence(snd_pcm_substream_t *substream)
 {
 	snd_pcm_runtime_t *runtime = substream->runtime;
-	snd_pcm_uframes_t frames, ofs;
+	snd_pcm_uframes_t frames, ofs, transfer;
 	snd_pcm_sframes_t noise_dist;
 	if (runtime->silenced_start != runtime->control->appl_ptr) {
 		snd_pcm_sframes_t n = runtime->control->appl_ptr - runtime->silenced_start;
@@ -60,32 +60,36 @@
 	ofs = runtime->silenced_start % runtime->buffer_size + runtime->silenced_size;
 	if (ofs >= runtime->buffer_size)
 		ofs -= runtime->buffer_size;
-	if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
-	    runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
-		if (substream->ops->silence) {
-			int err;
-			err = substream->ops->silence(substream, -1, ofs, frames);
-			snd_assert(err >= 0, );
-		} else {
-			char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs);
-			snd_pcm_format_set_silence(runtime->format, hwbuf, frames * runtime->channels);
-		}
-	} else {
-		unsigned int c;
-		unsigned int channels = runtime->channels;
-		if (substream->ops->silence) {
-			for (c = 0; c < channels; ++c) {
+	while (frames > 0) {
+		transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames;
+		if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED ||
+		    runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) {
+			if (substream->ops->silence) {
 				int err;
-				err = substream->ops->silence(substream, c, ofs, frames);
+				err = substream->ops->silence(substream, -1, ofs, transfer);
 				snd_assert(err >= 0, );
+			} else {
+				char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs);
+				snd_pcm_format_set_silence(runtime->format, hwbuf, transfer * runtime->channels);
 			}
 		} else {
-			size_t dma_csize = runtime->dma_bytes / channels;
-			for (c = 0; c < channels; ++c) {
-				char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, ofs);
-				snd_pcm_format_set_silence(runtime->format, hwbuf, frames);
+			unsigned int c;
+			unsigned int channels = runtime->channels;
+			if (substream->ops->silence) {
+				for (c = 0; c < channels; ++c) {
+					int err;
+					err = substream->ops->silence(substream, c, ofs, transfer);
+					snd_assert(err >= 0, );
+				}
+			} else {
+				size_t dma_csize = runtime->dma_bytes / channels;
+				for (c = 0; c < channels; ++c) {
+					char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, ofs);
+					snd_pcm_format_set_silence(runtime->format, hwbuf, transfer);
+				}
 			}
 		}
+		frames -= transfer;
 	}
 	runtime->silenced_size += frames;
 }


						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project  http://www.alsa-project.org
SuSE Linux    http://www.suse.com

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

end of thread, other threads:[~2002-04-12  7:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-08 13:01 Mixer chanel naming Kasparek Tomas
2002-03-08 14:26 ` Takashi Iwai
2002-03-08 16:22 ` Jaroslav Kysela
2002-04-11 15:16 ` PATCH: snd_pcm_playback_silence Sander van Leeuwen
2002-04-12  7:06   ` Jaroslav Kysela

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.