mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	add API for resetting allocated resamplers
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2088 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
		
							parent
							
								
									7f65e79e73
								
							
						
					
					
						commit
						2a44213430
					
				
					 2 changed files with 35 additions and 7 deletions
				
			
		| 
						 | 
					@ -72,6 +72,7 @@ struct pa_resampler {
 | 
				
			||||||
    void (*impl_free)(pa_resampler *r);
 | 
					    void (*impl_free)(pa_resampler *r);
 | 
				
			||||||
    void (*impl_update_rates)(pa_resampler *r);
 | 
					    void (*impl_update_rates)(pa_resampler *r);
 | 
				
			||||||
    void (*impl_resample)(pa_resampler *r, const pa_memchunk *in, unsigned in_samples, pa_memchunk *out, unsigned *out_samples);
 | 
					    void (*impl_resample)(pa_resampler *r, const pa_memchunk *in, unsigned in_samples, pa_memchunk *out, unsigned *out_samples);
 | 
				
			||||||
 | 
					    void (*impl_reset)(pa_resampler *r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    struct { /* data specific to the trivial resampler */
 | 
					    struct { /* data specific to the trivial resampler */
 | 
				
			||||||
        unsigned o_counter;
 | 
					        unsigned o_counter;
 | 
				
			||||||
| 
						 | 
					@ -208,6 +209,7 @@ pa_resampler* pa_resampler_new(
 | 
				
			||||||
    r->impl_free = NULL;
 | 
					    r->impl_free = NULL;
 | 
				
			||||||
    r->impl_update_rates = NULL;
 | 
					    r->impl_update_rates = NULL;
 | 
				
			||||||
    r->impl_resample = NULL;
 | 
					    r->impl_resample = NULL;
 | 
				
			||||||
 | 
					    r->impl_reset = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Fill sample specs */
 | 
					    /* Fill sample specs */
 | 
				
			||||||
    r->i_ss = *a;
 | 
					    r->i_ss = *a;
 | 
				
			||||||
| 
						 | 
					@ -374,6 +376,13 @@ size_t pa_resampler_max_block_size(pa_resampler *r) {
 | 
				
			||||||
    return (((block_size_max/fs + EXTRA_SAMPLES)*r->i_ss.rate)/ss.rate)*r->i_fz;
 | 
					    return (((block_size_max/fs + EXTRA_SAMPLES)*r->i_ss.rate)/ss.rate)*r->i_fz;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pa_resampler_reset(pa_resampler *r) {
 | 
				
			||||||
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (r->impl_reset)
 | 
				
			||||||
 | 
					        r->impl_reset(r);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pa_resample_method_t pa_resampler_get_method(pa_resampler *r) {
 | 
					pa_resample_method_t pa_resampler_get_method(pa_resampler *r) {
 | 
				
			||||||
    pa_assert(r);
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1181,6 +1190,12 @@ static void libsamplerate_update_rates(pa_resampler *r) {
 | 
				
			||||||
    pa_assert_se(src_set_ratio(r->src.state, (double) r->o_ss.rate / r->i_ss.rate) == 0);
 | 
					    pa_assert_se(src_set_ratio(r->src.state, (double) r->o_ss.rate / r->i_ss.rate) == 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void libsamplerate_reset(pa_resampler *r) {
 | 
				
			||||||
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se(src_reset(r->src.state) == 0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void libsamplerate_free(pa_resampler *r) {
 | 
					static void libsamplerate_free(pa_resampler *r) {
 | 
				
			||||||
    pa_assert(r);
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1199,6 +1214,7 @@ static int libsamplerate_init(pa_resampler *r) {
 | 
				
			||||||
    r->impl_free = libsamplerate_free;
 | 
					    r->impl_free = libsamplerate_free;
 | 
				
			||||||
    r->impl_update_rates = libsamplerate_update_rates;
 | 
					    r->impl_update_rates = libsamplerate_update_rates;
 | 
				
			||||||
    r->impl_resample = libsamplerate_resample;
 | 
					    r->impl_resample = libsamplerate_resample;
 | 
				
			||||||
 | 
					    r->impl_reset = libsamplerate_reset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1259,6 +1275,17 @@ static void speex_update_rates(pa_resampler *r) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void speex_reset(pa_resampler *r) {
 | 
				
			||||||
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (r->method >= PA_RESAMPLER_SPEEX_FIXED_BASE && r->method <= PA_RESAMPLER_SPEEX_FIXED_MAX)
 | 
				
			||||||
 | 
					        pa_assert_se(paspfx_resampler_reset_mem(r->speex.state) == 0);
 | 
				
			||||||
 | 
					    else  {
 | 
				
			||||||
 | 
					        pa_assert(r->method >= PA_RESAMPLER_SPEEX_FLOAT_BASE && r->method <= PA_RESAMPLER_SPEEX_FLOAT_MAX);
 | 
				
			||||||
 | 
					        pa_assert_se(paspfl_resampler_reset_mem(r->speex.state) == 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void speex_free(pa_resampler *r) {
 | 
					static void speex_free(pa_resampler *r) {
 | 
				
			||||||
    pa_assert(r);
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1280,6 +1307,7 @@ static int speex_init(pa_resampler *r) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    r->impl_free = speex_free;
 | 
					    r->impl_free = speex_free;
 | 
				
			||||||
    r->impl_update_rates = speex_update_rates;
 | 
					    r->impl_update_rates = speex_update_rates;
 | 
				
			||||||
 | 
					    r->impl_reset = speex_reset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (r->method >= PA_RESAMPLER_SPEEX_FIXED_BASE && r->method <= PA_RESAMPLER_SPEEX_FIXED_MAX) {
 | 
					    if (r->method >= PA_RESAMPLER_SPEEX_FIXED_BASE && r->method <= PA_RESAMPLER_SPEEX_FIXED_MAX) {
 | 
				
			||||||
        q = r->method - PA_RESAMPLER_SPEEX_FIXED_BASE;
 | 
					        q = r->method - PA_RESAMPLER_SPEEX_FIXED_BASE;
 | 
				
			||||||
| 
						 | 
					@ -1353,7 +1381,7 @@ static void trivial_resample(pa_resampler *r, const pa_memchunk *input, unsigned
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void trivial_update_rates(pa_resampler *r) {
 | 
					static void trivial_update_rates_or_reset(pa_resampler *r) {
 | 
				
			||||||
    pa_assert(r);
 | 
					    pa_assert(r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    r->trivial.i_counter = 0;
 | 
					    r->trivial.i_counter = 0;
 | 
				
			||||||
| 
						 | 
					@ -1366,8 +1394,8 @@ static int trivial_init(pa_resampler*r) {
 | 
				
			||||||
    r->trivial.o_counter = r->trivial.i_counter = 0;
 | 
					    r->trivial.o_counter = r->trivial.i_counter = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    r->impl_resample = trivial_resample;
 | 
					    r->impl_resample = trivial_resample;
 | 
				
			||||||
    r->impl_update_rates = trivial_update_rates;
 | 
					    r->impl_update_rates = trivial_update_rates_or_reset;
 | 
				
			||||||
    r->impl_free = NULL;
 | 
					    r->impl_reset = trivial_update_rates_or_reset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1495,9 +1523,5 @@ static int copy_init(pa_resampler *r) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(r->o_ss.rate == r->i_ss.rate);
 | 
					    pa_assert(r->o_ss.rate == r->i_ss.rate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    r->impl_free = NULL;
 | 
					 | 
				
			||||||
    r->impl_resample = NULL;
 | 
					 | 
				
			||||||
    r->impl_update_rates = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -81,6 +81,9 @@ void pa_resampler_set_input_rate(pa_resampler *r, uint32_t rate);
 | 
				
			||||||
/* Change the output rate of the resampler object */
 | 
					/* Change the output rate of the resampler object */
 | 
				
			||||||
void pa_resampler_set_output_rate(pa_resampler *r, uint32_t rate);
 | 
					void pa_resampler_set_output_rate(pa_resampler *r, uint32_t rate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Reinitialize state of the resampler, possibly due to seeking or other discontinuities */
 | 
				
			||||||
 | 
					void pa_resampler_reset(pa_resampler *r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Return the resampling method of the resampler object */
 | 
					/* Return the resampling method of the resampler object */
 | 
				
			||||||
pa_resample_method_t pa_resampler_get_method(pa_resampler *r);
 | 
					pa_resample_method_t pa_resampler_get_method(pa_resampler *r);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,4 +96,5 @@ const char *pa_resample_method_to_string(pa_resample_method_t m);
 | 
				
			||||||
/* Return 1 when the specified resampling method is supported */
 | 
					/* Return 1 when the specified resampling method is supported */
 | 
				
			||||||
int pa_resample_method_supported(pa_resample_method_t m);
 | 
					int pa_resample_method_supported(pa_resample_method_t m);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue