Changeset 18516cc6727f3a03d91e7ba97a9697aa1aa437c6

Show
Ignore:
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
  • src/video_output/video_output.c

    rd962b50 r18516cc  
    6666static void     RunThread         ( vout_thread_t * ); 
    6767static void     ErrorThread       ( vout_thread_t * ); 
     68static void     CleanThread       ( vout_thread_t * ); 
    6869static void     EndThread         ( vout_thread_t * ); 
    6970 
     
    725726    if( p_vout->b_error ) 
    726727    { 
     728        EndThread( p_vout ); 
    727729        vlc_mutex_unlock( &p_vout->change_lock ); 
    728730        return; 
     
    10361038            // FIXME pf_end 
    10371039            p_vout->b_error = 1; 
     1040            break; 
    10381041        } 
    10391042 
     
    10481051            p_vout->i_changes &= ~VOUT_SIZE_CHANGE; 
    10491052 
     1053            assert( !p_vout->b_direct ); 
     1054 
     1055            ChromaDestroy( p_vout ); 
     1056 
     1057            vlc_mutex_lock( &p_vout->picture_lock ); 
     1058 
    10501059            p_vout->pf_end( p_vout ); 
     1060 
    10511061            for( i = 0; i < I_OUTPUTPICTURES; i++ ) 
    10521062                 p_vout->p_picture[ i ].i_status = FREE_PICTURE; 
    10531063 
    10541064            I_OUTPUTPICTURES = 0; 
     1065 
    10551066            if( p_vout->pf_init( p_vout ) ) 
    10561067            { 
     
    10591070                p_vout->b_error = 1; 
    10601071            } 
     1072 
     1073            vlc_mutex_unlock( &p_vout->picture_lock ); 
    10611074 
    10621075            /* Need to reinitialise the chroma plugin. Since we might need 
     
    10641077             * recreate the chroma plugin chain from scratch. */ 
    10651078            /* 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; 
    10751086        } 
    10761087 
     
    10941105 
    10951106            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" ); 
    10961109 
    10971110            vlc_mutex_unlock( &p_vout->picture_lock ); 
     1111 
     1112            if( p_vout->b_error ) 
     1113                break; 
    10981114        } 
    10991115 
     
    11281144     */ 
    11291145    if( p_vout->b_error ) 
    1130     { 
    11311146        ErrorThread( p_vout ); 
    1132     } 
    11331147 
    11341148    /* End of thread */ 
     1149    CleanThread( p_vout ); 
    11351150    EndThread( p_vout ); 
    11361151    vlc_mutex_unlock( &p_vout->change_lock ); 
     
    11491164{ 
    11501165    /* 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 *****************************************************************************/ 
     1177static 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 ); 
    11561196} 
    11571197 
     
    11591199 * EndThread: thread destruction 
    11601200 ***************************************************************************** 
    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. 
    11631203 * XXX You have to enter it with change_lock taken. 
    11641204 *****************************************************************************/ 
    11651205static void EndThread( vout_thread_t *p_vout ) 
    11661206{ 
    1167     int     i_index;                                        /* index in heap */ 
    1168  
    11691207#ifdef STATS 
    11701208    { 
     
    11761214    } 
    11771215#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     } 
    11901216 
    11911217    /* Destroy subpicture unit */ 
     
    11951221    /* Destroy the video filters2 */ 
    11961222    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 ); 
    12001223} 
    12011224