Changeset 38dbd37adf32cf04e1caf17ceb7888a4a5ec2f40
- 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
| r1479b91 |
r38dbd37 |
|
| 222 | 222 | { |
|---|
| 223 | 223 | vlc_event_t event; |
|---|
| | 224 | vlc_mutex_lock( &p_i->p_lock ); |
|---|
| 224 | 225 | if( !p_i->p_meta ) |
|---|
| 225 | 226 | p_i->p_meta = vlc_meta_New(); |
|---|
| 226 | 227 | vlc_meta_Set( p_i->p_meta, meta_type, psz_val ); |
|---|
| | 228 | vlc_mutex_unlock( &p_i->p_lock ); |
|---|
| 227 | 229 | |
|---|
| 228 | 230 | /* Notify interested third parties */ |
|---|
| … | … | |
| 232 | 234 | } |
|---|
| 233 | 235 | |
|---|
| 234 | | static inline const char * input_item_GetMeta( input_item_t *p_i, vlc_meta_type_t meta_type ) |
|---|
| 235 | | { |
|---|
| | 236 | static 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 ); |
|---|
| 236 | 239 | if( !p_i->p_meta ) |
|---|
| | 240 | { |
|---|
| | 241 | vlc_mutex_unlock( &p_i->p_lock ); |
|---|
| 237 | 242 | 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 | |
|---|
| | 249 | static 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; |
|---|
| 239 | 255 | } |
|---|
| 240 | 256 | |
|---|
| rf60e1bd |
r38dbd37 |
|
| 867 | 867 | #define ADD_VLC_META_STRING( entry, item ) \ |
|---|
| 868 | 868 | { \ |
|---|
| 869 | | const char * psz = input_item_Get##item( p_input );\ |
|---|
| | 869 | char * psz = input_item_Get##item( p_input );\ |
|---|
| 870 | 870 | ADD_META( entry, DBUS_TYPE_STRING, \ |
|---|
| 871 | 871 | psz ); \ |
|---|
| | 872 | free( psz ); \ |
|---|
| 872 | 873 | } |
|---|
| 873 | 874 | |
|---|
| r51880eb |
r38dbd37 |
|
| 621 | 621 | if( !strncasecmp(psz, txt, strlen(txt)) ) \ |
|---|
| 622 | 622 | { \ |
|---|
| 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 ); \ |
|---|
| 624 | 624 | if( oldval ) \ |
|---|
| 625 | 625 | { \ |
|---|
| … | … | |
| 631 | 631 | else \ |
|---|
| 632 | 632 | vlc_meta_Set( p_sys->p_meta, vlc_meta_ ## var, &psz[strlen(txt)] ); \ |
|---|
| | 633 | free( oldval ); \ |
|---|
| 633 | 634 | } |
|---|
| 634 | 635 | IF_EXTRACT("TITLE=", Title ) |
|---|
| r51880eb |
r38dbd37 |
|
| 272 | 272 | { |
|---|
| 273 | 273 | /* 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 )]; |
|---|
| 277 | 278 | if( o_value == NULL ) |
|---|
| 278 | | o_value = [NSString stringWithCString: input_item_GetTitle( p_item->p_input )]; |
|---|
| | 279 | o_value = [NSString stringWithCString: psz_title )]; |
|---|
| 279 | 280 | } |
|---|
| 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 )]; |
|---|
| 283 | 300 | 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 ); |
|---|
| 306 | 318 | } |
|---|
| 307 | 319 | |
|---|
| rc4292a1 |
r38dbd37 |
|
| 189 | 189 | void MetaPanel::update( input_item_t *p_item ) |
|---|
| 190 | 190 | { |
|---|
| 191 | | const char *psz_meta; |
|---|
| | 191 | char *psz_meta; |
|---|
| 192 | 192 | #define UPDATE_META( meta, widget ) { \ |
|---|
| 193 | 193 | psz_meta = input_item_Get##meta( p_item ); \ |
|---|
| … | … | |
| 195 | 195 | widget->setText( qfu( psz_meta ) ); \ |
|---|
| 196 | 196 | else \ |
|---|
| 197 | | widget->setText( "" ); } |
|---|
| | 197 | widget->setText( "" ); } \ |
|---|
| | 198 | free( psz_meta ); |
|---|
| 198 | 199 | |
|---|
| 199 | 200 | #define UPDATE_META_INT( meta, widget ) { \ |
|---|
| 200 | 201 | psz_meta = input_item_Get##meta( p_item ); \ |
|---|
| 201 | 202 | if( !EMPTY_STR( psz_meta ) ) \ |
|---|
| 202 | | widget->setValue( atoi( psz_meta ) ); } |
|---|
| | 203 | widget->setValue( atoi( psz_meta ) ); } \ |
|---|
| | 204 | free( psz_meta ); |
|---|
| | 205 | |
|---|
| 203 | 206 | |
|---|
| 204 | 207 | /* Name / Title */ |
|---|
| … | … | |
| 209 | 212 | title_text->setText( qfu( p_item->psz_name ) ); |
|---|
| 210 | 213 | else title_text->setText( "" ); |
|---|
| | 214 | free( psz_meta ); |
|---|
| 211 | 215 | |
|---|
| 212 | 216 | /* URL / URI */ |
|---|
| … | … | |
| 216 | 220 | else if( !EMPTY_STR( p_item->psz_uri ) ) |
|---|
| 217 | 221 | emit uriSet( QString( p_item->psz_uri ) ); |
|---|
| | 222 | free( psz_meta ); |
|---|
| 218 | 223 | |
|---|
| 219 | 224 | /* Other classic though */ |
|---|
| … | … | |
| 244 | 249 | else |
|---|
| 245 | 250 | art_cover->setPixmap( QPixmap( ":/noart.png" ) ); |
|---|
| | 251 | free( psz_meta ); |
|---|
| 246 | 252 | } |
|---|
| 247 | 253 | |
|---|
| rb40e9cd |
r38dbd37 |
|
| 133 | 133 | /* Update text */ |
|---|
| 134 | 134 | 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 ); |
|---|
| 146 | 145 | } |
|---|
| 147 | 146 | else |
|---|
| 148 | 147 | { |
|---|
| 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 ); |
|---|
| 151 | 153 | if( old_name != text ) |
|---|
| 152 | 154 | { |
|---|
| rd084716 |
r38dbd37 |
|
| 21 | 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|---|
| 22 | 22 | *****************************************************************************/ |
|---|
| 23 | | #define PLI_NAME( p ) p ? p->p_input->psz_name : "null" |
|---|
| 24 | 23 | |
|---|
| 25 | 24 | #include <assert.h> |
|---|
| … | … | |
| 185 | 184 | current = iscurrent; |
|---|
| 186 | 185 | |
|---|
| 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 ) ) ); |
|---|
| 190 | 190 | else if( current ) |
|---|
| 191 | 191 | model->removeArt(); |
|---|
| | 192 | free( psz_arturl ); |
|---|
| 192 | 193 | |
|---|
| 193 | 194 | strings.clear(); |
|---|
| … | … | |
| 199 | 200 | } |
|---|
| 200 | 201 | |
|---|
| 201 | | |
|---|
| | 202 | char *psz_meta; |
|---|
| 202 | 203 | #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 ); |
|---|
| 204 | 207 | |
|---|
| 205 | 208 | for( int i_index=1; i_index <= VLC_META_ENGINE_MB_TRM_ID; i_index = i_index * 2 ) |
|---|
| … | … | |
| 213 | 216 | break; |
|---|
| 214 | 217 | 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 ) |
|---|
| 216 | 222 | { |
|---|
| 217 | 223 | ADD_META( p_item, Title ); |
|---|
| 218 | 224 | } else { |
|---|
| 219 | | strings.append( qfu( p_item->p_input->psz_name ) ); |
|---|
| | 225 | strings.append( qfu( psz_name ) ); |
|---|
| 220 | 226 | } |
|---|
| | 227 | free( psz_title ); |
|---|
| | 228 | free( psz_name ); |
|---|
| 221 | 229 | break; |
|---|
| 222 | 230 | case VLC_META_ENGINE_DESCRIPTION: |
|---|
| r51880eb |
r38dbd37 |
|
| 122 | 122 | |
|---|
| 123 | 123 | #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 ); \ |
|---|
| 125 | 125 | if( psz_meta != NULL && *psz_meta) \ |
|---|
| 126 | 126 | { \ |
|---|
| … | … | |
| 128 | 128 | } \ |
|---|
| 129 | 129 | else { widget->SetLabel( wxU( "-" ) ); } \ |
|---|
| 130 | | } |
|---|
| | 130 | } \ |
|---|
| | 131 | free( psz_meta ); |
|---|
| 131 | 132 | |
|---|
| 132 | 133 | UPDATE_META( Artist, artist_text ); |
|---|
| r51880eb |
r38dbd37 |
|
| 514 | 514 | |
|---|
| 515 | 515 | 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 ); |
|---|
| 519 | 517 | |
|---|
| 520 | 518 | char psz_duration[MSTRTIME_MAX_SIZE]; |
|---|
| r7377b28 |
r38dbd37 |
|
| 211 | 211 | void InputManager::UpdateNowPlaying() |
|---|
| 212 | 212 | { |
|---|
| 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) ); |
|---|
| 214 | 214 | if( psz_now_playing && *psz_now_playing ) |
|---|
| 215 | 215 | { |
|---|
| … | … | |
| 223 | 223 | wxU(input_GetItem(p_input)->psz_name), 2 ); |
|---|
| 224 | 224 | } |
|---|
| | 225 | free( psz_now_playing ); |
|---|
| 225 | 226 | } |
|---|
| 226 | 227 | |
|---|
| r7377b28 |
r38dbd37 |
|
| 300 | 300 | wxString duration = wxU( "" ); |
|---|
| 301 | 301 | |
|---|
| 302 | | const char *psz_artist = input_item_GetArtist( p_item->p_input ); |
|---|
| | 302 | char *psz_artist = input_item_GetArtist( p_item->p_input ); |
|---|
| 303 | 303 | if( ! psz_artist ) |
|---|
| 304 | 304 | { |
|---|
| … | … | |
| 325 | 325 | wxString(wxU(p_item->p_input->psz_name)) + duration; |
|---|
| 326 | 326 | } |
|---|
| | 327 | free( psz_artist ); |
|---|
| 327 | 328 | treectrl->SetItemText( item , msg ); |
|---|
| 328 | 329 | treectrl->SetItemImage( item, p_item->p_input->i_type ); |
|---|
| r3ea2708 |
r38dbd37 |
|
| 251 | 251 | return NULL; |
|---|
| 252 | 252 | } |
|---|
| | 253 | char *psz_meta; |
|---|
| 253 | 254 | |
|---|
| 254 | 255 | /* Load Lua libraries */ |
|---|
| … | … | |
| 259 | 260 | lua_pushlightuserdata( p_state, p_this ); |
|---|
| 260 | 261 | 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 ); |
|---|
| 263 | 265 | 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 ); |
|---|
| 266 | 270 | 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 ); |
|---|
| 269 | 275 | 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 ); |
|---|
| 272 | 280 | 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 ) */ |
|---|
| 274 | 283 | |
|---|
| 275 | 284 | return p_state; |
|---|
| r51880eb |
r38dbd37 |
|
| 78 | 78 | char *ppsz_args[4]; |
|---|
| 79 | 79 | |
|---|
| 80 | | char *psz_title; |
|---|
| 81 | 80 | char *psz_artist; |
|---|
| 82 | 81 | char *psz_album; |
|---|
| … | … | |
| 84 | 83 | psz_artist = input_item_GetArtist( p_item ); |
|---|
| 85 | 84 | psz_album = input_item_GetAlbum( p_item ); |
|---|
| 86 | | psz_title = p_item->psz_name; |
|---|
| 87 | 85 | |
|---|
| 88 | 86 | if( !psz_artist || !psz_album ) |
|---|
| | 87 | { |
|---|
| | 88 | free( psz_artist ); |
|---|
| | 89 | free( psz_album ); |
|---|
| 89 | 90 | return VLC_EGENERIC; |
|---|
| | 91 | } |
|---|
| | 92 | free( psz_artist ); |
|---|
| | 93 | free( psz_album ); |
|---|
| 90 | 94 | |
|---|
| 91 | 95 | musicbrainz_t p_mb; |
|---|
| … | … | |
| 155 | 159 | return VLC_SUCCESS; |
|---|
| 156 | 160 | 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; |
|---|
| 159 | 168 | } |
|---|
| 160 | 169 | |
|---|
| r51880eb |
r38dbd37 |
|
| 194 | 194 | TagLib::Tag *tag = f.tag(); |
|---|
| 195 | 195 | |
|---|
| 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, |
|---|
| 201 | 205 | TagLib::String::UTF8 ); |
|---|
| 202 | 206 | tag->setTitle( *psz_title ); |
|---|
| 203 | 207 | 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 ); |
|---|
| 212 | 225 | |
|---|
| 213 | 226 | f.save(); |
|---|
| r51880eb |
r38dbd37 |
|
| 631 | 631 | p_sys->p_current_song->time_playing = epoch; |
|---|
| 632 | 632 | |
|---|
| 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 ) |
|---|
| 634 | 635 | ? VLC_TRUE : VLC_FALSE; |
|---|
| | 636 | free( psz_name ); |
|---|
| 635 | 637 | |
|---|
| 636 | 638 | vlc_mutex_unlock( &p_sys->lock ); |
|---|
| … | … | |
| 1004 | 1006 | var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &video_val, NULL ); |
|---|
| 1005 | 1007 | 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 ) ) |
|---|
| 1007 | 1009 | { |
|---|
| 1008 | 1010 | msg_Dbg( p_this, "Not an audio only local file -> no submission"); |
|---|
| … | … | |
| 1039 | 1041 | } |
|---|
| 1040 | 1042 | |
|---|
| | 1043 | char *psz_meta; |
|---|
| 1041 | 1044 | #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 ) \ |
|---|
| 1043 | 1047 | { \ |
|---|
| 1044 | | a = encode_URI_component( \ |
|---|
| 1045 | | input_item_Get##b( input_GetItem(p_input) )); \ |
|---|
| | 1048 | a = encode_URI_component( psz_meta ); \ |
|---|
| 1046 | 1049 | if( !a ) \ |
|---|
| 1047 | 1050 | { \ |
|---|
| | 1051 | free( psz_meta ); \ |
|---|
| 1048 | 1052 | FREE_INPUT_AND_CHARS \ |
|---|
| 1049 | 1053 | return VLC_ENOMEM; \ |
|---|
| 1050 | 1054 | } \ |
|---|
| | 1055 | free( psz_meta ); \ |
|---|
| 1051 | 1056 | } |
|---|
| 1052 | 1057 | |
|---|
| … | … | |
| 1065 | 1070 | WAIT_METADATA_FETCHING( psz_artist ) |
|---|
| 1066 | 1071 | } |
|---|
| 1067 | | |
|---|
| 1068 | | if( input_GetItem(p_input)->psz_name ) |
|---|
| | 1072 | psz_meta = input_item_GetName( input_GetItem( p_input ) ); |
|---|
| | 1073 | if( psz_meta ) |
|---|
| 1069 | 1074 | { |
|---|
| 1070 | | psz_title = encode_URI_component( input_GetItem(p_input)->psz_name ); |
|---|
| | 1075 | psz_title = encode_URI_component( psz_meta ); |
|---|
| 1071 | 1076 | if( !psz_title ) |
|---|
| 1072 | 1077 | { |
|---|
| | 1078 | free( psz_meta ); |
|---|
| 1073 | 1079 | FREE_INPUT_AND_CHARS |
|---|
| 1074 | 1080 | return VLC_ENOMEM; |
|---|
| 1075 | 1081 | } |
|---|
| | 1082 | free( psz_meta ); |
|---|
| 1076 | 1083 | } |
|---|
| 1077 | 1084 | else |
|---|
| r728d281 |
r38dbd37 |
|
| 277 | 277 | libvlc_exception_t *p_e ) |
|---|
| 278 | 278 | { |
|---|
| 279 | | const char * psz_meta; |
|---|
| | 279 | char * psz_meta; |
|---|
| 280 | 280 | |
|---|
| 281 | 281 | /* XXX: locking */ |
|---|
| … | … | |
| 288 | 288 | /* Should be integrated in core */ |
|---|
| 289 | 289 | if( !psz_meta && e_meta == libvlc_meta_Title && p_md->p_input_item->psz_name ) |
|---|
| | 290 | { |
|---|
| | 291 | free( psz_meta ); |
|---|
| 290 | 292 | return strdup( p_md->p_input_item->psz_name ); |
|---|
| | 293 | } |
|---|
| 291 | 294 | |
|---|
| 292 | 295 | 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 | |
|---|
| r51880eb |
r38dbd37 |
|
| 121 | 121 | playlist_LiveSearchUpdate( p_playlist, p_item, psz_string ); |
|---|
| 122 | 122 | } |
|---|
| 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 ) ) |
|---|
| 125 | 123 | else |
|---|
| 126 | 124 | { |
|---|
| 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 ) |
|---|
| 129 | 146 | p_item->i_flags &= ~PLAYLIST_DBL_FLAG; |
|---|
| 130 | 147 | else |
|---|
| r51880eb |
r38dbd37 |
|
| 106 | 106 | |
|---|
| 107 | 107 | #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 ); \ |
|---|
| 110 | 110 | /* Nodes go first */ \ |
|---|
| 111 | 111 | if( pp_items[i]->i_children == -1 && pp_items[i_small]->i_children >= 0 ) \ |
|---|
| … | … | |
| 199 | 199 | pp_items[i_small] = p_temp; |
|---|
| 200 | 200 | } |
|---|
| | 201 | free( psz_a ); |
|---|
| | 202 | free( psz_b ); |
|---|
| 201 | 203 | return VLC_SUCCESS; |
|---|
| 202 | 204 | } |
|---|