diff options
| author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2009-03-16 15:05:19 +0000 |
|---|---|---|
| committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2009-03-16 15:05:19 +0000 |
| commit | f62eed3209aab6fc642e66b18cc71d526517aadb (patch) | |
| tree | 4b56b352759d4de7196a6ce564cf2ff88dfd08b2 /src/xine-engine | |
| parent | d8a50c1e20367be95911533c62637c23b809b916 (diff) | |
| parent | c3580b925a6c33105ee483d3c616a16f8ce0bba9 (diff) | |
| download | xine-lib-f62eed3209aab6fc642e66b18cc71d526517aadb.tar.gz xine-lib-f62eed3209aab6fc642e66b18cc71d526517aadb.tar.bz2 | |
Merge from 1.1.
--HG--
rename : src/libmpeg2new/Makefile.am => src/video_dec/libmpeg2new/Makefile.am
rename : src/libmpeg2new/libmpeg2/Makefile.am => src/video_dec/libmpeg2new/libmpeg2/Makefile.am
Diffstat (limited to 'src/xine-engine')
| -rw-r--r-- | src/xine-engine/audio_out.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 348431114..2f29f92ea 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -219,6 +219,7 @@ typedef struct { int num_driver_actions; /* number of threads, that wish to call * functions needing driver_lock */ pthread_mutex_t driver_action_lock; /* protects num_driver_actions */ + pthread_cond_t driver_action_cond; /* informs about num_driver_actions-- */ metronom_clock_t *clock; xine_t *xine; @@ -1285,8 +1286,15 @@ static void *ao_loop (void *this_gen) { /* Give other threads a chance to use functions which require this->driver_lock to * be available. This is needed when using NPTL on Linux (and probably PThreads * on Solaris as well). */ - if (this->num_driver_actions > 0) - sched_yield(); + if (this->num_driver_actions > 0) { + /* calling sched_yield() is not sufficient on multicore systems */ + /* sched_yield(); */ + /* instead wait for the other thread to acquire this->driver_lock */ + pthread_mutex_lock(&this->driver_action_lock); + if (this->num_driver_actions > 0) + pthread_cond_wait(&this->driver_action_cond, &this->driver_action_lock); + pthread_mutex_unlock(&this->driver_action_lock); + } } if (in_buf) { @@ -1477,6 +1485,8 @@ static inline void dec_num_driver_actions(aos_t *this) { pthread_mutex_lock(&this->driver_action_lock); this->num_driver_actions--; + /* indicate the change to ao_loop() */ + pthread_cond_broadcast(&this->driver_action_cond); pthread_mutex_unlock(&this->driver_action_lock); } @@ -1679,6 +1689,7 @@ static void ao_exit(xine_audio_port_t *this_gen) { } pthread_mutex_destroy(&this->driver_lock); + pthread_cond_destroy(&this->driver_action_cond); pthread_mutex_destroy(&this->driver_action_lock); pthread_mutex_destroy(&this->streams_lock); xine_list_delete(this->streams); @@ -2083,6 +2094,7 @@ xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, pthread_mutex_init( &this->streams_lock, NULL ); pthread_mutex_init( &this->driver_lock, &attr ); pthread_mutex_init( &this->driver_action_lock, NULL ); + pthread_cond_init( &this->driver_action_cond, NULL ); this->ao.open = ao_open; this->ao.get_buffer = ao_get_buffer; |
