summaryrefslogtreecommitdiff
path: root/src/modules/emotion/libvlc
diff options
context:
space:
mode:
authorThomas Guillem <thomas@gllm.fr>2016-03-25 09:05:39 +0100
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-28 16:40:02 +0900
commitb12c2a2cfd6850d695c76f96827e1e110be4038a (patch)
treee2813582c1dc1a225f72248fa8d74e53ca841106 /src/modules/emotion/libvlc
parenta6bd5dda420520a509fc1cee26e131a13401348f (diff)
emotion/libvlc: replace libvlc_mp_is_ready with ev->started
Diffstat (limited to 'src/modules/emotion/libvlc')
-rw-r--r--src/modules/emotion/libvlc/emotion_libvlc.c83
1 files changed, 36 insertions, 47 deletions
diff --git a/src/modules/emotion/libvlc/emotion_libvlc.c b/src/modules/emotion/libvlc/emotion_libvlc.c
index 98f6fdfe67..d9500cdfab 100644
--- a/src/modules/emotion/libvlc/emotion_libvlc.c
+++ b/src/modules/emotion/libvlc/emotion_libvlc.c
@@ -283,17 +283,6 @@ evas_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
283 eo_event_callback_call(ev->obj, EMOTION_OBJECT_EVENT_FRAME_DECODE, NULL); 283 eo_event_callback_call(ev->obj, EMOTION_OBJECT_EVENT_FRAME_DECODE, NULL);
284} 284}
285 285
286/* Returns true if libvlc mediaplayer is ready to process commands. */
287static Eina_Bool
288libvlc_mp_is_ready(Emotion_LibVLC *ev)
289{
290 libvlc_state_t state;
291
292 if (!ev->mp) return EINA_FALSE;
293 state = libvlc_media_player_get_state(ev->mp);
294 return state == libvlc_Playing || state == libvlc_Paused;
295}
296
297/* Fetch all libvlc tracks. */ 286/* Fetch all libvlc tracks. */
298static int 287static int
299libvlc_fetch_tracks(Emotion_LibVLC *ev) 288libvlc_fetch_tracks(Emotion_LibVLC *ev)
@@ -619,7 +608,7 @@ em_size_get(void *video,
619 *width = 0; 608 *width = 0;
620 *height = 0; 609 *height = 0;
621 610
622 if (!libvlc_mp_is_ready(ev)) return; 611 if (!ev->started) return;
623 612
624 track = libvlc_get_current_video_track(ev); 613 track = libvlc_get_current_video_track(ev);
625 if (track) 614 if (track)
@@ -634,7 +623,7 @@ em_pos_get(void *video)
634{ 623{
635 Emotion_LibVLC *ev = video; 624 Emotion_LibVLC *ev = video;
636 625
637 if (!libvlc_mp_is_ready(ev)) return 0.0; 626 if (!ev->started) return 0.0;
638 627
639 return ev->pos; 628 return ev->pos;
640} 629}
@@ -645,7 +634,7 @@ em_pos_set(void *video,
645{ 634{
646 Emotion_LibVLC *ev = video; 635 Emotion_LibVLC *ev = video;
647 636
648 if (!libvlc_mp_is_ready(ev)) 637 if (!ev->started)
649 { 638 {
650 _emotion_seek_done(ev->obj); 639 _emotion_seek_done(ev->obj);
651 return; 640 return;
@@ -661,7 +650,7 @@ em_len_get(void *video)
661{ 650{
662 Emotion_LibVLC *ev = video; 651 Emotion_LibVLC *ev = video;
663 652
664 if (!libvlc_mp_is_ready(ev)) return 0.0; 653 if (!ev->started) return 0.0;
665 654
666 return ev->len; 655 return ev->len;
667} 656}
@@ -671,7 +660,7 @@ em_buffer_size_get(void *video)
671{ 660{
672 Emotion_LibVLC *ev = video; 661 Emotion_LibVLC *ev = video;
673 662
674 if (!libvlc_mp_is_ready(ev)) return 0.0; 663 if (!ev->started) return 0.0;
675 664
676 return ev->buffer_cache; 665 return ev->buffer_cache;
677} 666}
@@ -681,7 +670,7 @@ em_fps_num_den_get(Emotion_LibVLC *ev, int *num, int *den)
681{ 670{
682 libvlc_media_track_t *track; 671 libvlc_media_track_t *track;
683 672
684 if (!libvlc_mp_is_ready(ev)) return; 673 if (!ev->started) return;
685 674
686 track = libvlc_get_current_video_track(ev); 675 track = libvlc_get_current_video_track(ev);
687 if (track) 676 if (track)
@@ -753,7 +742,7 @@ em_ratio_get(void *video)
753 Emotion_LibVLC *ev = video; 742 Emotion_LibVLC *ev = video;
754 libvlc_media_track_t *track; 743 libvlc_media_track_t *track;
755 744
756 if (!libvlc_mp_is_ready(ev)) return 0.0; 745 if (!ev->started) return 0.0;
757 746
758 track = libvlc_get_current_video_track(ev); 747 track = libvlc_get_current_video_track(ev);
759 if (track) 748 if (track)
@@ -771,7 +760,7 @@ em_video_handled(void *video)
771{ 760{
772 Emotion_LibVLC *ev = video; 761 Emotion_LibVLC *ev = video;
773 762
774 if (!libvlc_mp_is_ready(ev)) return 0.0; 763 if (!ev->started) return 0.0;
775 764
776 return libvlc_video_get_track_count(ev->mp) > 0; 765 return libvlc_video_get_track_count(ev->mp) > 0;
777} 766}
@@ -781,7 +770,7 @@ em_audio_handled(void *video)
781{ 770{
782 Emotion_LibVLC *ev = video; 771 Emotion_LibVLC *ev = video;
783 772
784 if (!libvlc_mp_is_ready(ev)) return 0.0; 773 if (!ev->started) return 0.0;
785 774
786 return libvlc_audio_get_track_count(ev->mp) > 0; 775 return libvlc_audio_get_track_count(ev->mp) > 0;
787} 776}
@@ -791,7 +780,7 @@ em_seekable(void *video)
791{ 780{
792 Emotion_LibVLC *ev = video; 781 Emotion_LibVLC *ev = video;
793 782
794 if (!libvlc_mp_is_ready(ev)) return 0; 783 if (!ev->started) return 0;
795 784
796 return libvlc_media_player_is_seekable(ev->mp); 785 return libvlc_media_player_is_seekable(ev->mp);
797} 786}
@@ -835,7 +824,7 @@ em_event_feed(void *video, int event)
835 Emotion_LibVLC *ev = video; 824 Emotion_LibVLC *ev = video;
836 unsigned int navigate; 825 unsigned int navigate;
837 826
838 if (!libvlc_mp_is_ready(ev)) return; 827 if (!ev->started) return;
839 828
840 switch (event) 829 switch (event)
841 { 830 {
@@ -906,7 +895,7 @@ em_video_channel_count(void *video)
906{ 895{
907 Emotion_LibVLC *ev = video; 896 Emotion_LibVLC *ev = video;
908 897
909 if (!libvlc_mp_is_ready(ev)) return -1; 898 if (!ev->started) return -1;
910 899
911 return libvlc_video_get_track_count(ev->mp); 900 return libvlc_video_get_track_count(ev->mp);
912} 901}
@@ -917,7 +906,7 @@ em_video_channel_set(void *video,
917{ 906{
918 Emotion_LibVLC *ev = video; 907 Emotion_LibVLC *ev = video;
919 908
920 if (!libvlc_mp_is_ready(ev)) return; 909 if (!ev->started) return;
921 910
922 if (channel < 0) 911 if (channel < 0)
923 libvlc_video_set_track(ev->mp, -1); 912 libvlc_video_set_track(ev->mp, -1);
@@ -936,7 +925,7 @@ em_video_channel_get(void *video)
936 Emotion_LibVLC *ev = video; 925 Emotion_LibVLC *ev = video;
937 int id; 926 int id;
938 927
939 if (!libvlc_mp_is_ready(ev)) return -1; 928 if (!ev->started) return -1;
940 929
941 id = libvlc_video_get_track(ev->mp); 930 id = libvlc_video_get_track(ev->mp);
942 931
@@ -949,7 +938,7 @@ em_video_subtitle_file_set(void *video,
949{ 938{
950 Emotion_LibVLC *ev = video; 939 Emotion_LibVLC *ev = video;
951 940
952 if (!libvlc_mp_is_ready(ev)) return; 941 if (!ev->started) return;
953 942
954 free(ev->subtitle_file); 943 free(ev->subtitle_file);
955 ev->subtitle_file = filepath ? strdup(filepath) : NULL; 944 ev->subtitle_file = filepath ? strdup(filepath) : NULL;
@@ -971,7 +960,7 @@ em_video_channel_name_get(void *video,
971 Emotion_LibVLC *ev = video; 960 Emotion_LibVLC *ev = video;
972 libvlc_media_track_t *track; 961 libvlc_media_track_t *track;
973 962
974 if (!libvlc_mp_is_ready(ev)) return NULL; 963 if (!ev->started) return NULL;
975 964
976 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_video); 965 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_video);
977 if (track) 966 if (track)
@@ -990,7 +979,7 @@ em_video_channel_mute_set(void *video,
990 return; 979 return;
991 ev->video_mute = mute; 980 ev->video_mute = mute;
992 981
993 if (libvlc_mp_is_ready(ev)) 982 if (ev->started)
994 em_video_channel_set(video, mute ? -1 : 0); 983 em_video_channel_set(video, mute ? -1 : 0);
995} 984}
996 985
@@ -1014,7 +1003,7 @@ em_audio_channel_count(void *video)
1014{ 1003{
1015 Emotion_LibVLC *ev = video; 1004 Emotion_LibVLC *ev = video;
1016 1005
1017 if (!libvlc_mp_is_ready(ev)) return -1; 1006 if (!ev->started) return -1;
1018 1007
1019 return em_channel_count(libvlc_audio_get_track_count(ev->mp)); 1008 return em_channel_count(libvlc_audio_get_track_count(ev->mp));
1020} 1009}
@@ -1025,7 +1014,7 @@ em_audio_channel_set(void *video,
1025{ 1014{
1026 Emotion_LibVLC *ev = video; 1015 Emotion_LibVLC *ev = video;
1027 1016
1028 if (!libvlc_mp_is_ready(ev)) return; 1017 if (!ev->started) return;
1029 1018
1030 if (channel < 0) 1019 if (channel < 0)
1031 libvlc_audio_set_track(ev->mp, -1); 1020 libvlc_audio_set_track(ev->mp, -1);
@@ -1044,7 +1033,7 @@ em_audio_channel_get(void *video)
1044 Emotion_LibVLC *ev = video; 1033 Emotion_LibVLC *ev = video;
1045 int id; 1034 int id;
1046 1035
1047 if (!libvlc_mp_is_ready(ev)) return -1; 1036 if (!ev->started) return -1;
1048 1037
1049 id = libvlc_audio_get_track(ev->mp); 1038 id = libvlc_audio_get_track(ev->mp);
1050 1039
@@ -1058,7 +1047,7 @@ em_audio_channel_name_get(void *video,
1058 Emotion_LibVLC *ev = video; 1047 Emotion_LibVLC *ev = video;
1059 libvlc_media_track_t *track; 1048 libvlc_media_track_t *track;
1060 1049
1061 if (!libvlc_mp_is_ready(ev)) return NULL; 1050 if (!ev->started) return NULL;
1062 1051
1063 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_audio); 1052 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_audio);
1064 if (track) 1053 if (track)
@@ -1075,7 +1064,7 @@ em_audio_channel_mute_set(void *video,
1075 1064
1076 ev->audio_mute = mute; 1065 ev->audio_mute = mute;
1077 1066
1078 if (libvlc_mp_is_ready(ev)) 1067 if (ev->started)
1079 em_audio_channel_set(video, mute ? -1 : 0); 1068 em_audio_channel_set(video, mute ? -1 : 0);
1080} 1069}
1081 1070
@@ -1099,7 +1088,7 @@ em_audio_channel_volume_set(void *video,
1099 vol = 1.0; 1088 vol = 1.0;
1100 ev->audio_vol = vol * 100; 1089 ev->audio_vol = vol * 100;
1101 1090
1102 if (!libvlc_mp_is_ready(ev)) return; 1091 if (!ev->started) return;
1103 1092
1104 libvlc_audio_set_volume(ev->mp, ev->audio_vol); 1093 libvlc_audio_set_volume(ev->mp, ev->audio_vol);
1105} 1094}
@@ -1109,7 +1098,7 @@ em_audio_channel_volume_get(void *video)
1109{ 1098{
1110 Emotion_LibVLC *ev = video; 1099 Emotion_LibVLC *ev = video;
1111 1100
1112 if (!libvlc_mp_is_ready(ev)) 1101 if (!ev->started)
1113 return ev->audio_vol / 100.0; 1102 return ev->audio_vol / 100.0;
1114 1103
1115 return libvlc_audio_get_volume(ev->mp) / 100.0; 1104 return libvlc_audio_get_volume(ev->mp) / 100.0;
@@ -1120,7 +1109,7 @@ em_spu_channel_count(void *video)
1120{ 1109{
1121 Emotion_LibVLC *ev = video; 1110 Emotion_LibVLC *ev = video;
1122 1111
1123 if (!libvlc_mp_is_ready(ev)) return -1; 1112 if (!ev->started) return -1;
1124 1113
1125 return em_channel_count(libvlc_video_get_spu_count(ev->mp)); 1114 return em_channel_count(libvlc_video_get_spu_count(ev->mp));
1126} 1115}
@@ -1131,7 +1120,7 @@ em_spu_channel_set(void *video,
1131{ 1120{
1132 Emotion_LibVLC *ev = video; 1121 Emotion_LibVLC *ev = video;
1133 1122
1134 if (!libvlc_mp_is_ready(ev)) return; 1123 if (!ev->started) return;
1135 1124
1136 if (channel < 0) 1125 if (channel < 0)
1137 libvlc_video_set_spu(ev->mp, -1); 1126 libvlc_video_set_spu(ev->mp, -1);
@@ -1150,7 +1139,7 @@ em_spu_channel_get(void *video)
1150 Emotion_LibVLC *ev = video; 1139 Emotion_LibVLC *ev = video;
1151 int id; 1140 int id;
1152 1141
1153 if (!libvlc_mp_is_ready(ev)) return -1; 1142 if (!ev->started) return -1;
1154 1143
1155 id = libvlc_video_get_spu(ev->mp); 1144 id = libvlc_video_get_spu(ev->mp);
1156 1145
@@ -1164,7 +1153,7 @@ em_spu_channel_name_get(void *video,
1164 Emotion_LibVLC *ev = video; 1153 Emotion_LibVLC *ev = video;
1165 libvlc_media_track_t *track; 1154 libvlc_media_track_t *track;
1166 1155
1167 if (!libvlc_mp_is_ready(ev)) return NULL; 1156 if (!ev->started) return NULL;
1168 1157
1169 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_text); 1158 track = libvlc_get_track_at_pos(ev, channel, libvlc_track_text);
1170 if (track) 1159 if (track)
@@ -1180,7 +1169,7 @@ em_spu_channel_mute_set(void *video, int mute)
1180 1169
1181 ev->spu_mute = mute; 1170 ev->spu_mute = mute;
1182 1171
1183 if (libvlc_mp_is_ready(ev)) 1172 if (ev->started)
1184 em_spu_channel_set(video, mute ? -1 : 0); 1173 em_spu_channel_set(video, mute ? -1 : 0);
1185} 1174}
1186 1175
@@ -1197,7 +1186,7 @@ em_chapter_count(void *video)
1197{ 1186{
1198 Emotion_LibVLC *ev = video; 1187 Emotion_LibVLC *ev = video;
1199 1188
1200 if (!libvlc_mp_is_ready(ev)) return 0; 1189 if (!ev->started) return 0;
1201 1190
1202 return libvlc_media_player_get_chapter_count(ev->mp); 1191 return libvlc_media_player_get_chapter_count(ev->mp);
1203} 1192}
@@ -1207,7 +1196,7 @@ em_chapter_set(void *video, int chapter)
1207{ 1196{
1208 Emotion_LibVLC *ev = video; 1197 Emotion_LibVLC *ev = video;
1209 1198
1210 if (!libvlc_mp_is_ready(ev)) return; 1199 if (!ev->started) return;
1211 1200
1212 libvlc_media_player_set_chapter(ev->mp, chapter); 1201 libvlc_media_player_set_chapter(ev->mp, chapter);
1213} 1202}
@@ -1217,7 +1206,7 @@ em_chapter_get(void *video)
1217{ 1206{
1218 Emotion_LibVLC *ev = video; 1207 Emotion_LibVLC *ev = video;
1219 1208
1220 if (!libvlc_mp_is_ready(ev)) return 0; 1209 if (!ev->started) return 0;
1221 1210
1222 return libvlc_media_player_get_chapter(ev->mp); 1211 return libvlc_media_player_get_chapter(ev->mp);
1223} 1212}
@@ -1227,7 +1216,7 @@ em_chapter_name_get(void *video, int chapter)
1227{ 1216{
1228 Emotion_LibVLC *ev = video; 1217 Emotion_LibVLC *ev = video;
1229 1218
1230 if (!libvlc_mp_is_ready(ev)) return NULL; 1219 if (!ev->started) return NULL;
1231 1220
1232 if (ev->nb_chapters == 0) 1221 if (ev->nb_chapters == 0)
1233 { 1222 {
@@ -1246,7 +1235,7 @@ em_speed_set(void *video, double speed)
1246{ 1235{
1247 Emotion_LibVLC *ev = video; 1236 Emotion_LibVLC *ev = video;
1248 1237
1249 if (!libvlc_mp_is_ready(ev)) return; 1238 if (!ev->started) return;
1250 1239
1251 libvlc_media_player_set_rate(ev->mp, speed); 1240 libvlc_media_player_set_rate(ev->mp, speed);
1252} 1241}
@@ -1256,7 +1245,7 @@ em_speed_get(void *video)
1256{ 1245{
1257 Emotion_LibVLC *ev = video; 1246 Emotion_LibVLC *ev = video;
1258 1247
1259 if (!libvlc_mp_is_ready(ev)) return 1.0; 1248 if (!ev->started) return 1.0;
1260 1249
1261 return libvlc_media_player_get_rate(ev->mp); 1250 return libvlc_media_player_get_rate(ev->mp);
1262} 1251}
@@ -1272,7 +1261,7 @@ em_meta_get(void *video, int meta)
1272{ 1261{
1273 Emotion_LibVLC *ev = video; 1262 Emotion_LibVLC *ev = video;
1274 1263
1275 if (!libvlc_mp_is_ready(ev)) return NULL; 1264 if (!ev->started) return NULL;
1276 1265
1277 if (meta <= 0 || meta >= META_TRACK_COUNT) 1266 if (meta <= 0 || meta >= META_TRACK_COUNT)
1278 return NULL; 1267 return NULL;