diff options
author | Reinhard Nißl <rnissl@gmx.de> | 2007-04-13 00:39:06 +0200 |
---|---|---|
committer | Reinhard Nißl <rnissl@gmx.de> | 2007-04-13 00:39:06 +0200 |
commit | f8e051109fc70cbf7acbfd6582bc2f6d03e6d93b (patch) | |
tree | 7d0ec108bfce5634cbc9d1ed2253f2b794d7e40a | |
parent | 31bb62fae17fe849704c5d3fe78090a3df92cead (diff) | |
download | xine-lib-f8e051109fc70cbf7acbfd6582bc2f6d03e6d93b.tar.gz xine-lib-f8e051109fc70cbf7acbfd6582bc2f6d03e6d93b.tar.bz2 |
Provide internal functions to lock frontend_lock.
The introduced functions give "frontend like" plugins a chance to
lock and unlock frontend_lock. This protects such threads for
example from beeing blocked when changing the streams speed.
-rw-r--r-- | src/xine-engine/xine.c | 28 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 1a9a2be4d..ce7713810 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -2143,3 +2143,31 @@ void _x_unlock_port_rewiring(xine_t *xine) { xine->port_ticket->unlock_port_rewiring(xine->port_ticket); } + +int _x_lock_frontend(xine_stream_t *stream, int ms_to_time_out) +{ + if (ms_to_time_out >= 0) { + struct timespec abstime; + + struct timeval now; + gettimeofday(&now, 0); + + abstime.tv_sec = now.tv_sec + ms_to_time_out / 1000; + abstime.tv_nsec = now.tv_usec * 1000 + (ms_to_time_out % 1000) * 1e6; + + if (abstime.tv_nsec > 1e9) { + abstime.tv_nsec -= 1e9; + abstime.tv_sec++; + } + + return (0 == pthread_mutex_timedlock(&stream->frontend_lock, &abstime)); + } + + pthread_mutex_lock(&stream->frontend_lock); + return 1; +} + +void _x_unlock_frontend(xine_stream_t *stream) +{ + pthread_mutex_unlock(&stream->frontend_lock); +} diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 4fa31a969..511b13a0d 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.h @@ -373,6 +373,8 @@ struct xine_stream_s { int _x_query_buffer_usage(xine_stream_t *stream, int *num_video_buffers, int *num_audio_buffers, int *num_video_frames, int *num_audio_frames) XINE_PROTECTED; int _x_lock_port_rewiring(xine_t *xine, int ms_to_time_out) XINE_PROTECTED; void _x_unlock_port_rewiring(xine_t *xine) XINE_PROTECTED; +int _x_lock_frontend(xine_stream_t *stream, int ms_to_time_out) XINE_PROTECTED; +void _x_unlock_frontend(xine_stream_t *stream) XINE_PROTECTED; void _x_handle_stream_end (xine_stream_t *stream, int non_user) XINE_PROTECTED; |