mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pipewire-alsa: Make sure to always fill the pipewire buffers with
silence on process if there is not enough data. This fixes noise with the retroarch alsa backend on pause, which doesn't actually pause the device.
This commit is contained in:
		
							parent
							
								
									86acbabe8f
								
							
						
					
					
						commit
						92c541ea03
					
				
					 1 changed files with 4 additions and 8 deletions
				
			
		| 
						 | 
					@ -199,7 +199,6 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b, snd_pcm_uf
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		nframes = d[0].chunk->size / pw->stride;
 | 
							nframes = d[0].chunk->size / pw->stride;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	nframes = SPA_MIN(nframes, *hw_avail);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pw->blocks == 1) {
 | 
						if (pw->blocks == 1) {
 | 
				
			||||||
		ptr = SPA_MEMBER(d[0].data, d[0].chunk->offset, void);
 | 
							ptr = SPA_MEMBER(d[0].data, d[0].chunk->offset, void);
 | 
				
			||||||
| 
						 | 
					@ -224,14 +223,11 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b, snd_pcm_uf
 | 
				
			||||||
	if (io->state == SND_PCM_STATE_RUNNING ||
 | 
						if (io->state == SND_PCM_STATE_RUNNING ||
 | 
				
			||||||
		io->state == SND_PCM_STATE_DRAINING) {
 | 
							io->state == SND_PCM_STATE_DRAINING) {
 | 
				
			||||||
		snd_pcm_uframes_t hw_ptr = pw->hw_ptr;
 | 
							snd_pcm_uframes_t hw_ptr = pw->hw_ptr;
 | 
				
			||||||
		if (*hw_avail > 0) {
 | 
							xfer = SPA_MIN(nframes, *hw_avail);
 | 
				
			||||||
 | 
							if (xfer > 0) {
 | 
				
			||||||
			const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io);
 | 
								const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io);
 | 
				
			||||||
			const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
 | 
								const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			xfer = nframes;
 | 
					 | 
				
			||||||
			if (xfer > *hw_avail)
 | 
					 | 
				
			||||||
				xfer = *hw_avail;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (io->stream == SND_PCM_STREAM_PLAYBACK)
 | 
								if (io->stream == SND_PCM_STREAM_PLAYBACK)
 | 
				
			||||||
				snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
 | 
									snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
 | 
				
			||||||
										areas, offset,
 | 
															areas, offset,
 | 
				
			||||||
| 
						 | 
					@ -249,6 +245,7 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b, snd_pcm_uf
 | 
				
			||||||
			if (hw_ptr > pw->boundary)
 | 
								if (hw_ptr > pw->boundary)
 | 
				
			||||||
				hw_ptr -= pw->boundary;
 | 
									hw_ptr -= pw->boundary;
 | 
				
			||||||
			pw->hw_ptr = hw_ptr;
 | 
								pw->hw_ptr = hw_ptr;
 | 
				
			||||||
 | 
								*hw_avail -= xfer;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	/* check if requested frames were copied */
 | 
						/* check if requested frames were copied */
 | 
				
			||||||
| 
						 | 
					@ -259,7 +256,6 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b, snd_pcm_uf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			snd_pcm_areas_silence(pwareas, xfer, io->channels,
 | 
								snd_pcm_areas_silence(pwareas, xfer, io->channels,
 | 
				
			||||||
								  frames, io->format);
 | 
													  frames, io->format);
 | 
				
			||||||
			xfer += frames;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		if (io->state == SND_PCM_STATE_RUNNING ||
 | 
							if (io->state == SND_PCM_STATE_RUNNING ||
 | 
				
			||||||
			io->state == SND_PCM_STATE_DRAINING) {
 | 
								io->state == SND_PCM_STATE_DRAINING) {
 | 
				
			||||||
| 
						 | 
					@ -267,7 +263,7 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b, snd_pcm_uf
 | 
				
			||||||
			pw->xrun_detected = true;
 | 
								pw->xrun_detected = true;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	*hw_avail -= xfer;
 | 
					
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue