mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-10-29 05:40:23 -04:00 
			
		
		
		
	add suspend_within_thread() callbacks to pa_sink_input/pa_source_output
This commit is contained in:
		
							parent
							
								
									35a4a0baa8
								
							
						
					
					
						commit
						61b07768c2
					
				
					 6 changed files with 44 additions and 3 deletions
				
			
		|  | @ -117,6 +117,7 @@ static void reset_callbacks(pa_sink_input *i) { | ||||||
|     i->attach = NULL; |     i->attach = NULL; | ||||||
|     i->detach = NULL; |     i->detach = NULL; | ||||||
|     i->suspend = NULL; |     i->suspend = NULL; | ||||||
|  |     i->suspend_within_thread = NULL; | ||||||
|     i->moving = NULL; |     i->moving = NULL; | ||||||
|     i->kill = NULL; |     i->kill = NULL; | ||||||
|     i->get_latency = NULL; |     i->get_latency = NULL; | ||||||
|  |  | ||||||
|  | @ -148,6 +148,10 @@ struct pa_sink_input { | ||||||
|      * to suspends or resumes. Called from main context */ |      * to suspends or resumes. Called from main context */ | ||||||
|     void (*suspend) (pa_sink_input *i, pa_bool_t b);   /* may be NULL */ |     void (*suspend) (pa_sink_input *i, pa_bool_t b);   /* may be NULL */ | ||||||
| 
 | 
 | ||||||
|  |     /* If non-NULL called whenever the sink this input is attached
 | ||||||
|  |      * to suspends or resumes. Called from IO context */ | ||||||
|  |     void (*suspend_within_thread) (pa_sink_input *i, pa_bool_t b);   /* may be NULL */ | ||||||
|  | 
 | ||||||
|     /* If non-NULL called whenever the sink input is moved to a new
 |     /* If non-NULL called whenever the sink input is moved to a new
 | ||||||
|      * sink. Called from main context after the sink input has been |      * sink. Called from main context after the sink input has been | ||||||
|      * detached from the old sink and before it has been attached to |      * detached from the old sink and before it has been attached to | ||||||
|  |  | ||||||
|  | @ -1585,7 +1585,11 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse | ||||||
|         case PA_SINK_MESSAGE_GET_MUTE: |         case PA_SINK_MESSAGE_GET_MUTE: | ||||||
|             return 0; |             return 0; | ||||||
| 
 | 
 | ||||||
|         case PA_SINK_MESSAGE_SET_STATE: |         case PA_SINK_MESSAGE_SET_STATE: { | ||||||
|  | 
 | ||||||
|  |             pa_bool_t suspend_change = | ||||||
|  |                 (s->thread_info.state == PA_SINK_SUSPENDED && PA_SINK_IS_OPENED(PA_PTR_TO_UINT(userdata))) || | ||||||
|  |                 (PA_SINK_IS_OPENED(s->thread_info.state) && PA_PTR_TO_UINT(userdata) == PA_SINK_SUSPENDED); | ||||||
| 
 | 
 | ||||||
|             s->thread_info.state = PA_PTR_TO_UINT(userdata); |             s->thread_info.state = PA_PTR_TO_UINT(userdata); | ||||||
| 
 | 
 | ||||||
|  | @ -1594,7 +1598,17 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse | ||||||
|                 s->thread_info.rewind_requested = FALSE; |                 s->thread_info.rewind_requested = FALSE; | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |             if (suspend_change) { | ||||||
|  |                 pa_sink_input *i; | ||||||
|  |                 void *state = NULL; | ||||||
|  | 
 | ||||||
|  |                 while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL))) | ||||||
|  |                     if (i->suspend_within_thread) | ||||||
|  |                         i->suspend_within_thread(i, s->thread_info.state == PA_SINK_SUSPENDED); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|             return 0; |             return 0; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         case PA_SINK_MESSAGE_DETACH: |         case PA_SINK_MESSAGE_DETACH: | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -87,6 +87,7 @@ static void reset_callbacks(pa_source_output *o) { | ||||||
|     o->attach = NULL; |     o->attach = NULL; | ||||||
|     o->detach = NULL; |     o->detach = NULL; | ||||||
|     o->suspend = NULL; |     o->suspend = NULL; | ||||||
|  |     o->suspend_within_thread = NULL; | ||||||
|     o->moving = NULL; |     o->moving = NULL; | ||||||
|     o->kill = NULL; |     o->kill = NULL; | ||||||
|     o->get_latency = NULL; |     o->get_latency = NULL; | ||||||
|  |  | ||||||
|  | @ -120,6 +120,10 @@ struct pa_source_output { | ||||||
|      * to suspends or resumes. Called from main context */ |      * to suspends or resumes. Called from main context */ | ||||||
|     void (*suspend) (pa_source_output *o, pa_bool_t b);   /* may be NULL */ |     void (*suspend) (pa_source_output *o, pa_bool_t b);   /* may be NULL */ | ||||||
| 
 | 
 | ||||||
|  |     /* If non-NULL called whenever the source this output is attached
 | ||||||
|  |      * to suspends or resumes. Called from IO context */ | ||||||
|  |     void (*suspend_within_thread) (pa_source_output *o, pa_bool_t b);   /* may be NULL */ | ||||||
|  | 
 | ||||||
|     /* If non-NULL called whenever the source output is moved to a new
 |     /* If non-NULL called whenever the source output is moved to a new
 | ||||||
|      * source. Called from main context after the stream was detached |      * source. Called from main context after the stream was detached | ||||||
|      * from the old source and before it is attached to the new |      * from the old source and before it is attached to the new | ||||||
|  |  | ||||||
|  | @ -933,9 +933,26 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_ | ||||||
|         case PA_SOURCE_MESSAGE_GET_MUTE: |         case PA_SOURCE_MESSAGE_GET_MUTE: | ||||||
|             return 0; |             return 0; | ||||||
| 
 | 
 | ||||||
|         case PA_SOURCE_MESSAGE_SET_STATE: |         case PA_SOURCE_MESSAGE_SET_STATE: { | ||||||
|  | 
 | ||||||
|  |             pa_bool_t suspend_change = | ||||||
|  |                 (s->thread_info.state == PA_SOURCE_SUSPENDED && PA_SOURCE_IS_OPENED(PA_PTR_TO_UINT(userdata))) || | ||||||
|  |                 (PA_SOURCE_IS_OPENED(s->thread_info.state) && PA_PTR_TO_UINT(userdata) == PA_SOURCE_SUSPENDED); | ||||||
|  | 
 | ||||||
|             s->thread_info.state = PA_PTR_TO_UINT(userdata); |             s->thread_info.state = PA_PTR_TO_UINT(userdata); | ||||||
|  | 
 | ||||||
|  |             if (suspend_change) { | ||||||
|  |                 pa_source_output *o; | ||||||
|  |                 void *state = NULL; | ||||||
|  | 
 | ||||||
|  |                 while ((o = pa_hashmap_iterate(s->thread_info.outputs, &state, NULL))) | ||||||
|  |                     if (o->suspend_within_thread) | ||||||
|  |                         o->suspend_within_thread(o, s->thread_info.state == PA_SOURCE_SUSPENDED); | ||||||
|  |             } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|             return 0; |             return 0; | ||||||
|  |         } | ||||||
| 
 | 
 | ||||||
|         case PA_SOURCE_MESSAGE_DETACH: |         case PA_SOURCE_MESSAGE_DETACH: | ||||||
| 
 | 
 | ||||||
|  | @ -1217,7 +1234,7 @@ void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t | ||||||
|    } |    } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /* Called from IO thread, and from main thread before pa_sink_put() is called */ | /* Called from IO thread, and from main thread before pa_source_put() is called */ | ||||||
| void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) { | void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) { | ||||||
|     void *state = NULL; |     void *state = NULL; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lennart Poettering
						Lennart Poettering