From: <man...@us...> - 2013-09-27 01:36:58
|
Revision: 2777 http://sourceforge.net/p/modplug/code/2777 Author: manxorist Date: 2013-09-27 01:36:48 +0000 (Fri, 27 Sep 2013) Log Message: ----------- [Mod] in_openmpt: Require a more modern winamp SDK. [Fix] in_openmpt: Fix unicode handling. Modified Paths: -------------- trunk/OpenMPT/include/readme.txt trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp Modified: trunk/OpenMPT/include/readme.txt =================================================================== --- trunk/OpenMPT/include/readme.txt 2013-09-27 01:05:23 UTC (rev 2776) +++ trunk/OpenMPT/include/readme.txt 2013-09-27 01:36:48 UTC (rev 2777) @@ -18,10 +18,10 @@ Please visit http://www.steinberg.net/en/company/developer.html to download the SDK. -Winamp2 SDK +Winamp5 SDK =========== -To build libopenmpt as a winamp2 input plugin, copy the winamp2 SDK headers to -include/winamp/. +To build libopenmpt as a winamp input plugin, copy the headers in Winamp/ +from WA5.55_SDK.exe to include/winamp/. Use #define NO_WINAMP in common/BuildSettings.h to disable. xmplay input SDK Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-09-27 01:05:23 UTC (rev 2776) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-09-27 01:36:48 UTC (rev 2777) @@ -25,7 +25,9 @@ #define NOMINMAX #include <windows.h> +#define UNICODE_INPUT_PLUGIN #include "winamp/IN2.H" +#include "winamp/wa_ipc.h" #include <algorithm> #include <fstream> @@ -38,7 +40,6 @@ #define WINAMP_DSP_HEADROOM_FACTOR 2 #define WINAMP_BUFFER_SIZE_FRAMES 576 -#define WM_WA_MPEG_EOF (WM_USER+2) #define WM_OPENMPT_SEEK (WM_USER+3) #define SHORT_TITLE "in_openmpt" @@ -76,7 +77,7 @@ openmpt::settings::settings settings; int samplerate; int channels; - std::string cached_filename; + std::wstring cached_filename; std::wstring cached_title; int cached_length; std::wstring cached_infotext; @@ -101,7 +102,7 @@ filetypes_string.push_back('\0'); samplerate = settings.samplerate; channels = settings.channels; - cached_filename = ""; + cached_filename = std::wstring(); cached_title = std::wstring(); cached_length = 0; cached_infotext = std::wstring(); @@ -135,9 +136,9 @@ static DWORD WINAPI DecodeThread( LPVOID ); -static std::wstring generate_infotext( const std::string & filename, const openmpt::module & mod ) { +static std::wstring generate_infotext( const std::wstring & filename, const openmpt::module & mod ) { std::wostringstream str; - str << L"filename: " << StringDecode( filename, CP_ACP ) << std::endl; + str << L"filename: " << filename << std::endl; str << L"duration: " << mod.get_duration_seconds() << L"seconds" << std::endl; std::vector<std::string> metadatakeys = mod.get_metadata_keys(); for ( std::vector<std::string>::iterator key = metadatakeys.begin(); key != metadatakeys.end(); ++key ) { @@ -196,11 +197,11 @@ } } -static int isourfile( char * fn ) { +static int isourfile( const in_char * fn ) { return 0; } -static int play( char * fn ) { +static int play( const in_char * fn ) { if ( !fn ) { return -1; } @@ -282,8 +283,8 @@ inmod.outMod->SetPan( pan ); } -static int infobox( char * fn, HWND hWndParent ) { - if ( fn && fn[0] != '\0' && self->cached_filename != std::string(fn) ) { +static int infobox( const in_char * fn, HWND hWndParent ) { + if ( fn && fn[0] != '\0' && self->cached_filename != std::wstring(fn) ) { try { std::ifstream s( fn, std::ios::binary ); openmpt::module mod( s ); @@ -296,13 +297,17 @@ return 0; } -static void getfileinfo( char * filename, char * title, int * length_in_ms ) { +static void getfileinfo( const in_char * filename, in_char * title, int * length_in_ms ) { if ( !filename || *filename == '\0' ) { if ( length_in_ms ) { *length_in_ms = self->cached_length; } if ( title ) { - strcpy( title, StringEncode( self->cached_title, CP_ACP ).c_str() ); + std::wstring truncated_title = self->cached_title; + if ( truncated_title.length() >= GETFILEINFO_TITLE_LENGTH ) { + truncated_title.resize( GETFILEINFO_TITLE_LENGTH - 1 ); + } + wcscpy( title, truncated_title.c_str() ); } } else { try { @@ -312,7 +317,11 @@ *length_in_ms = static_cast<int>( mod.get_duration_seconds() * 1000.0 ); } if ( title ) { - strcpy( title, StringEncode( StringDecode( mod.get_metadata("title"), CP_UTF8 ), CP_ACP ).c_str() ); + std::wstring truncated_title = StringDecode( mod.get_metadata("title"), CP_UTF8 ); + if ( truncated_title.length() >= GETFILEINFO_TITLE_LENGTH ) { + truncated_title.resize( GETFILEINFO_TITLE_LENGTH - 1 ); + } + wcscpy( title, truncated_title.c_str() ); } } catch ( ... ) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |