diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-12-10 08:57:10 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-12-10 08:57:10 +0000 |
commit | 8cfbd3604fac14f629244e521ad24ffa9938c790 (patch) | |
tree | 16dc096519b8b537bb7d4b73e0c97f5f33ee752b /apps/plugins/mpegplayer | |
parent | 40ff47c7eea41ac893d7af5c5b97ace52a5ffade (diff) | |
download | rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.tar.gz rockbox-8cfbd3604fac14f629244e521ad24ffa9938c790.zip |
Use cookies for thread identification instead of pointers directly which gives a buffer against wrongly identifying a thread when the slot is recycled (which has been nagging me for awhile). A slot gets 255 uses before it repeats. Everything gets incompatible so a full update is required.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19377 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/mpegplayer')
-rw-r--r-- | apps/plugins/mpegplayer/audio_thread.c | 6 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/disk_buf.c | 8 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/disk_buf.h | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_parser.c | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.c | 20 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/stream_mgr.h | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/stream_thread.h | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/video_thread.c | 6 |
8 files changed, 24 insertions, 24 deletions
diff --git a/apps/plugins/mpegplayer/audio_thread.c b/apps/plugins/mpegplayer/audio_thread.c index 45226575c9..2fb46efd56 100644 --- a/apps/plugins/mpegplayer/audio_thread.c +++ b/apps/plugins/mpegplayer/audio_thread.c | |||
@@ -732,7 +732,7 @@ bool audio_thread_init(void) | |||
732 | rb->queue_enable_queue_send(audio_str.hdr.q, &audio_str_queue_send, | 732 | rb->queue_enable_queue_send(audio_str.hdr.q, &audio_str_queue_send, |
733 | audio_str.thread); | 733 | audio_str.thread); |
734 | 734 | ||
735 | if (audio_str.thread == NULL) | 735 | if (audio_str.thread == 0) |
736 | return false; | 736 | return false; |
737 | 737 | ||
738 | /* Wait for thread to initialize */ | 738 | /* Wait for thread to initialize */ |
@@ -744,11 +744,11 @@ bool audio_thread_init(void) | |||
744 | /* Stops the audio thread */ | 744 | /* Stops the audio thread */ |
745 | void audio_thread_exit(void) | 745 | void audio_thread_exit(void) |
746 | { | 746 | { |
747 | if (audio_str.thread != NULL) | 747 | if (audio_str.thread != 0) |
748 | { | 748 | { |
749 | str_post_msg(&audio_str, STREAM_QUIT, 0); | 749 | str_post_msg(&audio_str, STREAM_QUIT, 0); |
750 | rb->thread_wait(audio_str.thread); | 750 | rb->thread_wait(audio_str.thread); |
751 | audio_str.thread = NULL; | 751 | audio_str.thread = 0; |
752 | } | 752 | } |
753 | 753 | ||
754 | #ifndef SIMULATOR | 754 | #ifndef SIMULATOR |
diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index df5e005b50..c008139356 100644 --- a/apps/plugins/mpegplayer/disk_buf.c +++ b/apps/plugins/mpegplayer/disk_buf.c | |||
@@ -835,7 +835,7 @@ void disk_buf_reply_msg(intptr_t retval) | |||
835 | 835 | ||
836 | bool disk_buf_init(void) | 836 | bool disk_buf_init(void) |
837 | { | 837 | { |
838 | disk_buf.thread = NULL; | 838 | disk_buf.thread = 0; |
839 | list_initialize(&nf_list); | 839 | list_initialize(&nf_list); |
840 | 840 | ||
841 | rb->mutex_init(&disk_buf_mtx); | 841 | rb->mutex_init(&disk_buf_mtx); |
@@ -893,7 +893,7 @@ bool disk_buf_init(void) | |||
893 | rb->queue_enable_queue_send(disk_buf.q, &disk_buf_queue_send, | 893 | rb->queue_enable_queue_send(disk_buf.q, &disk_buf_queue_send, |
894 | disk_buf.thread); | 894 | disk_buf.thread); |
895 | 895 | ||
896 | if (disk_buf.thread == NULL) | 896 | if (disk_buf.thread == 0) |
897 | return false; | 897 | return false; |
898 | 898 | ||
899 | /* Wait for thread to initialize */ | 899 | /* Wait for thread to initialize */ |
@@ -904,10 +904,10 @@ bool disk_buf_init(void) | |||
904 | 904 | ||
905 | void disk_buf_exit(void) | 905 | void disk_buf_exit(void) |
906 | { | 906 | { |
907 | if (disk_buf.thread != NULL) | 907 | if (disk_buf.thread != 0) |
908 | { | 908 | { |
909 | rb->queue_post(disk_buf.q, STREAM_QUIT, 0); | 909 | rb->queue_post(disk_buf.q, STREAM_QUIT, 0); |
910 | rb->thread_wait(disk_buf.thread); | 910 | rb->thread_wait(disk_buf.thread); |
911 | disk_buf.thread = NULL; | 911 | disk_buf.thread = 0; |
912 | } | 912 | } |
913 | } | 913 | } |
diff --git a/apps/plugins/mpegplayer/disk_buf.h b/apps/plugins/mpegplayer/disk_buf.h index b6399c81d1..e16939a92e 100644 --- a/apps/plugins/mpegplayer/disk_buf.h +++ b/apps/plugins/mpegplayer/disk_buf.h | |||
@@ -62,7 +62,7 @@ struct dbuf_range | |||
62 | * playback events as well as buffering */ | 62 | * playback events as well as buffering */ |
63 | struct disk_buf | 63 | struct disk_buf |
64 | { | 64 | { |
65 | struct thread_entry *thread; | 65 | unsigned int thread; |
66 | struct event_queue *q; | 66 | struct event_queue *q; |
67 | uint8_t *start; /* Start pointer */ | 67 | uint8_t *start; /* Start pointer */ |
68 | uint8_t *end; /* End of buffer pointer less MPEG_GUARDBUF_SIZE. The | 68 | uint8_t *end; /* End of buffer pointer less MPEG_GUARDBUF_SIZE. The |
diff --git a/apps/plugins/mpegplayer/mpeg_parser.c b/apps/plugins/mpegplayer/mpeg_parser.c index 54a6f23d92..42c388b375 100644 --- a/apps/plugins/mpegplayer/mpeg_parser.c +++ b/apps/plugins/mpegplayer/mpeg_parser.c | |||
@@ -1027,7 +1027,7 @@ intptr_t parser_send_video_msg(long id, intptr_t data) | |||
1027 | { | 1027 | { |
1028 | intptr_t retval = 0; | 1028 | intptr_t retval = 0; |
1029 | 1029 | ||
1030 | if (video_str.thread != NULL && disk_buf.in_file >= 0) | 1030 | if (video_str.thread != 0 && disk_buf.in_file >= 0) |
1031 | { | 1031 | { |
1032 | /* Hook certain messages since they involve multiple operations | 1032 | /* Hook certain messages since they involve multiple operations |
1033 | * behind the scenes */ | 1033 | * behind the scenes */ |
diff --git a/apps/plugins/mpegplayer/stream_mgr.c b/apps/plugins/mpegplayer/stream_mgr.c index 424d2fe503..222ffb7d6b 100644 --- a/apps/plugins/mpegplayer/stream_mgr.c +++ b/apps/plugins/mpegplayer/stream_mgr.c | |||
@@ -908,7 +908,7 @@ static void stream_mgr_thread(void) | |||
908 | /* Opens a new file */ | 908 | /* Opens a new file */ |
909 | int stream_open(const char *filename) | 909 | int stream_open(const char *filename) |
910 | { | 910 | { |
911 | if (stream_mgr.thread != NULL) | 911 | if (stream_mgr.thread != 0) |
912 | return stream_mgr_send_msg(STREAM_OPEN, (intptr_t)filename); | 912 | return stream_mgr_send_msg(STREAM_OPEN, (intptr_t)filename); |
913 | return STREAM_ERROR; | 913 | return STREAM_ERROR; |
914 | } | 914 | } |
@@ -916,7 +916,7 @@ int stream_open(const char *filename) | |||
916 | /* Plays the current file starting at time 'start' */ | 916 | /* Plays the current file starting at time 'start' */ |
917 | int stream_play(void) | 917 | int stream_play(void) |
918 | { | 918 | { |
919 | if (stream_mgr.thread != NULL) | 919 | if (stream_mgr.thread != 0) |
920 | return stream_mgr_send_msg(STREAM_PLAY, 0); | 920 | return stream_mgr_send_msg(STREAM_PLAY, 0); |
921 | return STREAM_ERROR; | 921 | return STREAM_ERROR; |
922 | } | 922 | } |
@@ -924,7 +924,7 @@ int stream_play(void) | |||
924 | /* Pauses playback if playing */ | 924 | /* Pauses playback if playing */ |
925 | int stream_pause(void) | 925 | int stream_pause(void) |
926 | { | 926 | { |
927 | if (stream_mgr.thread != NULL) | 927 | if (stream_mgr.thread != 0) |
928 | return stream_mgr_send_msg(STREAM_PAUSE, false); | 928 | return stream_mgr_send_msg(STREAM_PAUSE, false); |
929 | return STREAM_ERROR; | 929 | return STREAM_ERROR; |
930 | } | 930 | } |
@@ -932,7 +932,7 @@ int stream_pause(void) | |||
932 | /* Resumes playback if paused */ | 932 | /* Resumes playback if paused */ |
933 | int stream_resume(void) | 933 | int stream_resume(void) |
934 | { | 934 | { |
935 | if (stream_mgr.thread != NULL) | 935 | if (stream_mgr.thread != 0) |
936 | return stream_mgr_send_msg(STREAM_PAUSE, true); | 936 | return stream_mgr_send_msg(STREAM_PAUSE, true); |
937 | return STREAM_ERROR; | 937 | return STREAM_ERROR; |
938 | } | 938 | } |
@@ -940,7 +940,7 @@ int stream_resume(void) | |||
940 | /* Stops playback if not stopped */ | 940 | /* Stops playback if not stopped */ |
941 | int stream_stop(void) | 941 | int stream_stop(void) |
942 | { | 942 | { |
943 | if (stream_mgr.thread != NULL) | 943 | if (stream_mgr.thread != 0) |
944 | return stream_mgr_send_msg(STREAM_STOP, 0); | 944 | return stream_mgr_send_msg(STREAM_STOP, 0); |
945 | return STREAM_ERROR; | 945 | return STREAM_ERROR; |
946 | } | 946 | } |
@@ -950,7 +950,7 @@ int stream_seek(uint32_t time, int whence) | |||
950 | { | 950 | { |
951 | int ret; | 951 | int ret; |
952 | 952 | ||
953 | if (stream_mgr.thread == NULL) | 953 | if (stream_mgr.thread == 0) |
954 | return STREAM_ERROR; | 954 | return STREAM_ERROR; |
955 | 955 | ||
956 | stream_mgr_lock(); | 956 | stream_mgr_lock(); |
@@ -968,7 +968,7 @@ int stream_seek(uint32_t time, int whence) | |||
968 | /* Closes the current file */ | 968 | /* Closes the current file */ |
969 | int stream_close(void) | 969 | int stream_close(void) |
970 | { | 970 | { |
971 | if (stream_mgr.thread != NULL) | 971 | if (stream_mgr.thread != 0) |
972 | return stream_mgr_send_msg(STREAM_CLOSE, 0); | 972 | return stream_mgr_send_msg(STREAM_CLOSE, 0); |
973 | return STREAM_ERROR; | 973 | return STREAM_ERROR; |
974 | } | 974 | } |
@@ -1018,7 +1018,7 @@ int stream_init(void) | |||
1018 | rb->queue_enable_queue_send(stream_mgr.q, &stream_mgr_queue_send, | 1018 | rb->queue_enable_queue_send(stream_mgr.q, &stream_mgr_queue_send, |
1019 | stream_mgr.thread); | 1019 | stream_mgr.thread); |
1020 | 1020 | ||
1021 | if (stream_mgr.thread == NULL) | 1021 | if (stream_mgr.thread == 0) |
1022 | { | 1022 | { |
1023 | rb->splash(HZ, "Could not create stream manager thread!"); | 1023 | rb->splash(HZ, "Could not create stream manager thread!"); |
1024 | return STREAM_ERROR; | 1024 | return STREAM_ERROR; |
@@ -1073,11 +1073,11 @@ void stream_exit(void) | |||
1073 | disk_buf_exit(); | 1073 | disk_buf_exit(); |
1074 | pcm_output_exit(); | 1074 | pcm_output_exit(); |
1075 | 1075 | ||
1076 | if (stream_mgr.thread != NULL) | 1076 | if (stream_mgr.thread != 0) |
1077 | { | 1077 | { |
1078 | stream_mgr_post_msg(STREAM_QUIT, 0); | 1078 | stream_mgr_post_msg(STREAM_QUIT, 0); |
1079 | rb->thread_wait(stream_mgr.thread); | 1079 | rb->thread_wait(stream_mgr.thread); |
1080 | stream_mgr.thread = NULL; | 1080 | stream_mgr.thread = 0; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | #ifndef HAVE_LCD_COLOR | 1083 | #ifndef HAVE_LCD_COLOR |
diff --git a/apps/plugins/mpegplayer/stream_mgr.h b/apps/plugins/mpegplayer/stream_mgr.h index e3ea9207e6..a00b39f189 100644 --- a/apps/plugins/mpegplayer/stream_mgr.h +++ b/apps/plugins/mpegplayer/stream_mgr.h | |||
@@ -27,7 +27,7 @@ | |||
27 | * coordination with assistance from the parser */ | 27 | * coordination with assistance from the parser */ |
28 | struct stream_mgr | 28 | struct stream_mgr |
29 | { | 29 | { |
30 | struct thread_entry *thread; /* Playback control thread */ | 30 | unsigned int thread; /* Playback control thread */ |
31 | struct event_queue *q; /* event queue for control thread */ | 31 | struct event_queue *q; /* event queue for control thread */ |
32 | const char *filename; /* Current filename */ | 32 | const char *filename; /* Current filename */ |
33 | uint32_t resume_time; /* The stream tick where playback was | 33 | uint32_t resume_time; /* The stream tick where playback was |
diff --git a/apps/plugins/mpegplayer/stream_thread.h b/apps/plugins/mpegplayer/stream_thread.h index d6e42d274f..30bf46e6ff 100644 --- a/apps/plugins/mpegplayer/stream_thread.h +++ b/apps/plugins/mpegplayer/stream_thread.h | |||
@@ -45,7 +45,7 @@ struct stream_hdr | |||
45 | struct stream | 45 | struct stream |
46 | { | 46 | { |
47 | struct stream_hdr hdr; /* Base stream data */ | 47 | struct stream_hdr hdr; /* Base stream data */ |
48 | struct thread_entry *thread; /* Stream's thread */ | 48 | unsigned int thread; /* Stream's thread */ |
49 | uint8_t* curr_packet; /* Current stream packet beginning */ | 49 | uint8_t* curr_packet; /* Current stream packet beginning */ |
50 | uint8_t* curr_packet_end; /* Current stream packet end */ | 50 | uint8_t* curr_packet_end; /* Current stream packet end */ |
51 | struct list_item l; /* List of streams - either reserve pool | 51 | struct list_item l; /* List of streams - either reserve pool |
diff --git a/apps/plugins/mpegplayer/video_thread.c b/apps/plugins/mpegplayer/video_thread.c index 100904b01b..8b84686a3b 100644 --- a/apps/plugins/mpegplayer/video_thread.c +++ b/apps/plugins/mpegplayer/video_thread.c | |||
@@ -1009,7 +1009,7 @@ bool video_thread_init(void) | |||
1009 | rb->queue_enable_queue_send(video_str.hdr.q, &video_str_queue_send, | 1009 | rb->queue_enable_queue_send(video_str.hdr.q, &video_str_queue_send, |
1010 | video_str.thread); | 1010 | video_str.thread); |
1011 | 1011 | ||
1012 | if (video_str.thread == NULL) | 1012 | if (video_str.thread == 0) |
1013 | return false; | 1013 | return false; |
1014 | 1014 | ||
1015 | /* Wait for thread to initialize */ | 1015 | /* Wait for thread to initialize */ |
@@ -1022,11 +1022,11 @@ bool video_thread_init(void) | |||
1022 | /* Terminates the video thread */ | 1022 | /* Terminates the video thread */ |
1023 | void video_thread_exit(void) | 1023 | void video_thread_exit(void) |
1024 | { | 1024 | { |
1025 | if (video_str.thread != NULL) | 1025 | if (video_str.thread != 0) |
1026 | { | 1026 | { |
1027 | str_post_msg(&video_str, STREAM_QUIT, 0); | 1027 | str_post_msg(&video_str, STREAM_QUIT, 0); |
1028 | rb->thread_wait(video_str.thread); | 1028 | rb->thread_wait(video_str.thread); |
1029 | IF_COP(invalidate_icache()); | 1029 | IF_COP(invalidate_icache()); |
1030 | video_str.thread = NULL; | 1030 | video_str.thread = 0; |
1031 | } | 1031 | } |
1032 | } | 1032 | } |