mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add new API to replace the poll() function used by the main loop implementation
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@733 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									a8bb073acc
								
							
						
					
					
						commit
						76296ca8ad
					
				
					 2 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -101,6 +101,9 @@ struct pa_mainloop {
 | 
			
		|||
        STATE_POLLED,
 | 
			
		||||
        STATE_QUIT
 | 
			
		||||
    } state;
 | 
			
		||||
 | 
			
		||||
    pa_poll_func poll_func;
 | 
			
		||||
    void *poll_func_userdata;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/* IO events */
 | 
			
		||||
| 
						 | 
				
			
			@ -356,6 +359,9 @@ pa_mainloop *pa_mainloop_new(void) {
 | 
			
		|||
 | 
			
		||||
    m->state = STATE_PASSIVE;
 | 
			
		||||
 | 
			
		||||
    m->poll_func = NULL;
 | 
			
		||||
    m->poll_func_userdata = NULL;
 | 
			
		||||
    
 | 
			
		||||
    return m;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -665,6 +671,9 @@ int pa_mainloop_poll(pa_mainloop *m) {
 | 
			
		|||
    if (m->deferred_pending)
 | 
			
		||||
        r = 0;
 | 
			
		||||
    else {
 | 
			
		||||
        if (m->poll_func)
 | 
			
		||||
            r = m->poll_func(m->pollfds, m->n_pollfds, m->prepared_timeout, m->poll_func_userdata);
 | 
			
		||||
        else
 | 
			
		||||
            r = poll(m->pollfds, m->n_pollfds, m->prepared_timeout);
 | 
			
		||||
 | 
			
		||||
        if (r < 0) {
 | 
			
		||||
| 
						 | 
				
			
			@ -767,6 +776,14 @@ pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m) {
 | 
			
		|||
    return &m->api;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata) {
 | 
			
		||||
    assert(m);
 | 
			
		||||
 | 
			
		||||
    m->poll_func = poll_func;
 | 
			
		||||
    m->poll_func_userdata = userdata;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
void pa_mainloop_dump(pa_mainloop *m) {
 | 
			
		||||
    assert(m);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -70,6 +70,8 @@ PA_C_DECL_BEGIN
 | 
			
		|||
 * defined in \ref mainloop-api.h. This implementation is thread safe
 | 
			
		||||
 * as long as you access the main loop object from a single thread only.*/
 | 
			
		||||
 | 
			
		||||
#include <sys/poll.h>
 | 
			
		||||
 | 
			
		||||
/** An opaque main loop object */
 | 
			
		||||
typedef struct pa_mainloop pa_mainloop;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +116,12 @@ void pa_mainloop_quit(pa_mainloop *m, int r);
 | 
			
		|||
/** Interrupt a running poll (for threaded systems) */
 | 
			
		||||
void pa_mainloop_wakeup(pa_mainloop *m);
 | 
			
		||||
 | 
			
		||||
/** Generic prototype of a poll() like function */
 | 
			
		||||
typedef int (*pa_poll_func)(struct pollfd *ufds, nfds_t nfds, int timeout, void*userdata);
 | 
			
		||||
 | 
			
		||||
/** Change the poll() implementation */
 | 
			
		||||
void pa_mainloop_set_poll_func(pa_mainloop *m, pa_poll_func poll_func, void *userdata);
 | 
			
		||||
 | 
			
		||||
PA_C_DECL_END
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue