mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	remove the rate_match io
Now that the stream provides us with a requested size, we don't need to use the rate_match anymore.
This commit is contained in:
		
							parent
							
								
									5192fcb16c
								
							
						
					
					
						commit
						7e42c905a8
					
				
					 8 changed files with 12 additions and 104 deletions
				
			
		|  | @ -90,7 +90,6 @@ typedef struct { | ||||||
| 	struct spa_hook stream_listener; | 	struct spa_hook stream_listener; | ||||||
| 
 | 
 | ||||||
| 	struct pw_time time; | 	struct pw_time time; | ||||||
| 	struct spa_io_rate_match *rate_match; |  | ||||||
| 
 | 
 | ||||||
| 	struct spa_audio_info_raw format; | 	struct spa_audio_info_raw format; | ||||||
| } snd_pcm_pipewire_t; | } snd_pcm_pipewire_t; | ||||||
|  | @ -374,19 +373,6 @@ static void on_stream_param_changed(void *data, uint32_t id, const struct spa_po | ||||||
| 	pw_stream_update_params(pw->stream, params, n_params); | 	pw_stream_update_params(pw->stream, params, n_params); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void on_stream_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	snd_pcm_pipewire_t *pw = data; |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		if (pw->io.stream == SND_PCM_STREAM_PLAYBACK) |  | ||||||
| 			pw->rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	default: |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void on_stream_drained(void *data) | static void on_stream_drained(void *data) | ||||||
| { | { | ||||||
| 	snd_pcm_pipewire_t *pw = data; | 	snd_pcm_pipewire_t *pw = data; | ||||||
|  | @ -422,7 +408,7 @@ static void on_stream_process(void *data) | ||||||
| 	if (b == NULL) | 	if (b == NULL) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	want = pw->rate_match ? pw->rate_match->size : hw_avail; | 	want = b->requested ? b->requested : hw_avail; | ||||||
| 
 | 
 | ||||||
| 	xfer = snd_pcm_pipewire_process(pw, b, &hw_avail, want); | 	xfer = snd_pcm_pipewire_process(pw, b, &hw_avail, want); | ||||||
| 
 | 
 | ||||||
|  | @ -451,7 +437,6 @@ static void on_stream_process(void *data) | ||||||
| static const struct pw_stream_events stream_events = { | static const struct pw_stream_events stream_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.param_changed = on_stream_param_changed, | 	.param_changed = on_stream_param_changed, | ||||||
| 	.io_changed = on_stream_io_changed, |  | ||||||
| 	.process = on_stream_process, | 	.process = on_stream_process, | ||||||
| 	.drained = on_stream_drained, | 	.drained = on_stream_drained, | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -169,7 +169,6 @@ struct impl { | ||||||
| 	void *rec_buffer[SPA_AUDIO_MAX_CHANNELS]; | 	void *rec_buffer[SPA_AUDIO_MAX_CHANNELS]; | ||||||
| 	uint32_t rec_ringsize; | 	uint32_t rec_ringsize; | ||||||
| 	struct spa_ringbuffer rec_ring; | 	struct spa_ringbuffer rec_ring; | ||||||
| 	struct spa_io_rate_match *rec_rate_match; |  | ||||||
| 
 | 
 | ||||||
| 	struct pw_stream *playback; | 	struct pw_stream *playback; | ||||||
| 	struct spa_hook playback_listener; | 	struct spa_hook playback_listener; | ||||||
|  | @ -180,7 +179,6 @@ struct impl { | ||||||
| 	uint32_t play_ringsize; | 	uint32_t play_ringsize; | ||||||
| 	struct spa_ringbuffer play_ring; | 	struct spa_ringbuffer play_ring; | ||||||
| 	struct spa_ringbuffer play_delayed_ring; | 	struct spa_ringbuffer play_delayed_ring; | ||||||
| 	struct spa_io_rate_match *play_rate_match; |  | ||||||
| 
 | 
 | ||||||
| 	void *out_buffer[SPA_AUDIO_MAX_CHANNELS]; | 	void *out_buffer[SPA_AUDIO_MAX_CHANNELS]; | ||||||
| 	uint32_t out_ringsize; | 	uint32_t out_ringsize; | ||||||
|  | @ -338,17 +336,6 @@ static void capture_destroy(void *d) | ||||||
| 	impl->capture = NULL; | 	impl->capture = NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void capture_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	struct impl *impl = data; |  | ||||||
| 
 |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		impl->rec_rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void capture_process(void *data) | static void capture_process(void *data) | ||||||
| { | { | ||||||
| 	struct impl *impl = data; | 	struct impl *impl = data; | ||||||
|  | @ -382,7 +369,7 @@ static void capture_process(void *data) | ||||||
| 	 * if it has a specific requirement, else keep the block size the same | 	 * if it has a specific requirement, else keep the block size the same | ||||||
| 	 * on input and output or what the resampler needs */ | 	 * on input and output or what the resampler needs */ | ||||||
| 	if (impl->aec_blocksize == 0) { | 	if (impl->aec_blocksize == 0) { | ||||||
| 		impl->aec_blocksize = SPA_MAX(size, impl->rec_rate_match->size); | 		impl->aec_blocksize = size; | ||||||
| 		pw_log_debug("Setting AEC block size to %u", impl->aec_blocksize); | 		pw_log_debug("Setting AEC block size to %u", impl->aec_blocksize); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -454,7 +441,6 @@ static const struct pw_stream_events capture_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.destroy = capture_destroy, | 	.destroy = capture_destroy, | ||||||
| 	.state_changed = input_state_changed, | 	.state_changed = input_state_changed, | ||||||
| 	.io_changed = capture_io_changed, |  | ||||||
| 	.process = capture_process, | 	.process = capture_process, | ||||||
| 	.param_changed = input_param_changed | 	.param_changed = input_param_changed | ||||||
| }; | }; | ||||||
|  | @ -523,17 +509,6 @@ static void sink_destroy(void *d) | ||||||
| 	impl->sink = NULL; | 	impl->sink = NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void sink_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	struct impl *impl = data; |  | ||||||
| 
 |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		impl->play_rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void sink_process(void *data) | static void sink_process(void *data) | ||||||
| { | { | ||||||
| 	struct impl *impl = data; | 	struct impl *impl = data; | ||||||
|  | @ -567,7 +542,7 @@ static void sink_process(void *data) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if (impl->aec_blocksize == 0) { | 	if (impl->aec_blocksize == 0) { | ||||||
| 		impl->aec_blocksize = SPA_MAX(size, impl->rec_rate_match->size); | 		impl->aec_blocksize = size; | ||||||
| 		pw_log_debug("Setting AEC block size to %u", impl->aec_blocksize); | 		pw_log_debug("Setting AEC block size to %u", impl->aec_blocksize); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -608,7 +583,6 @@ static const struct pw_stream_events playback_events = { | ||||||
| static const struct pw_stream_events sink_events = { | static const struct pw_stream_events sink_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.destroy = sink_destroy, | 	.destroy = sink_destroy, | ||||||
| 	.io_changed = sink_io_changed, |  | ||||||
| 	.process = sink_process, | 	.process = sink_process, | ||||||
| 	.state_changed = output_state_changed, | 	.state_changed = output_state_changed, | ||||||
| 	.param_changed = output_param_changed | 	.param_changed = output_param_changed | ||||||
|  |  | ||||||
|  | @ -95,7 +95,6 @@ struct impl { | ||||||
| 	struct pw_properties *stream_props; | 	struct pw_properties *stream_props; | ||||||
| 	struct pw_stream *stream; | 	struct pw_stream *stream; | ||||||
| 	struct spa_hook stream_listener; | 	struct spa_hook stream_listener; | ||||||
| 	struct spa_io_rate_match *rate_match; |  | ||||||
| 	struct spa_audio_info_raw info; | 	struct spa_audio_info_raw info; | ||||||
| 	uint32_t frame_size; | 	uint32_t frame_size; | ||||||
| 
 | 
 | ||||||
|  | @ -157,10 +156,7 @@ static void capture_stream_process(void *d) | ||||||
| 	bd = &buf->buffer->datas[0]; | 	bd = &buf->buffer->datas[0]; | ||||||
| 
 | 
 | ||||||
| 	data = bd->data; | 	data = bd->data; | ||||||
| 	if (impl->rate_match) | 	size = buf->requested ? buf->requested * impl->frame_size : bd->maxsize; | ||||||
| 		size = SPA_MIN(impl->rate_match->size * impl->frame_size, bd->maxsize); |  | ||||||
| 	else |  | ||||||
| 		size = bd->maxsize; |  | ||||||
| 
 | 
 | ||||||
| 	/* fill buffer contents here */ | 	/* fill buffer contents here */ | ||||||
| 	pw_log_info("fill buffer data %p with up to %u bytes", data, size); | 	pw_log_info("fill buffer data %p with up to %u bytes", data, size); | ||||||
|  | @ -168,25 +164,15 @@ static void capture_stream_process(void *d) | ||||||
| 	bd->chunk->size = size; | 	bd->chunk->size = size; | ||||||
| 	bd->chunk->stride = impl->frame_size; | 	bd->chunk->stride = impl->frame_size; | ||||||
| 	bd->chunk->offset = 0; | 	bd->chunk->offset = 0; | ||||||
|  | 	buf->size = size / impl->frame_size; | ||||||
| 
 | 
 | ||||||
| 	pw_stream_queue_buffer(impl->stream, buf); | 	pw_stream_queue_buffer(impl->stream, buf); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void stream_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	struct impl *impl = data; |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		impl->rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static const struct pw_stream_events capture_stream_events = { | static const struct pw_stream_events capture_stream_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.destroy = stream_destroy, | 	.destroy = stream_destroy, | ||||||
| 	.state_changed = stream_state_changed, | 	.state_changed = stream_state_changed, | ||||||
| 	.io_changed = stream_io_changed, |  | ||||||
| 	.process = capture_stream_process | 	.process = capture_stream_process | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1260,8 +1260,7 @@ static void stream_process(void *data) | ||||||
| 	if (stream->direction == PW_DIRECTION_OUTPUT) { | 	if (stream->direction == PW_DIRECTION_OUTPUT) { | ||||||
| 		int32_t avail = spa_ringbuffer_get_read_index(&stream->ring, &index); | 		int32_t avail = spa_ringbuffer_get_read_index(&stream->ring, &index); | ||||||
| 
 | 
 | ||||||
| 		if (stream->rate_match) | 		minreq = buffer->requested * stream->frame_size; | ||||||
| 			minreq = stream->rate_match->size * stream->frame_size; |  | ||||||
| 		if (minreq == 0) | 		if (minreq == 0) | ||||||
| 			minreq = stream->attr.minreq; | 			minreq = stream->attr.minreq; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -61,17 +61,6 @@ static void sample_play_stream_state_changed(void *data, enum pw_stream_state ol | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void sample_play_stream_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	struct sample_play *p = data; |  | ||||||
| 
 |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		p->rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static void sample_play_stream_destroy(void *data) | static void sample_play_stream_destroy(void *data) | ||||||
| { | { | ||||||
| 	struct sample_play *p = data; | 	struct sample_play *p = data; | ||||||
|  | @ -111,8 +100,8 @@ static void sample_play_stream_process(void *data) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	size = SPA_MIN(size, buf->datas[0].maxsize); | 	size = SPA_MIN(size, buf->datas[0].maxsize); | ||||||
| 	if (p->rate_match) | 	if (b->requested) | ||||||
| 		size = SPA_MIN(size, p->rate_match->size * p->stride); | 		size = SPA_MIN(size, b->requested * p->stride); | ||||||
| 
 | 
 | ||||||
| 	memcpy(d, s->buffer + p->offset, size); | 	memcpy(d, s->buffer + p->offset, size); | ||||||
| 
 | 
 | ||||||
|  | @ -135,7 +124,6 @@ static void sample_play_stream_drained(void *data) | ||||||
| static const struct pw_stream_events sample_play_stream_events = { | static const struct pw_stream_events sample_play_stream_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.state_changed = sample_play_stream_state_changed, | 	.state_changed = sample_play_stream_state_changed, | ||||||
| 	.io_changed = sample_play_stream_io_changed, |  | ||||||
| 	.destroy = sample_play_stream_destroy, | 	.destroy = sample_play_stream_destroy, | ||||||
| 	.process = sample_play_stream_process, | 	.process = sample_play_stream_process, | ||||||
| 	.drained = sample_play_stream_drained, | 	.drained = sample_play_stream_drained, | ||||||
|  |  | ||||||
|  | @ -37,7 +37,6 @@ struct pw_loop; | ||||||
| struct pw_stream; | struct pw_stream; | ||||||
| struct pw_context; | struct pw_context; | ||||||
| struct pw_properties; | struct pw_properties; | ||||||
| struct spa_io_rate_match; |  | ||||||
| 
 | 
 | ||||||
| struct sample_play_events { | struct sample_play_events { | ||||||
| #define VERSION_SAMPLE_PLAY_EVENTS	0 | #define VERSION_SAMPLE_PLAY_EVENTS	0 | ||||||
|  | @ -55,7 +54,6 @@ struct sample_play { | ||||||
| 	struct spa_list link; | 	struct spa_list link; | ||||||
| 	struct sample *sample; | 	struct sample *sample; | ||||||
| 	struct pw_stream *stream; | 	struct pw_stream *stream; | ||||||
| 	struct spa_io_rate_match *rate_match; |  | ||||||
| 	uint32_t id; | 	uint32_t id; | ||||||
| 	struct spa_hook listener; | 	struct spa_hook listener; | ||||||
| 	struct pw_context *context; | 	struct pw_context *context; | ||||||
|  |  | ||||||
|  | @ -121,8 +121,6 @@ struct client { | ||||||
| 	struct pw_stream *playback; | 	struct pw_stream *playback; | ||||||
| 	struct spa_hook playback_listener; | 	struct spa_hook playback_listener; | ||||||
| 
 | 
 | ||||||
| 	struct spa_io_rate_match *rate_match; |  | ||||||
| 
 |  | ||||||
| 	unsigned int disconnect:1; | 	unsigned int disconnect:1; | ||||||
| 	unsigned int disconnecting:1; | 	unsigned int disconnecting:1; | ||||||
| 	unsigned int cleanup:1; | 	unsigned int cleanup:1; | ||||||
|  | @ -282,12 +280,9 @@ static void playback_process(void *data) | ||||||
| 	} | 	} | ||||||
| 	d = &buf->buffer->datas[0]; | 	d = &buf->buffer->datas[0]; | ||||||
| 
 | 
 | ||||||
| 	if (client->rate_match) { | 	size = d->maxsize; | ||||||
| 		size = client->rate_match->size * impl->frame_size; | 	if (buf->requested) | ||||||
| 		size = SPA_MIN(size, d->maxsize); | 		size = SPA_MIN(size, buf->requested * impl->frame_size); | ||||||
| 	} else { |  | ||||||
| 		size = d->maxsize; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	offset = 0; | 	offset = 0; | ||||||
| 	while (size > 0) { | 	while (size > 0) { | ||||||
|  | @ -354,16 +349,6 @@ static void playback_destroy(void *data) | ||||||
| 	client->playback = NULL; | 	client->playback = NULL; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void playback_io_changed(void *data, uint32_t id, void *area, uint32_t size) |  | ||||||
| { |  | ||||||
| 	struct client *client = data; |  | ||||||
| 	switch (id) { |  | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		client->rate_match = area; |  | ||||||
| 		break; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static const struct pw_stream_events capture_stream_events = { | static const struct pw_stream_events capture_stream_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.destroy = capture_destroy, | 	.destroy = capture_destroy, | ||||||
|  | @ -375,7 +360,6 @@ static const struct pw_stream_events playback_stream_events = { | ||||||
| 	PW_VERSION_STREAM_EVENTS, | 	PW_VERSION_STREAM_EVENTS, | ||||||
| 	.destroy = playback_destroy, | 	.destroy = playback_destroy, | ||||||
| 	.state_changed = on_stream_state_changed, | 	.state_changed = on_stream_state_changed, | ||||||
| 	.io_changed = playback_io_changed, |  | ||||||
| 	.process = playback_process | 	.process = playback_process | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -162,7 +162,6 @@ struct data { | ||||||
| 	int sync; | 	int sync; | ||||||
| 
 | 
 | ||||||
| 	struct spa_io_position *position; | 	struct spa_io_position *position; | ||||||
| 	struct spa_io_rate_match *rate_match; |  | ||||||
| 	bool drained; | 	bool drained; | ||||||
| 	uint64_t clock_time; | 	uint64_t clock_time; | ||||||
| 
 | 
 | ||||||
|  | @ -880,10 +879,6 @@ on_io_changed(void *userdata, uint32_t id, void *data, uint32_t size) | ||||||
| 	case SPA_IO_Position: | 	case SPA_IO_Position: | ||||||
| 		d->position = data; | 		d->position = data; | ||||||
| 		break; | 		break; | ||||||
| 	case SPA_IO_RateMatch: |  | ||||||
| 		if (d->data_type == TYPE_PCM) |  | ||||||
| 			d->rate_match = data; |  | ||||||
| 		break; |  | ||||||
| 	default: | 	default: | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  | @ -951,8 +946,7 @@ static void on_process(void *userdata) | ||||||
| 	if (data->mode == mode_playback) { | 	if (data->mode == mode_playback) { | ||||||
| 
 | 
 | ||||||
| 		n_frames = d->maxsize / data->stride; | 		n_frames = d->maxsize / data->stride; | ||||||
| 		if (data->rate_match && data->rate_match->size > 0) | 		n_frames = SPA_MIN(n_frames, (int)b->requested); | ||||||
| 			n_frames = SPA_MIN((uint32_t)n_frames, data->rate_match->size); |  | ||||||
| 
 | 
 | ||||||
| 		n_fill_frames = data->fill(data, p, n_frames); | 		n_fill_frames = data->fill(data, p, n_frames); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Wim Taymans
						Wim Taymans