Mercurial > audlegacy-plugins
annotate src/console/Audacious_Driver.cxx @ 1978:fa9f85cebade
s/vfs_/aud_vfs_/g
| author | William Pitcock <nenolod@atheme.org> |
|---|---|
| date | Sun, 07 Oct 2007 00:25:33 -0500 |
| parents | 5fa26178eaef |
| children | 489e32a8e106 |
| rev | line source |
|---|---|
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 /* |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 * Audacious: Cross platform multimedia player |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
3 * Copyright (c) 2005-2006 Audacious Team |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 * |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 * Driver for Game_Music_Emu library. See details at: |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 * http://www.slack.net/~ant/libs/ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 */ |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 |
|
1766
c3fdb0e5a306
Convert some makefiles, remove some -DHAVE_CONFIG_H.
William Pitcock <nenolod@atheme.org>
parents:
1734
diff
changeset
|
9 #include "config.h" |
| 528 | 10 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
11 #include <glib.h> |
|
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
385
diff
changeset
|
12 #include <audacious/i18n.h> |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
13 #include <gtk/gtk.h> |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
14 extern "C" { |
|
1954
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1952
diff
changeset
|
15 #include <audacious/plugin.h> |
|
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1870
diff
changeset
|
16 #include <audacious/util.h> |
|
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1870
diff
changeset
|
17 #include <audacious/output.h> |
|
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1870
diff
changeset
|
18 #include <audacious/playlist.h> |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
19 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
20 #include <string.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
21 #include <stdlib.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 #include <math.h> |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 // configdb and prefs ui |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 #include "Audacious_Config.h" |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
27 #include "Music_Emu.h" |
| 341 | 28 #include "Gzip_Reader.h" |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
30 int const fade_threshold = 10 * 1000; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
31 int const fade_length = 8 * 1000; |
| 341 | 32 int const path_max = 4096; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 |
|
1498
a1fccf242404
made SPC playback reverb a configuration option till the problem can be
mf0102 <0102@gmx.at>
parents:
1473
diff
changeset
|
34 AudaciousConsoleConfig audcfg = |
|
1499
799f92d815b2
removed NSFE playlist option (which was marked TODO)
mf0102 <0102@gmx.at>
parents:
1498
diff
changeset
|
35 { 180, FALSE, 32000, 0, 0, FALSE, 0, FALSE }; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
36 static GThread* decode_thread; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
37 static GStaticMutex playback_mutex = G_STATIC_MUTEX_INIT; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
38 static int console_ip_is_going; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
39 static volatile long pending_seek; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
40 extern InputPlugin console_ip; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
41 static Music_Emu* emu = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
42 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
43 static blargg_err_t log_err( blargg_err_t err ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
44 { |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
45 if ( err ) |
|
380
1397798646fb
[svn] - change use of printf to g_warning() and g_critical() where appropriate.
nenolod
parents:
378
diff
changeset
|
46 g_critical( "console error: %s\n", err ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
47 return err; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
48 } |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
49 |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
50 static void log_warning( Music_Emu* emu ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
51 { |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
52 const char* w = emu->warning(); |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
53 if ( w ) |
|
380
1397798646fb
[svn] - change use of printf to g_warning() and g_critical() where appropriate.
nenolod
parents:
378
diff
changeset
|
54 g_warning( "console warning: %s\n", w ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
55 } |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
56 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
57 static void unload_file() |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 { |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
59 if ( emu ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
60 log_warning( emu ); |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
61 gme_delete( emu ); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
62 emu = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
63 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 |
| 341 | 65 // Handles URL parsing, file opening and identification, and file loading. |
| 66 // Keeps file header around when loading rest of file to avoid seeking | |
| 67 // and re-reading. | |
| 68 class File_Handler { | |
| 69 public: | |
| 70 gchar* path; // path without track number specification | |
| 71 int track; // track number (0 = first track) | |
| 72 bool track_specified; // false if no track number was specified in path | |
| 73 Music_Emu* emu; // set to 0 to take ownership | |
| 74 gme_type_t type; | |
| 75 | |
| 76 // Parses path and identifies file type | |
|
385
ac806e416c48
[svn] - some improvements for chiptune expansion efficiency
nenolod
parents:
382
diff
changeset
|
77 File_Handler( const char* path, VFSFile* fd = 0, gboolean is_our_file_hack = FALSE ); |
| 341 | 78 |
| 79 // Creates emulator and returns 0. If this wasn't a music file or | |
| 80 // emulator couldn't be created, returns 1. | |
| 81 int load( long sample_rate ); | |
| 82 | |
| 83 // Deletes owned emu and closes file | |
| 84 ~File_Handler(); | |
| 85 private: | |
| 86 char header [4]; | |
| 1978 | 87 Vfs_File_Reader aud_vfs_in; |
| 341 | 88 Gzip_Reader in; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 }; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 |
|
385
ac806e416c48
[svn] - some improvements for chiptune expansion efficiency
nenolod
parents:
382
diff
changeset
|
91 File_Handler::File_Handler( const char* path_in, VFSFile* fd, gboolean is_our_file_hack ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
92 { |
| 341 | 93 emu = 0; |
| 94 type = 0; | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
95 track = 0; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
96 track_specified = false; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
97 |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
98 path = g_strdup( path_in ); |
| 341 | 99 if ( !path ) |
| 100 return; // out of memory | |
| 101 | |
| 102 // extract track number | |
| 103 gchar* args = strchr( path, '?' ); // TODO: use strrchr()? | |
| 752 | 104 if ( args && g_ascii_isdigit( (guchar) *(args + 1) ) ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 { |
| 341 | 106 *args = '\0'; |
| 107 // TODO: use func with better error reporting, and perhaps don't | |
| 108 // truncate path if there is no number after ? | |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
109 track = atoi( args + 1 ) - 1; |
| 341 | 110 track_specified = true; |
| 111 } | |
|
381
53056ce7940d
[svn] - avoid opening VFS FDs for track URIs where we know that the file is valid
nenolod
parents:
380
diff
changeset
|
112 |
|
53056ce7940d
[svn] - avoid opening VFS FDs for track URIs where we know that the file is valid
nenolod
parents:
380
diff
changeset
|
113 // if the track is specified, then we have a match. don't worry |
|
53056ce7940d
[svn] - avoid opening VFS FDs for track URIs where we know that the file is valid
nenolod
parents:
380
diff
changeset
|
114 // about it right now -nenolod |
|
385
ac806e416c48
[svn] - some improvements for chiptune expansion efficiency
nenolod
parents:
382
diff
changeset
|
115 if (track_specified && is_our_file_hack) |
|
381
53056ce7940d
[svn] - avoid opening VFS FDs for track URIs where we know that the file is valid
nenolod
parents:
380
diff
changeset
|
116 return; |
| 341 | 117 |
| 118 // open vfs | |
| 119 if ( fd ) | |
| 1978 | 120 aud_vfs_in.reset( fd ); |
| 121 else if ( log_err( aud_vfs_in.open( path ) ) ) | |
| 341 | 122 return; |
| 123 | |
| 124 // now open gzip_reader on top of vfs | |
| 1978 | 125 if ( log_err( in.open( &aud_vfs_in ) ) ) |
| 341 | 126 return; |
| 127 | |
| 128 // read and identify header | |
| 129 if ( !log_err( in.read( header, sizeof header ) ) ) | |
| 130 { | |
| 131 type = gme_identify_extension( gme_identify_header( header ) ); | |
| 132 if ( !type ) | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 { |
| 341 | 134 type = gme_identify_extension( path ); |
| 135 if ( type != gme_gym_type ) // only trust file extension for headerless .gym files | |
| 136 type = 0; | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
137 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
138 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
139 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
140 |
| 341 | 141 File_Handler::~File_Handler() |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
142 { |
| 341 | 143 gme_delete( emu ); |
| 144 g_free( path ); | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
145 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
146 |
| 341 | 147 int File_Handler::load( long sample_rate ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
148 { |
| 341 | 149 if ( !type ) |
| 150 return 1; | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
151 |
| 341 | 152 emu = gme_new_emu( type, sample_rate ); |
| 153 if ( !emu ) | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
154 { |
| 341 | 155 log_err( "Out of memory" ); |
| 156 return 1; | |
| 157 } | |
| 158 | |
| 159 { | |
| 160 // combine header with remaining file data | |
| 161 Remaining_Reader reader( header, sizeof header, &in ); | |
| 162 if ( log_err( emu->load( reader ) ) ) | |
| 163 return 1; | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
164 } |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
165 |
| 341 | 166 // files can be closed now |
| 167 in.close(); | |
| 1978 | 168 aud_vfs_in.close(); |
| 341 | 169 |
| 170 log_warning( emu ); | |
| 171 | |
| 172 // load .m3u from same directory( replace/add extension with ".m3u") | |
| 173 char m3u_path [path_max + 5]; | |
| 174 strncpy( m3u_path, path, path_max ); | |
| 175 m3u_path [path_max] = 0; | |
| 176 // TODO: use better path-building functions | |
| 177 char* p = strrchr( m3u_path, '.' ); | |
| 178 if ( !p ) | |
| 179 p = m3u_path + strlen( m3u_path ); | |
| 180 strcpy( p, ".m3u" ); | |
| 181 | |
| 182 Vfs_File_Reader m3u; | |
| 183 if ( !m3u.open( m3u_path ) ) | |
| 184 { | |
| 185 if ( log_err( emu->load_m3u( m3u ) ) ) // TODO: fail if m3u can't be loaded? | |
| 186 log_warning( emu ); // this will log line number of first problem in m3u | |
| 187 } | |
| 188 | |
| 189 return 0; | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
190 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
191 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
192 // Get info |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
193 |
| 603 | 194 static inline gchar *selective_strdup(const gchar *in) |
| 195 { | |
| 196 if (in == NULL || *in == '\0') | |
| 197 return NULL; | |
| 198 | |
| 199 return g_strdup(in); | |
| 200 } | |
| 201 | |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
202 static Tuple* get_track_ti( const char* path, track_info_t const& info, int track ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
203 { |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
204 Tuple* ti = aud_tuple_new(); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
205 if ( ti ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
206 { |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
207 aud_tuple_associate_string(ti, FIELD_FILE_NAME, NULL, g_path_get_basename(path)); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
208 aud_tuple_associate_string(ti, FIELD_FILE_PATH, NULL, g_path_get_dirname(path)); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
209 aud_tuple_associate_string(ti, FIELD_ARTIST, NULL, info.author); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
210 aud_tuple_associate_string(ti, FIELD_ALBUM, NULL, info.game); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
211 aud_tuple_associate_string(ti, -1, "game", info.game); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
212 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, info.song ? info.song : g_path_get_basename(path)); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
213 if ( info.track_count > 1 ) |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
214 { |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
215 aud_tuple_associate_int(ti, FIELD_TRACK_NUMBER, NULL, track + 1); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
216 aud_tuple_associate_int(ti, -1, "subsong", track + 1); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
217 aud_tuple_associate_int(ti, FIELD_SUBSONG_ID, NULL, track + 1); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
218 aud_tuple_associate_int(ti, FIELD_SUBSONG_NUM, NULL, info.track_count); |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
219 } |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
220 aud_tuple_associate_string(ti, FIELD_COPYRIGHT, NULL, info.copyright); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
221 aud_tuple_associate_string(ti, -1, "console", info.system); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
222 aud_tuple_associate_string(ti, FIELD_CODEC, NULL, info.system); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
223 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced"); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
224 aud_tuple_associate_string(ti, -1, "dumper", info.dumper); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
225 aud_tuple_associate_string(ti, FIELD_COMMENT, NULL, info.comment); |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
226 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
227 int length = info.length; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
228 if ( length <= 0 ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
229 length = info.intro_length + 2 * info.loop_length; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
230 if ( length <= 0 ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
231 length = audcfg.loop_length * 1000; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
232 else if ( length >= fade_threshold ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
233 length += fade_length; |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
234 aud_tuple_associate_int(ti, FIELD_LENGTH, NULL, length); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
235 } |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
236 return ti; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
237 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
238 |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
239 static char* format_and_free_ti( Tuple* ti, int* length ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
240 { |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
241 char* result = aud_tuple_formatter_make_title_string(ti, get_gentitle_format()); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
242 if ( result ) |
|
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
243 *length = aud_tuple_get_int(ti, FIELD_LENGTH, NULL); |
|
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1954
diff
changeset
|
244 aud_tuple_free((void *) ti); |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
245 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
246 return result; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
247 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
248 |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
249 static Tuple *get_song_tuple( gchar *path ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
250 { |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
251 Tuple* result = 0; |
| 341 | 252 File_Handler fh( path ); |
| 253 if ( !fh.load( gme_info_only ) ) | |
| 254 { | |
| 255 track_info_t info; | |
| 256 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) | |
| 257 result = get_track_ti( fh.path, info, fh.track ); | |
| 258 } | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
259 return result; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
260 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
261 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
262 static void get_song_info( char* path, char** title, int* length ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
263 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
264 *length = -1; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
265 *title = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
266 |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
267 Tuple* ti = get_song_tuple( path ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
268 if ( ti ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
269 *title = format_and_free_ti( ti, length ); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 // Playback |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
274 static void* play_loop_track( gpointer arg ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
275 { |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
276 InputPlayback *playback = (InputPlayback *) arg; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
277 g_static_mutex_lock( &playback_mutex ); |
|
1184
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
278 |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
279 int end_delay = 0; |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
280 while ( console_ip_is_going ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
281 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
282 // handle pending seek |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
283 long s = pending_seek; |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
284 pending_seek = -1; // TODO: use atomic swap |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 if ( s >= 0 ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 { |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
287 playback->output->flush( s * 1000 ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
288 emu->seek( s * 1000 ); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 } |
| 341 | 290 |
| 291 // fill and play buffer of audio | |
| 292 // TODO: see if larger buffer helps efficiency | |
| 293 int const buf_size = 1024; | |
| 294 Music_Emu::sample_t buf [buf_size]; | |
|
1184
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
295 if ( end_delay ) |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
296 { |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
297 // TODO: remove delay once host doesn't cut the end of track off |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
298 if ( !--end_delay ) |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
299 console_ip_is_going = false; |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
300 memset( buf, 0, sizeof buf ); |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
301 |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
302 } |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
303 else |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
304 { |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
305 emu->play( buf_size, buf ); |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
306 if ( emu->track_ended() ) |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
307 { |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
308 double const seconds = 3; |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
309 end_delay = emu->sample_rate() * (int) (seconds * 2) / buf_size; |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
310 } |
|
6d03915421e2
Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents:
1069
diff
changeset
|
311 } |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
312 produce_audio( playback->output->written_time(), |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 FMT_S16_NE, 1, sizeof buf, buf, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
314 &console_ip_is_going ); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
317 // stop playing |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 unload_file(); |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
319 playback->output->close_audio(); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 console_ip_is_going = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
321 g_static_mutex_unlock( &playback_mutex ); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
322 return NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
324 |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
325 static void play_file( InputPlayback *playback ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 { |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
327 char* path = playback->filename; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 unload_file(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
330 // identify file |
| 341 | 331 File_Handler fh( path ); |
| 332 if ( !fh.type ) | |
| 333 return; | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
334 |
| 341 | 335 // select sample rate |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
336 long sample_rate = 0; |
| 341 | 337 if ( fh.type == gme_spc_type ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
338 sample_rate = 32000; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
339 if ( audcfg.resample ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 sample_rate = audcfg.resample_rate; |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
341 if ( !sample_rate ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
342 sample_rate = 44100; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
343 |
| 341 | 344 // create emulator and load file |
| 345 if ( fh.load( sample_rate ) ) | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
346 return; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
348 // stereo echo depth |
| 341 | 349 gme_set_stereo_depth( fh.emu, 1.0 / 100 * audcfg.echo ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
350 |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
351 // set equalizer |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
352 if ( audcfg.treble || audcfg.bass ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 { |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
354 Music_Emu::equalizer_t eq; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
355 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
356 // bass - logarithmic, 2 to 8194 Hz |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
357 double bass = 1.0 - (audcfg.bass / 200.0 + 0.5); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
358 eq.bass = (long) (2.0 + pow( 2.0, bass * 13 )); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
359 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
360 // treble - -50 to 0 to +5 dB |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
361 double treble = audcfg.treble / 100.0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
362 eq.treble = treble * (treble < 0 ? 50.0 : 5.0); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
363 |
| 341 | 364 fh.emu->set_equalizer(eq); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
366 |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
367 // get info |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
368 int length = -1; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
369 track_info_t info; |
| 341 | 370 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
371 { |
| 341 | 372 if ( fh.type == gme_spc_type && audcfg.ignore_spc_length ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
373 info.length = -1; |
|
1418
08a6320f7a2b
console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents:
1395
diff
changeset
|
374 Tuple* ti = get_track_ti( fh.path, info, fh.track ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
375 if ( ti ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
376 { |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
377 char* title = format_and_free_ti( ti, &length ); |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
378 if ( title ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
379 { |
| 341 | 380 console_ip.set_info( title, length, fh.emu->voice_count() * 1000, sample_rate, 2 ); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
381 g_free( title ); |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
382 } |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
383 } |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
384 } |
| 341 | 385 |
| 386 // start track | |
| 387 if ( log_err( fh.emu->start_track( fh.track ) ) ) | |
| 388 return; | |
| 389 log_warning( fh.emu ); | |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
390 if ( !playback->output->open_audio( FMT_S16_NE, sample_rate, 2 ) ) |
| 341 | 391 return; |
| 392 | |
| 393 // set fade time | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
394 if ( length <= 0 ) |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
395 length = audcfg.loop_length * 1000; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
396 if ( length >= fade_threshold + fade_length ) |
| 648 | 397 length -= fade_length / 2; |
| 341 | 398 fh.emu->set_fade( length, fade_length ); |
| 399 | |
| 400 // take ownership of emu | |
| 401 emu = fh.emu; | |
| 402 fh.emu = 0; | |
| 403 | |
| 404 pending_seek = -1; | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 console_ip_is_going = 1; |
|
1348
d427f353e326
console: new threading model
William Pitcock <nenolod@atheme-project.org>
parents:
1185
diff
changeset
|
406 decode_thread = g_thread_self(); |
|
1447
195b5657303e
updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents:
1418
diff
changeset
|
407 playback->set_pb_ready(playback); |
|
1348
d427f353e326
console: new threading model
William Pitcock <nenolod@atheme-project.org>
parents:
1185
diff
changeset
|
408 play_loop_track( playback ); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
409 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
410 |
| 559 | 411 static void seek( InputPlayback * data, gint time ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 { |
| 341 | 413 // TODO: use thread-safe atomic set |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
414 pending_seek = time; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
415 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
416 |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
417 static void console_stop(InputPlayback *playback) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
419 console_ip_is_going = 0; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
420 if ( decode_thread ) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
421 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 g_thread_join( decode_thread ); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
423 decode_thread = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
424 } |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
425 playback->output->close_audio(); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 unload_file(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
427 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
428 |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
429 static void console_pause(InputPlayback * playback, gshort p) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
430 { |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
431 playback->output->pause(p); |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
432 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
434 static int get_time(InputPlayback *playback) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 { |
|
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
436 return console_ip_is_going ? playback->output->output_time() : -1; |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
437 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
438 |
| 341 | 439 static gint is_our_file_from_vfs( gchar* path, VFSFile* fd ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
440 { |
| 341 | 441 gint result = 0; |
|
385
ac806e416c48
[svn] - some improvements for chiptune expansion efficiency
nenolod
parents:
382
diff
changeset
|
442 File_Handler fh( path, fd, TRUE ); |
| 341 | 443 if ( fh.type ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
444 { |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
445 result = 1; |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
446 /* |
| 341 | 447 if ( fh.track_specified || fh.type->track_count == 1 ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
448 { |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
449 // don't even need to read file if track is specified or |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
450 // that file format can't have more than one track per file |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
451 result = 1; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
452 } |
| 341 | 453 else if ( !fh.load( gme_info_only ) ) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 { |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
455 // format requires reading file info to get track count |
| 341 | 456 if ( fh.emu->track_count() == 1 ) |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
457 { |
| 341 | 458 result = 1; |
| 459 } | |
| 460 else | |
| 461 { | |
| 462 // for multi-track types, add each track to playlist | |
| 463 for (int i = 0; i < fh.emu->track_count(); i++) | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
464 { |
| 341 | 465 gchar _buf[path_max]; |
| 466 g_snprintf(_buf, path_max, "%s?%d", fh.path, i); | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
467 |
|
363
958855dae693
[svn] - fix other plugins dependant on the playlist framework
nenolod
parents:
355
diff
changeset
|
468 playlist_add_url(playlist_get_active(), _buf); |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
469 } |
| 341 | 470 result = -1; |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
471 } |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
472 } |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
473 */ |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
474 } |
| 382 | 475 else if (fh.track_specified) |
| 476 { | |
| 477 result = 1; | |
| 478 } | |
| 479 | |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
480 return result; |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
481 } |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
483 static Tuple *probe_for_tuple(gchar *filename, VFSFile *fd) |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
484 { |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
485 if (!is_our_file_from_vfs(filename, fd)) |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
486 return NULL; |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
487 |
| 1978 | 488 aud_vfs_rewind(fd); |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
489 |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
490 return get_song_tuple(filename); |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
491 } |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
492 |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 // Setup |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
494 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
495 static void console_init(void) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
496 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
497 console_cfg_load(); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
498 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
499 |
|
1660
206e7cb5fce7
"about" dialog of console plugin opens now correctly
mf0102 <0102@gmx.at>
parents:
1659
diff
changeset
|
500 void console_aboutbox(void) |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
501 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
502 static GtkWidget * aboutbox = NULL; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
503 |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
504 if (!aboutbox) |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
505 { |
|
1677
f6f5603a0954
xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents:
1660
diff
changeset
|
506 aboutbox = audacious_info_dialog(_("About the Console Music Decoder"), |
| 341 | 507 _("Console music decoder engine based on Game_Music_Emu 0.5.2.\n" |
|
355
92848bda520d
[svn] Move supported formats to plugin info, rename plugin to 'Game console audio module decoder'.
kiyoshi
parents:
341
diff
changeset
|
508 "Supported formats: AY, GBS, GYM, HES, KSS, NSF, NSFE, SAP, SPC, VGM, VGZ\n" |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
509 "Audacious implementation by: William Pitcock <nenolod@nenolod.net>, \n" |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
510 " Shay Green <gblargg@gmail.com>"), |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
511 _("Ok"), |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
512 FALSE, NULL, NULL); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
513 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy", |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
514 (GCallback)gtk_widget_destroyed, &aboutbox); |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
515 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
516 } |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
517 |
|
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
752
diff
changeset
|
518 const gchar *gme_fmts[] = { "ay", "gbs", "gym", "hes", "kss", "nsf", "nsfe", |
| 378 | 519 "sap", "spc", "vgm", "vgz", NULL }; |
| 520 | |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
521 InputPlugin console_ip = |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
522 { |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
523 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
524 NULL, |
| 1185 | 525 (gchar *)"Game console audio module decoder", |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
526 console_init, |
| 1659 | 527 NULL, |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
528 console_aboutbox, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
529 console_cfg_ui, |
|
1611
f49d1284079a
"sorry, unimplemented: non-trivial designated initializers not supported". What a crock of g++.
William Pitcock <nenolod@atheme.org>
parents:
1510
diff
changeset
|
530 FALSE, |
|
f49d1284079a
"sorry, unimplemented: non-trivial designated initializers not supported". What a crock of g++.
William Pitcock <nenolod@atheme.org>
parents:
1510
diff
changeset
|
531 NULL, |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
532 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
533 play_file, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
534 console_stop, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
535 console_pause, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
536 seek, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
537 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
538 get_time, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
539 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
540 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
541 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
542 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
543 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
544 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
545 get_song_info, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
546 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
547 NULL, |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
548 get_song_tuple, |
|
316
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
549 NULL, |
|
fb513e10174e
[svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents:
12
diff
changeset
|
550 NULL, |
| 378 | 551 is_our_file_from_vfs, |
|
1734
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
552 (gchar **)gme_fmts, |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
553 NULL, |
|
5e47a0c1b969
- updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents:
1697
diff
changeset
|
554 probe_for_tuple |
|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
555 }; |
|
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
556 |
| 1069 | 557 InputPlugin *console_iplist[] = { &console_ip, NULL }; |
| 558 | |
| 1659 | 559 SIMPLE_INPUT_PLUGIN(console, console_iplist); |
