Changeset 618ebd5
- Timestamp:
- Mar 12, 2017, 2:30:48 PM (8 years ago)
- Branches:
- sampler
- Children:
- 8b07fa9
- Parents:
- 91ad284
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/io/source_avcodec.c
r91ad284 r618ebd5 53 53 54 54 #define AUBIO_AVCODEC_MAX_BUFFER_SIZE FF_MIN_BUFFER_SIZE 55 56 #ifdef HAVE_PTHREAD_H 57 // Global mutex to make sure avcodec_open2 is not called simultaneously in a 58 // multithreaded environment. Comment the following define if no lock required. 59 #define HAVE_AUBIO_AVCODEC_MUTEX 60 #include <pthread.h> 61 pthread_mutex_t aubio_avcodec_mutex = PTHREAD_MUTEX_INITIALIZER; 62 #endif /* HAVE_PTHREAD_H */ 55 63 56 64 struct _aubio_source_avcodec_t { … … 122 130 strncpy(s->path, path, strnlen(path, PATH_MAX) + 1); 123 131 132 #ifdef HAVE_AUBIO_AVCODEC_MUTEX 133 pthread_mutex_lock(&aubio_avcodec_mutex); 134 #endif /* HAVE_AUBIO_AVCODEC_MUTEX */ 135 124 136 // register all formats and codecs 125 137 av_register_all(); … … 231 243 } 232 244 245 #ifdef HAVE_AUBIO_AVCODEC_MUTEX 246 pthread_mutex_unlock(&aubio_avcodec_mutex); 247 #endif /* HAVE_AUBIO_AVCODEC_MUTEX */ 248 233 249 /* get input specs */ 234 250 s->input_samplerate = avCodecCtx->sample_rate; … … 280 296 //AUBIO_ERR("can not read %s at samplerate %dHz with a hop_size of %d\n", 281 297 // s->path, s->samplerate, s->hop_size); 298 #ifdef HAVE_AUBIO_AVCODEC_MUTEX 299 pthread_mutex_unlock(&aubio_avcodec_mutex); 300 #endif /* HAVE_AUBIO_AVCODEC_MUTEX */ 282 301 del_aubio_source_avcodec(s); 283 302 return NULL;
Note: See TracChangeset
for help on using the changeset viewer.