Home | History | Annotate | Download | only in server

Lines Matching refs:ramp

45 void cras_ramp_destroy(struct cras_ramp* ramp)
47 free(ramp);
52 struct cras_ramp* ramp;
53 ramp = (struct cras_ramp*)malloc(sizeof(*ramp));
54 if (ramp == NULL) {
57 cras_ramp_reset(ramp);
58 return ramp;
61 int cras_ramp_reset(struct cras_ramp *ramp) {
62 ramp->state = CRAS_RAMP_STATE_IDLE;
63 ramp->ramped_frames = 0;
64 ramp->duration_frames = 0;
65 ramp->increment = 0;
66 ramp->start_scaler = 1.0;
70 int cras_ramp_start(struct cras_ramp *ramp, int is_up, int duration_frames,
76 action = cras_ramp_get_current_action(ramp);
83 ramp->state = CRAS_RAMP_STATE_UP;
85 ramp->start_scaler = 0;
87 ramp->start_scaler = action.scaler;
88 ramp->increment = (1 - ramp->start_scaler) / duration_frames;
90 ramp->state = CRAS_RAMP_STATE_DOWN;
92 ramp->start_scaler = 1;
94 ramp->start_scaler = action.scaler;
96 ramp->increment = -ramp->start_scaler / duration_frames;
98 ramp->ramped_frames = 0;
99 ramp->duration_frames = duration_frames;
100 ramp->cb = cb;
101 ramp->cb_data = cb_data;
105 struct cras_ramp_action cras_ramp_get_current_action(const struct cras_ramp *ramp)
109 if (ramp->ramped_frames < 0) {
116 switch (ramp->state) {
124 action.scaler = ramp->start_scaler +
125 ramp->ramped_frames * ramp->increment;
126 action.increment = ramp->increment;
130 action.scaler = ramp->start_scaler +
131 ramp->ramped_frames * ramp->increment;
132 action.increment = ramp->increment;
139 struct cras_ramp *ramp, int num_frames)
141 if (ramp->state == CRAS_RAMP_STATE_IDLE)
143 ramp->ramped_frames += num_frames;
144 if (ramp->ramped_frames >= ramp->duration_frames) {
145 ramp->state = CRAS_RAMP_STATE_IDLE;
146 if (ramp->cb)
147 ramp->cb(ramp->cb_data);