mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@712 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
9fb2c73d4b
commit
342303d6d9
155
xmp-vgmstream/DllMain.c
Normal file
155
xmp-vgmstream/DllMain.c
Normal file
@ -0,0 +1,155 @@
|
||||
/*
|
||||
** vgmstream for XMPlay
|
||||
**
|
||||
** 11/11/2009 - started. this is hilariously buggy and doesnt support much yet. [unknownfile]
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
#include <io.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "../src/vgmstream.h"
|
||||
#include "../src/util.h"
|
||||
#include "xmp_in.h"
|
||||
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION
|
||||
#endif
|
||||
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
double timestamp=0;
|
||||
|
||||
#define DECODE_SIZE 1024
|
||||
#define APP_NAME "vgmstream plugin"
|
||||
#define PLUGIN_DESCRIPTION "vgmstream plugin " VERSION " " __DATE__
|
||||
|
||||
void __stdcall XMPAbout() {
|
||||
MessageBox(NULL,
|
||||
PLUGIN_DESCRIPTION "\n"
|
||||
"by hcs, FastElbja, manakoAT, and bxaimc\n\n"
|
||||
"http://sourceforge.net/projects/vgmstream"
|
||||
,"about in_vgmstream",MB_OK);
|
||||
}
|
||||
|
||||
void __stdcall Stop() {
|
||||
close_vgmstream(vgmstream);
|
||||
}
|
||||
|
||||
int __stdcall XMP_CheckFile(char *filename, BYTE *buf, DWORD length) {
|
||||
VGMSTREAM* fakevgmstream = init_vgmstream(filename);
|
||||
int ret;
|
||||
|
||||
if (!fakevgmstream) ret = 0;
|
||||
else { ret = 1; close_vgmstream(fakevgmstream); }
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __stdcall LoadVgmStream(char *filename, XMPFILE file) {
|
||||
vgmstream = init_vgmstream(filename);
|
||||
|
||||
if (!vgmstream) return 0;
|
||||
// just loop forever till we have configuration done
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __stdcall XMP_Buffer(float* buffer, UINT32 bufsize) {
|
||||
int i;
|
||||
|
||||
// Quick way of converting to float
|
||||
for (i=0;i<bufsize;i+=vgmstream->channels) {
|
||||
INT16 buf[16];
|
||||
render_vgmstream(buf,vgmstream->channels,vgmstream);
|
||||
*(buffer + i) = buf[0];
|
||||
if (vgmstream->channels == 2) *(buffer + i + 1) = buf[1];
|
||||
}
|
||||
|
||||
return bufsize;
|
||||
}
|
||||
|
||||
DWORD __stdcall XMP_GetFormat(DWORD *chan, DWORD *res) {
|
||||
*(chan) = vgmstream->channels;
|
||||
return vgmstream->sample_rate / 2;
|
||||
}
|
||||
|
||||
void __stdcall FormatPlayWindowText(char* txt) {
|
||||
strcpy(txt,"vgmstream!");
|
||||
}
|
||||
|
||||
void __stdcall GetAdditionalFields(char* blerp) {
|
||||
strcpy(blerp,"oh god how did this get here i am not good with computers\n");
|
||||
}
|
||||
|
||||
|
||||
double __stdcall GetDecodePosition() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
// Trap functions to catch stuff we haven't implemented.
|
||||
#define TRAP_FCN(id) void* __stdcall trap_##id() {\
|
||||
cprintf("trap %d hit\n",id);\
|
||||
return NULL;\
|
||||
}
|
||||
TRAP_FCN(1);
|
||||
TRAP_FCN(2);
|
||||
TRAP_FCN(3);
|
||||
TRAP_FCN(4);
|
||||
TRAP_FCN(5);
|
||||
TRAP_FCN(6);
|
||||
TRAP_FCN(7);
|
||||
TRAP_FCN(8);
|
||||
TRAP_FCN(9);
|
||||
TRAP_FCN(10);
|
||||
TRAP_FCN(11);
|
||||
TRAP_FCN(12);
|
||||
TRAP_FCN(13);
|
||||
TRAP_FCN(14);
|
||||
TRAP_FCN(15);
|
||||
TRAP_FCN(16);
|
||||
TRAP_FCN(17);
|
||||
TRAP_FCN(18);
|
||||
TRAP_FCN(19);
|
||||
TRAP_FCN(20);
|
||||
TRAP_FCN(21);
|
||||
TRAP_FCN(22);
|
||||
|
||||
int __stdcall Call22() {
|
||||
return 1; //
|
||||
}
|
||||
|
||||
XMPIN vgmstream_intf = {
|
||||
0,
|
||||
"vgmstream for XMplay",
|
||||
"vgmstream files\0brstm",
|
||||
XMPAbout,
|
||||
NULL,
|
||||
XMP_CheckFile,
|
||||
NULL,
|
||||
LoadVgmStream,
|
||||
Stop,
|
||||
XMP_GetFormat,
|
||||
NULL,
|
||||
NULL,
|
||||
FormatPlayWindowText,
|
||||
GetAdditionalFields,
|
||||
NULL,
|
||||
NULL,
|
||||
GetDecodePosition,
|
||||
NULL,//trap_18,
|
||||
XMP_Buffer,
|
||||
NULL,
|
||||
NULL,
|
||||
Call22,
|
||||
};
|
||||
|
||||
|
||||
__declspec(dllexport) XMPIN* XMPIN_GetInterface(UINT32 version, void* ifproc) {
|
||||
AllocConsole();
|
||||
if (version != 1) return NULL;
|
||||
return &vgmstream_intf;
|
||||
}
|
172
xmp-vgmstream/xmp-vgmstream.vcproj
Normal file
172
xmp-vgmstream/xmp-vgmstream.vcproj
Normal file
@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="xmp-vgmstream"
|
||||
ProjectGUID="{49AF76F7-CBA0-4486-9DDF-51F30DF45F33}"
|
||||
RootNamespace="xmpvgmstream"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../ext_includes"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="../ext_libs/libvorbis.lib ../ext_libs/libmpg123-0.lib"
|
||||
GenerateDebugInformation="true"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
GenerateDebugInformation="true"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\DllMain.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\xmp_in.h"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
110
xmp-vgmstream/xmp_in.h
Normal file
110
xmp-vgmstream/xmp_in.h
Normal file
@ -0,0 +1,110 @@
|
||||
// XMPlay input plugin header (c) 2004-2005 Ian Luck
|
||||
// new plugins can be submitted to plugins@xmplay.com
|
||||
|
||||
#include <wtypes.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XMPIN_FACE
|
||||
#define XMPIN_FACE 1 // "face"
|
||||
#endif
|
||||
|
||||
typedef void *XMPFILE;
|
||||
|
||||
#define XMPIN_FLAG_CANSTREAM 1 // can stream files (play while downloading from the 'net)
|
||||
#define XMPIN_FLAG_OWNFILE 2 // can process files without "XMPFILE" routines
|
||||
#define XMPIN_FLAG_NOXMPFILE 4 // never use "XMPFILE" routines (implies XMPIN_FLAG_OWNFILE)
|
||||
|
||||
// Note all texts are UTF-8 on WinNT based systems, and ANSI on Win9x
|
||||
#define Utf2Uni(src,slen,dst,dlen) MultiByteToWideChar(CP_UTF8,0,src,slen,dst,dlen) // convert UTF-8 to Unicode
|
||||
|
||||
typedef struct {
|
||||
DWORD flags; // XMPIN_FLAG_xxx
|
||||
char *name; // plugin name
|
||||
char *exts; // supported file extensions (description\0ext1/ext2/etc...)
|
||||
|
||||
void (WINAPI *About)(HWND win); // (OPTIONAL)
|
||||
void (WINAPI *Config)(HWND win); // present config options to user (OPTIONAL)
|
||||
BOOL (WINAPI *CheckFile)(char *filename, BYTE *buf, DWORD length); // verify file
|
||||
BOOL (WINAPI *GetFileInfo)(char *filename, XMPFILE file, float *length, char *tags[7]); // get track info
|
||||
//tags: 0=title,1=artist,2=album,3=year,4=track,5=genre,6=comment
|
||||
|
||||
// playback stuff
|
||||
DWORD (WINAPI *Open)(char *filename, XMPFILE file); // open a file
|
||||
void (WINAPI *Close)(); // close file
|
||||
DWORD (WINAPI *GetFormat)(DWORD *chan, DWORD *res); // return sample rate (OPTIONAL: mutually exclusive with SetFormat)
|
||||
void (WINAPI *SetFormat)(DWORD rate, DWORD chan); // (OPTIONAL: mutually exclusive with GetFormat)
|
||||
BOOL (WINAPI *GetTags)(char *tags[7]); // get title elements, return TRUE to delay (OPTIONAL)
|
||||
void (WINAPI *GetInfoText)(char *format, char *length); // get main panel info text
|
||||
void (WINAPI *GetGeneralInfo)(char *buf); // get General info window text
|
||||
void (WINAPI *GetMessage)(char *buf); // get Message info text (OPTIONAL)
|
||||
double (WINAPI *SetPosition)(DWORD pos); // seek (pos=0x800000nn=subsong nn)
|
||||
double (WINAPI *GetGranularity)(); // seeking granularity
|
||||
DWORD (WINAPI *GetBuffering)(); // get buffering progress (OPTIONAL)
|
||||
DWORD (WINAPI *Process)(float *buf, DWORD count); // decode some sample data
|
||||
BOOL (WINAPI *WriteFile)(char *filename); // write file to disk (OPTIONAL)
|
||||
|
||||
#if XMPIN_FACE>=1 // "face 1" additions
|
||||
void (WINAPI *GetSamples)(char *buf); // get Samples info text (OPTIONAL)
|
||||
DWORD (WINAPI *GetSubSongs)(float *length); // get number (and total length) of sub-songs (OPTIONAL)
|
||||
#endif
|
||||
} XMPIN;
|
||||
|
||||
|
||||
#define XMPFILE_TYPE_MEMORY 0 // file in memory
|
||||
#define XMPFILE_TYPE_FILE 1 // local file
|
||||
#define XMPFILE_TYPE_NETFILE 2 // file on the 'net
|
||||
#define XMPFILE_TYPE_NETSTREAM 3 // 'net stream (indeterminate length)
|
||||
|
||||
#define XMPCONFIG_NET_BUFFER 0
|
||||
#define XMPCONFIG_NET_RESTRICT 1
|
||||
#define XMPCONFIG_NET_RECONNECT 2
|
||||
#define XMPCONFIG_NET_NOPROXY 3
|
||||
|
||||
#define XMPINFO_MAIN 1 // main window info area
|
||||
#define XMPINFO_GENERAL 2 // General info window
|
||||
#define XMPINFO_MESSAGE 4 // Message info window
|
||||
#define XMPINFO_SAMPLES 8 // Samples info window
|
||||
|
||||
typedef struct {
|
||||
struct { // file functions
|
||||
DWORD (WINAPI *GetType)(XMPFILE file); // return XMPFILE_TYPE_xxx
|
||||
DWORD (WINAPI *GetSize)(XMPFILE file); // file size
|
||||
void *(WINAPI *GetMemory)(XMPFILE file); // memory location (XMPFILE_TYPE_MEMORY)
|
||||
DWORD (WINAPI *Read)(XMPFILE file, void *buf, DWORD len); // read from file
|
||||
BOOL (WINAPI *Seek)(XMPFILE file, DWORD pos); // seek in file
|
||||
DWORD (WINAPI *Tell)(XMPFILE file); // get current file pos
|
||||
// net-only stuff
|
||||
void (WINAPI *NetSetRate)(XMPFILE file, DWORD rate); // set bitrate in bytes/sec (decides buffer size)
|
||||
BOOL (WINAPI *NetIsActive)(XMPFILE file); // connection is still up?
|
||||
BOOL (WINAPI *NetPreBuf)(XMPFILE file); // pre-buffer data
|
||||
DWORD (WINAPI *NetAvailable)(XMPFILE file); // get amount of data ready to go
|
||||
#if XMPIN_FACE>=1
|
||||
// additional file opening stuff
|
||||
XMPFILE (WINAPI *Open)(char *filename); // open a file (local file/archive only, no 'net)
|
||||
void (WINAPI *Close)(XMPFILE file); // close an opened file
|
||||
#endif
|
||||
} file;
|
||||
|
||||
struct { // tag functions - return new strings in native form (UTF8/ANSI)
|
||||
char *(WINAPI *Ansi)(char *tag, int len); // ANSI string (len=-1=null terminated)
|
||||
char *(WINAPI *Unicode)(WCHAR *tag, int len); // Unicode string
|
||||
char *(WINAPI *Utf8)(char *tag, int len); // UTF-8 string
|
||||
} tag;
|
||||
|
||||
DWORD (WINAPI *GetConfig)(DWORD option); // get a config (XMPCONFIG_xxx) value
|
||||
BOOL (WINAPI *CheckCancel)(); // user wants to cancel?
|
||||
void (WINAPI *SetLength)(float length, BOOL seekable); // set track length (-1=unchanged) and if it's seekable
|
||||
void (WINAPI *SetGain)(DWORD mode, float gain); // set replaygain (mode 0=track, 1=album)
|
||||
BOOL (WINAPI *UpdateTitle)(char *track); // set track title (NULL=refresh tags/title)
|
||||
#if XMPIN_FACE>=1
|
||||
void (WINAPI *RefreshInfo)(DWORD mode); // refresh info displays (XMPINFO_xxx flags)
|
||||
#endif
|
||||
} XMPIN_FUNCS;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user