diff options
author | Ewald Snel <esnel@users.sourceforge.net> | 2002-04-28 15:32:41 +0000 |
---|---|---|
committer | Ewald Snel <esnel@users.sourceforge.net> | 2002-04-28 15:32:41 +0000 |
commit | 2f8c9ba5832fccd79bc950a66ab7f08f0d037d80 (patch) | |
tree | 0c5e301948d784d53c481eae043b9b186ad074e1 | |
parent | 03ec99979c521861738b769f70bbe9ae3dacb2d7 (diff) | |
download | xine-lib-2f8c9ba5832fccd79bc950a66ab7f08f0d037d80.tar.gz xine-lib-2f8c9ba5832fccd79bc950a66ab7f08f0d037d80.tar.bz2 |
Thread-safe once-only initialization
CVS patchset: 1796
CVS date: 2002/04/28 15:32:41
-rw-r--r-- | src/libw32dll/w32codec.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c index 9e320c723..0940bb6bd 100644 --- a/src/libw32dll/w32codec.c +++ b/src/libw32dll/w32codec.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: w32codec.c,v 1.75 2002/04/23 15:45:25 esnel Exp $ + * $Id: w32codec.c,v 1.76 2002/04/28 15:32:41 esnel Exp $ * * routines for using w32 codecs * DirectShow support by Miguel Freitas (Nov/2001) @@ -85,7 +85,8 @@ static GUID dvsd_clsid = /* some data is shared inside wine loader. * this mutex seems to avoid some segfaults */ -pthread_mutex_t win32_codec_mutex; +static pthread_mutex_t win32_codec_mutex; +static pthread_once_t once_control = PTHREAD_ONCE_INIT; extern char* win32_codec_name; extern char* win32_def_path; @@ -417,8 +418,6 @@ static void w32v_init_codec (w32v_decoder_t *this, int buf_type) { uint32_t vo_cap; int outfmt; - w32v_init_rgb_ycc(); - #ifdef LOG printf ("w32codec: init codec...\n"); #endif @@ -521,8 +520,6 @@ static void w32v_init_ds_codec (w32v_decoder_t *this, int buf_type) { uint32_t vo_cap; int outfmt; - w32v_init_rgb_ycc(); - printf ("w32codec: init Direct Show video codec...\n"); memset(&this->o_bih, 0, sizeof(BITMAPINFOHEADER)); @@ -1319,6 +1316,11 @@ static char *w32a_get_id(void) { return "vfw (win32) audio decoder"; } +static void init_routine(void) { + pthread_mutex_init (&win32_codec_mutex, NULL); + w32v_init_rgb_ycc(); +} + video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { w32v_decoder_t *this ; @@ -1350,7 +1352,7 @@ video_decoder_t *init_video_decoder_plugin (int iface_version, xine_t *xine) { this->video_decoder.dispose = w32v_dispose; this->video_decoder.priority = 1; - pthread_mutex_init (&win32_codec_mutex, NULL); + pthread_once (&once_control, init_routine); this->prof_rgb2yuv = xine_profiler_allocate_slot ("w32codec rgb2yuv convert"); @@ -1396,7 +1398,7 @@ audio_decoder_t *init_audio_decoder_plugin (int iface_version, xine_t *xine) { this->audio_decoder.dispose = w32a_dispose; this->audio_decoder.priority = 1; - pthread_mutex_init (&win32_codec_mutex, NULL); + pthread_once (&once_control, init_routine); #ifdef SYNC_SHUTDOWN w32a_instance = NULL; |