Re: [BUG] snd_pcm_drop() does not stop the PCM immediately

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 03/14/2018 04:13 PM, Takashi Iwai wrote:
> 
> It's a best-effort base stopping mechanism with dmix, so it's a sort
> of expected behavior, unfortunately.  Due to its nature of
> implementation, scratching off the existing data from the mixed buffer
> isn't so trivial for now.
> 
eSpeakNG has the workaround in pcaudiolib (see outcommented part):
"
int
alsa_object_flush(struct audio_object *object)
{
	struct alsa_object *self = to_alsa_object(object);
	if (self && self->handle){
		snd_pcm_drop(self->handle);
	}
/*
	if (!self) return 0;

	// Using snd_pcm_drop does not discard the audio, so reopen the device
	// to reset the sound buffer.
	if (self->is_open) {
		audio_object_close(object);
			//this crashes write operation in other thread!
		return audio_object_open(object, self->format, self->rate,
self->channels);
	}
*/
	return 0;
}

"
"
void
alsa_object_close(struct audio_object *object)
{
	struct alsa_object *self = to_alsa_object(object);

	if (self->handle) {
		snd_pcm_close(self->handle);
		self->handle = NULL;
		self->is_open = 1;
	}
}
"
Does snd_pcm_close() "scratching off the existing data from the mixed
buffer"? If yes, how could the workaround be made without letting crash
pending write operations in separate thread?

Thanks, Martin
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux