Mercurial > audlegacy
comparison Plugins/Input/console/Audacious_Driver.cpp @ 1127:a49cc8e8e38d trunk
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
| author | nenolod |
|---|---|
| date | Sat, 03 Jun 2006 12:09:25 -0700 |
| parents | 537e8cc47060 |
| children | 69b1707d83a5 |
comparison
equal
deleted
inserted
replaced
| 1126:537e8cc47060 | 1127:a49cc8e8e38d |
|---|---|
| 12 #include "libaudacious/configdb.h" | 12 #include "libaudacious/configdb.h" |
| 13 #include "libaudacious/util.h" | 13 #include "libaudacious/util.h" |
| 14 #include "libaudacious/titlestring.h" | 14 #include "libaudacious/titlestring.h" |
| 15 extern "C" { | 15 extern "C" { |
| 16 #include "audacious/output.h" | 16 #include "audacious/output.h" |
| 17 #include "audacious/playlist.h" | |
| 17 } | 18 } |
| 18 #include <string.h> | 19 #include <string.h> |
| 19 #include <stdlib.h> | 20 #include <stdlib.h> |
| 20 #include <ctype.h> | 21 #include <ctype.h> |
| 21 #include <math.h> | 22 #include <math.h> |
| 463 | 464 |
| 464 static void get_song_info( char* path, char** title, int* length ) | 465 static void get_song_info( char* path, char** title, int* length ) |
| 465 { | 466 { |
| 466 int track = 0; // to do: way to select other tracks | 467 int track = 0; // to do: way to select other tracks |
| 467 | 468 |
| 469 // extract the subsong id from the virtual path | |
| 470 gchar *path2 = g_strdup(path); | |
| 471 gchar *_path = strchr(path2, '?'); | |
| 472 | |
| 473 if (_path != NULL && *_path == '?') | |
| 474 { | |
| 475 *_path = '\0'; | |
| 476 _path++; | |
| 477 track = atoi(_path); | |
| 478 } | |
| 479 | |
| 468 *length = -1; | 480 *length = -1; |
| 469 *title = NULL; | 481 *title = NULL; |
| 470 Audacious_Reader in; | 482 Audacious_Reader in; |
| 471 tag_t tag; | 483 tag_t tag; |
| 472 if ( in.open( path ) || in.read( tag, sizeof tag ) ) | 484 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
| 473 return; | 485 return; |
| 474 | 486 |
| 475 int type = identify_file( path, tag ); | 487 int type = identify_file( path2, tag ); |
| 476 if ( !type ) | 488 if ( !type ) |
| 477 return; | 489 return; |
| 478 | 490 |
| 479 track_info_t info; | 491 track_info_t info; |
| 480 if ( begin_get_info( path, &info ) ) | 492 if ( begin_get_info( path2, &info ) ) |
| 481 return; | 493 return; |
| 482 info.track = track; | 494 info.track = track; |
| 483 | 495 |
| 484 switch ( type ) | 496 switch ( type ) |
| 485 { | 497 { |
| 489 case type_vgm: get_info_t( tag, in, &info, (Vgm_Emu::header_t*) 0 ); break; | 501 case type_vgm: get_info_t( tag, in, &info, (Vgm_Emu::header_t*) 0 ); break; |
| 490 case type_spc: get_info_t( tag, in, &info, (Spc_Emu::header_t*) 0 ); break; | 502 case type_spc: get_info_t( tag, in, &info, (Spc_Emu::header_t*) 0 ); break; |
| 491 case type_nsfe:get_info_t( tag, in, &info, (Nsfe_Emu::header_t*)0 ); break; | 503 case type_nsfe:get_info_t( tag, in, &info, (Nsfe_Emu::header_t*)0 ); break; |
| 492 } | 504 } |
| 493 *title = end_get_info( info, length, 0 ); | 505 *title = end_get_info( info, length, 0 ); |
| 506 | |
| 507 g_free(path2); | |
| 494 } | 508 } |
| 495 | 509 |
| 496 // Playback | 510 // Playback |
| 497 | 511 |
| 498 static void* play_loop_track( gpointer ) | 512 static void* play_loop_track( gpointer ) |
| 570 unload_file(); | 584 unload_file(); |
| 571 Audacious_Reader in; | 585 Audacious_Reader in; |
| 572 tag_t tag; | 586 tag_t tag; |
| 573 | 587 |
| 574 // extract the subsong id from the virtual path | 588 // extract the subsong id from the virtual path |
| 575 gchar *_path = strchr(path, '?'); | 589 gchar *path2 = g_strdup(path); |
| 590 gchar *_path = strchr(path2, '?'); | |
| 576 | 591 |
| 577 if (_path != NULL && *_path == '?') | 592 if (_path != NULL && *_path == '?') |
| 578 { | 593 { |
| 579 *_path = '\0'; | 594 *_path = '\0'; |
| 580 _path++; | 595 _path++; |
| 581 track = atoi(_path); | 596 track = atoi(_path); |
| 582 } | 597 } |
| 583 | 598 |
| 584 if ( in.open( path ) || in.read( tag, sizeof tag ) ) | 599 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
| 585 return; | 600 return; |
| 586 int type = identify_file( path, tag ); | 601 int type = identify_file( path2, tag ); |
| 587 | 602 |
| 588 // setup info | 603 // setup info |
| 589 long sample_rate = 44100; | 604 long sample_rate = 44100; |
| 590 if ( type == type_spc ) | 605 if ( type == type_spc ) |
| 591 sample_rate = Spc_Emu::native_sample_rate; | 606 sample_rate = Spc_Emu::native_sample_rate; |
| 592 if ( audcfg.resample ) | 607 if ( audcfg.resample ) |
| 593 sample_rate = audcfg.resample_rate; | 608 sample_rate = audcfg.resample_rate; |
| 594 track_info_t info; | 609 track_info_t info; |
| 595 info.track = track; | 610 info.track = track; |
| 596 if ( begin_get_info( path, &info ) ) | 611 if ( begin_get_info( path2, &info ) ) |
| 597 return; | 612 return; |
| 598 | 613 |
| 599 // load in emulator and get info | 614 // load in emulator and get info |
| 600 switch ( type ) | 615 switch ( type ) |
| 601 { | 616 { |
| 642 pending_seek = -1; | 657 pending_seek = -1; |
| 643 track_ended = 0; | 658 track_ended = 0; |
| 644 track_emu.start_track( emu, track, length, !has_length ); | 659 track_emu.start_track( emu, track, length, !has_length ); |
| 645 console_ip_is_going = 1; | 660 console_ip_is_going = 1; |
| 646 decode_thread = g_thread_create( play_loop_track, NULL, TRUE, NULL ); | 661 decode_thread = g_thread_create( play_loop_track, NULL, TRUE, NULL ); |
| 662 g_free(path2); | |
| 647 } | 663 } |
| 648 | 664 |
| 649 static void seek( gint time ) | 665 static void seek( gint time ) |
| 650 { | 666 { |
| 651 // to do: be sure seek works at all | 667 // to do: be sure seek works at all |
| 718 | 734 |
| 719 printf("number of tracks: %d\n", emu->track_count()); | 735 printf("number of tracks: %d\n", emu->track_count()); |
| 720 | 736 |
| 721 for (int i = 0; i < emu->track_count(); i++) | 737 for (int i = 0; i < emu->track_count(); i++) |
| 722 { | 738 { |
| 723 printf("path[%d]: %s?%d\n", i, path2, i); | 739 gchar _buf[65535]; |
| 740 g_snprintf(_buf, 65535, "%s?%d", path2, i); | |
| 741 | |
| 742 playlist_add_url(_buf); | |
| 743 | |
| 724 } | 744 } |
| 725 | 745 |
| 726 unload_file(); | 746 unload_file(); |
| 727 } | 747 } |
| 728 | 748 |
