Enlightenment CVS committal Author : moom16 Project : e17 Module : apps/eclair
Dir : e17/apps/eclair/src Modified Files: eclair.c eclair.h eclair_callbacks.c eclair_callbacks.h eclair_cover.c eclair_cover.h eclair_media_file.c eclair_meta_tag.c eclair_private.h Log Message: * Fix subtitles font by adding fonts.dir and fonts.alias * Improve cover integration in the GUI * Fix segfaults related to cover, which happened on shutdown * Some cleanups and fixes =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- eclair.c 30 Apr 2005 17:28:22 -0000 1.5 +++ eclair.c 2 May 2005 16:06:50 -0000 1.6 @@ -41,11 +41,13 @@ eclair->gui_object = NULL; eclair->gui_draggies = NULL; eclair->gui_cover = NULL; + eclair->gui_previous_cover = NULL; eclair->playlist_container = NULL; eclair->playlist_entry_height = -1; eclair->file_chooser_widget = NULL; eclair->state = ECLAIR_STOP; eclair->seek_to_pos = -1.0; + eclair->use_progress_bar_drag_for_time = 0; eclair->dont_update_progressbar = 0; eclair->file_chooser_th_created = 0; eclair->video_engine = ECLAIR_SOFTWARE; @@ -78,10 +80,10 @@ { if (eclair) { - eclair_playlist_empty(&eclair->playlist); eclair_subtitles_free(&eclair->subtitles); eclair_meta_tag_shutdown(&eclair->meta_tag_manager); eclair_cover_shutdown(&eclair->cover_manager); + eclair_playlist_empty(&eclair->playlist); eclair_config_shutdown(&eclair->config); } @@ -95,50 +97,40 @@ //Called when an new frame is decoded void eclair_update(Eclair *eclair) { - double progress_rate; char time_elapsed[10] = ""; - double position, length, time_to_display, x; + double position, length; if (!eclair) return; if (!eclair->video_object || !eclair->gui_object) return; - position = emotion_object_position_get(eclair->video_object); length = emotion_object_play_length_get(eclair->video_object); //Update time text - edje_object_part_drag_value_get(eclair->gui_object, "progress_bar_drag", &x, NULL); - time_to_display = x * length; - eclair_utils_second_to_string(time_to_display, length, time_elapsed); + if (eclair->use_progress_bar_drag_for_time) + { + edje_object_part_drag_value_get(eclair->gui_object, "progress_bar_drag", &position, NULL); + position *= length; + } + else + position = eclair_position_get(eclair); + eclair_utils_second_to_string(position, length, time_elapsed); edje_object_part_text_set(eclair->gui_object, "time_elapsed", time_elapsed); //Update progress bar - progress_rate = position / length; if (eclair->dont_update_progressbar) - { - eclair->dont_update_progressbar = 0.0; - if (eclair->seek_to_pos >= 0.0) - edje_object_part_drag_value_set(eclair->gui_object, "progress_bar_drag", eclair->seek_to_pos / length, 0.0); - } - else - { - if (eclair->seek_to_pos >= 0.0) - { - edje_object_part_drag_value_set(eclair->gui_object, "progress_bar_drag", eclair->seek_to_pos / length, 0.0); - eclair->seek_to_pos = -1.0; - } - else - edje_object_part_drag_value_set(eclair->gui_object, "progress_bar_drag", progress_rate, 0.0); - } + eclair->dont_update_progressbar = 0; + else if (eclair->seek_to_pos >= 0.0) + eclair->seek_to_pos = -1.0; + edje_object_part_drag_value_set(eclair->gui_object, "progress_bar_drag", position / length, 0.0); //Display subtitles eclair_subtitles_display_current_subtitle(&eclair->subtitles, position, eclair->subtitles_object); } -//TODO: //Set the file as current -void eclair_current_file_set(Eclair *eclair, const Eclair_Media_File *file) +void eclair_current_file_set(Eclair *eclair, Eclair_Media_File *file) { char *window_title; char *artist_title_string; @@ -182,30 +174,37 @@ else ecore_evas_title_set(eclair->video_window, "eclair"); } - eclair_cover_add_file_to_treat(&eclair->cover_manager, file); + eclair_cover_add_file_to_treat(&eclair->cover_manager, file, 1); } //Set the cover displayed on the GUI //Remove it if cover_path == NULL void eclair_gui_cover_set(Eclair *eclair, const char *cover_path) { - Evas_Coord cover_width, cover_height; - if (!eclair) return; if (!eclair->gui_object || !eclair->gui_cover) return; - edje_object_part_unswallow(eclair->gui_object, eclair->gui_cover); + if (eclair->gui_previous_cover) + { + Evas_Object *tmp; + + edje_object_part_unswallow(eclair->gui_object, eclair->gui_cover); + edje_object_part_unswallow(eclair->gui_object, eclair->gui_previous_cover); + tmp = eclair->gui_previous_cover; + eclair->gui_previous_cover = eclair->gui_cover; + eclair->gui_cover = tmp; + edje_object_part_swallow(eclair->gui_object, "cover", eclair->gui_cover); + edje_object_part_swallow(eclair->gui_object, "previous_cover", eclair->gui_previous_cover); + } + if (!cover_path) - evas_object_hide(eclair->gui_cover); - else + edje_object_signal_emit(eclair->gui_object, "signal_cover_unset", "eclair_bin"); + if (cover_path) { evas_object_image_file_set(eclair->gui_cover, cover_path, NULL); - edje_object_part_geometry_get(eclair->gui_object, "cover", NULL, NULL, &cover_width, &cover_height); - evas_object_image_fill_set(eclair->gui_cover, 0, 0, cover_width, cover_height); - edje_object_part_swallow(eclair->gui_object, "cover", eclair->gui_cover); - evas_object_show(eclair->gui_cover); + edje_object_signal_emit(eclair->gui_object, "signal_cover_set", "eclair_bin"); } } @@ -414,7 +413,7 @@ eclair->state = ECLAIR_STOP; } -//Set audio level +//Set the audio level void eclair_audio_level_set(Eclair *eclair, double audio_level) { if (!eclair) @@ -426,15 +425,60 @@ edje_object_part_drag_value_set(eclair->gui_object, "volume_bar_drag", audio_level, 0); } -//Set media progress rate +//Get the media progress rate +double eclair_progress_rate_get(Eclair *eclair) +{ + if (!eclair) + return 0.0; + if (!eclair->video_object) + return 0.0; + + return eclair_position_get(eclair) / emotion_object_play_length_get(eclair->video_object); +} + +//Set the media progress rate void eclair_progress_rate_set(Eclair *eclair, double progress_rate) { if (!eclair) return; if (!eclair->video_object) return; + + eclair_position_set(eclair, progress_rate * emotion_object_play_length_get(eclair->video_object)); +} + +//Get the media position in seconds +double eclair_position_get(Eclair *eclair) +{ + if (!eclair) + return 0.0; + if (!eclair->video_object) + return 0.0; - emotion_object_position_set(eclair->video_object, emotion_object_play_length_get(eclair->video_object) * progress_rate); + if (eclair->seek_to_pos < 0.0) + return emotion_object_position_get(eclair->video_object); + else + return eclair->seek_to_pos; +} + +//Set the media position in seconds +void eclair_position_set(Eclair *eclair, double position) +{ + double media_length; + + if (!eclair) + return; + if (!eclair->video_object) + return; + + media_length = emotion_object_play_length_get(eclair->video_object); + if (position < 0.0) + position = 0.0; + else if (position > media_length) + position = media_length; + eclair->dont_update_progressbar = 1; + eclair->seek_to_pos = position; + emotion_object_position_set(eclair->video_object, eclair->seek_to_pos); } //Create the gui window and load the interface @@ -442,6 +486,7 @@ { Evas *evas; Evas_Coord gui_width, gui_height; + Evas_Coord cover_width, cover_height; if (!eclair) return; @@ -485,7 +530,18 @@ if (edje_object_part_exists(eclair->gui_object, "cover")) { eclair->gui_cover = evas_object_image_add(evas); - evas_object_hide(eclair->gui_cover); + edje_object_part_swallow(eclair->gui_object, "cover", eclair->gui_cover); + edje_object_part_geometry_get(eclair->gui_object, "cover", NULL, NULL, &cover_width, &cover_height); + evas_object_image_fill_set(eclair->gui_cover, 0, 0, cover_width, cover_height); + evas_object_show(eclair->gui_cover); + } + if (edje_object_part_exists(eclair->gui_object, "previous_cover")) + { + eclair->gui_previous_cover = evas_object_image_add(evas); + edje_object_part_swallow(eclair->gui_object, "previous_cover", eclair->gui_previous_cover); + edje_object_part_geometry_get(eclair->gui_object, "previous_cover", NULL, NULL, &cover_width, &cover_height); + evas_object_image_fill_set(eclair->gui_previous_cover, 0, 0, cover_width, cover_height); + evas_object_show(eclair->gui_previous_cover); } evas_object_focus_set(eclair->gui_object, 1); @@ -498,13 +554,14 @@ edje_object_signal_callback_add(eclair->gui_object, "eclair_stop", "*", eclair_gui_stop_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "eclair_prev", "*", eclair_gui_prev_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "eclair_next", "*", eclair_gui_next_cb, eclair); - edje_object_signal_callback_add(eclair->gui_object, "drag,stop", "progress_bar_drag", eclair_gui_progress_bar_drag_cb, eclair); + edje_object_signal_callback_add(eclair->gui_object, "drag*", "progress_bar_drag", eclair_gui_progress_bar_drag_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "drag", "volume_bar_drag", eclair_gui_volume_bar_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "drag", "playlist_scrollbar_button", eclair_gui_playlist_scrollbar_button_drag_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_down_start", "", eclair_gui_playlist_scroll_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_down_stop", "", eclair_gui_playlist_scroll_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_up_start", "", eclair_gui_playlist_scroll_cb, eclair); edje_object_signal_callback_add(eclair->gui_object, "playlist_scroll_up_stop", "", eclair_gui_playlist_scroll_cb, eclair); + edje_object_message_handler_set(eclair->gui_object, eclair_gui_message_cb, eclair); } //Create the video window and object =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- eclair.h 30 Apr 2005 17:28:23 -0000 1.3 +++ eclair.h 2 May 2005 16:06:50 -0000 1.4 @@ -8,7 +8,7 @@ void eclair_shutdown(Eclair *eclair); void eclair_update(Eclair *eclair); void *eclair_file_chooser_thread(void *param); -void eclair_current_file_set(Eclair *eclair, const Eclair_Media_File *file); +void eclair_current_file_set(Eclair *eclair, Eclair_Media_File *file); void eclair_playlist_container_scroll(Eclair *eclair, int num_entries); void eclair_playlist_container_scroll_percent_set(Eclair *eclair, double percent); void eclair_gui_cover_set(Eclair *eclair, const char *cover_path); @@ -21,7 +21,10 @@ void eclair_pause(Eclair *eclair); void eclair_play(Eclair *eclair); void eclair_stop(Eclair *eclair); +double eclair_progress_rate_get(Eclair *eclair); void eclair_progress_rate_set(Eclair *eclair, double progress_rate); +double eclair_position_get(Eclair *eclair); +void eclair_position_set(Eclair *eclair, double position); void eclair_audio_level_set(Eclair *eclair, double audio_level); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_callbacks.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- eclair_callbacks.c 30 Apr 2005 17:41:18 -0000 1.5 +++ eclair_callbacks.c 2 May 2005 16:06:50 -0000 1.6 @@ -9,6 +9,11 @@ #include "eclair.h" #include "eclair_playlist.h" +typedef enum _Eclair_Gui_Message_Id +{ + COVER_ALPHA_CHANGED = 0 +} Eclair_Gui_Message_Id; + //Called when eclair is closed int eclair_exit_cb(void *data, int type, void *event) { @@ -122,33 +127,27 @@ || strcmp(ev->key, "Prior") == 0 || strcmp(ev->key, "Next") == 0 || strcmp(ev->key, "Home") == 0) { + double media_position; + if (!eclair->video_object) return; - if (eclair->seek_to_pos < 0.0) - eclair->seek_to_pos = emotion_object_position_get(eclair->video_object); - + media_position = eclair_position_get(eclair); if (strcmp(ev->key, "Left") == 0) - eclair->seek_to_pos -= 15.0; + media_position -= 15.0; else if (strcmp(ev->key, "Right") == 0) - eclair->seek_to_pos += 15.0; + media_position += 15.0; else if (strcmp(ev->key, "Down") == 0) - eclair->seek_to_pos -= 60.0; + media_position -= 60.0; else if (strcmp(ev->key, "Up") == 0) - eclair->seek_to_pos += 60.0; - else if (strcmp(ev->key, "Prior") == 0) - eclair->seek_to_pos -= 600.0; + media_position += 60.0; else if (strcmp(ev->key, "Next") == 0) - eclair->seek_to_pos += 600.0; + media_position -= 600.0; + else if (strcmp(ev->key, "Prior") == 0) + media_position += 600.0; else if (strcmp(ev->key, "Home") == 0) - eclair->seek_to_pos = 0.0; - - if (eclair->seek_to_pos < 0.0) - eclair->seek_to_pos = 0.0; - else if (eclair->seek_to_pos > emotion_object_play_length_get(eclair->video_object)) - eclair->seek_to_pos = emotion_object_play_length_get(eclair->video_object); - eclair->dont_update_progressbar = 1; - emotion_object_position_set(eclair->video_object, eclair->seek_to_pos); + media_position = 0.0; + eclair_position_set(eclair, media_position); } else if (strcmp(ev->key, "KP_Divide") == 0 || strcmp(ev->key, "slash") == 0 || strcmp(ev->key, "KP_Multiply") == 0 || strcmp(ev->key, "asterisk") == 0) @@ -163,6 +162,7 @@ volume -= (1.0 / 100); else if (strcmp(ev->key, "KP_Multiply") == 0 || strcmp (ev->key, "asterisk") == 0) volume += (1.0 / 100); + if (volume < 0.0) volume = 0.0; else if (volume > 1.0) @@ -263,14 +263,19 @@ void eclair_gui_progress_bar_drag_cb(void *data, Evas_Object *edje_object, const char *emission, const char *source) { Eclair *eclair = (Eclair *)data; - double x; + double progress_rate; if (!eclair) return; - edje_object_part_drag_value_get(eclair->gui_object, "progress_bar_drag", &x, NULL); - eclair_progress_rate_set(eclair, x); - eclair->dont_update_progressbar = 1; + if (strcmp(emission, "drag,start") == 0) + eclair->use_progress_bar_drag_for_time = 1; + else if (strcmp(emission, "drag,stop") == 0) + { + eclair->use_progress_bar_drag_for_time = 0; + edje_object_part_drag_value_get(eclair->gui_object, "progress_bar_drag", &progress_rate, NULL); + eclair_progress_rate_set(eclair, progress_rate); + } } //Called when the user drags the volume bar button @@ -325,3 +330,31 @@ eclair_playlist_container_scroll(eclair, event->z); } + +//Called when the gui send a message +void eclair_gui_message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg) +{ + Eclair *eclair = (Eclair *)data; + + if (!eclair) + return; + + switch (id) + { + case COVER_ALPHA_CHANGED: + { + Edje_Message_Int_Set *message; + if (type != EDJE_MESSAGE_INT_SET || !(message = (Edje_Message_Int_Set *)msg)) + break; + if (message->count != 2) + break; + if (eclair->gui_cover) + evas_object_color_set(eclair->gui_cover, 255, 255, 255, message->val[0]); + if (eclair->gui_previous_cover) + evas_object_color_set(eclair->gui_previous_cover, 255, 255, 255, message->val[1]); + break; + } + default: + break; + } +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_callbacks.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- eclair_callbacks.h 30 Apr 2005 12:11:16 -0000 1.3 +++ eclair_callbacks.h 2 May 2005 16:06:50 -0000 1.4 @@ -26,5 +26,6 @@ void eclair_gui_playlist_scrollbar_button_drag_cb(void *data, Evas_Object *edje_object, const char *emission, const char *source); void eclair_gui_playlist_container_wheel_cb(void *data, Evas *evas, Evas_Object *playlist_container, void *event_info); void eclair_gui_playlist_scroll_cb(void *data, Evas_Object *edje_object, const char *emission, const char *source); +void eclair_gui_message_cb(void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_cover.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eclair_cover.c 30 Apr 2005 12:11:16 -0000 1.2 +++ eclair_cover.c 2 May 2005 16:06:50 -0000 1.3 @@ -15,11 +15,17 @@ #define PACKET_CHUNK_SIZE 1024 #define MAX_REQUEST_SIZE 1024 -typedef struct _Eclair_Packet_Chunk +typedef struct _Eclair_Cover_Packet_Chunk { int size; char *data; -} Eclair_Packet_Chunk; +} Eclair_Cover_Packet_Chunk; + +typedef struct _Eclair_Cover_Not_In_DB_Album +{ + char *artist; + char *album; +} Eclair_Cover_Not_In_DB_Album; const char *amazon_hostname = "webservices.amazon.com"; const char *amazon_license_key = "0P1862RFDFSF4KYZQNG2"; @@ -37,6 +43,7 @@ static char *_eclair_cover_convert_to_url_format(const char *string); static xmlNode *_eclair_cover_get_node_xml_tree(xmlNode *root_node, const char *prop); static xmlChar *_eclair_cover_get_prop_value_from_xml_tree(xmlNode *root_node, const char *prop); +static void _eclair_cover_add_file_to_not_in_amazon_db_list(Evas_List **list, const char *artist, const char *album); static void *_eclair_cover_thread(void *param); @@ -47,6 +54,7 @@ return; cover_manager->cover_files_to_treat = NULL; + cover_manager->not_in_amazon_db = NULL; cover_manager->eclair = eclair; cover_manager->amazon_he = NULL; cover_manager->cover_delete_thread = 0; @@ -58,40 +66,52 @@ //Shutdown the cover module void eclair_cover_shutdown(Eclair_Cover_Manager *cover_manager) { + Evas_List *l; + Eclair_Cover_Not_In_DB_Album *album; + if (!cover_manager) return; free(cover_manager->amazon_he); - printf("Cover: Debug: Destroying cover thread\n"); + for (l = cover_manager->not_in_amazon_db; l; l = l->next) + { + if ((album = (Eclair_Cover_Not_In_DB_Album *)l->data)) + { + free(album->artist); + free(album->album); + free(album); + } + } + evas_list_free(cover_manager->not_in_amazon_db); + + fprintf(stderr, "Cover: Debug: Destroying cover thread\n"); cover_manager->cover_delete_thread = 1; - pthread_cond_broadcast(&cover_manager->cover_cond); - pthread_join(cover_manager->cover_thread, NULL); - printf("Cover: Debug: Cover thread destroyed\n"); + pthread_cond_broadcast(&cover_manager->cover_cond); + pthread_join(cover_manager->cover_thread, NULL); + fprintf(stderr, "Cover: Debug: Cover thread destroyed\n"); } //Add a media file to the list of files to treat -void eclair_cover_add_file_to_treat(Eclair_Cover_Manager *cover_manager, const Eclair_Media_File *media_file) +void eclair_cover_add_file_to_treat(Eclair_Cover_Manager *cover_manager, Eclair_Media_File *media_file, Evas_Bool high_priority) { if (!cover_manager || !media_file) return; - cover_manager->cover_files_to_treat = evas_list_append(cover_manager->cover_files_to_treat, media_file); + if (high_priority) + cover_manager->cover_files_to_treat = evas_list_prepend(cover_manager->cover_files_to_treat, media_file); + else + cover_manager->cover_files_to_treat = evas_list_append(cover_manager->cover_files_to_treat, media_file); pthread_cond_broadcast(&cover_manager->cover_cond); } -//TODO: amazon_he and comment -//CODE: -/*if ((he = gethostbyname(amazon_hostname))) -{ -cover_manager->amazon_he = (struct hostent *)malloc(sizeof(struct hostent)); -memcpy(cover_manager->amazon_he, he, sizeof(struct hostent)); -}*/ +//Fetch from amazon the covers of the files stored in the list cover_files_to_treat static void *_eclair_cover_thread(void *param) { Eclair_Cover_Manager *cover_manager = (Eclair_Cover_Manager *)param; Evas_List *l, *next; Eclair_Media_File *current_file; char *cover_path; + struct hostent *he; if (!cover_manager) return NULL; @@ -100,29 +120,36 @@ for (;;) { pthread_cond_wait(&cover_manager->cover_cond, &cover_manager->cover_mutex); + if (!cover_manager->amazon_he) + { + if ((he = gethostbyname(amazon_hostname))) + { + cover_manager->amazon_he = (struct hostent *)malloc(sizeof(struct hostent)); + memcpy(cover_manager->amazon_he, he, sizeof(struct hostent)); + } + } while (cover_manager->cover_files_to_treat || cover_manager->cover_delete_thread) { - for (l = cover_manager->cover_files_to_treat; l; l = next) + for (l = cover_manager->cover_files_to_treat; l || cover_manager->cover_delete_thread; l = next) { + if (cover_manager->cover_delete_thread) + { + cover_manager->cover_files_to_treat = evas_list_free(cover_manager->cover_files_to_treat); + cover_manager->cover_delete_thread = 0; + return NULL; + } + next = l->next; current_file = (Eclair_Media_File *)l->data; cover_manager->cover_files_to_treat = evas_list_remove_list(cover_manager->cover_files_to_treat, l); - if ((cover_path = eclair_cover_file_get(cover_manager, current_file->artist, current_file->album, current_file->path))) + + cover_path = eclair_cover_file_get(cover_manager, current_file->artist, current_file->album, current_file->path); + if (cover_manager->eclair) { - if (cover_manager->eclair) - { - if (current_file == evas_list_data(cover_manager->eclair->playlist.current)) - eclair_gui_cover_set(cover_manager->eclair, cover_path); - } - free(cover_path); + if (current_file == evas_list_data(cover_manager->eclair->playlist.current)) + eclair_gui_cover_set(cover_manager->eclair, cover_path); } - } - - if (cover_manager->cover_delete_thread) - { - cover_manager->cover_files_to_treat = evas_list_free(cover_manager->cover_files_to_treat); - cover_manager->cover_delete_thread = 0; - return NULL; + free(cover_path); } } } @@ -135,6 +162,9 @@ { char *path; + if (!cover_manager) + return NULL; + if ((path = eclair_cover_file_get_from_local(cover_manager, artist, album, file_path))) return path; if ((path = eclair_cover_file_get_from_amazon(cover_manager, artist, album))) @@ -184,9 +214,24 @@ char url[MAX_REQUEST_SIZE]; char *keywords, *converted_keywords; FILE *cover_file; + Evas_List *l; + Eclair_Cover_Not_In_DB_Album *not_in_db_album; if (!cover_manager || !artist || !album) return NULL; + if (strlen(artist) <= 0 || strlen(album) <= 0) + return NULL; + + //Check if we already perform a search on this album and if amazon answered it doesn't have this album in database + for (l = cover_manager->not_in_amazon_db; l; l = l->next) + { + if (!(not_in_db_album = l->data)) + continue; + if (!not_in_db_album->artist || !not_in_db_album->album) + continue; + if (strcmp(not_in_db_album->artist, artist) == 0 && strcmp(not_in_db_album->album, album) == 0) + return NULL; + } //Get the ASIN of the album keywords = (char *)malloc(strlen(artist) + strlen(album) + 2); @@ -196,10 +241,12 @@ _eclair_cover_build_url_for_item_search(converted_keywords, url); free(converted_keywords); + if (cover_manager->cover_delete_thread) + return NULL; body_length = _eclair_cover_fetch(url, cover_manager->amazon_he, &body); if (body_length <= 0) { - free(body); + fprintf(stderr, "Cover: Unable to download cover from amazon.com\n"); return NULL; } @@ -207,14 +254,15 @@ free(body); if (!doc) { - printf("Cover: Amazon.com webservices sent a non xml response\n"); + fprintf(stderr, "Cover: Amazon.com webservices sent a non xml response\n"); return NULL; } ASIN = _eclair_cover_get_prop_value_from_xml_tree(xmlDocGetRootElement(doc), "ASIN"); xmlFreeDoc(doc); if (!ASIN) { - printf("Cover: Unable to find the item \"%s - %s\" on amazon\n", artist, album); + fprintf(stderr, "Cover: Unable to find the item \"%s - %s\" on amazon\n", artist, album); + _eclair_cover_add_file_to_not_in_amazon_db_list(&cover_manager->not_in_amazon_db, artist, album); return NULL; } @@ -222,10 +270,12 @@ //Get cover url from the ASIN _eclair_cover_build_url_for_item_images((char *)ASIN, url); xmlFree(ASIN); + if (cover_manager->cover_delete_thread) + return NULL; body_length = _eclair_cover_fetch(url, cover_manager->amazon_he, &body); if (body_length <= 0) { - free(body); + fprintf(stderr, "Cover: Unable to download cover from amazon.com\n"); return NULL; } @@ -233,35 +283,45 @@ free(body); if (!doc) { - printf("Cover: Amazon.com webservices sent a non xml response\n"); + fprintf(stderr, "Cover: Amazon.com webservices sent a non xml response\n"); return NULL; } - image_node = _eclair_cover_get_node_xml_tree(xmlDocGetRootElement(doc), "LargeImage"); + if (!(image_node = _eclair_cover_get_node_xml_tree(xmlDocGetRootElement(doc), "LargeImage"))) + { + if (!(image_node = _eclair_cover_get_node_xml_tree(xmlDocGetRootElement(doc), "MediumImage"))) + image_node = _eclair_cover_get_node_xml_tree(xmlDocGetRootElement(doc), "SmallImage"); + } cover_url = _eclair_cover_get_prop_value_from_xml_tree(image_node, "URL"); xmlFreeDoc(doc); if (!cover_url) { - printf("Cover: Unable to find the cover for %s - %s\n", artist, album); + fprintf(stderr, "Cover: Unable to find the cover for %s - %s\n", artist, album); + _eclair_cover_add_file_to_not_in_amazon_db_list(&cover_manager->not_in_amazon_db, artist, album); return NULL; } //Fetch the cover - cover_path = _eclair_cover_build_path_from_artist_album(cover_manager, artist, album, "jpg"); + if (cover_manager->cover_delete_thread) + { + xmlFree(cover_url); + return NULL; + } body_length = _eclair_cover_fetch(cover_url, NULL, &body); xmlFree(cover_url); if (body_length <= 0) { - free(body); - printf("Cover: Unable to download cover from amazon.com\n"); + fprintf(stderr, "Cover: Unable to download cover from amazon.com\n"); return NULL; } //Save the file and return the path + cover_path = _eclair_cover_build_path_from_artist_album(cover_manager, artist, album, "jpg"); cover_file = fopen(cover_path, "wb"); if (!cover_file) { - printf("Cover: Unable to open the file \"%s\" to save the cover\n", cover_path); + fprintf(stderr, "Cover: Unable to open the file \"%s\" to save the cover\n", cover_path); + free(cover_path); free(body); return NULL; } @@ -284,7 +344,7 @@ if (!(he = gethostbyname(hostname))) { - printf("Cover: Unable to find IP of %s\n", hostname); + fprintf(stderr, "Cover: Unable to find IP of %s\n", hostname); return -1; } return _eclair_cover_connect_to_host(he); @@ -303,7 +363,7 @@ if ((socket_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - printf("Cover: Unable to create an Internet socket\n"); + fprintf(stderr, "Cover: Unable to create an Internet socket\n"); return 0; } @@ -313,7 +373,7 @@ memcpy(&adress.sin_addr, host->h_addr, host->h_length); if (connect(socket_fd, (struct sockaddr *)&adress, sizeof(struct sockaddr)) != 0) { - printf("Cover: Unable to connect to %s\n", inet_ntoa(adress.sin_addr)); + fprintf(stderr, "Cover: Unable to connect to %s\n", inet_ntoa(adress.sin_addr)); close(socket_fd); return -1; } @@ -339,14 +399,14 @@ if (strncmp(url, "http://", 7) != 0) { - printf("Cover: Invalid URL\n"); + fprintf(stderr, "Cover: Invalid URL\n"); return -1; } host_start = url + 7; url_abs_path = index(host_start, '/'); if (!url_abs_path) { - printf("Cover: Invalid URL\n"); + fprintf(stderr, "Cover: Invalid URL\n"); return -1; } @@ -375,7 +435,7 @@ sprintf(request, "GET %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: eclair\r\n\r\n", url_abs_path, host); if (send(socket_fd, request, strlen(request), 0) <= 0) { - printf("Cover: Unable to send request to host: %s\n", host); + fprintf(stderr, "Cover: Unable to send request to host: %s\n", host); free(host); close(socket_fd); return -1; @@ -386,7 +446,7 @@ free(host); if (body_length <= 0) { - printf("Unable to fetch the file stored at %s\n", url); + fprintf(stderr, "Cover: Unable to fetch the file stored at %s\n", url); free(packet); return body_length; } @@ -403,7 +463,7 @@ { char packet_chunk[PACKET_CHUNK_SIZE]; int num_bytes_read, pos; - Eclair_Packet_Chunk *chunk; + Eclair_Cover_Packet_Chunk *chunk; Evas_List *l, *chunks = NULL; if (socket_fd < 0 || !packet || !length) @@ -412,7 +472,7 @@ *length = 0; while ((num_bytes_read = read(socket_fd, packet_chunk, PACKET_CHUNK_SIZE)) > 0) { - chunk = (Eclair_Packet_Chunk *)malloc(sizeof(Eclair_Packet_Chunk)); + chunk = (Eclair_Cover_Packet_Chunk *)malloc(sizeof(Eclair_Cover_Packet_Chunk)); chunk->size = num_bytes_read; chunk->data = (char *)malloc(num_bytes_read * sizeof(char)); memcpy(chunk->data, packet_chunk, num_bytes_read); @@ -431,7 +491,7 @@ *packet = (char *)malloc(*length * sizeof(char)); for (l = chunks; l; l = l->next) { - if (!(chunk = (Eclair_Packet_Chunk *)l->data)) + if (!(chunk = (Eclair_Cover_Packet_Chunk *)l->data)) continue; memcpy(*packet + pos, chunk->data, chunk->size); free(chunk->data); @@ -589,3 +649,17 @@ return NULL; else return xmlNodeGetContent(node); } + +//Add the album to the list of albums which amazon doesn't have in its database +static void _eclair_cover_add_file_to_not_in_amazon_db_list(Evas_List **list, const char *artist, const char *album) +{ + Eclair_Cover_Not_In_DB_Album *new_album; + + if (!artist || !album || !list) + return; + + new_album = (Eclair_Cover_Not_In_DB_Album *)malloc(sizeof(Eclair_Cover_Not_In_DB_Album)); + new_album->artist = strdup(artist); + new_album->album = strdup(album); + *list = evas_list_prepend(*list, new_album); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_cover.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eclair_cover.h 30 Apr 2005 12:11:16 -0000 1.2 +++ eclair_cover.h 2 May 2005 16:06:50 -0000 1.3 @@ -5,7 +5,7 @@ void eclair_cover_init(Eclair_Cover_Manager *cover_manager, Eclair *eclair); void eclair_cover_shutdown(Eclair_Cover_Manager *cover_manager); -void eclair_cover_add_file_to_treat(Eclair_Cover_Manager *cover_manager, const Eclair_Media_File *media_file); +void eclair_cover_add_file_to_treat(Eclair_Cover_Manager *cover_manager, Eclair_Media_File *media_file, Evas_Bool high_priority); char *eclair_cover_file_get(Eclair_Cover_Manager *cover_manager, const char *artist, const char *album, const char *file_path); char *eclair_cover_file_get_from_local(Eclair_Cover_Manager *cover_manager, const char *artist, const char *album, const char *file_path); char *eclair_cover_file_get_from_amazon(Eclair_Cover_Manager *cover_manager, const char *artist, const char *album); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_media_file.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- eclair_media_file.c 30 Apr 2005 12:11:16 -0000 1.1 +++ eclair_media_file.c 2 May 2005 16:06:50 -0000 1.2 @@ -4,17 +4,10 @@ #include "eclair_cover.h" #include "eclair_utils.h" -static unsigned int _eclair_media_file_next_id = 0; - //Create a new media file Eclair_Media_File *eclair_media_file_new() { - Eclair_Media_File *new_media_file; - - new_media_file = (Eclair_Media_File *)calloc(1, sizeof(Eclair_Media_File)); - new_media_file->id = _eclair_media_file_next_id++; - - return new_media_file; + return (Eclair_Media_File *)calloc(1, sizeof(Eclair_Media_File)); } //Free a media file @@ -66,8 +59,8 @@ if (!eclair) return; - //TODO: Prioritize current file - eclair_cover_add_file_to_treat(&eclair->cover_manager, media_file); if (media_file == evas_list_data(eclair->playlist.current)) eclair_current_file_set(eclair, media_file); + else + eclair_cover_add_file_to_treat(&eclair->cover_manager, media_file, 0); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_meta_tag.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- eclair_meta_tag.c 30 Apr 2005 17:28:23 -0000 1.2 +++ eclair_meta_tag.c 2 May 2005 16:06:50 -0000 1.3 @@ -26,11 +26,11 @@ if (!meta_tag_manager) return; - printf("Meta tag: Debug: Destroying meta tag thread\n"); + fprintf(stderr, "Meta tag: Debug: Destroying meta tag thread\n"); meta_tag_manager->meta_tag_delete_thread = 1; pthread_cond_broadcast(&meta_tag_manager->meta_tag_cond); pthread_join(meta_tag_manager->meta_tag_thread, NULL); - printf("Meta tag: Debug: Meta tag thread destroyed\n"); + fprintf(stderr, "Meta tag: Debug: Meta tag thread destroyed\n"); } //Add a media file to the list of files to scan for meta tag @@ -38,7 +38,7 @@ { if (!meta_tag_manager || !media_file) return; - + meta_tag_manager->meta_tag_files_to_scan = evas_list_append(meta_tag_manager->meta_tag_files_to_scan, media_file); pthread_cond_broadcast(&meta_tag_manager->meta_tag_cond); } @@ -70,8 +70,8 @@ } if ((tag_audio_props = taglib_file_audioproperties(tag_file))) media_file->length = taglib_audioproperties_length(tag_audio_props); - taglib_file_free(tag_file); taglib_tag_free_strings(); + taglib_file_free(tag_file); eclair_media_file_update(eclair, media_file); } @@ -94,20 +94,20 @@ pthread_cond_wait(&meta_tag_manager->meta_tag_cond, &meta_tag_manager->meta_tag_mutex); while (meta_tag_manager->meta_tag_files_to_scan || meta_tag_manager->meta_tag_delete_thread) { - for (l = meta_tag_manager->meta_tag_files_to_scan; l; l = next) + for (l = meta_tag_manager->meta_tag_files_to_scan; l || meta_tag_manager->meta_tag_delete_thread; l = next) { + if (meta_tag_manager->meta_tag_delete_thread) + { + meta_tag_manager->meta_tag_files_to_scan = evas_list_free(meta_tag_manager->meta_tag_files_to_scan); + meta_tag_manager->meta_tag_delete_thread = 0; + return NULL; + } + next = l->next; current_file = (Eclair_Media_File *)l->data; meta_tag_manager->meta_tag_files_to_scan = evas_list_remove_list(meta_tag_manager->meta_tag_files_to_scan, l); eclair_meta_tag_read(eclair, current_file); } - - if (meta_tag_manager->meta_tag_delete_thread) - { - meta_tag_manager->meta_tag_files_to_scan = evas_list_free(meta_tag_manager->meta_tag_files_to_scan); - meta_tag_manager->meta_tag_delete_thread = 0; - return NULL; - } } } return NULL; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/eclair/src/eclair_private.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- eclair_private.h 30 Apr 2005 12:11:16 -0000 1.4 +++ eclair_private.h 2 May 2005 16:06:50 -0000 1.5 @@ -30,6 +30,7 @@ struct _Eclair_Cover_Manager { Evas_List *cover_files_to_treat; + Evas_List *not_in_amazon_db; struct hostent *amazon_he; Eclair *eclair; Evas_Bool cover_delete_thread; @@ -49,7 +50,6 @@ struct _Eclair_Media_File { - unsigned int id; char *path; char *artist; char *title; @@ -107,10 +107,11 @@ Ecore_Evas *gui_window; Evas_Object *gui_object; Evas_Object *gui_draggies; - Evas_Object *gui_cover; + Evas_Object *gui_cover, *gui_previous_cover; Evas_Object *playlist_container; int playlist_entry_height; double seek_to_pos; + Evas_Bool use_progress_bar_drag_for_time; Evas_Bool dont_update_progressbar; Eclair_Engine gui_engine; ------------------------------------------------------- This SF.Net email is sponsored by: NEC IT Guy Games. Get your fingers limbered up and give it your best shot. 4 great events, 4 opportunities to win big! Highest score wins.NEC IT Guy Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs