diff options
| author | phintuka <phintuka> | 2011-05-31 12:20:29 +0000 |
|---|---|---|
| committer | phintuka <phintuka> | 2011-05-31 12:20:29 +0000 |
| commit | 2848dfa9c34e46c77b17382e0dd823984397a78f (patch) | |
| tree | e76ec143516829edf8ddfd9094177cf21b6faeaa | |
| parent | e1983c992660da3b31e288aaf7367b845315399a (diff) | |
| download | xineliboutput-2848dfa9c34e46c77b17382e0dd823984397a78f.tar.gz xineliboutput-2848dfa9c34e46c77b17382e0dd823984397a78f.tar.bz2 | |
Added mutex to protect title_info
(get_optional_data() is called from another thread)
| -rw-r--r-- | xine/BluRay/input_bluray.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/xine/BluRay/input_bluray.c b/xine/BluRay/input_bluray.c index ebe4e806..d81471df 100644 --- a/xine/BluRay/input_bluray.c +++ b/xine/BluRay/input_bluray.c @@ -41,6 +41,7 @@ #include <string.h> #include <errno.h> #include <dlfcn.h> +#include <pthread.h> #include <libbluray/bluray.h> #include <libbluray/keys.h> @@ -124,6 +125,7 @@ typedef struct { int num_titles; /* navigation mode, number of titles in disc index */ int current_title; /* navigation mode, title from disc index */ BLURAY_TITLE_INFO *title_info; + pthread_mutex_t title_info_mutex; /* lock this when accessing title_info outside of input/demux thread */ unsigned int current_clip; int error; int menu_open; @@ -219,6 +221,8 @@ static void update_stream_info(bluray_input_plugin_t *this) static void update_title_info(bluray_input_plugin_t *this, int playlist_id) { + pthread_mutex_lock(&this->title_info_mutex); + if (this->title_info) bd_free_title_info(this->title_info); @@ -227,6 +231,8 @@ static void update_title_info(bluray_input_plugin_t *this, int playlist_id) else this->title_info = bd_get_playlist_info(this->bdh, playlist_id); + pthread_mutex_unlock(&this->title_info_mutex); + if (!this->title_info) { LOGMSG("bd_get_title_info(%d) failed\n", this->current_title_idx); return; @@ -805,7 +811,7 @@ static off_t bluray_plugin_seek_time (input_plugin_t *this_gen, int time_offset, { bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen; - if (!this || !this->bdh || !this->title_info) + if (!this || !this->bdh) return -1; /* convert relative seeks to absolute */ @@ -814,11 +820,21 @@ static off_t bluray_plugin_seek_time (input_plugin_t *this_gen, int time_offset, time_offset += this_gen->get_current_time(this_gen); } else if (origin == SEEK_END) { + + pthread_mutex_lock(&this->title_info_mutex); + + if (!this->title_info) { + pthread_mutex_unlock(&this->title_info_mutex); + return -1; + } + int duration = this->title_info->duration / 90; if (time_offset < duration) time_offset = duration - time_offset; else time_offset = 0; + + pthread_mutex_unlock(&this->title_info_mutex); } lprintf("bluray_plugin_seek_time() seeking to %d.%03ds\n", time_offset / 1000, time_offset % 1000); @@ -861,13 +877,8 @@ static const char* bluray_plugin_get_mrl (input_plugin_t *this_gen) return this->mrl; } -static int bluray_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) +static int get_optional_data_impl (bluray_input_plugin_t *this, void *data, int data_type) { - bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen; - - if (!this || !this->stream || !data) - return INPUT_OPTIONAL_UNSUPPORTED; - unsigned int current_clip = this->current_clip; switch (data_type) { @@ -947,6 +958,20 @@ static int bluray_plugin_get_optional_data (input_plugin_t *this_gen, void *data return INPUT_OPTIONAL_UNSUPPORTED; } +static int bluray_plugin_get_optional_data (input_plugin_t *this_gen, void *data, int data_type) +{ + bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen; + int r = INPUT_OPTIONAL_UNSUPPORTED; + + if (this && this->stream && data) { + pthread_mutex_lock(&this->title_info_mutex); + r = get_optional_data_impl(this, data, data_type); + pthread_mutex_unlock(&this->title_info_mutex); + } + + return r; +} + static void bluray_plugin_dispose (input_plugin_t *this_gen) { bluray_input_plugin_t *this = (bluray_input_plugin_t *) this_gen; @@ -959,8 +984,13 @@ static void bluray_plugin_dispose (input_plugin_t *this_gen) if (this->event_queue) xine_event_dispose_queue(this->event_queue); + pthread_mutex_lock(&this->title_info_mutex); if (this->title_info) bd_free_title_info(this->title_info); + this->title_info = NULL; + pthread_mutex_unlock(&this->title_info_mutex); + + pthread_mutex_destroy(&this->title_info_mutex); if (this->bdh) bd_close(this->bdh); @@ -1241,6 +1271,8 @@ static input_plugin_t *bluray_class_get_instance (input_class_t *cls_gen, xine_s this->event_queue = xine_event_new_queue (this->stream); + pthread_mutex_init(&this->title_info_mutex, NULL); + this->pg_stream = -1; return &this->input_plugin; |
