# HG changeset patch # User ulion # Date 1198304448 0 # Node ID 3e033aabc9d23a5c3dc031b01f7b1a357b31cd48 # Parent 7ef04742572c0a6b6e273aa09260c1e7b54be125 Combine common code for check whether chapter is available. diff -r 7ef04742572c -r 3e033aabc9d2 command.c --- a/command.c Sat Dec 22 06:14:38 2007 +0000 +++ b/command.c Sat Dec 22 06:20:48 2007 +0000 @@ -385,11 +385,12 @@ int step_all; char *chapter_name = NULL; + chapter = demuxer_get_current_chapter(mpctx->demuxer); + if (chapter < 0) + return M_PROPERTY_UNAVAILABLE; + switch (action) { case M_PROPERTY_GET: - chapter = demuxer_get_current_chapter(mpctx->demuxer); - if (chapter < 0) - return M_PROPERTY_UNAVAILABLE; if (!arg) return M_PROPERTY_ERROR; *(int *) arg = chapter; @@ -397,9 +398,6 @@ case M_PROPERTY_PRINT: { if (!arg) return M_PROPERTY_ERROR; - chapter = demuxer_get_current_chapter(mpctx->demuxer); - if (chapter < 0) - return M_PROPERTY_UNAVAILABLE; chapter_name = demuxer_chapter_display_name(mpctx->demuxer, chapter); if (!chapter_name) return M_PROPERTY_UNAVAILABLE; @@ -410,9 +408,6 @@ if (!arg) return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(int*)arg); - chapter = demuxer_get_current_chapter(mpctx->demuxer); - if (chapter < 0) - return M_PROPERTY_UNAVAILABLE; step_all = *(int *)arg - (chapter + 1); chapter += step_all; break; @@ -420,9 +415,6 @@ case M_PROPERTY_STEP_DOWN: { step_all = (arg && *(int*)arg != 0 ? *(int*)arg : 1) * (action == M_PROPERTY_STEP_UP ? 1 : -1); - chapter = demuxer_get_current_chapter(mpctx->demuxer); - if (chapter < 0) - return M_PROPERTY_UNAVAILABLE; chapter += step_all; if (chapter < 0) chapter = 0;