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