mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module-ffado: implement freewheeling
When freewheeling starts, pause the streaming and resume when freewheeling stops. Also make sure we don't try to do any IO or timeouts.
This commit is contained in:
		
							parent
							
								
									d6d08997bb
								
							
						
					
					
						commit
						d5298eee2c
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		| 
						 | 
					@ -252,6 +252,7 @@ struct impl {
 | 
				
			||||||
	unsigned int do_disconnect:1;
 | 
						unsigned int do_disconnect:1;
 | 
				
			||||||
	unsigned int fix_midi:1;
 | 
						unsigned int fix_midi:1;
 | 
				
			||||||
	unsigned int started:1;
 | 
						unsigned int started:1;
 | 
				
			||||||
 | 
						unsigned int freewheel:1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pthread_t thread;
 | 
						pthread_t thread;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -674,10 +675,28 @@ static void stream_io_changed(void *data, void *port_data, uint32_t id, void *ar
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct stream *s = data;
 | 
						struct stream *s = data;
 | 
				
			||||||
	struct impl *impl = s->impl;
 | 
						struct impl *impl = s->impl;
 | 
				
			||||||
 | 
						bool freewheel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (port_data == NULL) {
 | 
						if (port_data == NULL) {
 | 
				
			||||||
		switch (id) {
 | 
							switch (id) {
 | 
				
			||||||
		case SPA_IO_Position:
 | 
							case SPA_IO_Position:
 | 
				
			||||||
			impl->position = area;
 | 
								impl->position = area;
 | 
				
			||||||
 | 
								freewheel = impl->position != NULL &&
 | 
				
			||||||
 | 
									SPA_FLAG_IS_SET(impl->position->clock.flags, SPA_IO_CLOCK_FLAG_FREEWHEEL);
 | 
				
			||||||
 | 
								if (impl->freewheel != freewheel) {
 | 
				
			||||||
 | 
									pw_log_info("freewheel: %d -> %d", impl->freewheel, freewheel);
 | 
				
			||||||
 | 
									impl->freewheel = freewheel;
 | 
				
			||||||
 | 
									if (impl->started) {
 | 
				
			||||||
 | 
										if (freewheel) {
 | 
				
			||||||
 | 
											set_timeout(impl, 0);
 | 
				
			||||||
 | 
											ffado_streaming_stop(impl->dev);
 | 
				
			||||||
 | 
										} else {
 | 
				
			||||||
 | 
											ffado_streaming_start(impl->dev);
 | 
				
			||||||
 | 
											impl->rt.done = true;
 | 
				
			||||||
 | 
											set_timeout(impl, get_time_ns(impl));
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		default:
 | 
							default:
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
| 
						 | 
					@ -982,6 +1001,9 @@ static void on_ffado_timeout(void *data, uint64_t expirations)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pw_log_trace_fp("wakeup %d", impl->rt.done);
 | 
						pw_log_trace_fp("wakeup %d", impl->rt.done);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (impl->freewheel)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!impl->rt.done) {
 | 
						if (!impl->rt.done) {
 | 
				
			||||||
		impl->rt.pw_xrun++;
 | 
							impl->rt.pw_xrun++;
 | 
				
			||||||
		impl->rt.new_xrun = true;
 | 
							impl->rt.new_xrun = true;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue