diff --git a/src/extract/attachments.cpp b/src/extract/attachments.cpp index 611827499..93f480a07 100644 --- a/src/extract/attachments.cpp +++ b/src/extract/attachments.cpp @@ -73,7 +73,8 @@ using namespace libmatroska; using namespace std; static void -handle_attachments(KaxAttachments *atts) { +handle_attachments(KaxAttachments *atts, + vector &tracks) { KaxAttached *att; KaxFileData *fdata; EbmlElement *e; @@ -146,6 +147,7 @@ handle_attachments(KaxAttachments *atts) { void extract_attachments(const char *file_name, + vector &tracks, bool parse_fully) { mm_io_c *in; mm_stdio_c out; @@ -169,7 +171,7 @@ extract_attachments(const char *file_name, if (verbose > 0) debug_dump_elements(attachments, 0); - handle_attachments(attachments); + handle_attachments(attachments, tracks); delete attachments; } diff --git a/src/extract/mkvextract.cpp b/src/extract/mkvextract.cpp index 4ba0e3dc5..da4b3ed7a 100644 --- a/src/extract/mkvextract.cpp +++ b/src/extract/mkvextract.cpp @@ -76,7 +76,6 @@ using namespace std; #define MODE_CHAPTERS 3 #define MODE_CUESHEET 4 -vector tracks; bool no_variable_data = false; void @@ -150,7 +149,8 @@ static bool parse_fully = false; void parse_args(vector args, string &file_name, - int &mode) { + int &mode, + vector &tracks) { int i; char *colon, *copy; const char *sub_charset; @@ -365,6 +365,7 @@ main(int argc, char **argv) { string input_file; int mode; + vector tracks; #if defined(SYS_UNIX) nice(2); @@ -383,9 +384,9 @@ main(int argc, xml_element_map_init(); - parse_args(command_line_utf8(argc, argv), input_file, mode); + parse_args(command_line_utf8(argc, argv), input_file, mode, tracks); if (mode == MODE_TRACKS) { - extract_tracks(input_file.c_str()); + extract_tracks(input_file.c_str(), tracks); if (verbose == 0) mxinfo(_("progress: 100%%\n")); @@ -394,7 +395,7 @@ main(int argc, extract_tags(input_file.c_str(), parse_fully); else if (mode == MODE_ATTACHMENTS) - extract_attachments(input_file.c_str(), parse_fully); + extract_attachments(input_file.c_str(), tracks, parse_fully); else if (mode == MODE_CHAPTERS) extract_chapters(input_file.c_str(), chapter_format_simple, parse_fully); diff --git a/src/extract/mkvextract.h b/src/extract/mkvextract.h index 4b16e94d1..0c29e5cc9 100644 --- a/src/extract/mkvextract.h +++ b/src/extract/mkvextract.h @@ -46,7 +46,6 @@ struct track_spec_t { bool done; }; -extern vector tracks; extern bool no_variable_data; #define fits_parent(l, p) (l->GetElementPosition() < \ @@ -59,11 +58,12 @@ extern bool no_variable_data; void show_element(EbmlElement *l, int level, const char *fmt, ...); void show_error(const char *fmt, ...); -bool extract_tracks(const char *file_name); +bool extract_tracks(const char *file_name, vector &tracks); void extract_tags(const char *file_name, bool parse_fully); void extract_chapters(const char *file_name, bool chapter_format_simple, bool parse_fully); -void extract_attachments(const char *file_name, bool parse_fully); +void extract_attachments(const char *file_name, + vector &tracks, bool parse_fully); void extract_cuesheet(const char *file_name, bool parse_fully); void write_cuesheet(const char *file_name, KaxChapters &chapters, KaxTags &tags, int64_t tuid, mm_io_c &out); diff --git a/src/extract/tracks.cpp b/src/extract/tracks.cpp index ff6848d88..5290f9ad7 100644 --- a/src/extract/tracks.cpp +++ b/src/extract/tracks.cpp @@ -66,7 +66,8 @@ static vector extractors; // ------------------------------------------------------------------------ static void -create_extractors(KaxTracks &kax_tracks) { +create_extractors(KaxTracks &kax_tracks, + vector &tracks) { int i; for (i = 0; i < kax_tracks.ListSize(); i++) { @@ -219,7 +220,8 @@ close_extractors() { static void write_all_cuesheets(KaxChapters &chapters, - KaxTags &tags) { + KaxTags &tags, + vector &tracks) { int i; mm_io_c *out; @@ -261,7 +263,8 @@ write_all_cuesheets(KaxChapters &chapters, } bool -extract_tracks(const char *file_name) { +extract_tracks(const char *file_name, + vector &tracks) { int upper_lvl_el; // Elements for different levels EbmlElement *l0 = NULL, *l1 = NULL, *l2 = NULL, *l3 = NULL; @@ -373,7 +376,7 @@ extract_tracks(const char *file_name) { tracks_found = true; l1->Read(*es, KaxTracks::ClassInfos.Context, upper_lvl_el, l2, true); - create_extractors(*dynamic_cast(l1)); + create_extractors(*dynamic_cast(l1), tracks); } else if (EbmlId(*l1) == KaxCluster::ClassInfos.GlobalId) { show_element(l1, 1, _("Cluster")); @@ -494,7 +497,7 @@ extract_tracks(const char *file_name) { delete es; delete in; - write_all_cuesheets(all_chapters, all_tags); + write_all_cuesheets(all_chapters, all_tags, tracks); // Now just close the files and go to sleep. Mummy will sing you a // lullaby. Just close your eyes, listen to her sweet voice, singing,