Mercurial > audlegacy
annotate Plugins/Input/console/Audacious_Driver.cxx @ 1691:e24213152357 trunk
[svn] .cpp -> .cxx
This has the nice side effect that we don't need to add .cpp to .SUFFIXES for OpenBSD.
author | js |
---|---|
date | Thu, 14 Sep 2006 13:33:10 -0700 |
parents | Plugins/Input/console/Audacious_Driver.cpp@eff9a84c54bf |
children |
rev | line source |
---|---|
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
1 /* |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
2 * Audacious: Cross platform multimedia player |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
3 * Copyright (c) 2005 Audacious Team |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
4 * |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
5 * Driver for Game_Music_Emu library. See details at: |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
6 * http://www.slack.net/~ant/libs/ |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
7 */ |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
8 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
9 #include <glib.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
10 #include <glib/gi18n.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
11 #include <gtk/gtk.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
12 #include "libaudacious/util.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
13 #include "libaudacious/titlestring.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
14 extern "C" { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
15 #include "audacious/output.h" |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
16 #include "audacious/playlist.h" |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
17 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
18 #include <string.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
19 #include <stdlib.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
20 #include <ctype.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
21 #include <math.h> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
22 |
1403 | 23 // configdb and prefs ui |
24 #include "Audacious_Config.h" | |
25 | |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
26 // Game_Music_Emu |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
27 #include "Nsf_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
28 #include "Nsfe_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
29 #include "Gbs_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
30 #include "Vgm_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
31 #include "Gym_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
32 #include "Spc_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
33 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
34 #include "Track_Emu.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
35 #include "Vfs_File.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
36 #include "Gzip_File.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
37 #include "blargg_endian.h" |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
38 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
39 //typedef Vfs_File_Reader Audacious_Reader; // will use VFS once it handles gzip transparently |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
40 typedef Gzip_File_Reader Audacious_Reader; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
41 |
1405
cb985fe460cd
[svn] - libconsole: added an option to ignore length information from spc tags
giacomo
parents:
1403
diff
changeset
|
42 AudaciousConsoleConfig audcfg = { 180, FALSE, 32000, TRUE, 0, 0, FALSE }; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
43 static GThread* decode_thread; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
44 static GStaticMutex playback_mutex = G_STATIC_MUTEX_INIT; |
499
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
45 static int console_ip_is_going; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
46 static volatile long pending_seek; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
47 extern InputPlugin console_ip; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
48 static Music_Emu* emu = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
49 static Track_Emu track_emu; |
528
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
50 static int track_ended; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
51 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
52 static void unload_file() |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
53 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
54 delete emu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
55 emu = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
56 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
57 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
58 // Information |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
59 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
60 typedef unsigned char byte; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
61 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
62 #define DUPE_FIELD( field ) g_strndup( field, sizeof (field) ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
63 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
64 struct track_info_t |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
65 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
66 int track; // track to get info for |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
67 int length; // in msec, -1 = unknown |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
68 int loop; // in msec, -1 = unknown, 0 = not looped |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
69 int intro; // in msec, -1 = unknown |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
70 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
71 TitleInput* ti; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
72 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
73 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
74 // NSFE |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
75 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
76 void get_nsfe_info( Nsfe_Info const& nsfe, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
77 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
78 Nsfe_Info::info_t const& h = nsfe.info(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
79 out->ti->performer = DUPE_FIELD( h.author ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
80 out->ti->album_name = DUPE_FIELD( h.game ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
81 out->ti->comment = DUPE_FIELD( h.copyright ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
82 out->ti->track_name = g_strdup( nsfe.track_name( out->track ) ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
83 int time = nsfe.track_time( out->track ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
84 if ( time > 0 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
85 out->length = time; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
86 if ( nsfe.info().track_count > 1 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
87 out->ti->track_number = out->track + 1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
88 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
89 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
90 inline void get_info_emu( Nsfe_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
91 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
92 emu.enable_playlist( audcfg.nsfe_playlist ); // to do: kind of hacky |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
93 get_nsfe_info( emu, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
94 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
95 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
96 inline void get_file_info( Nsfe_Emu::header_t const& h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
97 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
98 Nsfe_Info nsfe; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
99 if ( !nsfe.load( h, in ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
100 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
101 nsfe.enable_playlist( audcfg.nsfe_playlist ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
102 get_nsfe_info( nsfe, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
103 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
104 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
105 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
106 // NSF |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
107 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
108 static void get_nsf_info_( Nsf_Emu::header_t const& h, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
109 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
110 out->ti->performer = DUPE_FIELD( h.author ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
111 out->ti->album_name = DUPE_FIELD( h.game ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
112 out->ti->comment = DUPE_FIELD( h.copyright ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
113 if ( h.track_count > 1 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
114 out->ti->track_number = out->track + 1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
115 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
116 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
117 inline void get_info_emu( Nsf_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
118 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
119 get_nsf_info_( emu.header(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
120 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
121 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
122 inline void get_file_info( Nsf_Emu::header_t const& h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
123 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
124 get_nsf_info_( h, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
125 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
126 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
127 // GBS |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
128 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
129 static void get_gbs_info_( Gbs_Emu::header_t const& h, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
130 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
131 out->ti->performer = DUPE_FIELD( h.author ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
132 out->ti->album_name = DUPE_FIELD( h.game ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
133 out->ti->comment = DUPE_FIELD( h.copyright ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
134 if ( h.track_count > 1 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
135 out->ti->track_number = out->track + 1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
136 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
137 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
138 inline void get_info_emu( Gbs_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
139 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
140 get_gbs_info_( emu.header(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
141 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
142 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
143 inline void get_file_info( Gbs_Emu::header_t const& h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
144 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
145 get_gbs_info_( h, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
146 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
147 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
148 // GYM |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
149 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
150 static void get_gym_info_( Gym_Emu::header_t const& h, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
151 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
152 if ( !memcmp( h.tag, "GYMX", 4 ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
153 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
154 out->ti->performer = DUPE_FIELD( h.copyright ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
155 out->ti->album_name = DUPE_FIELD( h.game ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
156 out->ti->track_name = DUPE_FIELD( h.song ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
157 out->ti->comment = DUPE_FIELD( h.comment ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
158 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
159 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
160 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
161 static void get_gym_timing_( Gym_Emu const& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
162 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
163 out->length = emu.track_length() * 50 / 3; // 1000 / 60 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
164 out->loop = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
165 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
166 long loop = get_le32( emu.header().loop_start ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
167 if ( loop ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
168 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
169 out->intro = loop * 50 / 3; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
170 out->loop = out->length - out->intro; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
171 out->length = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
172 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
173 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
174 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
175 inline void get_info_emu( Gym_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
176 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
177 get_gym_info_( emu.header(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
178 get_gym_timing_( emu, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
179 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
180 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
181 inline void get_file_info( Gym_Emu::header_t const& h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
182 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
183 get_gym_info_( h, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
184 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
185 // have to load and parse entire GYM file to determine length |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
186 // to do: could make more efficient by manually parsing data (format is simple) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
187 // rather than loading into emulator with its FM chips and resampler |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
188 Gym_Emu* emu = new Gym_Emu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
189 if ( emu && !emu->set_sample_rate( 44100 ) && !emu->load( h, in ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
190 get_gym_timing_( *emu, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
191 delete emu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
192 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
193 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
194 // SPC |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
195 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
196 static void get_spc_xid6( byte const* begin, long size, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
197 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
198 // header |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
199 byte const* end = begin + size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
200 if ( size < 8 || memcmp( begin, "xid6", 4 ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
201 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
202 long info_size = get_le32( begin + 4 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
203 byte const* in = begin + 8; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
204 if ( end - in > info_size ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
205 end = in + info_size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
206 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
207 while ( end - in >= 4 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
208 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
209 // header |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
210 int id = in [0]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
211 int data = in [3] * 0x100 + in [2]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
212 int type = in [1]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
213 int len = type ? data : 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
214 in += 4; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
215 if ( len > end - in ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
216 break; // block goes past end of data |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
217 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
218 // handle specific block types |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
219 switch ( id ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
220 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
221 case 0x01: out->ti->track_name = g_strndup( (char*) in, len ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
222 case 0x02: out->ti->album_name = g_strndup( (char*) in, len ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
223 case 0x03: out->ti->performer = g_strndup( (char*) in, len ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
224 case 0x07: out->ti->comment = g_strndup( (char*) in, len ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
225 //case 0x31: // loop length, but I haven't found any SPC files that use this |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
226 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
227 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
228 // skip to next block |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
229 in += len; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
230 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
231 // blocks are supposed to be 4-byte aligned with zero-padding... |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
232 byte const* unaligned = in; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
233 while ( (in - begin) & 3 && in < end ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
234 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
235 if ( *in++ != 0 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
236 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
237 // ...but some files have no padding |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
238 in = unaligned; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
239 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
240 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
241 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
242 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
243 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
244 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
245 static void get_spc_info_( Spc_Emu::header_t const& h, byte const* xid6, long xid6_size, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
246 track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
247 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
248 // decode length (can be in text or binary format) |
1395 | 249 char s [4] = { h.len_secs [0], h.len_secs [1], h.len_secs [2], 0 }; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
250 int len_secs = (unsigned char) s [1] * 0x100 + s [0]; |
1395 | 251 if ( s [1] >= ' ' || (!s [1] && isdigit( s [0] )) ) |
252 len_secs = atoi( s ); | |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
253 if ( len_secs ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
254 out->length = len_secs * 1000; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
255 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
256 if ( xid6_size ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
257 get_spc_xid6( xid6, xid6_size, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
258 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
259 // use header to fill any remaining fields |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
260 if ( !out->ti->performer ) out->ti->performer = DUPE_FIELD( h.author ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
261 if ( !out->ti->album_name ) out->ti->album_name = DUPE_FIELD( h.game ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
262 if ( !out->ti->track_name ) out->ti->track_name = DUPE_FIELD( h.song ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
263 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
264 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
265 inline void get_info_emu( Spc_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
266 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
267 get_spc_info_( emu.header(), emu.trailer(), emu.trailer_size(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
268 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
269 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
270 inline void get_file_info( Spc_Emu::header_t const& h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
271 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
272 // handle xid6 data at end of file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
273 long const xid6_skip = 0x10200 - sizeof (Spc_Emu::header_t); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
274 long xid6_size = in.remain() - xid6_skip; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
275 blargg_vector<byte> xid6; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
276 if ( xid6_size <= 0 || xid6.resize( xid6_size ) || in.skip( xid6_skip ) || |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
277 in.read( xid6.begin(), xid6.size() ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
278 xid6_size = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
279 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
280 get_spc_info_( h, xid6.begin(), xid6_size, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
281 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
282 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
283 // VGM |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
284 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
285 static void get_gd3_str( byte const* in, byte const* end, gchar** out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
286 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
287 int len = (end - in) / 2 - 1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
288 if ( len > 0 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
289 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
290 *out = g_strndup( "", len ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
291 if ( !*out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
292 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
293 for ( int i = 0; i < len; i++ ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
294 (*out) [i] = in [i * 2]; // to do: convert to utf-8 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
295 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
296 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
297 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
298 static byte const* skip_gd3_str( byte const* in, byte const* end ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
299 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
300 while ( end - in >= 2 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
301 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
302 in += 2; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
303 if ( !(in [-2] | in [-1]) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
304 break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
305 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
306 return in; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
307 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
308 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
309 static byte const* get_gd3_pair( byte const* in, byte const* end, gchar** out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
310 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
311 byte const* mid = skip_gd3_str( in, end ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
312 if ( out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
313 get_gd3_str( in, mid, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
314 return skip_gd3_str( mid, end ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
315 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
316 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
317 static void get_vgm_gd3( byte const* in, long size, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
318 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
319 byte const* end = in + size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
320 in = get_gd3_pair( in, end, &out->ti->track_name ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
321 in = get_gd3_pair( in, end, &out->ti->album_name ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
322 in = get_gd3_pair( in, end, 0 ); // system |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
323 in = get_gd3_pair( in, end, &out->ti->performer ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
324 in = get_gd3_pair( in, end, 0 ); // copyright |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
325 // ... other fields (release date, dumper, notes) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
326 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
327 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
328 static void get_vgm_length( Vgm_Emu::header_t const& h, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
329 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
330 long length = get_le32( h.track_duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
331 if ( length > 0 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
332 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
333 out->length = length * 10 / 441; // 1000 / 44100 (VGM files used 44100 as timebase) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
334 out->loop = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
335 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
336 long loop = get_le32( h.loop_duration ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
337 if ( loop > 0 && get_le32( h.loop_offset ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
338 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
339 out->loop = loop * 10 / 441; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
340 out->intro = out->length - out->loop; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
341 out->length = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
342 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
343 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
344 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
345 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
346 inline void get_info_emu( Vgm_Emu& emu, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
347 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
348 get_vgm_length( emu.header(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
349 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
350 int size; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
351 byte const* data = emu.gd3_data( &size ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
352 if ( data ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
353 get_vgm_gd3( data + 12, size, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
354 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
355 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
356 inline void get_file_info( Vgm_Emu::header_t const& vgm_h, Data_Reader& in, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
357 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
358 get_vgm_length( vgm_h, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
359 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
360 // find gd3 header |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
361 long gd3_offset = get_le32( vgm_h.gd3_offset ) + offsetof(Vgm_Emu::header_t,gd3_offset) - |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
362 sizeof vgm_h; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
363 long gd3_max_size = in.remain() - gd3_offset; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
364 byte gd3_h [12]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
365 if ( gd3_offset <= 0 || gd3_max_size < (int) sizeof gd3_h ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
366 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
367 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
368 // read gd3 header |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
369 if ( in.skip( gd3_offset ) || in.read( gd3_h, sizeof gd3_h ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
370 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
371 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
372 // check header signature and version |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
373 if ( memcmp( gd3_h, "Gd3 ", 4 ) || get_le32( gd3_h + 4 ) >= 0x200 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
374 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
375 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
376 // get and check size |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
377 long gd3_size = get_le32( gd3_h + 8 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
378 if ( gd3_size > gd3_max_size - 12 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
379 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
380 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
381 // read and parse gd3 data |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
382 blargg_vector<byte> gd3; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
383 if ( gd3.resize( gd3_size ) || in.read( gd3.begin(), gd3.size() ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
384 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
385 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
386 get_vgm_gd3( gd3.begin(), gd3.size(), out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
387 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
388 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
389 // File identification |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
390 |
1198
311c4a27c3dd
[svn] - yeah, JMA sucks -- i don't have the time for this
nenolod
parents:
1196
diff
changeset
|
391 enum { type_none = 0, type_spc, type_nsf, type_nsfe, type_vgm, type_gbs, type_gym }; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
392 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
393 int const tag_size = 4; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
394 typedef char tag_t [tag_size]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
395 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
396 static int identify_file( gchar* path, tag_t tag ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
397 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
398 // GYM file format doesn't require *any* header, just the ".gym" extension |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
399 if ( g_str_has_suffix( path, ".gym" ) ) // to do: is pathname in unicode? |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
400 return type_gym; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
401 // to do: trust suffix for all file types, avoiding having to look inside files? |
1125
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
402 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
403 int result = type_none; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
404 if ( !memcmp( tag, "SNES", 4 ) ) result = type_spc; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
405 if ( !memcmp( tag, "NESM", 4 ) ) result = type_nsf; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
406 if ( !memcmp( tag, "NSFE", 4 ) ) result = type_nsfe; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
407 if ( !memcmp( tag, "GYMX", 4 ) ) result = type_gym; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
408 if ( !memcmp( tag, "GBS" , 3 ) ) result = type_gbs; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
409 if ( !memcmp( tag, "Vgm ", 4 ) ) result = type_vgm; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
410 return result; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
411 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
412 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
413 // Get info |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
414 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
415 static int begin_get_info( const char* path, track_info_t* out ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
416 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
417 out->track = 0; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
418 out->length = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
419 out->loop = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
420 out->intro = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
421 TitleInput* fields = bmp_title_input_new(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
422 out->ti = fields; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
423 if ( !fields ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
424 return true; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
425 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
426 fields->file_name = g_path_get_basename( path ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
427 fields->file_path = g_path_get_dirname( path ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
428 return false; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
429 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
430 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
431 static char* end_get_info( track_info_t const& info, int* length, bool* has_length ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
432 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
433 *length = info.length; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
434 if ( has_length ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
435 *has_length = (*length > 0); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
436 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
437 if ( *length <= 0 ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
438 *length = audcfg.loop_length * 1000; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
439 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
440 // use filename for formats that don't have field for name of game |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
441 // to do: strip off file extension |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
442 if ( !info.ti->track_name ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
443 info.ti->track_name = g_strdup( info.ti->file_name ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
444 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
445 char* result = xmms_get_titlestring( xmms_get_gentitle_format(), info.ti ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
446 g_free( info.ti ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
447 return result; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
448 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
449 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
450 template<class Header> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
451 inline void get_info_t( tag_t tag, Data_Reader& in, track_info_t* out, Header* ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
452 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
453 Header h; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
454 memcpy( &h, tag, tag_size ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
455 if ( !in.read( (char*) &h + tag_size, sizeof h - tag_size ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
456 get_file_info( h, in, out ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
457 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
458 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
459 static void get_song_info( char* path, char** title, int* length ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
460 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
461 int track = 0; // to do: way to select other tracks |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
462 |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
463 // extract the subsong id from the virtual path |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
464 gchar *path2 = g_strdup(path); |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
465 gchar *_path = strchr(path2, '?'); |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
466 |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
467 if (_path != NULL && *_path == '?') |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
468 { |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
469 *_path = '\0'; |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
470 _path++; |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
471 track = atoi(_path); |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
472 } |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
473 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
474 *length = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
475 *title = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
476 Audacious_Reader in; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
477 tag_t tag; |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
478 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
479 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
480 |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
481 int type = identify_file( path2, tag ); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
482 if ( !type ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
483 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
484 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
485 track_info_t info; |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
486 if ( begin_get_info( path2, &info ) ) |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
487 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
488 info.track = track; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
489 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
490 switch ( type ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
491 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
492 case type_nsf: get_info_t( tag, in, &info, (Nsf_Emu::header_t*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
493 case type_gbs: get_info_t( tag, in, &info, (Gbs_Emu::header_t*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
494 case type_gym: get_info_t( tag, in, &info, (Gym_Emu::header_t*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
495 case type_vgm: get_info_t( tag, in, &info, (Vgm_Emu::header_t*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
496 case type_spc: get_info_t( tag, in, &info, (Spc_Emu::header_t*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
497 case type_nsfe:get_info_t( tag, in, &info, (Nsfe_Emu::header_t*)0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
498 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
499 *title = end_get_info( info, length, 0 ); |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
500 |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
501 g_free(path2); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
502 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
503 |
1242
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
504 // Get tuple |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
505 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
506 static TitleInput *get_song_tuple( char *path ) |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
507 { |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
508 int track = 0; // to do: way to select other tracks |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
509 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
510 // extract the subsong id from the virtual path |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
511 gchar *path2 = g_strdup(path); |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
512 gchar *_path = strchr(path2, '?'); |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
513 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
514 if (_path != NULL && *_path == '?') |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
515 { |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
516 *_path = '\0'; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
517 _path++; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
518 track = atoi(_path); |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
519 } |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
520 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
521 Audacious_Reader in; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
522 tag_t tag; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
523 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
524 return NULL; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
525 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
526 int type = identify_file( path2, tag ); |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
527 if ( !type ) |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
528 return NULL; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
529 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
530 track_info_t info; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
531 if ( begin_get_info( path2, &info ) ) |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
532 return NULL; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
533 info.track = track; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
534 |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
535 switch ( type ) |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
536 { |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
537 case type_nsf: get_info_t( tag, in, &info, (Nsf_Emu::header_t*) 0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
538 case type_gbs: get_info_t( tag, in, &info, (Gbs_Emu::header_t*) 0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
539 case type_gym: get_info_t( tag, in, &info, (Gym_Emu::header_t*) 0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
540 case type_vgm: get_info_t( tag, in, &info, (Vgm_Emu::header_t*) 0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
541 case type_spc: get_info_t( tag, in, &info, (Spc_Emu::header_t*) 0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
542 case type_nsfe:get_info_t( tag, in, &info, (Nsfe_Emu::header_t*)0 ); break; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
543 } |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
544 |
1243
7c765d74d643
[svn] - fill in the length part of the tuple (oops)
nenolod
parents:
1242
diff
changeset
|
545 info.ti->length = info.length; |
7c765d74d643
[svn] - fill in the length part of the tuple (oops)
nenolod
parents:
1242
diff
changeset
|
546 |
7c765d74d643
[svn] - fill in the length part of the tuple (oops)
nenolod
parents:
1242
diff
changeset
|
547 if ( info.ti->length <= 0 ) |
7c765d74d643
[svn] - fill in the length part of the tuple (oops)
nenolod
parents:
1242
diff
changeset
|
548 info.ti->length = audcfg.loop_length * 1000; |
7c765d74d643
[svn] - fill in the length part of the tuple (oops)
nenolod
parents:
1242
diff
changeset
|
549 |
1242
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
550 return info.ti; |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
551 } |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
552 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
553 // Playback |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
554 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
555 static void* play_loop_track( gpointer ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
556 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
557 g_static_mutex_lock( &playback_mutex ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
558 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
559 while ( console_ip_is_going ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
560 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
561 int const buf_size = 1024; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
562 Music_Emu::sample_t buf [buf_size]; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
563 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
564 // handle pending seek |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
565 long s = pending_seek; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
566 pending_seek = -1; // to do: use atomic swap |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
567 if ( s >= 0 ) |
497
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
568 { |
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
569 console_ip.output->flush( s * 1000 ); |
495
a371216b5c8a
[svn] Close enough... does some sort of speedup for 3 seconds like timidity, but close enough.
nenolod
parents:
494
diff
changeset
|
570 track_emu.seek( s * 1000 ); |
497
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
571 } |
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
572 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
573 // fill buffer |
528
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
574 if ( track_ended ) |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
575 { |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
576 if ( track_ended++ > emu->sample_rate() * 3 / (buf_size / 2) ) |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
577 console_ip_is_going = false; |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
578 memset( buf, 0, sizeof buf ); |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
579 } |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
580 else if ( track_emu.play( buf_size, buf ) ) |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
581 { |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
582 track_ended = 1; |
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
583 } |
497
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
584 produce_audio( console_ip.output->written_time(), |
499
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
585 FMT_S16_NE, 1, sizeof buf, buf, |
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
586 &console_ip_is_going ); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
587 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
588 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
589 // stop playing |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
590 unload_file(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
591 console_ip.output->close_audio(); |
499
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
592 console_ip_is_going = 0; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
593 g_static_mutex_unlock( &playback_mutex ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
594 // to do: should decode_thread be cleared here? |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
595 g_thread_exit( NULL ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
596 return NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
597 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
598 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
599 template<class Emu> |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
600 void load_file( tag_t tag, Data_Reader& in, long rate, track_info_t* out, Emu* dummy ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
601 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
602 typename Emu::header_t h; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
603 memcpy( &h, tag, tag_size ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
604 if ( in.read( (char*) &h + tag_size, sizeof h - tag_size ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
605 return; |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
606 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
607 if ( rate == 0 ) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
608 rate = 44100; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
609 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
610 Emu* local_emu = new Emu; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
611 if ( !local_emu || local_emu->set_sample_rate( rate ) || local_emu->load( h, in ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
612 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
613 delete local_emu; // delete NULL is safe |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
614 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
615 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
616 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
617 emu = local_emu; |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
618 if (out != NULL) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
619 get_info_emu( *local_emu, out ); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
620 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
621 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
622 static void play_file( char* path ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
623 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
624 int track = 0; // to do: some way to select other tracks |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
625 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
626 // open and identify file |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
627 unload_file(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
628 Audacious_Reader in; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
629 tag_t tag; |
1125
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
630 |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
631 // extract the subsong id from the virtual path |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
632 gchar *path2 = g_strdup(path); |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
633 gchar *_path = strchr(path2, '?'); |
1125
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
634 |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
635 if (_path != NULL && *_path == '?') |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
636 { |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
637 *_path = '\0'; |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
638 _path++; |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
639 track = atoi(_path); |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
640 } |
790c3a23eea2
[svn] - allow paths like /home/nenolod/moo/ff3/ff3.nsf?6 to play subsong 6 from ff3.nsf.
nenolod
parents:
1006
diff
changeset
|
641 |
1198
311c4a27c3dd
[svn] - yeah, JMA sucks -- i don't have the time for this
nenolod
parents:
1196
diff
changeset
|
642 if ( in.open( path2 ) || in.read( tag, sizeof tag ) ) |
311c4a27c3dd
[svn] - yeah, JMA sucks -- i don't have the time for this
nenolod
parents:
1196
diff
changeset
|
643 return; |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
644 int type = identify_file( path2, tag ); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
645 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
646 // setup info |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
647 long sample_rate = 44100; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
648 if ( type == type_spc ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
649 sample_rate = Spc_Emu::native_sample_rate; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
650 if ( audcfg.resample ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
651 sample_rate = audcfg.resample_rate; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
652 track_info_t info; |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
653 if ( begin_get_info( path2, &info ) ) |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
654 return; |
1128 | 655 info.track = track; |
656 | |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
657 // load in emulator and get info |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
658 switch ( type ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
659 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
660 case type_nsf: load_file( tag, in, sample_rate, &info, (Nsf_Emu*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
661 case type_nsfe:load_file( tag, in, sample_rate, &info, (Nsfe_Emu*)0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
662 case type_gbs: load_file( tag, in, sample_rate, &info, (Gbs_Emu*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
663 case type_gym: load_file( tag, in, sample_rate, &info, (Gym_Emu*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
664 case type_vgm: load_file( tag, in, sample_rate, &info, (Vgm_Emu*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
665 case type_spc: load_file( tag, in, sample_rate, &info, (Spc_Emu*) 0 ); break; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
666 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
667 in.close(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
668 if ( !emu ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
669 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
670 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
671 // set info |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
672 int length = -1; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
673 bool has_length = false; |
1405
cb985fe460cd
[svn] - libconsole: added an option to ignore length information from spc tags
giacomo
parents:
1403
diff
changeset
|
674 |
cb985fe460cd
[svn] - libconsole: added an option to ignore length information from spc tags
giacomo
parents:
1403
diff
changeset
|
675 if (( type == type_spc ) && ( audcfg.ignore_spc_length == TRUE )) |
cb985fe460cd
[svn] - libconsole: added an option to ignore length information from spc tags
giacomo
parents:
1403
diff
changeset
|
676 info.length = -1; |
cb985fe460cd
[svn] - libconsole: added an option to ignore length information from spc tags
giacomo
parents:
1403
diff
changeset
|
677 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
678 char* title = end_get_info( info, &length, &has_length ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
679 if ( title ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
680 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
681 console_ip.set_info( title, length, emu->voice_count() * 1000, sample_rate, 2 ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
682 g_free( title ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
683 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
684 |
1006 | 685 // set frequency equalization |
686 if ( audcfg.treble || audcfg.bass ) | |
687 { | |
688 Music_Emu::equalizer_t eq = emu->equalizer(); | |
689 | |
690 // bass - logarithmic, 2 to 8194 Hz | |
691 double bass = 1.0 - (audcfg.bass / 200.0 + 0.5); | |
692 eq.bass = (long int) pow(2.0, bass * 13.0) + (long int) 2.0; | |
693 | |
694 // treble - -50 to 0 to +5 dB | |
695 double treble = audcfg.treble / 100.0; | |
696 eq.treble = treble * (treble < 0 ? 50.0 : 5.0); | |
697 | |
698 emu->set_equalizer(eq); | |
699 } | |
700 | |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
701 // start |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
702 if ( !console_ip.output->open_audio( FMT_S16_NE, sample_rate, 2 ) ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
703 return; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
704 pending_seek = -1; |
528
980261e29f97
[svn] Patch for improved GYM/VGM file support ala blargg.
nenolod
parents:
499
diff
changeset
|
705 track_ended = 0; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
706 track_emu.start_track( emu, track, length, !has_length ); |
499
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
707 console_ip_is_going = 1; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
708 decode_thread = g_thread_create( play_loop_track, NULL, TRUE, NULL ); |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
709 g_free(path2); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
710 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
711 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
712 static void seek( gint time ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
713 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
714 // to do: be sure seek works at all |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
715 // to do: disallow seek on slow formats (SPC, GYM, VGM using FM)? |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
716 pending_seek = time; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
717 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
718 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
719 static void console_stop(void) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
720 { |
499
626c86bda311
[svn] If a track has a length, then we *really* do not want silence detection,
nenolod
parents:
497
diff
changeset
|
721 console_ip_is_going = 0; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
722 if ( decode_thread ) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
723 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
724 g_thread_join( decode_thread ); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
725 decode_thread = NULL; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
726 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
727 console_ip.output->close_audio(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
728 unload_file(); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
729 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
730 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
731 static void console_pause(gshort p) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
732 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
733 console_ip.output->pause(p); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
734 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
735 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
736 static int get_time(void) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
737 { |
497
dfba4ac44dd8
[svn] New output driver which makes use of Output objects ability to flush
nenolod
parents:
496
diff
changeset
|
738 return console_ip_is_going ? console_ip.output->output_time() : -1; |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
739 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
740 |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
741 static gint is_our_file( gchar* path ) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
742 { |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
743 Audacious_Reader in; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
744 tag_t tag; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
745 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
746 // extract the subsong id from the virtual path |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
747 gchar *path2 = g_strdup(path); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
748 gchar *_path = strchr(path2, '?'); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
749 gboolean is_subsong = FALSE; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
750 gint type; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
751 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
752 if (_path != NULL && *_path == '?') |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
753 { |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
754 *_path = '\0'; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
755 _path++; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
756 is_subsong = TRUE; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
757 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
758 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
759 gint ret = !in.open( path2 ) && !in.read( tag, sizeof tag ) && (type = identify_file( path2, tag )); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
760 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
761 if (ret == TRUE && is_subsong == FALSE) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
762 { |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
763 if (type == type_spc || type == type_gym || type == type_vgm) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
764 { |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
765 g_free(path2); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
766 return ret; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
767 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
768 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
769 switch ( type ) |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
770 { |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
771 case type_nsf: load_file( tag, in, 0, NULL, (Nsf_Emu*) 0 ); break; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
772 case type_nsfe:load_file( tag, in, 0, NULL, (Nsfe_Emu*)0 ); break; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
773 case type_gbs: load_file( tag, in, 0, NULL, (Gbs_Emu*) 0 ); break; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
774 case type_gym: load_file( tag, in, 0, NULL, (Gym_Emu*) 0 ); break; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
775 case type_vgm: load_file( tag, in, 0, NULL, (Vgm_Emu*) 0 ); break; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
776 case type_spc: load_file( tag, in, 0, NULL, (Spc_Emu*) 0 ); break; |
1223
f1e57db353a3
[svn] - Don't crash when we encounter an unsupported NSF/NSFE type
nenolod
parents:
1198
diff
changeset
|
777 default: return FALSE; |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
778 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
779 |
1223
f1e57db353a3
[svn] - Don't crash when we encounter an unsupported NSF/NSFE type
nenolod
parents:
1198
diff
changeset
|
780 if (emu == NULL) |
f1e57db353a3
[svn] - Don't crash when we encounter an unsupported NSF/NSFE type
nenolod
parents:
1198
diff
changeset
|
781 return FALSE; |
f1e57db353a3
[svn] - Don't crash when we encounter an unsupported NSF/NSFE type
nenolod
parents:
1198
diff
changeset
|
782 |
1485
eff9a84c54bf
[svn] use -1 to indicate "drop the original nsf/gbs/nsfe file, but silently error"
nenolod
parents:
1405
diff
changeset
|
783 for (int i = 0; i < emu->track_count(); i++) |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
784 { |
1127
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
785 gchar _buf[65535]; |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
786 g_snprintf(_buf, 65535, "%s?%d", path2, i); |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
787 |
a49cc8e8e38d
[svn] - present subsongs as playlist entities (will be enqueued at the current position)
nenolod
parents:
1126
diff
changeset
|
788 playlist_add_url(_buf); |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
789 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
790 |
1485
eff9a84c54bf
[svn] use -1 to indicate "drop the original nsf/gbs/nsfe file, but silently error"
nenolod
parents:
1405
diff
changeset
|
791 ret = -1; |
eff9a84c54bf
[svn] use -1 to indicate "drop the original nsf/gbs/nsfe file, but silently error"
nenolod
parents:
1405
diff
changeset
|
792 |
1126
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
793 unload_file(); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
794 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
795 |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
796 g_free(path2); |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
797 return ret; |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
798 } |
537e8cc47060
[svn] - allow load_file<class Emu> to load files into the parser without reading the tag information
nenolod
parents:
1125
diff
changeset
|
799 |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
800 // Setup |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
801 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
802 static void console_init(void) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
803 { |
1403 | 804 console_cfg_load(); |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
805 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
806 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
807 extern "C" void console_aboutbox(void) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
808 { |
900
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
809 static GtkWidget * aboutbox = NULL; |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
810 |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
811 if (!aboutbox) |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
812 { |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
813 aboutbox = xmms_show_message(_("About the Console Music Decoder"), |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
814 _("Console music decoder engine based on Game_Music_Emu 0.3.0.\n" |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
815 "Audacious implementation by: William Pitcock <nenolod@nenolod.net>, \n" |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
816 // Please do not put my hotpop.com address in the clear (I hate spam) |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
817 " Shay Green <hotpop.com@blargg>"), |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
818 _("Ok"), |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
819 FALSE, NULL, NULL); |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
820 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy", |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
821 (GCallback)gtk_widget_destroyed, &aboutbox); |
9eaff2f6cd4b
[svn] prevent libconsole aboutbox from spawning multiple times
giacomo
parents:
701
diff
changeset
|
822 } |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
823 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
824 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
825 InputPlugin console_ip = |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
826 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
827 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
828 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
829 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
830 console_init, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
831 console_aboutbox, |
1403 | 832 console_cfg_ui, |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
833 is_our_file, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
834 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
835 play_file, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
836 console_stop, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
837 console_pause, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
838 seek, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
839 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
840 get_time, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
841 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
842 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
843 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
844 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
845 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
846 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
847 NULL, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
848 get_song_info, |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
849 NULL, |
1242
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
850 NULL, |
0f89ebbf890a
[svn] - get_song_tuple() implementation (scrobblerific!)
nenolod
parents:
1223
diff
changeset
|
851 get_song_tuple, |
493
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
852 }; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
853 |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
854 extern "C" InputPlugin *get_iplugin_info(void) |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
855 { |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
856 console_ip.description = g_strdup_printf(_("SPC, VGM, NSF/NSFE, GBS, and GYM module decoder")); |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
857 return &console_ip; |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
858 } |
c04dff121e1d
[svn] hostile merge, phase 2: reimport based on new plugin code
nenolod
parents:
diff
changeset
|
859 |