2017-05-01 14:18:33 +02:00
|
|
|
/**
|
|
|
|
* vgmstream for Winamp
|
|
|
|
*/
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
/* Normally Winamp opens unicode files by their DOS 8.3 name. #define this to use wchar_t filenames,
|
|
|
|
* which must be opened with _wfopen in a WINAMP_STREAMFILE (needed for dual files like .pos).
|
|
|
|
* Only for Winamp paths, other parts would need #define UNICODE for Windows. */
|
2017-11-10 21:01:29 +01:00
|
|
|
#ifdef VGM_WINAMP_UNICODE
|
|
|
|
#define UNICODE_INPUT_PLUGIN
|
|
|
|
#endif
|
2017-04-28 16:15:32 +02:00
|
|
|
|
2008-04-03 15:40:36 +02:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
|
|
|
#endif
|
2008-03-10 23:58:31 +01:00
|
|
|
#include <windows.h>
|
2008-05-16 18:09:28 +02:00
|
|
|
#include <windowsx.h>
|
|
|
|
#include <commctrl.h>
|
2008-03-10 23:58:31 +01:00
|
|
|
#include <stdio.h>
|
2008-05-18 22:01:37 +02:00
|
|
|
#include <io.h>
|
2017-01-03 13:34:20 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
#include "../src/vgmstream.h"
|
|
|
|
#include "in2.h"
|
2008-05-18 22:01:37 +02:00
|
|
|
#include "wa_ipc.h"
|
2017-08-12 19:24:18 +02:00
|
|
|
#include "ipc_pe.h"
|
2008-05-16 18:09:28 +02:00
|
|
|
#include "resource.h"
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
|
2008-04-03 15:40:36 +02:00
|
|
|
#ifndef VERSION
|
2017-01-15 23:09:37 +01:00
|
|
|
#include "../version.h"
|
|
|
|
#endif
|
|
|
|
#ifndef VERSION
|
|
|
|
#define VERSION "(unknown version)"
|
2008-04-03 15:40:36 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__
|
2017-04-28 16:15:32 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
/* ************************************* */
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
/* config */
|
|
|
|
#define CONFIG_APP_NAME "vgmstream plugin"
|
|
|
|
#define CONFIG_INI_NAME "plugin.ini"
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
#define DEFAULT_FADE_SECONDS "10.00"
|
|
|
|
#define DEFAULT_FADE_DELAY_SECONDS "0.00"
|
|
|
|
#define DEFAULT_LOOP_COUNT "2.00"
|
2008-05-16 18:09:28 +02:00
|
|
|
#define DEFAULT_THREAD_PRIORITY 3
|
|
|
|
#define DEFAULT_LOOP_FOREVER 0
|
2008-05-17 20:01:20 +02:00
|
|
|
#define DEFAULT_IGNORE_LOOP 0
|
2017-08-19 11:05:01 +02:00
|
|
|
#define DEFAULT_DISABLE_SUBSONGS 0
|
2008-05-16 18:09:28 +02:00
|
|
|
|
|
|
|
#define FADE_SECONDS_INI_ENTRY "fade_seconds"
|
2008-05-16 22:28:36 +02:00
|
|
|
#define FADE_DELAY_SECONDS_INI_ENTRY "fade_delay"
|
2008-05-16 18:09:28 +02:00
|
|
|
#define LOOP_COUNT_INI_ENTRY "loop_count"
|
|
|
|
#define THREAD_PRIORITY_INI_ENTRY "thread_priority"
|
|
|
|
#define LOOP_FOREVER_INI_ENTRY "loop_forever"
|
2008-05-17 20:01:20 +02:00
|
|
|
#define IGNORE_LOOP_INI_ENTRY "ignore_loop"
|
2017-08-19 11:05:01 +02:00
|
|
|
#define DISABLE_SUBSONGS_INI_ENTRY "disable_subsongs"
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
char *priority_strings[] = {"Idle","Lowest","Below Normal","Normal","Above Normal","Highest (not recommended)","Time Critical (not recommended)"};
|
|
|
|
int priority_values[] = {THREAD_PRIORITY_IDLE,THREAD_PRIORITY_LOWEST,THREAD_PRIORITY_BELOW_NORMAL,THREAD_PRIORITY_NORMAL,THREAD_PRIORITY_ABOVE_NORMAL,THREAD_PRIORITY_HIGHEST,THREAD_PRIORITY_TIME_CRITICAL};
|
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
/* ************************************* */
|
|
|
|
|
|
|
|
/* plugin main (declared at the bottom of this file) */
|
|
|
|
In_Module input_module;
|
|
|
|
DWORD WINAPI __stdcall decode(void *arg);
|
2017-04-28 16:15:32 +02:00
|
|
|
|
|
|
|
/* Winamp Play extension list, needed to accept/play and associate extensions in Windows */
|
2017-11-10 20:26:44 +01:00
|
|
|
#define EXTENSION_LIST_SIZE (0x2000 * 6)
|
2017-04-28 16:15:32 +02:00
|
|
|
#define EXT_BUFFER_SIZE 200
|
|
|
|
char working_extension_list[EXTENSION_LIST_SIZE] = {0};
|
|
|
|
|
|
|
|
/* plugin config */
|
2008-05-16 18:09:28 +02:00
|
|
|
double fade_seconds;
|
2008-05-16 22:28:36 +02:00
|
|
|
double fade_delay_seconds;
|
2008-05-16 18:09:28 +02:00
|
|
|
double loop_count;
|
|
|
|
int thread_priority;
|
|
|
|
int loop_forever;
|
2008-05-17 20:01:20 +02:00
|
|
|
int ignore_loop;
|
2017-08-19 11:05:01 +02:00
|
|
|
int disable_subsongs;
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* plugin state */
|
2008-03-10 23:58:31 +01:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
HANDLE decode_thread_handle = INVALID_HANDLE_VALUE;
|
2017-04-28 16:15:32 +02:00
|
|
|
short sample_buffer[576*2*2]; /* 576 16-bit samples, stereo, possibly doubled in size for DSP */
|
|
|
|
|
2008-03-10 23:58:31 +01:00
|
|
|
int paused = 0;
|
|
|
|
int decode_abort = 0;
|
2008-05-16 22:57:19 +02:00
|
|
|
int seek_needed_samples = -1;
|
2008-03-10 23:58:31 +01:00
|
|
|
int decode_pos_ms = 0;
|
|
|
|
int decode_pos_samples = 0;
|
|
|
|
int stream_length_samples = 0;
|
|
|
|
int fade_samples = 0;
|
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
in_char lastfn[PATH_LIMIT] = {0}; /* name of the currently playing file */
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
/* ************************************* */
|
|
|
|
//todo safe ops
|
2017-08-19 10:26:21 +02:00
|
|
|
//todo there must be a better way to handle unicode...
|
2017-08-13 19:58:28 +02:00
|
|
|
#ifdef UNICODE_INPUT_PLUGIN
|
|
|
|
#define wa_strcpy wcscpy
|
|
|
|
#define wa_strncpy wcsncpy
|
2017-08-19 10:26:21 +02:00
|
|
|
#define wa_strcat wcscat
|
2017-08-13 19:58:28 +02:00
|
|
|
#define wa_strlen wcslen
|
2017-08-19 10:26:21 +02:00
|
|
|
#define wa_strchr wcschr
|
|
|
|
#define wa_sscanf swscanf
|
2017-09-30 01:26:44 +02:00
|
|
|
#define wa_snprintf _snwprintf
|
2017-08-19 10:26:21 +02:00
|
|
|
#define wa_fileinfo fileinfoW
|
|
|
|
#define wa_IPC_PE_INSERTFILENAME IPC_PE_INSERTFILENAMEW
|
|
|
|
#define wa_L(x) L ##x
|
2017-08-13 19:58:28 +02:00
|
|
|
#else
|
|
|
|
#define wa_strcpy strcpy
|
|
|
|
#define wa_strncpy strncpy
|
2017-08-19 10:26:21 +02:00
|
|
|
#define wa_strcat strcat
|
2017-08-13 19:58:28 +02:00
|
|
|
#define wa_strlen strlen
|
2017-08-19 10:26:21 +02:00
|
|
|
#define wa_strchr strchr
|
|
|
|
#define wa_sscanf sscanf
|
|
|
|
#define wa_snprintf snprintf
|
|
|
|
#define wa_fileinfo fileinfo
|
|
|
|
#define wa_IPC_PE_INSERTFILENAME IPC_PE_INSERTFILENAME
|
|
|
|
#define wa_L(x) x
|
2017-08-13 19:58:28 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* converts from utf16 to utf8 (if unicode is active) */
|
|
|
|
static void wa_wchar_to_char(char *dst, size_t dstsize, const in_char *wsrc) {
|
|
|
|
#ifdef UNICODE_INPUT_PLUGIN
|
|
|
|
/* converto to UTF8 codepage, default separate bytes, source wstr, wstr lenght, */
|
|
|
|
//int size_needed = WideCharToMultiByte(CP_UTF8,0, src,-1, NULL,0, NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_UTF8,0, wsrc,-1, dst,dstsize, NULL, NULL);
|
|
|
|
#else
|
|
|
|
strcpy(dst,wsrc);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* converts from utf8 to utf16 (if unicode is active) */
|
|
|
|
static void wa_char_to_wchar(in_char *wdst, size_t wdstsize, const char *src) {
|
|
|
|
#ifdef UNICODE_INPUT_PLUGIN
|
|
|
|
//int size_needed = MultiByteToWideChar(CP_UTF8,0, src,-1, NULL,0);
|
|
|
|
MultiByteToWideChar(CP_UTF8,0, src,-1, wdst,wdstsize);
|
|
|
|
#else
|
|
|
|
strcpy(wdst,src);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* opens a utf16 (unicode) path */
|
|
|
|
static FILE* wa_fopen(const in_char *wpath) {
|
|
|
|
#ifdef UNICODE_INPUT_PLUGIN
|
|
|
|
return _wfopen(wpath,L"rb");
|
|
|
|
#else
|
|
|
|
return fopen(wpath,"rb");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* dupes a utf16 (unicode) file */
|
|
|
|
static FILE* wa_fdopen(int fd) {
|
|
|
|
#ifdef UNICODE_INPUT_PLUGIN
|
|
|
|
return _wfdopen(fd,L"rb");
|
|
|
|
#else
|
|
|
|
return fdopen(fd,"rb");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* a STREAMFILE that operates via STDIOSTREAMFILE but handles Winamp's unicode (in_char) paths */
|
|
|
|
typedef struct _WINAMP_STREAMFILE {
|
|
|
|
STREAMFILE sf;
|
|
|
|
STREAMFILE *stdiosf;
|
|
|
|
FILE *infile_ref; /* pointer to the infile in stdiosf */
|
|
|
|
} WINAMP_STREAMFILE;
|
|
|
|
|
|
|
|
static STREAMFILE *open_winamp_streamfile_by_file(FILE *infile, const char * path);
|
|
|
|
static STREAMFILE *open_winamp_streamfile_by_wpath(const in_char *wpath);
|
|
|
|
|
|
|
|
static size_t wasf_read(WINAMP_STREAMFILE *streamfile, uint8_t *dest, off_t offset, size_t length) {
|
|
|
|
return streamfile->stdiosf->read(streamfile->stdiosf,dest,offset,length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static off_t wasf_get_size(WINAMP_STREAMFILE *streamfile) {
|
|
|
|
return streamfile->stdiosf->get_size(streamfile->stdiosf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static off_t wasf_get_offset(WINAMP_STREAMFILE *streamfile) {
|
|
|
|
return streamfile->stdiosf->get_offset(streamfile->stdiosf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wasf_get_name(WINAMP_STREAMFILE *streamfile, char *buffer, size_t length) {
|
|
|
|
return streamfile->stdiosf->get_name(streamfile->stdiosf, buffer, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wasf_get_realname(WINAMP_STREAMFILE *streamfile, char *buffer, size_t length) {
|
|
|
|
return streamfile->stdiosf->get_realname(streamfile->stdiosf, buffer, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
static STREAMFILE *wasf_open(WINAMP_STREAMFILE *streamFile, const char *const filename, size_t buffersize) {
|
|
|
|
int newfd;
|
|
|
|
FILE *newfile;
|
|
|
|
STREAMFILE *newstreamFile;
|
|
|
|
in_char wpath[PATH_LIMIT];
|
|
|
|
char name[PATH_LIMIT];
|
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* if same name, duplicate the file pointer we already have open */ //unsure if all this is needed
|
|
|
|
streamFile->stdiosf->get_name(streamFile->stdiosf, name, PATH_LIMIT);
|
|
|
|
if (!strcmp(name,filename)) {
|
|
|
|
if (((newfd = dup(fileno(streamFile->infile_ref))) >= 0) &&
|
|
|
|
(newfile = wa_fdopen(newfd)))
|
|
|
|
{
|
|
|
|
newstreamFile = open_winamp_streamfile_by_file(newfile,filename);
|
|
|
|
if (newstreamFile) {
|
|
|
|
return newstreamFile;
|
|
|
|
}
|
|
|
|
// failure, close it and try the default path (which will probably fail a second time)
|
|
|
|
fclose(newfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* STREAMFILEs carry char/UTF8 names, convert to wchar for Winamp */
|
|
|
|
wa_char_to_wchar(wpath,PATH_LIMIT, filename);
|
|
|
|
return open_winamp_streamfile_by_wpath(wpath);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wasf_close(WINAMP_STREAMFILE *streamfile) {
|
|
|
|
/* closes infile_ref + frees in the internal STDIOSTREAMFILE (fclose for wchar is not needed) */
|
|
|
|
streamfile->stdiosf->close(streamfile->stdiosf);
|
|
|
|
free(streamfile); /* and the current struct */
|
|
|
|
}
|
|
|
|
|
|
|
|
static STREAMFILE *open_winamp_streamfile_by_file(FILE *infile, const char * path) {
|
|
|
|
WINAMP_STREAMFILE *streamfile = NULL;
|
|
|
|
STREAMFILE *stdiosf = NULL;
|
|
|
|
|
|
|
|
streamfile = calloc(1,sizeof(WINAMP_STREAMFILE));
|
|
|
|
if (!streamfile) goto fail;
|
|
|
|
|
|
|
|
stdiosf = open_stdio_streamfile_by_file(infile,path);
|
|
|
|
if (!stdiosf) goto fail;
|
|
|
|
|
|
|
|
streamfile->sf.read = (void*)wasf_read;
|
|
|
|
streamfile->sf.get_size = (void*)wasf_get_size;
|
|
|
|
streamfile->sf.get_offset = (void*)wasf_get_offset;
|
|
|
|
streamfile->sf.get_name = (void*)wasf_get_name;
|
|
|
|
streamfile->sf.get_realname = (void*)wasf_get_realname;
|
|
|
|
streamfile->sf.open = (void*)wasf_open;
|
|
|
|
streamfile->sf.close = (void*)wasf_close;
|
|
|
|
|
|
|
|
streamfile->stdiosf = stdiosf;
|
|
|
|
streamfile->infile_ref = infile;
|
|
|
|
|
|
|
|
return &streamfile->sf; /* pointer to STREAMFILE start = rest of the custom data follows */
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_streamfile(stdiosf);
|
|
|
|
free(streamfile);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static STREAMFILE *open_winamp_streamfile_by_wpath(const in_char *wpath) {
|
|
|
|
FILE *infile = NULL;
|
|
|
|
STREAMFILE *streamFile;
|
|
|
|
char path[PATH_LIMIT];
|
|
|
|
|
|
|
|
/* open a FILE from a Winamp (possibly UTF-16) path */
|
|
|
|
infile = wa_fopen(wpath);
|
|
|
|
if (!infile) return NULL;
|
|
|
|
|
|
|
|
/* convert to UTF-8 if needed for internal use */
|
|
|
|
wa_wchar_to_char(path,PATH_LIMIT, wpath);
|
|
|
|
|
|
|
|
streamFile = open_winamp_streamfile_by_file(infile,path);
|
|
|
|
if (!streamFile) {
|
|
|
|
fclose(infile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return streamFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* opens vgmstream for winamp */
|
2017-08-19 10:26:21 +02:00
|
|
|
static VGMSTREAM* init_vgmstream_winamp(const in_char *fn, int stream_index) {
|
2017-08-13 19:58:28 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
|
|
|
|
//return init_vgmstream(fn);
|
|
|
|
|
|
|
|
/* manually init streamfile to pass the stream index */
|
|
|
|
STREAMFILE *streamFile = open_winamp_streamfile_by_wpath(fn); //open_stdio_streamfile(fn);
|
|
|
|
if (streamFile) {
|
2017-08-19 10:26:21 +02:00
|
|
|
streamFile->stream_index = stream_index;
|
2017-08-13 19:58:28 +02:00
|
|
|
vgmstream = init_vgmstream_from_STREAMFILE(streamFile);
|
|
|
|
close_streamfile(streamFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return vgmstream;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************* */
|
2008-03-11 03:33:52 +01:00
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
/* makes a modified filename, suitable to pass parameters around */
|
|
|
|
static void make_fn_subsong(in_char * dst, int dst_size, const in_char * filename, int stream_index) {
|
|
|
|
/* Follows "(file)(config)(ext)". Winamp needs to "see" (ext) to validate, and file goes first so relative
|
|
|
|
* files work in M3Us (path is added). Protocols a la "vgmstream://(config)(file)" work but don't get full paths. */
|
|
|
|
wa_snprintf(dst,dst_size, wa_L("%s|$s=%i|.vgmstream"), filename, stream_index);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unpacks the subsongs by adding entries to the playlist */
|
|
|
|
static int split_subsongs(const in_char * filename, int stream_index, VGMSTREAM *vgmstream) {
|
|
|
|
int i, playlist_index;
|
|
|
|
HWND hPlaylistWindow;
|
|
|
|
|
|
|
|
|
|
|
|
if (disable_subsongs || vgmstream->num_streams <= 1 || (vgmstream->num_streams > 1 && stream_index > 0))
|
|
|
|
return 0; /* no split if no subsongs or playing a subsong */
|
|
|
|
|
|
|
|
hPlaylistWindow = (HWND)SendMessage(input_module.hMainWindow, WM_WA_IPC, IPC_GETWND_PE, IPC_GETWND);
|
|
|
|
playlist_index = SendMessage(input_module.hMainWindow,WM_WA_IPC,0,IPC_GETLISTPOS);
|
|
|
|
|
|
|
|
/* 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. */
|
|
|
|
for (i = 0; i < vgmstream->num_streams; i++) {
|
|
|
|
in_char stream_fn[PATH_LIMIT];
|
|
|
|
|
|
|
|
make_fn_subsong(stream_fn,PATH_LIMIT, filename, (i+1)); /* encode index in filename */
|
|
|
|
|
|
|
|
/* insert at index */
|
|
|
|
{
|
|
|
|
COPYDATASTRUCT cds = {0};
|
|
|
|
wa_fileinfo f;
|
|
|
|
|
|
|
|
wa_strncpy(f.file, stream_fn,MAX_PATH-1);
|
|
|
|
f.file[MAX_PATH-1] = '\0';
|
|
|
|
f.index = playlist_index + (i+1);
|
|
|
|
cds.dwData = wa_IPC_PE_INSERTFILENAME;
|
|
|
|
cds.lpData = (void*)&f;
|
|
|
|
cds.cbData = sizeof(wa_fileinfo);
|
|
|
|
SendMessage(hPlaylistWindow,WM_COPYDATA,0,(LPARAM)&cds);
|
|
|
|
}
|
|
|
|
/* IPC_ENQUEUEFILE can pre-set the title without needing the Playlist handle, but can't insert at index */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remove current file from the playlist */
|
|
|
|
SendMessage(hPlaylistWindow, WM_WA_IPC, IPC_PE_DELETEINDEX, playlist_index);
|
|
|
|
|
|
|
|
/* autoplay doesn't always advance to the first unpacked track, manually fails too */
|
|
|
|
//SendMessage(input_module.hMainWindow,WM_WA_IPC,playlist_index,IPC_SETPLAYLISTPOS);
|
|
|
|
//SendMessage(input_module.hMainWindow,WM_WA_IPC,0,IPC_STARTPLAY);
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* parses a modified filename ('fakename') extracting tags parameters (NULL tag for first = filename) */
|
|
|
|
static int parse_fn_string(const in_char * fn, const in_char * tag, in_char * dst, int dst_size) {
|
|
|
|
in_char *end;
|
|
|
|
|
|
|
|
end = wa_strchr(fn,'|');
|
|
|
|
if (tag==NULL) {
|
|
|
|
wa_strcpy(dst,fn);
|
|
|
|
if (end)
|
|
|
|
dst[end - fn] = '\0';
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//todo actually find + read tags
|
|
|
|
dst[0] = '\0';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static int parse_fn_int(const in_char * fn, const in_char * tag, int * num) {
|
|
|
|
in_char * start = wa_strchr(fn,'|');
|
|
|
|
|
|
|
|
//todo actually find + read tags
|
|
|
|
if (start > 0) {
|
|
|
|
wa_sscanf(start+1, wa_L("$s=%i "), num);
|
|
|
|
return 1;
|
|
|
|
} else {
|
|
|
|
*num = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* try to detect XMPlay, which can't interact with the playlist = no splitting */
|
|
|
|
static int is_xmplay() {
|
|
|
|
if (GetModuleHandle("xmplay.exe"))
|
|
|
|
return 1;
|
|
|
|
if (GetModuleHandle("xmp-wadsp.dll"))
|
|
|
|
return 1;
|
|
|
|
if (GetModuleHandle("xmp-wma.dll"))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************************************* */
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* Winamp INI reader */
|
|
|
|
static void GetINIFileName(char * iniFile) {
|
2008-05-19 21:09:14 +02:00
|
|
|
/* if we're running on a newer winamp version that better supports
|
|
|
|
* saving of settings to a per-user directory, use that directory - if not
|
2008-05-18 22:01:37 +02:00
|
|
|
* then just revert to the old behaviour */
|
|
|
|
|
2008-05-19 21:09:14 +02:00
|
|
|
if(IsWindow(input_module.hMainWindow) && SendMessage(input_module.hMainWindow, WM_WA_IPC,0,IPC_GETVERSION) >= 0x5000) {
|
|
|
|
char * iniDir = (char *)SendMessage(input_module.hMainWindow, WM_WA_IPC, 0, IPC_GETINIDIRECTORY);
|
2017-08-13 19:58:28 +02:00
|
|
|
strncpy(iniFile, iniDir, PATH_LIMIT);
|
2008-05-18 22:01:37 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
strncat(iniFile, "\\Plugins\\", PATH_LIMIT);
|
2008-05-19 21:09:14 +02:00
|
|
|
/* can't be certain that \Plugins already exists in the user dir */
|
2008-05-20 17:18:38 +02:00
|
|
|
CreateDirectory(iniFile,NULL);
|
2017-08-13 19:58:28 +02:00
|
|
|
strncat(iniFile, CONFIG_INI_NAME, PATH_LIMIT);
|
2008-05-18 22:01:37 +02:00
|
|
|
}
|
2008-05-19 21:09:14 +02:00
|
|
|
else {
|
2008-05-20 17:18:38 +02:00
|
|
|
char * lastSlash;
|
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
GetModuleFileName(NULL, iniFile, PATH_LIMIT);
|
2008-05-20 17:18:38 +02:00
|
|
|
lastSlash = strrchr(iniFile, '\\');
|
2008-05-16 18:09:28 +02:00
|
|
|
|
|
|
|
*(lastSlash + 1) = 0;
|
2017-08-13 19:58:28 +02:00
|
|
|
strncat(iniFile, "Plugins\\" CONFIG_INI_NAME,PATH_LIMIT);
|
2017-04-28 16:15:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Adds ext to Winamp's extension list */
|
|
|
|
static void add_extension(int length, char * dst, const char * ext) {
|
|
|
|
char buf[EXT_BUFFER_SIZE];
|
|
|
|
char ext_upp[EXT_BUFFER_SIZE];
|
|
|
|
int ext_len, written;
|
|
|
|
int i,j;
|
|
|
|
if (length <= 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ext_len = strlen(ext);
|
|
|
|
|
|
|
|
/* find end of dst (double \0), saved in i */
|
|
|
|
for (i=0; i<length-2 && (dst[i] || dst[i+1]); i++)
|
|
|
|
;
|
|
|
|
|
|
|
|
/* check if end reached or not enough room to add */
|
|
|
|
if (i == length-2 || i + EXT_BUFFER_SIZE+2 > length-2 || ext_len * 3 + 20+2 > EXT_BUFFER_SIZE) {
|
|
|
|
dst[i]='\0';
|
|
|
|
dst[i+1]='\0';
|
|
|
|
return;
|
2008-05-16 18:09:28 +02:00
|
|
|
}
|
2017-04-28 16:15:32 +02:00
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
i++;
|
|
|
|
|
|
|
|
/* uppercase ext */
|
|
|
|
for (j=0; j < ext_len; j++)
|
|
|
|
ext_upp[j] = toupper(ext[j]);
|
|
|
|
ext_upp[j] = '\0';
|
|
|
|
|
|
|
|
/* copy new extension + double null terminate */
|
|
|
|
written = sprintf(buf, "%s%c%s Audio File (*.%s)%c", ext,'\0',ext_upp,ext_upp,'\0'); /*ex: "vgmstream\0vgmstream Audio File (*.VGMSTREAM)\0" */
|
|
|
|
for (j=0; j < written; i++,j++)
|
|
|
|
dst[i] = buf[j];
|
|
|
|
dst[i]='\0';
|
|
|
|
dst[i+1]='\0';
|
2008-05-16 18:09:28 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* Creates Winamp's extension list, a single string that ends with \0\0.
|
|
|
|
* Each extension must be in this format: "extension\0Description\0" */
|
|
|
|
static void build_extension_list() {
|
|
|
|
const char ** ext_list;
|
2017-11-10 20:26:44 +01:00
|
|
|
size_t ext_list_len;
|
2017-04-28 16:15:32 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
working_extension_list[0]='\0';
|
|
|
|
working_extension_list[1]='\0';
|
|
|
|
|
2017-11-10 20:26:44 +01:00
|
|
|
ext_list = vgmstream_get_formats(&ext_list_len);
|
2017-04-28 16:15:32 +02:00
|
|
|
|
|
|
|
for (i=0; i < ext_list_len; i++) {
|
|
|
|
add_extension(EXTENSION_LIST_SIZE, working_extension_list, ext_list[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-30 02:09:35 +02:00
|
|
|
/* unicode utils */
|
2017-08-19 10:26:21 +02:00
|
|
|
static void get_title(in_char * dst, int dst_size, const in_char * fn, VGMSTREAM * infostream) {
|
|
|
|
in_char *basename;
|
|
|
|
in_char buffer[PATH_LIMIT];
|
|
|
|
in_char filename[PATH_LIMIT];
|
|
|
|
int stream_index = 0;
|
|
|
|
|
|
|
|
parse_fn_string(fn, NULL, filename,PATH_LIMIT);
|
|
|
|
parse_fn_int(fn, wa_L("$s"), &stream_index);
|
|
|
|
|
|
|
|
basename = (in_char*)filename + wa_strlen(filename); /* find end */
|
|
|
|
while (*basename != '\\' && basename >= filename) /* and find last "\" */
|
|
|
|
basename--;
|
|
|
|
basename++;
|
|
|
|
wa_strcpy(dst,basename);
|
|
|
|
|
|
|
|
/* show stream subsong number */
|
|
|
|
if (stream_index > 0) {
|
|
|
|
wa_snprintf(buffer,PATH_LIMIT, wa_L("#%i"), stream_index);
|
|
|
|
wa_strcat(dst,buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* show name, but not for the base stream */
|
|
|
|
if (infostream && infostream->stream_name[0] != '\0' && stream_index > 0) {
|
|
|
|
in_char stream_name[PATH_LIMIT];
|
|
|
|
wa_char_to_wchar(stream_name, PATH_LIMIT, infostream->stream_name);
|
|
|
|
wa_snprintf(buffer,PATH_LIMIT, wa_L(" (%s)"), stream_name);
|
|
|
|
wa_strcat(dst,buffer);
|
|
|
|
}
|
2017-08-12 19:24:18 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* ***************************************** */
|
|
|
|
|
|
|
|
/* about dialog */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_About(HWND hwndParent) {
|
2017-04-28 16:15:32 +02:00
|
|
|
MessageBox(hwndParent,
|
|
|
|
PLUGIN_DESCRIPTION "\n"
|
2017-05-01 14:18:33 +02:00
|
|
|
"by hcs, FastElbja, manakoAT, bxaimc, snakemeat, soneek, kode54, bnnm and many others\n"
|
|
|
|
"\n"
|
|
|
|
"Winamp plugin by hcs, others\n"
|
|
|
|
"\n"
|
|
|
|
"https://github.com/kode54/vgmstream/\n"
|
|
|
|
"https://sourceforge.net/projects/vgmstream/ (original)"
|
2017-04-28 16:15:32 +02:00
|
|
|
,"about in_vgmstream",MB_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* called at program init */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_Init() {
|
2017-08-13 19:58:28 +02:00
|
|
|
char iniFile[PATH_LIMIT];
|
2008-05-16 18:09:28 +02:00
|
|
|
char buf[256];
|
2008-05-16 22:28:36 +02:00
|
|
|
int consumed;
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
GetINIFileName(iniFile);
|
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
thread_priority = GetPrivateProfileInt(CONFIG_APP_NAME,THREAD_PRIORITY_INI_ENTRY,DEFAULT_THREAD_PRIORITY,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
if (thread_priority < 0 || thread_priority > 6) {
|
|
|
|
sprintf(buf,"%d",DEFAULT_THREAD_PRIORITY);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,THREAD_PRIORITY_INI_ENTRY,buf,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
thread_priority = DEFAULT_THREAD_PRIORITY;
|
|
|
|
}
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
GetPrivateProfileString(CONFIG_APP_NAME,FADE_SECONDS_INI_ENTRY,DEFAULT_FADE_SECONDS,buf,sizeof(buf),iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
if (sscanf(buf,"%lf%n",&fade_seconds,&consumed)<1 || consumed!=strlen(buf) || fade_seconds < 0) {
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,FADE_SECONDS_INI_ENTRY,DEFAULT_FADE_SECONDS,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
sscanf(DEFAULT_FADE_SECONDS,"%lf",&fade_seconds);
|
|
|
|
}
|
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
GetPrivateProfileString(CONFIG_APP_NAME,FADE_DELAY_SECONDS_INI_ENTRY,DEFAULT_FADE_DELAY_SECONDS,buf,sizeof(buf),iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
if (sscanf(buf,"%lf%n",&fade_delay_seconds,&consumed)<1 || consumed!=strlen(buf)) {
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,FADE_DELAY_SECONDS_INI_ENTRY,DEFAULT_FADE_DELAY_SECONDS,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
sscanf(DEFAULT_FADE_DELAY_SECONDS,"%lf",&fade_delay_seconds);
|
|
|
|
}
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
GetPrivateProfileString(CONFIG_APP_NAME,LOOP_COUNT_INI_ENTRY,DEFAULT_LOOP_COUNT,buf,sizeof(buf),iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
if (sscanf(buf,"%lf%n",&loop_count,&consumed)!=1 || consumed!=strlen(buf) || loop_count < 0) {
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,LOOP_COUNT_INI_ENTRY,DEFAULT_LOOP_COUNT,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
sscanf(DEFAULT_LOOP_COUNT,"%lf",&loop_count);
|
|
|
|
}
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-13 19:58:28 +02:00
|
|
|
loop_forever = GetPrivateProfileInt(CONFIG_APP_NAME,LOOP_FOREVER_INI_ENTRY,DEFAULT_LOOP_FOREVER,iniFile);
|
|
|
|
ignore_loop = GetPrivateProfileInt(CONFIG_APP_NAME,IGNORE_LOOP_INI_ENTRY,DEFAULT_IGNORE_LOOP,iniFile);
|
2008-05-17 20:01:20 +02:00
|
|
|
if (loop_forever && ignore_loop) {
|
|
|
|
sprintf(buf,"%d",DEFAULT_LOOP_FOREVER);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,LOOP_FOREVER_INI_ENTRY,buf,iniFile);
|
2008-05-17 20:01:20 +02:00
|
|
|
loop_forever = DEFAULT_LOOP_FOREVER;
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2008-05-17 20:01:20 +02:00
|
|
|
sprintf(buf,"%d",DEFAULT_IGNORE_LOOP);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,IGNORE_LOOP_INI_ENTRY,buf,iniFile);
|
2008-05-17 20:01:20 +02:00
|
|
|
ignore_loop = DEFAULT_IGNORE_LOOP;
|
|
|
|
}
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-19 11:05:01 +02:00
|
|
|
disable_subsongs = GetPrivateProfileInt(CONFIG_APP_NAME,DISABLE_SUBSONGS_INI_ENTRY,DEFAULT_DISABLE_SUBSONGS,iniFile);
|
|
|
|
//if (disable_subsongs < 0) {
|
|
|
|
// sprintf(buf,"%d",DEFAULT_DISABLE_SUBSONGS);
|
|
|
|
// WritePrivateProfileString(CONFIG_APP_NAME,DISABLE_SUBSONGS_INI_ENTRY,buf,iniFile);
|
|
|
|
// disable_subsongs = DEFAULT_DISABLE_SUBSONGS;
|
|
|
|
//}
|
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
/* XMPlay with in_vgmstream doesn't support most IPC_x messages so no playlist manipulation */
|
|
|
|
if (is_xmplay()) {
|
|
|
|
disable_subsongs = 1;
|
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* dynamically make a list of supported extensions */
|
2008-03-11 03:33:52 +01:00
|
|
|
build_extension_list();
|
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* called at program quit */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_Quit() {
|
2017-04-28 16:15:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* called before extension checks, to allow detection of mms://, etc */
|
2017-08-12 19:24:18 +02:00
|
|
|
int winamp_IsOurFile(const in_char *fn) {
|
2017-04-28 16:15:32 +02:00
|
|
|
return 0; /* we don't recognize protocols */
|
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
/* request to start playing a file */
|
2017-08-12 19:24:18 +02:00
|
|
|
int winamp_Play(const in_char *fn) {
|
2008-03-10 23:58:31 +01:00
|
|
|
int max_latency;
|
2017-08-19 10:26:21 +02:00
|
|
|
in_char filename[PATH_LIMIT];
|
|
|
|
int stream_index = 0;
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
if (vgmstream)
|
|
|
|
return 1; // TODO: this should either pop up an error box or close the file
|
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
/* check for info encoded in the filename */
|
|
|
|
parse_fn_string(fn, NULL, filename,PATH_LIMIT);
|
|
|
|
parse_fn_int(fn, wa_L("$s"), &stream_index);
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* open the stream */
|
2017-08-19 10:26:21 +02:00
|
|
|
vgmstream = init_vgmstream_winamp(filename,stream_index);
|
2017-08-12 19:24:18 +02:00
|
|
|
if (!vgmstream)
|
2008-03-10 23:58:31 +01:00
|
|
|
return 1;
|
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
/* add N subsongs to the playlist, if any */
|
|
|
|
if (split_subsongs(filename, stream_index, vgmstream)) {
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
vgmstream = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* config */
|
|
|
|
if (ignore_loop)
|
|
|
|
vgmstream->loop_flag = 0;
|
|
|
|
|
|
|
|
/* save original name */
|
2017-08-13 19:58:28 +02:00
|
|
|
wa_strncpy(lastfn,fn,PATH_LIMIT);
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
/* open the output plugin */
|
2017-08-12 19:24:18 +02:00
|
|
|
max_latency = input_module.outMod->Open(vgmstream->sample_rate,vgmstream->channels, 16, 0, 0);
|
2008-03-10 23:58:31 +01:00
|
|
|
if (max_latency < 0) {
|
|
|
|
close_vgmstream(vgmstream);
|
2017-08-12 19:24:18 +02:00
|
|
|
vgmstream = NULL;
|
|
|
|
return 1;
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* set info display */ //TODO: actual bitrate
|
2015-02-09 04:08:40 +01:00
|
|
|
input_module.SetInfo(get_vgmstream_average_bitrate(vgmstream)/1000,vgmstream->sample_rate/1000,vgmstream->channels,1);
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
/* setup visualization */
|
|
|
|
input_module.SAVSAInit(max_latency,vgmstream->sample_rate);
|
|
|
|
input_module.VSASetInfo(vgmstream->sample_rate,vgmstream->channels);
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* reset internals */
|
2008-03-10 23:58:31 +01:00
|
|
|
decode_abort = 0;
|
2008-05-16 22:57:19 +02:00
|
|
|
seek_needed_samples = -1;
|
2008-03-10 23:58:31 +01:00
|
|
|
decode_pos_ms = 0;
|
|
|
|
decode_pos_samples = 0;
|
|
|
|
paused = 0;
|
2008-05-16 22:28:36 +02:00
|
|
|
stream_length_samples = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,vgmstream);
|
2008-05-11 20:11:55 +02:00
|
|
|
fade_samples = (int)(fade_seconds * vgmstream->sample_rate);
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* start */
|
2008-03-10 23:58:31 +01:00
|
|
|
decode_thread_handle = CreateThread(
|
|
|
|
NULL, /* handle cannot be inherited */
|
|
|
|
0, /* stack size, 0=default */
|
|
|
|
decode, /* thread start routine */
|
|
|
|
NULL, /* no parameter to start routine */
|
|
|
|
0, /* run thread immediately */
|
|
|
|
NULL); /* don't keep track of the thread id */
|
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
SetThreadPriority(decode_thread_handle,priority_values[thread_priority]);
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
return 0; /* success */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pause stream */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_Pause() {
|
|
|
|
paused = 1;
|
2017-04-28 16:15:32 +02:00
|
|
|
input_module.outMod->Pause(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unpause stream */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_UnPause() {
|
|
|
|
paused = 0;
|
2017-04-28 16:15:32 +02:00
|
|
|
input_module.outMod->Pause(0);
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* return 1 if paused, 0 if not */
|
|
|
|
int winamp_IsPaused() {
|
2017-04-28 16:15:32 +02:00
|
|
|
return paused;
|
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* stop (unload) stream */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_Stop() {
|
2008-03-10 23:58:31 +01:00
|
|
|
if (decode_thread_handle != INVALID_HANDLE_VALUE) {
|
2017-08-12 19:24:18 +02:00
|
|
|
decode_abort = 1;
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
/* arbitrary wait length */
|
|
|
|
if (WaitForSingleObject(decode_thread_handle,1000) == WAIT_TIMEOUT) {
|
2017-08-12 19:24:18 +02:00
|
|
|
TerminateThread(decode_thread_handle,0); // TODO: error?
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
CloseHandle(decode_thread_handle);
|
|
|
|
decode_thread_handle = INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
vgmstream = NULL;
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
input_module.outMod->Close();
|
|
|
|
input_module.SAVSADeInit();
|
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* get length in ms */
|
2017-08-12 19:24:18 +02:00
|
|
|
int winamp_GetLength() {
|
|
|
|
return stream_length_samples * 1000LL / vgmstream->sample_rate;
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* current output time in ms */
|
2017-08-12 19:24:18 +02:00
|
|
|
int winamp_GetOutputTime() {
|
|
|
|
return decode_pos_ms + (input_module.outMod->GetOutputTime()-input_module.outMod->GetWrittenTime());
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* seeks to point in stream (in ms) */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_SetOutputTime(int time_in_ms) {
|
2017-09-17 03:37:18 +02:00
|
|
|
if (!vgmstream)
|
|
|
|
return;
|
|
|
|
|
|
|
|
seek_needed_samples = (long long)time_in_ms * vgmstream->sample_rate / 1000LL;
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* pass these commands through */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_SetVolume(int volume) {
|
2017-04-28 16:15:32 +02:00
|
|
|
input_module.outMod->SetVolume(volume);
|
|
|
|
}
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_SetPan(int pan) {
|
2017-04-28 16:15:32 +02:00
|
|
|
input_module.outMod->SetPan(pan);
|
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* display info box (ALT+3) */
|
|
|
|
int winamp_InfoBox(const in_char *fn, HWND hwnd) {
|
2017-04-30 02:09:35 +02:00
|
|
|
char description[1024] = {0};
|
2008-03-11 03:33:52 +01:00
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
concatn(sizeof(description),description,PLUGIN_DESCRIPTION "\n\n");
|
2008-05-15 15:55:08 +02:00
|
|
|
|
2008-03-11 02:27:59 +01:00
|
|
|
if (!fn || !*fn) {
|
2017-08-12 19:24:18 +02:00
|
|
|
/* no filename = current playing file */
|
|
|
|
if (!vgmstream)
|
|
|
|
return 0;
|
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
describe_vgmstream(vgmstream,description,sizeof(description));
|
2017-08-12 19:24:18 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* some other file in playlist given by filename */
|
|
|
|
VGMSTREAM * infostream = NULL;
|
2017-08-19 10:26:21 +02:00
|
|
|
in_char filename[PATH_LIMIT];
|
|
|
|
int stream_index = 0;
|
|
|
|
|
|
|
|
/* check for info encoded in the filename */
|
|
|
|
parse_fn_string(fn, NULL, filename,PATH_LIMIT);
|
|
|
|
parse_fn_int(fn, wa_L("$s"), &stream_index);
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
infostream = init_vgmstream_winamp(filename, stream_index);
|
2017-08-12 19:24:18 +02:00
|
|
|
if (!infostream)
|
|
|
|
return 0;
|
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
describe_vgmstream(infostream,description,sizeof(description));
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2008-03-11 02:27:59 +01:00
|
|
|
close_vgmstream(infostream);
|
2017-08-12 19:24:18 +02:00
|
|
|
infostream = NULL;
|
2008-03-11 02:27:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageBox(hwnd,description,"Stream info",MB_OK);
|
2008-03-10 23:58:31 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* retrieve title (playlist name) and time on the current or other file in the playlist */
|
|
|
|
void winamp_GetFileInfo(const in_char *fn, in_char *title, int *length_in_ms) {
|
|
|
|
|
|
|
|
if (!fn || !*fn) {
|
|
|
|
/* no filename = current playing file */
|
2017-04-30 02:09:35 +02:00
|
|
|
|
|
|
|
if (!vgmstream)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (title) {
|
2017-08-19 10:26:21 +02:00
|
|
|
get_title(title,GETFILEINFO_TITLE_LENGTH, lastfn, vgmstream);
|
2008-03-11 00:50:13 +01:00
|
|
|
}
|
2017-04-30 02:09:35 +02:00
|
|
|
|
|
|
|
if (length_in_ms) {
|
2017-08-12 19:24:18 +02:00
|
|
|
*length_in_ms = winamp_GetLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* some other file in playlist given by filename */
|
|
|
|
VGMSTREAM * infostream = NULL;
|
2017-08-19 10:26:21 +02:00
|
|
|
in_char filename[PATH_LIMIT];
|
|
|
|
int stream_index = 0;
|
|
|
|
|
|
|
|
/* check for info encoded in the filename */
|
|
|
|
parse_fn_string(fn, NULL, filename,PATH_LIMIT);
|
|
|
|
parse_fn_int(fn, wa_L("$s"), &stream_index);
|
2017-04-30 02:09:35 +02:00
|
|
|
|
2017-08-19 10:26:21 +02:00
|
|
|
infostream = init_vgmstream_winamp(filename, stream_index);
|
|
|
|
if (!infostream) return;
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
if (title) {
|
2017-08-19 10:26:21 +02:00
|
|
|
get_title(title,GETFILEINFO_TITLE_LENGTH, fn, infostream);
|
2008-03-11 00:50:13 +01:00
|
|
|
}
|
2017-04-30 02:09:35 +02:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
if (length_in_ms) {
|
|
|
|
*length_in_ms = -1000;
|
|
|
|
if (infostream) {
|
|
|
|
int num_samples = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,infostream);
|
|
|
|
*length_in_ms = num_samples * 1000LL /infostream->sample_rate;
|
|
|
|
}
|
2008-05-16 20:24:47 +02:00
|
|
|
}
|
2017-08-12 19:24:18 +02:00
|
|
|
|
|
|
|
close_vgmstream(infostream);
|
|
|
|
infostream = NULL;
|
2008-03-11 00:50:13 +01:00
|
|
|
}
|
2008-05-16 20:24:47 +02:00
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* eq stuff */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_EQSet(int on, char data[10], int preamp) {
|
2017-04-28 16:15:32 +02:00
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
/* the decode thread */
|
|
|
|
DWORD WINAPI __stdcall decode(void *arg) {
|
2008-06-12 02:06:35 +02:00
|
|
|
/* channel count shouldn't change during decode */
|
|
|
|
int max_buffer_samples = sizeof(sample_buffer)/sizeof(sample_buffer[0])/2/vgmstream->channels;
|
2017-09-17 03:37:18 +02:00
|
|
|
int max_samples = get_vgmstream_play_samples(loop_count,fade_seconds,fade_delay_seconds,vgmstream);
|
2008-06-12 02:06:35 +02:00
|
|
|
|
2008-03-10 23:58:31 +01:00
|
|
|
while (!decode_abort) {
|
|
|
|
int samples_to_do;
|
|
|
|
int l;
|
2008-05-16 22:57:19 +02:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
if (decode_pos_samples + max_buffer_samples > stream_length_samples
|
|
|
|
&& (!loop_forever || !vgmstream->loop_flag))
|
|
|
|
samples_to_do = stream_length_samples - decode_pos_samples;
|
2008-03-10 23:58:31 +01:00
|
|
|
else
|
2017-08-12 19:24:18 +02:00
|
|
|
samples_to_do = max_buffer_samples;
|
2008-03-10 23:58:31 +01:00
|
|
|
|
2008-05-16 22:57:19 +02:00
|
|
|
/* play 'till the end of this seek, or note if we're done seeking */
|
|
|
|
if (seek_needed_samples != -1) {
|
|
|
|
/* reset if we need to seek backwards */
|
|
|
|
if (seek_needed_samples < decode_pos_samples) {
|
2008-05-19 05:58:15 +02:00
|
|
|
reset_vgmstream(vgmstream);
|
2008-05-16 22:57:19 +02:00
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
if (ignore_loop)
|
|
|
|
vgmstream->loop_flag = 0;
|
2008-05-19 19:20:35 +02:00
|
|
|
|
2008-05-16 22:57:19 +02:00
|
|
|
decode_pos_samples = 0;
|
|
|
|
decode_pos_ms = 0;
|
|
|
|
}
|
2008-05-19 05:58:15 +02:00
|
|
|
|
2017-09-17 03:37:18 +02:00
|
|
|
/* adjust seeking past file, can happen using the right (->) key
|
|
|
|
* (should be done here and not in SetOutputTime due to threads/race condicions) */
|
|
|
|
if (seek_needed_samples > max_samples) {
|
|
|
|
seek_needed_samples = max_samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* adjust max samples to seek */
|
2008-05-16 22:57:19 +02:00
|
|
|
if (decode_pos_samples < seek_needed_samples) {
|
2017-09-17 03:37:18 +02:00
|
|
|
samples_to_do = seek_needed_samples - decode_pos_samples;
|
2017-08-12 19:24:18 +02:00
|
|
|
if (samples_to_do > max_buffer_samples)
|
|
|
|
samples_to_do = max_buffer_samples;
|
2017-09-17 03:37:18 +02:00
|
|
|
}
|
|
|
|
else {
|
2008-05-16 22:57:19 +02:00
|
|
|
seek_needed_samples = -1;
|
2017-09-17 03:37:18 +02:00
|
|
|
}
|
2008-05-19 05:58:15 +02:00
|
|
|
|
|
|
|
input_module.outMod->Flush((int)decode_pos_ms);
|
2008-05-16 22:57:19 +02:00
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
l = (samples_to_do*vgmstream->channels*2) << (input_module.dsp_isactive()?1:0);
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
if (samples_to_do == 0) {
|
|
|
|
input_module.outMod->CanWrite(); /* ? */
|
|
|
|
if (!input_module.outMod->IsPlaying()) {
|
2017-08-12 19:24:18 +02:00
|
|
|
PostMessage(input_module.hMainWindow, WM_WA_MPEG_EOF, 0,0); /* end */
|
2008-03-10 23:58:31 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Sleep(10);
|
|
|
|
}
|
2008-05-16 22:57:19 +02:00
|
|
|
else if (seek_needed_samples != -1) {
|
|
|
|
render_vgmstream(sample_buffer,samples_to_do,vgmstream);
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
decode_pos_samples += samples_to_do;
|
|
|
|
decode_pos_ms = decode_pos_samples * 1000LL / vgmstream->sample_rate;
|
2008-05-16 22:57:19 +02:00
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
else if (input_module.outMod->CanWrite() >= l) {
|
|
|
|
/* let vgmstream do its thing */
|
|
|
|
render_vgmstream(sample_buffer,samples_to_do,vgmstream);
|
|
|
|
|
|
|
|
/* fade! */
|
2008-05-16 18:09:28 +02:00
|
|
|
if (vgmstream->loop_flag && fade_samples > 0 && !loop_forever) {
|
2008-03-10 23:58:31 +01:00
|
|
|
int samples_into_fade = decode_pos_samples - (stream_length_samples - fade_samples);
|
|
|
|
if (samples_into_fade + samples_to_do > 0) {
|
|
|
|
int j,k;
|
2017-08-12 19:24:18 +02:00
|
|
|
for (j=0; j < samples_to_do; j++, samples_into_fade++) {
|
2008-03-10 23:58:31 +01:00
|
|
|
if (samples_into_fade > 0) {
|
|
|
|
double fadedness = (double)(fade_samples-samples_into_fade)/fade_samples;
|
2017-08-12 19:24:18 +02:00
|
|
|
for (k=0; k < vgmstream->channels; k++) {
|
2008-03-10 23:58:31 +01:00
|
|
|
sample_buffer[j*vgmstream->channels+k] =
|
2008-05-11 20:11:55 +02:00
|
|
|
(short)(sample_buffer[j*vgmstream->channels+k]*fadedness);
|
2008-03-10 23:58:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
input_module.SAAddPCMData((char*)sample_buffer,vgmstream->channels,16,decode_pos_ms);
|
|
|
|
input_module.VSAAddPCMData((char*)sample_buffer,vgmstream->channels,16,decode_pos_ms);
|
2017-08-12 19:24:18 +02:00
|
|
|
decode_pos_samples += samples_to_do;
|
|
|
|
decode_pos_ms = decode_pos_samples*1000LL/vgmstream->sample_rate;
|
2008-03-10 23:58:31 +01:00
|
|
|
if (input_module.dsp_isactive())
|
2017-08-12 19:24:18 +02:00
|
|
|
l = input_module.dsp_dosamples(sample_buffer,samples_to_do,16,vgmstream->channels,vgmstream->sample_rate) * 2 * vgmstream->channels;
|
2008-03-10 23:58:31 +01:00
|
|
|
|
|
|
|
input_module.outMod->Write((char*)sample_buffer,l);
|
|
|
|
} /* if we can write enough */
|
2017-08-12 19:24:18 +02:00
|
|
|
else {
|
|
|
|
Sleep(20);
|
|
|
|
}
|
2008-03-10 23:58:31 +01:00
|
|
|
} /* main loop */
|
2017-08-12 19:24:18 +02:00
|
|
|
|
2008-03-10 23:58:31 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-08-12 19:24:18 +02:00
|
|
|
/* config dialog handler */
|
2008-05-17 20:54:32 +02:00
|
|
|
INT_PTR CALLBACK configDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
2008-05-16 18:09:28 +02:00
|
|
|
char buf[256];
|
2017-08-13 19:58:28 +02:00
|
|
|
char iniFile[PATH_LIMIT];
|
2008-05-16 18:09:28 +02:00
|
|
|
static int mypri;
|
|
|
|
HANDLE hSlider;
|
|
|
|
|
|
|
|
switch (uMsg) {
|
2008-05-16 20:24:47 +02:00
|
|
|
case WM_CLOSE:
|
|
|
|
EndDialog(hDlg,TRUE);
|
2008-05-17 20:54:32 +02:00
|
|
|
return TRUE;
|
2008-05-16 20:24:47 +02:00
|
|
|
case WM_INITDIALOG:
|
2008-05-16 18:09:28 +02:00
|
|
|
GetINIFileName(iniFile);
|
|
|
|
|
2008-05-16 20:24:47 +02:00
|
|
|
/* set CPU Priority slider */
|
|
|
|
hSlider=GetDlgItem(hDlg,IDC_THREAD_PRIORITY_SLIDER);
|
|
|
|
SendMessage(hSlider, TBM_SETRANGE,
|
|
|
|
(WPARAM) TRUE, /* redraw flag */
|
|
|
|
(LPARAM) MAKELONG(1, 7)); /* min. & max. positions */
|
|
|
|
SendMessage(hSlider, TBM_SETPOS,
|
|
|
|
(WPARAM) TRUE, /* redraw flag */
|
|
|
|
(LPARAM) thread_priority+1);
|
|
|
|
mypri=thread_priority;
|
|
|
|
SetDlgItemText(hDlg,IDC_THREAD_PRIORITY_TEXT,priority_strings[thread_priority]);
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
sprintf(buf,"%.2lf",fade_seconds);
|
2008-05-16 20:24:47 +02:00
|
|
|
SetDlgItemText(hDlg,IDC_FADE_SECONDS,buf);
|
2008-05-16 22:28:36 +02:00
|
|
|
sprintf(buf,"%.2lf",fade_delay_seconds);
|
|
|
|
SetDlgItemText(hDlg,IDC_FADE_DELAY_SECONDS,buf);
|
|
|
|
sprintf(buf,"%.2lf",loop_count);
|
2008-05-16 20:24:47 +02:00
|
|
|
SetDlgItemText(hDlg,IDC_LOOP_COUNT,buf);
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2008-05-17 20:01:20 +02:00
|
|
|
if (loop_forever)
|
|
|
|
CheckDlgButton(hDlg,IDC_LOOP_FOREVER,BST_CHECKED);
|
|
|
|
else if (ignore_loop)
|
|
|
|
CheckDlgButton(hDlg,IDC_IGNORE_LOOP,BST_CHECKED);
|
|
|
|
else
|
|
|
|
CheckDlgButton(hDlg,IDC_LOOP_NORMALLY,BST_CHECKED);
|
2008-05-16 18:09:28 +02:00
|
|
|
|
2017-08-19 11:05:01 +02:00
|
|
|
if (disable_subsongs)
|
|
|
|
CheckDlgButton(hDlg,IDC_DISABLE_SUBSONGS,BST_CHECKED);
|
|
|
|
|
2008-05-16 18:09:28 +02:00
|
|
|
break;
|
2008-05-16 20:24:47 +02:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
|
|
|
|
case IDOK:
|
|
|
|
{
|
2008-05-16 22:28:36 +02:00
|
|
|
double temp_fade_seconds;
|
|
|
|
double temp_fade_delay_seconds;
|
|
|
|
double temp_loop_count;
|
|
|
|
int consumed;
|
|
|
|
|
|
|
|
/* read and verify */
|
|
|
|
GetDlgItemText(hDlg,IDC_FADE_SECONDS,buf,sizeof(buf));
|
|
|
|
if (sscanf(buf,"%lf%n",&temp_fade_seconds,&consumed)<1
|
|
|
|
|| consumed!=strlen(buf) ||
|
|
|
|
temp_fade_seconds<0) {
|
|
|
|
MessageBox(hDlg,
|
|
|
|
"Invalid value for Fade Length\n"
|
|
|
|
"Must be a number greater than or equal to zero",
|
|
|
|
"Error",MB_OK|MB_ICONERROR);
|
|
|
|
break;
|
|
|
|
}
|
2008-05-16 20:24:47 +02:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
GetDlgItemText(hDlg,IDC_FADE_DELAY_SECONDS,buf,sizeof(buf));
|
|
|
|
if (sscanf(buf,"%lf%n",&temp_fade_delay_seconds,
|
|
|
|
&consumed)<1 || consumed!=strlen(buf)) {
|
|
|
|
MessageBox(hDlg,
|
|
|
|
"Invalid valid for Fade Delay\n"
|
|
|
|
"Must be a number",
|
|
|
|
"Error",MB_OK|MB_ICONERROR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetDlgItemText(hDlg,IDC_LOOP_COUNT,buf,sizeof(buf));
|
|
|
|
if (sscanf(buf,"%lf%n",&temp_loop_count,&consumed)<1 ||
|
|
|
|
consumed!=strlen(buf) ||
|
|
|
|
temp_loop_count<0) {
|
|
|
|
MessageBox(hDlg,
|
|
|
|
"Invalid value for Loop Count\n"
|
|
|
|
"Must be a number greater than or equal to zero",
|
|
|
|
"Error",MB_OK|MB_ICONERROR);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
GetINIFileName(iniFile);
|
2008-05-16 20:24:47 +02:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
thread_priority=mypri;
|
|
|
|
sprintf(buf,"%d",thread_priority);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,THREAD_PRIORITY_INI_ENTRY,buf,iniFile);
|
2008-05-16 20:24:47 +02:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
fade_seconds = temp_fade_seconds;
|
|
|
|
sprintf(buf,"%.2lf",fade_seconds);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,FADE_SECONDS_INI_ENTRY,buf,iniFile);
|
2008-05-16 20:24:47 +02:00
|
|
|
|
2008-05-16 22:28:36 +02:00
|
|
|
fade_delay_seconds = temp_fade_delay_seconds;
|
|
|
|
sprintf(buf,"%.2lf",fade_delay_seconds);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,FADE_DELAY_SECONDS_INI_ENTRY,buf,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
|
|
|
|
loop_count = temp_loop_count;
|
|
|
|
sprintf(buf,"%.2lf",loop_count);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,LOOP_COUNT_INI_ENTRY,buf,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
|
|
|
|
loop_forever = (IsDlgButtonChecked(hDlg,IDC_LOOP_FOREVER) == BST_CHECKED);
|
|
|
|
sprintf(buf,"%d",loop_forever);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,LOOP_FOREVER_INI_ENTRY,buf,iniFile);
|
2008-05-17 20:01:20 +02:00
|
|
|
|
|
|
|
ignore_loop = (IsDlgButtonChecked(hDlg,IDC_IGNORE_LOOP) == BST_CHECKED);
|
|
|
|
sprintf(buf,"%d",ignore_loop);
|
2017-08-13 19:58:28 +02:00
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,IGNORE_LOOP_INI_ENTRY,buf,iniFile);
|
2017-08-19 11:05:01 +02:00
|
|
|
|
|
|
|
disable_subsongs = (IsDlgButtonChecked(hDlg,IDC_DISABLE_SUBSONGS) == BST_CHECKED);
|
|
|
|
sprintf(buf,"%d",disable_subsongs);
|
|
|
|
WritePrivateProfileString(CONFIG_APP_NAME,DISABLE_SUBSONGS_INI_ENTRY,buf,iniFile);
|
2008-05-16 22:28:36 +02:00
|
|
|
}
|
2008-05-16 20:24:47 +02:00
|
|
|
|
|
|
|
EndDialog(hDlg,TRUE);
|
|
|
|
break;
|
|
|
|
case IDCANCEL:
|
|
|
|
EndDialog(hDlg,TRUE);
|
|
|
|
break;
|
2008-05-17 20:01:20 +02:00
|
|
|
case IDC_DEFAULT_BUTTON:
|
2008-05-16 22:28:36 +02:00
|
|
|
/* set CPU Priority slider */
|
|
|
|
hSlider=GetDlgItem(hDlg,IDC_THREAD_PRIORITY_SLIDER);
|
|
|
|
SendMessage(hSlider, TBM_SETRANGE,
|
|
|
|
(WPARAM) TRUE, /* redraw flag */
|
|
|
|
(LPARAM) MAKELONG(1, 7)); /* min. & max. positions */
|
|
|
|
SendMessage(hSlider, TBM_SETPOS,
|
|
|
|
(WPARAM) TRUE, /* redraw flag */
|
|
|
|
(LPARAM) DEFAULT_THREAD_PRIORITY+1);
|
|
|
|
mypri=DEFAULT_THREAD_PRIORITY;
|
|
|
|
SetDlgItemText(hDlg,IDC_THREAD_PRIORITY_TEXT,priority_strings[mypri]);
|
|
|
|
|
|
|
|
SetDlgItemText(hDlg,IDC_FADE_SECONDS,DEFAULT_FADE_SECONDS);
|
|
|
|
SetDlgItemText(hDlg,IDC_FADE_DELAY_SECONDS,DEFAULT_FADE_DELAY_SECONDS);
|
|
|
|
SetDlgItemText(hDlg,IDC_LOOP_COUNT,DEFAULT_LOOP_COUNT);
|
|
|
|
|
2009-04-06 09:59:43 +02:00
|
|
|
CheckDlgButton(hDlg,IDC_LOOP_FOREVER,BST_UNCHECKED);
|
|
|
|
CheckDlgButton(hDlg,IDC_IGNORE_LOOP,BST_UNCHECKED);
|
2008-05-17 20:01:20 +02:00
|
|
|
CheckDlgButton(hDlg,IDC_LOOP_NORMALLY,BST_CHECKED);
|
2017-08-19 11:05:01 +02:00
|
|
|
|
|
|
|
CheckDlgButton(hDlg,IDC_DISABLE_SUBSONGS,BST_UNCHECKED);
|
2009-04-06 09:59:43 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
2008-05-16 20:24:47 +02:00
|
|
|
}
|
|
|
|
case WM_HSCROLL:
|
|
|
|
if ((struct HWND__ *)lParam==GetDlgItem(hDlg,IDC_THREAD_PRIORITY_SLIDER)) {
|
|
|
|
if (LOWORD(wParam)==TB_THUMBPOSITION || LOWORD(wParam)==TB_THUMBTRACK) mypri=HIWORD(wParam)-1;
|
|
|
|
else mypri=SendMessage(GetDlgItem(hDlg,IDC_THREAD_PRIORITY_SLIDER),TBM_GETPOS,0,0)-1;
|
|
|
|
SetDlgItemText(hDlg,IDC_THREAD_PRIORITY_TEXT,priority_strings[mypri]);
|
|
|
|
}
|
2008-05-16 18:09:28 +02:00
|
|
|
break;
|
2008-05-16 20:24:47 +02:00
|
|
|
default:
|
2008-05-17 20:54:32 +02:00
|
|
|
return FALSE;
|
2008-05-16 18:09:28 +02:00
|
|
|
}
|
|
|
|
|
2008-05-17 20:54:32 +02:00
|
|
|
return TRUE;
|
2008-05-16 18:09:28 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* configuration dialog */
|
2017-08-12 19:24:18 +02:00
|
|
|
void winamp_Config(HWND hwndParent) {
|
2017-04-28 16:15:32 +02:00
|
|
|
/* defined in resource.rc */
|
2008-05-16 18:09:28 +02:00
|
|
|
DialogBox(input_module.hDllInstance, (const char *)IDD_CONFIG, hwndParent, configDlgProc);
|
|
|
|
}
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
/* *********************************** */
|
|
|
|
|
|
|
|
/* main plugin def */
|
|
|
|
In_Module input_module = {
|
2008-03-10 23:58:31 +01:00
|
|
|
IN_VER,
|
|
|
|
PLUGIN_DESCRIPTION,
|
2017-08-12 19:24:18 +02:00
|
|
|
0, /* hMainWindow (filled in by Winamp) */
|
|
|
|
0, /* hDllInstance (filled in by Winamp) */
|
2008-03-11 03:33:52 +01:00
|
|
|
working_extension_list,
|
2017-08-12 19:24:18 +02:00
|
|
|
1, /* is_seekable flag */
|
|
|
|
1, /* UsesOutputPlug flag */
|
|
|
|
winamp_Config,
|
|
|
|
winamp_About,
|
|
|
|
winamp_Init,
|
|
|
|
winamp_Quit,
|
|
|
|
winamp_GetFileInfo,
|
|
|
|
winamp_InfoBox,
|
|
|
|
winamp_IsOurFile,
|
|
|
|
winamp_Play,
|
|
|
|
winamp_Pause,
|
|
|
|
winamp_UnPause,
|
|
|
|
winamp_IsPaused,
|
|
|
|
winamp_Stop,
|
|
|
|
winamp_GetLength,
|
|
|
|
winamp_GetOutputTime,
|
|
|
|
winamp_SetOutputTime,
|
|
|
|
winamp_SetVolume,
|
|
|
|
winamp_SetPan,
|
|
|
|
0,0,0,0,0,0,0,0,0, /* vis stuff */
|
|
|
|
0,0, /* dsp stuff */
|
|
|
|
winamp_EQSet,
|
|
|
|
NULL, /* SetInfo */
|
|
|
|
0 /* outMod */
|
2008-03-10 23:58:31 +01:00
|
|
|
};
|
|
|
|
|
2017-04-28 16:15:32 +02:00
|
|
|
__declspec( dllexport ) In_Module * winampGetInModule2() {
|
2008-03-10 23:58:31 +01:00
|
|
|
return &input_module;
|
|
|
|
}
|