mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	never hand out more data from a sink input than requested. Otherwise the resampler might run for too long and we get a heavy delay/underrun
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2490 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									7297bd91e7
								
							
						
					
					
						commit
						c4f60d5960
					
				
					 4 changed files with 9 additions and 7 deletions
				
			
		| 
						 | 
					@ -185,6 +185,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
 | 
				
			||||||
        pa_memblock_unref(nchunk.memblock);
 | 
					        pa_memblock_unref(nchunk.memblock);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    tchunk.length = PA_MIN(nbytes, tchunk.length);
 | 
				
			||||||
    pa_assert(tchunk.length > 0);
 | 
					    pa_assert(tchunk.length > 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fs = pa_frame_size(&i->sample_spec);
 | 
					    fs = pa_frame_size(&i->sample_spec);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,6 +138,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    chunk->length = PA_MIN(chunk->length, nbytes);
 | 
				
			||||||
    pa_memblockq_drop(u->memblockq, chunk->length);
 | 
					    pa_memblockq_drop(u->memblockq, chunk->length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -374,6 +374,8 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        size_t m;
 | 
					        size_t m;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        chunk->length = PA_MIN(length, chunk->length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        c->playback.underrun = FALSE;
 | 
					        c->playback.underrun = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        pa_memblockq_drop(c->input_memblockq, chunk->length);
 | 
					        pa_memblockq_drop(c->input_memblockq, chunk->length);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -35,6 +35,7 @@
 | 
				
			||||||
#include <sndfile.h>
 | 
					#include <sndfile.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulse/xmalloc.h>
 | 
					#include <pulse/xmalloc.h>
 | 
				
			||||||
 | 
					#include <pulse/util.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <pulsecore/core-error.h>
 | 
					#include <pulsecore/core-error.h>
 | 
				
			||||||
#include <pulsecore/sink-input.h>
 | 
					#include <pulsecore/sink-input.h>
 | 
				
			||||||
| 
						 | 
					@ -149,8 +150,6 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
 | 
				
			||||||
    if (!u->memblockq)
 | 
					    if (!u->memblockq)
 | 
				
			||||||
        return -1;
 | 
					        return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_log_debug("pop: %lu", (unsigned long) length);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (;;) {
 | 
					    for (;;) {
 | 
				
			||||||
        pa_memchunk tchunk;
 | 
					        pa_memchunk tchunk;
 | 
				
			||||||
        size_t fs;
 | 
					        size_t fs;
 | 
				
			||||||
| 
						 | 
					@ -158,6 +157,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
 | 
				
			||||||
        sf_count_t n;
 | 
					        sf_count_t n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (pa_memblockq_peek(u->memblockq, chunk) >= 0) {
 | 
					        if (pa_memblockq_peek(u->memblockq, chunk) >= 0) {
 | 
				
			||||||
 | 
					            chunk->length = PA_MIN(chunk->length, length);
 | 
				
			||||||
            pa_memblockq_drop(u->memblockq, chunk->length);
 | 
					            pa_memblockq_drop(u->memblockq, chunk->length);
 | 
				
			||||||
            return 0;
 | 
					            return 0;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -194,11 +194,7 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t length, pa_memchunk *chunk
 | 
				
			||||||
        pa_memblock_unref(tchunk.memblock);
 | 
					        pa_memblock_unref(tchunk.memblock);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_log_debug("peek fail");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (pa_sink_input_safe_to_remove(i)) {
 | 
					    if (pa_sink_input_safe_to_remove(i)) {
 | 
				
			||||||
        pa_log_debug("completed to play");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        pa_memblockq_free(u->memblockq);
 | 
					        pa_memblockq_free(u->memblockq);
 | 
				
			||||||
        u->memblockq = NULL;
 | 
					        u->memblockq = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -216,6 +212,8 @@ static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes) {
 | 
				
			||||||
    u = FILE_STREAM(i->userdata);
 | 
					    u = FILE_STREAM(i->userdata);
 | 
				
			||||||
    file_stream_assert_ref(u);
 | 
					    file_stream_assert_ref(u);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_log("backwards %lu", (unsigned long) nbytes);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!u->memblockq)
 | 
					    if (!u->memblockq)
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -330,7 +328,7 @@ int pa_play_file(
 | 
				
			||||||
    data.driver = __FILE__;
 | 
					    data.driver = __FILE__;
 | 
				
			||||||
    pa_sink_input_new_data_set_sample_spec(&data, &ss);
 | 
					    pa_sink_input_new_data_set_sample_spec(&data, &ss);
 | 
				
			||||||
    pa_sink_input_new_data_set_volume(&data, volume);
 | 
					    pa_sink_input_new_data_set_volume(&data, volume);
 | 
				
			||||||
    pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, fname);
 | 
					    pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, pa_path_get_filename(fname));
 | 
				
			||||||
    pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname);
 | 
					    pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    u->sink_input = pa_sink_input_new(sink->core, &data, 0);
 | 
					    u->sink_input = pa_sink_input_new(sink->core, &data, 0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue