Changes over dmix: 1.0.11rc4 and future
Hi,
it looks like the 1.0.11rc4 announcement isn't sent out, so here I'd like to explain what has been changed over dmix recently.
As of 1.0.11rc4, dmix accepts more flexible buffer sizes than the earlier versions did. The buffer size is basically arbitrary. The only restriction is that it's aligned to the period size, and the minimal periods are two.
With this change, some applications have positive influences, and some have negative. The regression, for example with speaker-test, happens because there was no upper limit of buffer size. It's already fixed in the CVS version (by setting max periods = 1024).
If you have a problem with dmix what didn't happen ago, try to define
defaults.pcm.dmix_variable_buffer false
in ~/.asoundrc.
Also, you can try ALSA CVS version. It includes more fixes about the dmix. Or wait for ALSA 1.0.11-final, which (hopefully) will be released soon.
So far so good. Now, about the future changes.
Currently, dmix forks a resource server to share the opened file descriptor. (Don't misunderstand, it's not a mixing server but just manages the file descriptor.) This behavior seems causing troubles in some applications. I've been trying to reduce this mess.
The below (first one) is a patch to add O_APPEND support to PCM. If a PCM is opened with O_APPEND, it shares the alreay opened stream. And the second patch is to alsa-lib to use this new O_APPEND feature. Since the resource can be shared via O_APPEND, we don't need dmix server.
I'm not sure whether it's a 2.6.17 material or a post-2.6.17. Maybe we need a bit discussion whether this O_APPEND hack is right or not.
Beware that the patch is against the very latest CVS version. The anon tree doesn't have it yet right now.
Any comments or test reports are appreciated.
For further implementation, we could get rid of shared memory by a small addition to the kernel, too. At least, two different things would be needed:
- Missing GET_HW_PARAMS and GET_SW_PARAMS ioctls
(Why don't we have them?)
- Anonymous mmap for the shared sum area of dmix
This requires more detailed discussion, I think.
Takashi
Index: alsa-kernel/core/pcm.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/pcm.c,v retrieving revision 1.63
core/pcm.c +23 -2
@@ -829,6 +829,26 @@return -EINVAL ; } +if (file->f_flags &O_APPEND ) { +if (prefer_subdevice <0 ) { +if (pstr->substream_count >1 ) +return -EINVAL ;/* must be unique */ + substream = pstr->substream; + }else { +for (substream = pstr->substream; substream; + substream = substream->next) +if (substream->number == prefer_subdevice) +break ; + } +if (! substream) +return -ENODEV ; +if (!SUBSTREAM_BUSY (substream)) +return -EBADFD ; + substream->ref_count++; + *rsubstream = substream; +return 0 ; + } +if (prefer_subdevice >=0 ) {for (substream = pstr->substream; substream; substream = substream->next)if (!SUBSTREAM_BUSY (substream) && substream->number == prefer_subdevice)
@@ -873,7 +893,8 @@ substream->runtime = runtime; substream->private_data = pcm->private_data; - substream->ffile = file; + substream->ref_count =1 ; + substream->f_flags = file->f_flags; pstr->substream_opened++; *rsubstream = substream;return 0 ;
@@ -882,7 +903,7 @@void snd_pcm_detach_substream (struct snd_pcm_substream *substream) {struct snd_pcm_runtime *runtime; - substream->file =NULL ; + runtime = substream->runtime;snd_assert (runtime !=NULL , return);if (runtime->private_free !=NULL )
Index: alsa-kernel/core/pcm_lib.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/pcm_lib.c,v retrieving revision 1.71
core/pcm_lib.c +4 -4
@@ -2299,7 +2299,7 @@if (runtime->status->state ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; - nonblock = !!(substream->ffile->f_flags &O_NONBLOCK ); + nonblock = !!(substream->f_flags &O_NONBLOCK );if (runtime->access !=SNDRV_PCM_ACCESS_RW_INTERLEAVED && runtime->channels >1 )
@@ -2362,7 +2362,7 @@if (runtime->status->state ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; - nonblock = !!(substream->ffile->f_flags &O_NONBLOCK ); + nonblock = !!(substream->f_flags &O_NONBLOCK );if (runtime->access !=SNDRV_PCM_ACCESS_RW_NONINTERLEAVED )return -EINVAL ;
@@ -2572,7 +2572,7 @@if (runtime->status->state ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; - nonblock = !!(substream->ffile->f_flags &O_NONBLOCK ); + nonblock = !!(substream->f_flags &O_NONBLOCK );if (runtime->access !=SNDRV_PCM_ACCESS_RW_INTERLEAVED )return -EINVAL ;return snd_pcm_lib_read1 (substream, (unsigned long )buf, size, nonblock, snd_pcm_lib_read_transfer);
@@ -2629,7 +2629,7 @@if (runtime->status->state ==SNDRV_PCM_STATE_OPEN )return -EBADFD ; - nonblock = !!(substream->ffile->f_flags &O_NONBLOCK ); + nonblock = !!(substream->f_flags &O_NONBLOCK );if (runtime->access !=SNDRV_PCM_ACCESS_RW_NONINTERLEAVED )return -EINVAL ;return snd_pcm_lib_read1 (substream, (unsigned long )bufs, frames, nonblock, snd_pcm_lib_readv_transfer);
Index: alsa-kernel/core/pcm_native.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/pcm_native.c,v retrieving revision 1.114
core/pcm_native.c +55 -26
185 lines not on this page · raw message
Index: alsa-kernel/core/oss/pcm_oss.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/core/oss/pcm_oss.c,v retrieving revision 1.91
core/oss/pcm_oss.c +11 -8
@@ -850,7 +850,7 @@if (runtime->oss.period_ptr ==0 || runtime->oss.period_ptr == runtime->oss.buffer_used) runtime->oss.buffer_used =0 ; -else if ((substream->ffile->f_flags &O_NONBLOCK ) !=0 ) +else if ((substream->f_flags &O_NONBLOCK ) !=0 )return xfer >0 ? xfer : -EAGAIN ; } }else {
@@ -863,7 +863,7 @@ buf += tmp; bytes -= tmp; xfer += tmp; -if ((substream->ffile->f_flags &O_NONBLOCK ) !=0 && +if ((substream->f_flags &O_NONBLOCK ) !=0 && tmp != runtime->oss.period_bytes)break ; }
@@ -1101,10 +1101,10 @@* finish sync: drain the buffer */ __direct: - saved_f_flags = substream->ffile->f_flags; - substream->ffile->f_flags &= ~O_NONBLOCK ; + saved_f_flags = substream->f_flags; + substream->f_flags &= ~O_NONBLOCK ; err =snd_pcm_kernel_ioctl (substream,SNDRV_PCM_IOCTL_DRAIN ,NULL ); - substream->ffile->f_flags = saved_f_flags; + substream->f_flags = saved_f_flags;if (err <0 )return err; runtime->oss.prepare =1 ;
@@ -1681,9 +1681,9 @@ substream->oss.oss =1 ; substream->oss.setup = *setup;if (setup->nonblock) - substream->ffile->f_flags |=O_NONBLOCK ; -else - substream->ffile->f_flags &= ~O_NONBLOCK ; + substream->f_flags |=O_NONBLOCK ; +else if (setup->block) + substream->f_flags &= ~O_NONBLOCK ; runtime = substream->runtime; runtime->oss.params =1 ; runtime->oss.trigger =1 ;
@@ -1740,6 +1740,7 @@ (pcm->info_flags & SNDRV_PCM_INFO_HALF_DUPLEX)) f_mode =FMODE_WRITE ; + file->f_flags &= ~O_APPEND ;for (idx =0 ; idx <2 ; idx++) {if (setup[idx].disable)continue ;
@@ -2056,6 +2057,7 @@ substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE ];if (substream ==NULL )return -ENXIO ; + substream->f_flags = file->f_flags &O_NONBLOCK ;#ifndef OSS_DEBUG return snd_pcm_oss_read1 (substream, buf, count);#else
@@ -2077,6 +2079,7 @@ substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK ];if (substream ==NULL )return -ENXIO ; + substream->f_flags = file->f_flags &O_NONBLOCK ; result =snd_pcm_oss_write1 (substream, buf, count);#ifdef OSS_DEBUG printk ("pcm_oss: write %li bytes (wrote %li bytes)\n" , (long )count, (long )result);
Index: alsa-kernel/include/asound.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/include/asound.h,v retrieving revision 1.48
include/asound.h +1 -1
@@ -137,7 +137,7 @@* * *****************************************************************************/ -#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 7) +#define SNDRV_PCM_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8)typedef unsigned long snd_pcm_uframes_t ;typedef signed long snd_pcm_sframes_t ;
Index: alsa-kernel/include/pcm.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/include/pcm.h,v retrieving revision 1.66
include/pcm.h +3 -2
@@ -368,7 +368,8 @@struct snd_pcm_group *group;/* pointer to current group */ /* -- assigned files -- */ struct snd_pcm_file *file; -struct file *ffile; +int ref_count; +unsigned int f_flags;void (*pcm_release)(struct snd_pcm_substream *);#if defined(CONFIG_SND_PCM_OSS ) || defined(CONFIG_SND_PCM_OSS_MODULE )/* -- OSS things -- */
@@ -385,7 +386,7 @@ unsigned int hw_opened: 1; }; -#define SUBSTREAM_BUSY (substream) ((substream)->file != NULL) +#define SUBSTREAM_BUSY (substream) ((substream)->ref_count > 0)struct snd_pcm_str {
Index: alsa-kernel/usb/usx2y/usx2yhwdeppcm.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-kernel/usb/usx2y/usx2yhwdeppcm.c,v retrieving revision 1.10
usb/usx2y/usx2yhwdeppcm.c +1 -1
@@ -632,7 +632,7 @@for (s =0 ; s <2 ; ++s) {struct snd_pcm_substream *substream; substream = pcm->streams[s].substream; -if (substream && substream->ffile !=NULL ) +if (SUBSTREAM_BUSY (substream)) err = -EBUSY ; } }
Index: alsa-lib/src/pcm/pcm_direct.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_direct.c,v retrieving revision 1.57
src/pcm/pcm_direct.c +46 -0
71 lines not on this page · raw message
Index: alsa-lib/src/pcm/pcm_direct.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_direct.h,v retrieving revision 1.22
src/pcm/pcm_direct.h +3 -0
@@ -51,8 +51,10 @@ }; typedef struct { + unsigned int magic; /* magic number */ char socket_name[256]; /* name of communication socket */ snd_pcm_type_t type; /* PCM type (currently only hw) */ + int use_server; struct { unsigned int format; snd_interval_t rate;
@@ -168,6 +170,7 @@int snd_pcm_direct_client_connect (snd_pcm_direct_t *dmix);int snd_pcm_direct_client_discard (snd_pcm_direct_t *dmix);int snd_pcm_direct_initialize_slave (snd_pcm_direct_t *dmix,snd_pcm_t *spcm,struct slave_params *params); +int snd_pcm_direct_initialize_secondary_slave (snd_pcm_direct_t *dmix,snd_pcm_t *spcm,struct slave_params *params);int snd_pcm_direct_initialize_poll_fd (snd_pcm_direct_t *dmix);int snd_pcm_direct_check_interleave (snd_pcm_direct_t *dmix,snd_pcm_t *pcm);int snd_pcm_direct_parse_bindings (snd_pcm_direct_t *dmix,snd_config_t *cfg);
Index: alsa-lib/src/pcm/pcm_dmix.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dmix.c,v retrieving revision 1.72
src/pcm/pcm_dmix.c +46 -18
82 lines not on this page · raw message
Index: alsa-lib/src/pcm/pcm_dshare.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dshare.c,v retrieving revision 1.37
src/pcm/pcm_dshare.c +46 -18
81 lines not on this page · raw message
Index: alsa-lib/src/pcm/pcm_dsnoop.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dsnoop.c,v retrieving revision 1.37
src/pcm/pcm_dsnoop.c +45 -17
80 lines not on this page · raw message
Index: alsa-lib/src/pcm/pcm_hw.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_hw.c,v retrieving revision 1.113
src/pcm/pcm_hw.c +2 -0
@@ -1233,6 +1233,8 @@ fmode |=O_NONBLOCK ;if (mode &SND_PCM_ASYNC ) fmode |=O_ASYNC ; +if (mode &SND_PCM_APPEND ) + fmode |=O_APPEND ; fd =snd_open_device (filename, fmode);if (fd <0 ) { ret = -errno;
Index: alsa-lib/src/pcm/pcm_local.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_local.h,v retrieving revision 1.100
src/pcm/pcm_local.h +2 -0
@@ -746,6 +746,8 @@int snd_pcm_slave_conf (snd_config_t *root,snd_config_t *conf,snd_config_t **pcm_conf,unsigned int count, ...); +#define SND_PCM_APPEND (1<<8) +int snd_pcm_open_slave (snd_pcm_t **pcmp,snd_config_t *root,snd_config_t *conf,snd_pcm_stream_t stream,int mode,snd_config_t *parent_conf);
Quoted 52 lines · Takashi Iwai
Hi,
it looks like the 1.0.11rc4 announcement isn't sent out, so here I'd like to explain what has been changed over dmix recently.
As of 1.0.11rc4, dmix accepts more flexible buffer sizes than the earlier versions did. The buffer size is basically arbitrary. The only restriction is that it's aligned to the period size, and the minimal periods are two.
With this change, some applications have positive influences, and some have negative. The regression, for example with speaker-test, happens because there was no upper limit of buffer size. It's already fixed in the CVS version (by setting max periods = 1024).
If you have a problem with dmix what didn't happen ago, try to define
defaults.pcm.dmix_variable_buffer false
in ~/.asoundrc.
Also, you can try ALSA CVS version. It includes more fixes about the dmix. Or wait for ALSA 1.0.11-final, which (hopefully) will be released soon.
So far so good. Now, about the future changes.
Currently, dmix forks a resource server to share the opened file descriptor. (Don't misunderstand, it's not a mixing server but just manages the file descriptor.) This behavior seems causing troubles in some applications. I've been trying to reduce this mess.
The below (first one) is a patch to add
O_APPENDsupport to PCM. If a PCM is opened withO_APPEND, it shares the alreay opened stream. And the second patch is to alsa-lib to use this newO_APPENDfeature. Since the resource can be shared viaO_APPEND, we don't need dmix server.I'm not sure whether it's a 2.6.17 material or a post-2.6.17. Maybe we need a bit discussion whether this
O_APPENDhack is right or not.Beware that the patch is against the very latest CVS version. The anon tree doesn't have it yet right now.
Any comments or test reports are appreciated.
For further implementation, we could get rid of shared memory by a small addition to the kernel, too. At least, two different things would be needed:
Quoted 8 lines
- Missing
GET_HW_PARAMSandGET_SW_PARAMSioctls
(Why don't we have them?)
- Anonymous mmap for the shared sum area of dmixThis requires more detailed discussion, I think.
Takashi
This all sounds good. I will test the dmix buffer size improvement. I remember asking for this some time ago.
This might fix problems people are having with Doom3 and the like.
James
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
Quoted 15 lines · Takashi Iwai
Hi,
it looks like the 1.0.11rc4 announcement isn't sent out, so here I'd like to explain what has been changed over dmix recently.
As of 1.0.11rc4, dmix accepts more flexible buffer sizes than the earlier versions did. The buffer size is basically arbitrary. The only restriction is that it's aligned to the period size, and the minimal periods are two.
With this change, some applications have positive influences, and some have negative. The regression, for example with speaker-test, happens because there was no upper limit of buffer size. It's already fixed in the CVS version (by setting max periods = 1024).
Quoted 6 lines
If you have a problem with dmix what didn't happen ago, try to define
defaults.pcm.dmix_variable_buffer false
in ~/.asoundrc.
Does not work (alsa-lib and utils from today's CVS):
$ aplay -Dplug:dmix51 /usr/share/sounds/error.wav ALSA lib pcm.c:6650:(snd_pcm_slave_conf) Unknown field variable_buffer_size aplay: main:547: audio open error: Invalid argument
.asoundrc:
defaults.pcm.dmix_variable_buffer false
pcm.dmix51 {
type upmix
slave.pcm {
type dmix
ipc_key {
@func refer
name defaults.pcm.ipc_key
}
ipc_gid {
@func refer
name defaults.pcm.ipc_gid
}
slave {
pcm "hw:0,0"
period_size 512
periods 10
channels 6
variable_buffer_size true
}
}
}Lee
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
At Sat, 01 Apr 2006 14:19:13 -0500,
Quoted 47 lines · Lee Revell
Quoted 15 lines · Takashi Iwai
Hi,
it looks like the 1.0.11rc4 announcement isn't sent out, so here I'd like to explain what has been changed over dmix recently.
As of 1.0.11rc4, dmix accepts more flexible buffer sizes than the earlier versions did. The buffer size is basically arbitrary. The only restriction is that it's aligned to the period size, and the minimal periods are two.
With this change, some applications have positive influences, and some have negative. The regression, for example with speaker-test, happens because there was no upper limit of buffer size. It's already fixed in the CVS version (by setting max periods = 1024).
Quoted 6 lines
If you have a problem with dmix what didn't happen ago, try to define
defaults.pcm.dmix_variable_buffer false
in ~/.asoundrc.
Does not work (alsa-lib and utils from today's CVS):
$ aplay -Dplug:dmix51 /usr/share/sounds/error.wav ALSA lib pcm.c:6650:(snd_pcm_slave_conf) Unknown field variable_buffer_size aplay: main:547: audio open error: Invalid argument.asoundrc:
defaults.pcm.dmix_variable_buffer false
pcm.dmix51 { type upmix slave.pcm { type dmix ipc_key { @func refer name defaults.pcm.ipc_key } ipc_gid { @func refer name defaults.pcm.ipc_gid } slave {
Quoted 8 lines
pcm "hw:0,0"
period_size 512
periods 10
channels 6
variable_buffer_size true
}
}
}My bad, a syntax error in the dmix51 definition I posted.
pcm.dmix51 {
type upmix
slave.pcm {
type dmix
ipc_key {
@func refer
name defaults.pcm.ipc_key
}
ipc_gid {
@func refer
name defaults.pcm.ipc_gid
}
slave {
pcm "hw:0,0"
period_size 512
periods 10
channels 6
}
variable_buffer_size true
}
}If you still get an error regarding variable_buffer_size, just remove that line.
And note that this won't work with emu10k1.
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
Quoted 5 lines · Takashi Iwai
If you still get an error regarding
variable_buffer_size, just remove that line.And note that this won't work with emu10k1.
I now get:
Playing WAVE '/usr/share/sounds/error.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
ALSA lib pcm_params.c:2152:(snd_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:879: Broken configuration for this PCM: no configurations available
Which I think is normal as hw:0,0 on the emu10k1 is only a stereo device.
Lee
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
At Mon, 03 Apr 2006 12:29:25 -0400,
Quoted 17 lines · Lee Revell
Quoted 5 lines · Takashi Iwai
If you still get an error regarding
variable_buffer_size, just remove that line.And note that this won't work with emu10k1.
I now get:
Playing WAVE '
/usr/share/sounds/error.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
ALSA lib pcm_params.c:2152:(snd_pcm_hw_refine_slave) Slave PCM not usable
aplay: set_params:879: Broken configuration for this PCM: no configurations available
Quoted 2 lines
Which I think is normal as hw:0,0 on the emu10k1 is only a stereo device.
Yes, exactly.
I'll make a patch to support dmix on multiple hw streams, but it'll be after 1.0.11-final release... Or, at least, after cvs on sourceforge gets back. I already have too many pending patches on my local tree.
Takashi
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
At Mon, 27 Mar 2006 18:35:47 +0200,
Quoted 18 lines · I wrote:
Hi,
it looks like the 1.0.11rc4 announcement isn't sent out, so here I'd like to explain what has been changed over dmix recently.
As of 1.0.11rc4, dmix accepts more flexible buffer sizes than the earlier versions did. The buffer size is basically arbitrary. The only restriction is that it's aligned to the period size, and the minimal periods are two.
With this change, some applications have positive influences, and some have negative. The regression, for example with speaker-test, happens because there was no upper limit of buffer size. It's already fixed in the CVS version (by setting max periods = 1024).
If you have a problem with dmix what didn't happen ago, try to define
Quoted 7 lines
defaults.pcm.dmix_variable_buffer false
in ~/.asoundrc.
Also, you can try ALSA CVS version. It includes more fixes about the dmix. Or wait for ALSA 1.0.11-final, which (hopefully) will be released soon.
It seems that some applications don't like the dmix buffer bigger than the actual buffer of slave PCM. The below is a patch to fix. (It's not in CVS since CVS tree is stilll broken...)
Now, "variable_buffer_size" option is removed, and another new option,
"max_periods" is introduced. This specifies the max periods
available for the pcm. Specifying -1 means to stick with the slave PCM, i.e. the old behavior. Specifying 0 (or 1) means to limit the max periods to slave periods.
The default size is defined as "defaults.pcm.dmix_max_periods". It's defined as 0 in /usr/share/alsa/alsa.conf, and can be overridden by a definition in ~/.asoundrc or /etc/asound.conf.
Anyhow, usually you don't have to take care of this option. It should work as it is.
The O_APPEND patch in my early mail can be applied on this, too.
Takashi
Index: alsa-lib/src/conf/alsa.conf
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/conf/alsa.conf,v retrieving revision 1.26
src/conf/alsa.conf +1 -1
@@ -57,7 +57,7 @@ defaults.pcm.ipc_key 5678293 defaults.pcm.ipc_gid audio defaults.pcm.ipc_perm 0660 -defaults.pcm.dmix_variable_buffer true +defaults.pcm.dmix_max_periods 0 defaults.pcm.front.card defaults.pcm.card defaults.pcm.front.device defaults.pcm.device defaults.pcm.rear.card defaults.pcm.card
Index: alsa-lib/src/conf/pcm/dmix.conf
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/conf/pcm/dmix.conf,v retrieving revision 1.11
src/conf/pcm/dmix.conf +0 -5
@@ -92,9 +92,4 @@ default 16 } } - # Allow apps different buffer sizes - variable_buffer_size { - @func refer - name defaults.pcm.dmix_variable_buffer - } }
Index: alsa-lib/src/pcm/pcm_direct.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_direct.c,v retrieving revision 1.57
src/pcm/pcm_direct.c +30 -14
99 lines not on this page · raw message
Index: alsa-lib/src/pcm/pcm_direct.h
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_direct.h,v retrieving revision 1.22
src/pcm/pcm_direct.h +3 -4
@@ -117,7 +117,7 @@snd_timer_t *timer;/* timer used as poll_fd */ int interleaved;/* we have interleaved buffer */ int slowptr;/* use slow but more precise ptr updates */ -int variable_buffer_size;/* allow the variable buffer size */ +int max_periods;/* max periods (-1 = fixed periods, 0 = max buffer size) */ unsigned int channels;/* client's channels */ unsigned int *bindings;union {
@@ -187,7 +187,6 @@void snd_pcm_direct_clear_timer_queue (snd_pcm_direct_t *dmix);int snd_pcm_direct_set_timer_params (snd_pcm_direct_t *dmix);int snd_pcm_direct_open_secondary_client (snd_pcm_t **spcmp,snd_pcm_direct_t *dmix,const char *client_name); -int snd_pcm_direct_get_slave_ipc_offset (snd_config_t *root,snd_config_t *sconf,int direction);int snd_timer_async (snd_timer_t *timer,int sig,pid_t pid);struct timespec snd_pcm_hw_fast_tstamp (snd_pcm_t *pcm);
@@ -197,9 +196,9 @@mode_t ipc_perm;int ipc_gid;int slowptr; -int variable_buffer_size; +int max_periods;snd_config_t *slave;snd_config_t *bindings; }; -int snd_pcm_direct_parse_open_conf (snd_config_t *conf,struct snd_pcm_direct_open_conf *rec); +int snd_pcm_direct_parse_open_conf (snd_config_t *root,snd_config_t *conf,int stream,struct snd_pcm_direct_open_conf *rec);
Index: alsa-lib/src/pcm/pcm_dmix.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dmix.c,v retrieving revision 1.72
src/pcm/pcm_dmix.c +4 -12
@@ -437,6 +437,7 @@if (err <0 )return err;/* fallthru */ +snd_pcm_dmix_sync_area (pcm);case SNDRV_PCM_STATE_PREPARED :case SNDRV_PCM_STATE_SUSPENDED :case STATE_RUN_PENDING :
@@ -487,8 +488,7 @@static void reset_slave_ptr (snd_pcm_t *pcm,snd_pcm_direct_t *dmix) { dmix->slave_appl_ptr = dmix->slave_hw_ptr = *dmix->spcm->hw.ptr; -if (! dmix->variable_buffer_size || - pcm->buffer_size > pcm->period_size *2 ) +if (pcm->buffer_size > pcm->period_size *2 )return ;/* If we have too litte periods, better to align the start position * to the period boundary so that the interrupt can be handled properly
@@ -851,7 +851,7 @@ pcm->private_data = dmix; dmix->state =SND_PCM_STATE_OPEN ; dmix->slowptr = opts->slowptr; - dmix->variable_buffer_size = opts->variable_buffer_size; + dmix->max_periods = opts->max_periods; dmix->sync_ptr = snd_pcm_dmix_sync_ptr;if (first_instance) {
@@ -1092,10 +1092,9 @@struct slave_params params;struct snd_pcm_direct_open_conf dopen;int bsize, psize; -int ipc_offset;int err; - err =snd_pcm_direct_parse_open_conf (conf, &dopen); + err =snd_pcm_direct_parse_open_conf (root, conf, stream, &dopen);if (err <0 )return err;
@@ -1134,13 +1133,6 @@ params.period_size = psize; params.buffer_size = bsize; - ipc_offset =snd_pcm_direct_get_slave_ipc_offset (root, sconf, stream); -if (ipc_offset <0 ) { -snd_config_delete (sconf); -return ipc_offset; - } - dopen.ipc_key += ipc_offset; - err =snd_pcm_dmix_open (pcmp, name, &dopen, ¶ms, root, sconf, stream, mode);if (err <0 )
Index: alsa-lib/src/pcm/pcm_dshare.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dshare.c,v retrieving revision 1.37
src/pcm/pcm_dshare.c +2 -10
@@ -662,7 +662,7 @@ pcm->private_data = dshare; dshare->state =SND_PCM_STATE_OPEN ; dshare->slowptr = opts->slowptr; - dshare->variable_buffer_size = opts->variable_buffer_size; + dshare->max_periods = opts->max_periods; dshare->sync_ptr = snd_pcm_dshare_sync_ptr;if (first_instance) {
@@ -835,10 +835,9 @@struct slave_params params;struct snd_pcm_direct_open_conf dopen;int bsize, psize; -int ipc_offset;int err; - err =snd_pcm_direct_parse_open_conf (conf, &dopen); + err =snd_pcm_direct_parse_open_conf (root, conf, stream, &dopen);if (err <0 )return err;
@@ -869,13 +868,6 @@ params.period_size = psize; params.buffer_size = bsize; - ipc_offset =snd_pcm_direct_get_slave_ipc_offset (root, sconf, stream); -if (ipc_offset <0 ) { -snd_config_delete (sconf); -return ipc_offset; - } - dopen.ipc_key += ipc_offset; - err =snd_pcm_dshare_open (pcmp, name, &dopen, ¶ms, root, sconf, stream, mode);if (err <0 )
Index: alsa-lib/src/pcm/pcm_dsnoop.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_dsnoop.c,v retrieving revision 1.37
src/pcm/pcm_dsnoop.c +2 -10
@@ -544,7 +544,7 @@ pcm->private_data = dsnoop; dsnoop->state =SND_PCM_STATE_OPEN ; dsnoop->slowptr = opts->slowptr; - dsnoop->variable_buffer_size = opts->variable_buffer_size; + dsnoop->max_periods = opts->max_periods; dsnoop->sync_ptr = snd_pcm_dsnoop_sync_ptr;if (first_instance) {
@@ -707,10 +707,9 @@struct slave_params params;struct snd_pcm_direct_open_conf dopen;int bsize, psize; -int ipc_offset;int err; - err =snd_pcm_direct_parse_open_conf (conf, &dopen); + err =snd_pcm_direct_parse_open_conf (root, conf, stream, &dopen);if (err <0 )return err;
@@ -741,13 +740,6 @@ params.period_size = psize; params.buffer_size = bsize; - ipc_offset =snd_pcm_direct_get_slave_ipc_offset (root, sconf, stream); -if (ipc_offset <0 ) { -snd_config_delete (sconf); -return ipc_offset; - } - dopen.ipc_key += ipc_offset; - err =snd_pcm_dsnoop_open (pcmp, name, &dopen, ¶ms, root, sconf, stream, mode);if (err <0 )
Index: alsa-lib/src/pcm/pcm_rate.c
===================================================================
RCS file: /home/iwai/cvs/alsa/alsa-lib/src/pcm/pcm_rate.c,v retrieving revision 1.88
src/pcm/pcm_rate.c +5 -0
@@ -617,7 +617,12 @@static int snd_pcm_rate_delay (snd_pcm_t *pcm,snd_pcm_sframes_t *delayp) { +snd_pcm_rate_t *rate = pcm->private_data;snd_pcm_rate_hwsync (pcm); +/* call slave's delay callback although the value is overwritten. +* it's needed for a better sync of dmix on aoss. +*/ +snd_pcm_delay (rate->gen.slave, delayp);if (pcm->stream ==SND_PCM_STREAM_PLAYBACK ) *delayp =snd_pcm_mmap_playback_hw_avail (pcm);else
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642