| 329 | | msg_Err( p_this, "Out of memory" ); |
|---|
| 330 | | return; |
|---|
| | 333 | msg_Dbg( p_this, "Handshaking with last.fm ..." ); |
|---|
| | 334 | i_handshake = Handshake( p_this ); |
|---|
| | 335 | |
|---|
| | 336 | if( i_handshake == VLC_ENOMEM ) |
|---|
| | 337 | { |
|---|
| | 338 | msg_Err( p_this, "Out of memory" ); |
|---|
| | 339 | return; |
|---|
| | 340 | } |
|---|
| | 341 | |
|---|
| | 342 | else if( i_handshake == VLC_ENOVAR ) |
|---|
| | 343 | /* username not set */ |
|---|
| | 344 | { |
|---|
| | 345 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 346 | intf_UserFatal( p_this, VLC_FALSE, |
|---|
| | 347 | _("last.fm username not set"), |
|---|
| | 348 | _("You have to set a username," |
|---|
| | 349 | " and then restart VLC.\n" |
|---|
| | 350 | "Visit https://www.last.fm/join/" |
|---|
| | 351 | " if you don't have one.") |
|---|
| | 352 | ); |
|---|
| | 353 | return; |
|---|
| | 354 | } |
|---|
| | 355 | |
|---|
| | 356 | else if( i_handshake == VLC_SUCCESS ) |
|---|
| | 357 | { |
|---|
| | 358 | msg_Dbg( p_this, "Handshake successfull :)" ); |
|---|
| | 359 | vlc_mutex_lock ( &p_sys->lock ); |
|---|
| | 360 | p_sys->b_handshaked = VLC_TRUE; |
|---|
| | 361 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 362 | } |
|---|
| | 363 | |
|---|
| | 364 | else |
|---|
| | 365 | /* VLC_GENERIC : we'll try later */ |
|---|
| | 366 | { |
|---|
| | 367 | vlc_mutex_lock ( &p_sys->lock ); |
|---|
| | 368 | p_sys->i_interval = DEFAULT_INTERVAL; |
|---|
| | 369 | time( &p_sys->time_last_interval ); |
|---|
| | 370 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 371 | } |
|---|
| 332 | | |
|---|
| 333 | | else if( i_handshake == VLC_ENOVAR ) |
|---|
| 334 | | /* username not set */ |
|---|
| | 373 | } |
|---|
| | 374 | |
|---|
| | 375 | |
|---|
| | 376 | msg_Dbg( p_this, "Going to submit some data..." ); |
|---|
| | 377 | vlc_mutex_lock ( &p_sys->lock ); |
|---|
| | 378 | psz_submit_string = malloc( 2048 * sizeof( char ) ); |
|---|
| | 379 | |
|---|
| | 380 | if (!psz_submit_string) |
|---|
| | 381 | { |
|---|
| | 382 | msg_Err( p_this, "Out of memory" ); |
|---|
| | 383 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 384 | return; |
|---|
| | 385 | } |
|---|
| | 386 | |
|---|
| | 387 | for (i_song = 0; i_song < p_sys->p_first_queue->i_songs_nb ; |
|---|
| | 388 | i_song++ ) |
|---|
| | 389 | { |
|---|
| | 390 | snprintf( psz_submit_string, 2048, POST_DATA, |
|---|
| | 391 | p_sys->psz_username, p_sys->psz_response_md5, |
|---|
| | 392 | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_a, |
|---|
| | 393 | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_t, |
|---|
| | 394 | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_b, |
|---|
| | 395 | i_song, |
|---|
| | 396 | i_song, p_sys->p_first_queue->p_queue[i_song]->i_l, |
|---|
| | 397 | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_i |
|---|
| | 398 | ); |
|---|
| | 399 | } |
|---|
| | 400 | |
|---|
| | 401 | p_sys->i_post_socket = net_ConnectTCP( p_this, |
|---|
| | 402 | p_sys->psz_submit_host, p_sys->i_submit_port); |
|---|
| | 403 | |
|---|
| | 404 | i_netprintf = net_Printf( |
|---|
| | 405 | VLC_OBJECT(p_this), p_sys->i_post_socket, NULL, |
|---|
| | 406 | POST_REQUEST, p_sys->psz_submit_file, |
|---|
| | 407 | strlen( psz_submit_string), p_sys->psz_submit_file, |
|---|
| | 408 | VERSION, psz_submit_string |
|---|
| | 409 | ); |
|---|
| | 410 | |
|---|
| | 411 | if ( i_netprintf == -1 ) |
|---|
| | 412 | { |
|---|
| | 413 | /* If connection fails, we assume we must handshake again */ |
|---|
| | 414 | p_sys->i_interval = DEFAULT_INTERVAL; |
|---|
| | 415 | time( &p_sys->time_last_interval ); |
|---|
| | 416 | p_sys->b_handshaked = VLC_FALSE; |
|---|
| | 417 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 418 | continue; |
|---|
| | 419 | } |
|---|
| | 420 | |
|---|
| | 421 | p_buffer = ( uint8_t* ) calloc( 1, 1024 ); |
|---|
| | 422 | if ( !p_buffer ) |
|---|
| | 423 | { |
|---|
| | 424 | msg_Err( p_this, "Out of memory" ); |
|---|
| | 425 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 426 | return; |
|---|
| | 427 | } |
|---|
| | 428 | |
|---|
| | 429 | net_Read( p_this, p_sys->i_post_socket, NULL, |
|---|
| | 430 | p_buffer, 1024, VLC_FALSE ); |
|---|
| | 431 | net_Close( p_sys->i_post_socket ); |
|---|
| | 432 | |
|---|
| | 433 | p_buffer_pos = strstr( ( char * ) p_buffer, "INTERVAL" ); |
|---|
| | 434 | |
|---|
| | 435 | if ( p_buffer_pos ) |
|---|
| | 436 | { |
|---|
| | 437 | p_sys->i_interval = atoi( p_buffer_pos + |
|---|
| | 438 | strlen( "INTERVAL " ) ); |
|---|
| | 439 | time( &p_sys->time_last_interval ); |
|---|
| | 440 | } |
|---|
| | 441 | |
|---|
| | 442 | p_buffer_pos = strstr( ( char * ) p_buffer, "FAILED" ); |
|---|
| | 443 | |
|---|
| | 444 | if ( p_buffer_pos ) |
|---|
| | 445 | { |
|---|
| | 446 | msg_Dbg( p_this, p_buffer_pos ); |
|---|
| | 447 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 448 | continue; |
|---|
| | 449 | } |
|---|
| | 450 | |
|---|
| | 451 | p_buffer_pos = strstr( ( char * ) p_buffer, "BADAUTH" ); |
|---|
| | 452 | |
|---|
| | 453 | if ( p_buffer_pos ) |
|---|
| | 454 | { |
|---|
| | 455 | msg_Dbg( p_this, "Authentification failed, handshaking again" ); |
|---|
| | 456 | p_sys->b_handshaked = VLC_FALSE; |
|---|
| | 457 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 458 | continue; |
|---|
| | 459 | } |
|---|
| | 460 | |
|---|
| | 461 | p_buffer_pos = strstr( ( char * ) p_buffer, "OK" ); |
|---|
| | 462 | |
|---|
| | 463 | if ( p_buffer_pos ) |
|---|
| | 464 | { |
|---|
| | 465 | if ( p_sys->p_first_queue->i_songs_nb == 10 ) |
|---|
| 356 | | } |
|---|
| 357 | | } |
|---|
| 358 | | |
|---|
| 359 | | else |
|---|
| 360 | | { |
|---|
| 361 | | if ( ( p_sys->p_first_queue->i_songs_nb > 0 ) && |
|---|
| 362 | | ( time( NULL ) >= |
|---|
| 363 | | ( p_sys->time_last_interval + p_sys->i_interval ) ) ) |
|---|
| 364 | | { |
|---|
| 365 | | msg_Dbg( p_this, "Going to submit some data..." ); |
|---|
| 366 | | vlc_mutex_lock ( &p_sys->lock ); |
|---|
| 367 | | psz_submit_string = malloc( 2048 * sizeof( char ) ); |
|---|
| 368 | | |
|---|
| 369 | | if (!psz_submit_string) |
|---|
| 370 | | { |
|---|
| 371 | | msg_Err( p_this, "Out of memory" ); |
|---|
| 372 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 373 | | return; |
|---|
| 374 | | } |
|---|
| 375 | | |
|---|
| 376 | | for (i_song = 0; i_song < p_sys->p_first_queue->i_songs_nb ; |
|---|
| 377 | | i_song++ ) |
|---|
| 378 | | { |
|---|
| 379 | | snprintf( psz_submit_string, 2048, POST_DATA, |
|---|
| 380 | | p_sys->psz_username, p_sys->psz_response_md5, |
|---|
| 381 | | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_a, |
|---|
| 382 | | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_t, |
|---|
| 383 | | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_b, |
|---|
| 384 | | i_song, |
|---|
| 385 | | i_song, p_sys->p_first_queue->p_queue[i_song]->i_l, |
|---|
| 386 | | i_song, p_sys->p_first_queue->p_queue[i_song]->psz_i |
|---|
| 387 | | ); |
|---|
| 388 | | } |
|---|
| 389 | | |
|---|
| 390 | | p_sys->i_post_socket = net_ConnectTCP( p_this, |
|---|
| 391 | | p_sys->psz_submit_host, p_sys->i_submit_port); |
|---|
| 392 | | |
|---|
| 393 | | i_netprintf = net_Printf( |
|---|
| 394 | | VLC_OBJECT(p_this), p_sys->i_post_socket, NULL, |
|---|
| 395 | | POST_REQUEST, p_sys->psz_submit_file, |
|---|
| 396 | | strlen( psz_submit_string), p_sys->psz_submit_file, |
|---|
| 397 | | VERSION, psz_submit_string |
|---|
| 398 | | ); |
|---|
| 399 | | |
|---|
| 400 | | if ( i_netprintf == -1 ) |
|---|
| 401 | | { |
|---|
| 402 | | /* If connection fails, we assume we must handshake again */ |
|---|
| 403 | | p_sys->i_interval = DEFAULT_INTERVAL; |
|---|
| 404 | | time( &p_sys->time_last_interval ); |
|---|
| 405 | | p_sys->b_handshaked = VLC_FALSE; |
|---|
| 406 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 407 | | return; |
|---|
| 408 | | } |
|---|
| 409 | | |
|---|
| 410 | | p_buffer = ( uint8_t* ) calloc( 1, 1024 ); |
|---|
| 411 | | if ( !p_buffer ) |
|---|
| 412 | | { |
|---|
| 413 | | msg_Err( p_this, "Out of memory" ); |
|---|
| 414 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 415 | | return; |
|---|
| 416 | | } |
|---|
| 417 | | |
|---|
| 418 | | net_Read( p_this, p_sys->i_post_socket, NULL, |
|---|
| 419 | | p_buffer, 1024, VLC_FALSE ); |
|---|
| 420 | | net_Close( p_sys->i_post_socket ); |
|---|
| 421 | | |
|---|
| 422 | | p_buffer_pos = strstr( ( char * ) p_buffer, "INTERVAL" ); |
|---|
| 423 | | |
|---|
| 424 | | if ( p_buffer_pos ) |
|---|
| 425 | | { |
|---|
| 426 | | p_sys->i_interval = atoi( p_buffer_pos + |
|---|
| 427 | | strlen( "INTERVAL " ) ); |
|---|
| 428 | | time( &p_sys->time_last_interval ); |
|---|
| 429 | | } |
|---|
| 430 | | |
|---|
| 431 | | p_buffer_pos = strstr( ( char * ) p_buffer, "FAILED" ); |
|---|
| 432 | | |
|---|
| 433 | | if ( p_buffer_pos ) |
|---|
| 434 | | { |
|---|
| 435 | | msg_Err( p_this, p_buffer_pos ); |
|---|
| 436 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 437 | | return; |
|---|
| 438 | | } |
|---|
| 439 | | |
|---|
| 440 | | p_buffer_pos = strstr( ( char * ) p_buffer, "BADAUTH" ); |
|---|
| 441 | | |
|---|
| 442 | | if ( p_buffer_pos ) |
|---|
| 443 | | { |
|---|
| 444 | | msg_Err( p_this, |
|---|
| 445 | | "Authentification failed, handshaking again" ); |
|---|
| 446 | | p_sys->b_handshaked = VLC_FALSE; |
|---|
| 447 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 448 | | return; |
|---|
| 449 | | } |
|---|
| 450 | | |
|---|
| 451 | | p_buffer_pos = strstr( ( char * ) p_buffer, "OK" ); |
|---|
| 452 | | |
|---|
| 453 | | if ( p_buffer_pos ) |
|---|
| 454 | | { |
|---|
| 455 | | if ( p_sys->p_first_queue->i_songs_nb == 10 ) |
|---|
| 456 | | { |
|---|
| 457 | | p_first_queue = p_sys->p_first_queue->p_next_queue; |
|---|
| 458 | | DeleteQueue( p_sys->p_first_queue ); |
|---|
| 459 | | free( p_sys->p_first_queue ); |
|---|
| 460 | | p_sys->p_first_queue = p_first_queue; |
|---|
| 461 | | } |
|---|
| 462 | | else |
|---|
| 463 | | { |
|---|
| 464 | | DeleteQueue( p_sys->p_first_queue ); |
|---|
| 465 | | p_sys->p_first_queue->i_songs_nb = 0; |
|---|
| 466 | | } |
|---|
| 467 | | msg_Dbg( p_this, "Submission successfull!" ); |
|---|
| 468 | | } |
|---|
| 469 | | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| 470 | | } |
|---|
| 471 | | } |
|---|
| | 477 | msg_Dbg( p_this, "Submission successfull!" ); |
|---|
| | 478 | } |
|---|
| | 479 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 480 | } |
|---|
| | 481 | |
|---|
| 904 | | /* TODO check that this works on every arch/platform (uint32_t to char) */ |
|---|
| 905 | | b1 = hexa( p_struct_md5->p_digest[i] % 256 ); |
|---|
| 906 | | b2 = hexa( ( p_struct_md5->p_digest[i] / 256 ) % 256 ); |
|---|
| 907 | | b3 = hexa( ( p_struct_md5->p_digest[i] / 65536 ) % 256 ); |
|---|
| 908 | | b4 = hexa( p_struct_md5->p_digest[i] / 16777216 ); |
|---|
| 909 | | sprintf( &psz_password_md5[8*i], "%s%s%s%s", b1, b2, b3, b4 ); |
|---|
| 910 | | free( b1 ); |
|---|
| 911 | | free( b2 ); |
|---|
| 912 | | free( b3 ); |
|---|
| 913 | | free( b4 ); |
|---|
| | 920 | sprintf( &psz_password_md5[8*i], "%02x%02x%02x%02x", |
|---|
| | 921 | p_struct_md5->p_digest[i] & 0xff, |
|---|
| | 922 | ( p_struct_md5->p_digest[i] >> 8 ) & 0xff, |
|---|
| | 923 | ( p_struct_md5->p_digest[i] >> 16 ) & 0xff, |
|---|
| | 924 | p_struct_md5->p_digest[i] >> 24 |
|---|
| | 925 | ); |
|---|
| | 1003 | input_thread_t *p_input = NULL; |
|---|
| | 1004 | vlc_value_t video_val; |
|---|
| | 1005 | |
|---|
| | 1006 | intf_sys_t *p_sys = p_this->p_sys; |
|---|
| | 1007 | |
|---|
| | 1008 | p_playlist = pl_Yield( p_this ); |
|---|
| | 1009 | PL_LOCK; |
|---|
| | 1010 | p_input = p_playlist->p_input; |
|---|
| | 1011 | |
|---|
| | 1012 | if( !p_input ) |
|---|
| | 1013 | { |
|---|
| | 1014 | PL_UNLOCK; |
|---|
| | 1015 | pl_Release( p_playlist ); |
|---|
| | 1016 | return( VLC_SUCCESS ); |
|---|
| | 1017 | } |
|---|
| | 1018 | |
|---|
| | 1019 | vlc_object_yield( p_input ); |
|---|
| | 1020 | PL_UNLOCK; |
|---|
| | 1021 | pl_Release( p_playlist ); |
|---|
| | 1022 | |
|---|
| | 1023 | var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &video_val, NULL ); |
|---|
| | 1024 | if( ( video_val.i_int > 0 ) || \ |
|---|
| | 1025 | ( p_input->input.p_item->i_type == ITEM_TYPE_NET ) ) |
|---|
| | 1026 | { |
|---|
| | 1027 | msg_Dbg( p_this, "Not an audio file -> no submission"); |
|---|
| | 1028 | vlc_object_release( p_input ); |
|---|
| | 1029 | |
|---|
| | 1030 | vlc_mutex_lock( &p_sys->lock ); |
|---|
| | 1031 | p_sys->b_queued = VLC_TRUE; |
|---|
| | 1032 | p_sys->b_metadata_read = VLC_TRUE; |
|---|
| | 1033 | vlc_mutex_unlock( &p_sys->lock ); |
|---|
| | 1034 | |
|---|
| | 1035 | return VLC_SUCCESS; |
|---|
| | 1036 | } |
|---|
| | 1037 | |
|---|
| | 1038 | return ReadLocalMetaData( p_this, p_input ); |
|---|
| | 1039 | } |
|---|
| | 1040 | |
|---|
| | 1041 | /***************************************************************************** |
|---|
| | 1042 | * ReadLocalMetaData : Puts current song's meta data in p_sys->p_current_song |
|---|
| | 1043 | *****************************************************************************/ |
|---|
| | 1044 | static int ReadLocalMetaData( intf_thread_t *p_this, input_thread_t *p_input ) |
|---|
| | 1045 | { |
|---|
| 1014 | | p_playlist = pl_Yield( p_this ); |
|---|
| 1015 | | PL_LOCK; |
|---|
| 1016 | | p_input = p_playlist->p_input; |
|---|
| 1017 | | |
|---|
| 1018 | | if( !p_input ) |
|---|
| 1019 | | { |
|---|
| 1020 | | PL_UNLOCK; |
|---|
| 1021 | | pl_Release( p_playlist ); |
|---|
| 1022 | | return( VLC_SUCCESS ); |
|---|
| 1023 | | } |
|---|
| 1024 | | |
|---|
| 1025 | | vlc_object_yield( p_input ); |
|---|
| 1026 | | PL_UNLOCK; |
|---|
| 1027 | | pl_Release( p_playlist ); |
|---|
| 1028 | | |
|---|
| 1029 | | if ( p_input->input.p_item->i_type == ITEM_TYPE_NET ) |
|---|
| 1030 | | { |
|---|
| 1031 | | msg_Dbg( p_this, "We play a stream -> no submission"); |
|---|
| 1032 | | goto no_submission; |
|---|
| 1033 | | } |
|---|
| 1034 | | |
|---|
| 1035 | | var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &video_val, NULL ); |
|---|
| 1036 | | if( video_val.i_int > 0 ) |
|---|
| 1037 | | { |
|---|
| 1038 | | msg_Dbg( p_this, "We play a video -> no submission"); |
|---|
| 1039 | | goto no_submission; |
|---|
| 1040 | | } |
|---|
| 1041 | | |
|---|
| 1042 | | if ( p_input->input.p_item->p_meta->psz_artist ) |
|---|
| 1043 | | { |
|---|
| 1044 | | psz_artist = encode_URI_component( |
|---|
| 1045 | | p_input->input.p_item->p_meta->psz_artist ); |
|---|
| 1046 | | if ( !psz_artist ) |
|---|
| 1047 | | { |
|---|
| 1048 | | goto error; |
|---|
| 1049 | | } |
|---|
| 1050 | | } |
|---|
| 1051 | | else |
|---|
| 1052 | | { |
|---|
| 1053 | | msg_Dbg( p_this, "No artist.." ); |
|---|
| 1054 | | goto no_submission; |
|---|
| 1055 | | } |
|---|
| 1056 | | |
|---|
| 1057 | | if ( p_input->input.p_item->p_meta->psz_album ) |
|---|
| 1058 | | { |
|---|
| 1059 | | psz_album = encode_URI_component( |
|---|
| 1060 | | p_input->input.p_item->p_meta->psz_album ); |
|---|
| 1061 | | if ( !psz_album ) |
|---|
| 1062 | | { |
|---|
| 1063 | | goto error; |
|---|
| 1064 | | } |
|---|
| 1065 | | } |
|---|
| 1066 | | else |
|---|
| 1067 | | { |
|---|
| 1068 | | psz_album = calloc( 1, sizeof( char ) ); |
|---|
| 1069 | | } |
|---|
| 1070 | | |
|---|
| 1071 | | if ( p_input->input.p_item->psz_name ) |
|---|
| 1072 | | { |
|---|
| 1073 | | psz_title = encode_URI_component( p_input->input.p_item->psz_name ); |
|---|
| 1074 | | if ( !psz_title ) |
|---|
| 1075 | | { |
|---|
| 1076 | | goto error; |
|---|
| 1077 | | } |
|---|
| 1078 | | } |
|---|
| 1079 | | else |
|---|
| 1080 | | { |
|---|
| 1081 | | msg_Dbg( p_this, "No track name.." ); |
|---|
| 1082 | | goto no_submission; |
|---|
| 1083 | | } |
|---|
| 1084 | | |
|---|
| 1085 | | i_length = p_input->input.p_item->i_duration / 1000000; |
|---|
| 1086 | | |
|---|
| | 1055 | i_status = p_input->input.p_item->p_meta->i_status; |
|---|
| | 1056 | |
|---|
| | 1057 | vlc_mutex_lock( &p_sys->lock ); |
|---|
| | 1058 | b_waiting = p_sys->b_waiting_meta; |
|---|
| | 1059 | vlc_mutex_unlock( &p_sys->lock ); |
|---|
| | 1060 | |
|---|
| | 1061 | /* TODO : remove if (1) when meta_engine works */ |
|---|
| | 1062 | if ( (1/*( i_status & ITEM_PREPARSED )*/&& ( b_waiting == VLC_FALSE ) ) || \ |
|---|
| | 1063 | ( ( i_status & ITEM_META_FETCHED ) && ( b_waiting == VLC_TRUE ) ) ) |
|---|
| | 1064 | { |
|---|
| | 1065 | if ( p_input->input.p_item->p_meta->psz_artist ) |
|---|
| | 1066 | { |
|---|
| | 1067 | psz_artist = encode_URI_component( |
|---|
| | 1068 | p_input->input.p_item->p_meta->psz_artist ); |
|---|
| | 1069 | if ( !psz_artist ) |
|---|
| | 1070 | { |
|---|
| | 1071 | goto error; |
|---|
| | 1072 | } |
|---|
| | 1073 | } |
|---|
| | 1074 | else |
|---|
| | 1075 | { |
|---|
| | 1076 | msg_Dbg( p_this, "No artist.." ); |
|---|
| | 1077 | if ( b_waiting == VLC_TRUE ) |
|---|
| | 1078 | { |
|---|
| | 1079 | psz_artist = calloc( 1, sizeof( char ) ); |
|---|
| | 1080 | } |
|---|
| | 1081 | else |
|---|
| | 1082 | { |
|---|
| | 1083 | goto waiting_meta_data_fetching; |
|---|
| | 1084 | } |
|---|
| | 1085 | } |
|---|
| | 1086 | |
|---|
| | 1087 | if ( p_input->input.p_item->psz_name ) |
|---|
| | 1088 | { |
|---|
| | 1089 | psz_title = encode_URI_component( p_input->input.p_item->psz_name ); |
|---|
| | 1090 | if ( !psz_title ) |
|---|
| | 1091 | { |
|---|
| | 1092 | goto error; |
|---|
| | 1093 | } |
|---|
| | 1094 | } |
|---|
| | 1095 | else |
|---|
| | 1096 | { |
|---|
| | 1097 | msg_Dbg( p_this, "No track name.." ); |
|---|
| | 1098 | if ( b_waiting == VLC_TRUE ) |
|---|
| | 1099 | { |
|---|
| | 1100 | psz_title = calloc( 1, sizeof( char ) ); |
|---|
| | 1101 | } |
|---|
| | 1102 | else |
|---|
| | 1103 | { |
|---|
| | 1104 | goto waiting_meta_data_fetching; |
|---|
| | 1105 | } |
|---|
| | 1106 | } |
|---|
| | 1107 | |
|---|
| | 1108 | if ( p_input->input.p_item->p_meta->psz_album ) |
|---|
| | 1109 | { |
|---|
| | 1110 | psz_album = encode_URI_component( |
|---|
| | 1111 | p_input->input.p_item->p_meta->psz_album ); |
|---|
| | 1112 | if ( !psz_album ) |
|---|
| | 1113 | { |
|---|
| | 1114 | goto error; |
|---|
| | 1115 | } |
|---|
| | 1116 | } |
|---|
| | 1117 | else |
|---|
| | 1118 | { |
|---|
| | 1119 | psz_album = calloc( 1, sizeof( char ) ); |
|---|
| | 1120 | } |
|---|
| | 1121 | |
|---|
| | 1122 | i_length = p_input->input.p_item->i_duration / 1000000; |
|---|
| | 1123 | |
|---|
| | 1124 | vlc_object_release( p_input ); |
|---|
| | 1125 | |
|---|
| | 1126 | vlc_mutex_lock ( &p_sys->lock ); |
|---|
| | 1127 | |
|---|
| | 1128 | p_sys->p_current_song->psz_a = strdup( psz_artist ); |
|---|
| | 1129 | p_sys->p_current_song->psz_t = strdup( psz_title ); |
|---|
| | 1130 | p_sys->p_current_song->psz_b = strdup( psz_album ); |
|---|
| | 1131 | p_sys->p_current_song->i_l = i_length; |
|---|
| | 1132 | p_sys->b_queued = VLC_FALSE; |
|---|
| | 1133 | p_sys->b_metadata_read = VLC_TRUE; |
|---|
| | 1134 | |
|---|
| | 1135 | vlc_mutex_unlock ( &p_sys->lock ); |
|---|
| | 1136 | |
|---|
| | 1137 | msg_Dbg( p_this, "Meta data registered, waiting to be queued" ); |
|---|
| | 1138 | |
|---|
| | 1139 | free( psz_title ); |
|---|
| | 1140 | free( psz_artist ); |
|---|
| | 1141 | free( psz_album ); |
|---|
| | 1142 | |
|---|
| | 1143 | return VLC_SUCCESS; |
|---|
| | 1144 | } |
|---|
| | 1145 | |
|---|
| | 1146 | return VLC_SUCCESS; |
|---|
| | 1147 | |
|---|
| | 1148 | waiting_meta_data_fetching: |
|---|