mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	pipe: replace PIPE_BUF macro pa pa_pipe_buf call
This should help portability to platforms that lack PIPE_BUF. Based on a patch from Samuel Thibault. See ticket #546
This commit is contained in:
		
							parent
							
								
									0113e7282c
								
							
						
					
					
						commit
						e5c2256e36
					
				
					 4 changed files with 23 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -122,7 +122,7 @@ static int process_render(struct userdata *u) {
 | 
			
		|||
    pa_assert(u);
 | 
			
		||||
 | 
			
		||||
    if (u->memchunk.length <= 0)
 | 
			
		||||
        pa_sink_render(u->sink, PIPE_BUF, &u->memchunk);
 | 
			
		||||
        pa_sink_render(u->sink, pa_pipe_buf(u->fd), &u->memchunk);
 | 
			
		||||
 | 
			
		||||
    pa_assert(u->memchunk.length > 0);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -299,8 +299,8 @@ int pa__init(pa_module*m) {
 | 
			
		|||
 | 
			
		||||
    pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
 | 
			
		||||
    pa_sink_set_rtpoll(u->sink, u->rtpoll);
 | 
			
		||||
    pa_sink_set_max_request(u->sink, PIPE_BUF);
 | 
			
		||||
    pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(PIPE_BUF, &u->sink->sample_spec));
 | 
			
		||||
    pa_sink_set_max_request(u->sink, pa_pipe_buf(u->fd));
 | 
			
		||||
    pa_sink_set_fixed_latency(u->sink, pa_bytes_to_usec(pa_pipe_buf(u->fd), &u->sink->sample_spec));
 | 
			
		||||
 | 
			
		||||
    u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
 | 
			
		||||
    pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -142,7 +142,7 @@ static void thread_func(void *userdata) {
 | 
			
		|||
            void *p;
 | 
			
		||||
 | 
			
		||||
            if (!u->memchunk.memblock) {
 | 
			
		||||
                u->memchunk.memblock = pa_memblock_new(u->core->mempool, PIPE_BUF);
 | 
			
		||||
                u->memchunk.memblock = pa_memblock_new(u->core->mempool, pa_pipe_buf(u->fd));
 | 
			
		||||
                u->memchunk.index = u->memchunk.length = 0;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2779,3 +2779,19 @@ char* pa_maybe_prefix_path(const char *path, const char *prefix) {
 | 
			
		|||
 | 
			
		||||
    return pa_sprintf_malloc("%s" PA_PATH_SEP "%s", prefix, path);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
size_t pa_pipe_buf(int fd) {
 | 
			
		||||
 | 
			
		||||
#ifdef _PC_PIPE_BUF
 | 
			
		||||
    long n;
 | 
			
		||||
 | 
			
		||||
    if ((n = fpathconf(fd, _PC_PIPE_BUF)) >= 0)
 | 
			
		||||
        return (size_t) n;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef PIPE_BUF
 | 
			
		||||
    return PIPE_BUF;
 | 
			
		||||
#else
 | 
			
		||||
    return 4096;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -236,4 +236,7 @@ char **pa_split_spaces_strv(const char *s);
 | 
			
		|||
 | 
			
		||||
char* pa_maybe_prefix_path(const char *path, const char *prefix);
 | 
			
		||||
 | 
			
		||||
/* Returns size of the specified pipe or 4096 on failure */
 | 
			
		||||
size_t pa_pipe_buf(int fd);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue