void ff_tls_init(void) { avpriv_lock_avformat(); #if CONFIG_OPENSSL if (!openssl_init) { SSL_library_init(); SSL_load_error_strings(); #if HAVE_THREADS if (!CRYPTO_get_locking_callback()) { int i; openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks()); for (i = 0; i < CRYPTO_num_locks(); i++) pthread_mutex_init(&openssl_mutexes[i], NULL); CRYPTO_set_locking_callback(openssl_lock); #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000 CRYPTO_set_id_callback(openssl_thread_id); #endif } #endif } openssl_init++; #endif #if CONFIG_GNUTLS #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif gnutls_global_init(); #endif avpriv_unlock_avformat(); }
static av_cold int avisynth_read_close(AVFormatContext *s) { if (avpriv_lock_avformat()) return AVERROR_UNKNOWN; avisynth_context_destroy(s->priv_data); avpriv_unlock_avformat(); return 0; }
static void cleanup(ChromaprintMuxContext *cpr) { if (cpr->ctx) { avpriv_lock_avformat(); chromaprint_free(cpr->ctx); avpriv_unlock_avformat(); } }
void ff_gnutls_init(void) { avpriv_lock_avformat(); #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif gnutls_global_init(); avpriv_unlock_avformat(); }
static int write_header(AVFormatContext *s) { ChromaprintMuxContext *cpr = s->priv_data; AVStream *st; avpriv_lock_avformat(); cpr->ctx = chromaprint_new(cpr->algorithm); avpriv_unlock_avformat(); if (!cpr->ctx) { av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n"); return AVERROR(ENOMEM); } if (cpr->silence_threshold != -1) { #if CPR_VERSION_INT >= AV_VERSION_INT(0, 7, 0) if (!chromaprint_set_option(cpr->ctx, "silence_threshold", cpr->silence_threshold)) { av_log(s, AV_LOG_ERROR, "Failed to set silence threshold.\n"); goto fail; } #else av_log(s, AV_LOG_ERROR, "Setting the silence threshold requires Chromaprint " "version 0.7.0 or later.\n"); goto fail; #endif } if (s->nb_streams != 1) { av_log(s, AV_LOG_ERROR, "Only one stream is supported\n"); goto fail; } st = s->streams[0]; if (st->codecpar->channels > 2) { av_log(s, AV_LOG_ERROR, "Only up to 2 channels are supported\n"); goto fail; } if (st->codecpar->sample_rate < 1000) { av_log(s, AV_LOG_ERROR, "Sampling rate must be at least 1000\n"); goto fail; } if (!chromaprint_start(cpr->ctx, st->codecpar->sample_rate, st->codecpar->channels)) { av_log(s, AV_LOG_ERROR, "Failed to start chromaprint\n"); goto fail; } return 0; fail: cleanup(cpr); return AVERROR(EINVAL); }
static av_cold int avisynth_read_header(AVFormatContext *s) { int ret; // Calling library must implement a lock for thread-safe opens. if (ret = avpriv_lock_avformat()) return ret; if (ret = avisynth_open_file(s)) { avpriv_unlock_avformat(); return ret; } avpriv_unlock_avformat(); return 0; }
void ff_openssl_deinit(void) { avpriv_lock_avformat(); openssl_init--; if (!openssl_init) { #if HAVE_THREADS if (CRYPTO_get_locking_callback() == openssl_lock) { int i; CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) pthread_mutex_destroy(&openssl_mutexes[i]); av_free(openssl_mutexes); } #endif } avpriv_unlock_avformat(); }
void ff_tls_deinit(void) { avpriv_lock_avformat(); #if CONFIG_OPENSSL openssl_init--; if (!openssl_init) { #if HAVE_THREADS if (CRYPTO_get_locking_callback() == openssl_lock) { int i; CRYPTO_set_locking_callback(NULL); for (i = 0; i < CRYPTO_num_locks(); i++) pthread_mutex_destroy(&openssl_mutexes[i]); av_free(openssl_mutexes); } #endif } #endif #if CONFIG_GNUTLS gnutls_global_deinit(); #endif avpriv_unlock_avformat(); }
void ff_openssl_init(void) { avpriv_lock_avformat(); if (!openssl_init) { SSL_library_init(); SSL_load_error_strings(); #if HAVE_THREADS if (!CRYPTO_get_locking_callback()) { int i; openssl_mutexes = av_malloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks()); for (i = 0; i < CRYPTO_num_locks(); i++) pthread_mutex_init(&openssl_mutexes[i], NULL); CRYPTO_set_locking_callback(openssl_lock); #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000 CRYPTO_set_id_callback(openssl_thread_id); #endif } #endif } openssl_init++; avpriv_unlock_avformat(); }
void ff_gnutls_deinit(void) { avpriv_lock_avformat(); gnutls_global_deinit(); avpriv_unlock_avformat(); }