summaryrefslogtreecommitdiff
path: root/legacy/emotion/src
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2013-01-03 20:27:08 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2013-01-03 20:27:08 +0000
commitd9c28e87a207b60c5dc3c83a174e28c6ceee447e (patch)
tree23fbf7ecfb7583b4210ff16f4ae0e6c5d168ef68 /legacy/emotion/src
parent0ec613a4fa4c022e5eaac05c94a1ade569d0eed6 (diff)
Emotion: generic vlc player now uses eina_log
SVN revision: 82098
Diffstat (limited to 'legacy/emotion/src')
-rw-r--r--legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c68
1 files changed, 45 insertions, 23 deletions
diff --git a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
index d15341667a..a20717303c 100644
--- a/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
+++ b/legacy/emotion/src/generic_players/vlc/emotion_generic_vlc.c
@@ -20,6 +20,14 @@
20#include <vlc/vlc.h> 20#include <vlc/vlc.h>
21 21
22#include <Emotion_Generic_Plugin.h> 22#include <Emotion_Generic_Plugin.h>
23#include <Eina.h>
24
25static int _em_vlc_log_dom = -1;
26#define ERR(...) EINA_LOG_DOM_ERR(_em_vlc_log_dom, __VA_ARGS__)
27#define DBG(...) EINA_LOG_DOM_DBG(_em_vlc_log_dom, __VA_ARGS__)
28#define INF(...) EINA_LOG_DOM_INFO(_em_vlc_log_dom, __VA_ARGS__)
29#define WRN(...) EINA_LOG_DOM_WARN(_em_vlc_log_dom, __VA_ARGS__)
30#define CRIT(...) EINA_LOG_DOM_CRIT(_em_vlc_log_dom, __VA_ARGS__)
23 31
24enum _Thread_Events { 32enum _Thread_Events {
25 EM_THREAD_POSITION_CHANGED, 33 EM_THREAD_POSITION_CHANGED,
@@ -80,8 +88,7 @@ _em_read_safe(int fd, void *buf, ssize_t size)
80 continue; 88 continue;
81 else 89 else
82 { 90 {
83 fprintf(stderr, "could not read from fd %d: %s", 91 ERR("could not read from fd %d: %s", fd, strerror(errno));
84 fd, strerror(errno));
85 return 0; 92 return 0;
86 } 93 }
87 } 94 }
@@ -117,8 +124,7 @@ _em_write_safe(int fd, const void *buf, ssize_t size)
117 continue; 124 continue;
118 else 125 else
119 { 126 {
120 fprintf(stderr, "could not write to fd %d: %s", 127 ERR("could not write to fd %d: %s", fd, strerror(errno));
121 fd, strerror(errno));
122 return 0; 128 return 0;
123 } 129 }
124 } 130 }
@@ -403,14 +409,14 @@ _file_set(struct _App *app)
403 app->m = libvlc_media_new_path(app->libvlc, app->filename); 409 app->m = libvlc_media_new_path(app->libvlc, app->filename);
404 if (!app->m) 410 if (!app->m)
405 { 411 {
406 fprintf(stderr, "could not open path: \"%s\"\n", app->filename); 412 ERR("could not open path: \"%s\"", app->filename);
407 return; 413 return;
408 } 414 }
409 415
410 app->mp = libvlc_media_player_new_from_media(app->m); 416 app->mp = libvlc_media_player_new_from_media(app->m);
411 if (!app->mp) 417 if (!app->mp)
412 { 418 {
413 fprintf(stderr, "could not create new player from media.\n"); 419 ERR("could not create new player from media.");
414 return; 420 return;
415 } 421 }
416 422
@@ -748,8 +754,8 @@ _process_thread_events(struct _App *app)
748 size = read(app->fd_read, &event, sizeof(event)); 754 size = read(app->fd_read, &event, sizeof(event));
749 if (size != sizeof(event)) 755 if (size != sizeof(event))
750 { 756 {
751 fprintf(stderr, "player: problem when reading thread event. size = %zd\n", size); 757 ERR("player: problem when reading thread event. size = %zd", size);
752 return; 758 return;
753 } 759 }
754 760
755 switch (event) { 761 switch (event) {
@@ -774,6 +780,24 @@ main(int argc, const char *argv[])
774 int tpipe[2]; // pipe for comunicating events from threads 780 int tpipe[2]; // pipe for comunicating events from threads
775 char cwidth[64], cheight[64], cpitch[64], chroma[64]; 781 char cwidth[64], cheight[64], cpitch[64], chroma[64];
776 char buf[64]; 782 char buf[64];
783
784 if (!eina_init())
785 {
786 EINA_LOG_CRIT("Can't initialize generic vlc player, eina failed.");
787 return -1;
788 }
789
790 _em_vlc_log_dom = eina_log_domain_register("emotion_generic_vlc",
791 EINA_COLOR_CYAN);
792 if (_em_vlc_log_dom < 0)
793 {
794 EINA_LOG_CRIT("Unable to register emotion_generic_vlc log domain.");
795 goto error;
796 }
797
798 if (!eina_log_domain_level_check(_em_vlc_log_dom, EINA_LOG_LEVEL_WARN))
799 eina_log_domain_level_set("emotion_generic_vlc", EINA_LOG_LEVEL_WARN);
800
777 const char *vlc_argv[] = 801 const char *vlc_argv[] =
778 { 802 {
779 "--quiet", 803 "--quiet",
@@ -791,9 +815,9 @@ main(int argc, const char *argv[])
791 815
792 if (argc < 3) 816 if (argc < 3)
793 { 817 {
794 fprintf(stderr, "player: missing paramters.\n"); 818 ERR("missing parameters.");
795 fprintf(stderr, "syntax:\n\t%s <fd read> <fd write>\n", argv[0]); 819 ERR("syntax:\n\t%s <fd read> <fd write>", argv[0]);
796 return -1; 820 goto error;
797 } 821 }
798 822
799 app.em_read = atoi(argv[1]); 823 app.em_read = atoi(argv[1]);
@@ -829,8 +853,8 @@ main(int argc, const char *argv[])
829 853
830 if (_em_cmd_read(&app) != EM_CMD_INIT) 854 if (_em_cmd_read(&app) != EM_CMD_INIT)
831 { 855 {
832 fprintf(stderr, "player: wrong init command!\n"); 856 ERR("wrong init command!");
833 return -1; 857 goto error;
834 } 858 }
835 859
836 int size; 860 int size;
@@ -859,22 +883,18 @@ main(int argc, const char *argv[])
859 continue; 883 continue;
860 else if (r < 0) 884 else if (r < 0)
861 { 885 {
862 fprintf(stderr, 886 ERR("an error ocurred on poll(): %s", strerror(errno));
863 "emotion_generic_vlc: an error ocurred on poll(): %s\n", 887 break;
864 strerror(errno));
865 break;
866 } 888 }
867 889
868 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) 890 if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))
869 { 891 {
870 fputs("emotion_generic_vlc: error communicating with stdin\n", 892 ERR("error communicating with stdin", stderr);
871 stderr);
872 break; 893 break;
873 } 894 }
874 if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL)) 895 if (fds[1].revents & (POLLERR | POLLHUP | POLLNVAL))
875 { 896 {
876 fputs("emotion_generic_vlc: error communicating with thread\n", 897 ERR("error communicating with thread", stderr);
877 stderr);
878 break; 898 break;
879 } 899 }
880 900
@@ -887,8 +907,10 @@ main(int argc, const char *argv[])
887 } 907 }
888 908
889 libvlc_release(app.libvlc); 909 libvlc_release(app.libvlc);
890
891
892 return 0; 910 return 0;
911
912 error:
913 eina_shutdown();
914 return -1;
893} 915}
894#undef SEND_CMD_PARAM 916#undef SEND_CMD_PARAM