bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) { switch (state) { case BSV_MOVIE_CTL_IS_INITED: return bsv_movie_state.movie; case BSV_MOVIE_CTL_PLAYBACK_ON: return bsv_movie_state.movie && bsv_movie_state.movie_playback; case BSV_MOVIE_CTL_PLAYBACK_OFF: return bsv_movie_state.movie && !bsv_movie_state.movie_playback; case BSV_MOVIE_CTL_START_RECORDING: return bsv_movie_state.movie_start_recording; case BSV_MOVIE_CTL_SET_START_RECORDING: bsv_movie_state.movie_start_recording = true; break; case BSV_MOVIE_CTL_UNSET_START_RECORDING: bsv_movie_state.movie_start_recording = false; break; case BSV_MOVIE_CTL_START_PLAYBACK: return bsv_movie_state.movie_start_playback; case BSV_MOVIE_CTL_SET_START_PLAYBACK: bsv_movie_state.movie_start_playback = true; break; case BSV_MOVIE_CTL_UNSET_START_PLAYBACK: bsv_movie_state.movie_start_playback = false; break; case BSV_MOVIE_CTL_END: return bsv_movie_state.movie_end; case BSV_MOVIE_CTL_SET_END_EOF: bsv_movie_state.eof_exit = true; break; case BSV_MOVIE_CTL_END_EOF: return bsv_movie_state.movie_end && bsv_movie_state.eof_exit; case BSV_MOVIE_CTL_SET_END: bsv_movie_state.movie_end = true; break; case BSV_MOVIE_CTL_UNSET_END: bsv_movie_state.movie_end = false; break; case BSV_MOVIE_CTL_UNSET_PLAYBACK: bsv_movie_state.movie_playback = false; break; case BSV_MOVIE_CTL_DEINIT: if (bsv_movie_state.movie) bsv_movie_free(bsv_movie_state.movie); bsv_movie_state.movie = NULL; break; case BSV_MOVIE_CTL_INIT: bsv_movie_init_state(); break; case BSV_MOVIE_CTL_SET_FRAME_START: bsv_movie_set_frame_start(bsv_movie_state.movie); break; case BSV_MOVIE_CTL_SET_FRAME_END: bsv_movie_set_frame_end(bsv_movie_state.movie); break; case BSV_MOVIE_CTL_FRAME_REWIND: bsv_movie_frame_rewind(bsv_movie_state.movie); break; default: return false; } return true; }
bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) { switch (state) { case BSV_MOVIE_CTL_IS_INITED: return bsv_movie_state.movie; case BSV_MOVIE_CTL_PLAYBACK_ON: return bsv_movie_state.movie && bsv_movie_state.movie_playback; case BSV_MOVIE_CTL_PLAYBACK_OFF: return bsv_movie_state.movie && !bsv_movie_state.movie_playback; case BSV_MOVIE_CTL_START_RECORDING: return bsv_movie_state.movie_start_recording; case BSV_MOVIE_CTL_SET_START_RECORDING: bsv_movie_state.movie_start_recording = true; break; case BSV_MOVIE_CTL_UNSET_START_RECORDING: bsv_movie_state.movie_start_recording = false; break; case BSV_MOVIE_CTL_START_PLAYBACK: return bsv_movie_state.movie_start_playback; case BSV_MOVIE_CTL_SET_START_PLAYBACK: bsv_movie_state.movie_start_playback = true; break; case BSV_MOVIE_CTL_UNSET_START_PLAYBACK: bsv_movie_state.movie_start_playback = false; break; case BSV_MOVIE_CTL_END: return bsv_movie_state.movie_end; case BSV_MOVIE_CTL_SET_END_EOF: bsv_movie_state.eof_exit = true; break; case BSV_MOVIE_CTL_END_EOF: return bsv_movie_state.movie_end && bsv_movie_state.eof_exit; case BSV_MOVIE_CTL_SET_END: bsv_movie_state.movie_end = true; break; case BSV_MOVIE_CTL_UNSET_END: bsv_movie_state.movie_end = false; break; case BSV_MOVIE_CTL_UNSET_PLAYBACK: bsv_movie_state.movie_playback = false; break; case BSV_MOVIE_CTL_DEINIT: if (bsv_movie_state.movie) bsv_movie_free(bsv_movie_state.movie); bsv_movie_state.movie = NULL; break; case BSV_MOVIE_CTL_INIT: bsv_movie_init_state(); break; case BSV_MOVIE_CTL_SET_FRAME_START: bsv_movie_set_frame_start(bsv_movie_state.movie); break; case BSV_MOVIE_CTL_SET_FRAME_END: bsv_movie_set_frame_end(bsv_movie_state.movie); break; case BSV_MOVIE_CTL_FRAME_REWIND: bsv_movie_frame_rewind(bsv_movie_state.movie); break; case BSV_MOVIE_CTL_GET_INPUT: { int16_t *bsv_data = (int16_t*)data; bsv_movie_t *handle = bsv_movie_state.movie; if (fread(bsv_data, sizeof(int16_t), 1, handle->file) != 1) return false; *bsv_data = swap_if_big16(*bsv_data); } break; case BSV_MOVIE_CTL_SET_INPUT: { int16_t *bsv_data = (int16_t*)data; bsv_movie_t *handle = bsv_movie_state.movie; *bsv_data = swap_if_big16(*bsv_data); fwrite(bsv_data, sizeof(int16_t), 1, handle->file); } break; case BSV_MOVIE_CTL_NONE: default: return false; } return true; }