mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	virtual: minor simplifications for the virtual sink
This commit is contained in:
		
							parent
							
								
									066e626401
								
							
						
					
					
						commit
						5030852c8e
					
				
					 2 changed files with 14 additions and 22 deletions
				
			
		| 
						 | 
					@ -158,7 +158,9 @@ static void sink_request_rewind_cb(pa_sink *s) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Just hand this one over to the master sink */
 | 
					    /* Just hand this one over to the master sink */
 | 
				
			||||||
    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes + pa_memblockq_get_length(u->memblockq), TRUE, FALSE, FALSE);
 | 
					    pa_sink_input_request_rewind(u->sink_input,
 | 
				
			||||||
 | 
					                                 s->thread_info.rewind_nbytes +
 | 
				
			||||||
 | 
					                                 pa_memblockq_get_length(u->memblockq), TRUE, FALSE, FALSE);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from I/O thread context */
 | 
					/* Called from I/O thread context */
 | 
				
			||||||
| 
						 | 
					@ -924,7 +926,6 @@ void pa__done(pa_module*m) {
 | 
				
			||||||
        pa_memblockq_free(u->memblockq);
 | 
					        pa_memblockq_free(u->memblockq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_xfree(u->input);
 | 
					    pa_xfree(u->input);
 | 
				
			||||||
 | 
					 | 
				
			||||||
    pa_xfree(u->control);
 | 
					    pa_xfree(u->control);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_xfree(u);
 | 
					    pa_xfree(u);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,7 +142,9 @@ static void sink_request_rewind_cb(pa_sink *s) {
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Just hand this one over to the master sink */
 | 
					    /* Just hand this one over to the master sink */
 | 
				
			||||||
    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes + pa_memblockq_get_length(u->memblockq), TRUE, FALSE, FALSE);
 | 
					    pa_sink_input_request_rewind(u->sink_input,
 | 
				
			||||||
 | 
					                                 s->thread_info.rewind_nbytes +
 | 
				
			||||||
 | 
					                                 pa_memblockq_get_length(u->memblockq), TRUE, FALSE, FALSE);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Called from I/O thread context */
 | 
					/* Called from I/O thread context */
 | 
				
			||||||
| 
						 | 
					@ -234,17 +236,20 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
 | 
				
			||||||
    dst = (float*) pa_memblock_acquire(chunk->memblock);
 | 
					    dst = (float*) pa_memblock_acquire(chunk->memblock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* PUT YOUR CODE HERE TO DO SOMETHING WITH THE DATA */
 | 
					    /* PUT YOUR CODE HERE TO DO SOMETHING WITH THE DATA */
 | 
				
			||||||
    /* example, copy input to output */
 | 
					
 | 
				
			||||||
 | 
					    /* As an example, copy input to output */
 | 
				
			||||||
    for (c = 0; c < u->channels; c++) {
 | 
					    for (c = 0; c < u->channels; c++) {
 | 
				
			||||||
        pa_sample_clamp(PA_SAMPLE_FLOAT32NE,dst+c, u->channels*sizeof(float),
 | 
					        pa_sample_clamp(PA_SAMPLE_FLOAT32NE,
 | 
				
			||||||
                        src+c, u->channels*sizeof(float),n);
 | 
					                        dst+c, u->channels*sizeof(float),
 | 
				
			||||||
 | 
					                        src+c, u->channels*sizeof(float),
 | 
				
			||||||
 | 
					                        n);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_memblock_release(tchunk.memblock);
 | 
					    pa_memblock_release(tchunk.memblock);
 | 
				
			||||||
    pa_memblock_release(chunk->memblock);
 | 
					    pa_memblock_release(chunk->memblock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_memblock_unref(tchunk.memblock);
 | 
					    pa_memblock_unref(tchunk.memblock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    curr_latency =
 | 
					    curr_latency =
 | 
				
			||||||
        /* Get the latency of the master sink */
 | 
					        /* Get the latency of the master sink */
 | 
				
			||||||
        pa_sink_get_latency_within_thread(i->sink) +
 | 
					        pa_sink_get_latency_within_thread(i->sink) +
 | 
				
			||||||
| 
						 | 
					@ -254,7 +259,6 @@ static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* FIXME: do something with the latency */
 | 
					    /* FIXME: do something with the latency */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -275,8 +279,8 @@ static void sink_input_process_rewind_cb(pa_sink_input *i, size_t nbytes) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (amount > 0) {
 | 
					        if (amount > 0) {
 | 
				
			||||||
            pa_memblockq_seek(u->memblockq, - (int64_t) amount, PA_SEEK_RELATIVE, TRUE);
 | 
					            pa_memblockq_seek(u->memblockq, - (int64_t) amount, PA_SEEK_RELATIVE, TRUE);
 | 
				
			||||||
            /* NEED TO RESET POST-PROCESSING HERE */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            /* PUT YOUR CODE HERE TO RESET POST-PROCESSING  */
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -480,19 +484,10 @@ int pa__init(pa_module*m) {
 | 
				
			||||||
        goto fail;
 | 
					        goto fail;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    u = pa_xnew0(struct userdata, 1);
 | 
					    u = pa_xnew0(struct userdata, 1);
 | 
				
			||||||
    if (!u) {
 | 
					 | 
				
			||||||
        pa_log("Failed to alloc userdata");
 | 
					 | 
				
			||||||
        goto fail;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    u->module = m;
 | 
					    u->module = m;
 | 
				
			||||||
    m->userdata = u;
 | 
					    m->userdata = u;
 | 
				
			||||||
    u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
 | 
					    u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
 | 
				
			||||||
    if (!u->memblockq) {
 | 
					 | 
				
			||||||
        pa_log("Failed to create sink memblockq.");
 | 
					 | 
				
			||||||
        goto fail;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    u->channels = ss.channels;
 | 
					    u->channels = ss.channels;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Create sink */
 | 
					    /* Create sink */
 | 
				
			||||||
| 
						 | 
					@ -572,8 +567,6 @@ int pa__init(pa_module*m) {
 | 
				
			||||||
    u->sink_input->mute_changed = sink_input_mute_changed_cb;
 | 
					    u->sink_input->mute_changed = sink_input_mute_changed_cb;
 | 
				
			||||||
    u->sink_input->userdata = u;
 | 
					    u->sink_input->userdata = u;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //pa_sink_input_set_requested_latency(u->sink_input, 5000);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pa_sink_put(u->sink);
 | 
					    pa_sink_put(u->sink);
 | 
				
			||||||
    pa_sink_input_put(u->sink_input);
 | 
					    pa_sink_input_put(u->sink_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -626,10 +619,8 @@ void pa__done(pa_module*m) {
 | 
				
			||||||
    if (u->sink)
 | 
					    if (u->sink)
 | 
				
			||||||
        pa_sink_unref(u->sink);
 | 
					        pa_sink_unref(u->sink);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (u->memblockq)
 | 
					    if (u->memblockq)
 | 
				
			||||||
        pa_memblockq_free(u->memblockq);
 | 
					        pa_memblockq_free(u->memblockq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
    pa_xfree(u);
 | 
					    pa_xfree(u);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue