[gnac/devel: 2/5] Merge branch 'devel' into refactoring
- From: David Joaquim <djoaquim src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel: 2/5] Merge branch 'devel' into refactoring
- Date: Sun, 9 May 2010 14:10:19 +0000 (UTC)
commit 84f2a9c7a1e0db5b07ac3c4abc3742fc35ee1ccb
Merge: f11edb3 1d6cc2a
Author: David Joaquim <djoaquim src gnome org>
Date: Fri May 7 22:21:14 2010 +0200
Merge branch 'devel' into refactoring
Conflicts:
libgnac/libgnac-converter.c
libgnac/libgnac-converter.h
libgnac/libgnac-output.c
.gitignore | 30 +
Makefile.am | 5 +-
TODO | 1 +
autogen.sh | 11 +-
configure.ac | 98 ++-
data/profiles/default/Voice,_Lossless.xml.in | 2 +-
data/profiles/speex.xml.in | 2 +-
data/ui/gnac-properties-window.xml | 5 +-
libgnac/libgnac-converter.c | 270 ++++---
libgnac/libgnac-gst-utils.c | 187 ++++
libgnac/libgnac-gst-utils.h | 71 ++
libgnac/libgnac-gst.c | 9 +
libgnac/libgnac-media-item.c | 243 +++++
libgnac/libgnac-media-item.h | 106 +++
libgnac/libgnac-output.c | 12 +-
libgnac/libgnac-profile.h | 44 +
po/LINGUAS | 4 +
po/cs.po | 38 +-
po/da.po | 1288 ++++++++++++++++++++++++++
po/de.po | 12 +-
po/es.po | 384 +++++----
po/nb.po | 1206 ++++++++++++++++++++++++
po/pt_BR.po | 1278 +++++++++++++++++++++++++
po/sl.po | 14 +-
po/sv.po | 1010 +++++++++-----------
po/zh_CN.po | 1220 ++++++++++++++++++++++++
src/gnac-main.c | 5 +-
src/gnac-prefs.c | 6 +-
src/gnac-properties.c | 15 +-
src/gnac-properties.h | 5 +
src/gnac-ui.c | 14 +-
src/profiles/formats/gnac-profiles-aac.c | 3 +-
src/profiles/formats/gnac-profiles-flac.c | 3 +-
src/profiles/formats/gnac-profiles-lame.c | 3 +-
src/profiles/formats/gnac-profiles-speex.c | 3 +-
src/profiles/formats/gnac-profiles-unknown.c | 5 +-
src/profiles/formats/gnac-profiles-vorbis.c | 3 +-
src/profiles/formats/gnac-profiles-wav.c | 3 +-
src/profiles/formats/gnac-profiles-wavpack.c | 3 +-
src/profiles/gnac-profiles-default.c | 3 +-
src/profiles/gnac-profiles-properties.c | 15 +-
src/profiles/gnac-profiles-utils.c | 2 +-
src/profiles/gnac-profiles-xml-engine.c | 17 +-
43 files changed, 6681 insertions(+), 977 deletions(-)
---
diff --cc libgnac/libgnac-converter.c
index 1a5196a,6ab012d..9d777e2
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@@ -856,8 -833,170 +856,7 @@@ libgnac_converter_resume(LibgnacConvert
}
-/* LibgnacConverterItem functions */
-
-LibgnacConverterItem *
-libgnac_converter_item_new(LibgnacConverter *self,
- GFile *source)
-{
- LibgnacConverterItem *item;
-
- g_return_val_if_fail(LIBGNAC_IS_CONVERTER(self), NULL);
-
- item = (LibgnacConverterItem*)g_malloc(sizeof(LibgnacConverterItem));
-
- g_object_ref(self);
- item->converter = self;
- item->source = g_file_dup(source);
- item->destination = NULL;
- item->pipeline = NULL;
- item->audio_encoder = NULL;
- item->bus = NULL;
- item->timeout_id = 0;
- item->pos = 0;
-
- return item;
-}
-
-
-void
-libgnac_converter_item_build(LibgnacConverterItem *item,
- GError **error)
-{
- gboolean has_video = FALSE;
- GError *err = NULL;
- LibgnacTags *tags;
-
- g_return_if_fail(error == NULL || *error == NULL);
-
- /* is it a video file? */
- // TODO why not passing error ?
- tags = libgnac_metadata_extract(metadata, item->source, NULL);
- if (tags && libgnac_metadata_tag_exists(tags, GNAC_TAG_HAS_VIDEO)) {
- has_video = TRUE;
- }
-
- libgnac_gst_build_pipeline(item, has_video, &err);
- g_return_if_fail(item->destination);
- if (err) {
- libgnac_warning("Unable to build pipeline");
- libgnac_gst_clean_pipeline(item);
- g_propagate_error(error, err);
- }
-}
-
-void
-libgnac_converter_item_run(LibgnacConverterItem *item,
- GError **error)
-{
- GError *err = NULL;
- g_return_if_fail(error == NULL || *error == NULL);
-
- /* Build pipeline if doesn't exist */
-
- if (!item->pipeline) {
- libgnac_converter_item_build(item, &err);
- if(err)
- {
- g_propagate_error(error, err);
- return;
- }
- }
-
-
- libgnac_converter_item_initialize_event_source(item);
-
- libgnac_gst_run(item, &err);
- if (err) {
- libgnac_warning("Unable to run pipeline");
- libgnac_gst_clean_pipeline(item);
- g_propagate_error(error, err);
- return;
- }
-}
-
-
-void
-libgnac_converter_item_stop(LibgnacConverterItem *item,
- GError **error)
-{
- GError *err = NULL;
- g_return_if_fail(error == NULL || *error == NULL);
-
- libgnac_converter_item_clear_event_source(item);
- libgnac_gst_stop(item, &err);
- // TODO propagate error here
- //g_propagate_error(error, err);
-
- /* Remove not completed file */
- if (G_IS_FILE(item->destination))
- {
- g_file_delete(item->destination, NULL, &err);
- if (err) {
- // Warning, but not critical
- libgnac_warning("Unable to remove partial file");
- g_clear_error(&err);
- }
- }
-}
-
-
-/*void
-libgnac_converter_item_pause(LibgnacConverterItem *item,
- GError **error)
-{
- g_return_if_fail(error == NULL || *error == NULL);
-}
-
-
-void
-libgnac_converter_item_resume(LibgnacConverterItem *item,
- GError **error)
-{
- g_return_if_fail(error == NULL || *error == NULL);
-}*/
-
-
-void
-libgnac_converter_item_free(LibgnacConverterItem *item)
-{
- libgnac_converter_item_clear_event_source(item);
- g_object_unref(item->converter);
- item->converter = NULL;
-
- g_object_unref(item->source);
- item->source = NULL;
- if (item->destination) {
- g_object_unref(item->destination);
- item->destination = NULL;
- }
-
- libgnac_gst_clean_pipeline(item);
-
- g_free(item);
-}
-
-
-void
-libgnac_converter_item_initialize_event_source(LibgnacConverterItem *item)
-{
- item->timeout_id = g_timeout_add(PROGRESS_TIMEOUT,
- (GSourceFunc)libgnac_converter_percentage_cb, item);
-}
-
-
-void
-libgnac_converter_item_clear_event_source(LibgnacConverterItem *item)
-{
- if (item->timeout_id) {
- g_source_remove(item->timeout_id);
- item->timeout_id = 0;
- }
-}
-
-
/* Callbacks */
--
void
libgnac_converter_eos_cb(GstBus *bus,
GstMessage *message,
@@@ -884,6 -1020,132 +883,132 @@@
}
}
+ static gboolean
-libgnac_converter_error_sink(LibgnacConverterItem *item,
++libgnac_converter_error_sink(LibgnacMediaItem *item,
+ GstMessage *message,
+ gchar *uri,
+ GError *error)
+ {
+ g_return_val_if_fail(item, FALSE);
+ g_return_val_if_fail(item->destination, FALSE);
+ g_return_val_if_fail(error, FALSE);
+
+ /* Create missing directory */
+ GError *err = NULL;
+ GFile *folder;
+ gboolean folder_creation;
+
+ // TODO libgnac_utils
+ /* Get parent folder name */
+ folder = g_file_get_parent(item->destination);
+ folder_creation = g_file_make_directory_with_parents(folder, NULL, &err);
+ g_object_unref(folder);
+
+ /* New folder create relaunch pipeline */
+ if (folder_creation && !err) {
+ libgnac_debug("Folder successfully created");
+ return TRUE;
+ }
+
+ if (err) {
+ /* If folder existed but something went wrong */
+ if (!g_error_matches(err, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
+ libgnac_debug("Unable to create directory");
- g_signal_emit(item->converter, signals[ERROR], 0, uri,
++ g_signal_emit(item->parent, signals[ERROR], 0, uri,
+ _("Unable to create destination directory"), NULL);
+ g_clear_error(&err);
+ return FALSE;
+ }
+ g_clear_error(&err);
+ }
+
+ /* The destination file already exists */
+ if (g_file_test(g_file_get_path(item->destination), G_FILE_TEST_EXISTS))
+ {
+ libgnac_debug("Destination file already exists");
+
+ gboolean overwrite = FALSE;
+
+ /* TODO; do not interrupt user's workflow
+ * Provide some notification => GtkInfoBar */
- g_signal_emit(item->converter, signals[OVERWRITE], 0,
++ g_signal_emit(item->parent, signals[OVERWRITE], 0,
+ item->destination, &overwrite);
+
+ if (overwrite)
+ {
+ GError *err = NULL;
+
+ libgnac_debug("Overwrite file");
+ // TODO libgnac_utils
+ g_file_delete(item->destination, NULL, &err);
+ if (err) {
+ libgnac_warning("Unable to overwrite file %s: %s", uri, err->message);
+ g_clear_error(&err);
+ }
+ else
+ {
+ return TRUE;
+ }
+ }
+ /* Just send error signal */
+ else
+ {
+ // TODO transform to WARNING signal
+ gchar *msg;
+ GError *err = NULL;
+
+ libgnac_debug("Do not owerwrite file");
+ msg = g_strdup_printf(_("Destination file %s already exists"), uri);
+ g_set_error_literal(&err, LIBGNAC_ERROR,
+ LIBGNAC_ERROR_FILE_EXISTS, msg);
- g_signal_emit(item->converter, signals[ERROR], 0, uri, msg, err);
++ g_signal_emit(item->parent, signals[ERROR], 0, uri, msg, err);
+ g_clear_error(&err);
+ g_free(msg);
+ }
+ }
+ /* Access error */
+ else
+ {
+ libgnac_debug("Other error happend");
- g_signal_emit(item->converter, signals[ERROR], 0, uri,
++ g_signal_emit(item->parent, signals[ERROR], 0, uri,
+ _("Unable to access destination file"), error);
+ }
+
+ return FALSE;
+ }
+
+ static gboolean
-libgnac_converter_error_src(LibgnacConverterItem *item,
++libgnac_converter_error_src(LibgnacMediaItem *item,
+ GstMessage *message,
+ gchar *uri,
+ GError *error)
+ {
- g_signal_emit(item->converter, signals[ERROR], 0, uri,
++ g_signal_emit(item->parent, signals[ERROR], 0, uri,
+ _("Unable to read source file"), error);
+
+ return FALSE;
+ }
+
+ static gboolean
-libgnac_converter_error_other(LibgnacConverterItem *item,
++libgnac_converter_error_other(LibgnacMediaItem *item,
+ GstMessage *message,
+ gchar *uri,
+ GError *error)
+ {
+ GError *err = NULL;
+
+ // TODO libgnac_utils
+ g_file_delete(item->destination, NULL, &err);
+ if (err) {
+ libgnac_warning("Unable to remove partial file %s: %s", uri, err->message);
+ g_clear_error(&err);
+ }
- g_signal_emit(item->converter, signals[ERROR], 0, uri,
++ g_signal_emit(item->parent, signals[ERROR], 0, uri,
+ _("An error occured during conversion"), error);
+
+ return FALSE;
+ }
+
void
libgnac_converter_error_cb(GstBus *bus,
@@@ -892,136 -1154,65 +1017,69 @@@
{
GError *error = NULL;
GstObject *src = NULL;
- LibgnacConverterItem *item = NULL;
+ LibgnacConverter *converter = NULL;
+ LibgnacMediaItem *item = NULL;
gchar *uri;
+ gchar *out_uri;
gchar *name;
+ gboolean restart = FALSE;
- item = (LibgnacConverterItem*)data;
- libgnac_converter_item_clear_event_source(item);
+ converter = (LibgnacConverter*)data;
+ g_return_if_fail(LIBGNAC_IS_CONVERTER(converter));
+
+ item = converter->priv->current;
- src = GST_MESSAGE_SRC(message);
- name = gst_object_get_name(src);
-
uri = g_file_get_uri(item->source);
-
+ out_uri = g_file_get_uri(item->destination);
+ src = GST_MESSAGE_SRC(message);
+ name = GST_MESSAGE_SRC_NAME(message);
gst_message_parse_error(message, &error, NULL);
+ libgnac_debug("An error occured for file %s", uri);
- if (g_str_has_prefix(name, "giosink"))
- {
- if (g_error_matches(error,
- GST_RESOURCE_ERROR,
- GST_RESOURCE_ERROR_NOT_FOUND))
- {
- /* Create missing directory */
- GError *err = NULL;
- GFile *folder;
- gchar *furi;
-
-
- folder = g_file_get_parent(item->destination);
-
- furi = g_file_get_uri(folder);
- libgnac_debug("Creating missing directory: %s", furi);
- g_free(furi);
-
- g_file_make_directory_with_parents(folder, NULL, &err);
- g_object_unref(folder);
- if (err) {
- libgnac_debug("Unable to create missing directory");
- g_signal_emit(converter, signals[ERROR], 0, uri,
- _("Unable to create destination directory"), NULL);
- g_clear_error(&err);
- } else if (libgnac_converter_restart_current(converter)) return;
-
- } else if (g_error_matches(error,
- GST_RESOURCE_ERROR,
- GST_RESOURCE_ERROR_OPEN_READ))
- {
- if (g_file_test(g_file_get_path(item->destination), G_FILE_TEST_EXISTS))
- {
-
- libgnac_debug("Destination file exists");
- gboolean overwrite = FALSE;
- g_signal_emit(converter, signals[OVERWRITE], 0,
- item->destination, &overwrite);
- if (overwrite)
- {
- GError *err = NULL;
-
-
- libgnac_debug("Delete file for overwrite");
- g_file_delete(item->destination, NULL, &err);
- if (err) {
- libgnac_warning("Unable to overwrite file %s: %s", uri, err->message);
- g_clear_error(&err);
- }
- else if (libgnac_converter_restart_current(converter))
- {
- g_clear_error(&error);
- g_free(name);
- g_free(uri);
- return;
- }
- }
- else
- {
- gchar *msg;
- GError *err = NULL;
-
-
- libgnac_debug("Do nothing, overwrite forbidden");
- msg = g_strdup_printf(_("Destination file %s already exists"), uri);
- g_set_error_literal(&err, LIBGNAC_ERROR,
- LIBGNAC_ERROR_FILE_EXISTS, msg);
- g_signal_emit(converter, signals[ERROR], 0, uri, msg, err);
- g_clear_error(&err);
- g_free(msg);
- }
- }
- else
- {
- libgnac_debug("Unable to access destination file");
- g_signal_emit(converter, signals[ERROR], 0, uri,
- _("Unable to access destination file"), error);
- }
- }
+ libgnac_debug("An error has occured:\n"
+ "\tFile: %s\n"
+ "\tOut file %s\n"
+ "\tBin name: %s\n"
+ "\tError message: %s",
+ uri, out_uri, name, error->message);
+
+ if (g_str_has_prefix(name, "giosink")) {
+ libgnac_debug("Sink error");
+ /* flush the bus to avoid receiving the same message twice */
+ gst_bus_set_flushing(bus, TRUE);
+ restart = libgnac_converter_error_sink(item, message, uri, error);
+ /* restore the normal state of the bus */
+ gst_bus_set_flushing(bus, FALSE);
} else if (g_str_has_prefix(name, "giosrc")) {
-
- libgnac_debug("Unable to read source file");
- g_signal_emit(converter, signals[ERROR], 0, uri,
- _("Unable to read source file"), error);
+ libgnac_debug("Source error");
+ restart = libgnac_converter_error_src(item, message, uri, error);
} else {
- GError *err = NULL;
-
- libgnac_debug("Removing partial file");
- g_file_delete(item->destination, NULL, &err);
- if (err) {
- libgnac_debug("Unable to remove partial file");
- libgnac_warning("Unable to remove partial file %s: %s", uri, err->message);
- g_clear_error(&err);
- }
- g_signal_emit(converter, signals[ERROR], 0, uri,
- _("An error occured during conversion"), error);
+ libgnac_debug("Other error");
+ restart = libgnac_converter_error_other(item, message, uri, error);
}
- libgnac_warning("Conversion failed:\n\tFile: %s\n\tBin name: %s\n\tError message: %s",
- uri, name, error->message);
-
g_clear_error(&error);
- g_free(name);
g_free(uri);
+ g_free(out_uri);
+
+ /*
+ * We cannot remove partial file here, in some case the error is
+ * access error and we do not want and cannot remove the file
+ */
+
+ // TODO restart current if needed
+ if (restart) {
- if (libgnac_converter_restart_current(item->converter)) {
++ if (libgnac_converter_restart_current(item->parent)) {
+ /* The restart was ok, do not send any signal and do not start next*/
+ return;
+ }
+ }
- if (!libgnac_converter_start_next(item->converter))
+ if (!libgnac_converter_start_next(converter))
{
- item->converter->priv->n_converted = -1;
- g_signal_emit(item->converter, signals[COMPLETION], 0);
+ converter->priv->n_converted = -1;
+ g_signal_emit(converter, signals[COMPLETION], 0);
}
-
- //libgnac_converter_restart_current(item->converter);
}
diff --cc libgnac/libgnac-output.c
index e546d96,4b16a40..ee47a1f
--- a/libgnac/libgnac-output.c
+++ b/libgnac/libgnac-output.c
@@@ -402,12 -404,14 +404,14 @@@ libgnac_output_build_output(LibgnacMedi
g_return_if_fail(!error || !*error);
+ if (item->destination) return;
+
- g_object_get(item->converter, "extension", &extension, NULL);
- g_object_get(item->converter, "strip-special", &strip_special, NULL);
- g_object_get(item->converter, "folder-hierarchy", &folder_hierarchy, NULL);
- g_object_get(item->converter, "folder-path", &folder_path, NULL);
- g_object_get(item->converter, "rename-pattern", &rename_pattern, NULL);
- g_object_get(item->converter, "folder-type", &folder_type, NULL);
+ g_object_get(item->parent, "extension", &extension, NULL);
+ g_object_get(item->parent, "strip-special", &strip_special, NULL);
+ g_object_get(item->parent, "folder-hierarchy", &folder_hierarchy, NULL);
+ g_object_get(item->parent, "folder-path", &folder_path, NULL);
+ g_object_get(item->parent, "rename-pattern", &rename_pattern, NULL);
+ g_object_get(item->parent, "folder-type", &folder_type, NULL);
filename = libgnac_output_get_filename(item, rename_pattern, &output_error);
if (output_error) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]