cleanup: api stuff

This commit is contained in:
bnnm 2024-08-18 17:50:55 +02:00
parent 01661a0d99
commit 03d8cb5329
9 changed files with 91 additions and 81 deletions

View File

@ -121,7 +121,7 @@ static int api_example(const char* infile) {
buf_bytes = err * sizeof(short) * lib->format->channels; buf_bytes = err * sizeof(short) * lib->format->channels;
} }
else { else {
err = libvgmstream_play(lib); err = libvgmstream_render(lib);
if (err < 0) goto fail; if (err < 0) goto fail;
buf = lib->decoder->buf; buf = lib->decoder->buf;

View File

@ -51,7 +51,7 @@ static void update_decoder_info(libvgmstream_priv_t* priv, int samples_done) {
priv->dec.done = priv->decode_done; priv->dec.done = priv->decode_done;
} }
LIBVGMSTREAM_API int libvgmstream_play(libvgmstream_t* lib) { LIBVGMSTREAM_API int libvgmstream_render(libvgmstream_t* lib) {
if (!lib || !lib->priv) if (!lib || !lib->priv)
return LIBVGMSTREAM_ERROR_GENERIC; return LIBVGMSTREAM_ERROR_GENERIC;
@ -85,7 +85,7 @@ LIBVGMSTREAM_API int libvgmstream_fill(libvgmstream_t* lib, void* buf, int buf_s
return LIBVGMSTREAM_ERROR_GENERIC; return LIBVGMSTREAM_ERROR_GENERIC;
if (priv->buf.consumed >= priv->buf.samples) { if (priv->buf.consumed >= priv->buf.samples) {
int err = libvgmstream_play(lib); int err = libvgmstream_render(lib);
if (err < 0) return err; if (err < 0) return err;
} }

View File

@ -88,4 +88,8 @@ LIBVGMSTREAM_API int libvgmstream_get_title(libvgmstream_t* lib, libvgmstream_ti
return LIBVGMSTREAM_OK; return LIBVGMSTREAM_OK;
} }
LIBVGMSTREAM_API bool libvgmstream_is_virtual_filename(const char* filename) {
return vgmstream_is_virtual_filename(filename);
}
#endif #endif

View File

@ -1,30 +1,29 @@
/* libvgmstream: vgmstream's public API */
#ifndef _LIBVGMSTREAM_H_ #ifndef _LIBVGMSTREAM_H_
#define _LIBVGMSTREAM_H_ #define _LIBVGMSTREAM_H_
//#define LIBVGMSTREAM_ENABLE 1 //#define LIBVGMSTREAM_ENABLE 1
#if LIBVGMSTREAM_ENABLE #if LIBVGMSTREAM_ENABLE
/* By default vgmstream behaves like a decoder (decode samples until stream end), but you can configure /* libvgmstream: vgmstream's public API
*
* Basic usage (also see api_example.c):
* - libvgmstream_init(...) // create context
* - libvgmstream_setup(...) // setup config (if needed)
* - libvgmstream_open_song(...) // open format
* - libvgmstream_render(...) // main decode
* - output samples + repeat libvgmstream_render until stream is done
* - libvgmstream_free(...) // cleanup
*
* By default vgmstream behaves like a decoder (returns samples until stream end), but you can configure
* it to loop N times or even downmix. In other words, it also behaves a bit like a player. * it to loop N times or even downmix. In other words, it also behaves a bit like a player.
* It exposes multiple convenience stuff mainly for various plugins that mostly repeat the same features. * It exposes multiple convenience stuff mainly for various plugins with similar features.
* All this may make the API still WIP and a bit twisted, probably will improve later. Probably. * This may make the API a bit odd, will probably improve later. Probably.
* *
* Notes: * Notes:
* - now there is an API internals (vgmstream.h) may change in the future * - now there is an API, internals (vgmstream.h) may change in the future so avoid accesing them
* - may dynamically allocate stuff as needed (mainly some buffers, but varies per format)
* - some details described in the API may not happen at the moment (defined for future changes) * - some details described in the API may not happen at the moment (defined for future changes)
* - uses long-winded libvgmstream_* names since internals alredy use the vgmstream_* 'namespace', #define as needed * - uses long-winded libvgmstream_* names since internals alredy use the vgmstream_* 'namespace', #define as needed
* - c-strings should be in UTF-8 * - c-strings should be in UTF-8
*
* Basic usage (also see api_example.c):
* - libvgmstream_init(...) // base context
* - libvgmstream_setup(...) // config if needed
* - libvgmstream_open_song(...) // setup format
* - libvgmstream_play(...) // main decode
* - output samples + repeat libvgmstream_play until stream is done
* - libvgmstream_free(...) // cleanup
*/ */
@ -108,7 +107,9 @@ typedef struct {
int64_t stream_samples; // file's max samples (not final play duration) int64_t stream_samples; // file's max samples (not final play duration)
int64_t loop_start; // loop start sample int64_t loop_start; // loop start sample
int64_t loop_end; // loop end sample int64_t loop_end; // loop end sample
bool loop_flag; // if file loops (false + defined loops means looping was forcefully disabled) bool loop_flag; // if file loops
// ** false + defined loops means looping was forcefully disabled
// ** true + undefined loops means the file loops in a way not representable by loop points
bool play_forever; // if file loops forever based on current config (meaning _play never stops) bool play_forever; // if file loops forever based on current config (meaning _play never stops)
int64_t play_samples; // totals after all calculations (after applying loop/fade/etc config) int64_t play_samples; // totals after all calculations (after applying loop/fade/etc config)
@ -191,8 +192,8 @@ typedef struct {
} libvgmstream_config_t; } libvgmstream_config_t;
/* pass default config, that will be applied to song on open /* pass default config, that will be applied to song on open
* - invalid config or complex cases (ex. some TXTP) may ignore these settings. * - invalid config or complex cases (ex. some TXTP) may ignore these settings
* - called without a song loaded (before _open or after _close), otherwise ignored. * - should be called without a song loaded (before _open or after _close)
* - without config vgmstream will decode the current stream once * - without config vgmstream will decode the current stream once
*/ */
LIBVGMSTREAM_API void libvgmstream_setup(libvgmstream_t* lib, libvgmstream_config_t* cfg); LIBVGMSTREAM_API void libvgmstream_setup(libvgmstream_t* lib, libvgmstream_config_t* cfg);
@ -227,7 +228,7 @@ LIBVGMSTREAM_API void libvgmstream_close_song(libvgmstream_t* lib);
* - vgmstream supplies its own buffer, updated on lib->decoder->* values (may change between calls) * - vgmstream supplies its own buffer, updated on lib->decoder->* values (may change between calls)
* - returns < 0 on error * - returns < 0 on error
*/ */
LIBVGMSTREAM_API int libvgmstream_play(libvgmstream_t* lib); LIBVGMSTREAM_API int libvgmstream_render(libvgmstream_t* lib);
/* Same as _play, but fills some external buffer (also updates lib->decoder->* values) /* Same as _play, but fills some external buffer (also updates lib->decoder->* values)
* - returns < 0 on error, or N = number of filled samples. * - returns < 0 on error, or N = number of filled samples.
@ -297,7 +298,7 @@ typedef struct {
/* Returns if vgmstream can parse a filename by extension, to reject some files earlier /* Returns if vgmstream can parse a filename by extension, to reject some files earlier
* - doesn't check file contents (that's only done on _open) * - doesn't check file contents (that's only done on _open)
* - config may be NULL * - config may be NULL
* - mainly for plugins that fail early; libvgmstream doesn't use this * - mainly for plugins that want to fail early; libvgmstream doesn't use this
*/ */
LIBVGMSTREAM_API bool libvgmstream_is_valid(const char* filename, libvgmstream_valid_t* cfg); LIBVGMSTREAM_API bool libvgmstream_is_valid(const char* filename, libvgmstream_valid_t* cfg);
@ -321,6 +322,9 @@ LIBVGMSTREAM_API int libvgmstream_get_title(libvgmstream_t* lib, libvgmstream_ti
*/ */
LIBVGMSTREAM_API int libvgmstream_format_describe(libvgmstream_t* lib, char* dst, int dst_size); LIBVGMSTREAM_API int libvgmstream_format_describe(libvgmstream_t* lib, char* dst, int dst_size);
/* Return true if vgmstream detects from the filename that file can be used even if doesn't physically exist.
*/
LIBVGMSTREAM_API bool libvgmstream_is_virtual_filename(const char* filename);
/*****************************************************************************/ /*****************************************************************************/

View File

@ -60,29 +60,29 @@ static void ini_get_filename(In_Module* input_module, TCHAR *inifile) {
if (IsWindow(input_module->hMainWindow) && SendMessage(input_module->hMainWindow, WM_WA_IPC,0,IPC_GETVERSION) >= 0x5000) { if (IsWindow(input_module->hMainWindow) && SendMessage(input_module->hMainWindow, WM_WA_IPC,0,IPC_GETVERSION) >= 0x5000) {
/* newer Winamp with per-user settings */ /* newer Winamp with per-user settings */
TCHAR *ini_dir = (TCHAR *)SendMessage(input_module->hMainWindow, WM_WA_IPC, 0, IPC_GETINIDIRECTORY); TCHAR *ini_dir = (TCHAR *)SendMessage(input_module->hMainWindow, WM_WA_IPC, 0, IPC_GETINIDIRECTORY);
cfg_strncpy(inifile, ini_dir, PATH_LIMIT); cfg_strncpy(inifile, ini_dir, WINAMP_PATH_LIMIT);
cfg_strncat(inifile, TEXT("\\Plugins\\"), PATH_LIMIT); cfg_strncat(inifile, TEXT("\\Plugins\\"), WINAMP_PATH_LIMIT);
/* can't be certain that \Plugins already exists in the user dir */ /* can't be certain that \Plugins already exists in the user dir */
CreateDirectory(inifile,NULL); CreateDirectory(inifile,NULL);
cfg_strncat(inifile, CONFIG_INI_NAME, PATH_LIMIT); cfg_strncat(inifile, CONFIG_INI_NAME, WINAMP_PATH_LIMIT);
} }
else { else {
/* older winamp with single settings */ /* older winamp with single settings */
TCHAR *lastSlash; TCHAR *lastSlash;
GetModuleFileName(NULL, inifile, PATH_LIMIT); GetModuleFileName(NULL, inifile, WINAMP_PATH_LIMIT);
lastSlash = cfg_strrchr(inifile, TEXT('\\')); lastSlash = cfg_strrchr(inifile, TEXT('\\'));
*(lastSlash + 1) = 0; *(lastSlash + 1) = 0;
/* XMPlay doesn't have a "plugins" subfolder */ /* XMPlay doesn't have a "plugins" subfolder */
if (settings.is_xmplay) if (settings.is_xmplay)
cfg_strncat(inifile, CONFIG_INI_NAME,PATH_LIMIT); cfg_strncat(inifile, CONFIG_INI_NAME, WINAMP_PATH_LIMIT);
else else
cfg_strncat(inifile, TEXT("Plugins\\") CONFIG_INI_NAME,PATH_LIMIT); cfg_strncat(inifile, TEXT("Plugins\\") CONFIG_INI_NAME, WINAMP_PATH_LIMIT);
/* Maybe should query IPC_GETINIDIRECTORY and use that, not sure what ancient Winamps need. /* Maybe should query IPC_GETINIDIRECTORY and use that, not sure what ancient Winamps need.
* There must be some proper way to handle dirs since other Winamp plugins save config in * There must be some proper way to handle dirs since other Winamp plugins save config in
* XMPlay correctly (this feels like archaeology, try later) */ * XMPlay correctly (this feels like archaeology, try later) */
@ -144,7 +144,7 @@ static void ini_set_b(const char *inifile, const char *entry, int val) {
} }
/*static*/ void load_config(In_Module* input_module, winamp_settings_t* settings, winamp_settings_t* defaults) { /*static*/ void load_config(In_Module* input_module, winamp_settings_t* settings, winamp_settings_t* defaults) {
TCHAR inifile[PATH_LIMIT]; TCHAR inifile[WINAMP_PATH_LIMIT];
ini_get_filename(input_module, inifile); ini_get_filename(input_module, inifile);
@ -176,7 +176,7 @@ static void ini_set_b(const char *inifile, const char *entry, int val) {
} }
static void save_config(In_Module* input_module, winamp_settings_t* settings) { static void save_config(In_Module* input_module, winamp_settings_t* settings) {
TCHAR inifile[PATH_LIMIT]; TCHAR inifile[WINAMP_PATH_LIMIT];
ini_get_filename(input_module, inifile); ini_get_filename(input_module, inifile);

View File

@ -61,14 +61,14 @@ static void wasf_get_name(WINAMP_STREAMFILE* sf, char* buffer, size_t length) {
} }
static STREAMFILE* wasf_open(WINAMP_STREAMFILE* sf, const char* const filename, size_t buffersize) { static STREAMFILE* wasf_open(WINAMP_STREAMFILE* sf, const char* const filename, size_t buffersize) {
in_char wpath[PATH_LIMIT]; in_char wpath[WINAMP_PATH_LIMIT];
if (!filename) if (!filename)
return NULL; return NULL;
/* no need to wfdopen here, may use standard IO */ /* no need to wfdopen here, may use standard IO */
/* STREAMFILEs carry char/UTF8 names, convert to wchar for Winamp */ /* STREAMFILEs carry char/UTF8 names, convert to wchar for Winamp */
wa_char_to_ichar(wpath, PATH_LIMIT, filename); wa_char_to_ichar(wpath, WINAMP_PATH_LIMIT, filename);
return open_winamp_streamfile_by_ipath(wpath); return open_winamp_streamfile_by_ipath(wpath);
} }
@ -109,11 +109,11 @@ fail:
STREAMFILE* open_winamp_streamfile_by_ipath(const in_char* wpath) { STREAMFILE* open_winamp_streamfile_by_ipath(const in_char* wpath) {
FILE* infile = NULL; FILE* infile = NULL;
STREAMFILE* sf; STREAMFILE* sf;
char path[PATH_LIMIT]; char path[WINAMP_PATH_LIMIT];
/* convert to UTF-8 if needed for internal use */ /* convert to UTF-8 if needed for internal use */
wa_ichar_to_char(path,PATH_LIMIT, wpath); wa_ichar_to_char(path, WINAMP_PATH_LIMIT, wpath);
/* open a FILE from a Winamp (possibly UTF-16) path */ /* open a FILE from a Winamp (possibly UTF-16) path */
infile = wa_fopen(wpath); infile = wa_fopen(wpath);

View File

@ -89,9 +89,9 @@ bool split_subsongs(const in_char* filename, int subsong_index, VGMSTREAM* vgmst
/* The only way to pass info around in Winamp is encoding it into the filename, so a fake name /* The only way to pass info around in Winamp is encoding it into the filename, so a fake name
* is created with the index. Then, winamp_Play (and related) intercepts and reads the index. */ * is created with the index. Then, winamp_Play (and related) intercepts and reads the index. */
for (i = 0; i < vgmstream->num_streams; i++) { for (i = 0; i < vgmstream->num_streams; i++) {
in_char stream_fn[PATH_LIMIT]; in_char stream_fn[WINAMP_PATH_LIMIT];
make_fn_subsong(stream_fn,PATH_LIMIT, filename, (i+1)); /* encode index in filename */ make_fn_subsong(stream_fn, WINAMP_PATH_LIMIT, filename, (i+1)); /* encode index in filename */
/* insert at index */ /* insert at index */
{ {

View File

@ -51,7 +51,7 @@ const char* tagfile_name = "!tags.m3u";
HANDLE decode_thread_handle = INVALID_HANDLE_VALUE; HANDLE decode_thread_handle = INVALID_HANDLE_VALUE;
VGMSTREAM* vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
in_char lastfn[PATH_LIMIT] = {0}; /* name of the currently playing file */ in_char lastfn[WINAMP_PATH_LIMIT] = {0}; /* name of the currently playing file */
winamp_settings_t defaults; winamp_settings_t defaults;
winamp_settings_t settings; winamp_settings_t settings;
@ -59,7 +59,7 @@ winamp_state_t state;
short sample_buffer[SAMPLE_BUFFER_SIZE * 2 * VGMSTREAM_MAX_CHANNELS]; //todo maybe should be dynamic short sample_buffer[SAMPLE_BUFFER_SIZE * 2 * VGMSTREAM_MAX_CHANNELS]; //todo maybe should be dynamic
/* info cache (optimization) */ /* info cache (optimization) */
in_char info_fn[PATH_LIMIT] = {0}; in_char info_fn[WINAMP_PATH_LIMIT] = {0};
in_char info_title[GETFILEINFO_TITLE_LENGTH]; in_char info_title[GETFILEINFO_TITLE_LENGTH];
int info_time; int info_time;
int info_valid; int info_valid;
@ -116,11 +116,11 @@ static VGMSTREAM* init_vgmstream_winamp(const in_char* fn, int stream_index) {
/* opens vgmstream with (possibly) an index */ /* opens vgmstream with (possibly) an index */
static VGMSTREAM* init_vgmstream_winamp_fileinfo(const in_char* fn) { static VGMSTREAM* init_vgmstream_winamp_fileinfo(const in_char* fn) {
in_char filename[PATH_LIMIT]; in_char filename[WINAMP_PATH_LIMIT];
int stream_index = 0; int stream_index = 0;
/* check for info encoded in the filename */ /* check for info encoded in the filename */
parse_fn_string(fn, NULL, filename,PATH_LIMIT); parse_fn_string(fn, NULL, filename, WINAMP_PATH_LIMIT);
parse_fn_int(fn, wa_L("$s"), &stream_index); parse_fn_int(fn, wa_L("$s"), &stream_index);
return init_vgmstream_winamp(filename, stream_index); return init_vgmstream_winamp(filename, stream_index);
@ -141,14 +141,14 @@ static int is_xmplay() {
/* unicode utils */ /* unicode utils */
static void get_title(in_char* dst, int dst_size, const in_char* fn, VGMSTREAM* infostream) { static void get_title(in_char* dst, int dst_size, const in_char* fn, VGMSTREAM* infostream) {
in_char filename[PATH_LIMIT]; in_char filename[WINAMP_PATH_LIMIT];
char buffer[PATH_LIMIT]; char buffer[WINAMP_PATH_LIMIT];
char filename_utf8[PATH_LIMIT]; char filename_utf8[WINAMP_PATH_LIMIT];
parse_fn_string(fn, NULL, filename,PATH_LIMIT); parse_fn_string(fn, NULL, filename,WINAMP_PATH_LIMIT);
//parse_fn_int(fn, wa_L("$s"), &stream_index); //parse_fn_int(fn, wa_L("$s"), &stream_index);
wa_ichar_to_char(filename_utf8, PATH_LIMIT, filename); wa_ichar_to_char(filename_utf8, WINAMP_PATH_LIMIT, filename);
/* infostream gets added at first with index 0, then once played it re-adds proper numbers */ /* infostream gets added at first with index 0, then once played it re-adds proper numbers */
if (infostream) { if (infostream) {
@ -187,7 +187,7 @@ static double get_album_gain_volume(const in_char* fn) {
if (settings.gain_type == REPLAYGAIN_NONE) if (settings.gain_type == REPLAYGAIN_NONE)
return 1.0; return 1.0;
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,(in_char*)fn); vgm_logi("get_album_gain_volume: file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,(in_char*)fn); vgm_logi("get_album_gain_volume: file %s\n", f8); }
replaygain[0] = '\0'; /* reset each time to make sure we read actual tags */ replaygain[0] = '\0'; /* reset each time to make sure we read actual tags */
if (settings.gain_type == REPLAYGAIN_ALBUM if (settings.gain_type == REPLAYGAIN_ALBUM
@ -281,7 +281,7 @@ void winamp_Quit() {
int winamp_IsOurFile(const in_char *fn) { int winamp_IsOurFile(const in_char *fn) {
VGMSTREAM* infostream; VGMSTREAM* infostream;
vgmstream_ctx_valid_cfg cfg = {0}; vgmstream_ctx_valid_cfg cfg = {0};
char filename_utf8[PATH_LIMIT]; char filename_utf8[WINAMP_PATH_LIMIT];
int valid; int valid;
/* Winamp file opening 101: /* Winamp file opening 101:
@ -315,7 +315,7 @@ int winamp_IsOurFile(const in_char *fn) {
cfg.accept_unknown = settings.exts_unknown_on; cfg.accept_unknown = settings.exts_unknown_on;
cfg.accept_common = settings.exts_common_on; cfg.accept_common = settings.exts_common_on;
wa_ichar_to_char(filename_utf8, PATH_LIMIT, fn); wa_ichar_to_char(filename_utf8, WINAMP_PATH_LIMIT, fn);
//;vgm_logi("winamp_IsOurFile: %s\n", filename_utf8); //;vgm_logi("winamp_IsOurFile: %s\n", filename_utf8);
@ -324,7 +324,7 @@ int winamp_IsOurFile(const in_char *fn) {
* open/get info from the file (slower so keep some cache) */ * open/get info from the file (slower so keep some cache) */
info_valid = 0; /* may not be playable */ info_valid = 0; /* may not be playable */
wa_strncpy(info_fn, fn, PATH_LIMIT); /* copy now for repeat calls */ wa_strncpy(info_fn, fn, WINAMP_PATH_LIMIT); /* copy now for repeat calls */
/* basic extension check */ /* basic extension check */
valid = vgmstream_ctx_is_valid(filename_utf8, &cfg); valid = vgmstream_ctx_is_valid(filename_utf8, &cfg);
@ -369,17 +369,17 @@ int winamp_IsOurFile(const in_char *fn) {
/* request to start playing a file */ /* request to start playing a file */
int winamp_Play(const in_char *fn) { int winamp_Play(const in_char *fn) {
int max_latency; int max_latency;
in_char filename[PATH_LIMIT]; in_char filename[WINAMP_PATH_LIMIT];
int stream_index = 0; int stream_index = 0;
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,fn); vgm_logi("winamp_Play: file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,fn); vgm_logi("winamp_Play: file %s\n", f8); }
/* shouldn't happen */ /* shouldn't happen */
if (vgmstream) if (vgmstream)
return 1; return 1;
/* check for info encoded in the filename */ /* check for info encoded in the filename */
parse_fn_string(fn, NULL, filename,PATH_LIMIT); parse_fn_string(fn, NULL, filename,WINAMP_PATH_LIMIT);
parse_fn_int(fn, wa_L("$s"), &stream_index); parse_fn_int(fn, wa_L("$s"), &stream_index);
/* open the stream */ /* open the stream */
@ -412,7 +412,7 @@ int winamp_Play(const in_char *fn) {
/* save original name */ /* save original name */
wa_strncpy(lastfn,fn,PATH_LIMIT); wa_strncpy(lastfn,fn,WINAMP_PATH_LIMIT);
/* open the output plugin */ /* open the output plugin */
max_latency = input_module.outMod->Open(vgmstream->sample_rate, state.output_channels, 16, 0, 0); max_latency = input_module.outMod->Open(vgmstream->sample_rate, state.output_channels, 16, 0, 0);
@ -592,7 +592,7 @@ void winamp_GetFileInfo(const in_char *fn, in_char *title, int *length_in_ms) {
} }
else { else {
VGMSTREAM* infostream = NULL; VGMSTREAM* infostream = NULL;
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,fn); vgm_logi("winamp_GetFileInfo: file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,fn); vgm_logi("winamp_GetFileInfo: file %s\n", f8); }
/* not changed from last IsOurFile (most common) */ /* not changed from last IsOurFile (most common) */
if (info_valid && wa_strcmp(fn, info_fn) == 0) { if (info_valid && wa_strcmp(fn, info_fn) == 0) {
@ -789,13 +789,13 @@ __declspec(dllexport) In_Module * winampGetInModule2() {
/* IN_TAGS */ /* IN_TAGS */
/* ************************************* */ /* ************************************* */
/* could malloc and stuff but totals aren't much bigger than PATH_LIMITs anyway */ /* could malloc and stuff but totals aren't much bigger than WINAMP_PATH_LIMITs anyway */
#define WINAMP_TAGS_ENTRY_MAX 30 #define WINAMP_TAGS_ENTRY_MAX 30
#define WINAMP_TAGS_ENTRY_SIZE 2048 #define WINAMP_TAGS_ENTRY_SIZE 2048
typedef struct { typedef struct {
int loaded; int loaded;
in_char filename[PATH_LIMIT]; /* tags are loaded for this file */ in_char filename[WINAMP_PATH_LIMIT]; /* tags are loaded for this file */
int tag_count; int tag_count;
char keys[WINAMP_TAGS_ENTRY_MAX][WINAMP_TAGS_ENTRY_SIZE+1]; char keys[WINAMP_TAGS_ENTRY_MAX][WINAMP_TAGS_ENTRY_SIZE+1];
@ -809,10 +809,10 @@ winamp_tags last_tags;
* Winamp requests one tag at a time and may reask for the same tag several times */ * Winamp requests one tag at a time and may reask for the same tag several times */
static void load_tagfile_info(in_char* filename) { static void load_tagfile_info(in_char* filename) {
STREAMFILE *tagFile = NULL; STREAMFILE *tagFile = NULL;
in_char filename_clean[PATH_LIMIT]; in_char filename_clean[WINAMP_PATH_LIMIT];
char filename_utf8[PATH_LIMIT]; char filename_utf8[WINAMP_PATH_LIMIT];
char tagfile_path_utf8[PATH_LIMIT]; char tagfile_path_utf8[WINAMP_PATH_LIMIT];
in_char tagfile_path_i[PATH_LIMIT]; in_char tagfile_path_i[WINAMP_PATH_LIMIT];
char *path; char *path;
@ -823,7 +823,7 @@ static void load_tagfile_info(in_char* filename) {
} }
/* clean extra part for subsong tags */ /* clean extra part for subsong tags */
parse_fn_string(filename, NULL, filename_clean,PATH_LIMIT); parse_fn_string(filename, NULL, filename_clean,WINAMP_PATH_LIMIT);
if (wa_strcmp(last_tags.filename, filename_clean) == 0) { if (wa_strcmp(last_tags.filename, filename_clean) == 0) {
return; /* not changed, tags still apply */ return; /* not changed, tags still apply */
@ -832,7 +832,7 @@ static void load_tagfile_info(in_char* filename) {
last_tags.loaded = 0; last_tags.loaded = 0;
/* tags are now for this filename, find tagfile path */ /* tags are now for this filename, find tagfile path */
wa_ichar_to_char(filename_utf8, PATH_LIMIT, filename_clean); wa_ichar_to_char(filename_utf8, WINAMP_PATH_LIMIT, filename_clean);
strcpy(tagfile_path_utf8,filename_utf8); strcpy(tagfile_path_utf8,filename_utf8);
path = strrchr(tagfile_path_utf8,'\\'); path = strrchr(tagfile_path_utf8,'\\');
@ -843,7 +843,7 @@ static void load_tagfile_info(in_char* filename) {
else { /* ??? */ else { /* ??? */
strcpy(tagfile_path_utf8, tagfile_name); strcpy(tagfile_path_utf8, tagfile_name);
} }
wa_char_to_ichar(tagfile_path_i, PATH_LIMIT, tagfile_path_utf8); wa_char_to_ichar(tagfile_path_i, WINAMP_PATH_LIMIT, tagfile_path_utf8);
wa_strcpy(last_tags.filename, filename_clean); wa_strcpy(last_tags.filename, filename_clean);
last_tags.tag_count = 0; last_tags.tag_count = 0;
@ -895,7 +895,7 @@ static int winampGetExtendedFileInfo_common(in_char* filename, char *metadata, c
int i, tag_found; int i, tag_found;
int max_len; int max_len;
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,filename); vgm_logi("winampGetExtendedFileInfo_common: file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,filename); vgm_logi("winampGetExtendedFileInfo_common: file %s\n", f8); }
/* load list current tags, if necessary */ /* load list current tags, if necessary */
load_tagfile_info(filename); load_tagfile_info(filename);
@ -952,13 +952,13 @@ fail:
/* for Winamp 5.24 */ /* for Winamp 5.24 */
__declspec (dllexport) int winampGetExtendedFileInfo(char *filename, char *metadata, char *ret, int retlen) { __declspec (dllexport) int winampGetExtendedFileInfo(char *filename, char *metadata, char *ret, int retlen) {
in_char filename_wchar[PATH_LIMIT]; in_char filename_wchar[WINAMP_PATH_LIMIT];
int ok; int ok;
if (settings.tagfile_disable) if (settings.tagfile_disable)
return 0; return 0;
wa_char_to_ichar(filename_wchar,PATH_LIMIT, filename); wa_char_to_ichar(filename_wchar,WINAMP_PATH_LIMIT, filename);
//;{ vgm_logi("winampGetExtendedFileInfo: file %s\n", filename); } //;{ vgm_logi("winampGetExtendedFileInfo: file %s\n", filename); }
@ -971,16 +971,16 @@ __declspec (dllexport) int winampGetExtendedFileInfo(char *filename, char *metad
/* for Winamp 5.3+ */ /* for Winamp 5.3+ */
__declspec (dllexport) int winampGetExtendedFileInfoW(wchar_t *filename, char *metadata, wchar_t *ret, int retlen) { __declspec (dllexport) int winampGetExtendedFileInfoW(wchar_t *filename, char *metadata, wchar_t *ret, int retlen) {
in_char filename_ichar[PATH_LIMIT]; in_char filename_ichar[WINAMP_PATH_LIMIT];
char ret_utf8[2048]; char ret_utf8[2048];
int ok; int ok;
if (settings.tagfile_disable) if (settings.tagfile_disable)
return 0; return 0;
wa_wchar_to_ichar(filename_ichar,PATH_LIMIT, filename); wa_wchar_to_ichar(filename_ichar,WINAMP_PATH_LIMIT, filename);
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,filename); vgm_logi("winampGetExtendedFileInfoW: file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,filename); vgm_logi("winampGetExtendedFileInfoW: file %s\n", f8); }
ok = winampGetExtendedFileInfo_common(filename_ichar, metadata, ret_utf8,2048); ok = winampGetExtendedFileInfo_common(filename_ichar, metadata, ret_utf8,2048);
if (ok == 0) if (ok == 0)
@ -1019,7 +1019,7 @@ short xsample_buffer[SAMPLE_BUFFER_SIZE*2 * VGMSTREAM_MAX_CHANNELS];
static void* winampGetExtendedRead_open_common(in_char *fn, int *size, int *bps, int *nch, int *srate) { static void* winampGetExtendedRead_open_common(in_char *fn, int *size, int *bps, int *nch, int *srate) {
VGMSTREAM* xvgmstream = NULL; VGMSTREAM* xvgmstream = NULL;
//;{ char f8[PATH_LIMIT]; wa_ichar_to_char(f8,PATH_LIMIT,fn); vgm_logi("winampGetExtendedRead_open_common: open common file %s\n", f8); } //;{ char f8[WINAMP_PATH_LIMIT]; wa_ichar_to_char(f8,WINAMP_PATH_LIMIT,fn); vgm_logi("winampGetExtendedRead_open_common: open common file %s\n", f8); }
/* open the stream */ /* open the stream */
xvgmstream = init_vgmstream_winamp_fileinfo(fn); xvgmstream = init_vgmstream_winamp_fileinfo(fn);
@ -1056,17 +1056,17 @@ static void* winampGetExtendedRead_open_common(in_char *fn, int *size, int *bps,
} }
__declspec(dllexport) void* winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate) { __declspec(dllexport) void* winampGetExtendedRead_open(const char *fn, int *size, int *bps, int *nch, int *srate) {
in_char filename_wchar[PATH_LIMIT]; in_char filename_wchar[WINAMP_PATH_LIMIT];
wa_char_to_ichar(filename_wchar, PATH_LIMIT, fn); wa_char_to_ichar(filename_wchar, WINAMP_PATH_LIMIT, fn);
return winampGetExtendedRead_open_common(filename_wchar, size, bps, nch, srate); return winampGetExtendedRead_open_common(filename_wchar, size, bps, nch, srate);
} }
__declspec(dllexport) void* winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate) { __declspec(dllexport) void* winampGetExtendedRead_openW(const wchar_t *fn, int *size, int *bps, int *nch, int *srate) {
in_char filename_ichar[PATH_LIMIT]; in_char filename_ichar[WINAMP_PATH_LIMIT];
wa_wchar_to_ichar(filename_ichar, PATH_LIMIT, fn); wa_wchar_to_ichar(filename_ichar, WINAMP_PATH_LIMIT, fn);
return winampGetExtendedRead_open_common(filename_ichar, size, bps, nch, srate); return winampGetExtendedRead_open_common(filename_ichar, size, bps, nch, srate);
} }

View File

@ -33,6 +33,8 @@
/* IN_CONFIG */ /* IN_CONFIG */
/* ************************************* */ /* ************************************* */
#define WINAMP_PATH_LIMIT 4096
extern In_Module input_module; extern In_Module input_module;
extern const int priority_values[7]; extern const int priority_values[7];