comparison src/animate.c @ 153:9870b049b7f6

Make mb_progm_abort() work.
author Thinker K.F. Li <thinker@branda.to>
date Sat, 27 Sep 2008 02:40:42 +0800
parents 6a8588df68af
children 6749f6639924
comparison
equal deleted inserted replaced
152:2b316b5d65f9 153:9870b049b7f6
96 96
97 mb_timeval_t start_time; 97 mb_timeval_t start_time;
98 int first_playing; /*!< first playing word. */ 98 int first_playing; /*!< first playing word. */
99 mb_tman_t *tman; 99 mb_tman_t *tman;
100 subject_t *complete; /*!< notify when a program is completed. */ 100 subject_t *complete; /*!< notify when a program is completed. */
101 mb_timer_t *cur_timer;
101 102
102 int n_words; 103 int n_words;
103 int max_words; 104 int max_words;
104 mb_word_t words[1]; 105 mb_word_t words[1];
105 }; 106 };
288 if(MB_TIMEVAL_LATER(&word->abs_start, &next_tmo)) 289 if(MB_TIMEVAL_LATER(&word->abs_start, &next_tmo))
289 MB_TIMEVAL_CP(&next_tmo, &word->abs_start); 290 MB_TIMEVAL_CP(&next_tmo, &word->abs_start);
290 timer = mb_tman_timeout(progm->tman, &next_tmo, 291 timer = mb_tman_timeout(progm->tman, &next_tmo,
291 mb_progm_step, progm); 292 mb_progm_step, progm);
292 } else { 293 } else {
294 /* Make program to complete. */
293 #ifndef UNITTEST 295 #ifndef UNITTEST
294 factory = rdman_get_ob_factory(progm->rdman); 296 factory = rdman_get_ob_factory(progm->rdman);
295 comp_evt.event.type = EVT_PROGM_COMPLETE; 297 comp_evt.event.type = EVT_PROGM_COMPLETE;
296 comp_evt.event.tgt = comp_evt.event.cur_tgt = progm->complete; 298 comp_evt.event.tgt = comp_evt.event.cur_tgt = progm->complete;
297 comp_evt.progm = progm; 299 comp_evt.progm = progm;
298 subject_notify(factory, progm->complete, &comp_evt.event); 300 subject_notify(factory, progm->complete, &comp_evt.event);
299 #endif /* UNITTEST */ 301 #endif /* UNITTEST */
302 progm->cur_timer = NULL;
300 } 303 }
301 } 304 }
302 305
303 void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman, 306 void mb_progm_start(mb_progm_t *progm, mb_tman_t *tman,
304 mb_timeval_t *now) { 307 mb_timeval_t *now) {
327 } 330 }
328 331
329 timer = mb_tman_timeout(tman, &progm->words[0].abs_start, 332 timer = mb_tman_timeout(tman, &progm->words[0].abs_start,
330 mb_progm_step, progm); 333 mb_progm_step, progm);
331 ASSERT(timer != NULL); 334 ASSERT(timer != NULL);
332 } 335
333 336 /* We need timer to abort it. */
334 void mb_progm_abort(mb_progm_t *progm, mb_tman_t *tman) { 337 progm->cur_timer = timer;
338 }
339
340 void mb_progm_abort(mb_progm_t *progm) {
335 /*! \todo Make sure abort release resources. */ 341 /*! \todo Make sure abort release resources. */
342 if(progm->cur_timer) {
343 mb_tman_remove(progm->tman, progm->cur_timer);
344 progm->cur_timer = NULL;
345 }
336 } 346 }
337 347
338 /*! \brief Return event subject for completion of a program. 348 /*! \brief Return event subject for completion of a program.
339 */ 349 */
340 subject_t *mb_progm_get_complete(mb_progm_t *progm) { 350 subject_t *mb_progm_get_complete(mb_progm_t *progm) {