aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/previewopus_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/previewopus_extractor.c')
-rw-r--r--src/plugins/previewopus_extractor.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c
index 1f4c874..1387044 100644
--- a/src/plugins/previewopus_extractor.c
+++ b/src/plugins/previewopus_extractor.c
@@ -106,12 +106,10 @@
106#define OUTPUT_SAMPLE_FORMAT AV_SAMPLE_FMT_S16 106#define OUTPUT_SAMPLE_FORMAT AV_SAMPLE_FMT_S16
107 107
108 108
109/** 109/** Our output buffer*/
110 * Global handle to MAGIC data.
111 */
112static magic_t magic;
113
114static unsigned char *buffer; 110static unsigned char *buffer;
111
112/** Actual output buffer size */
115static int totalSize; 113static int totalSize;
116 114
117/** 115/**
@@ -987,7 +985,6 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
987 frame_finished = 0; 985 frame_finished = 0;
988 986
989 987
990
991 /** 988 /**
992 * Loop as long as we have input samples to read or output samples 989 * Loop as long as we have input samples to read or output samples
993 * to write; abort as soon as we have neither. 990 * to write; abort as soon as we have neither.
@@ -1126,14 +1123,13 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec)
1126 unsigned int i; 1123 unsigned int i;
1127 ssize_t iret; 1124 ssize_t iret;
1128 void *data; 1125 void *data;
1129 const char *mime; 1126
1130 1127
1131 if (-1 == (iret = ec->read (ec->cls, 1128 if (-1 == (iret = ec->read (ec->cls,
1132 &data, 1129 &data,
1133 16 * 1024))) 1130 16 * 1024)))
1134 return; 1131 return;
1135 if (NULL == (mime = magic_buffer (magic, data, iret))) 1132
1136 return;
1137 if (0 != ec->seek (ec->cls, 0, SEEK_SET)) 1133 if (0 != ec->seek (ec->cls, 0, SEEK_SET))
1138 return; 1134 return;
1139 1135
@@ -1163,18 +1159,14 @@ previewopus_av_log_callback (void* ptr,
1163 1159
1164 1160
1165/** 1161/**
1166 * Initialize av-libs and load magic file. 1162 * Initialize av-libs
1167 */ 1163 */
1168void __attribute__ ((constructor)) 1164void __attribute__ ((constructor))
1169previewopus_lib_init (void) 1165previewopus_lib_init (void)
1170{ 1166{
1171 av_log_set_callback (&previewopus_av_log_callback); 1167 av_log_set_callback (&previewopus_av_log_callback);
1172 av_register_all (); 1168 av_register_all ();
1173 magic = magic_open (MAGIC_MIME_TYPE); 1169
1174 if (0 != magic_load (magic, NULL))
1175 {
1176 /* FIXME: how to deal with errors? */
1177 }
1178} 1170}
1179 1171
1180 1172
@@ -1184,11 +1176,7 @@ previewopus_lib_init (void)
1184void __attribute__ ((destructor)) 1176void __attribute__ ((destructor))
1185previewopus_ltdl_fini () 1177previewopus_ltdl_fini ()
1186{ 1178{
1187 if (NULL != magic) 1179
1188 {
1189 magic_close (magic);
1190 magic = NULL;
1191 }
1192} 1180}
1193 1181
1194 1182