Changeset e3f0531d93abd49f902a324241e31200de05b45d
- Timestamp:
- 14/09/08 11:35:42
(3 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1221384942 +0300
- git-parent:
[8df80e5ede700e71f673cf052958015b7c851d5c]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1221384942 +0300
- Message:
Playlist: put private data after public data
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rbad878b |
re3f0531 |
|
| 154 | 154 | { PLAYLIST_STOPPED,PLAYLIST_RUNNING,PLAYLIST_PAUSED } playlist_status_t; |
|---|
| 155 | 155 | |
|---|
| 156 | | typedef struct playlist_private_t playlist_private_t; |
|---|
| 157 | | |
|---|
| 158 | 156 | /** Structure containing information about the playlist */ |
|---|
| 159 | 157 | struct playlist_t |
|---|
| … | … | |
| 225 | 223 | vlc_mutex_t lock; /**< Lock to protect request */ |
|---|
| 226 | 224 | } request; |
|---|
| 227 | | |
|---|
| 228 | | /* All other data is PRIVATE. You can't access it |
|---|
| 229 | | * outside of src/input */ |
|---|
| 230 | | playlist_private_t *p; |
|---|
| 231 | 225 | }; |
|---|
| 232 | 226 | |
|---|
| rbad878b |
re3f0531 |
|
| 100 | 100 | if( psz_artist && psz_album ) |
|---|
| 101 | 101 | { |
|---|
| 102 | | FOREACH_ARRAY( playlist_album_t album, p_playlist->p->p_fetcher->albums ) |
|---|
| | 102 | FOREACH_ARRAY( playlist_album_t album, pl_priv(p_playlist)->p_fetcher->albums ) |
|---|
| 103 | 103 | if( !strcmp( album.psz_artist, psz_artist ) && |
|---|
| 104 | 104 | !strcmp( album.psz_album, psz_album ) ) |
|---|
| … | … | |
| 180 | 180 | a.psz_arturl = input_item_GetArtURL( p_item ); |
|---|
| 181 | 181 | a.b_found = (i_ret == VLC_EGENERIC ? false : true ); |
|---|
| 182 | | ARRAY_APPEND( p_playlist->p->p_fetcher->albums, a ); |
|---|
| | 182 | ARRAY_APPEND( pl_priv(p_playlist)->p_fetcher->albums, a ); |
|---|
| 183 | 183 | } |
|---|
| 184 | 184 | else |
|---|
| r8df80e5 |
re3f0531 |
|
| 190 | 190 | input_item_t *p_item ) |
|---|
| 191 | 191 | { |
|---|
| 192 | | playlist_preparse_t *p_preparse = &p_playlist->p->preparse; |
|---|
| | 192 | playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 193 | 193 | |
|---|
| 194 | 194 | vlc_gc_incref( p_item ); |
|---|
| … | … | |
| 207 | 207 | playlist_item_t *p_item ) |
|---|
| 208 | 208 | { |
|---|
| 209 | | playlist_preparse_t *p_preparse = &p_playlist->p->preparse; |
|---|
| | 209 | playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 210 | 210 | |
|---|
| 211 | 211 | vlc_object_lock( p_playlist ); |
|---|
| … | … | |
| 220 | 220 | input_item_t *p_item ) |
|---|
| 221 | 221 | { |
|---|
| 222 | | vlc_object_lock( p_playlist->p->p_fetcher ); |
|---|
| 223 | | if( !vlc_object_alive( p_playlist->p->p_fetcher ) ) |
|---|
| 224 | | { |
|---|
| 225 | | vlc_object_unlock( p_playlist->p->p_fetcher ); |
|---|
| | 222 | playlist_fetcher_t *p_fetcher = pl_priv(p_playlist)->p_fetcher; |
|---|
| | 223 | vlc_object_lock( p_fetcher ); |
|---|
| | 224 | if( !vlc_object_alive( p_fetcher ) ) |
|---|
| | 225 | { |
|---|
| | 226 | vlc_object_unlock( p_fetcher ); |
|---|
| 226 | 227 | return VLC_EGENERIC; |
|---|
| 227 | 228 | } |
|---|
| 228 | 229 | |
|---|
| 229 | 230 | vlc_gc_incref( p_item ); |
|---|
| 230 | | INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting, |
|---|
| 231 | | p_playlist->p->p_fetcher->i_waiting, |
|---|
| 232 | | p_playlist->p->p_fetcher->i_waiting, p_item ); |
|---|
| 233 | | vlc_object_signal_unlocked( p_playlist->p->p_fetcher ); |
|---|
| 234 | | vlc_object_unlock( p_playlist->p->p_fetcher ); |
|---|
| | 231 | INSERT_ELEM( p_fetcher->pp_waiting, p_fetcher->i_waiting, |
|---|
| | 232 | p_fetcher->i_waiting, p_item ); |
|---|
| | 233 | vlc_object_signal_unlocked( p_fetcher ); |
|---|
| | 234 | vlc_object_unlock( p_fetcher ); |
|---|
| 235 | 235 | return VLC_SUCCESS; |
|---|
| 236 | 236 | } |
|---|
| … | … | |
| 239 | 239 | playlist_item_t *p_item ) |
|---|
| 240 | 240 | { |
|---|
| 241 | | playlist_preparse_t *p_preparse = &p_playlist->p->preparse; |
|---|
| | 241 | playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 242 | 242 | |
|---|
| 243 | 243 | if( p_item->i_children == -1 ) |
|---|
| … | … | |
| 506 | 506 | { |
|---|
| 507 | 507 | input_item_t *p_input = p_item->p_input; |
|---|
| 508 | | sout_instance_t **pp_sout = &p_playlist->p->p_sout; |
|---|
| | 508 | sout_instance_t **pp_sout = &pl_priv(p_playlist)->p_sout; |
|---|
| 509 | 509 | int i_activity = var_GetInteger( p_playlist, "activity" ) ; |
|---|
| 510 | 510 | |
|---|
| … | … | |
| 535 | 535 | free( psz_uri ); |
|---|
| 536 | 536 | |
|---|
| 537 | | if( p_playlist->p->p_fetcher && |
|---|
| 538 | | p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED ) |
|---|
| | 537 | if( pl_priv(p_playlist)->p_fetcher && |
|---|
| | 538 | pl_priv(p_playlist)->p_fetcher->i_art_policy == ALBUM_ART_WHEN_PLAYED ) |
|---|
| 539 | 539 | { |
|---|
| 540 | 540 | bool b_has_art; |
|---|
| r8df80e5 |
re3f0531 |
|
| 62 | 62 | static const char playlist_name[] = "playlist"; |
|---|
| 63 | 63 | playlist_t *p_playlist; |
|---|
| | 64 | playlist_private_t *p; |
|---|
| 64 | 65 | bool b_save; |
|---|
| 65 | 66 | |
|---|
| 66 | 67 | /* Allocate structure */ |
|---|
| 67 | | p_playlist = vlc_custom_create( p_parent, sizeof( *p_playlist ), |
|---|
| 68 | | VLC_OBJECT_GENERIC, playlist_name ); |
|---|
| 69 | | if( !p_playlist ) |
|---|
| | 68 | p = vlc_custom_create( p_parent, sizeof( *p ), |
|---|
| | 69 | VLC_OBJECT_GENERIC, playlist_name ); |
|---|
| | 70 | if( !p ) |
|---|
| 70 | 71 | return NULL; |
|---|
| 71 | 72 | |
|---|
| | 73 | assert( offsetof( playlist_private_t, public_data ) == 0 ); |
|---|
| | 74 | p_playlist = &p->public_data; |
|---|
| 72 | 75 | TAB_INIT( p_playlist->i_sds, p_playlist->pp_sds ); |
|---|
| 73 | | MALLOC_NULL( p_playlist->p, playlist_private_t ); |
|---|
| 74 | | memset( p_playlist->p, 0, sizeof( playlist_private_t ) ); |
|---|
| 75 | 76 | |
|---|
| 76 | 77 | libvlc_priv(p_parent->p_libvlc)->p_playlist = p_playlist; |
|---|
| … | … | |
| 79 | 80 | |
|---|
| 80 | 81 | /* Initialise data structures */ |
|---|
| 81 | | p_playlist->p->p_playlist = p_playlist; |
|---|
| 82 | 82 | p_playlist->i_last_playlist_id = 0; |
|---|
| 83 | 83 | p_playlist->p_input = NULL; |
|---|
| … | … | |
| 177 | 177 | { |
|---|
| 178 | 178 | playlist_t * p_playlist = (playlist_t *)p_this; |
|---|
| 179 | | playlist_preparse_t *p_preparse = &p_playlist->p->preparse; |
|---|
| | 179 | playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 180 | 180 | |
|---|
| 181 | 181 | /* Destroy the item preparser */ |
|---|
| … | … | |
| 194 | 194 | |
|---|
| 195 | 195 | /* Destroy the item meta-infos fetcher */ |
|---|
| 196 | | if( p_playlist->p->p_fetcher ) |
|---|
| 197 | | { |
|---|
| 198 | | vlc_object_release( p_playlist->p->p_fetcher ); |
|---|
| | 196 | if( pl_priv(p_playlist)->p_fetcher ) |
|---|
| | 197 | { |
|---|
| | 198 | vlc_object_release( pl_priv(p_playlist)->p_fetcher ); |
|---|
| 199 | 199 | } |
|---|
| 200 | 200 | msg_Dbg( p_this, "Destroyed" ); |
|---|
| … | … | |
| 380 | 380 | int i_activity; |
|---|
| 381 | 381 | input_thread_t *p_input; |
|---|
| 382 | | sout_instance_t **pp_sout = &p_playlist->p->p_sout; |
|---|
| | 382 | sout_instance_t **pp_sout = &pl_priv(p_playlist)->p_sout; |
|---|
| 383 | 383 | |
|---|
| 384 | 384 | PL_DEBUG( "dead input" ); |
|---|
| … | … | |
| 521 | 521 | #ifdef ENABLE_SOUT |
|---|
| 522 | 522 | /* close the remaining sout-keep (if there was no input atm) */ |
|---|
| 523 | | sout_instance_t *p_sout = p_playlist->p->p_sout; |
|---|
| | 523 | sout_instance_t *p_sout = pl_priv(p_playlist)->p_sout; |
|---|
| 524 | 524 | if (p_sout) |
|---|
| 525 | 525 | sout_DeleteInstance( p_sout ); |
|---|
| … | … | |
| 531 | 531 | playlist_MLDump( p_playlist ); |
|---|
| 532 | 532 | |
|---|
| 533 | | vlc_object_kill( p_playlist->p->p_fetcher ); |
|---|
| 534 | | vlc_thread_join( p_playlist->p->p_fetcher ); |
|---|
| | 533 | vlc_object_kill( pl_priv(p_playlist)->p_fetcher ); |
|---|
| | 534 | vlc_thread_join( pl_priv(p_playlist)->p_fetcher ); |
|---|
| 535 | 535 | |
|---|
| 536 | 536 | PL_LOCK; |
|---|
| … | … | |
| 570 | 570 | { |
|---|
| 571 | 571 | playlist_preparse_t *p_preparse = data; |
|---|
| 572 | | playlist_t *p_playlist = ((playlist_private_t *)(((char *)p_preparse) |
|---|
| 573 | | - offsetof(playlist_private_t, preparse)))->p_playlist; |
|---|
| | 572 | playlist_t *p_playlist = &((playlist_private_t *)(((char *)p_preparse) |
|---|
| | 573 | - offsetof(playlist_private_t, preparse)))->public_data; |
|---|
| 574 | 574 | int i_activity; |
|---|
| 575 | 575 | |
|---|
| … | … | |
| 616 | 616 | char *psz_arturl = input_item_GetArtURL( p_current ); |
|---|
| 617 | 617 | char *psz_name = input_item_GetName( p_current ); |
|---|
| 618 | | if( p_playlist->p->p_fetcher->i_art_policy == ALBUM_ART_ALL && |
|---|
| 619 | | ( !psz_arturl || strncmp( psz_arturl, "file://", 7 ) ) ) |
|---|
| | 618 | playlist_fetcher_t *p_fetcher = pl_priv(p_playlist)->p_fetcher; |
|---|
| | 619 | if( p_fetcher->i_art_policy == ALBUM_ART_ALL && |
|---|
| | 620 | ( !psz_arturl || strncmp( psz_arturl, "file://", 7 ) ) ) |
|---|
| 620 | 621 | { |
|---|
| 621 | 622 | PL_DEBUG("meta ok for %s, need to fetch art", psz_name ); |
|---|
| 622 | | vlc_object_lock( p_playlist->p->p_fetcher ); |
|---|
| 623 | | if( vlc_object_alive( p_playlist->p->p_fetcher ) ) |
|---|
| | 623 | vlc_object_lock( p_fetcher ); |
|---|
| | 624 | if( vlc_object_alive( p_fetcher ) ) |
|---|
| 624 | 625 | { |
|---|
| 625 | | INSERT_ELEM( p_playlist->p->p_fetcher->pp_waiting, |
|---|
| 626 | | p_playlist->p->p_fetcher->i_waiting, |
|---|
| 627 | | p_playlist->p->p_fetcher->i_waiting, p_current); |
|---|
| 628 | | vlc_object_signal_unlocked( p_playlist->p->p_fetcher ); |
|---|
| | 626 | INSERT_ELEM( p_fetcher->pp_waiting, p_fetcher->i_waiting, |
|---|
| | 627 | p_fetcher->i_waiting, p_current); |
|---|
| | 628 | vlc_object_signal_unlocked( p_fetcher ); |
|---|
| 629 | 629 | } |
|---|
| 630 | 630 | else |
|---|
| 631 | 631 | vlc_gc_decref( p_current ); |
|---|
| 632 | | vlc_object_unlock( p_playlist->p->p_fetcher ); |
|---|
| | 632 | vlc_object_unlock( p_fetcher ); |
|---|
| 633 | 633 | } |
|---|
| 634 | 634 | else |
|---|
| r8df80e5 |
re3f0531 |
|
| 59 | 59 | } playlist_fetcher_t; |
|---|
| 60 | 60 | |
|---|
| 61 | | struct playlist_private_t |
|---|
| | 61 | typedef struct playlist_private_t |
|---|
| 62 | 62 | { |
|---|
| 63 | | playlist_t *p_playlist; /**< Public data */ |
|---|
| | 63 | playlist_t public_data; |
|---|
| 64 | 64 | playlist_preparse_t preparse; /**< Preparser data */ |
|---|
| 65 | 65 | playlist_fetcher_t *p_fetcher; /**< Meta and art fetcher object */ |
|---|
| 66 | 66 | sout_instance_t *p_sout; /**< Kept sout instance */ |
|---|
| 67 | | }; |
|---|
| | 67 | } playlist_private_t; |
|---|
| | 68 | |
|---|
| | 69 | #define pl_priv( pl ) ((playlist_private_t *)(pl)) |
|---|
| 68 | 70 | |
|---|
| 69 | 71 | /***************************************************************************** |
|---|
| r8df80e5 |
re3f0531 |
|
| 58 | 58 | |
|---|
| 59 | 59 | // Preparse |
|---|
| 60 | | playlist_preparse_t *p_preparse = &p_playlist->p->preparse; |
|---|
| | 60 | playlist_preparse_t *p_preparse = &pl_priv(p_playlist)->preparse; |
|---|
| 61 | 61 | vlc_mutex_init (&p_preparse->lock); |
|---|
| 62 | 62 | vlc_cond_init (&p_preparse->wait); |
|---|
| … | … | |
| 75 | 75 | // Secondary Preparse |
|---|
| 76 | 76 | static const char fname[] = "fetcher"; |
|---|
| 77 | | p_playlist->p->p_fetcher = |
|---|
| | 77 | playlist_fetcher_t *p_fetcher = |
|---|
| | 78 | pl_priv(p_playlist)->p_fetcher = |
|---|
| 78 | 79 | vlc_custom_create( p_playlist, sizeof( playlist_fetcher_t ), |
|---|
| 79 | 80 | VLC_OBJECT_GENERIC, fname ); |
|---|
| 80 | | if( !p_playlist->p->p_fetcher ) |
|---|
| | 81 | if( !p_fetcher ) |
|---|
| 81 | 82 | { |
|---|
| 82 | 83 | msg_Err( p_playlist, "unable to create secondary preparser" ); |
|---|
| … | … | |
| 84 | 85 | return; |
|---|
| 85 | 86 | } |
|---|
| 86 | | p_playlist->p->p_fetcher->i_waiting = 0; |
|---|
| 87 | | p_playlist->p->p_fetcher->pp_waiting = NULL; |
|---|
| 88 | | p_playlist->p->p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist, |
|---|
| 89 | | "album-art" ); |
|---|
| | 87 | p_fetcher->i_waiting = 0; |
|---|
| | 88 | p_fetcher->pp_waiting = NULL; |
|---|
| | 89 | p_fetcher->i_art_policy = var_CreateGetInteger( p_playlist, "album-art" ); |
|---|
| 90 | 90 | |
|---|
| 91 | | vlc_object_set_destructor( p_playlist->p->p_fetcher, FetcherDestructor ); |
|---|
| 92 | | |
|---|
| 93 | | vlc_object_attach( p_playlist->p->p_fetcher, p_playlist ); |
|---|
| 94 | | if( vlc_thread_create( p_playlist->p->p_fetcher, |
|---|
| 95 | | "fetcher", |
|---|
| 96 | | RunFetcher, |
|---|
| | 91 | vlc_object_set_destructor( p_fetcher, FetcherDestructor ); |
|---|
| | 92 | vlc_object_attach( p_fetcher, p_playlist ); |
|---|
| | 93 | if( vlc_thread_create( p_fetcher, "fetcher", RunFetcher, |
|---|
| 97 | 94 | VLC_THREAD_PRIORITY_LOW, false ) ) |
|---|
| 98 | 95 | { |
|---|
| 99 | 96 | msg_Err( p_playlist, "cannot spawn secondary preparse thread" ); |
|---|
| 100 | | vlc_object_release( p_playlist->p->p_fetcher ); |
|---|
| | 97 | vlc_object_release( p_fetcher ); |
|---|
| 101 | 98 | return; |
|---|
| 102 | 99 | } |
|---|