On Thu, 13 Apr 2023 12:16:04 +0200, Oswald Buddenhagen wrote: > > On Thu, Apr 13, 2023 at 07:42:06AM +0200, Takashi Iwai wrote: > > On Wed, 12 Apr 2023 21:59:28 +0200, > > Jaroslav Kysela wrote: > >> This looks like a sane proposal, but some drivers does not require > >> the > >> silencing at all, so we can probably skip this step for them (new > >> SNDRV_PCM_INFO_PERFECT_DRAIN flag?). > > > > Sure, we should apply it only conditionally. > > > i don't think the extra complexity is justified. with my improved > proposal, we're talking about a cost of filling two periods per > draining op, which aren't exactly super-frequent. I'm not much fan of introducing a new flag for that behavior, either. > > Also, we may skip the > > workaround for applications accessing directly via mmap as default. > > > no, because one may easily miss that more than one period is required. > also, i think that forgetting it entirely is an easy mistake to make, > even if it's harder with mmap than with write. I don't agree with that point -- if application wants the access only via mmap (without any write actions via alsa-lib functions), the buffer and data management relies fully on the application itself. Manipulating the data *silently* is no good action for such applications. For them, the drain simply means to stop at the certain point. OTOH, for the explicit write, basically alsa-lib / kernel is responsible for the buffer / data management, and the workaround can be applied. That's I mentioned to "apply conditionally". There are cases where we shouldn't touch the data at all. For the usual cases with the standard write, we may apply it. thanks, Takashi