diff src/flacng/plugin.c @ 1401:263d72004333

- Introduce a mutex for test_info and lock appropriately
author Ralf Ertzinger <ralf@skytale.net>
date Sat, 04 Aug 2007 16:30:43 +0200
parents 58ce3497879a
children 654aa79e43ef
line wrap: on
line diff
--- a/src/flacng/plugin.c	Fri Aug 03 20:39:05 2007 +0200
+++ b/src/flacng/plugin.c	Sat Aug 04 16:30:43 2007 +0200
@@ -180,8 +180,11 @@
 
     _DEBUG("Testing fd for file: %s", filename);
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _DEBUG("File not handled by this plugin!");
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -190,6 +193,7 @@
      */
     if (FALSE == test_info->metadata_changed) {
         _DEBUG("No metadata found in stream");
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -207,6 +211,7 @@
     if (MAX_SUPPORTED_CHANNELS < test_info->stream.channels) {
         _ERROR("This number of channels (%d) is currently not supported, stream not handled by this plugin",
             test_info->stream.channels);
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -215,6 +220,7 @@
         (8 != test_info->stream.bits_per_sample)) {
         _ERROR("This number of bits (%d) is currently not supported, stream not handled by this plugin",
             test_info->stream.bits_per_sample);
+        INFO_UNLOCK(test_info);
         _LEAVE FALSE;
     }
 
@@ -225,6 +231,7 @@
     _DEBUG("Accepting file %s", filename);
 
     reset_info(test_info, FALSE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE TRUE;
 }
@@ -647,11 +654,14 @@
         _LEAVE;
     }
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _ERROR("Could not read file info!");
         *length = -1;
         *title = g_strdup("");
         reset_info(test_info, TRUE);
+        INFO_UNLOCK(test_info);
         _LEAVE;
     }
 
@@ -670,6 +680,7 @@
     *title = get_title(filename, test_info);
 
     reset_info(test_info, TRUE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE;
 }
@@ -692,15 +703,19 @@
         _LEAVE NULL;
     }
 
+    INFO_LOCK(test_info);
+
     if (FALSE == read_metadata(fd, test_decoder, test_info)) {
         _ERROR("Could not read metadata tuple for file <%s>", filename);
         reset_info(test_info, TRUE);
+        INFO_UNLOCK(test_info);
         _LEAVE NULL;
     }
 
     tuple = get_tuple(filename, test_info);
 
     reset_info(test_info, TRUE);
+    INFO_UNLOCK(test_info);
 
     _LEAVE tuple;
 }