ffprobe: fix chapter printing, fix JSON output
authorStefano Sabatini <stefasab@gmail.com>
Tue, 29 May 2012 16:08:00 +0000 (18:08 +0200)
committerStefano Sabatini <stefasab@gmail.com>
Tue, 29 May 2012 16:11:36 +0000 (18:11 +0200)
Make writer_print_chapter_header() set the internal values *before* the
private writer callback is called, otherwise the accessed internal values
will be wrong.

Fix regression introduced in fa6cb2fdffe.

Found-By: Daemon404
ffprobe.c

index 2727dd7..afc0883 100644 (file)
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -252,14 +252,14 @@ static inline void writer_print_footer(WriterContext *wctx)
 static inline void writer_print_chapter_header(WriterContext *wctx,
                                                const char *chapter)
 {
 static inline void writer_print_chapter_header(WriterContext *wctx,
                                                const char *chapter)
 {
-    if (wctx->writer->print_chapter_header)
-        wctx->writer->print_chapter_header(wctx, chapter);
     wctx->nb_section = 0;
     wctx->nb_section = 0;
-
     wctx->multiple_sections = !strcmp(chapter, "packets") || !strcmp(chapter, "frames" ) ||
                               !strcmp(chapter, "packets_and_frames") ||
                               !strcmp(chapter, "streams") || !strcmp(chapter, "library_versions");
     wctx->is_fmt_chapter = !strcmp(chapter, "format");
     wctx->multiple_sections = !strcmp(chapter, "packets") || !strcmp(chapter, "frames" ) ||
                               !strcmp(chapter, "packets_and_frames") ||
                               !strcmp(chapter, "streams") || !strcmp(chapter, "library_versions");
     wctx->is_fmt_chapter = !strcmp(chapter, "format");
+
+    if (wctx->writer->print_chapter_header)
+        wctx->writer->print_chapter_header(wctx, chapter);
 }
 
 static inline void writer_print_chapter_footer(WriterContext *wctx,
 }
 
 static inline void writer_print_chapter_footer(WriterContext *wctx,