annotate src/console/Audacious_Driver.cxx @ 2997:73ae33c89dc6

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