Changeset 2d90e869b49fc72111a61ee715aa081fc92d169a
- Timestamp:
- 25/09/06 00:01:28
(2 years ago)
- Author:
- Antoine Cellerier <dionoea@videolan.org>
- git-committer:
- Antoine Cellerier <dionoea@videolan.org> 1159135288 +0000
- git-parent:
[e398a81bd261feaada934e7b402b5fed57646593]
- git-author:
- Antoine Cellerier <dionoea@videolan.org> 1159135288 +0000
- Message:
Some more (mostly) untested stuff:
- Secondary queue items now have a b_fetch_art flag
- You can use the playlist_AskForArtEnqueue function to ask for art from an interface. This will enqueue at the begining of the secondary queue
- other stuff which i don't remember :)
- (fix issues with previous (and unrelated) DIR_SEP commit)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rf17e985 |
r2d90e86 |
|
| 238 | 238 | typedef struct playlist_add_t playlist_add_t; |
|---|
| 239 | 239 | typedef struct playlist_preparse_t playlist_preparse_t; |
|---|
| | 240 | typedef struct playlist_secondary_preparse_t playlist_secondary_preparse_t; |
|---|
| 240 | 241 | |
|---|
| 241 | 242 | /* Modules */ |
|---|
| … | … | |
| 1281 | 1282 | |
|---|
| 1282 | 1283 | #if defined( WIN32 ) || defined( UNDER_CE ) |
|---|
| | 1284 | # define DIR_SEP_CHAR '\\' |
|---|
| 1283 | 1285 | # define DIR_SEP "\\" |
|---|
| 1284 | 1286 | #else |
|---|
| | 1287 | # define DIR_SEP_CHAR '/' |
|---|
| 1285 | 1288 | # define DIR_SEP "/" |
|---|
| 1286 | 1289 | #endif |
|---|
| re398a81 |
r2d90e86 |
|
| 477 | 477 | #define input_MetaFetch(a,b) __input_MetaFetch(VLC_OBJECT(a),b) |
|---|
| 478 | 478 | VLC_EXPORT( int, __input_MetaFetch, ( vlc_object_t *, input_item_t * ) ); |
|---|
| | 479 | #define input_ArtFetch(a,b) __input_ArtFetch(VLC_OBJECT(a),b) |
|---|
| | 480 | VLC_EXPORT( int, __input_ArtFetch, ( vlc_object_t *, input_item_t * ) ); |
|---|
| 479 | 481 | |
|---|
| 480 | 482 | enum input_query_e |
|---|
| r5601054 |
r2d90e86 |
|
| 146 | 146 | mtime_t i_sout_destroyed_date; |
|---|
| 147 | 147 | playlist_preparse_t *p_preparse; /**< Preparser object */ |
|---|
| 148 | | playlist_preparse_t *p_secondary_preparse; /**< Preparser object */ |
|---|
| | 148 | playlist_secondary_preparse_t *p_secondary_preparse;/**< Preparser object */ |
|---|
| 149 | 149 | |
|---|
| 150 | 150 | vlc_mutex_t gc_lock; /**< Lock to protect the garbage collection */ |
|---|
| … | … | |
| 238 | 238 | VLC_EXPORT( int, playlist_PreparseEnqueue, (playlist_t *, input_item_t *) ); |
|---|
| 239 | 239 | VLC_EXPORT( int, playlist_PreparseEnqueueItem, (playlist_t *, playlist_item_t *) ); |
|---|
| | 240 | VLC_EXPORT( int, playlist_AskForArtEnqueue, (playlist_t *, input_item_t *) ); |
|---|
| 240 | 241 | |
|---|
| 241 | 242 | /* Services discovery */ |
|---|
| re398a81 |
r2d90e86 |
|
| 547 | 547 | int (*input_DownloadAndCacheArt_inner) (vlc_object_t *p_parent, input_item_t *p_item); |
|---|
| 548 | 548 | uint32_t (*input_GetMetaEngineFlags_inner) (vlc_meta_t *p_meta); |
|---|
| | 549 | int (*__input_ArtFetch_inner) (vlc_object_t *, input_item_t *); |
|---|
| | 550 | void *input_AskForArt_deprecated; |
|---|
| | 551 | int (*playlist_AskForArtEnqueue_inner) (playlist_t *, input_item_t *); |
|---|
| 549 | 552 | }; |
|---|
| 550 | 553 | # if defined (__PLUGIN__) |
|---|
| … | … | |
| 1023 | 1026 | # define input_DownloadAndCacheArt (p_symbols)->input_DownloadAndCacheArt_inner |
|---|
| 1024 | 1027 | # define input_GetMetaEngineFlags (p_symbols)->input_GetMetaEngineFlags_inner |
|---|
| | 1028 | # define __input_ArtFetch (p_symbols)->__input_ArtFetch_inner |
|---|
| | 1029 | # define playlist_AskForArtEnqueue (p_symbols)->playlist_AskForArtEnqueue_inner |
|---|
| 1025 | 1030 | # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) |
|---|
| 1026 | 1031 | /****************************************************************** |
|---|
| … | … | |
| 1502 | 1507 | ((p_symbols)->input_DownloadAndCacheArt_inner) = input_DownloadAndCacheArt; \ |
|---|
| 1503 | 1508 | ((p_symbols)->input_GetMetaEngineFlags_inner) = input_GetMetaEngineFlags; \ |
|---|
| | 1509 | ((p_symbols)->__input_ArtFetch_inner) = __input_ArtFetch; \ |
|---|
| | 1510 | ((p_symbols)->playlist_AskForArtEnqueue_inner) = playlist_AskForArtEnqueue; \ |
|---|
| 1504 | 1511 | (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ |
|---|
| 1505 | 1512 | (p_symbols)->vlc_input_item_GetInfo_deprecated = NULL; \ |
|---|
| … | … | |
| 1555 | 1562 | (p_symbols)->streaming_ChainToPsz_deprecated = NULL; \ |
|---|
| 1556 | 1563 | (p_symbols)->__input_SecondaryPreparse_deprecated = NULL; \ |
|---|
| | 1564 | (p_symbols)->input_AskForArt_deprecated = NULL; \ |
|---|
| 1557 | 1565 | |
|---|
| 1558 | 1566 | # endif /* __PLUGIN__ */ |
|---|
| re398a81 |
r2d90e86 |
|
| 33 | 33 | #endif |
|---|
| 34 | 34 | |
|---|
| 35 | | int input_FindArt( vlc_object_t *p_parent, input_item_t *p_item ); |
|---|
| | 35 | int input_FindArtInCache( vlc_object_t *p_parent, input_item_t *p_item ); |
|---|
| 36 | 36 | |
|---|
| 37 | 37 | int __input_MetaFetch( vlc_object_t *p_parent, input_item_t *p_item ) |
|---|
| … | … | |
| 56 | 56 | } |
|---|
| 57 | 57 | |
|---|
| 58 | | input_FindArt( p_parent, p_item ); |
|---|
| | 58 | input_FindArtInCache( p_parent, p_item ); |
|---|
| 59 | 59 | |
|---|
| 60 | 60 | i_meta = input_GetMetaEngineFlags( p_item->p_meta ); |
|---|
| … | … | |
| 88 | 88 | } |
|---|
| 89 | 89 | |
|---|
| | 90 | int __input_ArtFetch( vlc_object_t *p_parent, input_item_t *p_item ) |
|---|
| | 91 | { |
|---|
| | 92 | if( !p_item->p_meta ) |
|---|
| | 93 | return VLC_EGENERIC; |
|---|
| | 94 | |
|---|
| | 95 | /* TODO: call art fetcher modules */ |
|---|
| | 96 | |
|---|
| | 97 | if( !p_item->p_meta->psz_arturl || !*p_item->p_meta->psz_arturl ) |
|---|
| | 98 | return VLC_EGENERIC; |
|---|
| | 99 | |
|---|
| | 100 | if( strncmp( "file://", p_item->p_meta->psz_arturl, 7 ) ) |
|---|
| | 101 | { |
|---|
| | 102 | return input_DownloadAndCacheArt( p_parent, p_item ); |
|---|
| | 103 | } |
|---|
| | 104 | return VLC_SUCCESS; |
|---|
| | 105 | } |
|---|
| | 106 | |
|---|
| 90 | 107 | #ifndef MAX_PATH |
|---|
| 91 | 108 | # define MAX_PATH 250 |
|---|
| 92 | 109 | #endif |
|---|
| 93 | | int input_FindArt( vlc_object_t *p_parent, input_item_t *p_item ) |
|---|
| | 110 | int input_FindArtInCache( vlc_object_t *p_parent, input_item_t *p_item ) |
|---|
| 94 | 111 | { |
|---|
| 95 | 112 | char *psz_artist; |
|---|
| 96 | 113 | char *psz_album; |
|---|
| 97 | | char *psz_type; |
|---|
| 98 | 114 | char psz_filename[MAX_PATH]; |
|---|
| 99 | 115 | int i; |
|---|
| 100 | 116 | struct stat a; |
|---|
| 101 | | const char ppsz_type[] = { ".jpg", ".png", ".gif", ".bmp", "" }; |
|---|
| | 117 | const char *ppsz_type[] = { ".jpg", ".png", ".gif", ".bmp", "" }; |
|---|
| 102 | 118 | |
|---|
| 103 | 119 | if( !p_item->p_meta ) return VLC_EGENERIC; |
|---|
| … | … | |
| 112 | 128 | DIR_SEP "%s" DIR_SEP "%s" DIR_SEP "art%s", |
|---|
| 113 | 129 | p_parent->p_libvlc->psz_homedir, |
|---|
| 114 | | psz_artist, psz_album, psz_type ); |
|---|
| | 130 | psz_artist, psz_album, ppsz_type[i] ); |
|---|
| 115 | 131 | |
|---|
| 116 | 132 | /* Check if file exists */ |
|---|
| … | … | |
| 119 | 135 | msg_Dbg( p_parent, "album art %s already exists in cache" |
|---|
| 120 | 136 | , psz_filename ); |
|---|
| | 137 | vlc_meta_SetArtURL( p_item->p_meta, psz_filename ); |
|---|
| 121 | 138 | return VLC_SUCCESS; |
|---|
| 122 | 139 | } |
|---|
| re398a81 |
r2d90e86 |
|
| 223 | 223 | psz_subdir, |
|---|
| 224 | 224 | psz_subdir[strlen(psz_subdir) - 1] == |
|---|
| 225 | | DIR_SEP ? '\0' : DIR_SEP ); |
|---|
| | 225 | DIR_SEP_CHAR ? '\0' : DIR_SEP_CHAR ); |
|---|
| 226 | 226 | subdirs[i] = psz_temp; |
|---|
| 227 | 227 | i++; |
|---|
| … | … | |
| 278 | 278 | |
|---|
| 279 | 279 | /* extract filename & dirname from psz_fname */ |
|---|
| 280 | | tmp = strrchr( psz_fname, DIR_SEP ); |
|---|
| | 280 | tmp = strrchr( psz_fname, DIR_SEP_CHAR ); |
|---|
| 281 | 281 | if( tmp ) |
|---|
| 282 | 282 | { |
|---|
| … | … | |
| 305 | 305 | dirlen = strlen( f_dir ); |
|---|
| 306 | 306 | f_dir = (char *)realloc(f_dir, dirlen +2 ); |
|---|
| 307 | | f_dir[dirlen] = DIR_SEP; |
|---|
| | 307 | f_dir[dirlen] = DIR_SEP_CHAR; |
|---|
| 308 | 308 | f_dir[dirlen+1] = '\0'; |
|---|
| 309 | 309 | f_fname = FromLocaleDup( psz_fname ); |
|---|
| r5601054 |
r2d90e86 |
|
| 215 | 215 | } |
|---|
| 216 | 216 | |
|---|
| | 217 | int playlist_AskForArtEnqueue( playlist_t *p_playlist, |
|---|
| | 218 | input_item_t *p_item ) |
|---|
| | 219 | { |
|---|
| | 220 | int i; |
|---|
| | 221 | preparse_item_t p; |
|---|
| | 222 | p.p_item = p_item; |
|---|
| | 223 | p.b_fetch_art = VLC_TRUE; |
|---|
| | 224 | |
|---|
| | 225 | vlc_mutex_lock( &p_playlist->p_secondary_preparse->object_lock ); |
|---|
| | 226 | for( i = 0; i < p_playlist->p_secondary_preparse->i_waiting && |
|---|
| | 227 | p_playlist->p_secondary_preparse->p_waiting->b_fetch_art == VLC_TRUE; |
|---|
| | 228 | i++ ); |
|---|
| | 229 | vlc_gc_incref( p_item ); |
|---|
| | 230 | INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting, |
|---|
| | 231 | p_playlist->p_secondary_preparse->i_waiting, |
|---|
| | 232 | i, |
|---|
| | 233 | p ); |
|---|
| | 234 | vlc_mutex_unlock( &p_playlist->p_secondary_preparse->object_lock ); |
|---|
| | 235 | return VLC_SUCCESS; |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| 217 | 238 | void PreparseEnqueueItemSub( playlist_t *p_playlist, |
|---|
| 218 | 239 | playlist_item_t *p_item ) |
|---|
| rbd3484b |
r2d90e86 |
|
| 460 | 460 | { |
|---|
| 461 | 461 | vlc_bool_t b_preparsed = VLC_FALSE; |
|---|
| | 462 | preparse_item_t p; |
|---|
| 462 | 463 | if( strncmp( p_current->psz_uri, "http:", 5 ) && |
|---|
| 463 | 464 | strncmp( p_current->psz_uri, "rtsp:", 5 ) && |
|---|
| … | … | |
| 489 | 490 | * - don't do this for things we won't get meta for, like |
|---|
| 490 | 491 | * videos |
|---|
| | 492 | * -> done in input_MetaFetch atm |
|---|
| 491 | 493 | */ |
|---|
| 492 | | if( !(p_current->p_meta->psz_title && *p_current->p_meta->psz_title |
|---|
| | 494 | /*if( !(p_current->p_meta->psz_title && *p_current->p_meta->psz_title |
|---|
| 493 | 495 | && p_current->p_meta->psz_artist && |
|---|
| 494 | 496 | *p_current->p_meta->psz_artist) ) |
|---|
| 495 | | { |
|---|
| | 497 | {*/ |
|---|
| | 498 | p.p_item = p_current; |
|---|
| | 499 | p.b_fetch_art = VLC_FALSE; |
|---|
| 496 | 500 | vlc_mutex_lock( &p_playlist->p_secondary_preparse->object_lock); |
|---|
| 497 | | INSERT_ELEM( p_playlist->p_secondary_preparse->pp_waiting, |
|---|
| | 501 | INSERT_ELEM( p_playlist->p_secondary_preparse->p_waiting, |
|---|
| 498 | 502 | p_playlist->p_secondary_preparse->i_waiting, |
|---|
| 499 | 503 | p_playlist->p_secondary_preparse->i_waiting, |
|---|
| 500 | | p_current ); |
|---|
| | 504 | p ); |
|---|
| 501 | 505 | vlc_mutex_unlock( |
|---|
| 502 | 506 | &p_playlist->p_secondary_preparse->object_lock); |
|---|
| 503 | | } |
|---|
| | 507 | /*} |
|---|
| 504 | 508 | else |
|---|
| 505 | | vlc_gc_decref( p_current ); |
|---|
| | 509 | vlc_gc_decref( p_current );*/ |
|---|
| 506 | 510 | PL_UNLOCK; |
|---|
| 507 | 511 | } |
|---|
| … | … | |
| 520 | 524 | |
|---|
| 521 | 525 | /** Main loop for secondary preparser queue */ |
|---|
| 522 | | void playlist_SecondaryPreparseLoop( playlist_preparse_t *p_obj ) |
|---|
| | 526 | void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t *p_obj ) |
|---|
| 523 | 527 | { |
|---|
| 524 | 528 | playlist_t *p_playlist = (playlist_t *)p_obj->p_parent; |
|---|
| … | … | |
| 528 | 532 | if( p_obj->i_waiting > 0 ) |
|---|
| 529 | 533 | { |
|---|
| 530 | | input_item_t *p_current = p_obj->pp_waiting[0]; |
|---|
| 531 | | REMOVE_ELEM( p_obj->pp_waiting, p_obj->i_waiting, 0 ); |
|---|
| | 534 | vlc_bool_t b_fetch_art = p_obj->p_waiting->b_fetch_art; |
|---|
| | 535 | input_item_t *p_item = p_obj->p_waiting->p_item; |
|---|
| | 536 | REMOVE_ELEM( p_obj->p_waiting, p_obj->i_waiting, 0 ); |
|---|
| 532 | 537 | vlc_mutex_unlock( &p_obj->object_lock ); |
|---|
| 533 | | if( p_current ) |
|---|
| 534 | | { |
|---|
| 535 | | input_MetaFetch( p_playlist, p_current ); |
|---|
| 536 | | p_current->p_meta->i_status |= ITEM_META_FETCHED; |
|---|
| 537 | | var_SetInteger( p_playlist, "item-change", p_current->i_id ); |
|---|
| 538 | | vlc_gc_decref( p_current ); |
|---|
| | 538 | if( p_item ) |
|---|
| | 539 | { |
|---|
| | 540 | input_MetaFetch( p_playlist, p_item ); |
|---|
| | 541 | p_item->p_meta->i_status |= ITEM_META_FETCHED; |
|---|
| | 542 | if( b_fetch_art == VLC_TRUE ) |
|---|
| | 543 | { |
|---|
| | 544 | input_ArtFetch( p_playlist, p_item ); |
|---|
| | 545 | p_item->p_meta->i_status |= ITEM_ART_FETCHED; |
|---|
| | 546 | } |
|---|
| | 547 | var_SetInteger( p_playlist, "item-change", p_item->i_id ); |
|---|
| | 548 | vlc_gc_decref( p_item ); |
|---|
| 539 | 549 | } |
|---|
| 540 | 550 | else |
|---|
| r5601054 |
r2d90e86 |
|
| 40 | 40 | }; |
|---|
| 41 | 41 | |
|---|
| | 42 | typedef struct preparse_item_t |
|---|
| | 43 | { |
|---|
| | 44 | input_item_t *p_item; |
|---|
| | 45 | vlc_bool_t b_fetch_art; |
|---|
| | 46 | } preparse_item_t; |
|---|
| | 47 | |
|---|
| | 48 | struct playlist_secondary_preparse_t |
|---|
| | 49 | { |
|---|
| | 50 | VLC_COMMON_MEMBERS |
|---|
| | 51 | vlc_mutex_t lock; |
|---|
| | 52 | int i_waiting; |
|---|
| | 53 | preparse_item_t *p_waiting; |
|---|
| | 54 | }; |
|---|
| 42 | 55 | |
|---|
| 43 | 56 | /***************************************************************************** |
|---|
| … | … | |
| 53 | 66 | void playlist_LastLoop( playlist_t * ); |
|---|
| 54 | 67 | void playlist_PreparseLoop( playlist_preparse_t * ); |
|---|
| 55 | | void playlist_SecondaryPreparseLoop( playlist_preparse_t * ); |
|---|
| | 68 | void playlist_SecondaryPreparseLoop( playlist_secondary_preparse_t * ); |
|---|
| 56 | 69 | |
|---|
| 57 | 70 | /* Control */ |
|---|
| r5601054 |
r2d90e86 |
|
| 34 | 34 | static void RunControlThread ( playlist_t * ); |
|---|
| 35 | 35 | static void RunPreparse( playlist_preparse_t * ); |
|---|
| 36 | | static void RunSecondaryPreparse( playlist_preparse_t * ); |
|---|
| | 36 | static void RunSecondaryPreparse( playlist_secondary_preparse_t * ); |
|---|
| 37 | 37 | |
|---|
| 38 | 38 | static playlist_t * CreatePlaylist( vlc_object_t *p_parent ); |
|---|
| … | … | |
| 97 | 97 | // Secondary Preparse |
|---|
| 98 | 98 | p_playlist->p_secondary_preparse = vlc_object_create( p_playlist, |
|---|
| 99 | | sizeof( playlist_preparse_t ) ); |
|---|
| | 99 | sizeof( playlist_secondary_preparse_t ) ); |
|---|
| 100 | 100 | if( !p_playlist->p_secondary_preparse ) |
|---|
| 101 | 101 | { |
|---|
| … | … | |
| 105 | 105 | } |
|---|
| 106 | 106 | p_playlist->p_secondary_preparse->i_waiting = 0; |
|---|
| 107 | | p_playlist->p_secondary_preparse->pp_waiting = NULL; |
|---|
| | 107 | p_playlist->p_secondary_preparse->p_waiting = NULL; |
|---|
| 108 | 108 | |
|---|
| 109 | 109 | vlc_object_attach( p_playlist->p_secondary_preparse, p_playlist ); |
|---|
| … | … | |
| 219 | 219 | } |
|---|
| 220 | 220 | |
|---|
| 221 | | static void RunSecondaryPreparse( playlist_preparse_t *p_obj ) |
|---|
| | 221 | static void RunSecondaryPreparse( playlist_secondary_preparse_t *p_obj ) |
|---|
| 222 | 222 | { |
|---|
| 223 | 223 | playlist_t *p_playlist = (playlist_t *)p_obj->p_parent; |
|---|