diff options
-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; |