Changeset 38dbd37adf32cf04e1caf17ceb7888a4a5ec2f40

Show
Ignore:
Timestamp:
18/08/07 05:22:03 (1 year ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1187407323 +0000
git-parent:

[a9d17dba883714d98580639980f3142317a22e69]

git-author:
Rafaël Carré <funman@videolan.org> 1187407323 +0000
Message:

Input access locking. Part one

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_input.h

    r1479b91 r38dbd37  
    222222{ 
    223223    vlc_event_t event; 
     224    vlc_mutex_lock( &p_i->p_lock ); 
    224225    if( !p_i->p_meta ) 
    225226        p_i->p_meta = vlc_meta_New(); 
    226227    vlc_meta_Set( p_i->p_meta, meta_type, psz_val ); 
     228    vlc_mutex_unlock( &p_i->p_lock );  
    227229 
    228230    /* Notify interested third parties */ 
     
    232234} 
    233235 
    234 static inline const char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) 
    235 
     236static inline char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) 
     237
     238    vlc_mutex_lock( &p_i->p_lock ); 
    236239    if( !p_i->p_meta ) 
     240    { 
     241        vlc_mutex_unlock( &p_i->p_lock ); 
    237242        return NULL; 
    238     return vlc_meta_Get( p_i->p_meta, meta_type ); 
     243    } 
     244    char *psz_s = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) ); 
     245    vlc_mutex_unlock( &p_i->p_lock ); 
     246    return psz_s; 
     247
     248 
     249static inline char * input_item_GetName( input_item_t *p_i ) 
     250
     251    vlc_mutex_lock( &p_i->p_lock ); 
     252    char *psz_s = strdup( p_i->psz_name ); 
     253    vlc_mutex_unlock( &p_i->p_lock ); 
     254    return psz_s; 
    239255} 
    240256 
  • modules/control/dbus.c

    rf60e1bd r38dbd37  
    867867#define ADD_VLC_META_STRING( entry, item ) \ 
    868868    { \ 
    869         const char * psz = input_item_Get##item( p_input );\ 
     869        char * psz = input_item_Get##item( p_input );\ 
    870870        ADD_META( entry, DBUS_TYPE_STRING, \ 
    871871                  psz ); \ 
     872        free( psz ); \ 
    872873    } 
    873874 
  • modules/demux/flac.c

    r51880eb r38dbd37  
    621621    if( !strncasecmp(psz, txt, strlen(txt)) ) \ 
    622622    { \ 
    623         const char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \ 
     623        char * oldval = vlc_meta_Get( p_sys->p_meta, vlc_meta_ ## var ); \ 
    624624        if( oldval ) \ 
    625625        { \ 
     
    631631        else \ 
    632632            vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \ 
     633        free( oldval ); \ 
    633634    } 
    634635        IF_EXTRACT("TITLE=", Title ) 
  • modules/gui/macosx/playlist.m

    r51880eb r38dbd37  
    272272    { 
    273273        /* sanity check to prevent the NSString class from crashing */ 
    274         if( !EMPTY_STR( input_item_GetTitle( p_item->p_input ) ) ) 
    275         { 
    276             o_value = [NSString stringWithUTF8String: input_item_GetTitle( p_item->p_input )]; 
     274        char *psz_title =  input_item_GetTitle( p_item->p_input ); 
     275        if( !EMPTY_STR( psz_title ) ) ) 
     276        { 
     277            o_value = [NSString stringWithUTF8String: psz_title )]; 
    277278            if( o_value == NULL ) 
    278                 o_value = [NSString stringWithCString: input_item_GetTitle( p_item->p_input )]; 
     279                o_value = [NSString stringWithCString: psz_title )]; 
    279280        }  
    280         else if( p_item->p_input->psz_name != NULL ) 
    281         { 
    282             o_value = [NSString stringWithUTF8String: p_item->p_input->psz_name]; 
     281        else 
     282        { 
     283            char *psz_name = input_item_GetName( p_item->p_input ); 
     284            if( psz_name != NULL ) 
     285            { 
     286                o_value = [NSString stringWithUTF8String: psz_name]; 
     287                if( o_value == NULL ) 
     288                    o_value = [NSString stringWithCString: psz_name]; 
     289            } 
     290        } 
     291        free( psz_title ); 
     292        free( psz_name ); 
     293    } 
     294    else 
     295    { 
     296        char *psz_artist = input_item_GetArtist( p_item->p_input ); 
     297        if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( psz_artist ) ) 
     298        { 
     299            o_value = [NSString stringWithUTF8String: psz_artist )]; 
    283300            if( o_value == NULL ) 
    284                 o_value = [NSString stringWithCString: p_item->p_input->psz_name]; 
    285         } 
    286     } 
    287     else if( [[o_tc identifier] isEqualToString:@"2"] && !EMPTY_STR( input_item_GetArtist( p_item->p_input ) ) ) 
    288     { 
    289         o_value = [NSString stringWithUTF8String: input_item_GetArtist( p_item->p_input )]; 
    290         if( o_value == NULL ) 
    291             o_value = [NSString stringWithCString: input_item_GetArtist( p_item->p_input )]; 
    292     } 
    293     else if( [[o_tc identifier] isEqualToString:@"3"] ) 
    294     { 
    295         char psz_duration[MSTRTIME_MAX_SIZE]; 
    296         mtime_t dur = p_item->p_input->i_duration; 
    297         if( dur != -1 ) 
    298         { 
    299             secstotimestr( psz_duration, dur/1000000 ); 
    300             o_value = [NSString stringWithUTF8String: psz_duration]; 
    301         } 
    302         else 
    303         { 
    304             o_value = @"-:--:--"; 
    305         } 
     301                o_value = [NSString stringWithCString: psz_artist )]; 
     302        } 
     303        else if( [[o_tc identifier] isEqualToString:@"3"] ) 
     304        { 
     305            char psz_duration[MSTRTIME_MAX_SIZE]; 
     306            mtime_t dur = p_item->p_input->i_duration; 
     307            if( dur != -1 ) 
     308            { 
     309                secstotimestr( psz_duration, dur/1000000 ); 
     310                o_value = [NSString stringWithUTF8String: psz_duration]; 
     311            } 
     312            else 
     313            { 
     314                o_value = @"-:--:--"; 
     315            } 
     316        } 
     317        free( psz_artist ); 
    306318    } 
    307319 
  • modules/gui/qt4/components/infopanels.cpp

    rc4292a1 r38dbd37  
    189189void MetaPanel::update( input_item_t *p_item ) 
    190190{ 
    191     const char *psz_meta;  
     191    char *psz_meta;  
    192192#define UPDATE_META( meta, widget ) {               \ 
    193193    psz_meta = input_item_Get##meta( p_item );      \ 
     
    195195        widget->setText( qfu( psz_meta ) );         \ 
    196196    else                                            \ 
    197         widget->setText( "" ); } 
     197        widget->setText( "" ); }                    \ 
     198    free( psz_meta ); 
    198199 
    199200#define UPDATE_META_INT( meta, widget ) {           \ 
    200201    psz_meta = input_item_Get##meta( p_item );      \ 
    201202    if( !EMPTY_STR( psz_meta ) )                    \ 
    202         widget->setValue( atoi( psz_meta ) ); } 
     203        widget->setValue( atoi( psz_meta ) ); }     \ 
     204    free( psz_meta ); 
     205 
    203206 
    204207    /* Name / Title */ 
     
    209212        title_text->setText( qfu( p_item->psz_name ) ); 
    210213    else title_text->setText( "" ); 
     214    free( psz_meta ); 
    211215 
    212216    /* URL / URI */ 
     
    216220    else if( !EMPTY_STR( p_item->psz_uri ) ) 
    217221        emit uriSet( QString( p_item->psz_uri ) ); 
     222    free( psz_meta ); 
    218223 
    219224    /* Other classic though */ 
     
    244249    else 
    245250        art_cover->setPixmap( QPixmap( ":/noart.png" ) ); 
     251    free( psz_meta ); 
    246252} 
    247253 
  • modules/gui/qt4/input_manager.cpp

    rb40e9cd r38dbd37  
    133133    /* Update text */ 
    134134    QString text; 
    135     if( !EMPTY_STR(input_item_GetNowPlaying( input_GetItem(p_input) )) ) 
    136     { 
    137         text.sprintf( "%s - %s", 
    138                   input_item_GetNowPlaying( input_GetItem(p_input) ), 
    139                   input_GetItem(p_input)->psz_name ); 
    140     } 
    141     else if( !EMPTY_STR(input_item_GetArtist( input_GetItem(p_input) )) ) 
    142     { 
    143         text.sprintf( "%s - %s", 
    144                   input_item_GetArtist( input_GetItem(p_input) ), 
    145                   input_GetItem(p_input)->psz_name ); 
     135    char *psz_name = input_GetName( input_GetItem( p_input ) ); 
     136    char *psz_nowplaying = input_item_GetNowPlaying( input_GetItem( p_input ); 
     137    char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) ); 
     138    if( !EMPTY_STR( psz_nowplaying ) ) 
     139    { 
     140        text.sprintf( "%s - %s", psz_now_playing, psz_name ); 
     141    } 
     142    else if( !EMPTY_STR( psz_artist ) ) 
     143    { 
     144        text.sprintf( "%s - %s", psz_artist, psz_name ); 
    146145    } 
    147146    else 
    148147    { 
    149         text.sprintf( "%s", input_GetItem(p_input)->psz_name ); 
    150     } 
     148        text.sprintf( "%s", psz_name ); 
     149    } 
     150    free( psz_name ); 
     151    free( psz_nowplaying ); 
     152    free( psz_artist ); 
    151153    if( old_name != text ) 
    152154    { 
  • modules/gui/qt4/playlist_model.cpp

    rd084716 r38dbd37  
    2121 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 
    2222 *****************************************************************************/ 
    23 #define PLI_NAME( p ) p ? p->p_input->psz_name : "null" 
    2423 
    2524#include <assert.h> 
     
    185184    current = iscurrent; 
    186185 
    187     if( current && input_item_GetArtURL( p_item->p_input ) && 
    188         !strncmp( input_item_GetArtURL( p_item->p_input ), "file://", 7 ) ) 
    189         model->sendArt( qfu( input_item_GetArtURL( p_item->p_input ) ) ); 
     186    char *psz_arturl = input_item_GetArtURL( p_item->p_input ); 
     187    if( current && psz_arturl ) && 
     188        !strncmp( psz_arturl, "file://", 7 ) ) 
     189        model->sendArt( qfu( psz_arturl ) ) ); 
    190190    else if( current ) 
    191191        model->removeArt(); 
     192    free( psz_arturl ); 
    192193 
    193194    strings.clear(); 
     
    199200    } 
    200201 
    201  
     202    char *psz_meta; 
    202203#define ADD_META( item, meta ) \ 
    203       strings.append( qfu( input_item_Get ## meta ( item->p_input ) ) ) 
     204      psz_meta = input_item_Get ## meta ( item->p_input ); \ 
     205      strings.append( qfu( psz_meta ) ); \ 
     206      free( psz_meta ); 
    204207 
    205208    for( int i_index=1; i_index <= VLC_META_ENGINE_MB_TRM_ID; i_index = i_index * 2 ) 
     
    213216                    break; 
    214217                case VLC_META_ENGINE_TITLE: 
    215                     if( input_item_GetTitle( p_item->p_input ) ) 
     218                    char *psz_title; 
     219                    psz_title = input_item_GetTile( p_item->p_input ); 
     220                    psz_name = input_item_GetName( p_item->p_input ); 
     221                    if( psz_title ) 
    216222                    { 
    217223                        ADD_META( p_item, Title ); 
    218224                    } else { 
    219                         strings.append( qfu( p_item->p_input->psz_name ) ); 
     225                        strings.append( qfu( psz_name ) ); 
    220226                    } 
     227                    free( psz_title ); 
     228                    free( psz_name ); 
    221229                    break; 
    222230                case VLC_META_ENGINE_DESCRIPTION: 
  • modules/gui/wxwidgets/dialogs/infopanels.cpp

    r51880eb r38dbd37  
    122122 
    123123#define UPDATE_META( meta, widget ) {                                       \ 
    124     const char *psz_meta = input_item_Get##meta( p_item );                  \ 
     124    char *psz_meta = input_item_Get##meta( p_item );                        \ 
    125125    if( psz_meta != NULL && *psz_meta)                                      \ 
    126126    {                                                                       \ 
     
    128128    }                                                                       \ 
    129129    else { widget->SetLabel( wxU( "-" ) ); }                                \ 
    130     } 
     130    }                                                                       \ 
     131    free( psz_meta ); 
    131132 
    132133    UPDATE_META( Artist, artist_text ); 
  • modules/gui/wxwidgets/dialogs/playlist.cpp

    r51880eb r38dbd37  
    514514 
    515515    char *psz_artist; 
    516     psz_artist = input_item_GetArtist( p_item->p_input ) ? 
    517                     strdup( input_item_GetArtist( p_item->p_input ) ) : 
    518                     strdup(""); 
     516    psz_artist = input_item_GetArtist( p_item->p_input ); 
    519517 
    520518    char psz_duration[MSTRTIME_MAX_SIZE]; 
  • modules/gui/wxwidgets/input_manager.cpp

    r7377b28 r38dbd37  
    211211void InputManager::UpdateNowPlaying() 
    212212{ 
    213     const char *psz_now_playing = input_item_GetNowPlaying( input_GetItem(p_input) ); 
     213    char *psz_now_playing = input_item_GetNowPlaying( input_GetItem(p_input) ); 
    214214    if( psz_now_playing && *psz_now_playing ) 
    215215    { 
     
    223223                   wxU(input_GetItem(p_input)->psz_name), 2 ); 
    224224    } 
     225    free( psz_now_playing ); 
    225226} 
    226227 
  • modules/gui/wxwidgets/playlist_manager.cpp

    r7377b28 r38dbd37  
    300300    wxString duration = wxU( "" ); 
    301301 
    302     const char *psz_artist = input_item_GetArtist( p_item->p_input ); 
     302    char *psz_artist = input_item_GetArtist( p_item->p_input ); 
    303303    if( ! psz_artist ) 
    304304    { 
     
    325325                    wxString(wxU(p_item->p_input->psz_name)) + duration; 
    326326    } 
     327    free( psz_artist ); 
    327328    treectrl->SetItemText( item , msg ); 
    328329    treectrl->SetItemImage( item, p_item->p_input->i_type ); 
  • modules/meta_engine/luameta.c

    r3ea2708 r38dbd37  
    251251        return NULL; 
    252252    } 
     253    char *psz_meta; 
    253254 
    254255    /* Load Lua libraries */ 
     
    259260    lua_pushlightuserdata( p_state, p_this ); 
    260261    lua_setfield( p_state, lua_gettop( p_state ) - 1, "private" ); 
    261      
    262     lua_pushstring( p_state, p_item->psz_name ); 
     262    
     263    psz_meta = input_item_GetName( p_item ); 
     264    lua_pushstring( p_state, psz_meta ); 
    263265    lua_setfield( p_state, lua_gettop( p_state ) - 1, "name" ); 
    264      
    265     lua_pushstring( p_state, input_item_GetTitle( p_item ) ); 
     266    free( psz_meta ); 
     267    
     268    psz_meta = input_item_GetTitle( p_item ) ; 
     269    lua_pushstring( p_state, psz_meta ); 
    266270    lua_setfield( p_state, lua_gettop( p_state ) - 1, "title" ); 
    267      
    268     lua_pushstring( p_state, input_item_GetAlbum( p_item ) ); 
     271    free( psz_meta ); 
     272    
     273    psz_meta = input_item_GetAlbum( p_item ); 
     274    lua_pushstring( p_state, psz_meta ); 
    269275    lua_setfield( p_state, lua_gettop( p_state ) - 1, "album" ); 
    270  
    271     lua_pushstring( p_state, input_item_GetArtURL( p_item ) ); 
     276    free( psz_meta ); 
     277 
     278    psz_meta = input_item_GetArtURL( p_item ); 
     279    lua_pushstring( p_state, psz_meta ); 
    272280    lua_setfield( p_state, lua_gettop( p_state ) - 1, "arturl" ); 
    273     /* XXX: all should be passed */ 
     281    free( psz_meta ); 
     282    /* XXX: all should be passed ( could use macro ) */ 
    274283 
    275284    return p_state; 
  • modules/meta_engine/musicbrainz.c

    r51880eb r38dbd37  
    7878    char *ppsz_args[4]; 
    7979 
    80     char *psz_title; 
    8180    char *psz_artist; 
    8281    char *psz_album; 
     
    8483    psz_artist = input_item_GetArtist( p_item ); 
    8584    psz_album = input_item_GetAlbum( p_item ); 
    86     psz_title = p_item->psz_name; 
    8785 
    8886    if( !psz_artist || !psz_album ) 
     87    { 
     88        free( psz_artist ); 
     89        free( psz_album ); 
    8990        return VLC_EGENERIC; 
     91    } 
     92    free( psz_artist ); 
     93    free( psz_album ); 
    9094 
    9195    musicbrainz_t p_mb; 
     
    155159        return VLC_SUCCESS; 
    156160    else 
    157         return EMPTY_STR( input_item_GetArtURL( p_item ) ) ? 
    158                VLC_SUCCESS : VLC_EGENERIC; 
     161    { 
     162        char *psz_arturl; 
     163        psz_arturl = input_item_GetArtURL( p_item ); 
     164        int i_ret; 
     165        i_ret = EMPTY_STR( psz_arturl ) ? VLC_SUCCESS : VLC_EGENERIC ; 
     166        free( psz_arturl ); 
     167        return i_ret; 
    159168} 
    160169 
  • modules/meta_engine/taglib.cpp

    r51880eb r38dbd37  
    194194        TagLib::Tag *tag = f.tag(); 
    195195 
    196         SET( Artist, input_item_GetArtist( p_item ) ); 
    197  
    198         const char *psz_titlec = ( input_item_GetTitle( p_item ) ? 
    199             input_item_GetTitle( p_item ) : p_item->psz_name ); 
    200         TagLib::String *psz_title = new TagLib::String( psz_titlec, 
     196        char *psz_meta; 
     197 
     198        psz_meta = input_item_GetArtist( p_item ); 
     199        SET( Artist, psz_meta ); 
     200        free( psz_meta ); 
     201 
     202        psz_meta = input_item_GetTitle( p_item ); 
     203        if( !psz_meta ) psz_meta = input_item_GetName( p_item ); 
     204        TagLib::String *psz_title = new TagLib::String( psz_meta, 
    201205            TagLib::String::UTF8 ); 
    202206        tag->setTitle( *psz_title ); 
    203207        delete psz_title; 
    204  
    205         SET( Album, input_item_GetAlbum( p_item ) ); 
    206         SET( Genre, input_item_GetGenre( p_item ) ); 
    207  
    208         if( input_item_GetDate( p_item ) ) 
    209             tag->setYear( atoi( input_item_GetDate( p_item ) ) ); 
    210         if( input_item_GetTrackNum( p_item ) ) 
    211             tag->setTrack( atoi( input_item_GetTrackNum( p_item ) ) ); 
     208        free( psz_meta ); 
     209 
     210        psz_meta = input_item_GetAlbum( p_item ); 
     211        SET( Album, psz_meta ); 
     212        free( psz_meta ); 
     213 
     214        psz_meta = input_item_GetGenre( p_item ); 
     215        SET( Genre, psz_meta ); 
     216        free( psz_meta ); 
     217 
     218        psz_meta = input_item_GetDate( p_item ); 
     219        if( psz_meta ) tag->setYear( atoi( psz_meta ) ); 
     220        free( psz_meta ); 
     221 
     222        psz_meta = input_item_GetTrackNum( p_item ); 
     223        if( psz_meta ) tag->setTrack( atoi( psz_meta ) ); 
     224        free( psz_meta ); 
    212225 
    213226        f.save(); 
  • modules/misc/audioscrobbler.c

    r51880eb r38dbd37  
    631631    p_sys->p_current_song->time_playing = epoch; 
    632632 
    633     p_sys->b_paused = ( p_input->b_dead || !input_GetItem(p_input)->psz_name ) 
     633    char *psz_name = input_item_GetName( input_GetItem( p_input ) ); 
     634    p_sys->b_paused = ( p_input->b_dead || !psz_name ) 
    634635                      ? VLC_TRUE : VLC_FALSE; 
     636    free( psz_name ); 
    635637 
    636638    vlc_mutex_unlock( &p_sys->lock ); 
     
    10041006    var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &video_val, NULL ); 
    10051007    if( ( video_val.i_int > 0 ) || \ 
    1006         ( input_GetItem(p_input)->i_type == ITEM_TYPE_NET ) ) 
     1008        ( input_GetItem( p_input )->i_type == ITEM_TYPE_NET ) ) 
    10071009    { 
    10081010        msg_Dbg( p_this, "Not an audio only local file -> no submission"); 
     
    10391041        } 
    10401042 
     1043    char *psz_meta; 
    10411044    #define ALLOC_ITEM_META( a, b ) \ 
    1042         if ( input_item_Get##b( input_GetItem(p_input) ) ) \ 
     1045        psz_meta = input_item_Get##b( input_GetItem( p_input ) ) \ 
     1046        if( psz_meta ) \ 
    10431047        { \ 
    1044             a = encode_URI_component( \ 
    1045                 input_item_Get##b( input_GetItem(p_input) )); \ 
     1048            a = encode_URI_component( psz_meta ); \ 
    10461049            if( !a ) \ 
    10471050            { \ 
     1051                free( psz_meta ); \ 
    10481052                FREE_INPUT_AND_CHARS \ 
    10491053                return VLC_ENOMEM; \ 
    10501054            } \ 
     1055            free( psz_meta ); \ 
    10511056        } 
    10521057 
     
    10651070            WAIT_METADATA_FETCHING( psz_artist ) 
    10661071        } 
    1067  
    1068         if( input_GetItem(p_input)->psz_name
     1072        psz_meta = input_item_GetName( input_GetItem( p_input ) ); 
     1073        if( psz_meta
    10691074        { 
    1070             psz_title = encode_URI_component( input_GetItem(p_input)->psz_name ); 
     1075            psz_title = encode_URI_component( psz_meta ); 
    10711076            if( !psz_title ) 
    10721077            { 
     1078                free( psz_meta ); 
    10731079                FREE_INPUT_AND_CHARS 
    10741080                return VLC_ENOMEM; 
    10751081            } 
     1082            free( psz_meta ); 
    10761083        } 
    10771084        else 
  • src/control/media_descriptor.c

    r728d281 r38dbd37  
    277277                                         libvlc_exception_t *p_e ) 
    278278{ 
    279     const char * psz_meta; 
     279    char * psz_meta; 
    280280 
    281281    /* XXX: locking */ 
     
    288288    /* Should be integrated in core */ 
    289289    if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name ) 
     290    { 
     291        free( psz_meta ); 
    290292        return strdup( p_md->p_input_item->psz_name ); 
     293    } 
    291294 
    292295    if( !psz_meta ) 
    293         return NULL; 
    294  
    295     return strdup( psz_meta ); 
    296 
    297  
     296    { 
     297        free( psz_meta ); 
     298        return NULL 
     299    } 
     300 
     301    return psz_meta; 
     302
     303 
  • src/playlist/search.c

    r51880eb r38dbd37  
    121121            playlist_LiveSearchUpdate( p_playlist, p_item, psz_string ); 
    122122        } 
    123 #define META_MATCHES( field ) ( input_item_GetMeta( p_item->p_input, vlc_meta_##field ) && \ 
    124                                 strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_##field ), psz_string ) ) 
    125123        else 
    126124        { 
    127             if( strcasestr( p_item->p_input->psz_name, psz_string ) || 
    128                 META_MATCHES( Artist ) || META_MATCHES( Album ) ) 
     125            char *psz_name_matches, *psz_artist_matches, *psz_album_matches; 
     126            char *psz_field, *psz_field_case; 
     127 
     128            psz_field = input_item_GetName( p_i ); 
     129            psz_name_matches = strcasestr( psz_field, psz_string ); 
     130            free( psz_field ); 
     131 
     132            psz_field = input_item_GetMeta( p_item->p_input, vlc_meta_Artist ); 
     133            psz_field_case = strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_Artist ), psz_string ); 
     134            psz_artist_matches = ( psz_field && psz_field_case ); 
     135            free( psz_field ); 
     136            free( psz_field_case ); 
     137 
     138 
     139            psz_field = input_item_GetMeta( p_item->p_input, vlc_meta_Album ); 
     140            psz_field_case = strcasestr( input_item_GetMeta( p_item->p_input, vlc_meta_Album ), psz_string ); 
     141            psz_album_matches = ( psz_field && psz_field_case ); 
     142            free( psz_field ); 
     143            free( psz_field_case ); 
     144 
     145            if( psz_name_matches || psz_artist_matches || psz_album_matches ) 
    129146                p_item->i_flags &= ~PLAYLIST_DBL_FLAG; 
    130147            else 
  • src/playlist/sort.c

    r51880eb r38dbd37  
    106106 
    107107#define DO_META_SORT( node ) { \ 
    108     const char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \ 
    109     const char *psz_b = input_item_GetMeta( pp_items[i_small]->p_input, vlc_meta_##node ); \ 
     108    char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \ 
     109    char *psz_b = input_item_GetMeta( pp_items[i_small]->p_input, vlc_meta_##node ); \ 
    110110    /* Nodes go first */ \ 
    111111    if( pp_items[i]->i_children == -1 && pp_items[i_small]->i_children >= 0 ) \ 
     
    199199        pp_items[i_small] = p_temp; 
    200200    } 
     201    free( psz_a ); 
     202    free( psz_b ); 
    201203    return VLC_SUCCESS; 
    202204}