mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	alsa: init variable correctly
We need to initialize the frames variable correctly before calling mmap. Also initialize the now timer when starting.
This commit is contained in:
		
							parent
							
								
									30316df5c8
								
							
						
					
					
						commit
						0aca605bfb
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
					@ -430,14 +430,14 @@ int spa_alsa_write(struct state *state, snd_pcm_uframes_t silence)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	snd_pcm_t *hndl = state->hndl;
 | 
						snd_pcm_t *hndl = state->hndl;
 | 
				
			||||||
	const snd_pcm_channel_area_t *my_areas;
 | 
						const snd_pcm_channel_area_t *my_areas;
 | 
				
			||||||
	snd_pcm_uframes_t written, frames, offset, off, to_write;
 | 
						snd_pcm_uframes_t written, frames = state->buffer_frames, offset, off, to_write;
 | 
				
			||||||
	int res;
 | 
						int res;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((res = snd_pcm_mmap_begin(hndl, &my_areas, &offset, &frames)) < 0) {
 | 
						if ((res = snd_pcm_mmap_begin(hndl, &my_areas, &offset, &frames)) < 0) {
 | 
				
			||||||
		spa_log_error(state->log, "snd_pcm_mmap_begin error: %s", snd_strerror(res));
 | 
							spa_log_error(state->log, "snd_pcm_mmap_begin error: %s", snd_strerror(res));
 | 
				
			||||||
		return res;
 | 
							return res;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	spa_log_trace(state->log, "begin %ld %ld", offset, frames);
 | 
						spa_log_trace(state->log, "begin %ld %ld %d", offset, frames, state->threshold);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	silence = SPA_MIN(silence, frames);
 | 
						silence = SPA_MIN(silence, frames);
 | 
				
			||||||
	to_write = frames;
 | 
						to_write = frames;
 | 
				
			||||||
| 
						 | 
					@ -787,6 +787,7 @@ int spa_alsa_start(struct state *state, bool xrun_recover)
 | 
				
			||||||
		state->alsa_started = true;
 | 
							state->alsa_started = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						clock_gettime(CLOCK_MONOTONIC, &state->now);
 | 
				
			||||||
	ts.it_value.tv_sec = 0;
 | 
						ts.it_value.tv_sec = 0;
 | 
				
			||||||
	ts.it_value.tv_nsec = 1;
 | 
						ts.it_value.tv_nsec = 1;
 | 
				
			||||||
	ts.it_interval.tv_sec = 0;
 | 
						ts.it_interval.tv_sec = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue