Changeset 18516cc6727f3a03d91e7ba97a9697aa1aa437c6
- Timestamp:
- 30/06/08 20:00:04
(3 months ago)
- Author:
- Laurent Aimar <fenrir@videolan.org>
- git-committer:
- Laurent Aimar <fenrir@videolan.org> 1214848804 +0000
- git-parent:
[d962b50eede7adbdc0a5fe9a37dc7c85f3293ae9]
- git-author:
- Laurent Aimar <fenrir@videolan.org> 1214848774 +0000
- Message:
Clean up vout error path.
Correctly free spu and filter chain.
Do not free 2x vout pictures.
(At least, vlc -V x11 does not segfault any more on resize, it
just does not work)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd962b50 |
r18516cc |
|
| 66 | 66 | static void RunThread ( vout_thread_t * ); |
|---|
| 67 | 67 | static void ErrorThread ( vout_thread_t * ); |
|---|
| | 68 | static void CleanThread ( vout_thread_t * ); |
|---|
| 68 | 69 | static void EndThread ( vout_thread_t * ); |
|---|
| 69 | 70 | |
|---|
| … | … | |
| 725 | 726 | if( p_vout->b_error ) |
|---|
| 726 | 727 | { |
|---|
| | 728 | EndThread( p_vout ); |
|---|
| 727 | 729 | vlc_mutex_unlock( &p_vout->change_lock ); |
|---|
| 728 | 730 | return; |
|---|
| … | … | |
| 1036 | 1038 | // FIXME pf_end |
|---|
| 1037 | 1039 | p_vout->b_error = 1; |
|---|
| | 1040 | break; |
|---|
| 1038 | 1041 | } |
|---|
| 1039 | 1042 | |
|---|
| … | … | |
| 1048 | 1051 | p_vout->i_changes &= ~VOUT_SIZE_CHANGE; |
|---|
| 1049 | 1052 | |
|---|
| | 1053 | assert( !p_vout->b_direct ); |
|---|
| | 1054 | |
|---|
| | 1055 | ChromaDestroy( p_vout ); |
|---|
| | 1056 | |
|---|
| | 1057 | vlc_mutex_lock( &p_vout->picture_lock ); |
|---|
| | 1058 | |
|---|
| 1050 | 1059 | p_vout->pf_end( p_vout ); |
|---|
| | 1060 | |
|---|
| 1051 | 1061 | for( i = 0; i < I_OUTPUTPICTURES; i++ ) |
|---|
| 1052 | 1062 | p_vout->p_picture[ i ].i_status = FREE_PICTURE; |
|---|
| 1053 | 1063 | |
|---|
| 1054 | 1064 | I_OUTPUTPICTURES = 0; |
|---|
| | 1065 | |
|---|
| 1055 | 1066 | if( p_vout->pf_init( p_vout ) ) |
|---|
| 1056 | 1067 | { |
|---|
| … | … | |
| 1059 | 1070 | p_vout->b_error = 1; |
|---|
| 1060 | 1071 | } |
|---|
| | 1072 | |
|---|
| | 1073 | vlc_mutex_unlock( &p_vout->picture_lock ); |
|---|
| 1061 | 1074 | |
|---|
| 1062 | 1075 | /* Need to reinitialise the chroma plugin. Since we might need |
|---|
| … | … | |
| 1064 | 1077 | * recreate the chroma plugin chain from scratch. */ |
|---|
| 1065 | 1078 | /* dionoea */ |
|---|
| 1066 | | if( !p_vout->b_direct ) |
|---|
| 1067 | | { |
|---|
| 1068 | | ChromaDestroy( p_vout ); |
|---|
| 1069 | | |
|---|
| 1070 | | if( ChromaCreate( p_vout ) ) |
|---|
| 1071 | | { |
|---|
| 1072 | | msg_Err( p_vout, "WOW THIS SUCKS BIG TIME!!!!!" ); |
|---|
| 1073 | | } |
|---|
| 1074 | | } |
|---|
| | 1079 | if( ChromaCreate( p_vout ) ) |
|---|
| | 1080 | { |
|---|
| | 1081 | msg_Err( p_vout, "WOW THIS SUCKS BIG TIME!!!!!" ); |
|---|
| | 1082 | p_vout->b_error = 1; |
|---|
| | 1083 | } |
|---|
| | 1084 | if( p_vout->b_error ) |
|---|
| | 1085 | break; |
|---|
| 1075 | 1086 | } |
|---|
| 1076 | 1087 | |
|---|
| … | … | |
| 1094 | 1105 | |
|---|
| 1095 | 1106 | p_vout->b_error = InitThread( p_vout ); |
|---|
| | 1107 | if( p_vout->b_error ) |
|---|
| | 1108 | msg_Err( p_vout, "InitThread after VOUT_PICTURE_BUFFERS_CHANGE failed\n" ); |
|---|
| 1096 | 1109 | |
|---|
| 1097 | 1110 | vlc_mutex_unlock( &p_vout->picture_lock ); |
|---|
| | 1111 | |
|---|
| | 1112 | if( p_vout->b_error ) |
|---|
| | 1113 | break; |
|---|
| 1098 | 1114 | } |
|---|
| 1099 | 1115 | |
|---|
| … | … | |
| 1128 | 1144 | */ |
|---|
| 1129 | 1145 | if( p_vout->b_error ) |
|---|
| 1130 | | { |
|---|
| 1131 | 1146 | ErrorThread( p_vout ); |
|---|
| 1132 | | } |
|---|
| 1133 | 1147 | |
|---|
| 1134 | 1148 | /* End of thread */ |
|---|
| | 1149 | CleanThread( p_vout ); |
|---|
| 1135 | 1150 | EndThread( p_vout ); |
|---|
| 1136 | 1151 | vlc_mutex_unlock( &p_vout->change_lock ); |
|---|
| … | … | |
| 1149 | 1164 | { |
|---|
| 1150 | 1165 | /* Wait until a `die' order */ |
|---|
| 1151 | | while( !p_vout->b_die ) |
|---|
| 1152 | | { |
|---|
| 1153 | | /* Sleep a while */ |
|---|
| 1154 | | msleep( VOUT_IDLE_SLEEP ); |
|---|
| 1155 | | } |
|---|
| | 1166 | while( vlc_object_alive( p_vout ) ) |
|---|
| | 1167 | vlc_object_wait( p_vout ); |
|---|
| | 1168 | } |
|---|
| | 1169 | |
|---|
| | 1170 | /***************************************************************************** |
|---|
| | 1171 | * CleanThread: clean up after InitThread |
|---|
| | 1172 | ***************************************************************************** |
|---|
| | 1173 | * This function is called after a sucessful |
|---|
| | 1174 | * initialization. It frees all resources allocated by InitThread. |
|---|
| | 1175 | * XXX You have to enter it with change_lock taken. |
|---|
| | 1176 | *****************************************************************************/ |
|---|
| | 1177 | static void CleanThread( vout_thread_t *p_vout ) |
|---|
| | 1178 | { |
|---|
| | 1179 | int i_index; /* index in heap */ |
|---|
| | 1180 | |
|---|
| | 1181 | if( !p_vout->b_direct ) |
|---|
| | 1182 | ChromaDestroy( p_vout ); |
|---|
| | 1183 | |
|---|
| | 1184 | /* Destroy all remaining pictures */ |
|---|
| | 1185 | for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES + 1; i_index++ ) |
|---|
| | 1186 | { |
|---|
| | 1187 | if ( p_vout->p_picture[i_index].i_type == MEMORY_PICTURE ) |
|---|
| | 1188 | { |
|---|
| | 1189 | free( p_vout->p_picture[i_index].p_data_orig ); |
|---|
| | 1190 | } |
|---|
| | 1191 | } |
|---|
| | 1192 | |
|---|
| | 1193 | /* Destroy translation tables */ |
|---|
| | 1194 | if( !p_vout->b_error ) |
|---|
| | 1195 | p_vout->pf_end( p_vout ); |
|---|
| 1156 | 1196 | } |
|---|
| 1157 | 1197 | |
|---|
| … | … | |
| 1159 | 1199 | * EndThread: thread destruction |
|---|
| 1160 | 1200 | ***************************************************************************** |
|---|
| 1161 | | * This function is called when the thread ends after a sucessful |
|---|
| 1162 | | * initialization. It frees all resources allocated by InitThread. |
|---|
| | 1201 | * This function is called when the thread ends. |
|---|
| | 1202 | * It frees all resources not allocated by InitThread. |
|---|
| 1163 | 1203 | * XXX You have to enter it with change_lock taken. |
|---|
| 1164 | 1204 | *****************************************************************************/ |
|---|
| 1165 | 1205 | static void EndThread( vout_thread_t *p_vout ) |
|---|
| 1166 | 1206 | { |
|---|
| 1167 | | int i_index; /* index in heap */ |
|---|
| 1168 | | |
|---|
| 1169 | 1207 | #ifdef STATS |
|---|
| 1170 | 1208 | { |
|---|
| … | … | |
| 1176 | 1214 | } |
|---|
| 1177 | 1215 | #endif |
|---|
| 1178 | | |
|---|
| 1179 | | if( !p_vout->b_direct ) |
|---|
| 1180 | | ChromaDestroy( p_vout ); |
|---|
| 1181 | | |
|---|
| 1182 | | /* Destroy all remaining pictures */ |
|---|
| 1183 | | for( i_index = 0; i_index < 2 * VOUT_MAX_PICTURES + 1; i_index++ ) |
|---|
| 1184 | | { |
|---|
| 1185 | | if ( p_vout->p_picture[i_index].i_type == MEMORY_PICTURE ) |
|---|
| 1186 | | { |
|---|
| 1187 | | free( p_vout->p_picture[i_index].p_data_orig ); |
|---|
| 1188 | | } |
|---|
| 1189 | | } |
|---|
| 1190 | 1216 | |
|---|
| 1191 | 1217 | /* Destroy subpicture unit */ |
|---|
| … | … | |
| 1195 | 1221 | /* Destroy the video filters2 */ |
|---|
| 1196 | 1222 | filter_chain_Delete( p_vout->p_vf2_chain ); |
|---|
| 1197 | | |
|---|
| 1198 | | /* Destroy translation tables FIXME if b_error is set, it can already be done */ |
|---|
| 1199 | | p_vout->pf_end( p_vout ); |
|---|
| 1200 | 1223 | } |
|---|
| 1201 | 1224 | |
|---|