This prevents multiple threads from racing in creation of a missing fish.
#define BABL_HARD_MAX_PATH_LENGTH 8
#define BABL_MAX_NAME_LEN 1024
-#define BABL_TEST_ITER 4
+#define BABL_TEST_ITER 16
#ifndef MIN
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#endif
-#define NUM_TEST_PIXELS (babl_get_num_path_test_pixels ())
#define MAX_BUFFER_SIZE 512
-
+#define ITERATIONS 4
int babl_in_fish_path = 0;
max_path_length () + 2 <= BABL_HARD_MAX_PATH_LENGTH)
{
get_conversion_path (&pc, (Babl *) source, 0, max_path_length () + 2, tolerance);
-#if 0
+#if 1
if (babl->fish_path.conversion_list->count)
{
fprintf (stderr, "babl is using very long chain, should be optimized\n");
babl_list_each (babl->fish_path.conversion_list, show_item, NULL);
}
+ else
+ {
+ fprintf (stderr, "babl is lacking conversion for %s to %s\n",
+ babl_get_name (source), babl_get_name (destination));
+ }
#endif
}
return ffish.fish_path;
}
+ babl_mutex_lock (babl_fish_mutex);
+ /* do a second look in the database, in case another thread held the
+ mutex and made the fish
+ */
+ if (!ffish.fish_fish)
+ {
+ babl_hash_table_find (id_htable, hashval, find_fish_path, (void *) &ffish);
+ if (ffish.fish_path)
+ {
+ /* we have found suitable fish path in the database */
+ babl_mutex_unlock (babl_fish_mutex);
+ return ffish.fish_path;
+ }
+ }
+
if (!ffish.fish_fish)
{
const Babl *src_space = (void*)source_format->format.space;
if (fish_path)
{
+ babl_mutex_unlock (babl_fish_mutex);
return fish_path;
}
#if 1
if (ffish.fish_ref)
{
/* we have already found suitable reference fish */
+ babl_mutex_unlock (babl_fish_mutex);
return ffish.fish_ref;
}
else
{
/* we have to create new reference fish */
- return babl_fish_reference (source_format, destination_format);
+ Babl *ret = babl_fish_reference (source_format, destination_format);
+ babl_mutex_unlock (babl_fish_mutex);
+ return ret;
}
}
}
exit (-1);
}
+BablMutex *babl_fish_mutex;
BablMutex *babl_format_mutex;
#if BABL_DEBUG_MEM
{
babl_set_malloc (malloc);
babl_set_free (free);
+ babl_fish_mutex = babl_mutex_new ();
babl_format_mutex = babl_mutex_new ();
babl_reference_mutex = babl_mutex_new ();
#if BABL_DEBUG_MEM
void
babl_internal_destroy (void)
{
+ babl_mutex_destroy (babl_fish_mutex);
babl_mutex_destroy (babl_format_mutex);
babl_mutex_destroy (babl_reference_mutex);
#if BABL_DEBUG_MEM
extern int babl_hmpf_on_name_lookups;
extern int babl_in_fish_path;
extern BablMutex *babl_format_mutex;
+extern BablMutex *babl_fish_mutex;
extern BablMutex *babl_reference_mutex;
#define BABL_DEBUG_MEM 0