Changeset 662ed774b9740eabf8b0203e53f51e6c35657e0d
- Timestamp:
- 18/08/07 16:59:31
(1 year ago)
- Author:
- Rafaël Carré <funman@videolan.org>
- git-committer:
- Rafaël Carré <funman@videolan.org> 1187449171 +0000
- git-parent:
[a387a1ff337681b34c749ac762338ac673254574]
- git-author:
- Rafaël Carré <funman@videolan.org> 1187449171 +0000
- Message:
Input access locking, part 2.
Fix [21193]
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r07c9227 |
r662ed77 |
|
| 27 | 27 | #endif |
|---|
| 28 | 28 | |
|---|
| | 29 | #ifndef __USE_GNU |
|---|
| | 30 | #define __USE_GNU |
|---|
| | 31 | #endif |
|---|
| | 32 | #include <string.h> /* strcasestr() */ |
|---|
| | 33 | |
|---|
| 29 | 34 | /* __ is need because conflict with <vlc/input.h> */ |
|---|
| 30 | 35 | #ifndef _VLC__INPUT_H |
|---|
| … | … | |
| 223 | 228 | vlc_event_t event; |
|---|
| 224 | 229 | |
|---|
| 225 | | //vlc_mutex_lock( &p_i->lock ); |
|---|
| | 230 | vlc_mutex_lock( &p_i->lock ); |
|---|
| 226 | 231 | if( !p_i->p_meta ) |
|---|
| 227 | 232 | p_i->p_meta = vlc_meta_New(); |
|---|
| 228 | 233 | vlc_meta_Set( p_i->p_meta, meta_type, psz_val ); |
|---|
| 229 | | //vlc_mutex_unlock( &p_i->lock ); |
|---|
| | 234 | vlc_mutex_unlock( &p_i->lock ); |
|---|
| 230 | 235 | |
|---|
| 231 | 236 | /* Notify interested third parties */ |
|---|
| … | … | |
| 237 | 242 | static inline vlc_bool_t input_item_MetaMatch( input_item_t *p_i, vlc_meta_type_t meta_type, const char *psz ) |
|---|
| 238 | 243 | { |
|---|
| 239 | | //vlc_mutex_lock( &p_i->lock ); |
|---|
| | 244 | vlc_mutex_lock( &p_i->lock ); |
|---|
| 240 | 245 | const char * meta = vlc_meta_Get( p_i->p_meta, meta_type ); |
|---|
| 241 | 246 | vlc_bool_t ret = meta && strcasestr( meta, psz ); |
|---|
| 242 | | //vlc_mutex_unlock( &p_i->lock ); |
|---|
| | 247 | vlc_mutex_unlock( &p_i->lock ); |
|---|
| 243 | 248 | |
|---|
| 244 | 249 | return ret; |
|---|
| … | … | |
| 248 | 253 | { |
|---|
| 249 | 254 | char * psz = NULL; |
|---|
| 250 | | //vlc_mutex_lock( &p_i->lock ); |
|---|
| | 255 | vlc_mutex_lock( &p_i->lock ); |
|---|
| 251 | 256 | |
|---|
| 252 | 257 | if( !p_i->p_meta ) |
|---|
| 253 | 258 | { |
|---|
| 254 | | //vlc_mutex_unlock( &p_i->lock ); |
|---|
| | 259 | vlc_mutex_unlock( &p_i->lock ); |
|---|
| 255 | 260 | return NULL; |
|---|
| 256 | 261 | } |
|---|
| … | … | |
| 259 | 264 | psz = strdup( vlc_meta_Get( p_i->p_meta, meta_type ) ); |
|---|
| 260 | 265 | |
|---|
| 261 | | //vlc_mutex_unlock( &p_i->lock ); |
|---|
| | 266 | vlc_mutex_unlock( &p_i->lock ); |
|---|
| 262 | 267 | return psz; |
|---|
| 263 | 268 | } |
|---|
| … | … | |
| 265 | 270 | static inline char * input_item_GetName( input_item_t * p_i ) |
|---|
| 266 | 271 | { |
|---|
| 267 | | //vlc_mutex_lock( &p_i->lock ); |
|---|
| | 272 | vlc_mutex_lock( &p_i->lock ); |
|---|
| 268 | 273 | char *psz_s = p_i->psz_name ? strdup( p_i->psz_name ) : NULL; |
|---|
| 269 | | //vlc_mutex_unlock( &p_i->lock ); |
|---|
| | 274 | vlc_mutex_unlock( &p_i->lock ); |
|---|
| 270 | 275 | return psz_s; |
|---|
| 271 | 276 | } |
|---|
| r51880eb |
r662ed77 |
|
| 125 | 125 | vlc_object_yield( p_input ); |
|---|
| 126 | 126 | |
|---|
| 127 | | if( p_input->b_dead || !input_GetItem(p_input)->psz_name ) |
|---|
| | 127 | char *psz_name = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| | 128 | if( p_input->b_dead || !psz_name ) |
|---|
| 128 | 129 | { |
|---|
| 129 | 130 | /* Not playing anything ... */ |
|---|
| | 131 | free( psz_name ); |
|---|
| 130 | 132 | vlc_object_release( p_input ); |
|---|
| 131 | 133 | return VLC_SUCCESS; |
|---|
| 132 | 134 | } |
|---|
| | 135 | free( psz_name ); |
|---|
| 133 | 136 | |
|---|
| 134 | 137 | /* Playing something ... */ |
|---|
| 135 | | psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ? |
|---|
| 136 | | strdup( input_item_GetArtist( input_GetItem(p_input) ) ) : |
|---|
| 137 | | strdup( "" ); |
|---|
| 138 | | psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ? |
|---|
| 139 | | strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) : |
|---|
| 140 | | strdup("" ); |
|---|
| 141 | | psz_title = strdup( input_GetItem(p_input)->psz_name ); |
|---|
| | 138 | psz_artist = input_item_GetArtist( input_GetItem( p_input ) ); |
|---|
| | 139 | if( psz_artist == NULL ) psz_artist = strdup( "" ); |
|---|
| | 140 | psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ; |
|---|
| | 141 | if( psz_album == NULL ) psz_album = strdup( "" ); |
|---|
| | 142 | psz_title = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| 142 | 143 | if( psz_title == NULL ) psz_title = strdup( N_("(no title)") ); |
|---|
| 143 | 144 | snprintf( psz_tmp, GROWL_MAX_LENGTH, "%s %s %s", |
|---|
| r51880eb |
r662ed77 |
|
| 151 | 151 | |
|---|
| 152 | 152 | /* Playing something ... */ |
|---|
| 153 | | psz_artist = input_item_GetArtist( input_GetItem(p_input) ) ? |
|---|
| 154 | | strdup( input_item_GetArtist( input_GetItem(p_input) ) ) : |
|---|
| 155 | | strdup( _("no artist") ); |
|---|
| 156 | | psz_album = input_item_GetAlbum( input_GetItem(p_input) ) ? |
|---|
| 157 | | strdup( input_item_GetAlbum( input_GetItem(p_input) ) ) : |
|---|
| 158 | | strdup( _("no album") ); |
|---|
| 159 | | psz_title = strdup( input_GetItem(p_input)->psz_name ); |
|---|
| | 153 | psz_artist = input_item_GetArtist( input_GetItem( p_input ) ); |
|---|
| | 154 | if( psz_artist == NULL ) psz_artist = strdup( _("no artist") ); |
|---|
| | 155 | psz_album = input_item_GetAlbum( input_GetItem( p_input ) ) ; |
|---|
| | 156 | if( psz_album == NULL ) psz_album = strdup( _("no album") ); |
|---|
| | 157 | psz_title = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| 160 | 158 | |
|---|
| 161 | 159 | vlc_object_release( p_input ); |
|---|
| r51880eb |
r662ed77 |
|
| 66 | 66 | |
|---|
| 67 | 67 | /* General info */ |
|---|
| 68 | | if( p_current->p_input->psz_name && |
|---|
| 69 | | strcmp( p_current->p_input->psz_uri, |
|---|
| 70 | | p_current->p_input->psz_name ) ) |
|---|
| | 68 | char *psz_name = input_item_GetName( p_current->p_input ); |
|---|
| | 69 | if( psz_name && strcmp( p_current->p_input->psz_uri, psz_name ) ) |
|---|
| 71 | 70 | { |
|---|
| 72 | | char *psz_artist = input_item_GetArtist( p_current->p_input ) ? |
|---|
| 73 | | strdup( input_item_GetArtist( p_current->p_input ) ): |
|---|
| 74 | | strdup( "" ); |
|---|
| | 71 | char *psz_artist = input_item_GetArtist( p_current->p_input ); |
|---|
| | 72 | if( psz_artist == NULL ) psz_artist = strdup( "" ); |
|---|
| 75 | 73 | if( psz_artist && *psz_artist ) |
|---|
| 76 | 74 | { |
|---|
| … | … | |
| 88 | 86 | p_current->p_input->psz_name); |
|---|
| 89 | 87 | } |
|---|
| 90 | | if( psz_artist ) |
|---|
| 91 | | free( psz_artist ); |
|---|
| | 88 | free( psz_artist ); |
|---|
| 92 | 89 | } |
|---|
| | 90 | free( psz_name ); |
|---|
| 93 | 91 | |
|---|
| 94 | 92 | /* VLC specific options */ |
|---|
| r51880eb |
r662ed77 |
|
| 164 | 164 | |
|---|
| 165 | 165 | /* -> the artist/creator */ |
|---|
| 166 | | psz = input_item_GetArtist( p_item->p_input ) ? |
|---|
| 167 | | strdup( input_item_GetArtist( p_item->p_input ) ): |
|---|
| 168 | | strdup( "" ); |
|---|
| | 166 | psz = input_item_GetArtist( p_item->p_input ); |
|---|
| | 167 | if( psz == NULL ) psz = strdup( "" ); |
|---|
| 169 | 168 | psz_temp = convert_xml_special_chars( psz ); |
|---|
| 170 | | if( psz ) free( psz ); |
|---|
| | 169 | free( psz ); |
|---|
| 171 | 170 | if( *psz_temp ) |
|---|
| 172 | 171 | { |
|---|
| … | … | |
| 176 | 175 | |
|---|
| 177 | 176 | /* -> the album */ |
|---|
| 178 | | psz = input_item_GetAlbum( p_item->p_input ) ? |
|---|
| 179 | | strdup( input_item_GetAlbum( p_item->p_input ) ): |
|---|
| 180 | | strdup( "" ); |
|---|
| | 177 | psz = input_item_GetAlbum( p_item->p_input ); |
|---|
| | 178 | if( psz == NULL ) psz = strdup( "" ); |
|---|
| 181 | 179 | psz_temp = convert_xml_special_chars( psz ); |
|---|
| 182 | | if( psz ) free( psz ); |
|---|
| | 180 | free( psz ); |
|---|
| 183 | 181 | if( *psz_temp ) |
|---|
| 184 | 182 | { |
|---|
| … | … | |
| 188 | 186 | |
|---|
| 189 | 187 | /* -> the track number */ |
|---|
| 190 | | psz = input_item_GetTrackNum( p_item->p_input ) ? |
|---|
| 191 | | strdup( input_item_GetTrackNum( p_item->p_input ) ): |
|---|
| 192 | | strdup( "" ); |
|---|
| | 188 | psz = input_item_GetTrackNum( p_item->p_input ); |
|---|
| | 189 | if( psz == NULL ) psz = strdup( "" ); |
|---|
| 193 | 190 | if( psz ) |
|---|
| 194 | 191 | { |
|---|
| … | … | |
| 197 | 194 | fprintf( p_file, "\t\t\t<trackNum>%i</trackNum>\n", atoi( psz ) ); |
|---|
| 198 | 195 | } |
|---|
| 199 | | free( psz ); |
|---|
| 200 | | } |
|---|
| | 196 | } |
|---|
| | 197 | free( psz ); |
|---|
| 201 | 198 | |
|---|
| 202 | 199 | /* -> the description */ |
|---|
| 203 | | psz = input_item_GetDescription( p_item->p_input ) ? |
|---|
| 204 | | strdup( input_item_GetDescription( p_item->p_input ) ): |
|---|
| 205 | | strdup( "" ); |
|---|
| | 200 | psz = input_item_GetDescription( p_item->p_input ); |
|---|
| | 201 | if( psz == NULL ) psz = strdup( "" ); |
|---|
| 206 | 202 | psz_temp = convert_xml_special_chars( psz ); |
|---|
| 207 | | if( psz ) free( psz ); |
|---|
| | 203 | free( psz ); |
|---|
| 208 | 204 | if( *psz_temp ) |
|---|
| 209 | 205 | { |
|---|
| r51880eb |
r662ed77 |
|
| 417 | 417 | if( p_input ) |
|---|
| 418 | 418 | { |
|---|
| 419 | | if( !EMPTY_STR( input_item_GetTitle( input_GetItem(p_input) ) ) ) |
|---|
| 420 | | { |
|---|
| 421 | | psz_title = strdup( input_item_GetTitle( input_GetItem(p_input) ) ); |
|---|
| 422 | | } |
|---|
| 423 | | else |
|---|
| 424 | | { |
|---|
| | 419 | psz_title = strdup( input_item_GetTitle( input_GetItem( p_input ) ) ); |
|---|
| | 420 | if( EMPTY_STR( psz_title ) ) |
|---|
| | 421 | { |
|---|
| | 422 | free( psz_title ); |
|---|
| 425 | 423 | char *psz = strrchr( input_GetItem(p_input)->psz_uri, '/' ); |
|---|
| 426 | 424 | |
|---|
| rfbc7ad6 |
r662ed77 |
|
| 153 | 153 | if( !p_cat ) |
|---|
| 154 | 154 | { |
|---|
| 155 | | vlc_mutex_lock( &p_input->p->input.p_item->lock ); |
|---|
| | 155 | vlc_mutex_unlock( &p_input->p->input.p_item->lock ); |
|---|
| 156 | 156 | return VLC_EGENERIC; |
|---|
| 157 | 157 | } |
|---|
| … | … | |
| 181 | 181 | if( !p_info ) |
|---|
| 182 | 182 | { |
|---|
| 183 | | vlc_mutex_lock( &p_input->p->input.p_item->lock ); |
|---|
| | 183 | vlc_mutex_unlock( &p_input->p->input.p_item->lock ); |
|---|
| 184 | 184 | return VLC_EGENERIC; |
|---|
| 185 | 185 | } |
|---|
| r51880eb |
r662ed77 |
|
| 488 | 488 | |
|---|
| 489 | 489 | /* Update now playing */ |
|---|
| 490 | | vlc_mutex_lock( &p_input->p->input.p_item->lock ); |
|---|
| 491 | 490 | input_item_SetNowPlaying( p_input->p->input.p_item, |
|---|
| 492 | 491 | p_pgrm->psz_now_playing ); |
|---|
| 493 | 492 | input_item_SetPublisher( p_input->p->input.p_item, |
|---|
| 494 | 493 | p_pgrm->psz_publisher ); |
|---|
| 495 | | vlc_mutex_unlock( &p_input->p->input.p_item->lock ); |
|---|
| 496 | 494 | |
|---|
| 497 | 495 | var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); |
|---|
| … | … | |
| 673 | 671 | { |
|---|
| 674 | 672 | if( p_sys->p_pgrm == p_pgrm ) |
|---|
| 675 | | { |
|---|
| 676 | | vlc_mutex_lock( &p_input->p->input.p_item->lock ); |
|---|
| 677 | 673 | input_item_SetPublisher( p_input->p->input.p_item, psz_provider ); |
|---|
| 678 | | vlc_mutex_unlock( &p_input->p->input.p_item->lock ); |
|---|
| 679 | | } |
|---|
| 680 | 674 | input_Control( p_input, INPUT_ADD_INFO, psz_cat, input_MetaTypeToLocalizedString(vlc_meta_Publisher), psz_provider ); |
|---|
| 681 | 675 | } |
|---|
| … | … | |
| 799 | 793 | p_pgrm->psz_now_playing = strdup( p_epg->p_current->psz_name ); |
|---|
| 800 | 794 | |
|---|
| 801 | | vlc_mutex_lock( &p_input->p->input.p_item->lock ); |
|---|
| 802 | 795 | if( p_pgrm == p_sys->p_pgrm ) |
|---|
| 803 | 796 | input_item_SetNowPlaying( p_input->p->input.p_item, p_pgrm->psz_now_playing ); |
|---|
| 804 | | vlc_mutex_unlock( &p_input->p->input.p_item->lock ); |
|---|
| 805 | 797 | |
|---|
| 806 | 798 | if( p_pgrm->psz_now_playing ) |
|---|
| rda8a2f9 |
r662ed77 |
|
| 255 | 255 | _(VLC_META_INFO_CAT), |
|---|
| 256 | 256 | _(VLC_META_NOW_PLAYING) ); |
|---|
| 257 | | vlc_mutex_lock( &p_item->lock ); |
|---|
| 258 | 257 | input_item_SetNowPlaying( p_item, NULL ); |
|---|
| 259 | | vlc_mutex_unlock( &p_item->lock ); |
|---|
| 260 | 258 | |
|---|
| 261 | 259 | /* */ |
|---|
| … | … | |
| 2506 | 2504 | { |
|---|
| 2507 | 2505 | input_item_t *p_item = p_input->p->input.p_item; |
|---|
| 2508 | | char * psz_saved_arturl = NULL; |
|---|
| 2509 | | const char * psz_arturl = NULL; |
|---|
| | 2506 | char * psz_arturl = NULL; |
|---|
| 2510 | 2507 | char *psz_title = NULL; |
|---|
| 2511 | 2508 | int i; |
|---|
| | 2509 | int i_arturl_event = VLC_FALSE; |
|---|
| 2512 | 2510 | |
|---|
| 2513 | 2511 | if( !p_meta ) |
|---|
| 2514 | 2512 | return; |
|---|
| | 2513 | |
|---|
| | 2514 | psz_arturl = input_item_GetArtURL( p_item ); |
|---|
| 2515 | 2515 | |
|---|
| 2516 | 2516 | vlc_mutex_lock( &p_item->lock ); |
|---|
| … | … | |
| 2518 | 2518 | psz_title = strdup( vlc_meta_Get( p_meta, vlc_meta_Title ) ); |
|---|
| 2519 | 2519 | |
|---|
| 2520 | | if( input_item_GetArtURL( p_item ) ) |
|---|
| 2521 | | psz_saved_arturl = strdup( input_item_GetArtURL( p_item ) ); |
|---|
| 2522 | | |
|---|
| 2523 | 2520 | vlc_meta_Merge( p_item->p_meta, p_meta ); |
|---|
| 2524 | 2521 | |
|---|
| 2525 | | if( psz_saved_arturl && *psz_saved_arturl ) |
|---|
| 2526 | | input_item_SetArtURL( p_item, psz_saved_arturl ); |
|---|
| 2527 | | |
|---|
| 2528 | | free( psz_saved_arturl ); |
|---|
| | 2522 | if( psz_arturl && *psz_arturl ) |
|---|
| | 2523 | { |
|---|
| | 2524 | vlc_meta_Set( p_item->p_meta, vlc_meta_ArtworkURL, psz_arturl ); |
|---|
| | 2525 | i_arturl_event = VLC_TRUE; |
|---|
| | 2526 | } |
|---|
| | 2527 | |
|---|
| 2529 | 2528 | vlc_meta_Delete( p_meta ); |
|---|
| 2530 | 2529 | |
|---|
| 2531 | | psz_arturl = input_item_GetArtURL( p_item ); |
|---|
| 2532 | 2530 | if( psz_arturl && !strncmp( psz_arturl, "attachment://", strlen("attachment") ) ) |
|---|
| 2533 | 2531 | { |
|---|
| … | … | |
| 2535 | 2533 | * XXX It can change when sout has meta data support */ |
|---|
| 2536 | 2534 | if( p_input->p->p_sout && !p_input->b_preparsing ) |
|---|
| 2537 | | input_item_SetArtURL( p_item, "" ); |
|---|
| | 2535 | { |
|---|
| | 2536 | vlc_meta_Set( p_item->p_meta, vlc_meta_ArtworkURL, "" ); |
|---|
| | 2537 | i_arturl_event = VLC_TRUE; |
|---|
| | 2538 | |
|---|
| | 2539 | } |
|---|
| 2538 | 2540 | else |
|---|
| 2539 | 2541 | input_ExtractAttachmentAndCacheArt( p_input ); |
|---|
| 2540 | 2542 | } |
|---|
| | 2543 | free( psz_arturl ); |
|---|
| 2541 | 2544 | |
|---|
| 2542 | 2545 | input_item_SetPreparsed( p_item, VLC_TRUE ); |
|---|
| … | … | |
| 2550 | 2553 | } |
|---|
| 2551 | 2554 | vlc_mutex_unlock( &p_item->lock ); |
|---|
| | 2555 | |
|---|
| | 2556 | if( i_arturl_event == VLC_TRUE ) |
|---|
| | 2557 | { |
|---|
| | 2558 | vlc_event_t event; |
|---|
| | 2559 | |
|---|
| | 2560 | /* Notify interested third parties */ |
|---|
| | 2561 | event.type = vlc_InputItemMetaChanged; |
|---|
| | 2562 | event.u.input_item_meta_changed.meta_type = vlc_meta_ArtworkURL; |
|---|
| | 2563 | vlc_event_send( &p_item->event_manager, &event ); |
|---|
| | 2564 | } |
|---|
| 2552 | 2565 | |
|---|
| 2553 | 2566 | if( psz_title ) |
|---|
| r72b9e70 |
r662ed77 |
|
| 120 | 120 | int i_ret = VLC_EGENERIC; |
|---|
| 121 | 121 | module_t *p_module; |
|---|
| | 122 | char *psz_name, *psz_title, *psz_artist, *psz_album; |
|---|
| 122 | 123 | |
|---|
| 123 | 124 | if( !p_item->p_meta ) |
|---|
| 124 | 125 | return VLC_EGENERIC; |
|---|
| 125 | 126 | |
|---|
| 126 | | if( !p_item->psz_name && !input_item_GetTitle( p_item ) && |
|---|
| 127 | | (!input_item_GetArtist( p_item ) || !input_item_GetAlbum( p_item )) ) |
|---|
| | 127 | psz_name = input_item_GetName( p_item ); |
|---|
| | 128 | psz_title = input_item_GetTitle( p_item ); |
|---|
| | 129 | psz_artist = input_item_GetArtist( p_item ); |
|---|
| | 130 | psz_album = input_item_GetAlbum( p_item ); |
|---|
| | 131 | |
|---|
| | 132 | if( !psz_name && !psz_title && !psz_artist && !psz_album ) |
|---|
| 128 | 133 | return VLC_EGENERIC; |
|---|
| | 134 | free( psz_name ); |
|---|
| | 135 | free( psz_title ); |
|---|
| 129 | 136 | |
|---|
| 130 | 137 | /* If we already checked this album in this session, skip */ |
|---|
| 131 | | if( input_item_GetArtist( p_item ) && input_item_GetAlbum( p_item ) ) |
|---|
| | 138 | if( psz_artist && psz_album ) |
|---|
| 132 | 139 | { |
|---|
| 133 | 140 | FOREACH_ARRAY( playlist_album_t album, p_playlist->p_fetcher->albums ) |
|---|
| 134 | | if( !strcmp( album.psz_artist, input_item_GetArtist( p_item ) ) && |
|---|
| 135 | | !strcmp( album.psz_album, input_item_GetAlbum( p_item ) ) ) |
|---|
| | 141 | if( !strcmp( album.psz_artist, psz_artist ) && |
|---|
| | 142 | !strcmp( album.psz_album, psz_album ) ) |
|---|
| 136 | 143 | { |
|---|
| 137 | 144 | msg_Dbg( p_playlist, " %s - %s has already been searched", |
|---|
| 138 | | input_item_GetArtist( p_item ), input_item_GetAlbum( p_item ) ); |
|---|
| | 145 | psz_artist, psz_album ); |
|---|
| 139 | 146 | /* TODO-fenrir if we cache art filename too, we can go faster */ |
|---|
| | 147 | free( psz_artist ); |
|---|
| | 148 | free( psz_album ); |
|---|
| 140 | 149 | if( album.b_found ) |
|---|
| 141 | 150 | { |
|---|
| … | … | |
| 151 | 160 | FOREACH_END(); |
|---|
| 152 | 161 | } |
|---|
| 153 | | |
|---|
| | 162 | free( psz_artist ); |
|---|
| | 163 | free( psz_album ); |
|---|
| | 164 | |
|---|
| | 165 | char *psz_arturl = input_item_GetArtURL( p_item ); |
|---|
| 154 | 166 | input_FindArtInCache( p_playlist, p_item ); |
|---|
| 155 | | if( !EMPTY_STR(input_item_GetArtURL( p_item )) ) |
|---|
| | 167 | if( !EMPTY_STR( psz_arturl ) ) |
|---|
| | 168 | { |
|---|
| | 169 | free( psz_arturl ); |
|---|
| 156 | 170 | return 0; |
|---|
| | 171 | } |
|---|
| | 172 | free( psz_arturl ); |
|---|
| 157 | 173 | |
|---|
| 158 | 174 | PL_LOCK; |
|---|
| 159 | 175 | p_playlist->p_private = p_item; |
|---|
| 160 | | if( input_item_GetAlbum( p_item ) && input_item_GetArtist( p_item ) ) |
|---|
| | 176 | psz_album = input_item_GetAlbum( p_item ); |
|---|
| | 177 | psz_artist = input_item_GetArtist( p_item ); |
|---|
| | 178 | psz_name = input_item_GetName( p_item ); |
|---|
| | 179 | psz_title = input_item_GetTitle( p_item ); |
|---|
| | 180 | if( psz_album && psz_artist ) |
|---|
| 161 | 181 | { |
|---|
| 162 | 182 | msg_Dbg( p_playlist, "searching art for %s - %s", |
|---|
| 163 | | input_item_GetArtist( p_item ), input_item_GetAlbum( p_item ) ); |
|---|
| | 183 | psz_artist, psz_album ); |
|---|
| 164 | 184 | } |
|---|
| 165 | 185 | else |
|---|
| 166 | 186 | { |
|---|
| 167 | 187 | msg_Dbg( p_playlist, "searching art for %s", |
|---|
| 168 | | input_item_GetTitle( p_item ) ? input_item_GetTitle( p_item ) : p_item->psz_name ); |
|---|
| 169 | | } |
|---|
| | 188 | psz_title ? psz_title : psz_name ); |
|---|
| | 189 | } |
|---|
| | 190 | free( psz_title ); |
|---|
| | 191 | free( psz_name ); |
|---|
| 170 | 192 | |
|---|
| 171 | 193 | p_module = module_Need( p_playlist, "art finder", 0, VLC_FALSE ); |
|---|
| … | … | |
| 177 | 199 | |
|---|
| 178 | 200 | /* Record this album */ |
|---|
| 179 | | if( input_item_GetArtist( p_item ) && input_item_GetAlbum( p_item ) ) |
|---|
| | 201 | if( psz_artist && psz_album ) |
|---|
| 180 | 202 | { |
|---|
| 181 | 203 | playlist_album_t a; |
|---|
| 182 | | a.psz_artist = strdup( input_item_GetArtist( p_item ) ); |
|---|
| 183 | | a.psz_album = strdup( input_item_GetAlbum( p_item ) ); |
|---|
| | 204 | a.psz_artist = psz_artist; |
|---|
| | 205 | a.psz_album = psz_album; |
|---|
| 184 | 206 | a.b_found = (i_ret == VLC_EGENERIC ? VLC_FALSE : VLC_TRUE ); |
|---|
| 185 | 207 | ARRAY_APPEND( p_playlist->p_fetcher->albums, a ); |
|---|
| | 208 | } |
|---|
| | 209 | else |
|---|
| | 210 | { |
|---|
| | 211 | free( psz_artist ); |
|---|
| | 212 | free( psz_album ); |
|---|
| 186 | 213 | } |
|---|
| 187 | 214 | |
|---|
| … | … | |
| 281 | 308 | static int __input_FindArtInCache( vlc_object_t *p_obj, input_item_t *p_item ) |
|---|
| 282 | 309 | { |
|---|
| 283 | | const char *psz_artist; |
|---|
| 284 | | const char *psz_album; |
|---|
| 285 | | const char *psz_title; |
|---|
| | 310 | char *psz_artist; |
|---|
| | 311 | char *psz_album; |
|---|
| | 312 | char *psz_title; |
|---|
| 286 | 313 | char psz_filename[MAX_PATH+1]; |
|---|
| 287 | 314 | int i; |
|---|
| … | … | |
| 294 | 321 | psz_album = input_item_GetAlbum( p_item ); |
|---|
| 295 | 322 | psz_title = input_item_GetTitle( p_item ); |
|---|
| 296 | | if( !psz_title ) psz_title = p_item->psz_name; |
|---|
| 297 | | |
|---|
| 298 | | if( (!psz_artist || !psz_album) && !psz_title ) return VLC_EGENERIC; |
|---|
| | 323 | if( !psz_title ) psz_title = input_item_GetName( p_item ); |
|---|
| | 324 | |
|---|
| | 325 | if( !psz_title && ( !psz_album || !psz_artist ) ) |
|---|
| | 326 | { |
|---|
| | 327 | free( psz_artist ); |
|---|
| | 328 | free( psz_album ); |
|---|
| | 329 | free( psz_title ); |
|---|
| | 330 | return VLC_EGENERIC; |
|---|
| | 331 | } |
|---|
| | 332 | free( psz_title ); |
|---|
| 299 | 333 | |
|---|
| 300 | 334 | for( i = 0; i < 5; i++ ) |
|---|
| … | … | |
| 307 | 341 | { |
|---|
| 308 | 342 | input_item_SetArtURL( p_item, psz_filename ); |
|---|
| | 343 | free( psz_artist ); |
|---|
| | 344 | free( psz_album ); |
|---|
| 309 | 345 | return VLC_SUCCESS; |
|---|
| 310 | 346 | } |
|---|
| 311 | 347 | } |
|---|
| | 348 | free( psz_artist ); |
|---|
| | 349 | free( psz_album ); |
|---|
| 312 | 350 | return VLC_EGENERIC; |
|---|
| 313 | 351 | } |
|---|
| … | … | |
| 325 | 363 | char *psz_album = NULL; |
|---|
| 326 | 364 | char *psz_title = NULL; |
|---|
| | 365 | char *psz_artist_m, *psz_album_m, *psz_title_m, *psz_name_m, *psz_arturl_m; |
|---|
| 327 | 366 | char *psz_type; |
|---|
| 328 | | if( input_item_GetArtist( p_item ) ) |
|---|
| 329 | | psz_artist = ArtCacheCreateString( input_item_GetArtist( p_item ) ); |
|---|
| 330 | | if( input_item_GetAlbum( p_item ) ) |
|---|
| 331 | | psz_album = ArtCacheCreateString( input_item_GetAlbum( p_item ) ); |
|---|
| 332 | | if( input_item_GetTitle( p_item ) ) |
|---|
| 333 | | psz_title = ArtCacheCreateString( input_item_GetTitle( p_item ) ); |
|---|
| 334 | | else if( p_item->psz_name ) |
|---|
| 335 | | psz_title = ArtCacheCreateString( p_item->psz_name ); |
|---|
| | 367 | |
|---|
| | 368 | psz_artist_m = input_item_GetArtist( p_item ); |
|---|
| | 369 | psz_album_m = input_item_GetAlbum( p_item ); |
|---|
| | 370 | psz_title_m = input_item_GetTitle( p_item ); |
|---|
| | 371 | psz_name_m = input_item_GetName( p_item ); |
|---|
| | 372 | |
|---|
| | 373 | if( psz_artist_m ) psz_artist = ArtCacheCreateString( psz_artist_m ); |
|---|
| | 374 | if( psz_album_m ) psz_album = ArtCacheCreateString( psz_album_m ); |
|---|
| | 375 | if( psz_title_m ) psz_title = ArtCacheCreateString( psz_title_m ); |
|---|
| | 376 | else if( psz_name_m ) psz_title = ArtCacheCreateString( psz_name_m ); |
|---|
| | 377 | |
|---|
| | 378 | free( psz_artist_m ); |
|---|
| | 379 | free( psz_album_m ); |
|---|
| | 380 | free( psz_title_m ); |
|---|
| | 381 | free( psz_name_m ); |
|---|
| 336 | 382 | |
|---|
| 337 | 383 | if( !psz_title && (!psz_artist || !psz_album) ) |
|---|
| … | … | |
| 343 | 389 | } |
|---|
| 344 | 390 | |
|---|
| 345 | | assert( !EMPTY_STR(input_item_GetArtURL( p_item )) ); |
|---|
| 346 | | |
|---|
| 347 | | psz_type = strrchr( input_item_GetArtURL( p_item ), '.' ); |
|---|
| | 391 | psz_arturl_m = input_item_GetArtURL( p_item ); |
|---|
| | 392 | assert( !EMPTY_STR( psz_arturl_m ) ); |
|---|
| | 393 | |
|---|
| | 394 | psz_type = strrchr( psz_arturl_m, '.' ); |
|---|
| 348 | 395 | |
|---|
| 349 | 396 | /* */ |
|---|
| … | … | |
| 359 | 406 | free( psz_title ); |
|---|
| 360 | 407 | |
|---|
| 361 | | if( !strncmp( input_item_GetArtURL( p_item ) , "APIC", 4 ) ) |
|---|
| | 408 | if( !strncmp( psz_arturl_m , "APIC", 4 ) ) |
|---|
| 362 | 409 | { |
|---|
| 363 | 410 | msg_Warn( p_playlist, "APIC fetch not supported yet" ); |
|---|
| | 411 | free( psz_arturl_m ); |
|---|
| 364 | 412 | return VLC_EGENERIC; |
|---|
| 365 | 413 | } |
|---|
| 366 | 414 | |
|---|
| 367 | | p_stream = stream_UrlNew( p_playlist, input_item_GetArtURL( p_item ) ); |
|---|
| | 415 | p_stream = stream_UrlNew( p_playlist, psz_arturl_m ); |
|---|
| 368 | 416 | if( p_stream ) |
|---|
| 369 | 417 | { |
|---|
| … | … | |
| 392 | 440 | i_status = VLC_SUCCESS; |
|---|
| 393 | 441 | } |
|---|
| | 442 | free( psz_arturl_m ); |
|---|
| 394 | 443 | return i_status; |
|---|
| 395 | 444 | } |
|---|
| … | … | |
| 403 | 452 | char *psz_title = NULL; |
|---|
| 404 | 453 | char *psz_type = NULL; |
|---|
| | 454 | char *psz_artist_m, *psz_album_m, *psz_title_m, *psz_name_m; |
|---|
| 405 | 455 | char psz_filename[MAX_PATH+1]; |
|---|
| 406 | 456 | FILE *f; |
|---|
| … | … | |
| 412 | 462 | * and then set it here to to be faster */ |
|---|
| 413 | 463 | |
|---|
| 414 | | psz_arturl = strdup( input_item_GetArtURL( p_item ) ); |
|---|
| | 464 | psz_arturl = input_item_GetArtURL( p_item ); |
|---|
| 415 | 465 | if( !psz_arturl || strncmp( psz_arturl, "attachment://", strlen("attachment://") ) ) |
|---|
| 416 | 466 | { |
|---|
| | 467 | free( psz_arturl ); |
|---|
| 417 | 468 | msg_Err( p_input, "internal input error with input_ExtractAttachmentAndCacheArt" ); |
|---|
| 418 | 469 | return; |
|---|
| … | … | |
| 446 | 497 | } |
|---|
| 447 | 498 | |
|---|
| 448 | | if( input_item_GetArtist( p_item ) ) |
|---|
| 449 | | psz_artist = ArtCacheCreateString( input_item_GetArtist( p_item ) ); |
|---|
| 450 | | if( input_item_GetAlbum( p_item ) ) |
|---|
| 451 | | psz_album = ArtCacheCreateString( input_item_GetAlbum( p_item ) ); |
|---|
| 452 | | if( input_item_GetTitle( p_item ) ) |
|---|
| 453 | | psz_title = ArtCacheCreateString( input_item_GetTitle( p_item ) ); |
|---|
| 454 | | else if( p_item->psz_name ) |
|---|
| 455 | | psz_title = ArtCacheCreateString( p_item->psz_name ); |
|---|
| | 499 | psz_artist_m = input_item_GetArtist( p_item ); |
|---|
| | 500 | psz_album_m = input_item_GetAlbum( p_item ); |
|---|
| | 501 | psz_title_m = input_item_GetTitle( p_item ); |
|---|
| | 502 | psz_name_m = input_item_GetName( p_item ); |
|---|
| | 503 | |
|---|
| | 504 | if( psz_artist_m ) psz_artist = ArtCacheCreateString( psz_artist_m ); |
|---|
| | 505 | if( psz_album_m ) psz_album = ArtCacheCreateString( psz_album_m ); |
|---|
| | 506 | if( psz_title_m ) psz_title = ArtCacheCreateString( psz_title_m ); |
|---|
| | 507 | else if( psz_name_m ) psz_title = ArtCacheCreateString( psz_name_m ); |
|---|
| | 508 | |
|---|
| | 509 | free( psz_artist_m ); |
|---|
| | 510 | free( psz_album_m ); |
|---|
| | 511 | free( psz_title_m ); |
|---|
| | 512 | free( psz_name_m ); |
|---|
| 456 | 513 | |
|---|
| 457 | 514 | if( (!psz_artist || !psz_album ) && !psz_title ) |
|---|
| r51880eb |
r662ed77 |
|
| 455 | 455 | vlc_bool_t b_has_art; |
|---|
| 456 | 456 | |
|---|
| 457 | | vlc_mutex_lock( &p_input->lock ); |
|---|
| 458 | | /* p_input->p_meta should not be null after a successfull CreateThread */ |
|---|
| 459 | | b_has_art = !EMPTY_STR( input_item_GetArtURL( p_input ) ); |
|---|
| 460 | | vlc_mutex_unlock( &p_input->lock ); |
|---|
| | 457 | char *psz_arturl, *psz_name; |
|---|
| | 458 | psz_arturl = input_item_GetArtURL( p_input ); |
|---|
| | 459 | psz_name = input_item_GetName( p_input ); |
|---|
| | 460 | |
|---|
| | 461 | /* p_input->p_meta should not be null after a successfull CreateThread*/ |
|---|
| | 462 | b_has_art = !EMPTY_STR( psz_arturl ); |
|---|
| 461 | 463 | |
|---|
| 462 | 464 | if( !b_has_art ) |
|---|
| 463 | 465 | { |
|---|
| 464 | | PL_DEBUG( "requesting art for %s", p_input->psz_name ); |
|---|
| | 466 | PL_DEBUG( "requesting art for %s", psz_name ); |
|---|
| 465 | 467 | playlist_AskForArtEnqueue( p_playlist, p_input ); |
|---|
| 466 | 468 | } |
|---|
| | 469 | free( psz_arturl ); |
|---|
| | 470 | free( psz_name ); |
|---|
| 467 | 471 | } |
|---|
| 468 | 472 | |
|---|
| r716d5bf |
r662ed77 |
|
| 528 | 528 | * \todo don't do this for things we won't get meta for, like vids |
|---|
| 529 | 529 | */ |
|---|
| | 530 | char *psz_arturl = input_item_GetArtURL( p_current ); |
|---|
| | 531 | char *psz_name = input_item_GetName( p_current ); |
|---|
| 530 | 532 | if( !input_MetaSatisfied( p_playlist, p_current, &i_m, &i_o ) ) |
|---|
| 531 | 533 | { |
|---|
| … | … | |
| 543 | 545 | /* We already have all needed meta, but we need art right now */ |
|---|
| 544 | 546 | else if( p_playlist->p_fetcher->i_art_policy == ALBUM_ART_ALL && |
|---|
| 545 | | EMPTY_STR( input_item_GetArtURL( p_current ) ) ) |
|---|
| | 547 | EMPTY_STR( psz_arturl ) ) |
|---|
| 546 | 548 | { |
|---|
| 547 | 549 | preparse_item_t p; |
|---|
| 548 | | PL_DEBUG("meta ok for %s, need to fetch art", |
|---|
| 549 | | p_current->psz_name ); |
|---|
| | 550 | PL_DEBUG("meta ok for %s, need to fetch art", psz_name ); |
|---|
| 550 | 551 | p.p_item = p_current; |
|---|
| 551 | 552 | p.b_fetch_art = VLC_TRUE; |
|---|
| … | … | |
| 560 | 561 | { |
|---|
| 561 | 562 | PL_DEBUG( "no fetch required for %s (art currently %s)", |
|---|
| 562 | | p_current->psz_name, |
|---|
| 563 | | input_item_GetArtURL( p_current )); |
|---|
| | 563 | psz_name, psz_arturl ); |
|---|
| 564 | 564 | vlc_gc_decref( p_current ); |
|---|
| 565 | 565 | } |
|---|
| | 566 | free( psz_name ); |
|---|
| | 567 | free( psz_arturl ); |
|---|
| 566 | 568 | PL_UNLOCK; |
|---|
| 567 | 569 | } |
|---|
| r6dd4b20 |
r662ed77 |
|
| 658 | 658 | } |
|---|
| 659 | 659 | /* Preparse if PREPARSE or SPREPARSE & not enough meta */ |
|---|
| | 660 | char *psz_artist = input_item_GetArtist( p_item_cat->p_input ); |
|---|
| | 661 | char *psz_album = input_item_GetAlbum( p_item_cat->p_input ); |
|---|
| 660 | 662 | if( p_playlist->b_auto_preparse && |
|---|
| 661 | 663 | (i_mode & PLAYLIST_PREPARSE || |
|---|
| 662 | 664 | ( i_mode & PLAYLIST_SPREPARSE && |
|---|
| 663 | | ( EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) || |
|---|
| 664 | | ( EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) ) ) |
|---|
| | 665 | ( EMPTY_STR( psz_artist ) || ( EMPTY_STR( psz_album ) ) ) |
|---|
| 665 | 666 | ) ) ) |
|---|
| 666 | 667 | playlist_PreparseEnqueue( p_playlist, p_item_cat->p_input ); |
|---|
| 667 | 668 | /* If we already have it, signal it */ |
|---|
| 668 | | else if( !EMPTY_STR( input_item_GetArtist( p_item_cat->p_input ) ) && |
|---|
| 669 | | !EMPTY_STR( input_item_GetAlbum( p_item_cat->p_input ) ) ) |
|---|
| | 669 | else if( !EMPTY_STR( psz_artist ) && !EMPTY_STR( psz_album ) ) |
|---|
| 670 | 670 | input_item_SetPreparsed( p_item_cat->p_input, VLC_TRUE ); |
|---|
| | 671 | free( psz_artist ); |
|---|
| | 672 | free( psz_album ); |
|---|
| 671 | 673 | } |
|---|
| 672 | 674 | |
|---|
| r51880eb |
r662ed77 |
|
| 639 | 639 | |
|---|
| 640 | 640 | #define INSERT_STRING( check, string ) \ |
|---|
| 641 | | if( check && string ) \ |
|---|
| | 641 | if( check ) \ |
|---|
| 642 | 642 | { \ |
|---|
| 643 | | int len = strlen( string ); \ |
|---|
| 644 | | dst = realloc( dst, \ |
|---|
| 645 | | i_size = i_size + len + 1 ); \ |
|---|
| 646 | | strncpy( d, string, len+1 ); \ |
|---|
| 647 | | d += len; \ |
|---|
| 648 | | } \ |
|---|
| 649 | | else \ |
|---|
| 650 | | { \ |
|---|
| 651 | | *d = '-'; \ |
|---|
| 652 | | d++; \ |
|---|
| | 643 | psz_meta = string; \ |
|---|
| | 644 | if( string ) \ |
|---|
| | 645 | { \ |
|---|
| | 646 | int len = strlen( psz_meta ); \ |
|---|
| | 647 | dst = realloc( dst, \ |
|---|
| | 648 | i_size = i_size + len + 1 ); \ |
|---|
| | 649 | strncpy( d, psz_meta, len+1 ); \ |
|---|
| | 650 | d += len; \ |
|---|
| | 651 | free( psz_meta ); \ |
|---|
| | 652 | } \ |
|---|
| | 653 | else \ |
|---|
| | 654 | { \ |
|---|
| | 655 | *d = '-'; \ |
|---|
| | 656 | d++; \ |
|---|
| | 657 | } \ |
|---|
| 653 | 658 | } |
|---|
| 654 | 659 | char *__str_format_meta( vlc_object_t *p_object, const char *string ) |
|---|
| … | … | |
| 682 | 687 | switch( *s ) |
|---|
| 683 | 688 | { |
|---|
| | 689 | char *psz_meta; /* used by INSERT_STRING */ |
|---|
| 684 | 690 | case 'a': |
|---|
| 685 | 691 | INSERT_STRING( p_item, input_item_GetArtist(p_item) ); |
|---|
| ra9e4de1 |
r662ed77 |
|
| 1643 | 1643 | i_now = mdate(); |
|---|
| 1644 | 1644 | i_stop = i_now + (mtime_t)(p_vout->i_title_timeout * 1000); |
|---|
| 1645 | | if( !EMPTY_STR(input_item_GetNowPlaying(input_GetItem(p_input))) ) |
|---|
| | 1645 | char *psz_nowplaying = |
|---|
| | 1646 | input_item_GetNowPlaying( input_GetItem( p_input ) ); |
|---|
| | 1647 | char *psz_artist = input_item_GetArtist( input_GetItem( p_input ) ); |
|---|
| | 1648 | char *psz_name = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| | 1649 | if( !EMPTY_STR( psz_nowplaying ) ) |
|---|
| 1646 | 1650 | { |
|---|
| 1647 | 1651 | vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, |
|---|
| 1648 | | input_item_GetNowPlaying(input_GetItem(p_input)), NULL, |
|---|
| | 1652 | psz_nowplaying, NULL, |
|---|
| 1649 | 1653 | p_vout->i_title_position, |
|---|
| 1650 | 1654 | 30 + p_vout->fmt_in.i_width |
|---|
| … | … | |
| 1654 | 1658 | i_now, i_stop ); |
|---|
| 1655 | 1659 | } |
|---|
| 1656 | | else if( !EMPTY_STR(input_item_GetArtist(input_GetItem(p_input))) ) |
|---|
| | 1660 | else if( !EMPTY_STR( psz_artist ) ) |
|---|
| 1657 | 1661 | { |
|---|
| 1658 | 1662 | char *psz_string = NULL; |
|---|
| 1659 | 1663 | |
|---|
| 1660 | | psz_string = malloc( strlen(input_GetItem(p_input)->psz_name) ) + |
|---|
| 1661 | | strlen( input_item_GetArtist(input_GetItem(p_input)) ); |
|---|
| | 1664 | psz_string = malloc( strlen( psz_name ) + strlen( psz_artist ) ); |
|---|
| 1662 | 1665 | if( psz_string ) |
|---|
| 1663 | 1666 | { |
|---|
| 1664 | | sprintf( psz_string, "%s - %s", |
|---|
| 1665 | | input_GetItem(p_input)->psz_name, |
|---|
| 1666 | | input_item_GetArtist(input_GetItem(p_input)) ); |
|---|
| | 1667 | sprintf( psz_string, "%s - %s", psz_name, psz_artist ); |
|---|
| 1667 | 1668 | |
|---|
| 1668 | 1669 | vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, |
|---|
| … | … | |
| 1680 | 1681 | { |
|---|
| 1681 | 1682 | vout_ShowTextAbsolute( p_vout, DEFAULT_CHAN, |
|---|
| 1682 | | input_GetItem(p_input)->psz_name, NULL, |
|---|
| | 1683 | psz_name, NULL, |
|---|
| 1683 | 1684 | p_vout->i_title_position, |
|---|
| 1684 | 1685 | 30 + p_vout->fmt_in.i_width |
|---|
| … | … | |
| 1689 | 1690 | } |
|---|
| 1690 | 1691 | vlc_object_release( p_input ); |
|---|
| 1691 | | } |
|---|
| 1692 | | } |
|---|
| | 1692 | free( psz_artist ); |
|---|
| | 1693 | free( psz_name ); |
|---|
| | 1694 | free( psz_nowplaying ); |
|---|
| | 1695 | } |
|---|
| | 1696 | } |
|---|