static void benchmark_plugin (SquashPlugin* plugin, void* data) { /* Since we're often running against the source dir, we will pick up plugins which have not been compiled. This should bail us out before trying to actually use them. */ if (squash_plugin_init (plugin) != SQUASH_OK) { return; } squash_plugin_foreach_codec (plugin, benchmark_codec, data); }
/** * @brief Initialize a codec * @private * * @param plugin The plugin. * @param codec The codec to initialize. * @param impl The function table to fill. * @returns A status code. */ SquashStatus squash_plugin_init_codec (SquashPlugin* plugin, SquashCodec* codec, SquashCodecImpl* impl) { SquashStatus res = SQUASH_OK; assert (plugin != NULL); if (plugin->plugin == NULL) { res = squash_plugin_init (plugin); if (res != SQUASH_OK) { return res; } } if (codec->initialized == 0) { SquashStatus (*init_codec_func) (SquashCodec*, SquashCodecImpl*); #if !defined(_WIN32) *(void **) (&init_codec_func) = dlsym (plugin->plugin, "squash_plugin_init_codec"); #else *(void **) (&init_codec_func) = GetProcAddress (plugin->plugin, "squash_plugin_init_codec"); #endif if (SQUASH_UNLIKELY(init_codec_func == NULL)) { return squash_error (SQUASH_UNABLE_TO_LOAD); } SQUASH_MTX_LOCK(codec_init); if (SQUASH_LIKELY(codec->initialized == 0)) { res = init_codec_func (codec, impl); codec->initialized = (res == SQUASH_OK); assert ((codec->impl.info & SQUASH_CODEC_INFO_AUTO_MASK) == 0); if (codec->impl.process_stream != NULL) codec->impl.info |= (SquashCodecInfo) SQUASH_CODEC_INFO_NATIVE_STREAMING; if (codec->impl.get_uncompressed_size != NULL || (codec->impl.info & SQUASH_CODEC_INFO_WRAP_SIZE)) codec->impl.info |= (SquashCodecInfo) SQUASH_CODEC_INFO_KNOWS_UNCOMPRESSED_SIZE; } SQUASH_MTX_UNLOCK(codec_init); } return res; }