Browse Source

[alsa-out] safety commit (somethings wrong)

git-svn-id: svn+ssh://jackaudio.org/trunk/jack@3384 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.117.0
torben 17 years ago
parent
commit
f224e7e3b4
1 changed files with 12 additions and 7 deletions
  1. +12
    -7
      tools/alsa_out.c

+ 12
- 7
tools/alsa_out.c View File

@@ -296,7 +296,7 @@ int process (jack_nframes_t nframes, void *arg) {
int rlen;
int err;
snd_pcm_sframes_t delay = target_delay;
int i;

snd_pcm_delay( alsa_handle, &delay );

@@ -311,6 +311,10 @@ int process (jack_nframes_t nframes, void *arg) {
delay = target_delay;
//current_resample_factor = (double) sample_rate / (double) jack_sample_rate;
current_resample_factor = resample_mean;
offset_integral = - (resample_mean - 1.0) * catch_factor * catch_factor2;
//offset_integral = 0;
for( i=0; i<OFF_D_SIZE; i++ )
offset_array[i] = 0.0;
jumped = 3;
}
if( delay < (target_delay-max_diff) ) {
@@ -323,6 +327,12 @@ int process (jack_nframes_t nframes, void *arg) {
delay = target_delay;
//current_resample_factor = (double) sample_rate / (double) jack_sample_rate;
current_resample_factor = resample_mean;
// Set the resample_rate... we need to adjust the offset integral, to do this.
offset_integral = - (resample_mean - 1.0) * catch_factor * catch_factor2;
//offset_integral = 0;
for( i=0; i<OFF_D_SIZE; i++ )
offset_array[i] = 0.0;
jumped = 3;
}
/* ok... now we should have target_delay +- max_diff on the alsa side.
@@ -358,7 +368,6 @@ int process (jack_nframes_t nframes, void *arg) {
offset_differential_array[(offset_differential_index++) % OFF_D_SIZE ] = 0.0;
}

int i;
double smooth_offset_differential = 0.0;
for( i=0; i<OFF_D_SIZE; i++ )
smooth_offset_differential +=
@@ -371,10 +380,6 @@ int process (jack_nframes_t nframes, void *arg) {
offset_array[ (i + offset_differential_index-1) % OFF_D_SIZE] * hann( (double) i / ((double) OFF_D_SIZE - 1.0) );
smooth_offset /= (double) OFF_D_SIZE;

////////////////////////
dd_resample_factor = 0.9999 * dd_resample_factor + 0.0001 * smooth_offset;
//smooth_offset_differential = dd_resample_factor;
///////////////////////////////////
old_offset = offset;

offset_integral += smooth_offset;
@@ -384,7 +389,7 @@ int process (jack_nframes_t nframes, void *arg) {
smooth_offset = 0.0;

current_resample_factor = 1.0 - smooth_offset / (double) catch_factor - offset_integral / (double) catch_factor / (double)catch_factor2;
current_resample_factor = floor( current_resample_factor * 50000 + 0.5 ) / 50000;
current_resample_factor = floor( current_resample_factor * 100000.0 + 0.5 ) / 100000.0;
//current_resample_factor -= offset_integral / (double) nframes / (double)10000000 / (double) catch_factor;

//current_resample_factor -= pow(smooth_offset/ (double) nframes, 3) / (double) catch_factor;


Loading…
Cancel
Save