diff options
author | Philip Withnall <philip@tecnocode.co.uk> | 2009-06-17 14:52:31 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2009-06-17 14:52:31 +0100 |
commit | ccfcf8ab8d2657f9ac198a82d49d8b4c878595e3 (patch) | |
tree | 22cffa22c8a84e2c12dd9c0cd67c4bc818f72111 /plparse/totem-pl-parser-wm.c | |
parent | 73fc40f8ce7a393cf1394d0d4469f6cd7bafea58 (diff) | |
download | totem-pl-parser-ccfcf8ab8d2657f9ac198a82d49d8b4c878595e3.tar.gz |
Add asynchronous parsing support to totem-pl-parser
2009-06-17 Philip Withnall <philip@tecnocode.co.uk>
* docs/reference/totem-pl-parser-sections.txt:
* plparse/plparser.symbols:
* plparse/totem-pl-parser-builtins.c
(totem_pl_parser_result_get_type):
* plparse/totem-pl-parser-lines.c (totem_pl_parser_add_ram),
(totem_pl_parser_add_m3u), (totem_pl_parser_add_ra):
* plparse/totem-pl-parser-lines.h:
* plparse/totem-pl-parser-media.c (totem_pl_parser_add_iso),
(totem_pl_parser_add_cue), (totem_pl_parser_add_directory),
(totem_pl_parser_add_block):
* plparse/totem-pl-parser-media.h:
* plparse/totem-pl-parser-misc.c (totem_pl_parser_add_gvp),
(totem_pl_parser_add_desktop):
* plparse/totem-pl-parser-misc.h:
* plparse/totem-pl-parser-pla.c (totem_pl_parser_add_pla):
* plparse/totem-pl-parser-pla.h:
* plparse/totem-pl-parser-pls.c
(totem_pl_parser_add_pls_with_contents), (totem_pl_parser_add_pls):
* plparse/totem-pl-parser-pls.h:
* plparse/totem-pl-parser-podcast.c (totem_pl_parser_add_rss),
(totem_pl_parser_add_itpc), (totem_pl_parser_add_zune),
(totem_pl_parser_add_atom), (totem_pl_parser_add_xml_feed),
(totem_pl_parser_add_itms), (totem_pl_parser_add_opml):
* plparse/totem-pl-parser-podcast.h:
* plparse/totem-pl-parser-private.h:
* plparse/totem-pl-parser-qt.c
(totem_pl_parser_add_quicktime_rtsptext),
(totem_pl_parser_add_quicktime_metalink),
(totem_pl_parser_add_quicktime):
* plparse/totem-pl-parser-qt.h:
* plparse/totem-pl-parser-smil.c (totem_pl_parser_add_smil):
* plparse/totem-pl-parser-smil.h:
* plparse/totem-pl-parser-wm.c
(totem_pl_parser_add_asf_reference_parser),
(totem_pl_parser_add_asf_parser), (parse_asx_entry),
(parse_asx_entryref), (parse_asx_entries),
(totem_pl_parser_add_asx), (totem_pl_parser_add_asf):
* plparse/totem-pl-parser-wm.h:
* plparse/totem-pl-parser-xspf.c (totem_pl_parser_add_xspf):
* plparse/totem-pl-parser-xspf.h:
* plparse/totem-pl-parser.c (totem_pl_parser_class_init),
(emit_playlist_ended_signal), (totem_pl_parser_playlist_end),
(totem_pl_parser_is_debugging_enabled), (totem_pl_parser_init),
(totem_pl_parser_finalize), (emit_entry_parsed_signal),
(totem_pl_parser_add_uri_valist),
(totem_pl_parser_scheme_is_ignored),
(totem_pl_parser_mimetype_is_ignored),
(totem_pl_parser_parse_internal), (parse_async_data_free),
(parse_thread), (totem_pl_parser_parse_with_base_async),
(totem_pl_parser_parse_with_base), (totem_pl_parser_parse_async),
(totem_pl_parser_parse_finish),
(totem_pl_parser_add_ignored_scheme),
(totem_pl_parser_add_ignored_mimetype):
* plparse/totem-pl-parser.h: Add asynchronous playlist parsing
functions, totem_pl_parser_parse_async, *_parse_with_base_async and
totem_pl_parser_parse_finish. This includes making TotemPlParser
threadsafe, and ensuring it emits all its signals in the main thread.
It also includes refactoring of recursive parsing so that global
options are copied and preserved throughout the parse operation,
and can't be changed mid-operation from another thread.
(Closes: #561444)
Diffstat (limited to 'plparse/totem-pl-parser-wm.c')
-rw-r--r-- | plparse/totem-pl-parser-wm.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/plparse/totem-pl-parser-wm.c b/plparse/totem-pl-parser-wm.c index 94d48e6..bbce3bd 100644 --- a/plparse/totem-pl-parser-wm.c +++ b/plparse/totem-pl-parser-wm.c @@ -82,6 +82,7 @@ static TotemPlParserResult totem_pl_parser_add_asf_reference_parser (TotemPlParser *parser, GFile *file, GFile *base_file, + TotemPlParseData *parse_data, gpointer data) { char *contents, **lines, *ref; @@ -97,7 +98,7 @@ totem_pl_parser_add_asf_reference_parser (TotemPlParser *parser, ref = totem_pl_parser_read_ini_line_string (lines, "Ref1"); if (ref == NULL) { g_strfreev (lines); - return totem_pl_parser_add_asx (parser, file, base_file, data); + return totem_pl_parser_add_asx (parser, file, base_file, parse_data, data); } /* change http to mmsh, thanks Microsoft */ @@ -119,6 +120,7 @@ static TotemPlParserResult totem_pl_parser_add_asf_parser (TotemPlParser *parser, GFile *file, GFile *base_file, + TotemPlParseData *parse_data, gpointer data) { TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; @@ -130,7 +132,7 @@ totem_pl_parser_add_asf_parser (TotemPlParser *parser, return TOTEM_PL_PARSER_RESULT_UNHANDLED; if (g_str_has_prefix (data, "ASF ") == FALSE) { - return totem_pl_parser_add_asf_reference_parser (parser, file, base_file, data); + return totem_pl_parser_add_asf_reference_parser (parser, file, base_file, parse_data, data); } if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE) @@ -155,7 +157,7 @@ totem_pl_parser_add_asf_parser (TotemPlParser *parser, } static gboolean -parse_asx_entry (TotemPlParser *parser, GFile *base_file, xml_node_t *parent) +parse_asx_entry (TotemPlParser *parser, GFile *base_file, xml_node_t *parent, TotemPlParseData *parse_data) { xml_node_t *node; TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS; @@ -256,7 +258,7 @@ parse_asx_entry (TotemPlParser *parser, GFile *base_file, xml_node_t *parent) g_free (resolved_uri); /* .asx files can contain references to other .asx files */ - retval = totem_pl_parser_parse_internal (parser, resolved, NULL); + retval = totem_pl_parser_parse_internal (parser, resolved, NULL, parse_data); if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) { totem_pl_parser_add_uri (parser, TOTEM_PL_PARSER_FIELD_FILE, resolved, @@ -277,7 +279,7 @@ bail: } static gboolean -parse_asx_entryref (TotemPlParser *parser, GFile *base_file, xml_node_t *node) +parse_asx_entryref (TotemPlParser *parser, GFile *base_file, xml_node_t *node, TotemPlParseData *parse_data) { TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_SUCCESS; const char *uri; @@ -294,7 +296,7 @@ parse_asx_entryref (TotemPlParser *parser, GFile *base_file, xml_node_t *node) g_free (resolved_uri); /* .asx files can contain references to other .asx files */ - retval = totem_pl_parser_parse_internal (parser, resolved, NULL); + retval = totem_pl_parser_parse_internal (parser, resolved, NULL, parse_data); if (retval != TOTEM_PL_PARSER_RESULT_SUCCESS) { totem_pl_parser_add_uri (parser, TOTEM_PL_PARSER_FIELD_FILE, resolved, @@ -308,7 +310,7 @@ parse_asx_entryref (TotemPlParser *parser, GFile *base_file, xml_node_t *node) //FIXME the retval is completely wrong static gboolean -parse_asx_entries (TotemPlParser *parser, const char *uri, GFile *base_file, xml_node_t *parent) +parse_asx_entries (TotemPlParser *parser, const char *uri, GFile *base_file, xml_node_t *parent, TotemPlParseData *parse_data) { char *title = NULL; GFile *new_base; @@ -341,17 +343,17 @@ parse_asx_entries (TotemPlParser *parser, const char *uri, GFile *base_file, xml } if (g_ascii_strcasecmp (node->name, "entry") == 0) { /* Whee! found an entry here, find the REF and TITLE */ - if (parse_asx_entry (parser, new_base ? new_base : base_file, node) != FALSE) + if (parse_asx_entry (parser, new_base ? new_base : base_file, node, parse_data) != FALSE) retval = TOTEM_PL_PARSER_RESULT_SUCCESS; } if (g_ascii_strcasecmp (node->name, "entryref") == 0) { /* Found an entryref, extract the REF attribute */ - if (parse_asx_entryref (parser, new_base ? new_base : base_file, node) != FALSE) + if (parse_asx_entryref (parser, new_base ? new_base : base_file, node, parse_data) != FALSE) retval = TOTEM_PL_PARSER_RESULT_SUCCESS; } if (g_ascii_strcasecmp (node->name, "repeat") == 0) { /* Repeat at the top-level */ - if (parse_asx_entries (parser, uri, new_base ? new_base : base_file, node) != FALSE) + if (parse_asx_entries (parser, uri, new_base ? new_base : base_file, node, parse_data) != FALSE) retval = TOTEM_PL_PARSER_RESULT_SUCCESS; } } @@ -369,6 +371,7 @@ TotemPlParserResult totem_pl_parser_add_asx (TotemPlParser *parser, GFile *file, GFile *base_file, + TotemPlParseData *parse_data, gpointer data) { xml_node_t* doc; @@ -377,7 +380,7 @@ totem_pl_parser_add_asx (TotemPlParser *parser, TotemPlParserResult retval = TOTEM_PL_PARSER_RESULT_UNHANDLED; if (data != NULL && totem_pl_parser_is_uri_list (data, strlen (data)) != FALSE) { - return totem_pl_parser_add_ram (parser, file, data); + return totem_pl_parser_add_ram (parser, file, parse_data, data); } if (g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) == FALSE) @@ -399,7 +402,7 @@ totem_pl_parser_add_asx (TotemPlParser *parser, uri = g_file_get_uri (file); - if (parse_asx_entries (parser, uri, base_file, doc) != FALSE) + if (parse_asx_entries (parser, uri, base_file, doc, parse_data) != FALSE) retval = TOTEM_PL_PARSER_RESULT_SUCCESS; g_free (uri); @@ -413,6 +416,7 @@ TotemPlParserResult totem_pl_parser_add_asf (TotemPlParser *parser, GFile *file, GFile *base_file, + TotemPlParseData *parse_data, gpointer data) { if (data == NULL) { @@ -425,7 +429,7 @@ totem_pl_parser_add_asf (TotemPlParser *parser, return TOTEM_PL_PARSER_RESULT_SUCCESS; } - return totem_pl_parser_add_asf_parser (parser, file, base_file, data); + return totem_pl_parser_add_asf_parser (parser, file, base_file, parse_data, data); } #endif /* !TOTEM_PL_PARSER_MINI */ |