/* * NAME: hfs->close() * DESCRIPTION: close a file */ int hfs_close(hfsfile *file) { hfsvol *vol = file->vol; int result = 0; if (--(file->refs)) { // File still has more refs printf("file %s still has %d refs\n", file->name, file->refs); return 0; } if (f_trunc(file) == -1 || f_flush(file) == -1) result = -1; if (file->prev) file->prev->next = file->next; if (file->next) file->next->prev = file->prev; if (file == vol->files) vol->files = file->next; FREE(file); return result; }
void i_deref(inoptr ino) { magic(ino); if(!ino->c_refs) panic("inode freed."); if((ino->c_node.i_mode & F_MASK) == F_PIPE) wakeup((char *)ino); /* If the inode has no links and no refs, it must have its blocks freed. */ if(!(--ino->c_refs || ino->c_node.i_nlink)) /* SN (mcy) */ if(((ino->c_node.i_mode & F_MASK) == F_REG) || ((ino->c_node.i_mode & F_MASK) == F_DIR) || ((ino->c_node.i_mode & F_MASK) == F_PIPE)) f_trunc(ino); /* If the inode was modified, we must write it to disk. */ if(!(ino->c_refs) && ino->c_dirty) { if(!(ino->c_node.i_nlink)) { ino->c_node.i_mode = 0; i_free(ino->c_dev, ino->c_num); } wr_inode(ino); } }
/* * NAME: hfs->setfork() * DESCRIPTION: select file fork for I/O operations */ int hfs_setfork(hfsfile *file, int fork) { int result = 0; if (f_trunc(file) == -1) result = -1; f_selectfork(file, fork ? fkRsrc : fkData); return result; }
uint8_t write_core_image(void) { inoptr parent = NULLINODE; inoptr ino; udata.u_error = 0; /* FIXME: need to think more about the case sp is lala */ if (uput("core", (uint8_t *)udata.u_syscall_sp - 5, 5)) return 0; ino = n_open((char *)udata.u_syscall_sp - 5, &parent); if (ino) { i_deref(parent); return 0; } if (parent) { i_lock(parent); if ((ino = newfile(parent, "core")) != NULL) { ino->c_node.i_mode = F_REG | 0400; setftime(ino, A_TIME | M_TIME | C_TIME); wr_inode(ino); f_trunc(ino); #if 0 /* FIXME address ranges for different models - move core writer for address spaces into helpers ? */ /* FIXME: need to add some arch specific header bits, and also pull stuff like the true sp and registers out of the return stack properly */ corehdr.ch_base = pagemap_base; corehdr.ch_break = udata.u_break; corehdr.ch_sp = udata.u_syscall_sp; corehdr.ch_top = PROGTOP; udata.u_offset = 0; udata.u_base = (uint8_t *)&corehdr; udata.u_sysio = true; udata.u_count = sizeof(corehdr); writei(ino, 0); udata.u_sysio = false; udata.u_base = (uint8_t *)pagemap_base; udata.u_count = udata.u_break - pagemap_base; writei(ino, 0); udata.u_base = udata.u_sp; udata.u_count = PROGTOP - (uint32_t)udata.u_sp; writei(ino, 0); #endif i_unlock_deref(ino); return W_COREDUMP; } } return 0; }
/* * NAME: hfs->setfork() * DESCRIPTION: select file fork for I/O operations */ int hfs_setfork(hfsfile *file, int fork) { int result = 0; if (! (file->vol->flags & HFS_READONLY) && f_trunc(file) < 0) result = -1; f_selectfork(file, fork); return result; }
uint8_t write_core_image(void) { inoptr parent = NULLINODE; inoptr ino; udata.u_error = 0; /* FIXME: need to think more about the case sp is lala */ if (uput("core", udata.u_syscall_sp - 5, 5)) return 0; ino = n_open(udata.u_syscall_sp - 5, &parent); if (ino) { i_deref(parent); return 0; } if (parent) { i_lock(parent); if (ino = newfile(parent, "core")) { ino->c_node.i_mode = F_REG | 0400; setftime(ino, A_TIME | M_TIME | C_TIME); wr_inode(ino); f_trunc(ino); /* FIXME: need to add some arch specific header bits, and also pull stuff like the true sp and registers out of the return stack properly */ corehdr.ch_base = MAPBASE; corehdr.ch_break = udata.u_break; corehdr.ch_sp = udata.u_syscall_sp; corehdr.ch_top = PROGTOP; udata.u_offset = 0; udata.u_base = (uint8_t *)&corehdr; udata.u_sysio = true; udata.u_count = sizeof(corehdr); writei(ino, 0); udata.u_sysio = false; udata.u_base = MAPBASE; udata.u_count = udata.u_break - MAPBASE; writei(ino, 0); udata.u_base = udata.u_sp; udata.u_count = PROGTOP - (uint16_t)udata.u_sp; writei(ino, 0); i_unlock_deref(ino); return W_COREDUMP; } } return 0; }
static void runAddingCombSplitter(LADSPA_Handle instance, unsigned long sample_count) { CombSplitter *plugin_data = (CombSplitter *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Band separation (Hz) (float value) */ const LADSPA_Data freq = *(plugin_data->freq); /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output 1 (array of floats of length sample_count) */ LADSPA_Data * const out1 = plugin_data->out1; /* Output 2 (array of floats of length sample_count) */ LADSPA_Data * const out2 = plugin_data->out2; long comb_pos = plugin_data->comb_pos; LADSPA_Data * comb_tbl = plugin_data->comb_tbl; float last_offset = plugin_data->last_offset; long sample_rate = plugin_data->sample_rate; float offset; int data_pos; unsigned long pos; float xf, xf_step, d_pos, fr, interp, in; offset = sample_rate / freq; offset = f_clamp(offset, 0, COMB_SIZE - 1); xf_step = 1.0f / (float)sample_count; xf = 0.0f; for (pos = 0; pos < sample_count; pos++) { xf += xf_step; d_pos = comb_pos - LIN_INTERP(xf, last_offset, offset); data_pos = f_trunc(d_pos); fr = d_pos - data_pos; interp = cube_interp(fr, comb_tbl[(data_pos - 1) & COMB_MASK], comb_tbl[data_pos & COMB_MASK], comb_tbl[(data_pos + 1) & COMB_MASK], comb_tbl[(data_pos + 2) & COMB_MASK]); in = input[pos]; comb_tbl[comb_pos] = in; buffer_write(out1[pos], (in + interp) * 0.5f); buffer_write(out2[pos], (in - interp) * 0.5f); comb_pos = (comb_pos + 1) & COMB_MASK; } plugin_data->comb_pos = comb_pos; plugin_data->last_offset = offset; }
static void runComb(LADSPA_Handle instance, unsigned long sample_count) { Comb *plugin_data = (Comb *)instance; /* Band separation (Hz) (float value) */ const LADSPA_Data freq = *(plugin_data->freq); /* Feedback (float value) */ const LADSPA_Data fb = *(plugin_data->fb); /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output (array of floats of length sample_count) */ LADSPA_Data * const output = plugin_data->output; long comb_pos = plugin_data->comb_pos; LADSPA_Data * comb_tbl = plugin_data->comb_tbl; float last_offset = plugin_data->last_offset; long sample_rate = plugin_data->sample_rate; #line 41 "comb_1190.xml" float offset; int data_pos; unsigned long pos; float xf, xf_step, d_pos, fr, interp; offset = sample_rate / freq; offset = f_clamp(offset, 0, COMB_SIZE - 1); xf_step = 1.0f / (float)sample_count; xf = 0.0f; for (pos = 0; pos < sample_count; pos++) { xf += xf_step; d_pos = comb_pos - LIN_INTERP(xf, last_offset, offset); data_pos = f_trunc(d_pos); fr = d_pos - data_pos; interp = cube_interp(fr, comb_tbl[(data_pos - 1) & COMB_MASK], comb_tbl[data_pos & COMB_MASK], comb_tbl[(data_pos + 1) & COMB_MASK], comb_tbl[(data_pos + 2) & COMB_MASK]); comb_tbl[comb_pos] = input[pos] + fb * interp; buffer_write(output[pos], (input[pos] + interp) * 0.5f); comb_pos = (comb_pos + 1) & COMB_MASK; } plugin_data->comb_pos = comb_pos; plugin_data->last_offset = offset; }
/* * NAME: hfs->close() * DESCRIPTION: close a file */ int hfs_close(hfsfile *file) { hfsvol *vol = file->vol; int result = 0; if (f_trunc(file) == -1 || f_flush(file) == -1) result = -1; if (file->prev) file->prev->next = file->next; if (file->next) file->next->prev = file->prev; if (file == vol->files) vol->files = file->next; FREE(file); return result; }
static void runAddingRetroFlange(LADSPA_Handle instance, unsigned long sample_count) { RetroFlange *plugin_data = (RetroFlange *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Average stall (ms) (float value) */ const LADSPA_Data delay_depth_avg = *(plugin_data->delay_depth_avg); /* Flange frequency (Hz) (float value) */ const LADSPA_Data law_freq = *(plugin_data->law_freq); /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output (array of floats of length sample_count) */ LADSPA_Data * const output = plugin_data->output; LADSPA_Data * buffer = plugin_data->buffer; long buffer_size = plugin_data->buffer_size; long count = plugin_data->count; LADSPA_Data * delay_line = plugin_data->delay_line; int delay_line_length = plugin_data->delay_line_length; int delay_pos = plugin_data->delay_pos; LADSPA_Data last_in = plugin_data->last_in; int last_law_p = plugin_data->last_law_p; int last_phase = plugin_data->last_phase; int max_law_p = plugin_data->max_law_p; float next_law_peak = plugin_data->next_law_peak; int next_law_pos = plugin_data->next_law_pos; float phase = plugin_data->phase; float prev_law_peak = plugin_data->prev_law_peak; int prev_law_pos = plugin_data->prev_law_pos; long sample_rate = plugin_data->sample_rate; LADSPA_Data z0 = plugin_data->z0; LADSPA_Data z1 = plugin_data->z1; LADSPA_Data z2 = plugin_data->z2; #line 75 "retro_flange_1208.xml" long int pos; int law_p = f_trunc(LIMIT(sample_rate / f_clamp(law_freq, 0.0001f, 100.0f), 1, max_law_p)); float increment; float lin_int, lin_inc; int track; int fph; LADSPA_Data out = 0.0f; const float dda_c = f_clamp(delay_depth_avg, 0.0f, 10.0f); int dl_used = (dda_c * sample_rate) / 1000; float inc_base = 1000.0f * (float)BASE_BUFFER; const float delay_depth = 2.0f * dda_c; float n_ph, p_ph, law; for (pos = 0; pos < sample_count; pos++) { // Write into the delay line delay_line[delay_pos] = input[pos]; z0 = delay_line[MOD(delay_pos - dl_used, delay_line_length)] + 0.12919609397f*z1 - 0.31050847f*z2; out = sat(z0*0.20466966f + z1*0.40933933f + z2*0.40933933f, -0.23f, 3.3f); z2 = z1; z1 = z0; delay_pos = (delay_pos + 1) % delay_line_length; if ((count++ % law_p) == 0) { // Value for amplitude of law peak next_law_peak = (float)rand() / (float)RAND_MAX; next_law_pos = count + law_p; } else if (count % law_p == law_p / 2) { // Value for amplitude of law peak prev_law_peak = (float)rand() / (float)RAND_MAX; prev_law_pos = count + law_p; } n_ph = (float)(law_p - abs(next_law_pos - count))/(float)law_p; p_ph = n_ph + 0.5f; if (p_ph > 1.0f) { p_ph -= 1.0f; } law = f_sin_sq(3.1415926f*p_ph)*prev_law_peak + f_sin_sq(3.1415926f*n_ph)*next_law_peak; increment = inc_base / (delay_depth * law + 0.2); fph = f_trunc(phase); last_phase = fph; lin_int = phase - (float)fph; out += LIN_INTERP(lin_int, buffer[(fph+1) % buffer_size], buffer[(fph+2) % buffer_size]); phase += increment; lin_inc = 1.0f / (floor(phase) - last_phase + 1); lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc; lin_int = 0.0f; for (track = last_phase; track < phase; track++) { lin_int += lin_inc; buffer[track % buffer_size] = LIN_INTERP(lin_int, last_in, input[pos]); } last_in = input[pos]; buffer_write(output[pos], out * 0.707f); if (phase >= buffer_size) { phase -= buffer_size; } } // Store current phase in instance plugin_data->phase = phase; plugin_data->prev_law_peak = prev_law_peak; plugin_data->next_law_peak = next_law_peak; plugin_data->prev_law_pos = prev_law_pos; plugin_data->next_law_pos = next_law_pos; plugin_data->last_phase = last_phase; plugin_data->last_in = last_in; plugin_data->count = count; plugin_data->last_law_p = last_law_p; plugin_data->delay_pos = delay_pos; plugin_data->z0 = z0; plugin_data->z1 = z1; plugin_data->z2 = z2; }
void processAudio(AudioBuffer& _buf){ uint32_t sample_count = _buf.getSize(); float s_rate = getSampleRate(); delay_depth_avg = getParameterValue(PARAMETER_A)*10 - 0; law_freq = getParameterValue(PARAMETER_B)*7.5 - 0.5; input = _buf.getSamples(0); output = _buf.getSamples(0); RetroFlangePatch* plugin_data = this; long int pos; int law_p = f_trunc(LIMIT(sample_rate / f_clamp(law_freq, 0.0001f, 100.0f), 1, max_law_p)); float increment; float lin_int, lin_inc; int track; int fph; LADSPA_Data out = 0.0f; const float dda_c = f_clamp(delay_depth_avg, 0.0f, 10.0f); int dl_used = (dda_c * sample_rate) / 1000; float inc_base = 1000.0f * (float)BASE_BUFFER; const float delay_depth = 2.0f * dda_c; float n_ph, p_ph, law; for (pos = 0; pos < sample_count; pos++) { // Write into the delay line delay_line[delay_pos] = input[pos]; z0 = delay_line[MOD(delay_pos - dl_used, delay_line_length)] + 0.12919609397f*z1 - 0.31050847f*z2; out = sat(z0*0.20466966f + z1*0.40933933f + z2*0.40933933f, -0.23f, 3.3f); z2 = z1; z1 = z0; delay_pos = (delay_pos + 1) % delay_line_length; if ((count++ % law_p) == 0) { // Value for amplitude of law peak next_law_peak = (float)rand() / (float)RAND_MAX; next_law_pos = count + law_p; } else if (count % law_p == law_p / 2) { // Value for amplitude of law peak prev_law_peak = (float)rand() / (float)RAND_MAX; prev_law_pos = count + law_p; } n_ph = (float)(law_p - abs(next_law_pos - count))/(float)law_p; p_ph = n_ph + 0.5f; if (p_ph > 1.0f) { p_ph -= 1.0f; } law = f_sin_sq(3.1415926f*p_ph)*prev_law_peak + f_sin_sq(3.1415926f*n_ph)*next_law_peak; increment = inc_base / (delay_depth * law + 0.2); fph = f_trunc(phase); last_phase = fph; lin_int = phase - (float)fph; out += LIN_INTERP(lin_int, buffer[(fph+1) % buffer_size], buffer[(fph+2) % buffer_size]); phase += increment; lin_inc = 1.0f / (floor(phase) - last_phase + 1); lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc; lin_int = 0.0f; for (track = last_phase; track < phase; track++) { lin_int += lin_inc; buffer[track % buffer_size] = LIN_INTERP(lin_int, last_in, input[pos]); } last_in = input[pos]; buffer_write(output[pos], out * 0.707f); if (phase >= buffer_size) { phase -= buffer_size; } } // Store current phase in instance plugin_data->phase = phase; plugin_data->prev_law_peak = prev_law_peak; plugin_data->next_law_peak = next_law_peak; plugin_data->prev_law_pos = prev_law_pos; plugin_data->next_law_pos = next_law_pos; plugin_data->last_phase = last_phase; plugin_data->last_in = last_in; plugin_data->count = count; plugin_data->last_law_p = last_law_p; plugin_data->delay_pos = delay_pos; plugin_data->z0 = z0; plugin_data->z1 = z1; plugin_data->z2 = z2; }
/* * NAME: hfs->delete() * DESCRIPTION: remove both forks of a file */ int hfs_delete(hfsvol *vol, const char *path) { hfsfile file; CatKeyRec key; byte pkey[HFS_CATKEYLEN]; int found; if (getvol(&vol) == -1 || v_resolve(&vol, path, &file.cat, &file.parid, file.name, 0) <= 0) goto fail; if (file.cat.cdrType != cdrFilRec) ERROR(EISDIR, 0); if (file.parid == HFS_CNID_ROOTPAR) ERROR(EINVAL, 0); if (vol->flags & HFS_VOL_READONLY) ERROR(EROFS, 0); /* free allocation blocks */ file.vol = vol; file.flags = 0; file.cat.u.fil.filLgLen = 0; file.cat.u.fil.filRLgLen = 0; f_selectfork(&file, fkData); if (f_trunc(&file) == -1) goto fail; f_selectfork(&file, fkRsrc); if (f_trunc(&file) == -1) goto fail; /* delete file record */ r_makecatkey(&key, file.parid, file.name); r_packcatkey(&key, pkey, 0); if (bt_delete(&vol->cat, pkey) == -1 || v_adjvalence(vol, file.parid, 0, -1) == -1) goto fail; /* delete file thread, if any */ found = v_getfthread(vol, file.cat.u.fil.filFlNum, 0, 0); if (found == -1) goto fail; if (found) { r_makecatkey(&key, file.cat.u.fil.filFlNum, ""); r_packcatkey(&key, pkey, 0); if (bt_delete(&vol->cat, pkey) == -1) goto fail; } return 0; fail: return -1; }
arg_t _open(void) { int8_t uindex; int8_t oftindex; staticfast inoptr ino; int16_t perm; staticfast inoptr parent; char fname[FILENAME_LEN + 1]; int trunc; int r; int w; int j; parent = NULLINODE; trunc = flag & O_TRUNC; r = (flag + 1) & 1; w = (flag + 1) & 2; if (O_ACCMODE(flag) == 3 || (flag & O_BADBITS)) { udata.u_error = EINVAL; return (-1); } if ((uindex = uf_alloc()) == -1) return (-1); if ((oftindex = oft_alloc()) == -1) goto nooft; ino = n_open(name, &parent); if (ino) { i_deref(parent); /* O_EXCL test */ if ((flag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL)) { udata.u_error = EEXIST; goto idrop; } } else { /* The n_open failed */ if (udata.u_error == EFAULT) goto cantopen; /* New file */ if (!(flag & O_CREAT)) { udata.u_error = ENOENT; goto cantopen; } filename(name, fname); /* newfile drops parent for us */ if (parent && (ino = newfile(parent, fname))) { ino->c_node.i_mode = (F_REG | (mode & MODE_MASK & ~udata.u_mask)); setftime(ino, A_TIME | M_TIME | C_TIME); wr_inode(ino); } else { udata.u_error = ENFILE; /* FIXME, should be set in newfile not bodged to a guessed code */ goto cantopen; } } /* Book our slot in case we block opening a device */ of_tab[oftindex].o_inode = ino; perm = getperm(ino); if ((r && !(perm & OTH_RD)) || (w && !(perm & OTH_WR))) { udata.u_error = EACCES; goto cantopen; } if (w) { if (getmode(ino) == F_DIR ) { udata.u_error = EISDIR; goto cantopen; } if (ino->c_flags & CRDONLY) { udata.u_error = EROFS; goto cantopen; } } if (isdevice(ino)) { inoptr *iptr = &of_tab[oftindex].o_inode; /* d_open may block and thus ino may become invalid as may parent (but we don't need it again). It may also be changed by the call to dev_openi */ if (dev_openi(iptr, flag) != 0) goto cantopen; /* May have changed */ /* get the static pointer back in case it changed via dev usage or just because we blocked */ ino = *iptr; } if (trunc && getmode(ino) == F_REG) { if (f_trunc(ino)) goto idrop; for (j = 0; j < OFTSIZE; ++j) /* Arguably should fix at read/write */ if (of_tab[j].o_inode == ino) of_tab[j].o_ptr = 0; } udata.u_files[uindex] = oftindex; of_tab[oftindex].o_ptr = 0; of_tab[oftindex].o_access = flag; /* Save the low bits only */ if (flag & O_CLOEXEC) udata.u_cloexec |= (1 << oftindex); /* FIXME: ATIME ? */ /* * Sleep process if no writer or reader */ if (getmode(ino) == F_PIPE && of_tab[oftindex].o_refs == 1 && !(flag & O_NDELAY)) psleep(ino); /* From the moment of the psleep ino is invalid */ return (uindex); idrop: i_deref(ino); cantopen: oft_deref(oftindex); /* This will call i_deref() */ nooft: udata.u_files[uindex] = NO_FILE; return (-1); }
static void runAddingTapeDelay(LADSPA_Handle instance, unsigned long sample_count) { TapeDelay *plugin_data = (TapeDelay *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Tape speed (inches/sec, 1=normal) (float value) */ const LADSPA_Data speed = *(plugin_data->speed); /* Dry level (dB) (float value) */ const LADSPA_Data da_db = *(plugin_data->da_db); /* Tap 1 distance (inches) (float value) */ const LADSPA_Data t1d = *(plugin_data->t1d); /* Tap 1 level (dB) (float value) */ const LADSPA_Data t1a_db = *(plugin_data->t1a_db); /* Tap 2 distance (inches) (float value) */ const LADSPA_Data t2d = *(plugin_data->t2d); /* Tap 2 level (dB) (float value) */ const LADSPA_Data t2a_db = *(plugin_data->t2a_db); /* Tap 3 distance (inches) (float value) */ const LADSPA_Data t3d = *(plugin_data->t3d); /* Tap 3 level (dB) (float value) */ const LADSPA_Data t3a_db = *(plugin_data->t3a_db); /* Tap 4 distance (inches) (float value) */ const LADSPA_Data t4d = *(plugin_data->t4d); /* Tap 4 level (dB) (float value) */ const LADSPA_Data t4a_db = *(plugin_data->t4a_db); /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output (array of floats of length sample_count) */ LADSPA_Data * const output = plugin_data->output; LADSPA_Data * buffer = plugin_data->buffer; unsigned int buffer_mask = plugin_data->buffer_mask; unsigned int buffer_size = plugin_data->buffer_size; LADSPA_Data last2_in = plugin_data->last2_in; LADSPA_Data last3_in = plugin_data->last3_in; LADSPA_Data last_in = plugin_data->last_in; unsigned int last_phase = plugin_data->last_phase; float phase = plugin_data->phase; int sample_rate = plugin_data->sample_rate; LADSPA_Data z0 = plugin_data->z0; LADSPA_Data z1 = plugin_data->z1; LADSPA_Data z2 = plugin_data->z2; unsigned int pos; float increment = f_clamp(speed, 0.0f, 40.0f); float lin_int, lin_inc; unsigned int track; unsigned int fph; LADSPA_Data out; const float da = DB_CO(da_db); const float t1a = DB_CO(t1a_db); const float t2a = DB_CO(t2a_db); const float t3a = DB_CO(t3a_db); const float t4a = DB_CO(t4a_db); const unsigned int t1d_s = f_round(t1d * sample_rate); const unsigned int t2d_s = f_round(t2d * sample_rate); const unsigned int t3d_s = f_round(t3d * sample_rate); const unsigned int t4d_s = f_round(t4d * sample_rate); for (pos = 0; pos < sample_count; pos++) { fph = f_trunc(phase); last_phase = fph; lin_int = phase - (float)fph; out = buffer[(unsigned int)(fph - t1d_s) & buffer_mask] * t1a; out += buffer[(unsigned int)(fph - t2d_s) & buffer_mask] * t2a; out += buffer[(unsigned int)(fph - t3d_s) & buffer_mask] * t3a; out += buffer[(unsigned int)(fph - t4d_s) & buffer_mask] * t4a; phase += increment; lin_inc = 1.0f / (floor(phase) - last_phase + 1); lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc; lin_int = 0.0f; for (track = last_phase; track < phase; track++) { lin_int += lin_inc; buffer[track & buffer_mask] = cube_interp(lin_int, last3_in, last2_in, last_in, input[pos]); } last3_in = last2_in; last2_in = last_in; last_in = input[pos]; out += input[pos] * da; buffer_write(output[pos], out); if (phase >= buffer_size) { phase -= buffer_size; } } // Store current phase in instance plugin_data->phase = phase; plugin_data->last_phase = last_phase; plugin_data->last_in = last_in; plugin_data->last2_in = last2_in; plugin_data->last3_in = last3_in; plugin_data->z0 = z0; plugin_data->z1 = z1; plugin_data->z2 = z2; }
/* * NAME: hfs->delete() * DESCRIPTION: remove both forks of a file */ int hfs_delete(hfsvol *vol, char *path) { hfsfile file; CatKeyRec key; unsigned char pkey[HFS_CATKEYLEN]; int found; if (v_getvol(&vol) < 0 || v_resolve(&vol, path, &file.cat, &file.parid, file.name, 0) <= 0) return -1; if (file.cat.cdrType != cdrFilRec) { ERROR(EISDIR, 0); return -1; } if (file.parid == HFS_CNID_ROOTPAR) { ERROR(EINVAL, 0); return -1; } if (vol->flags & HFS_READONLY) { ERROR(EROFS, 0); return -1; } /* free disk blocks */ file.vol = vol; file.flags = 0; file.cat.u.fil.filLgLen = 0; file.cat.u.fil.filRLgLen = 0; f_selectfork(&file, 0); if (f_trunc(&file) < 0) return -1; f_selectfork(&file, 1); if (f_trunc(&file) < 0) return -1; /* delete file record */ r_makecatkey(&key, file.parid, file.name); r_packcatkey(&key, pkey, 0); if (bt_delete(&vol->cat, pkey) < 0 || v_adjvalence(vol, file.parid, 0, -1) < 0) return -1; /* delete file thread, if any */ found = v_getfthread(vol, file.cat.u.fil.filFlNum, 0, 0); if (found < 0) return -1; if (found) { r_makecatkey(&key, file.cat.u.fil.filFlNum, (char *)""); r_packcatkey(&key, pkey, 0); if (bt_delete(&vol->cat, pkey) < 0) return -1; } return 0; }