annotate src/console/Audacious_Driver.cxx @ 2171:a4387938cc7d

set have_subtune
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Sun, 18 Nov 2007 21:45:12 +0900
parents d52d3029bb91
children ed6c81bd9016
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
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
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
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
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
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
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
64 // Handles URL parsing, file opening and identification, and file loading.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
65 // Keeps file header around when loading rest of file to avoid seeking
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
66 // and re-reading.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
67 class File_Handler {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
68 public:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
69 gchar* path; // path without track number specification
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
70 int track; // track number (0 = first track)
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
71 Music_Emu* emu; // set to 0 to take ownership
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
72 gme_type_t type;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
73
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
74 // Parses path and identifies file type
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
75 File_Handler( const char* path, VFSFile* fd = 0 );
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
76
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
77 // Creates emulator and returns 0. If this wasn't a music file or
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
78 // emulator couldn't be created, returns 1.
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
79 int load( long sample_rate );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
80
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
81 // Deletes owned emu and closes file
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
82 ~File_Handler();
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
83 private:
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
84 char header [4];
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
85 Vfs_File_Reader aud_vfs_in;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
86 Gzip_Reader in;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
89 File_Handler::File_Handler( const char* path_in, VFSFile* fd )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
91 emu = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
92 type = 0;
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
93 track = 0;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
94
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
95 path = g_strdup( path_in );
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
96 if ( !path )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
97 return; // out of memory
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
98
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
99 // extract track number
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
100 gchar* args = strrchr( path, '?' ); // TODO: use strrchr()?
752
560292f1ebb3 [svn] - fix a stupid C++ error
nenolod
parents: 751
diff changeset
101 if ( args && g_ascii_isdigit( (guchar) *(args + 1) ) )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
103 *args = '\0';
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
104 // TODO: use func with better error reporting, and perhaps don't
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
105 // truncate path if there is no number after ?
1734
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
106 track = atoi( args + 1 ) - 1;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
107 }
381
53056ce7940d [svn] - avoid opening VFS FDs for track URIs where we know that the file is valid
nenolod
parents: 380
diff changeset
108
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
109 // open vfs
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
110 if ( fd )
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
111 aud_vfs_in.reset( fd );
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
112 else if ( log_err( aud_vfs_in.open( path ) ) )
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
113 return;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
114
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
115 // now open gzip_reader on top of vfs
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
116 if ( log_err( in.open( &aud_vfs_in ) ) )
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
117 return;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
118
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
119 // read and identify header
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
120 if ( !log_err( in.read( header, sizeof header ) ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
121 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
122 type = gme_identify_extension( gme_identify_header( header ) );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
123 if ( !type )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
124 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
125 type = gme_identify_extension( path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
126 if ( type != gme_gym_type ) // only trust file extension for headerless .gym files
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
127 type = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
128 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
129 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
130 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
131
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
132 File_Handler::~File_Handler()
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
133 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
134 gme_delete( emu );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
135 g_free( path );
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
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
138 int File_Handler::load( long sample_rate )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
139 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
140 if ( !type )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
141 return 1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
142
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
143 emu = gme_new_emu( type, sample_rate );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
144 if ( !emu )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
145 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
146 log_err( "Out of memory" );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
147 return 1;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
148 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
149
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
150 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
151 // combine header with remaining file data
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
152 Remaining_Reader reader( header, sizeof header, &in );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
153 if ( log_err( emu->load( reader ) ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
154 return 1;
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
155 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
156
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
157 // files can be closed now
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
158 in.close();
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
159 aud_vfs_in.close();
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
160
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
161 log_warning( emu );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
162
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
163 // load .m3u from same directory( replace/add extension with ".m3u")
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
164 char m3u_path [path_max + 5];
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
165 strncpy( m3u_path, path, path_max );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
166 m3u_path [path_max] = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
167 // TODO: use better path-building functions
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
168 char* p = strrchr( m3u_path, '.' );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
169 if ( !p )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
170 p = m3u_path + strlen( m3u_path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
171 strcpy( p, ".m3u" );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
172
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
173 Vfs_File_Reader m3u;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
174 if ( !m3u.open( m3u_path ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
175 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
176 if ( log_err( emu->load_m3u( m3u ) ) ) // TODO: fail if m3u can't be loaded?
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
177 log_warning( emu ); // this will log line number of first problem in m3u
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
178 }
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
179
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
180 return 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
181 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
182
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
183 // Get info
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
184
603
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
185 static inline gchar *selective_strdup(const gchar *in)
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
186 {
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
187 if (in == NULL || *in == '\0')
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
188 return NULL;
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
189
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
190 return g_strdup(in);
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
191 }
73ae7a6d510e [svn] - don't fill in tuple fields with "".
nenolod
parents: 582
diff changeset
192
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
193 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
194 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
195 Tuple* ti = aud_tuple_new();
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
196 if ( ti )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
197 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
198 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
199 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
200 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
201 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
202 aud_tuple_associate_string(ti, -1, "game", info.game);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
203 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
204 if ( info.track_count > 1 )
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
205 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
206 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
207 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
208 aud_tuple_associate_int(ti, FIELD_SUBSONG_NUM, NULL, info.track_count);
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
209 ti->nsubtunes = info.track_count;
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
210 ti->subtunes = NULL;
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
211 }
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
212 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
213 aud_tuple_associate_string(ti, -1, "console", info.system);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
214 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
215 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "sequenced");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
216 aud_tuple_associate_string(ti, -1, "dumper", info.dumper);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
217 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
218
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
219 int length = info.length;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
220 if ( length <= 0 )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
221 length = info.intro_length + 2 * info.loop_length;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
222 if ( length <= 0 )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
223 length = audcfg.loop_length * 1000;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
224 else if ( length >= fade_threshold )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
225 length += fade_length;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
226 aud_tuple_associate_int(ti, FIELD_LENGTH, NULL, length);
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
227 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
228 return ti;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
231 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
232 {
2055
2f2ffbc2d04d gentitle changes
William Pitcock <nenolod@atheme.org>
parents: 2020
diff changeset
233 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
234 if ( result )
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
235 *length = aud_tuple_get_int(ti, FIELD_LENGTH, NULL);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
236 aud_tuple_free((void *) ti);
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
237
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 return result;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
241 static Tuple *get_song_tuple( gchar *path )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242 {
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
243 Tuple* result = NULL;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
244 File_Handler fh( path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
245 if ( !fh.load( gme_info_only ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
246 {
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
247 track_info_t info;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
248 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
249 result = get_track_ti( fh.path, info, fh.track );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
250 }
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
251 return result;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
252 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 // Playback
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
256 static void* play_loop_track( gpointer arg )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
257 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
258 InputPlayback *playback = (InputPlayback *) arg;
1184
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
259
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
260 int end_delay = 0;
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
261 while ( console_ip_is_going )
0
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 // handle pending seek
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264 long s = pending_seek;
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
265 pending_seek = -1; // TODO: use atomic swap
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
266 if ( s >= 0 )
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
268 playback->output->flush( s * 1000 );
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
269 emu->seek( s * 1000 );
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
270 }
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
271
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
272 // fill and play buffer of audio
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
273 // TODO: see if larger buffer helps efficiency
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
274 int const buf_size = 1024;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
275 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
276 if ( end_delay )
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
277 {
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
278 // 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
279 if ( !--end_delay )
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
280 console_ip_is_going = false;
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
281 memset( buf, 0, sizeof buf );
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
282
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
283 }
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
284 else
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
285 {
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
286 emu->play( buf_size, buf );
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
287 if ( emu->track_ended() )
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
288 {
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
289 double const seconds = 3;
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
290 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
291 }
6d03915421e2 Possibly fix bug #850. Patch from P2E.
William Pitcock <nenolod@atheme.org>
parents: 1069
diff changeset
292 }
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1984
diff changeset
293 playback->pass_audio( playback,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 FMT_S16_NE, 1, sizeof buf, buf,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295 &console_ip_is_going );
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298 // stop playing
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299 unload_file();
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
300 playback->output->close_audio();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301 console_ip_is_going = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
302 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
305 static void play_file( InputPlayback *playback )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
306 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
307 char* path = playback->filename;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 unload_file();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
310 // identify file
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
311 File_Handler fh( path );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
312 if ( !fh.type )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
313 return;
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
314
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
315 // select sample rate
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
316 long sample_rate = 0;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
317 if ( fh.type == gme_spc_type )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
318 sample_rate = 32000;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319 if ( audcfg.resample )
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320 sample_rate = audcfg.resample_rate;
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
321 if ( !sample_rate )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
322 sample_rate = 44100;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
323
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
324 // create emulator and load file
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
325 if ( fh.load( sample_rate ) )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
328 // stereo echo depth
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
329 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
330
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
331 // set equalizer
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 if ( audcfg.treble || audcfg.bass )
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
333 {
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
334 Music_Emu::equalizer_t eq;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336 // bass - logarithmic, 2 to 8194 Hz
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 double bass = 1.0 - (audcfg.bass / 200.0 + 0.5);
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
338 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
339
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340 // treble - -50 to 0 to +5 dB
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341 double treble = audcfg.treble / 100.0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342 eq.treble = treble * (treble < 0 ? 50.0 : 5.0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
344 fh.emu->set_equalizer(eq);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
347 // get info
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
348 int length = -1;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
349 track_info_t info;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
350 if ( !log_err( fh.emu->track_info( &info, fh.track ) ) )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
351 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
352 if ( fh.type == gme_spc_type && audcfg.ignore_spc_length )
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
353 info.length = -1;
1418
08a6320f7a2b console: update to new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
354 Tuple* ti = get_track_ti( fh.path, info, fh.track );
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
355 if ( ti )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
356 {
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
357 char* title = format_and_free_ti( ti, &length );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
358 if ( title )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
359 {
1984
489e32a8e106 change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
360 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
361 g_free( title );
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
362 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
363 }
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
364 }
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
365
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
366 // start track
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
367 if ( log_err( fh.emu->start_track( fh.track ) ) )
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
368 return;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
369 log_warning( fh.emu );
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
370 if ( !playback->output->open_audio( FMT_S16_NE, sample_rate, 2 ) )
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
371 return;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
372
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
373 // set fade time
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
374 if ( length <= 0 )
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
375 length = audcfg.loop_length * 1000;
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
376 if ( length >= fade_threshold + fade_length )
648
0eca44731221 [svn] - fix timing on fades
nenolod
parents: 603
diff changeset
377 length -= fade_length / 2;
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
378 fh.emu->set_fade( length, fade_length );
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
379
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
380 // take ownership of emu
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
381 emu = fh.emu;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
382 fh.emu = 0;
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
383
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
384 pending_seek = -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
385 console_ip_is_going = 1;
1348
d427f353e326 console: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1185
diff changeset
386 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
387 playback->set_pb_ready(playback);
1348
d427f353e326 console: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1185
diff changeset
388 play_loop_track( playback );
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
389 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
390
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 528
diff changeset
391 static void seek( InputPlayback * data, gint time )
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
392 {
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
393 // TODO: use thread-safe atomic set
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
394 pending_seek = time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
395 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
396
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
397 static void console_stop(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
399 console_ip_is_going = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
400 if ( decode_thread )
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
401 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
402 g_thread_join( decode_thread );
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
403 decode_thread = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
404 }
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
405 playback->output->close_audio();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406 unload_file();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
408
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
409 static void console_pause(InputPlayback * playback, gshort p)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
410 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
411 playback->output->pause(p);
0
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 int get_time(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
415 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
416 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
417 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418
1734
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
419 static Tuple *probe_for_tuple(gchar *filename, VFSFile *fd)
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
420 {
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
421 File_Handler fh(filename, fd);
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
422
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
423 if (!fh.type)
1734
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
424 return NULL;
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
425
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
426 aud_vfs_rewind(fd);
1734
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
427
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
428 return get_song_tuple(filename);
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
429 }
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
430
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
431 // Setup
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 static void console_init(void)
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 console_cfg_load();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
436 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
437
1660
206e7cb5fce7 "about" dialog of console plugin opens now correctly
mf0102 <0102@gmx.at>
parents: 1659
diff changeset
438 void console_aboutbox(void)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
439 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
440 static GtkWidget * aboutbox = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
441
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
442 if (!aboutbox)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 {
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1660
diff changeset
444 aboutbox = audacious_info_dialog(_("About the Console Music Decoder"),
341
986f098da058 [svn] - merge in blargg's changes
nenolod
parents: 332
diff changeset
445 _("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
446 "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
447 "Audacious implementation by: William Pitcock <nenolod@nenolod.net>, \n"
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
448 " Shay Green <gblargg@gmail.com>"),
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
449 _("Ok"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450 FALSE, NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
452 (GCallback)gtk_widget_destroyed, &aboutbox);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
454 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
455
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 752
diff changeset
456 const gchar *gme_fmts[] = { "ay", "gbs", "gym", "hes", "kss", "nsf", "nsfe",
378
899e285f4be5 [svn] - extension assist for libconsole
nenolod
parents: 363
diff changeset
457 "sap", "spc", "vgm", "vgz", NULL };
899e285f4be5 [svn] - extension assist for libconsole
nenolod
parents: 363
diff changeset
458
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
459 InputPlugin console_ip =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
460 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
461 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
462 NULL,
1185
6d749f573b3b suppress warnings.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1184
diff changeset
463 (gchar *)"Game console audio module decoder",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
464 console_init,
1659
53adc480f9a7 fixed some more plugins
mf0102 <0102@gmx.at>
parents: 1611
diff changeset
465 NULL,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
466 console_aboutbox,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
467 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
468 FALSE,
f49d1284079a "sorry, unimplemented: non-trivial designated initializers not supported". What a crock of g++.
William Pitcock <nenolod@atheme.org>
parents: 1510
diff changeset
469 NULL,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
470 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
471 play_file,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
472 console_stop,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
473 console_pause,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
474 seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
475 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
476 get_time,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
478 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
479 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
480 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
481 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482 NULL,
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
483 NULL,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
484 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485 NULL,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
486 get_song_tuple,
316
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
487 NULL,
fb513e10174e [svn] - merge libconsole-blargg into mainline libconsole:
nenolod
parents: 12
diff changeset
488 NULL,
2089
d52d3029bb91 Fix subtunes support to match the new core (possibly not working yet)
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
489 NULL,
1734
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
490 (gchar **)gme_fmts,
5e47a0c1b969 - updated libconsole plugin subtune code
Giacomo Lozito <james@develia.org>
parents: 1697
diff changeset
491 NULL,
2171
a4387938cc7d set have_subtune
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2089
diff changeset
492 probe_for_tuple,
a4387938cc7d set have_subtune
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2089
diff changeset
493 TRUE
0
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
1069
f04f4a223f7b [svn] - update libconsole to plugin API v2
nenolod
parents: 1044
diff changeset
496 InputPlugin *console_iplist[] = { &console_ip, NULL };
f04f4a223f7b [svn] - update libconsole to plugin API v2
nenolod
parents: 1044
diff changeset
497
1659
53adc480f9a7 fixed some more plugins
mf0102 <0102@gmx.at>
parents: 1611
diff changeset
498 SIMPLE_INPUT_PLUGIN(console, console_iplist);