1
0
mirror of https://github.com/TASVideos/desmume synced 2024-07-05 09:18:50 +00:00

delete vio2sf; kode54 decided to maintain it. see https://bitbucket.org/kode54/vio2sf

This commit is contained in:
zeromus 2016-03-19 07:37:36 +00:00
parent da90bfec30
commit ac26660c86
524 changed files with 0 additions and 119614 deletions

View File

@ -1,7 +0,0 @@
copy /y winamp2\plugins\vio2sf.bin ~dist
copy /y winamp2\plugins\in_vio2sf.dll ~dist
copy /y winamp5\plugins\in_vio2sfu.dll ~dist
copy /y fb8\foo_8_vio2sf.dll ~dist
copy /y fb9\components\foo_input_vio2sf.dll ~dist
copy /y kbmed\plugins\vio2sf.kpi ~dist
upx -9 ~dist/*

View File

@ -1,9 +0,0 @@
drop directories in here for testing: (projects are configured to put plugins in here)
winamp2
winamp5
kbmed
fb8
fb9
tips:
run winamp /NEW myfile.mini2sf to test builds

Binary file not shown.

View File

@ -1,130 +0,0 @@
2SF plugins / DeSmuMe
This build is from the DeSmuMe SVN repository
foo_8_vio2sf.dll + vio2sf.bin(put into same directory)
foobar2000 v0.8.x plugin
foo_input_vio2sf.dll + vio2sf.bin(put into same directory)
foobar2000 v0.9.x plugin
in_vio2sf.dll + vio2sf.bin(put into same directory)
Winamp 2.x plugin
Missing feature:reading-from-archive unicode-filename(by-spec)
in_vio2sfu.dll + vio2sf.bin(put into same directory)
Winamp 5.x unicode plugin
Missing feature:reading-from-archive
vio2sf.kpi + vio2sf.bin(put into same directory)
KbMedia Player plugin
Missing feature:replaygain(by-spec) tag-writing(by-spec) unicode-filename(by-spec) libs-in-archive-with-sub-directory(by-spec)
History
-------
0.23 (2010/01/19)
Import desmume 0.9.4 generation SPU
- fix bugs in ADPCM looping and PSG channels
Add interpolation options (none,linear,cosine)
0.22 (2009/10/16)
Fixed: Failed to load libs by relative path.
Fixed: Failed to read '_libN' tags.
0.21 (2009/09/30)
Fixed: Bufffer for several dsp plugins needed double space.
0.20 (2009/07/22)
Fixed: Skipped loading 2sflib described in '_lib2' tag without '_lib' tag.
0.19 (2009/03/13)
Removed: Experimental tag('_vio2sf_loader_type').
Ignored: Inconsistency with priority of superimposing.
0.18 (2009/03/10)
Added: Experimental tag('_vio2sf_loader_type').
0.17 (2009/03/07)
Fixed:Obsolete config dialog for Winamp 2.x was not able to be displayed.
0.16 (2009/03/06)
Fixed:Skipped silent songs although these had length information.
0.15 (2009/03/05)
Fixed:ROM address mask was set to invalid value when 2sf had only single memory block.
0.14 (2008/04/30)
DeSmuMe 0.8.0
0.13 (2008/03/05)
Added:Plugin for foobar v0.8.x
Fixed:Informed blank title last played to Winamp.
0.12 (2008/03/04)
Fixed:Loaded libs in nonstandard order.
Clean up common code.
0.11 (2008/02/11)
Added:'_clockdown' tag support.
Fixed:ARM coprocessor work memory is leaked.
0.10 (2008/02/04)
Fixed:Played with inaccurate pitch and timer speed.
Added:'_frame' tag support.
Added: Experimental tags('_vio2sf_sync_type','_vio2sf_arm9_clockdown_level','_vio2sf_arm7_clockdown_level').
_vio2sf_sync_type=0(hsync:default),1(vsync:fast but inaccurate)
_vio2sf_arm9_clockdown_level=0(default),1(Clock of ARM9 down to 1/2),2(Clock of ARM9 down to 1/4),3(Clock of ARM9 down to 1/8)
_vio2sf_arm7_clockdown_level=0(default),1(Clock of ARM7 down to 1/2),2(Clock of ARM7 down to 1/4),3(Clock of ARM7 down to 1/8)
0.09 (2008/02/03)
Fixed:Crashed with memory access violation over rom length.
0.08 (2008/02/02)
Fixed:No samples clipped after mixing.
Fixed:Wasted CPU cycles by looping ADPCM.
0.07 (2008/02/01)
SPU emulation based on DeSmuME v0.7.3wp1 mdn.
0.06 / 0.05 / 0.04 (2008/02/01)
Fixed:Invaid initial state of ARM9.
0.03 (2008/01/30)
Removed:Needless cpu emulation on loading process.
0.02 (2008/01/29)
Fixed:Erased system tags('_lib') by tag writer in Winamp.
Fixed:Uncompressed buffers are leaked on loading process.
0.01 (2008/01/28)
First release.
License
-------
[DeSmuMe](GPL)
DeSmuME
_________________________________________
Copyright (C) 2006 yopyop
Copyright (C) 2006-2007 DeSmuME team
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Please refer to src.7z/src/vio2sf/desmume/COPYING.
[zlib](ZLIBL)
'zlib' general purpose compression library version 1.2.3, July 18th, 2005
Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
Please refer to src.7z/src/vio2sf/zlib/zlib.h
[loadpe](LGPL)
libloadpe
Copyright (C)2007 Ku-Zu
Please refer to src.7z/src/loadpe/COPYING.LIB for redistributing.

View File

@ -1,258 +0,0 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="foo_input_vio2sf"
ProjectGUID="{22752D82-8F89-4F87-B07E-D254D7BF675A}"
RootNamespace="foo_input_vio2sf"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src/foobar;src"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FOO_INPUT_VIO2SF_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(ProjectName).dll"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
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="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="false"
AdditionalIncludeDirectories="src/foobar;src"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FOO_INPUT_VIO2SF_EXPORTS"
StringPooling="true"
RuntimeLibrary="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="OUTPUT\fb9\components\foo_input_vio2sf.dll"
LinkIncremental="1"
GenerateManifest="true"
GenerateDebugInformation="false"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
SetChecksum="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="ソース ファイル"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\xsfc\foo_input_xsf.cpp"
>
</File>
<File
RelativePath=".\src\xsfc\foo_input_xsfcfg.cpp"
>
</File>
<File
RelativePath=".\src\loadpe\loadpe.c"
>
</File>
<File
RelativePath=".\src\xsfc\xsfc.cpp"
>
</File>
<File
RelativePath=".\src\xsfc\xsfcfg.cpp"
>
</File>
</Filter>
<Filter
Name="ヘッダー ファイル"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\xsfc\leakchk.h"
>
</File>
<File
RelativePath=".\src\loadpe\loadpe.h"
>
</File>
<File
RelativePath=".\src\pversion.h"
>
</File>
<File
RelativePath=".\src\xsfc\tagget.h"
>
</File>
<File
RelativePath=".\src\xsfc\winresx.h"
>
</File>
<File
RelativePath=".\src\xsfc\xsfc.h"
>
</File>
<File
RelativePath=".\src\xsfc\xsfcfg.h"
>
</File>
<File
RelativePath=".\src\xsfc\xsfdrv.h"
>
</File>
</Filter>
<Filter
Name="リソース ファイル"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\src\xsfc\xsfui.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,151 +0,0 @@
# Microsoft Developer Studio Project File - Name="foo_xsf8" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=foo_xsf8 - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "foo_xsf8.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "foo_xsf8.mak" CFG="foo_xsf8 - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "foo_xsf8 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "foo_xsf8 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "foo_xsf8 - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "foo_xsf8___Win32_Release"
# PROP BASE Intermediate_Dir "foo_xsf8___Win32_Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "foo_xsf8___Win32_Release"
# PROP Intermediate_Dir "foo_xsf8___Win32_Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /I "src/foobar8" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"OUTPUT\fb8\foo_8_vio2sf.dll"
!ELSEIF "$(CFG)" == "foo_xsf8 - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "foo_xsf8___Win32_Debug"
# PROP BASE Intermediate_Dir "foo_xsf8___Win32_Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "foo_xsf8___Win32_Debug"
# PROP Intermediate_Dir "foo_xsf8___Win32_Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "src/foobar8" /I "src" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "FOO_XSF8_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"foo_8_vio2sf.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "foo_xsf8 - Win32 Release"
# Name "foo_xsf8 - Win32 Debug"
# Begin Group "loadpe"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\loadpe\loadpe.c
# End Source File
# Begin Source File
SOURCE=.\src\loadpe\loadpe.h
# End Source File
# End Group
# Begin Group "xsfc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\xsfc\foo_input_xsf8.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\foo_input_xsfcfg8.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\leakchk.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\tagget.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfdrv.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfui.rc
# End Source File
# End Group
# Begin Source File
SOURCE=.\src\pversion.h
# End Source File
# End Target
# End Project

View File

@ -1,374 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="foo_xsf8"
ProjectGUID="{02361C60-7E8A-4002-890A-E2B0AC2C91D8}"
RootNamespace="foo_xsf8"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\foo_xsf8___Win32_Release"
IntermediateDirectory=".\foo_xsf8___Win32_Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\foo_xsf8___Win32_Release/foo_xsf8.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FOO_XSF8_EXPORTS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\foo_xsf8___Win32_Release/foo_xsf8.pch"
AssemblerListingLocation=".\foo_xsf8___Win32_Release/"
ObjectFile=".\foo_xsf8___Win32_Release/"
ProgramDataBaseFileName=".\foo_xsf8___Win32_Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="pfc.lib foobar2000_SDK.lib foobar2000_sdk_helpers.lib odbc32.lib odbccp32.lib"
OutputFile="OUTPUT\fb8\foo_8_vio2sf.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\foo_xsf8___Win32_Release/foo_8_vio2sf.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\foo_xsf8___Win32_Release/foo_8_vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\foo_xsf8___Win32_Release/foo_xsf8.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\foo_xsf8___Win32_Debug"
IntermediateDirectory=".\foo_xsf8___Win32_Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\foo_xsf8___Win32_Debug/foo_xsf8.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FOO_XSF8_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\foo_xsf8___Win32_Debug/foo_xsf8.pch"
AssemblerListingLocation=".\foo_xsf8___Win32_Debug/"
ObjectFile=".\foo_xsf8___Win32_Debug/"
ProgramDataBaseFileName=".\foo_xsf8___Win32_Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="pfcD.lib foobar2000_SDKD.lib foobar2000_sdk_helpersD.lib odbc32.lib odbccp32.lib"
OutputFile="C:\Program Files\foobar2000_8\components\foo_8_vio2sf.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\foo_xsf8___Win32_Debug/foo_8_vio2sf.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\foo_xsf8___Win32_Debug/foo_8_vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\foo_xsf8___Win32_Debug/foo_xsf8.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="loadpe"
>
<File
RelativePath="src\loadpe\loadpe.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\loadpe\loadpe.h"
>
</File>
</Filter>
<Filter
Name="xsfc"
>
<File
RelativePath="src\xsfc\foo_input_xsf8.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\foo_input_xsfcfg8.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\leakchk.h"
>
</File>
<File
RelativePath="src\xsfc\tagget.h"
>
</File>
<File
RelativePath="src\xsfc\xsfc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfc.h"
>
</File>
<File
RelativePath="src\xsfc\xsfcfg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfcfg.h"
>
</File>
<File
RelativePath="src\xsfc\xsfdrv.h"
>
</File>
<File
RelativePath="src\xsfc\xsfui.rc"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="src\pversion.h"
>
</File>
<File
RelativePath=".\src\xsfc\xsfui.rh"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,156 +0,0 @@
# Microsoft Developer Studio Project File - Name="in_xsf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=in_xsf - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "in_xsf.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "in_xsf.mak" CFG="in_xsf - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "in_xsf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "in_xsf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "in_xsf - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_in_xsf"
# PROP Intermediate_Dir "Release_in_xsf"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /pdb:none /machine:I386 /out:"OUTPUT\winamp2\plugins\in_vio2sf.dll"
!ELSEIF "$(CFG)" == "in_xsf - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug_in_xsf"
# PROP Intermediate_Dir "Debug_in_xsf"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D "LSB_FIRST" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"in_vio2sf.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "in_xsf - Win32 Release"
# Name "in_xsf - Win32 Debug"
# Begin Group "loadpe"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\loadpe\loadpe.c
# End Source File
# Begin Source File
SOURCE=.\src\loadpe\loadpe.h
# End Source File
# End Group
# Begin Group "xsfc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\xsfc\in_xsf.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\in_xsfcfg.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\in_xsfcfg.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\leakchk.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\tagget.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfdrv.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfui.rc
# End Source File
# End Group
# Begin Source File
SOURCE=.\src\pversion.h
# End Source File
# End Target
# End Project

View File

@ -1,374 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="in_xsf"
ProjectGUID="{035B66F9-6D8C-47AA-8CDC-F43DA0BDC1E7}"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug_in_xsf"
IntermediateDirectory=".\Debug_in_xsf"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug_in_xsf/in_xsf.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src/aosdk,src/aosdk/zlib"
PreprocessorDefinitions="LSB_FIRST;WIN32;_DEBUG;_WINDOWS;_USRDLL;IN_XSF_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug_in_xsf/in_xsf.pch"
AssemblerListingLocation=".\Debug_in_xsf/"
ObjectFile=".\Debug_in_xsf/"
ProgramDataBaseFileName=".\Debug_in_xsf/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="C:\Program Files\Winamp\Plugins/in_vio2sf.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug_in_xsf/in_vio2sf.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Debug_in_xsf/in_vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug_in_xsf/in_xsf.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release_in_xsf"
IntermediateDirectory=".\Release_in_xsf"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release_in_xsf/in_xsf.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IN_XSF_EXPORTS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release_in_xsf/in_xsf.pch"
AssemblerListingLocation=".\Release_in_xsf/"
ObjectFile=".\Release_in_xsf/"
ProgramDataBaseFileName=".\Release_in_xsf/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="OUTPUT/winamp2/plugins/in_vio2sf.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release_in_xsf/in_vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release_in_xsf/in_xsf.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="loadpe"
>
<File
RelativePath="src\loadpe\loadpe.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\loadpe\loadpe.h"
>
</File>
</Filter>
<Filter
Name="xsfc"
>
<File
RelativePath="src\xsfc\in_xsf.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\in_xsfcfg.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\in_xsfcfg.h"
>
</File>
<File
RelativePath="src\xsfc\leakchk.h"
>
</File>
<File
RelativePath="src\xsfc\tagget.h"
>
</File>
<File
RelativePath="src\xsfc\xsfc.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfc.h"
>
</File>
<File
RelativePath="src\xsfc\xsfcfg.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfcfg.h"
>
</File>
<File
RelativePath="src\xsfc\xsfdrv.h"
>
</File>
<File
RelativePath="src\xsfc\xsfui.rc"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="src\pversion.h"
>
</File>
</Files>
</VisualStudioProject>

View File

@ -1,156 +0,0 @@
# Microsoft Developer Studio Project File - Name="in_xsfu" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=in_xsfu - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "in_xsfu.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "in_xsfu.mak" CFG="in_xsfu - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "in_xsfu - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "in_xsfu - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "in_xsfu - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_in_xsfu"
# PROP Intermediate_Dir "Release_in_xsfu"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D ENABLE_UNICODE_PLUGIN=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /pdb:none /machine:I386 /out:"OUTPUT\winamp5\plugins\in_vio2sfu.dll"
!ELSEIF "$(CFG)" == "in_xsfu - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug_in_xsfu"
# PROP Intermediate_Dir "Debug_in_xsfu"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "src/aosdk" /I "src/aosdk/zlib" /I "src" /D ENABLE_UNICODE_PLUGIN=1 /D "LSB_FIRST" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "IN_XSF_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"in_vio2sfu.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "in_xsfu - Win32 Release"
# Name "in_xsfu - Win32 Debug"
# Begin Group "loadpe"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\loadpe\loadpe.c
# End Source File
# Begin Source File
SOURCE=.\src\loadpe\loadpe.h
# End Source File
# End Group
# Begin Group "xsfc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\xsfc\in_xsf.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\in_xsfcfg.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\in_xsfcfg.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\leakchk.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\tagget.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfc.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.cpp
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfcfg.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfdrv.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfui.rc
# End Source File
# End Group
# Begin Source File
SOURCE=.\src\pversion.h
# End Source File
# End Target
# End Project

View File

@ -1,391 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="in_xsfu"
ProjectGUID="{226CE519-0842-4808-B6F9-C02DE14BB3DC}"
RootNamespace="in_xsfu"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release_in_xsfu"
IntermediateDirectory=".\Release_in_xsfu"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release_in_xsfu/in_xsfu.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="src/aosdk,src/aosdk/zlib,src"
PreprocessorDefinitions="ENABLE_UNICODE_PLUGIN=1;WIN32;NDEBUG;_WINDOWS;_USRDLL;IN_XSF_EXPORTS"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release_in_xsfu/in_xsfu.pch"
AssemblerListingLocation=".\Release_in_xsfu/"
ObjectFile=".\Release_in_xsfu/"
ProgramDataBaseFileName=".\Release_in_xsfu/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="OUTPUT/winamp5/plugins/in_vio2sfu.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release_in_xsfu/in_vio2sfu.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release_in_xsfu/in_xsfu.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug_in_xsfu"
IntermediateDirectory=".\Debug_in_xsfu"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug_in_xsfu/in_xsfu.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
AdditionalOptions="/MP"
Optimization="0"
AdditionalIncludeDirectories="src/aosdk,src/aosdk/zlib,src"
PreprocessorDefinitions="ENABLE_UNICODE_PLUGIN=1;LSB_FIRST;WIN32;_DEBUG;_WINDOWS;_USRDLL;IN_XSF_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug_in_xsfu/in_xsfu.pch"
AssemblerListingLocation=".\Debug_in_xsfu/"
ObjectFile=".\Debug_in_xsfu/"
ProgramDataBaseFileName=".\Debug_in_xsfu/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="OUTPUT/winamp5/plugins/in_vio2sfu.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug_in_xsfu/in_vio2sfu.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Debug_in_xsfu/in_vio2sfu.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug_in_xsfu/in_xsfu.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine=""
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="loadpe"
>
<File
RelativePath="src\loadpe\loadpe.c"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\loadpe\loadpe.h"
>
</File>
</Filter>
<Filter
Name="xsfc"
>
<File
RelativePath="src\xsfc\in_xsf.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\in_xsfcfg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\in_xsfcfg.h"
>
</File>
<File
RelativePath="src\xsfc\leakchk.h"
>
</File>
<File
RelativePath="src\xsfc\tagget.h"
>
</File>
<File
RelativePath="src\xsfc\xsfc.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfc.h"
>
</File>
<File
RelativePath="src\xsfc\xsfcfg.cpp"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\xsfcfg.h"
>
</File>
<File
RelativePath="src\xsfc\xsfdrv.h"
>
</File>
<File
RelativePath="src\xsfc\xsfui.rc"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions=""
AdditionalIncludeDirectories="src\xsfc"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath="src\pversion.h"
>
</File>
<File
RelativePath=".\src\xsfc\xsfui.rh"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,136 +0,0 @@
# Microsoft Developer Studio Project File - Name="kpixsf" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=kpixsf - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "kpixsf.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "kpixsf.mak" CFG="kpixsf - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "kpixsf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "kpixsf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "kpixsf - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release_kpixsf"
# PROP Intermediate_Dir "Release_kpixsf"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "NDEBUG"
# ADD RSC /l 0x411 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /dll /pdb:none /machine:I386 /out:"output\kbmed\plugins\vio2sf.kpi"
!ELSEIF "$(CFG)" == "kpixsf - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug_kpixsf"
# PROP Intermediate_Dir "Debug_kpixsf"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "KPIXSF_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x411 /d "_DEBUG"
# ADD RSC /l 0x411 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib shlwapi.lib /nologo /dll /debug /machine:I386 /out:"vio2sf.kpi" /pdbtype:sept
!ENDIF
# Begin Target
# Name "kpixsf - Win32 Release"
# Name "kpixsf - Win32 Debug"
# Begin Group "loadpe"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\loadpe\loadpe.c
# End Source File
# Begin Source File
SOURCE=.\src\loadpe\loadpe.h
# End Source File
# End Group
# Begin Group "kobarin"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\kobarin\kmp_pi.h
# End Source File
# End Group
# Begin Group "xsfc"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\xsfc\kpixsf.c
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\leakchk.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\tagget.h
# End Source File
# Begin Source File
SOURCE=.\src\xsfc\xsfdrv.h
# End Source File
# End Group
# Begin Source File
SOURCE=.\src\pversion.h
# End Source File
# End Target
# End Project

View File

@ -1,286 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="kpixsf"
ProjectGUID="{45AEABD2-996B-4C43-947C-E43D3A3DF79A}"
TargetFrameworkVersion="0"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug_kpixsf"
IntermediateDirectory=".\Debug_kpixsf"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug_kpixsf/kpixsf.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;KPIXSF_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug_kpixsf/kpixsf.pch"
AssemblerListingLocation=".\Debug_kpixsf/"
ObjectFile=".\Debug_kpixsf/"
ProgramDataBaseFileName=".\Debug_kpixsf/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib shlwapi.lib"
OutputFile="C:\usr\bin\kbmed242_beta4\Plugins/vio2sf.kpi"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug_kpixsf/vio2sf.pdb"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Debug_kpixsf/vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug_kpixsf/kpixsf.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release_kpixsf"
IntermediateDirectory=".\Release_kpixsf"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release_kpixsf/kpixsf.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;KPIXSF_EXPORTS"
StringPooling="true"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release_kpixsf/kpixsf.pch"
AssemblerListingLocation=".\Release_kpixsf/"
ObjectFile=".\Release_kpixsf/"
ProgramDataBaseFileName=".\Release_kpixsf/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1041"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib shlwapi.lib"
OutputFile="vio2sf.kpi"
LinkIncremental="1"
SuppressStartupBanner="true"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
ImportLibrary=".\Release_kpixsf/vio2sf.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release_kpixsf/kpixsf.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="loadpe"
>
<File
RelativePath="src\loadpe\loadpe.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\loadpe\loadpe.h"
>
</File>
</Filter>
<Filter
Name="kobarin"
>
<File
RelativePath="src\kobarin\kmp_pi.h"
>
</File>
</Filter>
<Filter
Name="xsfc"
>
<File
RelativePath="src\xsfc\kpixsf.c"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="src\xsfc\leakchk.h"
>
</File>
<File
RelativePath="src\xsfc\tagget.h"
>
</File>
<File
RelativePath="src\xsfc\xsfdrv.h"
>
</File>
</Filter>
<File
RelativePath="src\pversion.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,4 +0,0 @@
First build every project in vio2sf.dsw. This will include the vio2sf project which will copy vio2sf.bin into all the plugin dirs.
Then build foo_input_vio2sf from vio2sf.sln. This plugin my be built in a newer msvc.
It has a dependency on vio2sf, which will then overwrite all vio2sf.bin in all directories with a vc9 version.
This is safe since it doesn't import any CRT DLL, and it probably runs a little faster.

View File

@ -1,65 +0,0 @@
#ifndef NULLSOFT_WINAMP_DSP_H
#define NULLSOFT_WINAMP_DSP_H
// DSP plugin interface
// notes:
// any window that remains in foreground should optimally pass unused
// keystrokes to the parent (winamp's) window, so that the user
// can still control it. As for storing configuration,
// Configuration data should be stored in <dll directory>\plugin.ini
// (look at the vis plugin for configuration code)
typedef struct winampDSPModule {
char *description; // description
HWND hwndParent; // parent window (filled in by calling app)
HINSTANCE hDllInstance; // instance handle to this DLL (filled in by calling app)
void (*Config)(struct winampDSPModule *this_mod); // configuration dialog (if needed)
int (*Init)(struct winampDSPModule *this_mod); // 0 on success, creates window, etc (if needed)
// modify waveform samples: returns number of samples to actually write
// (typically numsamples, but no more than twice numsamples, and no less than half numsamples)
// numsamples should always be at least 128. should, but I'm not sure
int (*ModifySamples)(struct winampDSPModule *this_mod, short int *samples, int numsamples, int bps, int nch, int srate);
void (*Quit)(struct winampDSPModule *this_mod); // called when unloading
void *userData; // user data, optional
} winampDSPModule;
typedef struct {
int version; // DSP_HDRVER
char *description; // description of library
winampDSPModule* (*getModule)(int); // module retrieval function
int (*sf)(int key); // DSP_HDRVER == 0x21
} winampDSPHeader;
// exported symbols
#ifdef USE_DSP_HDR_HWND
typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND);
#define DSP_HDRVER 0x22
#else
typedef winampDSPHeader* (*winampDSPGetHeaderType)(HWND);
// header version: 0x20 == 0.20 == winamp 2.0
#define DSP_HDRVER 0x20
#endif
// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param)
// which determine if we can uninstall the plugin immediately or on winamp restart
#define DSP_PLUGIN_UNINSTALL_NOW 0x0
#define DSP_PLUGIN_UNINSTALL_REBOOT 0x1
//
// uninstall support was added from 5.0+ and uninstall now support from 5.5+
// it is down to you to ensure that if uninstall now is returned that it will not cause a crash
// (ie don't use if you've been subclassing the main window)
// Version note:
//
// Added passing of Winamp's main hwnd in the call to the exported winampDSPHeader()
// which allows for primarily the use of localisation features with the bundled plugins.
// If you want to use the new version then either you can edit you version of dsp.h or
// you can add USE_DSP_HDR_HWND to your project's defined list or before use of dsp.h
//
#endif

View File

@ -1,37 +0,0 @@
#ifndef NULLSOFT_WINAMP_GEN_H
#define NULLSOFT_WINAMP_GEN_H
#include <windows.h>
#define GEN_INIT_SUCCESS 0
// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param)
// which determine if we can uninstall the plugin immediately or on winamp restart
//
// uninstall support was added from 5.0+ and uninstall now support from 5.5+
// it is down to you to ensure that if uninstall now is returned that it will not cause a crash
// (ie don't use if you've been subclassing the main window)
#define GEN_PLUGIN_UNINSTALL_NOW 0x1
#define GEN_PLUGIN_UNINSTALL_REBOOT 0x0
typedef struct {
int version;
char *description;
int (*init)();
void (*config)();
void (*quit)();
HWND hwndParent;
HINSTANCE hDllInstance;
} winampGeneralPurposePlugin;
#define GPPHDR_VER 0x10
#ifdef __cplusplus
extern "C" {
#endif
//extern winampGeneralPurposePlugin *gen_plugins[256];
typedef winampGeneralPurposePlugin * (*winampGeneralPurposePluginGetter)();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,138 +0,0 @@
#ifndef NULLSOFT_WINAMP_IN2H
#define NULLSOFT_WINAMP_IN2H
#include "out.h"
// note: exported symbol is now winampGetInModule2.
#define IN_UNICODE 0x0F000000
#ifdef UNICODE_INPUT_PLUGIN
#define in_char wchar_t
#define IN_VER (IN_UNICODE | 0x100)
#else
#define in_char char
#define IN_VER 0x100
#endif
#define IN_MODULE_FLAG_USES_OUTPUT_PLUGIN 1
// By default, Winamp assumes that your input plugin wants to use Winamp's EQ, and doesn't do replay gain
// if you handle any of these yourself (EQ, Replay Gain adjustments), then set these flags accordingly
#define IN_MODULE_FLAG_EQ 2 // set this if you do your own EQ
#define IN_MODULE_FLAG_REPLAYGAIN 8 // set this if you adjusted volume for replay gain
// for tracks with no replay gain metadata, you should clear this flag
// UNLESS you handle "non_replaygain" gain adjustment yourself
#define IN_MODULE_FLAG_REPLAYGAIN_PREAMP 16 // use this if you queried for the replay gain preamp parameter and used it
// this parameter is new to 5.54
typedef struct
{
int version; // module type (IN_VER)
char *description; // description of module, with version string
HWND hMainWindow; // winamp's main window (filled in by winamp)
HINSTANCE hDllInstance; // DLL instance handle (Also filled in by winamp)
char *FileExtensions; // "mp3\0Layer 3 MPEG\0mp2\0Layer 2 MPEG\0mpg\0Layer 1 MPEG\0"
// May be altered from Config, so the user can select what they want
int is_seekable; // is this stream seekable?
int UsesOutputPlug; // does this plug-in use the output plug-ins? (musn't ever change, ever :)
// note that this has turned into a "flags" field
// see IN_MODULE_FLAG_*
void (*Config)(HWND hwndParent); // configuration dialog
void (*About)(HWND hwndParent); // about dialog
void (*Init)(); // called at program init
void (*Quit)(); // called at program quit
#define GETFILEINFO_TITLE_LENGTH 2048
void (*GetFileInfo)(const in_char *file, in_char *title, int *length_in_ms); // if file == NULL, current playing is used
#define INFOBOX_EDITED 0
#define INFOBOX_UNCHANGED 1
int (*InfoBox)(const in_char *file, HWND hwndParent);
int (*IsOurFile)(const in_char *fn); // called before extension checks, to allow detection of mms://, etc
// playback stuff
int (*Play)(const in_char *fn); // return zero on success, -1 on file-not-found, some other value on other (stopping winamp) error
void (*Pause)(); // pause stream
void (*UnPause)(); // unpause stream
int (*IsPaused)(); // ispaused? return 1 if paused, 0 if not
void (*Stop)(); // stop (unload) stream
// time stuff
int (*GetLength)(); // get length in ms
int (*GetOutputTime)(); // returns current output time in ms. (usually returns outMod->GetOutputTime()
void (*SetOutputTime)(int time_in_ms); // seeks to point in stream (in ms). Usually you signal your thread to seek, which seeks and calls outMod->Flush()..
// volume stuff
void (*SetVolume)(int volume); // from 0 to 255.. usually just call outMod->SetVolume
void (*SetPan)(int pan); // from -127 to 127.. usually just call outMod->SetPan
// in-window builtin vis stuff
void (*SAVSAInit)(int maxlatency_in_ms, int srate); // call once in Play(). maxlatency_in_ms should be the value returned from outMod->Open()
// call after opening audio device with max latency in ms and samplerate
void (*SAVSADeInit)(); // call in Stop()
// simple vis supplying mode
void (*SAAddPCMData)(void *PCMData, int nch, int bps, int timestamp);
// sets the spec data directly from PCM data
// quick and easy way to get vis working :)
// needs at least 576 samples :)
// advanced vis supplying mode, only use if you're cool. Use SAAddPCMData for most stuff.
int (*SAGetMode)(); // gets csa (the current type (4=ws,2=osc,1=spec))
// use when calling SAAdd()
int (*SAAdd)(void *data, int timestamp, int csa); // sets the spec data, filled in by winamp
// vis stuff (plug-in)
// simple vis supplying mode
void (*VSAAddPCMData)(void *PCMData, int nch, int bps, int timestamp); // sets the vis data directly from PCM data
// quick and easy way to get vis working :)
// needs at least 576 samples :)
// advanced vis supplying mode, only use if you're cool. Use VSAAddPCMData for most stuff.
int (*VSAGetMode)(int *specNch, int *waveNch); // use to figure out what to give to VSAAdd
int (*VSAAdd)(void *data, int timestamp); // filled in by winamp, called by plug-in
// call this in Play() to tell the vis plug-ins the current output params.
void (*VSASetInfo)(int srate, int nch); // <-- Correct (benski, dec 2005).. old declaration had the params backwards
// dsp plug-in processing:
// (filled in by winamp, calld by input plug)
// returns 1 if active (which means that the number of samples returned by dsp_dosamples
// could be greater than went in.. Use it to estimate if you'll have enough room in the
// output buffer
int (*dsp_isactive)();
// returns number of samples to output. This can be as much as twice numsamples.
// be sure to allocate enough buffer for samples, then.
int (*dsp_dosamples)(short int *samples, int numsamples, int bps, int nch, int srate);
// eq stuff
void (*EQSet)(int on, char data[10], int preamp); // 0-64 each, 31 is +0, 0 is +12, 63 is -12. Do nothing to ignore.
// info setting (filled in by winamp)
void (*SetInfo)(int bitrate, int srate, int stereo, int synched); // if -1, changes ignored? :)
Out_Module *outMod; // filled in by winamp, optionally used :)
} In_Module;
// return values from the winampUninstallPlugin(HINSTANCE hdll, HWND parent, int param)
// which determine if we can uninstall the plugin immediately or on winamp restart
//
// uninstall support was added from 5.0+ and uninstall now support from 5.5+
// it is down to you to ensure that if uninstall now is returned that it will not cause a crash
// (ie don't use if you've been subclassing the main window)
#define IN_PLUGIN_UNINSTALL_NOW 0x1
#define IN_PLUGIN_UNINSTALL_REBOOT 0x0
#endif

View File

@ -1,73 +0,0 @@
#ifndef NULLSOFT_OUTH
#define NULLSOFT_OUTH
#include <windows.h>
#include <stddef.h>
// ids:
// waveout: 32
// gapless: 64
// xfade: 63
// disk: 33
// dsound: 38
// NULL: 65
// mm2: 69
#if (_MSC_VER <= 1200)
typedef int intptr_t;
#endif
#define OUT_VER 0x10
typedef struct
{
int version; // module version (OUT_VER)
char *description; // description of module, with version string
intptr_t id; // module id. each input module gets its own. non-nullsoft modules should
// be >= 65536.
HWND hMainWindow; // winamp's main window (filled in by winamp)
HINSTANCE hDllInstance; // DLL instance handle (filled in by winamp)
void (*Config)(HWND hwndParent); // configuration dialog
void (*About)(HWND hwndParent); // about dialog
void (*Init)(); // called when loaded
void (*Quit)(); // called when unloaded
int (*Open)(int samplerate, int numchannels, int bitspersamp, int bufferlenms, int prebufferms);
// returns >=0 on success, <0 on failure
// NOTENOTENOTE: bufferlenms and prebufferms are ignored in most if not all output plug-ins.
// ... so don't expect the max latency returned to be what you asked for.
// returns max latency in ms (0 for diskwriters, etc)
// bufferlenms and prebufferms must be in ms. 0 to use defaults.
// prebufferms must be <= bufferlenms
// pass bufferlenms==-666 to tell the output plugin that it's clock is going to be used to sync video
// out_ds turns off silence-eating when -666 is passed
void (*Close)(); // close the ol' output device.
int (*Write)(char *buf, int len);
// 0 on success. Len == bytes to write (<= 8192 always). buf is straight audio data.
// 1 returns not able to write (yet). Non-blocking, always.
int (*CanWrite)(); // returns number of bytes possible to write at a given time.
// Never will decrease unless you call Write (or Close, heh)
int (*IsPlaying)(); // non0 if output is still going or if data in buffers waiting to be
// written (i.e. closing while IsPlaying() returns 1 would truncate the song
int (*Pause)(int pause); // returns previous pause state
void (*SetVolume)(int volume); // volume is 0-255
void (*SetPan)(int pan); // pan is -128 to 128
void (*Flush)(int t); // flushes buffers and restarts output at time t (in ms)
// (used for seeking)
int (*GetOutputTime)(); // returns played time in MS
int (*GetWrittenTime)(); // returns time written in MS (used for synching up vis stuff)
} Out_Module;
#endif

View File

@ -1,56 +0,0 @@
#ifndef __IPC_PE_H
#define __IPC_PE_H
#define IPC_PE_GETCURINDEX 100 // returns current idx
#define IPC_PE_GETINDEXTOTAL 101 // returns number of items
#define IPC_PE_GETINDEXINFO 102 // (copydata) lpData is of type callbackinfo, callback is called with copydata/fileinfo structure and msg IPC_PE_GETINDEXINFORESULT
#define IPC_PE_GETINDEXINFORESULT 103 // callback message for IPC_PE_GETINDEXINFO
#define IPC_PE_DELETEINDEX 104 // lParam = index
#define IPC_PE_SWAPINDEX 105 // (lParam & 0xFFFF0000) >> 16 = from, (lParam & 0xFFFF) = to
#define IPC_PE_INSERTFILENAME 106 // (copydata) lpData is of type fileinfo
#define IPC_PE_GETDIRTY 107 // returns 1 if the playlist changed since the last IPC_PE_SETCLEAN
#define IPC_PE_SETCLEAN 108 // resets the dirty flag until next modification
#define IPC_PE_GETIDXFROMPOINT 109 // pass a point parm, return a playlist index
#define IPC_PE_SAVEEND 110 // pass index to save from
#define IPC_PE_RESTOREEND 111 // no parm
#define IPC_PE_GETNEXTSELECTED 112 // same as IPC_PLAYLIST_GET_NEXT_SELECTED for the main window
#define IPC_PE_GETSELECTEDCOUNT 113
#define IPC_PE_INSERTFILENAMEW 114 // (copydata) lpData is of type fileinfoW
#define IPC_PE_GETINDEXINFO_TITLE 115 // like IPC_PE_GETINDEXINFO, but writes the title to char file[MAX_PATH] instead of filename
#define IPC_PE_GETINDEXINFORESULT_TITLE 116 // callback message for IPC_PE_GETINDEXINFO
typedef struct {
char file[MAX_PATH];
int index;
} fileinfo;
typedef struct {
wchar_t file[MAX_PATH];
int index;
} fileinfoW;
typedef struct {
HWND callback;
int index;
} callbackinfo;
// the following messages are in_process ONLY
#define IPC_PE_GETINDEXTITLE 200 // lParam = pointer to fileinfo2 struct
#define IPC_PE_GETINDEXTITLEW 201 // lParam = pointer to fileinfo2W struct
#define IPC_PE_GETINDEXINFO_INPROC 202 // lParam = pointer to fileinfo struct
#define IPC_PE_GETINDEXINFOW_INPROC 203 // lParam = pointer to fileinfoW struct
typedef struct {
int fileindex;
char filetitle[256];
char filelength[16];
} fileinfo2;
typedef struct
{
int fileindex;
wchar_t filetitle[256];
wchar_t filelength[16];
} fileinfo2W;
#endif

View File

@ -1,436 +0,0 @@
/*
** Copyright (C) 2003-2008 Nullsoft, Inc.
**
** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held
** liable for any damages arising from the use of this software.
**
** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to
** alter it and redistribute it freely, subject to the following restrictions:
**
** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
**
** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
**
** 3. This notice may not be removed or altered from any source distribution.
**
*/
#ifndef _WA_DLG_H_
#define _WA_DLG_H_
#include "wa_ipc.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
1) gen.bmp has a generic window frame for plugins to use.
its format is similar to the minibrowser's.
In addition gen.bmp includes a font for the titlebar, in both
highlight and no-highlight modes. The font is variable width,
and it uses the first color before the letter A as the delimiter.
The no-highlight form of letter must be the same width as the
highlight form.
2) genex.bmp has button and scrollbar images, as well as some individual
pixels that describe the colors for the dialog. The button and
scrollbar images should be self explanatory (note that the buttons
have 4 pixel sized edges that are not stretched, and the center is
stretched), and the scrollbars do something similar.
The colors start at (48,0) and run every other pixel. The meaning
of each pixel is:
x=48: item background (background to edits, listviews etc)
x=50: item foreground (text color of edit/listview, etc)
x=52: window background (used to set the bg color for the dialog)
x=54: button text color
x=56: window text color
x=58: color of dividers and sunken borders
x=60: selection color for playlists
x=62: listview header background color
x=64: listview header text color
x=66: listview header frame top color
x=68: listview header frame middle color
x=70: listview header frame bottom color
x=72: listview header empty color
x=74: scrollbar foreground color
x=76: scrollbar background color
x=78: inverse scrollbar foreground color
x=80: inverse scrollbar background color
x=82: scrollbar dead area color
x=84: listview/treeview selection bar text color (active)
x=86: listview/treeview selection bar back color (active)
x=88: listview/treeview selection bar text color (inactive)
x=90: listview/treeview selection bar back color (inactive)
x=92: alternate item background
x=94: alternate item foreground
*/
#define DCW_SUNKENBORDER 0x00010000
#define DCW_DIVIDER 0x00020000
enum
{
WADLG_ITEMBG,
WADLG_ITEMFG,
WADLG_WNDBG,
WADLG_BUTTONFG,
WADLG_WNDFG,
WADLG_HILITE,
WADLG_SELCOLOR,
WADLG_LISTHEADER_BGCOLOR,
WADLG_LISTHEADER_FONTCOLOR,
WADLG_LISTHEADER_FRAME_TOPCOLOR,
WADLG_LISTHEADER_FRAME_MIDDLECOLOR,
WADLG_LISTHEADER_FRAME_BOTTOMCOLOR,
WADLG_LISTHEADER_EMPTY_BGCOLOR,
WADLG_SCROLLBAR_FGCOLOR,
WADLG_SCROLLBAR_BGCOLOR,
WADLG_SCROLLBAR_INV_FGCOLOR,
WADLG_SCROLLBAR_INV_BGCOLOR,
WADLG_SCROLLBAR_DEADAREA_COLOR,
WADLG_SELBAR_FGCOLOR,
WADLG_SELBAR_BGCOLOR,
WADLG_INACT_SELBAR_FGCOLOR,
WADLG_INACT_SELBAR_BGCOLOR,
WADLG_ITEMBG2,
WADLG_ITEMFG2,
WADLG_NUM_COLORS
};
typedef enum _WACURSOR // used in IPC_GETSKINCURSORS
{
WACURSOR_VOLUME = 0, // volume & balane
WACURSOR_POSITION = 1, // position
WACURSOR_BTN_WINSHADE = 2, // winshade
WACURSOR_BTN_MINIMIZE = 3, // minimize
WACURSOR_BTN_CLOSE = 4, // close
WACURSOR_MENU = 5, // main menu
WACURSOR_TITLEBAR = 6, // title bar
WACURSOR_SONGNAME = 7,
WACURSOR_NORMAL = 8,
WACURSOR_WINSHADE_BTN_WINSHADE = 9,
WACURSOR_WINSHADE_BTN_MINIMIZE = 10,
WACURSOR_WINSHADE_POSITION = 11,
WACURSOR_WINSHADE_BTN_CLOSE = 12,
WACURSOR_WINSHADE_MENU = 13,
WACURSOR_WINSHADE_NORMAL = 14,
WACURSOR_PL_BTN_WINSHADE = 15,
WACURSOR_PL_BTN_CLOSE = 16,
WACURSOR_PL_TITLEBAR = 17,
WACURSOR_PL_VSCROLL = 18,
WACURSOR_PL_RESIZE = 19,
WACURSOR_PL_NORMAL = 20,
WACURSOR_PL_WINSHADE_BTN_WINSHADE = 21,
WACURSOR_PL_WINSHADE_BTN_CLOSE = 22,
WACURSOR_PL_WINSHADE_HSIZE = 23,
WACURSOR_PL_WINSHADE_NORMAL = 24,
WACURSOR_EQ_SLIDER = 25,
WACURSOR_EQ_BTN_CLOSE = 26,
WACURSOR_EQ_TITLEBAR = 27,
WACURSOR_EQ_NORMAL = 28,
} WACURSOR;
void WADlg_init(HWND hwndWinamp); // call this on init, or on WM_DISPLAYCHANGE
void WADlg_close();
int WADlg_getColor(int idx);
int WADlg_initted();
LRESULT WADlg_handleDialogMsgs(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); //
void WADlg_DrawChildWindowBorders(HWND hwndDlg, int *tab, int tabsize); // each entry in tab would be the id | DCW_*
HBITMAP WADlg_getBitmap();
/// define WA_DLG_IMPLEMENT in one of your source files before including this .h
// if you are making a media library plugin, you dont need to do this, look at view_ex for
// an example of how to get the function *'s via an IPC message.
#ifdef __cplusplus
}
#endif
#ifdef WA_DLG_IMPLEMENT
static HBRUSH wadlg_lastbrush=0;
static HBITMAP wadlg_bitmap=0; // load this manually
static int wadlg_colors[WADLG_NUM_COLORS];
static int wadlg_defcolors[WADLG_NUM_COLORS]=
{
RGB(0,0,0),
RGB(0,255,0),
RGB(36,36,60),
RGB(57,56,66),
RGB(255,255,255),
RGB(132,148,165),
RGB(0,0,198),
RGB(36*2,36*2,60*2),
RGB(255,255,255),
RGB(36*3,36*3,60*3),
RGB(36,36,60),
RGB(36*0.5,36*0.5,60*0.5),
RGB(36,36,60),
RGB(36*1,36*1,60*1),
RGB(36*1,36*1,60*1),
RGB(121,130,150),
RGB(78,88,110),
RGB(36*1,36*1,60*1),
RGB(255,255,255),
RGB(0,0,180),
RGB(0,255,0),
RGB(0,0,128),
RGB(0,0,0),
RGB(0,255,0),
};
int WADlg_initted()
{
return !!wadlg_bitmap;
}
int WADlg_getColor(int idx)
{
if (idx < 0 || idx >= WADLG_NUM_COLORS) return 0;
return wadlg_colors[idx];
}
HBITMAP WADlg_getBitmap()
{
return wadlg_bitmap;
}
void WADlg_init(HWND hwndWinamp) // call this on init, or on WM_DISPLAYCHANGE
{
if (wadlg_bitmap) DeleteObject(wadlg_bitmap);
wadlg_bitmap = (HBITMAP) SendMessage(hwndWinamp,WM_WA_IPC,0,IPC_GET_GENSKINBITMAP);
if (wadlg_bitmap)
{
HDC tmpDC=CreateCompatibleDC(NULL);
HGDIOBJ o=SelectObject(tmpDC,(HGDIOBJ)wadlg_bitmap);
int defbgcol=GetPixel(tmpDC,111,0);
for (int x = 0; x < WADLG_NUM_COLORS; x ++)
{
int a=GetPixel(tmpDC,48+x*2,0);
if (a == CLR_INVALID || a == RGB(0,198,255) || a == defbgcol)
{
//defaults for old skins
if (x == WADLG_SELBAR_FGCOLOR || x == WADLG_INACT_SELBAR_FGCOLOR) a=wadlg_colors[WADLG_WNDFG];
else if (x == WADLG_SELBAR_BGCOLOR || x == WADLG_INACT_SELBAR_BGCOLOR)
{
a=wadlg_colors[WADLG_SELCOLOR];
if (x == WADLG_INACT_SELBAR_BGCOLOR)
a=((a/2)&0x7F7F7F)+(((wadlg_colors[WADLG_WNDBG])/2)&0x7F7F7F);
}
else if (x == WADLG_ITEMBG2)
{
a=wadlg_colors[WADLG_ITEMBG];
}
else if (x == WADLG_ITEMFG2)
{
a=wadlg_colors[WADLG_ITEMFG];
}
else a=wadlg_defcolors[x];
}
wadlg_colors[x]=a;
}
SelectObject(tmpDC,o);
DeleteDC(tmpDC);
}
}
void WADlg_close()
{
if (wadlg_bitmap) DeleteObject(wadlg_bitmap);
wadlg_bitmap=0;
if (wadlg_lastbrush) DeleteObject(wadlg_lastbrush);
wadlg_lastbrush=0;
}
void WADlg_dotLine(HDC hdc, int left, int top, int len, int vert)
{
for(int i=(top&1);i<len-1;i+=2)
{
if(vert)
{
MoveToEx(hdc,left,top+i,NULL);
LineTo(hdc,left,top+i+1);
}
else
{
MoveToEx(hdc,left+i,top,NULL);
LineTo(hdc,left+i+1,top);
}
}
}
LRESULT WADlg_handleDialogMsgs(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (uMsg == WM_DRAWITEM)
{
DRAWITEMSTRUCT *di = (DRAWITEMSTRUCT *)lParam;
if (di->CtlType == ODT_BUTTON) {
wchar_t wt[256];
RECT r;
GetDlgItemTextW(hwndDlg,(INT)wParam,wt,sizeof(wt)/sizeof(*wt));
HDC hdc = CreateCompatibleDC(di->hDC);
HBITMAP hbmpOld = (HBITMAP)SelectObject(hdc, wadlg_bitmap);
r=di->rcItem;
SetStretchBltMode(di->hDC,COLORONCOLOR);
int yoffs = (di->itemState & ODS_SELECTED) ? 15 : 0;
BitBlt(di->hDC,r.left,r.top,4,4,hdc,0,yoffs,SRCCOPY); // top left
StretchBlt(di->hDC,r.left+4,r.top,r.right-r.left-4-4,4,hdc,4,yoffs,47-4-4,4,SRCCOPY); // top center
BitBlt(di->hDC,r.right-4,r.top,4,4,hdc,47-4,yoffs,SRCCOPY); // top right
StretchBlt(di->hDC,r.left,r.top+4,4,r.bottom-r.top-4-4,hdc,0,4+yoffs,4,15-4-4,SRCCOPY); // left edge
StretchBlt(di->hDC,r.right-4,r.top+4,4,r.bottom-r.top-4-4,hdc,47-4,4+yoffs,4,15-4-4,SRCCOPY); // right edge
// center
StretchBlt(di->hDC,r.left+4,r.top+4,r.right-r.left-4-4,r.bottom-r.top-4-4,hdc,4,4+yoffs,47-4-4,15-4-4,SRCCOPY);
BitBlt(di->hDC,r.left,r.bottom-4,4,4,hdc,0,15-4+yoffs,SRCCOPY); // bottom left
StretchBlt(di->hDC,r.left+4,r.bottom-4,r.right-r.left-4-4,4,hdc,4,15-4+yoffs,47-4-4,4,SRCCOPY); // bottom center
BitBlt(di->hDC,r.right-4,r.bottom-4,4,4,hdc,47-4,15-4+yoffs,SRCCOPY); // bottom right
// draw text
SetBkMode(di->hDC,TRANSPARENT);
// this will do a different style for the button text depending on enabled state of the button
COLORREF colour = wadlg_colors[WADLG_BUTTONFG];
if(!IsWindowEnabled(di->hwndItem)){
COLORREF fg = wadlg_colors[WADLG_WNDFG],
bg = wadlg_colors[WADLG_WNDBG];
colour = RGB((GetRValue(fg)+GetRValue(bg))/2,
(GetGValue(fg)+GetGValue(bg))/2,
(GetBValue(fg)+GetBValue(bg))/2);
}
SetTextColor(di->hDC,colour);
if (di->itemState & ODS_SELECTED) {r.left+=2; r.top+=2;}
DrawTextW(di->hDC,wt,-1,&r,DT_VCENTER|DT_SINGLELINE|DT_CENTER);
SelectObject(hdc, hbmpOld);
DeleteDC(hdc);
if(GetFocus()==di->hwndItem) {
HPEN hpen, hpenOld;
hpen =CreatePen(PS_SOLID,0,RGB(0,0,0));
hpenOld = (HPEN)SelectObject(di->hDC, hpen);
WADlg_dotLine(di->hDC,r.left+2,r.top+2,r.right-r.left-3,0);
WADlg_dotLine(di->hDC,r.right-3,r.top+2,r.bottom-r.top-3,1);
WADlg_dotLine(di->hDC,r.left+2,r.top+2,r.bottom-r.top-3,1);
WADlg_dotLine(di->hDC,r.left+2,r.bottom-3,r.right-r.left-3,0);
SelectObject(di->hDC, hpenOld);
DeleteObject(hpen);
}
}
}
switch(uMsg)
{
case WM_CTLCOLORLISTBOX:
case WM_CTLCOLORDLG:
case WM_CTLCOLORBTN:
case WM_CTLCOLORSTATIC:
case WM_CTLCOLOREDIT:
{
int bgcolor=(uMsg == WM_CTLCOLOREDIT || uMsg == WM_CTLCOLORLISTBOX) ? wadlg_colors[WADLG_ITEMBG] : (uMsg == WM_CTLCOLORBTN ? wadlg_colors[WADLG_ITEMBG] : wadlg_colors[WADLG_WNDBG]);
LOGBRUSH lb={BS_SOLID,GetNearestColor((HDC)wParam,bgcolor)};
if (wadlg_lastbrush) DeleteObject(wadlg_lastbrush);
wadlg_lastbrush=CreateBrushIndirect(&lb);
SetTextColor((HDC)wParam,uMsg == WM_CTLCOLORSTATIC ? wadlg_colors[WADLG_WNDFG] : wadlg_colors[WADLG_ITEMFG]);
SetBkColor((HDC)wParam,lb.lbColor);
return (LRESULT)wadlg_lastbrush;
}
}
return 0;
}
static int RectInRect(RECT *rect1, RECT *rect2)
{
// this has a bias towards true
// this could probably be optimized a lot
return ((rect1->top >= rect2->top && rect1->top <= rect2->bottom) ||
(rect1->bottom >= rect2->top && rect1->bottom <= rect2->bottom) ||
(rect2->top >= rect1->top && rect2->top <= rect1->bottom) ||
(rect2->bottom >= rect1->top && rect2->bottom <= rect1->bottom)) // vertical intersect
&&
((rect1->left >= rect2->left && rect1->left <= rect2->right) ||
(rect1->right >= rect2->left && rect1->right <= rect2->right) ||
(rect2->left >= rect1->left && rect2->left <= rect1->right) ||
(rect2->right >= rect1->left && rect2->right <= rect1->right)) // horiz intersect
;
}
static void WADlg_removeFromRgn(HRGN hrgn, int left, int top, int right, int bottom)
{
HRGN rgn2=CreateRectRgn(left,top,right,bottom);
CombineRgn(hrgn,hrgn,rgn2,RGN_DIFF);
DeleteObject(rgn2);
}
void WADlg_DrawChildWindowBorders(HWND hwndDlg, int *tab, int tabsize)
{
PAINTSTRUCT ps;
BeginPaint(hwndDlg,&ps);
HRGN hrgn = (ps.fErase) ? CreateRectRgnIndirect(&ps.rcPaint) : NULL;
HPEN pen = CreatePen(PS_SOLID, 0, wadlg_colors[WADLG_HILITE]);
HGDIOBJ o = SelectObject(ps.hdc, pen);
while (tabsize--)
{
RECT r;
int a = *tab++;
GetWindowRect(GetDlgItem(hwndDlg, a & 0xffff),&r);
MapWindowPoints(HWND_DESKTOP, hwndDlg, (LPPOINT)&r, 2);
if (RectInRect(&ps.rcPaint,&r))
{
if ((a & 0xffff0000) == DCW_SUNKENBORDER)
{
MoveToEx(ps.hdc,r.left,r.bottom,NULL);
LineTo(ps.hdc,r.right,r.bottom);
LineTo(ps.hdc,r.right,r.top-1);
if(hrgn)
{
WADlg_removeFromRgn(hrgn,r.left,r.bottom,r.right,r.bottom+1);
WADlg_removeFromRgn(hrgn,r.right,r.top,r.right+1,r.bottom);
}
}
else if ((a & 0xffff0000) == DCW_DIVIDER)
{
if (r.right - r.left < r.bottom - r.top) // vertical
{
int left=(r.left+r.right)/2;
MoveToEx(ps.hdc,left,r.top,NULL);
LineTo(ps.hdc,left,r.bottom+1);
if(hrgn) WADlg_removeFromRgn(hrgn,left,r.top,left+1,r.bottom);
}
else // horiz
{
int top=(r.top+r.bottom)/2;
MoveToEx(ps.hdc,r.left,top,NULL);
LineTo(ps.hdc,r.right+1,top);
if(hrgn) WADlg_removeFromRgn(hrgn,r.left,top,r.right,top+1);
}
}
}
}
SelectObject(ps.hdc, o);
DeleteObject(pen);
if(hrgn)
{
//erase bkgnd while clipping out our own drawn stuff (for flickerless display)
HBRUSH b = CreateSolidBrush(wadlg_colors[WADLG_WNDBG]);
FillRgn(ps.hdc,hrgn,b);
DeleteObject(b);
DeleteObject(hrgn);
}
EndPaint(hwndDlg,&ps);
}
#endif
#endif//_WA_DLG_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,73 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_SDK", "foobar2000\SDK\foobar2000_SDK.vcproj", "{E8091321-D79D-4575-86EF-064EA1A4A20D}"
ProjectSection(ProjectDependencies) = postProject
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C} = {EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_ATL_helpers", "foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcproj", "{622E8B19-8109-4717-BD4D-9657AA78363E}"
ProjectSection(ProjectDependencies) = postProject
{E8091321-D79D-4575-86EF-064EA1A4A20D} = {E8091321-D79D-4575-86EF-064EA1A4A20D}
{EE47764E-A202-4F85-A767-ABDAB4AFF35F} = {EE47764E-A202-4F85-A767-ABDAB4AFF35F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_component_client", "foobar2000\foobar2000_component_client\foobar2000_component_client.vcproj", "{71AD2674-065B-48F5-B8B0-E1F9D3892081}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "foobar2000_sdk_helpers", "foobar2000\helpers\foobar2000_sdk_helpers.vcproj", "{EE47764E-A202-4F85-A767-ABDAB4AFF35F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pfc", "pfc\pfc.vcproj", "{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.ActiveCfg = Debug|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|Win32.Build.0 = Debug|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.ActiveCfg = Debug|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Debug|x64.Build.0 = Debug|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.ActiveCfg = Release|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|Win32.Build.0 = Release|Win32
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.ActiveCfg = Release|x64
{E8091321-D79D-4575-86EF-064EA1A4A20D}.Release|x64.Build.0 = Release|x64
{622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|Win32.ActiveCfg = Debug|Win32
{622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|Win32.Build.0 = Debug|Win32
{622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|x64.ActiveCfg = Debug|x64
{622E8B19-8109-4717-BD4D-9657AA78363E}.Debug|x64.Build.0 = Debug|x64
{622E8B19-8109-4717-BD4D-9657AA78363E}.Release|Win32.ActiveCfg = Release|Win32
{622E8B19-8109-4717-BD4D-9657AA78363E}.Release|Win32.Build.0 = Release|Win32
{622E8B19-8109-4717-BD4D-9657AA78363E}.Release|x64.ActiveCfg = Release|x64
{622E8B19-8109-4717-BD4D-9657AA78363E}.Release|x64.Build.0 = Release|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.ActiveCfg = Debug|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|Win32.Build.0 = Debug|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.ActiveCfg = Debug|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Debug|x64.Build.0 = Debug|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.ActiveCfg = Release|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|Win32.Build.0 = Release|Win32
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.ActiveCfg = Release|x64
{71AD2674-065B-48F5-B8B0-E1F9D3892081}.Release|x64.Build.0 = Release|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.ActiveCfg = Debug|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|Win32.Build.0 = Debug|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.ActiveCfg = Debug|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Debug|x64.Build.0 = Debug|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.ActiveCfg = Release|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|Win32.Build.0 = Release|Win32
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.ActiveCfg = Release|x64
{EE47764E-A202-4F85-A767-ABDAB4AFF35F}.Release|x64.Build.0 = Release|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.ActiveCfg = Debug|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|Win32.Build.0 = Debug|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.ActiveCfg = Debug|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Debug|x64.Build.0 = Debug|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.ActiveCfg = Release|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|Win32.Build.0 = Release|Win32
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.ActiveCfg = Release|x64
{EBFFFB4E-261D-44D3-B89C-957B31A0BF9C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -1,17 +0,0 @@
#include "foobar2000.h"
void abort_callback::check() const {
if (is_aborting()) throw exception_aborted();
}
void abort_callback::sleep(double p_timeout_seconds) const {
if (!sleep_ex(p_timeout_seconds)) throw exception_aborted();
}
bool abort_callback::sleep_ex(double p_timeout_seconds) const {
#ifdef _WIN32
return !win32_event::g_wait_for(get_abort_event(),p_timeout_seconds);
#else
#error PORTME
#endif
}

View File

@ -1,76 +0,0 @@
#ifndef _foobar2000_sdk_abort_callback_h_
#define _foobar2000_sdk_abort_callback_h_
namespace foobar2000_io {
PFC_DECLARE_EXCEPTION(exception_aborted,pfc::exception,"User abort");
#ifdef _WIN32
typedef HANDLE abort_callback_event;
#else
#error PORTME
#endif
//! This class is used to signal underlying worker code whether user has decided to abort a potentially time-consuming operation. It is commonly required by all file related operations. Code that receives an abort_callback object should periodically check it and abort any operations being performed if it is signaled, typically throwing exception_aborted. \n
//! See abort_callback_impl for an implementation.
class NOVTABLE abort_callback
{
public:
//! Returns whether user has requested the operation to be aborted.
virtual bool is_aborting() const = 0;
//! Retrieves event object that can be used with some OS calls. The even object becomes signaled when abort is triggered. On win32, this is equivalent to win32 event handle (see: CreateEvent). \n
//! You must not close this handle or call any methods that change this handle's state (SetEvent() or ResetEvent()), you can only wait for it.
virtual abort_callback_event get_abort_event() const = 0;
//! Checks if user has requested the operation to be aborted, and throws exception_aborted if so.
void check() const;
//! For compatibility with old code. Do not call.
inline void check_e() const {check();}
//! Sleeps p_timeout_seconds or less when aborted, throws exception_aborted on abort.
void sleep(double p_timeout_seconds) const;
//! Sleeps p_timeout_seconds or less when aborted, returns true when execution should continue, false when not.
bool sleep_ex(double p_timeout_seconds) const;
protected:
abort_callback() {}
~abort_callback() {}
};
//! Implementation of abort_callback interface.
class abort_callback_impl : public abort_callback {
public:
abort_callback_impl() : m_aborting(false) {
m_event.create(true,false);
}
inline void abort() {set_state(true);}
inline void reset() {set_state(false);}
void set_state(bool p_state) {m_aborting = p_state; m_event.set_state(p_state);}
bool is_aborting() const {return m_aborting;}
abort_callback_event get_abort_event() const {return m_event.get();}
private:
abort_callback_impl(const abort_callback_impl &) {throw pfc::exception_not_implemented();}
const abort_callback_impl & operator=(const abort_callback_impl&) {throw pfc::exception_not_implemented();}
volatile bool m_aborting;
#ifdef WIN32
win32_event m_event;
#endif
};
//! Dummy abort_callback that never gets aborted. To be possibly optimized in the future.
typedef abort_callback_impl abort_callback_dummy;
}
using namespace foobar2000_io;
#endif //_foobar2000_sdk_abort_callback_h_

View File

@ -1,266 +0,0 @@
//! Entrypoint class for adding items to Advanced Preferences page. \n
//! Implementations must derive from one of subclasses: advconfig_branch, advconfig_entry_checkbox, advconfig_entry_string. \n
//! Implementations are typically registered using static service_factory_single_t<myclass>, or using provided helper classes in case of standard implementations declared in this header.
class NOVTABLE advconfig_entry : public service_base {
public:
virtual void get_name(pfc::string_base & p_out) = 0;
virtual GUID get_guid() = 0;
virtual GUID get_parent() = 0;
virtual void reset() = 0;
virtual double get_sort_priority() = 0;
static bool g_find(service_ptr_t<advconfig_entry>& out, const GUID & id) {
service_enum_t<advconfig_entry> e; service_ptr_t<advconfig_entry> ptr; while(e.next(ptr)) { if (ptr->get_guid() == id) {out = ptr; return true;} } return false;
}
static const GUID guid_root;
static const GUID guid_branch_tagging,guid_branch_decoding,guid_branch_tools,guid_branch_playback,guid_branch_display;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(advconfig_entry);
};
//! Creates a new branch in Advanced Preferences. \n
//! Implementation: see advconfig_branch_impl / advconfig_branch_factory.
class NOVTABLE advconfig_branch : public advconfig_entry {
public:
FB2K_MAKE_SERVICE_INTERFACE(advconfig_branch,advconfig_entry);
};
//! Creates a checkbox/radiocheckbox entry in Advanced Preferences. \n
//! The difference between checkboxes and radiocheckboxes is different icon (obviously) and that checking a radiocheckbox unchecks all other radiocheckboxes in the same branch. \n
//! Implementation: see advconfig_entry_checkbox_impl / advconfig_checkbox_factory_t.
class NOVTABLE advconfig_entry_checkbox : public advconfig_entry {
public:
virtual bool get_state() = 0;
virtual void set_state(bool p_state) = 0;
virtual bool is_radio() = 0;
FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_checkbox,advconfig_entry);
};
//! Creates a string/integer editbox entry in Advanced Preferences.\n
//! Implementation: see advconfig_entry_string_impl / advconfig_string_factory.
class NOVTABLE advconfig_entry_string : public advconfig_entry {
public:
virtual void get_state(pfc::string_base & p_out) = 0;
virtual void set_state(const char * p_string,t_size p_length = infinite) = 0;
virtual t_uint32 get_flags() = 0;
enum {
flag_is_integer = 1 << 0,
flag_is_signed = 1 << 1,
};
FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_string,advconfig_entry);
};
//! Standard implementation of advconfig_branch. \n
//! Usage: no need to use this class directly - use advconfig_branch_factory instead.
class advconfig_branch_impl : public advconfig_branch {
public:
advconfig_branch_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority) : m_name(p_name), m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {}
void get_name(pfc::string_base & p_out) {p_out = m_name;}
GUID get_guid() {return m_guid;}
GUID get_parent() {return m_parent;}
void reset() {}
double get_sort_priority() {return m_priority;}
private:
pfc::string8 m_name;
GUID m_guid,m_parent;
const double m_priority;
};
//! Standard implementation of advconfig_entry_checkbox. \n
//! p_is_radio parameter controls whether we're implementing a checkbox or a radiocheckbox (see advconfig_entry_checkbox description for more details).
template<bool p_is_radio = false>
class advconfig_entry_checkbox_impl : public advconfig_entry_checkbox {
public:
advconfig_entry_checkbox_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate)
: m_name(p_name), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate), m_parent(p_parent), m_priority(p_priority) {}
void get_name(pfc::string_base & p_out) {p_out = m_name;}
GUID get_guid() {return m_state.get_guid();}
GUID get_parent() {return m_parent;}
void reset() {m_state = m_initialstate;}
bool get_state() {return m_state;}
void set_state(bool p_state) {m_state = p_state;}
bool is_radio() {return p_is_radio;}
double get_sort_priority() {return m_priority;}
bool get_state_() const {return m_state;}
private:
pfc::string8 m_name;
const bool m_initialstate;
cfg_bool m_state;
GUID m_parent;
const double m_priority;
};
//! Service factory helper around standard advconfig_branch implementation. Use this class to register your own Advanced Preferences branches. \n
//! Usage: static advconfig_branch_factory mybranch(name, branchID, parentBranchID, priority);
class advconfig_branch_factory : public service_factory_single_t<advconfig_branch_impl> {
public:
advconfig_branch_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority)
: service_factory_single_t<advconfig_branch_impl>(p_name,p_guid,p_parent,p_priority) {}
};
//! Service factory helper around standard advconfig_entry_checkbox implementation. Use this class to register your own Advanced Preferences checkbox/radiocheckbox entries. \n
//! Usage: static advconfig_entry_checkbox<isRadioBox> mybox(name, itemID, parentID, priority, initialstate);
template<bool p_is_radio>
class advconfig_checkbox_factory_t : public service_factory_single_t<advconfig_entry_checkbox_impl<p_is_radio> > {
public:
advconfig_checkbox_factory_t(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate)
: service_factory_single_t<advconfig_entry_checkbox_impl<p_is_radio> >(p_name,p_guid,p_parent,p_priority,p_initialstate) {}
bool get() const {return get_static_instance().get_state_();}
void set(bool val) {get_static_instance().set_state(val);}
operator bool() const {return get();}
bool operator=(bool val) {set(val); return val;}
};
//! Service factory helper around standard advconfig_entry_checkbox implementation, specialized for checkboxes (rather than radiocheckboxes). See advconfig_checkbox_factory_t<> for more details.
typedef advconfig_checkbox_factory_t<false> advconfig_checkbox_factory;
//! Service factory helper around standard advconfig_entry_checkbox implementation, specialized for radiocheckboxes (rather than standard checkboxes). See advconfig_checkbox_factory_t<> for more details.
typedef advconfig_checkbox_factory_t<true> advconfig_radio_factory;
//! Standard advconfig_entry_string implementation. Use advconfig_string_factory to register your own string entries in Advanced Preferences instead of using this class directly.
class advconfig_entry_string_impl : public advconfig_entry_string {
public:
advconfig_entry_string_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate)
: m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate) {}
void get_name(pfc::string_base & p_out) {p_out = m_name;}
GUID get_guid() {return m_state.get_guid();}
GUID get_parent() {return m_parent;}
void reset() {core_api::ensure_main_thread();m_state = m_initialstate;}
double get_sort_priority() {return m_priority;}
void get_state(pfc::string_base & p_out) {core_api::ensure_main_thread();p_out = m_state;}
void set_state(const char * p_string,t_size p_length = infinite) {core_api::ensure_main_thread();m_state.set_string(p_string,p_length);}
t_uint32 get_flags() {return 0;}
private:
const pfc::string8 m_initialstate, m_name;
cfg_string m_state;
const double m_priority;
const GUID m_parent;
};
//! Service factory helper around standard advconfig_entry_string implementation. Use this class to register your own string entries in Advanced Preferences. \n
//! Usage: static advconfig_string_factory mystring(name, itemID, branchID, priority, initialValue);
class advconfig_string_factory : public service_factory_single_t<advconfig_entry_string_impl> {
public:
advconfig_string_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate)
: service_factory_single_t<advconfig_entry_string_impl>(p_name,p_guid,p_parent,p_priority,p_initialstate) {}
void get(pfc::string_base & out) {get_static_instance().get_state(out);}
void set(const char * in) {get_static_instance().set_state(in);}
};
//! Special advconfig_entry_string implementation - implements integer entries. Use advconfig_integer_factory to register your own integer entries in Advanced Preferences instead of using this class directly.
class advconfig_entry_integer_impl : public advconfig_entry_string {
public:
advconfig_entry_integer_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,t_uint64 p_initialstate,t_uint64 p_min,t_uint64 p_max)
: m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initval(p_initialstate), m_min(p_min), m_max(p_max), m_state(p_guid,p_initialstate) {}
void get_name(pfc::string_base & p_out) {p_out = m_name;}
GUID get_guid() {return m_state.get_guid();}
GUID get_parent() {return m_parent;}
void reset() {m_state = m_initval;}
double get_sort_priority() {return m_priority;}
void get_state(pfc::string_base & p_out) {p_out = pfc::format_uint(m_state.get_value());}
void set_state(const char * p_string,t_size p_length) {set_state_int(pfc::atoui64_ex(p_string,p_length));}
t_uint32 get_flags() {return advconfig_entry_string::flag_is_integer;}
t_uint64 get_state_int() const {return m_state;}
void set_state_int(t_uint64 val) {m_state = pfc::clip_t<t_uint64>(val,m_min,m_max);}
private:
cfg_int_t<t_uint64> m_state;
const double m_priority;
const t_uint64 m_initval, m_min, m_max;
const GUID m_parent;
const pfc::string8 m_name;
};
//! Service factory helper around integer-specialized advconfig_entry_string implementation. Use this class to register your own integer entries in Advanced Preferences. \n
//! Usage: static advconfig_integer_factory myint(name, itemID, parentID, priority, initialValue, minValue, maxValue);
class advconfig_integer_factory : public service_factory_single_t<advconfig_entry_integer_impl> {
public:
advconfig_integer_factory(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,t_uint64 p_initialstate,t_uint64 p_min,t_uint64 p_max)
: service_factory_single_t<advconfig_entry_integer_impl>(p_name,p_guid,p_parent,p_priority,p_initialstate,p_min,p_max) {}
t_uint64 get() const {return get_static_instance().get_state_int();}
void set(t_uint64 val) {get_static_instance().set_state_int(val);}
operator t_uint64() const {return get();}
t_uint64 operator=(t_uint64 val) {set(val); return val;}
};
//! Not currently used, reserved for future use.
class NOVTABLE advconfig_entry_enum : public advconfig_entry {
public:
virtual t_size get_value_count() = 0;
virtual void enum_value(pfc::string_base & p_out,t_size p_index) = 0;
virtual t_size get_state() = 0;
virtual void set_state(t_size p_value) = 0;
FB2K_MAKE_SERVICE_INTERFACE(advconfig_entry_enum,advconfig_entry);
};
//! Special version if advconfig_entry_string_impl that allows the value to be retrieved from worker threads.
class advconfig_entry_string_impl_MT : public advconfig_entry_string {
public:
advconfig_entry_string_impl_MT(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate)
: m_name(p_name), m_parent(p_parent), m_priority(p_priority), m_initialstate(p_initialstate), m_state(p_guid,p_initialstate) {}
void get_name(pfc::string_base & p_out) {p_out = m_name;}
GUID get_guid() {return m_state.get_guid();}
GUID get_parent() {return m_parent;}
void reset() {
insync(m_sync);
m_state = m_initialstate;
}
double get_sort_priority() {return m_priority;}
void get_state(pfc::string_base & p_out) {
insync(m_sync);
p_out = m_state;
}
void set_state(const char * p_string,t_size p_length = infinite) {
insync(m_sync);
m_state.set_string(p_string,p_length);
}
t_uint32 get_flags() {return 0;}
private:
const pfc::string8 m_initialstate, m_name;
cfg_string m_state;
critical_section m_sync;
const double m_priority;
const GUID m_parent;
};
//! Special version if advconfig_string_factory that allows the value to be retrieved from worker threads.
class advconfig_string_factory_MT : public service_factory_single_t<advconfig_entry_string_impl_MT> {
public:
advconfig_string_factory_MT(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,const char * p_initialstate)
: service_factory_single_t<advconfig_entry_string_impl_MT>(p_name,p_guid,p_parent,p_priority,p_initialstate) {}
void get(pfc::string_base & out) {get_static_instance().get_state(out);}
void set(const char * in) {get_static_instance().set_state(in);}
};
/*
Advanced Preferences variable declaration examples
static advconfig_string_factory mystring("name goes here",myguid,parentguid,0,"asdf");
to retrieve state: pfc::string8 val; mystring.get(val);
static advconfig_checkbox_factory mycheckbox("name goes here",myguid,parentguid,0,false);
to retrieve state: mycheckbox.get();
static advconfig_integer_factory myint("name goes here",myguid,parentguid,0,initialValue,minimumValue,maximumValue);
to retrieve state: myint.get();
*/

View File

@ -1,17 +0,0 @@
#include "foobar2000.h"
bool album_art_editor::g_get_interface(service_ptr_t<album_art_editor> & out,const char * path) {
service_enum_t<album_art_editor> e; ptr ptr;
pfc::string_extension ext(path);
while(e.next(ptr)) {
if (ptr->is_our_path(path,ext)) {
out = ptr; return true;
}
}
return false;
}
bool album_art_editor::g_is_supported_path(const char * path) {
ptr ptr;
return g_get_interface(ptr,path);
}

View File

@ -1,222 +0,0 @@
//new in 0.9.5
//! Common class for handling picture data. \n
//! Type of contained picture data is unknown and to be determined according to memory block contents by code parsing/rendering the picture. Commonly encountered types are: BMP, PNG, JPEG and GIF. \n
//! Implementation: use album_art_data_impl.
class NOVTABLE album_art_data : public service_base {
public:
//! Retrieves a pointer to a memory block containing the picture.
virtual const void * get_ptr() const = 0;
//! Retrieves size of the memory block containing the picture.
virtual t_size get_size() const = 0;
//! Determine whether two album_art_data objects store the same picture data.
static bool equals(album_art_data const & v1, album_art_data const & v2) {
const t_size s = v1.get_size();
if (s != v2.get_size()) return false;
return memcmp(v1.get_ptr(), v2.get_ptr(),s) == 0;
}
bool operator==(const album_art_data & other) const {return equals(*this,other);}
bool operator!=(const album_art_data & other) const {return !equals(*this,other);}
FB2K_MAKE_SERVICE_INTERFACE(album_art_data,service_base);
};
typedef service_ptr_t<album_art_data> album_art_data_ptr;
//! Implements album_art_data.
class album_art_data_impl : public album_art_data {
public:
const void * get_ptr() const {return m_content.get_ptr();}
t_size get_size() const {return m_content.get_size();}
void * get_ptr() {return m_content.get_ptr();}
void set_size(t_size p_size) {m_content.set_size(p_size);}
//! Reads picture data from the specified stream object.
void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) {
set_size(p_bytes); p_stream->read_object(get_ptr(),p_bytes,p_abort);
}
//! Creates an album_art_data object from picture data contained in a memory buffer.
static album_art_data_ptr g_create(const void * p_buffer,t_size p_bytes) {
service_ptr_t<album_art_data_impl> instance = new service_impl_t<album_art_data_impl>();
instance->set_size(p_bytes);
memcpy(instance->get_ptr(),p_buffer,p_bytes);
return instance;
}
//! Creates an album_art_data object from picture data contained in a stream.
static album_art_data_ptr g_create(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) {
service_ptr_t<album_art_data_impl> instance = new service_impl_t<album_art_data_impl>();
instance->from_stream(p_stream,p_bytes,p_abort);
return instance;
}
private:
pfc::array_t<t_uint8> m_content;
};
//! Namespace containing identifiers of album art types.
namespace album_art_ids {
//! Front cover.
static const GUID cover_front = { 0xf1e66f4e, 0xfe09, 0x4b94, { 0x91, 0xa3, 0x67, 0xc2, 0x3e, 0xd1, 0x44, 0x5e } };
//! Back cover.
static const GUID cover_back = { 0xcb552d19, 0x86d5, 0x434c, { 0xac, 0x77, 0xbb, 0x24, 0xed, 0x56, 0x7e, 0xe4 } };
//! Picture of a disc or other storage media.
static const GUID disc = { 0x3dba9f36, 0xf928, 0x4fa4, { 0x87, 0x9c, 0xd3, 0x40, 0x47, 0x59, 0x58, 0x7e } };
//! Album-specific icon (NOT a file type icon).
static const GUID icon = { 0x74cdf5b4, 0x7053, 0x4b3d, { 0x9a, 0x3c, 0x54, 0x69, 0xf5, 0x82, 0x6e, 0xec } };
};
PFC_DECLARE_EXCEPTION(exception_album_art_not_found,exception_io_not_found,"Album Art Not Found");
PFC_DECLARE_EXCEPTION(exception_album_art_unsupported_entry,exception_io_data,"Unsupported Album Art Entry");
//! Class encapsulating access to album art stored in a media file. Use album_art_extractor class obtain album_art_extractor_instance referring to specified media file.
class NOVTABLE album_art_extractor_instance : public service_base {
public:
//! Throws exception_album_art_not_found when the requested album art entry could not be found in the referenced media file.
virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(album_art_extractor_instance,service_base);
};
//! Class encapsulating access to album art stored in a media file. Use album_art_editor class to obtain album_art_editor_instance referring to specified media file.
class NOVTABLE album_art_editor_instance : public album_art_extractor_instance {
public:
//! Throws exception_album_art_unsupported_entry when the file format we're dealing with does not support specific entry.
virtual void set(const GUID & p_what,album_art_data_ptr p_data,abort_callback & p_abort) = 0;
//! Removes the requested entry. Fails silently when the entry doesn't exist.
virtual void remove(const GUID & p_what) = 0;
//! Finalizes file tag update operation.
virtual void commit(abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(album_art_editor_instance,album_art_extractor_instance);
};
typedef service_ptr_t<album_art_extractor_instance> album_art_extractor_instance_ptr;
typedef service_ptr_t<album_art_editor_instance> album_art_editor_instance_ptr;
//! Entrypoint class for accessing album art extraction functionality. Register your own implementation to allow album art extraction from your media file format. \n
//! If you want to extract album art from a media file, it's recommended that you use album_art_manager API instead of calling album_art_extractor directly.
class NOVTABLE album_art_extractor : public service_base {
public:
//! Returns whether the specified file is one of formats supported by our album_art_extractor implementation.
//! @param p_path Path to file being queried.
//! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons.
virtual bool is_our_path(const char * p_path,const char * p_extension) = 0;
//! Instantiates album_art_extractor_instance providing access to album art stored in a specified media file. \n
//! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all.
//! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally.
virtual album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_extractor);
};
//! Entrypoint class for accessing album art editing functionality. Register your own implementation to allow album art editing on your media file format.
class NOVTABLE album_art_editor : public service_base {
public:
//! Returns whether the specified file is one of formats supported by our album_art_editor implementation.
//! @param p_path Path to file being queried.
//! @param p_extension Extension of file being queried (also present in p_path parameter) - provided as a separate parameter for performance reasons.
virtual bool is_our_path(const char * p_path,const char * p_extension) = 0;
//! Instantiates album_art_editor_instance providing access to album art stored in a specified media file. \n
//! @param p_filehint Optional; specifies a file interface to use for accessing the specified file; can be null - in that case, the implementation will open and close the file internally.
virtual album_art_editor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) = 0;
//! Helper; attempts to retrieve an album_art_editor service pointer that supports the specified file.
//! @returns True on success, false on failure (no registered album_art_editor supports this file type).
static bool g_get_interface(service_ptr_t<album_art_editor> & out,const char * path);
//! Helper; returns whether one of registered album_art_editor implementations is capable of opening the specified file.
static bool g_is_supported_path(const char * path);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_editor);
};
//! Primary API for interfacing with foobar2000 core's album art extraction functionality. \n
//! Use static_api_ptr_t<album_art_manager>()->instantiate() to obtain a pointer to album_art_manager_instance. \n
//! The main difference between using album_art_manager_instance and calling album_art_extractor methods directly is that
//! album_art_manager_instance will fall back to returning pictures found in the folder containing the specified media file
//! in case requested album art entries can't be extracted from the media file itself.
class NOVTABLE album_art_manager_instance : public service_base {
public:
//! @returns True when the newly requested file has different album art than the old one, false when album art we're referencing is the same as before.
virtual bool open(const char * p_file,abort_callback & p_abort) = 0;
//! Resets internal data.
virtual void close() = 0;
//! Queries album art data for currently open media file. Throws exception_album_art_not_found when the requested album art entry isn't present.
virtual album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) = 0;
//! Queries for stub image to display when there's no album art to show. \n
//! May fail with exception_album_art_not_found as well when we have no stub image configured.
virtual album_art_data_ptr query_stub_image(abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(album_art_manager_instance,service_base);
};
typedef service_ptr_t<album_art_manager_instance> album_art_manager_instance_ptr;
//! Entrypoint API for accessing album art loading functionality provided by foobar2000 core. Usage: static_api_ptr_t<album_art_manager>. \n
//! This API was introduced in 0.9.5.
class NOVTABLE album_art_manager : public service_base {
public:
virtual album_art_manager_instance_ptr instantiate() = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(album_art_manager);
};
//! Helper - simple implementation of album_art_extractor_instance.
class album_art_extractor_instance_simple : public album_art_extractor_instance {
public:
void set(const GUID & p_what,album_art_data_ptr p_content) {m_content.set(p_what,p_content);}
bool have_item(const GUID & p_what) {return m_content.have_item(p_what);}
album_art_data_ptr query(const GUID & p_what,abort_callback & p_abort) {
album_art_data_ptr temp;
if (!m_content.query(p_what,temp)) throw exception_album_art_not_found();
return temp;
}
bool is_empty() const {return m_content.get_count() == 0;}
private:
pfc::map_t<GUID,album_art_data_ptr> m_content;
};
//! Helper API for extracting album art from APEv2 tags - introduced in 0.9.5.
class NOVTABLE tag_processor_album_art_utils : public service_base {
public:
//! Throws one of I/O exceptions on failure; exception_album_art_not_found when the file has no album art record at all.
virtual album_art_extractor_instance_ptr open(file_ptr p_file,abort_callback & p_abort) = 0;
//! Currently not implemented. Reserved for future use.
virtual album_art_editor_instance_ptr edit(file_ptr p_file,abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(tag_processor_album_art_utils)
};
//! Helper implementation of album_art_extractor - reads album art from arbitrary file formats that comply with APEv2 tagging specification.
class album_art_extractor_impl_stdtags : public album_art_extractor {
public:
//! @param exts Semicolon-separated list of file format extensions to support.
album_art_extractor_impl_stdtags(const char * exts) {
pfc::splitStringSimple_toList(m_extensions,";",exts);
}
bool is_our_path(const char * p_path,const char * p_extension) {
return m_extensions.have_item(p_extension);
}
album_art_extractor_instance_ptr open(file_ptr p_filehint,const char * p_path,abort_callback & p_abort) {
PFC_ASSERT( is_our_path(p_path, pfc::string_extension(p_path) ) );
file_ptr l_file ( p_filehint );
if (l_file.is_empty()) filesystem::g_open_read(l_file, p_path, p_abort);
return static_api_ptr_t<tag_processor_album_art_utils>()->open( l_file, p_abort );
}
private:
pfc::avltree_t<pfc::string,pfc::string::comparatorCaseInsensitiveASCII> m_extensions;
};

View File

@ -1,12 +0,0 @@
#include "foobar2000.h"
bool app_close_blocker::g_query()
{
service_ptr_t<app_close_blocker> ptr;
service_enum_t<app_close_blocker> e;
while(e.next(ptr))
{
if (!ptr->query()) return false;
}
return true;
}

View File

@ -1,45 +0,0 @@
//! (DEPRECATED) This service is used to signal whether something is currently preventing main window from being closed and app from being shut down.
class NOVTABLE app_close_blocker : public service_base
{
public:
//! Checks whether this service is currently preventing main window from being closed and app from being shut down.
virtual bool query() = 0;
//! Static helper function, checks whether any of registered app_close_blocker services is currently preventing main window from being closed and app from being shut down.
static bool g_query();
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(app_close_blocker);
};
//! An interface encapsulating a task preventing the foobar2000 application from being closed. Instances of this class need to be registered using app_close_blocking_task_manager methods. \n
//! Implementation: it's recommended that you derive from app_close_blocking_task_impl class instead of deriving from app_close_blocking_task directly, it manages registration/unregistration behind-the-scenes.
class NOVTABLE app_close_blocking_task {
public:
virtual void query_task_name(pfc::string_base & out) = 0;
protected:
app_close_blocking_task() {}
~app_close_blocking_task() {}
PFC_CLASS_NOT_COPYABLE_EX(app_close_blocking_task);
};
//! Entrypoint class for registering app_close_blocking_task instances. Introduced in 0.9.5.1. \n
//! Usage: static_api_ptr_t<app_close_blocking_task_manager>(). May fail if user runs pre-0.9.5.1. It's recommended that you use app_close_blocking_task_impl class instead of calling app_close_blocking_task_manager directly.
class NOVTABLE app_close_blocking_task_manager : public service_base {
public:
virtual void register_task(app_close_blocking_task * task) = 0;
virtual void unregister_task(app_close_blocking_task * task) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(app_close_blocking_task_manager);
};
//! Helper; implements standard functionality required by app_close_blocking_task implementations - registers/unregisters the task on construction/destruction.
class app_close_blocking_task_impl : public app_close_blocking_task {
public:
app_close_blocking_task_impl() { try { static_api_ptr_t<app_close_blocking_task_manager>()->register_task(this); } catch(exception_service_not_found) {/*user runs pre-0.9.5.1*/}}
~app_close_blocking_task_impl() { try { static_api_ptr_t<app_close_blocking_task_manager>()->unregister_task(this); } catch(exception_service_not_found) {/*user runs pre-0.9.5.1*/}}
void query_task_name(pfc::string_base & out) { out = "<unnamed task>"; }
};

View File

@ -1,335 +0,0 @@
#include "foobar2000.h"
void audio_chunk::set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config)
{
t_size size = samples * nch;
set_data_size(size);
if (src)
pfc::memcpy_t(get_data(),src,size);
else
pfc::memset_t(get_data(),(audio_sample)0,size);
set_sample_count(samples);
set_channels(nch,channel_config);
set_srate(srate);
}
static bool check_exclusive(unsigned val, unsigned mask)
{
return (val&mask)!=0 && (val&mask)!=mask;
}
namespace {
template<class T,bool b_swap,bool b_signed,bool b_pad> class msvc6_sucks_v2 { public:
inline static void do_fixedpoint_convert(const void * source,unsigned bps,t_size count,audio_sample* buffer)
{
const char * src = (const char *) source;
unsigned bytes = bps>>3;
t_size n;
T max = ((T)1)<<(bps-1);
T negmask = - max;
ASSUME(bytes<=sizeof(T));
const double div = 1.0 / (double)(1<<(bps-1));
for(n=0;n<count;n++) {
T temp;
if (b_pad)
{
temp = 0;
memcpy(&temp,src,bytes);
if (b_swap) pfc::byteswap_raw(&temp,bytes);
}
else
{
temp = * reinterpret_cast<const T*>(src);
if (b_swap) temp = pfc::byteswap_t(temp);
}
if (!b_signed) temp ^= max;
if (b_pad)
{
if (temp & max) temp |= negmask;
}
if (b_pad)
src += bytes;
else
src += sizeof(T);
buffer[n] = (audio_sample) ( (double)temp * div );
}
}
};
template <class T,bool b_pad> class msvc6_sucks { public:
inline static void do_fixedpoint_convert(bool b_swap,bool b_signed,const void * source,unsigned bps,t_size count,audio_sample* buffer)
{
if (sizeof(T)==1)
{
if (b_signed)
{
msvc6_sucks_v2<T,false,true,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
else
{
msvc6_sucks_v2<T,false,false,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
}
else if (b_swap)
{
if (b_signed)
{
msvc6_sucks_v2<T,true,true,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
else
{
msvc6_sucks_v2<T,true,false,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
}
else
{
if (b_signed)
{
msvc6_sucks_v2<T,false,true,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
else
{
msvc6_sucks_v2<T,false,false,b_pad>::do_fixedpoint_convert(source,bps,count,buffer);
}
}
}
};
};
void audio_chunk::set_data_fixedpoint_ex(const void * source,t_size size,unsigned srate,unsigned nch,unsigned bps,unsigned flags,unsigned p_channel_config)
{
assert( check_exclusive(flags,FLAG_SIGNED|FLAG_UNSIGNED) );
assert( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) );
bool need_swap = !!(flags & FLAG_BIG_ENDIAN);
if (pfc::byte_order_is_big_endian) need_swap = !need_swap;
t_size count = size / (bps/8);
set_data_size(count);
audio_sample * buffer = get_data();
bool b_signed = !!(flags & FLAG_SIGNED);
switch(bps)
{
case 8:
msvc6_sucks<t_int8,false>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer);
break;
case 16:
if (!need_swap && b_signed) audio_math::convert_from_int16((const t_int16*)source,count,buffer,1.0);
else msvc6_sucks<t_int16,false>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer);
break;
case 24:
msvc6_sucks<t_int32,true>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer);
break;
case 32:
if (!need_swap && b_signed) audio_math::convert_from_int32((const t_int32*)source,count,buffer,1.0);
else msvc6_sucks<t_int32,false>::do_fixedpoint_convert(need_swap,b_signed,source,bps,count,buffer);
break;
default:
//unknown size, cant convert
pfc::memset_t(buffer,(audio_sample)0,count);
break;
}
set_sample_count(count/nch);
set_srate(srate);
set_channels(nch,p_channel_config);
}
template<class t_float>
static void process_float_multi(audio_sample * p_out,const t_float * p_in,const t_size p_count)
{
t_size n;
for(n=0;n<p_count;n++)
p_out[n] = (audio_sample)p_in[n];
}
template<class t_float>
static void process_float_multi_swap(audio_sample * p_out,const t_float * p_in,const t_size p_count)
{
t_size n;
for(n=0;n<p_count;n++) {
p_out[n] = (audio_sample) pfc::byteswap_t(p_in[n]);
}
}
void audio_chunk::set_data_floatingpoint_ex(const void * ptr,t_size size,unsigned srate,unsigned nch,unsigned bps,unsigned flags,unsigned p_channel_config)
{
assert(bps==32 || bps==64);
assert( check_exclusive(flags,FLAG_LITTLE_ENDIAN|FLAG_BIG_ENDIAN) );
assert( ! (flags & (FLAG_SIGNED|FLAG_UNSIGNED) ) );
bool use_swap = pfc::byte_order_is_big_endian ? !!(flags & FLAG_LITTLE_ENDIAN) : !!(flags & FLAG_BIG_ENDIAN);
const t_size count = size / (bps/8);
set_data_size(count);
audio_sample * out = get_data();
if (bps == 32)
{
if (use_swap)
process_float_multi_swap(out,reinterpret_cast<const float*>(ptr),count);
else
process_float_multi(out,reinterpret_cast<const float*>(ptr),count);
}
else if (bps == 64)
{
if (use_swap)
process_float_multi_swap(out,reinterpret_cast<const double*>(ptr),count);
else
process_float_multi(out,reinterpret_cast<const double*>(ptr),count);
}
else throw exception_io_data("invalid bit depth");
set_sample_count(count/nch);
set_srate(srate);
set_channels(nch,p_channel_config);
}
bool audio_chunk::is_valid() const
{
unsigned nch = get_channels();
if (nch==0 || nch>256) return false;
if (!g_is_valid_sample_rate(get_srate())) return false;
t_size samples = get_sample_count();
if (samples==0 || samples >= 0x80000000 / (sizeof(audio_sample) * nch) ) return false;
t_size size = get_data_size();
if (samples * nch > size) return false;
if (!get_data()) return false;
return true;
}
void audio_chunk::pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate) {
if (is_empty())
{
if (hint_srate && hint_nch) {
return set_data(0,samples,hint_nch,hint_srate);
} else throw exception_io_data();
}
else
{
if (hint_srate && hint_srate != get_srate()) samples = MulDiv_Size(samples,get_srate(),hint_srate);
if (samples > get_sample_count())
{
t_size old_size = get_sample_count() * get_channels();
t_size new_size = samples * get_channels();
set_data_size(new_size);
pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size);
set_sample_count(samples);
}
}
}
void audio_chunk::pad_with_silence(t_size samples) {
if (samples > get_sample_count())
{
t_size old_size = get_sample_count() * get_channels();
t_size new_size = pfc::multiply_guarded(samples,get_channels());
set_data_size(new_size);
pfc::memset_t(get_data() + old_size,(audio_sample)0,new_size - old_size);
set_sample_count(samples);
}
}
void audio_chunk::insert_silence_fromstart(t_size samples) {
t_size old_size = get_sample_count() * get_channels();
t_size delta = samples * get_channels();
t_size new_size = old_size + delta;
set_data_size(new_size);
audio_sample * ptr = get_data();
pfc::memmove_t(ptr+delta,ptr,old_size);
pfc::memset_t(ptr,(audio_sample)0,delta);
set_sample_count(get_sample_count() + samples);
}
t_size audio_chunk::skip_first_samples(t_size samples_delta)
{
t_size samples_old = get_sample_count();
if (samples_delta >= samples_old)
{
set_sample_count(0);
set_data_size(0);
return samples_old;
}
else
{
t_size samples_new = samples_old - samples_delta;
unsigned nch = get_channels();
audio_sample * ptr = get_data();
pfc::memmove_t(ptr,ptr+nch*samples_delta,nch*samples_new);
set_sample_count(samples_new);
set_data_size(nch*samples_new);
return samples_delta;
}
}
audio_sample audio_chunk::get_peak(audio_sample p_peak) const {
return pfc::max_t(p_peak, get_peak());
}
audio_sample audio_chunk::get_peak() const {
return audio_math::calculate_peak(get_data(),get_sample_count() * get_channels());
}
void audio_chunk::scale(audio_sample p_value)
{
audio_sample * ptr = get_data();
audio_math::scale(ptr,get_sample_count() * get_channels(),ptr,p_value);
}
static void render_8bit(const audio_sample * in, t_size inLen, void * out) {
t_int8 * outWalk = reinterpret_cast<t_int8*>(out);
for(t_size walk = 0; walk < inLen; ++walk) {
*outWalk++ = (t_int8)pfc::clip_t<t_int32>(audio_math::rint32( in[walk] * 0x80 ), -128, 127);
}
}
static void render_24bit(const audio_sample * in, t_size inLen, void * out) {
t_uint8 * outWalk = reinterpret_cast<t_uint8*>(out);
for(t_size walk = 0; walk < inLen; ++walk) {
const t_int32 v = pfc::clip_t<t_int32>(audio_math::rint32( in[walk] * 0x800000 ), -128 * 256 * 256, 128 * 256 * 256 - 1);
*(outWalk ++) = (t_uint8) (v & 0xFF);
*(outWalk ++) = (t_uint8) ((v >> 8) & 0xFF);
*(outWalk ++) = (t_uint8) ((v >> 16) & 0xFF);
}
}
bool audio_chunk::to_raw_data(mem_block_container & out, t_uint32 bps) const {
const t_size samples = get_sample_count();
const t_size dataLen = pfc::multiply_guarded(samples, (t_size)get_channel_count());
switch(bps) {
case 8:
out.set_size(dataLen);
render_8bit(get_data(), dataLen, out.get_ptr());
break;
case 16:
out.set_size(dataLen * 2);
audio_math::convert_to_int16(get_data(), dataLen, reinterpret_cast<t_int16*>(out.get_ptr()), 1.0);
break;
case 24:
out.set_size(dataLen * 3);
render_24bit(get_data(), dataLen, out.get_ptr());
break;
case 32:
pfc::static_assert<sizeof(audio_sample) == 4>();
out.set(get_data(), dataLen * sizeof(audio_sample));
break;
default:
return false;
}
return true;
}

View File

@ -1,342 +0,0 @@
//! Thrown when audio_chunk sample rate or channel mapping changes in mid-stream and the code receiving audio_chunks can't deal with that scenario.
PFC_DECLARE_EXCEPTION(exception_unexpected_audio_format_change, exception_io_data, "Unexpected audio format change" );
//! Interface to container of a chunk of audio data. See audio_chunk_impl for an implementation.
class NOVTABLE audio_chunk {
public:
enum {
sample_rate_min = 1000, sample_rate_max = 1000000
};
static bool g_is_valid_sample_rate(t_uint32 p_val) {return p_val >= sample_rate_min && p_val <= sample_rate_max;}
//! Channel map flag declarations. Note that order of interleaved channel data in the stream is same as order of these flags.
enum
{
channel_front_left = 1<<0,
channel_front_right = 1<<1,
channel_front_center = 1<<2,
channel_lfe = 1<<3,
channel_back_left = 1<<4,
channel_back_right = 1<<5,
channel_front_center_left = 1<<6,
channel_front_center_right = 1<<7,
channel_back_center = 1<<8,
channel_side_left = 1<<9,
channel_side_right = 1<<10,
channel_top_center = 1<<11,
channel_top_front_left = 1<<12,
channel_top_front_center = 1<<13,
channel_top_front_right = 1<<14,
channel_top_back_left = 1<<15,
channel_top_back_center = 1<<16,
channel_top_back_right = 1<<17,
channel_config_mono = channel_front_center,
channel_config_stereo = channel_front_left | channel_front_right,
channel_config_5point1 = channel_front_left | channel_front_right | channel_back_left | channel_back_right | channel_front_center | channel_lfe,
defined_channel_count = 18,
};
//! Helper function; guesses default channel map for specified channel count.
static unsigned g_guess_channel_config(unsigned count);
#ifdef _WIN32
//! Helper function; translates audio_chunk channel map to WAVEFORMATEXTENSIBLE channel map.
static DWORD g_channel_config_to_wfx(unsigned p_config);
//! Helper function; translates WAVEFORMATEXTENSIBLE channel map to audio_chunk channel map.
static unsigned g_channel_config_from_wfx(DWORD p_wfx);
#endif
//! Extracts flag describing Nth channel from specified map. Usable to figure what specific channel in a stream means.
static unsigned g_extract_channel_flag(unsigned p_config,unsigned p_index);
//! Counts channels specified by channel map.
static unsigned g_count_channels(unsigned p_config);
//! Calculates index of a channel specified by p_flag in a stream where channel map is described by p_config.
static unsigned g_channel_index_from_flag(unsigned p_config,unsigned p_flag);
//! Retrieves audio data buffer pointer (non-const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n
//! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible.
virtual audio_sample * get_data() = 0;
//! Retrieves audio data buffer pointer (const version). Returned pointer is for temporary use only; it is valid until next set_data_size call, or until the object is destroyed. \n
//! Size of returned buffer is equal to get_data_size() return value (in audio_samples). Amount of actual data may be smaller, depending on sample count and channel count. Conditions where sample count * channel count are greater than data size should not be possible.
virtual const audio_sample * get_data() const = 0;
//! Retrieves size of allocated buffer space, in audio_samples.
virtual t_size get_data_size() const = 0;
//! Resizes audio data buffer to specified size. Throws std::bad_alloc on failure.
virtual void set_data_size(t_size p_new_size) = 0;
//! Retrieves sample rate of contained audio data.
virtual unsigned get_srate() const = 0;
//! Sets sample rate of contained audio data.
virtual void set_srate(unsigned val) = 0;
//! Retrieves channel count of contained audio data.
virtual unsigned get_channels() const = 0;
//! Helper - for consistency - same as get_channels().
inline unsigned get_channel_count() const {return get_channels();}
//! Retrieves channel map of contained audio data. Conditions where number of channels specified by channel map don't match get_channels() return value should not be possible.
virtual unsigned get_channel_config() const = 0;
//! Sets channel count / channel map.
virtual void set_channels(unsigned p_count,unsigned p_config) = 0;
//! Retrieves number of valid samples in the buffer. \n
//! Note that a "sample" means a unit of interleaved PCM data representing states of each channel at given point of time, not a single PCM value. \n
//! For an example, duration of contained audio data is equal to sample count / sample rate, while actual size of contained data is equal to sample count * channel count.
virtual t_size get_sample_count() const = 0;
//! Sets number of valid samples in the buffer. WARNING: sample count * channel count should never be above allocated buffer size.
virtual void set_sample_count(t_size val) = 0;
//! Helper, same as get_srate().
inline unsigned get_sample_rate() const {return get_srate();}
//! Helper, same as set_srate().
inline void set_sample_rate(unsigned val) {set_srate(val);}
//! Helper; sets channel count to specified value and uses default channel map for this channel count.
void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));}
//! Helper; resizes audio data buffer when it's current size is smaller than requested.
inline void grow_data_size(t_size p_requested) {if (p_requested > get_data_size()) set_data_size(p_requested);}
//! Retrieves duration of contained audio data, in seconds.
inline double get_duration() const
{
double rv = 0;
t_size srate = get_srate (), samples = get_sample_count();
if (srate>0 && samples>0) rv = (double)samples/(double)srate;
return rv;
}
//! Returns whether the chunk is empty (contains no audio data).
inline bool is_empty() const {return get_channels()==0 || get_srate()==0 || get_sample_count()==0;}
//! Returns whether the chunk contents are valid (for bug check purposes).
bool is_valid() const;
//! Returns actual amount of audio data contained in the buffer (sample count * channel count). Must not be greater than data size (see get_data_size()).
inline t_size get_data_length() const {return get_sample_count() * get_channels();}
//! Resets all audio_chunk data.
inline void reset() {
set_sample_count(0);
set_srate(0);
set_channels(0);
set_data_size(0);
}
//! Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate / channel map.
void set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate,unsigned channel_config);
//! Helper, sets chunk data to contents of specified buffer, with specified number of channels / sample rate, using default channel map for specified channel count.
inline void set_data(const audio_sample * src,t_size samples,unsigned nch,unsigned srate) {set_data(src,samples,nch,srate,g_guess_channel_config(nch));}
//! Helper, sets chunk data to contents of specified buffer, using default win32/wav conventions for signed/unsigned switch.
inline void set_data_fixedpoint(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) {
set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,(bps==8 ? FLAG_UNSIGNED : FLAG_SIGNED) | flags_autoendian(), channel_config);
}
inline void set_data_fixedpoint_unsigned(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) {
return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_UNSIGNED | flags_autoendian(), channel_config);
}
inline void set_data_fixedpoint_signed(const void * ptr,t_size bytes,unsigned srate,unsigned nch,unsigned bps,unsigned channel_config) {
return set_data_fixedpoint_ex(ptr,bytes,srate,nch,bps,FLAG_SIGNED | flags_autoendian(), channel_config);
}
enum
{
FLAG_LITTLE_ENDIAN = 1,
FLAG_BIG_ENDIAN = 2,
FLAG_SIGNED = 4,
FLAG_UNSIGNED = 8,
};
inline static unsigned flags_autoendian() {
return pfc::byte_order_is_big_endian ? FLAG_BIG_ENDIAN : FLAG_LITTLE_ENDIAN;
}
void set_data_fixedpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//p_flags - see FLAG_* above
void set_data_floatingpoint_ex(const void * ptr,t_size bytes,unsigned p_sample_rate,unsigned p_channels,unsigned p_bits_per_sample,unsigned p_flags,unsigned p_channel_config);//signed/unsigned flags dont apply
inline void set_data_32(const float * src,t_size samples,unsigned nch,unsigned srate) {return set_data(src,samples,nch,srate);}
void pad_with_silence_ex(t_size samples,unsigned hint_nch,unsigned hint_srate);
void pad_with_silence(t_size samples);
void insert_silence_fromstart(t_size samples);
t_size skip_first_samples(t_size samples);
//! Simple function to get original PCM stream back. Assumes host's endianness, integers are signed - including the 8bit mode; 32bit mode assumed to be float.
//! @returns false when the conversion could not be performed because of unsupported bit depth etc.
bool to_raw_data(class mem_block_container & out, t_uint32 bps) const;
//! Helper, calculates peak value of data in the chunk. The optional parameter specifies initial peak value, to simplify calling code.
audio_sample get_peak(audio_sample p_peak) const;
audio_sample get_peak() const;
//! Helper function; scales entire chunk content by specified value.
void scale(audio_sample p_value);
//! Helper; copies content of another audio chunk to this chunk.
void copy(const audio_chunk & p_source) {
set_data(p_source.get_data(),p_source.get_sample_count(),p_source.get_channels(),p_source.get_srate(),p_source.get_channel_config());
}
const audio_chunk & operator=(const audio_chunk & p_source) {
copy(p_source);
return *this;
}
protected:
audio_chunk() {}
~audio_chunk() {}
};
//! Implementation of audio_chunk. Takes pfc allocator template as template parameter.
template<template<typename> class t_alloc = pfc::alloc_standard>
class audio_chunk_impl_t : public audio_chunk {
typedef audio_chunk_impl_t<t_alloc> t_self;
pfc::array_t<audio_sample,t_alloc> m_data;
unsigned m_srate,m_nch,m_setup;
t_size m_samples;
public:
audio_chunk_impl_t() : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {}
audio_chunk_impl_t(const audio_sample * src,unsigned samples,unsigned nch,unsigned srate) : m_srate(0), m_nch(0), m_samples(0)
{set_data(src,samples,nch,srate);}
audio_chunk_impl_t(const audio_chunk & p_source) : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);}
audio_chunk_impl_t(const t_self & p_source) : m_srate(0), m_nch(0), m_samples(0), m_setup(0) {copy(p_source);}
virtual audio_sample * get_data() {return m_data.get_ptr();}
virtual const audio_sample * get_data() const {return m_data.get_ptr();}
virtual t_size get_data_size() const {return m_data.get_size();}
virtual void set_data_size(t_size new_size) {m_data.set_size(new_size);}
virtual unsigned get_srate() const {return m_srate;}
virtual void set_srate(unsigned val) {m_srate=val;}
virtual unsigned get_channels() const {return m_nch;}
virtual unsigned get_channel_config() const {return m_setup;}
virtual void set_channels(unsigned val,unsigned setup) {m_nch = val;m_setup = setup;}
void set_channels(unsigned val) {set_channels(val,g_guess_channel_config(val));}
virtual t_size get_sample_count() const {return m_samples;}
virtual void set_sample_count(t_size val) {m_samples = val;}
const t_self & operator=(const audio_chunk & p_source) {copy(p_source);return *this;}
const t_self & operator=(const t_self & p_source) {copy(p_source);return *this;}
};
typedef audio_chunk_impl_t<> audio_chunk_impl;
typedef audio_chunk_impl_t<pfc::alloc_fast_aggressive> audio_chunk_impl_temporary;
typedef audio_chunk_impl audio_chunk_i;//for compatibility
//! Implements const methods of audio_chunk only, referring to an external buffer. For temporary use only (does not maintain own storage), e.g.: somefunc( audio_chunk_temp_impl(mybuffer,....) );
class audio_chunk_temp_impl : public audio_chunk {
public:
audio_chunk_temp_impl(const audio_sample * p_data,t_size p_samples,t_uint32 p_sample_rate,t_uint32 p_channels,t_uint32 p_channel_config) :
m_data(p_data), m_samples(p_samples), m_sample_rate(p_sample_rate), m_channels(p_channels), m_channel_config(p_channel_config)
{
PFC_ASSERT(is_valid());
}
audio_sample * get_data() {throw pfc::exception_not_implemented();}
const audio_sample * get_data() const {return m_data;}
t_size get_data_size() const {return m_samples * m_channels;}
void set_data_size(t_size p_new_size) {throw pfc::exception_not_implemented();}
unsigned get_srate() const {return m_sample_rate;}
void set_srate(unsigned val) {throw pfc::exception_not_implemented();}
unsigned get_channels() const {return m_channels;}
unsigned get_channel_config() const {return m_channel_config;}
void set_channels(unsigned p_count,unsigned p_config) {throw pfc::exception_not_implemented();}
t_size get_sample_count() const {return m_samples;}
void set_sample_count(t_size val) {throw pfc::exception_not_implemented();}
private:
t_size m_samples;
t_uint32 m_sample_rate,m_channels,m_channel_config;
const audio_sample * m_data;
};
//! Duration counter class - accumulates duration using sample values, without any kind of rounding error accumulation.
class duration_counter {
public:
duration_counter() : m_offset() {
}
void set(double v) {
m_sampleCounts.remove_all();
m_offset = v;
}
void reset() {
set(0);
}
void add(double v) {m_offset += v;}
void subtract(double v) {m_offset -= v;}
double query() const {
double acc = m_offset;
for(t_map::const_iterator walk = m_sampleCounts.first(); walk.is_valid(); ++walk) {
acc += audio_math::samples_to_time(walk->m_value, walk->m_key);
}
return acc;
}
void add(const audio_chunk & c) {
add(c.get_sample_count(), c.get_sample_rate());
}
void add(t_uint64 sampleCount, t_uint32 sampleRate) {
PFC_ASSERT( sampleRate > 0 );
if (sampleRate > 0 && sampleCount > 0) {
m_sampleCounts.find_or_add(sampleRate) += sampleCount;
}
}
void add(const duration_counter & other) {
add(other.m_offset);
for(t_map::const_iterator walk = other.m_sampleCounts.first(); walk.is_valid(); ++walk) {
add(walk->m_value, walk->m_key);
}
}
void subtract(const duration_counter & other) {
subtract(other.m_offset);
for(t_map::const_iterator walk = other.m_sampleCounts.first(); walk.is_valid(); ++walk) {
subtract(walk->m_value, walk->m_key);
}
}
void subtract(t_uint64 sampleCount, t_uint32 sampleRate) {
PFC_ASSERT( sampleRate > 0 );
if (sampleRate > 0 && sampleCount > 0) {
t_uint64 * val = m_sampleCounts.query_ptr(sampleRate);
if (val == NULL) throw pfc::exception_invalid_params();
if (*val < sampleCount) throw pfc::exception_invalid_params();
else if (*val == sampleCount) {
m_sampleCounts.remove(sampleRate);
} else {
*val -= sampleCount;
}
}
}
void subtract(const audio_chunk & c) {
subtract(c.get_sample_count(), c.get_sample_rate());
}
template<typename t_source> duration_counter & operator+=(const t_source & source) {add(source); return *this;}
template<typename t_source> duration_counter & operator-=(const t_source & source) {subtract(source); return *this;}
template<typename t_source> duration_counter & operator=(const t_source & source) {reset(); add(source); return *this;}
private:
double m_offset;
typedef pfc::map_t<t_uint32, t_uint64> t_map;
t_map m_sampleCounts;
};
class audio_chunk_partial_ref : public audio_chunk_temp_impl {
public:
audio_chunk_partial_ref(const audio_chunk & chunk, t_size base, t_size count) : audio_chunk_temp_impl(chunk.get_data() + base * chunk.get_channels(), count, chunk.get_sample_rate(), chunk.get_channels(), chunk.get_channel_config()) {}
};

View File

@ -1,131 +0,0 @@
#include "foobar2000.h"
#ifdef _WIN32
#include <ks.h>
#include <ksmedia.h>
#if 0
#define SPEAKER_FRONT_LEFT 0x1
#define SPEAKER_FRONT_RIGHT 0x2
#define SPEAKER_FRONT_CENTER 0x4
#define SPEAKER_LOW_FREQUENCY 0x8
#define SPEAKER_BACK_LEFT 0x10
#define SPEAKER_BACK_RIGHT 0x20
#define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
#define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
#define SPEAKER_BACK_CENTER 0x100
#define SPEAKER_SIDE_LEFT 0x200
#define SPEAKER_SIDE_RIGHT 0x400
#define SPEAKER_TOP_CENTER 0x800
#define SPEAKER_TOP_FRONT_LEFT 0x1000
#define SPEAKER_TOP_FRONT_CENTER 0x2000
#define SPEAKER_TOP_FRONT_RIGHT 0x4000
#define SPEAKER_TOP_BACK_LEFT 0x8000
#define SPEAKER_TOP_BACK_CENTER 0x10000
#define SPEAKER_TOP_BACK_RIGHT 0x20000
#endif
static struct {DWORD m_wfx; unsigned m_native; } const g_translation_table[] =
{
{SPEAKER_FRONT_LEFT, audio_chunk::channel_front_left},
{SPEAKER_FRONT_RIGHT, audio_chunk::channel_front_right},
{SPEAKER_FRONT_CENTER, audio_chunk::channel_front_center},
{SPEAKER_LOW_FREQUENCY, audio_chunk::channel_lfe},
{SPEAKER_BACK_LEFT, audio_chunk::channel_back_left},
{SPEAKER_BACK_RIGHT, audio_chunk::channel_back_right},
{SPEAKER_FRONT_LEFT_OF_CENTER, audio_chunk::channel_front_center_left},
{SPEAKER_FRONT_RIGHT_OF_CENTER, audio_chunk::channel_front_center_right},
{SPEAKER_BACK_CENTER, audio_chunk::channel_back_center},
{SPEAKER_SIDE_LEFT, audio_chunk::channel_side_left},
{SPEAKER_SIDE_RIGHT, audio_chunk::channel_side_right},
{SPEAKER_TOP_CENTER, audio_chunk::channel_top_center},
{SPEAKER_TOP_FRONT_LEFT, audio_chunk::channel_top_front_left},
{SPEAKER_TOP_FRONT_CENTER, audio_chunk::channel_top_front_center},
{SPEAKER_TOP_FRONT_RIGHT, audio_chunk::channel_top_front_right},
{SPEAKER_TOP_BACK_LEFT, audio_chunk::channel_top_back_left},
{SPEAKER_TOP_BACK_CENTER, audio_chunk::channel_top_back_center},
{SPEAKER_TOP_BACK_RIGHT, audio_chunk::channel_top_back_right},
};
DWORD audio_chunk::g_channel_config_to_wfx(unsigned p_config)
{
DWORD ret = 0;
unsigned n;
for(n=0;n<tabsize(g_translation_table);n++)
{
if (p_config & g_translation_table[n].m_native) ret |= g_translation_table[n].m_wfx;
}
return ret;
}
unsigned audio_chunk::g_channel_config_from_wfx(DWORD p_wfx)
{
unsigned ret = 0;
unsigned n;
for(n=0;n<tabsize(g_translation_table);n++)
{
if (p_wfx & g_translation_table[n].m_wfx) ret |= g_translation_table[n].m_native;
}
return ret;
}
#endif
static unsigned g_audio_channel_config_table[] =
{
0,
audio_chunk::channel_config_mono,
audio_chunk::channel_config_stereo,
audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_lfe,
audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right,
audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right | audio_chunk::channel_lfe,
audio_chunk::channel_config_5point1,
audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right | audio_chunk::channel_lfe | audio_chunk::channel_front_center_right | audio_chunk::channel_front_center_left,
audio_chunk::channel_front_left | audio_chunk::channel_front_right | audio_chunk::channel_back_left | audio_chunk::channel_back_right | audio_chunk::channel_front_center | audio_chunk::channel_lfe | audio_chunk::channel_front_center_right | audio_chunk::channel_front_center_left,
};
unsigned audio_chunk::g_guess_channel_config(unsigned count)
{
if (count >= tabsize(g_audio_channel_config_table)) return 0;
return g_audio_channel_config_table[count];
}
unsigned audio_chunk::g_channel_index_from_flag(unsigned p_config,unsigned p_flag) {
unsigned index = 0;
for(unsigned walk = 0; walk < 32; walk++) {
unsigned query = 1 << walk;
if (p_flag & query) return index;
if (p_config & query) index++;
}
return infinite;
}
unsigned audio_chunk::g_extract_channel_flag(unsigned p_config,unsigned p_index)
{
unsigned toskip = p_index;
unsigned flag = 1;
while(flag)
{
if (p_config & flag)
{
if (toskip == 0) break;
toskip--;
}
flag <<= 1;
}
return flag;
}
unsigned audio_chunk::g_count_channels(unsigned p_config)
{
unsigned ret = 0;
while(p_config) {
ret += (p_config & 1);
p_config >>= 1;
}
return ret;
}

View File

@ -1,25 +0,0 @@
//! This class handles conversion of audio data (audio_chunk) to various linear PCM types, with optional dithering.
class NOVTABLE audio_postprocessor : public service_base
{
public:
//! Processes one chunk of audio data.
//! @param p_chunk Chunk of audio data to process.
//! @param p_output Receives output linear signed PCM data.
//! @param p_out_bps Desired bit depth of output.
//! @param p_out_bps_physical Desired physical word width of output. Must be either 8, 16, 24 or 32, greater or equal to p_out_bps. This is typically set to same value as p_out_bps.
//! @param p_dither Indicates whether dithering should be used. Note that dithering is CPU-heavy.
//! @param p_prescale Value to scale all audio samples by when converting. Set to 1.0 to do nothing.
virtual void run(const audio_chunk & p_chunk,
mem_block_container & p_output,
t_uint32 p_out_bps,
t_uint32 p_out_bps_physical,
bool p_dither,
audio_sample p_prescale
) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(audio_postprocessor);
};

View File

@ -1,106 +0,0 @@
/*
Autoplaylist APIs
These APIs were introduced in foobar2000 0.9.5, to reduce amount of code required to create your own autoplaylists. Creation of autoplaylists is was also possible before through playlist lock APIs.
In most cases, you'll want to turn regular playlists into autoplaylists using the following code:
static_api_ptr_t<autoplaylist_manager>()->add_client_simple(querypattern, sortpattern, playlistindex, forceSort ? autoplaylist_flag_sort : 0);
If you require more advanced functionality, such as using your own code to filter which part of user's Media Library should be placed in specific autoplaylist, you must implement autoplaylist_client (to let autoplaylist manager invoke your handlers when needed) / autoplaylist_client_factory (to re-instantiate your autoplaylist_client after a foobar2000 restart cycle).
*/
enum {
//! When set, core will keep the autoplaylist sorted and prevent user from reordering it.
autoplaylist_flag_sort = 1 << 0,
};
//! Main class controlling autoplaylist behaviors. Implemented by autoplaylist client in scenarios where simple query/sort strings are not enough (core provides a standard implementation for simple queries).
class NOVTABLE autoplaylist_client : public service_base {
public:
virtual GUID get_guid() = 0;
//! Called only inside a metadb lock for performance reasons.
virtual void filter(metadb_handle_list_cref data, bool * out) = 0;
//! Return true when you have filled p_orderbuffer with a permutation to apply to p_items, false when you don't support sorting (core's own sort scheme will be applied).
virtual bool sort(metadb_handle_list_cref p_items,t_size * p_orderbuffer) = 0;
//! Retrieves your configuration data to be used later when re-instantiating your autoplaylist_client after a restart.
virtual void get_configuration(stream_writer * p_stream,abort_callback & p_abort) = 0;
virtual void show_ui(t_size p_source_playlist) = 0;
//! Helper.
template<typename t_array> void get_configuration(t_array & p_out) {
pfc::static_assert<sizeof(p_out[0]) == 1>();
typedef pfc::array_t<t_uint8,pfc::alloc_fast_aggressive> t_temp; t_temp temp;
get_configuration(&stream_writer_buffer_append_ref_t<t_temp>(temp),abort_callback_impl());
p_out = temp;
}
FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client,service_base)
};
typedef service_ptr_t<autoplaylist_client> autoplaylist_client_ptr;
//! Supported from 0.9.5.3 up.
class NOVTABLE autoplaylist_client_v2 : public autoplaylist_client {
public:
//! Sets a completion_notify object that the autoplaylist_client implementation should call when its filtering behaviors have changed so the whole playlist needs to be rebuilt. \n
//! completion_notify::on_completion() status parameter meaning: \n
//! 0.9.5.3 : ignored. \n
//! 0.9.5.4 and newer: set to 1 to indicate that your configuration has changed as well (for an example as a result of user edits) to get a get_configuration() call as well as cause the playlist to be rebuilt; set to zero otherwise - when the configuration hasn't changed but the playlist needs to be rebuilt as a result of some other event.
virtual void set_full_refresh_notify(completion_notify::ptr notify) = 0;
//! Returns whether the show_ui() method is available / does anything useful with out implementation (not everyone implements show_ui).
virtual bool show_ui_available() = 0;
//! Returns a human-readable autoplaylist implementer's label to display in playlist's context menu / description / etc.
virtual void get_display_name(pfc::string_base & out) = 0;
FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_client_v2, autoplaylist_client);
};
//! Class needed to re-instantiate autoplaylist_client after a restart. Not directly needed to set up an autoplaylist_client, but without it, your autoplaylist will be lost after a restart.
class NOVTABLE autoplaylist_client_factory : public service_base {
public:
//! Must return same GUID as your autoplaylist_client::get_guid()
virtual GUID get_guid() = 0;
//! Instantiates your autoplaylist_client with specified configuration.
virtual autoplaylist_client_ptr instantiate(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(autoplaylist_client_factory)
};
PFC_DECLARE_EXCEPTION(exception_autoplaylist,pfc::exception,"Autoplaylist error")
PFC_DECLARE_EXCEPTION(exception_autoplaylist_already_owned,exception_autoplaylist,"This playlist is already an autoplaylist")
PFC_DECLARE_EXCEPTION(exception_autoplaylist_not_owned,exception_autoplaylist,"This playlist is not an autoplaylist")
PFC_DECLARE_EXCEPTION(exception_autoplaylist_lock_failure,exception_autoplaylist,"Playlist could not be locked")
//! Primary class for managing autoplaylists. Implemented by core, do not reimplement; instantiate using static_api_ptr_t<autoplaylist_manager>.
class NOVTABLE autoplaylist_manager : public service_base {
public:
//! Throws exception_autoplaylist or one of its subclasses on failure.
//! @param p_flags See autoplaylist_flag_* constants.
virtual void add_client(autoplaylist_client_ptr p_client,t_size p_playlist,t_uint32 p_flags) = 0;
virtual bool is_client_present(t_size p_playlist) = 0;
//! Throws exception_autoplaylist or one of its subclasses on failure (eg. not an autoplaylist).
virtual autoplaylist_client_ptr query_client(t_size p_playlist) = 0;
virtual void remove_client(t_size p_playlist) = 0;
//! Helper; sets up an autoplaylist using standard autoplaylist_client implementation based on simple query/sort strings. When using this, you don't need to maintain own autoplaylist_client/autoplaylist_client_factory implementations, and autoplaylists that you create will not be lost when your DLL is removed, as opposed to using add_client() directly.
//! Throws exception_autoplaylist or one of its subclasses on failure.
//! @param p_flags See autoplaylist_flag_* constants.
virtual void add_client_simple(const char * p_query,const char * p_sort,t_size p_playlist,t_uint32 p_flags) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(autoplaylist_manager)
};
//! \since 0.9.5.4
//! Extended version of autoplaylist_manager, available from 0.9.5.4 up, with methods allowing modification of autoplaylist flags.
class NOVTABLE autoplaylist_manager_v2 : public autoplaylist_manager {
FB2K_MAKE_SERVICE_INTERFACE(autoplaylist_manager_v2, autoplaylist_manager)
public:
virtual t_uint32 get_client_flags(t_size playlist) = 0;
virtual void set_client_flags(t_size playlist, t_uint32 newFlags) = 0;
//! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else.
virtual t_uint32 get_client_flags(autoplaylist_client::ptr client) = 0;
//! For use with autoplaylist client configuration dialogs. It's recommended not to call this from anything else.
virtual void set_client_flags(autoplaylist_client::ptr client, t_uint32 newFlags) = 0;
};

View File

@ -1,57 +0,0 @@
#include "foobar2000.h"
cfg_var_reader * cfg_var_reader::g_list = NULL;
cfg_var_writer * cfg_var_writer::g_list = NULL;
void cfg_var_reader::config_read_file(stream_reader * p_stream,abort_callback & p_abort)
{
pfc::map_t<GUID,cfg_var_reader*> vars;
for(cfg_var_reader * walk = g_list; walk != NULL; walk = walk->m_next) {
vars.set(walk->m_guid,walk);
}
for(;;) {
GUID guid;
t_uint32 size;
if (p_stream->read(&guid,sizeof(guid),p_abort) != sizeof(guid)) break;
guid = pfc::byteswap_if_be_t(guid);
p_stream->read_lendian_t(size,p_abort);
cfg_var_reader * var;
if (vars.query(guid,var)) {
stream_reader_limited_ref wrapper(p_stream,size);
try {
var->set_data_raw(&wrapper,size,p_abort);
} catch(exception_io_data) {}
wrapper.flush_remaining(p_abort);
} else {
p_stream->skip_object(size,p_abort);
}
}
}
void cfg_var_writer::config_write_file(stream_writer * p_stream,abort_callback & p_abort) {
cfg_var_writer * ptr;
pfc::array_t<t_uint8,pfc::alloc_fast_aggressive> temp;
for(ptr = g_list; ptr; ptr = ptr->m_next) {
temp.set_size(0);
ptr->get_data_raw(&stream_writer_buffer_append_ref_t<pfc::array_t<t_uint8,pfc::alloc_fast_aggressive> >(temp),p_abort);
p_stream->write_lendian_t(ptr->m_guid,p_abort);
p_stream->write_lendian_t(pfc::downcast_guarded<t_uint32>(temp.get_size()),p_abort);
if (temp.get_size() > 0) {
p_stream->write_object(temp.get_ptr(),temp.get_size(),p_abort);
}
}
}
void cfg_string::get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {
p_stream->write_object(get_ptr(),length(),p_abort);
}
void cfg_string::set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
pfc::string8_fastalloc temp;
p_stream->read_string_raw(temp,p_abort);
set_string(temp);
}

View File

@ -1,235 +0,0 @@
#ifndef _FOOBAR2000_SDK_CFG_VAR_H_
#define _FOOBAR2000_SDK_CFG_VAR_H_
#define CFG_VAR_ASSERT_SAFEINIT PFC_ASSERT(!core_api::are_services_available());/*imperfect check for nonstatic instantiation*/
//! Reader part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_reader directly.
class NOVTABLE cfg_var_reader {
public:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
cfg_var_reader(const GUID & guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this; }
~cfg_var_reader() { CFG_VAR_ASSERT_SAFEINIT; }
//! Sets state of the variable. Called only from main thread, when reading configuration file.
//! @param p_stream Stream containing new state of the variable.
//! @param p_sizehint Number of bytes contained in the stream; reading past p_sizehint bytes will fail (EOF).
virtual void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) = 0;
//! For internal use only, do not call.
static void config_read_file(stream_reader * p_stream,abort_callback & p_abort);
const GUID m_guid;
private:
static cfg_var_reader * g_list;
cfg_var_reader * m_next;
PFC_CLASS_NOT_COPYABLE_EX(cfg_var_reader)
};
//! Writer part of cfg_var object. In most cases, you should use cfg_var instead of using cfg_var_writer directly.
class NOVTABLE cfg_var_writer {
public:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
cfg_var_writer(const GUID & guid) : m_guid(guid) { CFG_VAR_ASSERT_SAFEINIT; m_next = g_list; g_list = this;}
~cfg_var_writer() { CFG_VAR_ASSERT_SAFEINIT; }
//! Retrieves state of the variable. Called only from main thread, when writing configuration file.
//! @param p_stream Stream receiving state of the variable.
virtual void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) = 0;
//! For internal use only, do not call.
static void config_write_file(stream_writer * p_stream,abort_callback & p_abort);
const GUID m_guid;
private:
static cfg_var_writer * g_list;
cfg_var_writer * m_next;
PFC_CLASS_NOT_COPYABLE_EX(cfg_var_writer)
};
//! Base class for configuration variable classes; provides self-registration mechaisms and methods to set/retrieve configuration data; those methods are automatically called for all registered instances by backend when configuration file is being read or written.\n
//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such).
class NOVTABLE cfg_var : public cfg_var_reader, public cfg_var_writer {
protected:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
cfg_var(const GUID & p_guid) : cfg_var_reader(p_guid), cfg_var_writer(p_guid) {}
public:
GUID get_guid() const {return cfg_var_reader::m_guid;}
};
//! Generic integer config variable class. Template parameter can be used to specify integer type to use.\n
//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such).
template<typename t_inttype>
class cfg_int_t : public cfg_var {
private:
t_inttype m_val;
protected:
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {p_stream->write_lendian_t(m_val,p_abort);}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
t_inttype temp;
p_stream->read_lendian_t(temp,p_abort);//alter member data only on success, this will throw an exception when something isn't right
m_val = temp;
}
public:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
//! @param p_default Default value of the variable.
explicit inline cfg_int_t(const GUID & p_guid,t_inttype p_default) : cfg_var(p_guid), m_val(p_default) {}
inline const cfg_int_t<t_inttype> & operator=(const cfg_int_t<t_inttype> & p_val) {m_val=p_val.m_val;return *this;}
inline t_inttype operator=(t_inttype p_val) {m_val=p_val;return m_val;}
inline operator t_inttype() const {return m_val;}
inline t_inttype get_value() const {return m_val;}
};
typedef cfg_int_t<t_int32> cfg_int;
typedef cfg_int_t<t_uint32> cfg_uint;
//! Since relevant byteswapping functions also understand GUIDs, this can be abused to declare a cfg_guid.
typedef cfg_int_t<GUID> cfg_guid;
typedef cfg_int_t<bool> cfg_bool;
//! String config variable. Stored in the stream with int32 header containing size in bytes, followed by non-null-terminated UTF-8 data.\n
//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such).
class cfg_string : public cfg_var, public pfc::string8
{
protected:
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort);
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort);
public:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
//! @param p_defaultval Default/initial value of the variable.
explicit inline cfg_string(const GUID & p_guid,const char * p_defaultval) : cfg_var(p_guid), pfc::string8(p_defaultval) {}
inline const cfg_string& operator=(const cfg_string & p_val) {set_string(p_val);return *this;}
inline const cfg_string& operator=(const char* p_val) {set_string(p_val);return *this;}
inline operator const char * () const {return get_ptr();}
};
//! Struct config variable template. Warning: not endian safe, should be used only for nonportable code.\n
//! Note that cfg_var class and its derivatives may be only instantiated statically (as static objects or members of other static objects), NEVER dynamically (operator new, local variables, members of objects instantiated as such).
template<typename t_struct>
class cfg_struct_t : public cfg_var {
private:
t_struct m_val;
protected:
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {p_stream->write_object(&m_val,sizeof(m_val),p_abort);}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
t_struct temp;
p_stream->read_object(&temp,sizeof(temp),p_abort);
m_val = temp;
}
public:
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
inline cfg_struct_t(const GUID & p_guid,const t_struct & p_val) : cfg_var(p_guid), m_val(p_val) {}
//! @param p_guid GUID of the variable, used to identify variable implementations owning specific configuration file entries when reading the configuration file back. You must generate a new GUID every time you declare a new cfg_var.
inline cfg_struct_t(const GUID & p_guid,int filler) : cfg_var(p_guid) {memset(&m_val,filler,sizeof(t_struct));}
inline const cfg_struct_t<t_struct> & operator=(const cfg_struct_t<t_struct> & p_val) {m_val = p_val.get_value();return *this;}
inline const cfg_struct_t<t_struct> & operator=(const t_struct & p_val) {m_val = p_val;return *this;}
inline const t_struct& get_value() const {return m_val;}
inline t_struct& get_value() {return m_val;}
inline operator t_struct() const {return m_val;}
};
template<typename TObj>
class cfg_objList : public cfg_var, public pfc::list_t<TObj> {
public:
cfg_objList(const GUID& guid) : cfg_var(guid) {}
template<typename TSource, unsigned Count> cfg_objList(const GUID& guid, const TSource (& source)[Count]) : cfg_var(guid) {
reset(source);
}
template<typename TSource, unsigned Count> void reset(const TSource (& source)[Count]) {
set_size(Count); for(t_size walk = 0; walk < Count; ++walk) (*this)[walk] = source[walk];
}
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {
stream_writer_formatter<> out(*p_stream,p_abort);
out << pfc::downcast_guarded<t_uint32>(get_size());
for(t_size walk = 0; walk < get_size(); ++walk) out << (*this)[walk];
}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
try {
stream_reader_formatter<> in(*p_stream,p_abort);
t_uint32 count; in >> count;
set_count(count);
for(t_uint32 walk = 0; walk < count; ++walk) in >> (*this)[walk];
} catch(...) {
remove_all();
throw;
}
}
};
template<typename TList>
class cfg_objListEx : public cfg_var, public TList {
public:
cfg_objListEx(const GUID & guid) : cfg_var(guid) {}
void get_data_raw(stream_writer * p_stream, abort_callback & p_abort) {
stream_writer_formatter<> out(*p_stream,p_abort);
out << pfc::downcast_guarded<t_uint32>(this->get_count());
for(typename TList::const_iterator walk = this->first(); walk.is_valid(); ++walk) out << *walk;
}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
remove_all();
stream_reader_formatter<> in(*p_stream,p_abort);
t_uint32 count; in >> count;
for(t_uint32 walk = 0; walk < count; ++walk) {
typename TList::t_item item; in >> item; this->add_item(item);
}
}
};
template<typename TObj>
class cfg_obj : public cfg_var, public TObj {
public:
cfg_obj(const GUID& guid) : cfg_var(guid), TObj() {}
template<typename TInitData> cfg_obj(const GUID& guid,const TInitData& initData) : cfg_var(guid), TObj(initData) {}
TObj & val() {return *this;}
TObj const & val() const {return *this;}
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {
stream_writer_formatter<> out(*p_stream,p_abort);
const TObj * ptr = this;
out << *ptr;
}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
stream_reader_formatter<> in(*p_stream,p_abort);
TObj * ptr = this;
in >> *ptr;
}
};
template<typename TObj, typename TImport> class cfg_objListImporter : private cfg_var_reader {
public:
typedef cfg_objList<TObj> TMasterVar;
cfg_objListImporter(TMasterVar & var, const GUID & guid) : m_var(var), cfg_var_reader(guid) {}
private:
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {
TImport temp;
try {
stream_reader_formatter<> in(*p_stream,p_abort);
t_uint32 count; in >> count;
m_var.set_count(count);
for(t_uint32 walk = 0; walk < count; ++walk) {
in >> temp;
m_var[walk] = temp;
}
} catch(...) {
m_var.remove_all();
throw;
}
}
TMasterVar & m_var;
};
#endif

View File

@ -1,24 +0,0 @@
#include "foobar2000.h"
void chapter_list::copy(const chapter_list & p_source)
{
t_size n, count = p_source.get_chapter_count();
set_chapter_count(count);
for(n=0;n<count;n++)
set_info(n,p_source.get_info(n));
}
bool chapterizer::g_find(service_ptr_t<chapterizer> & p_out,const char * p_path,abort_callback & p_abort)
{
service_ptr_t<chapterizer> ptr;
service_enum_t<chapterizer> e;
while(e.next(ptr))
{
if (ptr->is_our_file(p_path,p_abort))
{
p_out = ptr;
return true;
}
}
return false;
}

View File

@ -1,72 +0,0 @@
//! Interface for object storing list of chapters.
class NOVTABLE chapter_list {
public:
//! Returns number of chapters.
virtual t_size get_chapter_count() const = 0;
//! Queries description of specified chapter.
//! @param p_chapter Index of chapter to query, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash).
//! @returns reference to file_info object describing specified chapter (length part of file_info indicates distance between beginning of this chapter and next chapter mark). Returned reference value for temporary use only, becomes invalid after any non-const operation on the chapter_list object.
virtual const file_info & get_info(t_size p_chapter) const = 0;
//! Sets number of chapters.
virtual void set_chapter_count(t_size p_count) = 0;
//! Modifies description of specified chapter.
//! @param p_chapter_index Index of chapter to modify, greater or equal zero and less than get_chapter_count() value. If p_chapter value is out of valid range, results are undefined (e.g. crash).
//! @param p_info New chapter description. Note that length part of file_info is used to calculate chapter marks.
virtual void set_info(t_size p_chapter,const file_info & p_info) = 0;
//! Copies contents of specified chapter_list object to this object.
void copy(const chapter_list & p_source);
inline const chapter_list & operator=(const chapter_list & p_source) {copy(p_source); return *this;}
protected:
chapter_list() {}
~chapter_list() {}
};
//! Implements chapter_list.
class chapter_list_impl : public chapter_list
{
public:
chapter_list_impl(const chapter_list_impl & p_source) {copy(p_source);}
chapter_list_impl(const chapter_list & p_source) {copy(p_source);}
chapter_list_impl() {}
const chapter_list_impl & operator=(const chapter_list_impl & p_source) {copy(p_source); return *this;}
const chapter_list_impl & operator=(const chapter_list & p_source) {copy(p_source); return *this;}
t_size get_chapter_count() const {return m_infos.get_size();}
const file_info & get_info(t_size p_chapter) const {return m_infos[p_chapter];}
void set_chapter_count(t_size p_count) {m_infos.set_size(p_count);}
void set_info(t_size p_chapter,const file_info & p_info) {m_infos[p_chapter] = p_info;}
private:
pfc::array_t<file_info_impl> m_infos;
};
//! This service implements chapter list editing operations for various file formats, e.g. for MP4 chapters or CD images with embedded cuesheets. Used by converter "encode single file with chapters" feature.
class NOVTABLE chapterizer : public service_base {
public:
//! Tests whether specified path is supported by this implementation.
//! @param p_path Path of file to examine.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual bool is_our_file(const char * p_path,abort_callback & p_abort) = 0;
//! Writes new chapter list to specified file.
//! @param p_path Path of file to modify.
//! @param p_list New chapter list to write.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void set_chapters(const char * p_path,chapter_list const & p_list,abort_callback & p_abort) = 0;
//! Retrieves chapter list from specified file.
//! @param p_path Path of file to examine.
//! @param p_list Object receiving chapter list.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void get_chapters(const char * p_path,chapter_list & p_list,abort_callback & p_abort) = 0;
//! Static helper, tries to find chapterizer interface that supports specified file.
static bool g_find(service_ptr_t<chapterizer> & p_out,const char * p_path,abort_callback & p_abort);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(chapterizer);
};

View File

@ -1,24 +0,0 @@
#include "foobar2000.h"
void commandline_handler_metadb_handle::on_file(const char * url)
{
abort_callback_dummy blah;
{
playlist_loader_callback_impl callback(blah);
bool fail = false;
try {
playlist_loader::g_process_path_ex(url,callback);
} catch(std::exception const & e) {
console::complain("Unhandled exception in playlist loader", e);
fail = true;
}
if (!fail) {
t_size n,m=callback.get_count();
for(n=0;n<m;n++) on_file(callback.get_item(n));
}
}
}

View File

@ -1,41 +0,0 @@
class NOVTABLE commandline_handler : public service_base
{
public:
enum result
{
RESULT_NOT_OURS,//not our command
RESULT_PROCESSED,//command processed
RESULT_PROCESSED_EXPECT_FILES,//command processed, we want to takeover file urls after this command
};
virtual result on_token(const char * token)=0;
virtual void on_file(const char * url) {};//optional
virtual void on_files_done() {};//optional
virtual bool want_directories() {return false;}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(commandline_handler);
};
class commandline_handler_metadb_handle : public commandline_handler//helper
{
protected:
virtual void on_file(const char * url);
virtual bool want_directories() {return true;}
public:
virtual result on_token(const char * token)=0;
virtual void on_files_done() {};
virtual void on_file(const metadb_handle_ptr & ptr)=0;
};
/*
how commandline_handler is used:
scenario #1:
creation => on_token() => deletion
scenario #2:
creation => on_token() returning RESULT_PROCESSED_EXPECT_FILES => on_file(), on_file().... => on_files_done() => deletion
*/
template<typename T>
class commandline_handler_factory_t : public service_factory_t<T> {};

View File

@ -1,25 +0,0 @@
#include "foobar2000.h"
namespace {
class main_thread_callback_myimpl : public main_thread_callback {
public:
void callback_run() {
m_notify->on_completion(m_code);
}
main_thread_callback_myimpl(completion_notify_ptr p_notify,unsigned p_code) : m_notify(p_notify), m_code(p_code) {}
private:
completion_notify_ptr m_notify;
unsigned m_code;
};
}
void completion_notify::g_signal_completion_async(completion_notify_ptr p_notify,unsigned p_code) {
if (p_notify.is_valid()) {
static_api_ptr_t<main_thread_callback_manager>()->add_callback(new service_impl_t<main_thread_callback_myimpl>(p_notify,p_code));
}
}
void completion_notify::on_completion_async(unsigned p_code) {
static_api_ptr_t<main_thread_callback_manager>()->add_callback(new service_impl_t<main_thread_callback_myimpl>(this,p_code));
}

View File

@ -1,89 +0,0 @@
//! Generic service for receiving notifications about async operation completion. Used by various other services.
class completion_notify : public service_base {
public:
//! Called when an async operation has been completed. Note that on_completion is always called from main thread. You can use on_completion_async() helper if you need to signal completion while your context is in another thread.\n
//! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion.
//! @param p_code Context-specific status code. Possible values depend on the operation being performed.
virtual void on_completion(unsigned p_code) = 0;
//! Helper. Queues a notification, using main_thread_callback.
void on_completion_async(unsigned p_code);
//! Helper. Checks for null ptr and calls on_completion_async when the ptr is not null.
static void g_signal_completion_async(service_ptr_t<completion_notify> p_notify,unsigned p_code);
FB2K_MAKE_SERVICE_INTERFACE(completion_notify,service_base);
};
//! Implementation helper.
class completion_notify_dummy : public completion_notify {
public:
void on_completion(unsigned p_code) {}
};
//! Implementation helper.
class completion_notify_orphanable : public completion_notify {
public:
virtual void orphan() = 0;
};
//! Helper implementation.
//! IMPLEMENTATION WARNING: If process being completed creates a window taking caller's window as parent, you must not destroy the parent window inside on_task_completion(). If you need to do so, use PostMessage() or main_thread_callback to delay the deletion.
template<typename t_receiver>
class completion_notify_impl : public completion_notify_orphanable {
public:
void on_completion(unsigned p_code) {
if (m_receiver != NULL) {
m_receiver->on_task_completion(m_taskid,p_code);
}
}
void setup(t_receiver * p_receiver, unsigned p_task_id) {m_receiver = p_receiver; m_taskid = p_task_id;}
void orphan() {m_receiver = NULL; m_taskid = 0;}
private:
t_receiver * m_receiver;
unsigned m_taskid;
};
template<typename t_receiver>
service_ptr_t<completion_notify_orphanable> completion_notify_create(t_receiver * p_receiver,unsigned p_taskid) {
service_ptr_t<completion_notify_impl<t_receiver> > instance = new service_impl_t<completion_notify_impl<t_receiver> >();
instance->setup(p_receiver,p_taskid);
return instance;
}
typedef service_ptr_t<completion_notify> completion_notify_ptr;
typedef service_ptr_t<completion_notify_orphanable> completion_notify_orphanable_ptr;
//! Helper base class for classes that manage nonblocking tasks and get notified back thru completion_notify interface.
class completion_notify_receiver {
public:
completion_notify_ptr create_task(unsigned p_id) {
completion_notify_orphanable_ptr ptr;
if (m_tasks.query(p_id,ptr)) ptr->orphan();
ptr = completion_notify_create(this,p_id);
m_tasks.set(p_id,ptr);
return ptr;
}
bool have_task(unsigned p_id) const {
return m_tasks.have_item(p_id);
}
void orphan_task(unsigned p_id) {
completion_notify_orphanable_ptr ptr;
if (m_tasks.query(p_id,ptr)) {
ptr->orphan();
m_tasks.remove(p_id);
}
}
~completion_notify_receiver() {
orphan_all_tasks();
}
void orphan_all_tasks() {
m_tasks.enumerate(orphanfunc);
m_tasks.remove_all();
}
virtual void on_task_completion(unsigned p_id,unsigned p_status) {}
private:
static void orphanfunc(unsigned,completion_notify_orphanable_ptr p_item) {p_item->orphan();}
pfc::map_t<unsigned,completion_notify_orphanable_ptr> m_tasks;
};

View File

@ -1,44 +0,0 @@
#ifndef _COMPONENT_H_
#define _COMPONENT_H_
#include "foobar2000.h"
class NOVTABLE foobar2000_client
{
public:
typedef service_factory_base* pservice_factory_base;
enum {FOOBAR2000_CLIENT_VERSION_COMPATIBLE = 70, FOOBAR2000_CLIENT_VERSION = 73}; //changes everytime global compatibility is broken
virtual t_uint32 FB2KAPI get_version() = 0;
virtual pservice_factory_base FB2KAPI get_service_list() = 0;
virtual void FB2KAPI get_config(stream_writer * p_stream,abort_callback & p_abort) = 0;
virtual void FB2KAPI set_config(stream_reader * p_stream,abort_callback & p_abort) = 0;
virtual void FB2KAPI set_library_path(const char * path,const char * name) = 0;
virtual void FB2KAPI services_init(bool val) = 0;
virtual bool is_debug() = 0;
protected:
foobar2000_client() {}
~foobar2000_client() {}
};
class NOVTABLE foobar2000_api
{
public:
virtual service_class_ref FB2KAPI service_enum_find_class(const GUID & p_guid) = 0;
virtual bool FB2KAPI service_enum_create(service_ptr_t<service_base> & p_out,service_class_ref p_class,t_size p_index) = 0;
virtual t_size FB2KAPI service_enum_get_count(service_class_ref p_class) = 0;
virtual HWND FB2KAPI get_main_window()=0;
virtual bool FB2KAPI assert_main_thread()=0;
virtual bool FB2KAPI is_main_thread()=0;
virtual bool FB2KAPI is_shutting_down()=0;
virtual pcchar FB2KAPI get_profile_path()=0;
virtual bool FB2KAPI is_initializing() = 0;
protected:
foobar2000_api() {}
~foobar2000_api() {}
};
extern foobar2000_api * g_api;
#endif

View File

@ -1,6 +0,0 @@
#ifndef _COMPONENT_CLIENT_H_
#define _COMPONENT_CLIENT_H_
#endif //_COMPONENT_CLIENT_H_

View File

@ -1,7 +0,0 @@
#ifndef _COMPONENTS_MENU_H_
#define _COMPONENTS_MENU_H_
#error deprecated, see menu_item.h
#endif

View File

@ -1,56 +0,0 @@
//! Entrypoint interface for declaring component's version information. Instead of implementing this directly, use DECLARE_COMPONENT_VERSION().
class NOVTABLE componentversion : public service_base {
public:
virtual void get_file_name(pfc::string_base & out)=0;
virtual void get_component_name(pfc::string_base & out)=0;
virtual void get_component_version(pfc::string_base & out)=0;
virtual void get_about_message(pfc::string_base & out)=0;//about message uses "\n" for line separators
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(componentversion);
};
//! Implementation helper.
class componentversion_impl_simple : public componentversion {
const char * name,*version,*about;
public:
//do not derive/override
virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());}
virtual void get_component_name(pfc::string_base & out) {out.set_string(name?name:"");}
virtual void get_component_version(pfc::string_base & out) {out.set_string(version?version:"");}
virtual void get_about_message(pfc::string_base & out) {out.set_string(about?about:"");}
explicit componentversion_impl_simple(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {}
};
//! Implementation helper.
class componentversion_impl_copy : public componentversion {
pfc::string8 name,version,about;
public:
//do not derive/override
virtual void get_file_name(pfc::string_base & out) {out.set_string(core_api::get_my_file_name());}
virtual void get_component_name(pfc::string_base & out) {out.set_string(name);}
virtual void get_component_version(pfc::string_base & out) {out.set_string(version);}
virtual void get_about_message(pfc::string_base & out) {out.set_string(about);}
explicit componentversion_impl_copy(const char * p_name,const char * p_version,const char * p_about) : name(p_name), version(p_version), about(p_about ? p_about : "") {}
};
typedef service_factory_single_transparent_t<componentversion_impl_simple> __componentversion_impl_simple_factory;
typedef service_factory_single_transparent_t<componentversion_impl_copy> __componentversion_impl_copy_factory;
class componentversion_impl_simple_factory : public __componentversion_impl_simple_factory {
public:
componentversion_impl_simple_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_simple_factory(p_name,p_version,p_about) {}
};
class componentversion_impl_copy_factory : public __componentversion_impl_copy_factory {
public:
componentversion_impl_copy_factory(const char * p_name,const char * p_version,const char * p_about) : __componentversion_impl_copy_factory(p_name,p_version,p_about) {}
};
//! Use this to declare your component's version information. Parameters must ba plain const char * string constants. The ABOUT string can be NULL if you don't provide any information to show in the "About" dialog. \n
//! Example: DECLARE_COMPONENT_VERSION("blah","v1.337",NULL)
#define DECLARE_COMPONENT_VERSION(NAME,VERSION,ABOUT) \
static componentversion_impl_simple_factory g_componentversion_service(NAME,VERSION,ABOUT);
//! Same as DECLARE_COMPONENT_VERSION(), but parameters can be dynamically generated strings rather than compile-time constants.
#define DECLARE_COMPONENT_VERSION_COPY(NAME,VERSION,ABOUT) \
static componentversion_impl_copy_factory g_componentversion_service(NAME,VERSION,ABOUT);

View File

@ -1,15 +0,0 @@
//! Implementing this interface lets you maintain your own configuration files rather than depending on the cfg_var system. \n
//! Note that you must not make assumptions about what happens first: config_io_callback::on_read(), initialization of cfg_var values or config_io_callback::on_read() in other components. Order of these things is undefined and will change with each run. \n
//! Use service_factory_single_t<myclass> to register your implementations. Do not call other people's implementations, core is responsible for doing that when appropriate.
class NOVTABLE config_io_callback : public service_base {
public:
//! Called on startup. You can read your configuration file from here. \n
//! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
virtual void on_read() = 0;
//! Called on shutdown. You can write your configuration file from here.
//! Hint: use core_api::get_profile_path() to retrieve the path of the folder where foobar2000 configuration files are stored.
//! @param reset If set to true, our configuration is being reset, so you should wipe your files rather than rewrite them with current configuration.
virtual void on_write(bool reset) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_io_callback);
};

View File

@ -1,206 +0,0 @@
#include "foobar2000.h"
void config_object_notify_manager::g_on_changed(const service_ptr_t<config_object> & p_object)
{
if (core_api::assert_main_thread())
{
service_enum_t<config_object_notify_manager> e;
service_ptr_t<config_object_notify_manager> ptr;
while(e.next(ptr))
ptr->on_changed(p_object);
}
}
bool config_object::g_find(service_ptr_t<config_object> & p_out,const GUID & p_guid)
{
service_ptr_t<config_object> ptr;
service_enum_t<config_object> e;
while(e.next(ptr))
{
if (ptr->get_guid() == p_guid)
{
p_out = ptr;
return true;
}
}
return false;
}
void config_object::g_get_data_string(const GUID & p_guid,pfc::string_base & p_out)
{
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
ptr->get_data_string(p_out);
}
void config_object::g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length)
{
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
ptr->set_data_string(p_data,p_length);
}
void config_object::get_data_int32(t_int32 & p_out)
{
t_int32 temp;
get_data_struct_t<t_int32>(temp);
byte_order::order_le_to_native_t(temp);
p_out = temp;
}
void config_object::set_data_int32(t_int32 p_val)
{
t_int32 temp = p_val;
byte_order::order_native_to_le_t(temp);
set_data_struct_t<t_int32>(temp);
}
bool config_object::get_data_bool_simple(bool p_default) {
try {
bool ret = p_default;
get_data_bool(ret);
return ret;
} catch(...) {return p_default;}
}
t_int32 config_object::get_data_int32_simple(t_int32 p_default) {
try {
t_int32 ret = p_default;
get_data_int32(ret);
return ret;
} catch(...) {return p_default;}
}
void config_object::g_get_data_int32(const GUID & p_guid,t_int32 & p_out) {
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
ptr->get_data_int32(p_out);
}
void config_object::g_set_data_int32(const GUID & p_guid,t_int32 p_val) {
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
ptr->set_data_int32(p_val);
}
bool config_object::g_get_data_bool_simple(const GUID & p_guid,bool p_default)
{
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
return ptr->get_data_bool_simple(p_default);
}
t_int32 config_object::g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default)
{
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
return ptr->get_data_int32_simple(p_default);
}
void config_object::get_data_bool(bool & p_out) {get_data_struct_t<bool>(p_out);}
void config_object::set_data_bool(bool p_val) {set_data_struct_t<bool>(p_val);}
void config_object::g_get_data_bool(const GUID & p_guid,bool & p_out) {g_get_data_struct_t<bool>(p_guid,p_out);}
void config_object::g_set_data_bool(const GUID & p_guid,bool p_val) {g_set_data_struct_t<bool>(p_guid,p_val);}
namespace {
class stream_writer_string : public stream_writer {
public:
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
m_out.add_string((const char*)p_buffer,p_bytes);
}
stream_writer_string(pfc::string_base & p_out) : m_out(p_out) {m_out.reset();}
private:
pfc::string_base & m_out;
};
class stream_writer_fixedbuffer : public stream_writer {
public:
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
if (p_bytes > 0) {
if (p_bytes > m_bytes - m_bytes_read) throw pfc::exception_overflow();
memcpy((t_uint8*)m_out,p_buffer,p_bytes);
m_bytes_read += p_bytes;
}
}
stream_writer_fixedbuffer(void * p_out,t_size p_bytes,t_size & p_bytes_read) : m_out(p_out), m_bytes(p_bytes), m_bytes_read(p_bytes_read) {m_bytes_read = 0;}
private:
void * m_out;
t_size m_bytes;
t_size & m_bytes_read;
};
class stream_writer_get_length : public stream_writer {
public:
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
m_length += p_bytes;
}
stream_writer_get_length(t_size & p_length) : m_length(p_length) {m_length = 0;}
private:
t_size & m_length;
};
};
t_size config_object::get_data_raw(void * p_out,t_size p_bytes) {
t_size ret = 0;
get_data(&stream_writer_fixedbuffer(p_out,p_bytes,ret),abort_callback_impl());
return ret;
}
t_size config_object::get_data_raw_length() {
t_size ret = 0;
get_data(&stream_writer_get_length(ret),abort_callback_impl());
return ret;
}
void config_object::set_data_raw(const void * p_data,t_size p_bytes, bool p_notify) {
set_data(&stream_reader_memblock_ref(p_data,p_bytes),abort_callback_impl(),p_notify);
}
void config_object::set_data_string(const char * p_data,t_size p_length) {
set_data_raw(p_data,pfc::strlen_max(p_data,p_length));
}
void config_object::get_data_string(pfc::string_base & p_out) {
get_data(&stream_writer_string(p_out),abort_callback_impl());
}
//config_object_impl stuff
void config_object_impl::get_data(stream_writer * p_stream,abort_callback & p_abort) const {
insync(m_sync);
p_stream->write_object(m_data.get_ptr(),m_data.get_size(),p_abort);
}
void config_object_impl::set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) {
core_api::ensure_main_thread();
{
insync(m_sync);
m_data.set_size(0);
enum {delta = 1024};
t_uint8 buffer[delta];
for(;;)
{
t_size delta_done = p_stream->read(buffer,delta,p_abort);
if (delta_done > 0)
{
m_data.append_fromptr(buffer,delta_done);
}
if (delta_done != delta) break;
}
}
if (p_notify) config_object_notify_manager::g_on_changed(this);
}
config_object_impl::config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes) : cfg_var(p_guid)
{
m_data.set_data_fromptr((const t_uint8*)p_data,p_bytes);
}

View File

@ -1,85 +0,0 @@
#ifndef _CONFIG_OBJECT_H_
#define _CONFIG_OBJECT_H_
class config_object;
class NOVTABLE config_object_notify_manager : public service_base
{
public:
virtual void on_changed(const service_ptr_t<config_object> & p_object) = 0;
static void g_on_changed(const service_ptr_t<config_object> & p_object);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify_manager);
};
class NOVTABLE config_object : public service_base
{
public:
//interface
virtual GUID get_guid() const = 0;
virtual void get_data(stream_writer * p_stream,abort_callback & p_abort) const = 0;
virtual void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_sendnotify = true) = 0;
//helpers
static bool g_find(service_ptr_t<config_object> & p_out,const GUID & p_guid);
void set_data_raw(const void * p_data,t_size p_bytes,bool p_sendnotify = true);
t_size get_data_raw(void * p_out,t_size p_bytes);
t_size get_data_raw_length();
template<class T> void get_data_struct_t(T& p_out);
template<class T> void set_data_struct_t(const T& p_in);
template<class T> static void g_get_data_struct_t(const GUID & p_guid,T & p_out);
template<class T> static void g_set_data_struct_t(const GUID & p_guid,const T & p_in);
void set_data_string(const char * p_data,t_size p_length);
void get_data_string(pfc::string_base & p_out);
void get_data_bool(bool & p_out);
void set_data_bool(bool p_val);
void get_data_int32(t_int32 & p_out);
void set_data_int32(t_int32 p_val);
bool get_data_bool_simple(bool p_default);
t_int32 get_data_int32_simple(t_int32 p_default);
static void g_get_data_string(const GUID & p_guid,pfc::string_base & p_out);
static void g_set_data_string(const GUID & p_guid,const char * p_data,t_size p_length = ~0);
static void g_get_data_bool(const GUID & p_guid,bool & p_out);
static void g_set_data_bool(const GUID & p_guid,bool p_val);
static void g_get_data_int32(const GUID & p_guid,t_int32 & p_out);
static void g_set_data_int32(const GUID & p_guid,t_int32 p_val);
static bool g_get_data_bool_simple(const GUID & p_guid,bool p_default);
static t_int32 g_get_data_int32_simple(const GUID & p_guid,t_int32 p_default);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object);
};
class standard_config_objects
{
public:
static const GUID bool_remember_window_positions, bool_ui_always_on_top,bool_playlist_stop_after_current;
static const GUID bool_playback_follows_cursor, bool_cursor_follows_playback;
static const GUID bool_show_keyboard_shortcuts_in_menus;
static const GUID string_gui_last_directory_media,string_gui_last_directory_playlists;
static const GUID int32_dynamic_bitrate_display_rate;
inline static bool query_show_keyboard_shortcuts_in_menus() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_show_keyboard_shortcuts_in_menus,true);}
inline static bool query_remember_window_positions() {return config_object::g_get_data_bool_simple(standard_config_objects::bool_remember_window_positions,true);}
};
class config_object_notify : public service_base
{
public:
virtual t_size get_watched_object_count() = 0;
virtual GUID get_watched_object(t_size p_index) = 0;
virtual void on_watched_object_changed(const service_ptr_t<config_object> & p_object) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(config_object_notify);
};
#endif _CONFIG_OBJECT_H_

View File

@ -1,174 +0,0 @@
#ifndef _CONFIG_OBJECT_IMPL_H_
#define _CONFIG_OBJECT_IMPL_H_
//template function bodies from config_object class
template<class T>
void config_object::get_data_struct_t(T& p_out) {
if (get_data_raw(&p_out,sizeof(T)) != sizeof(T)) throw exception_io_data_truncation();
}
template<class T>
void config_object::set_data_struct_t(const T& p_in) {
return set_data_raw(&p_in,sizeof(T));
}
template<class T>
void config_object::g_get_data_struct_t(const GUID & p_guid,T & p_out) {
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
return ptr->get_data_struct_t<T>(p_out);
}
template<class T>
void config_object::g_set_data_struct_t(const GUID & p_guid,const T & p_in) {
service_ptr_t<config_object> ptr;
if (!g_find(ptr,p_guid)) throw exception_service_not_found();
return ptr->set_data_struct_t<T>(p_in);
}
class config_object_impl : public config_object, private cfg_var
{
public:
GUID get_guid() const {return cfg_var::get_guid();}
void get_data(stream_writer * p_stream,abort_callback & p_abort) const ;
void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify);
config_object_impl(const GUID & p_guid,const void * p_data,t_size p_bytes);
private:
//cfg_var methods
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {get_data(p_stream,p_abort);}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {set_data(p_stream,p_abort,false);}
mutable critical_section m_sync;
pfc::array_t<t_uint8> m_data;
};
typedef service_factory_single_transparent_t<config_object_impl> config_object_factory;
template<t_size p_size>
class config_object_fixed_const_impl_t : public config_object {
public:
config_object_fixed_const_impl_t(const GUID & p_guid, const void * p_data) : m_guid(p_guid) {memcpy(m_data,p_data,p_size);}
GUID get_guid() const {return m_guid;}
void get_data(stream_writer * p_stream, abort_callback & p_abort) const { p_stream->write_object(m_data,p_size,p_abort); }
void set_data(stream_reader * p_stream, abort_callback & p_abort, bool p_notify) { PFC_ASSERT(!"Should not get here."); }
private:
t_uint8 m_data[p_size];
const GUID m_guid;
};
template<t_size p_size>
class config_object_fixed_impl_t : public config_object, private cfg_var {
public:
GUID get_guid() const {return cfg_var::get_guid();}
void get_data(stream_writer * p_stream,abort_callback & p_abort) const {
insync(m_sync);
p_stream->write_object(m_data,p_size,p_abort);
}
void set_data(stream_reader * p_stream,abort_callback & p_abort,bool p_notify) {
core_api::ensure_main_thread();
{
t_uint8 temp[p_size];
p_stream->read_object(temp,p_size,p_abort);
insync(m_sync);
memcpy(m_data,temp,p_size);
}
if (p_notify) config_object_notify_manager::g_on_changed(this);
}
config_object_fixed_impl_t (const GUID & p_guid,const void * p_data)
: cfg_var(p_guid)
{
memcpy(m_data,p_data,p_size);
}
private:
//cfg_var methods
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {get_data(p_stream,p_abort);}
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort) {set_data(p_stream,p_abort,false);}
mutable critical_section m_sync;
t_uint8 m_data[p_size];
};
template<t_size p_size, bool isConst> class _config_object_fixed_impl_switch;
template<t_size p_size> class _config_object_fixed_impl_switch<p_size,false> { public: typedef config_object_fixed_impl_t<p_size> type; };
template<t_size p_size> class _config_object_fixed_impl_switch<p_size,true> { public: typedef config_object_fixed_const_impl_t<p_size> type; };
template<t_size p_size, bool isConst = false>
class config_object_fixed_factory_t : public service_factory_single_transparent_t< typename _config_object_fixed_impl_switch<p_size,isConst>::type >
{
public:
config_object_fixed_factory_t(const GUID & p_guid,const void * p_initval)
:
service_factory_single_transparent_t< typename _config_object_fixed_impl_switch<p_size,isConst>::type >
(p_guid,p_initval)
{}
};
class config_object_string_factory : public config_object_factory
{
public:
config_object_string_factory(const GUID & p_guid,const char * p_string,t_size p_string_length = infinite)
: config_object_factory(p_guid,p_string,pfc::strlen_max(p_string,infinite)) {}
};
template<bool isConst = false>
class config_object_bool_factory_t : public config_object_fixed_factory_t<1,isConst> {
public:
config_object_bool_factory_t(const GUID & p_guid,bool p_initval)
: config_object_fixed_factory_t<1,isConst>(p_guid,&p_initval) {}
};
typedef config_object_bool_factory_t<> config_object_bool_factory;
template<class T,bool isConst = false>
class config_object_int_factory_t : public config_object_fixed_factory_t<sizeof(T),isConst>
{
private:
template<class T>
struct t_initval
{
T m_initval;
t_initval(T p_initval) : m_initval(p_initval) {byte_order::order_native_to_le_t(m_initval);}
T * get_ptr() {return &m_initval;}
};
public:
config_object_int_factory_t(const GUID & p_guid,T p_initval)
: config_object_fixed_factory_t<sizeof(T)>(p_guid,t_initval<T>(p_initval).get_ptr() )
{}
};
typedef config_object_int_factory_t<t_int32> config_object_int32_factory;
class config_object_notify_impl_simple : public config_object_notify
{
public:
t_size get_watched_object_count() {return 1;}
GUID get_watched_object(t_size p_index) {return m_guid;}
void on_watched_object_changed(const service_ptr_t<config_object> & p_object) {m_func(p_object);}
typedef void (*t_func)(const service_ptr_t<config_object> &);
config_object_notify_impl_simple(const GUID & p_guid,t_func p_func) : m_guid(p_guid), m_func(p_func) {}
private:
GUID m_guid;
t_func m_func;
};
typedef service_factory_single_transparent_t<config_object_notify_impl_simple> config_object_notify_simple_factory;
#endif _CONFIG_OBJECT_IMPL_H_

View File

@ -1,50 +0,0 @@
#include "foobar2000.h"
void console::info(const char * p_message) {print(p_message);}
void console::error(const char * p_message) {complain("Error", p_message);}
void console::warning(const char * p_message) {complain("Warning", p_message);}
void console::info_location(const playable_location & src) {print_location(src);}
void console::info_location(const metadb_handle_ptr & src) {print_location(src);}
void console::print_location(const metadb_handle_ptr & src)
{
print_location(src->get_location());
}
void console::print_location(const playable_location & src)
{
formatter() << src;
}
void console::complain(const char * what, const char * msg) {
formatter() << what << ": " << msg;
}
void console::complain(const char * what, std::exception const & e) {
complain(what, e.what());
}
void console::print(const char* p_message)
{
if (core_api::are_services_available()) {
service_ptr_t<console_receiver> ptr;
service_enum_t<console_receiver> e;
while(e.next(ptr)) ptr->print(p_message,infinite);
}
}
void console::printf(const char* p_format,...)
{
va_list list;
va_start(list,p_format);
printfv(p_format,list);
va_end(list);
}
void console::printfv(const char* p_format,va_list p_arglist)
{
pfc::string8_fastalloc temp;
uPrintfV(temp,p_format,p_arglist);
print(temp);
}

View File

@ -1,31 +0,0 @@
//! Namespace with functions for sending text to console. All functions are fully multi-thread safe, though they must not be called during dll initialization or deinitialization (e.g. static object constructors or destructors) when service system is not available.
namespace console
{
void info(const char * p_message);
void error(const char * p_message);
void warning(const char * p_message);
void info_location(const playable_location & src);
void info_location(const metadb_handle_ptr & src);
void print_location(const playable_location & src);
void print_location(const metadb_handle_ptr & src);
void print(const char*);
void printf(const char*,...);
void printfv(const char*,va_list p_arglist);
//! Usage: console::formatter() << "blah " << somenumber << " asdf" << somestring;
class formatter : public pfc::string_formatter {
public:
~formatter() {if (!is_empty()) console::print(get_ptr());}
};
void complain(const char * what, const char * msg);
void complain(const char * what, std::exception const & e);
};
//! Interface receiving console output. Do not call directly; use console namespace functions instead.
class NOVTABLE console_receiver : public service_base {
public:
virtual void print(const char * p_message,t_size p_message_length) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(console_receiver);
};

View File

@ -1,242 +0,0 @@
//! Reserved for future use.
typedef void * t_glyph;
class NOVTABLE contextmenu_item_node {
public:
enum t_flags {
FLAG_CHECKED = 1,
FLAG_DISABLED = 2,
FLAG_GRAYED = 4,
FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED,
FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility.
};
enum t_type {
TYPE_POPUP,TYPE_COMMAND,TYPE_SEPARATOR
};
virtual bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) = 0;
virtual t_type get_type() = 0;
virtual void execute(metadb_handle_list_cref p_data,const GUID & p_caller) = 0;
virtual t_glyph get_glyph(metadb_handle_list_cref p_data,const GUID & p_caller) {return 0;}//RESERVED
virtual t_size get_children_count() = 0;
virtual contextmenu_item_node * get_child(t_size p_index) = 0;
virtual bool get_description(pfc::string_base & p_out) = 0;
virtual GUID get_guid() = 0;
virtual bool is_mappable_shortcut() = 0;
protected:
contextmenu_item_node() {}
~contextmenu_item_node() {}
};
class NOVTABLE contextmenu_item_node_root : public contextmenu_item_node
{
public:
virtual ~contextmenu_item_node_root() {}
};
class NOVTABLE contextmenu_item_node_leaf : public contextmenu_item_node
{
public:
t_type get_type() {return TYPE_COMMAND;}
t_size get_children_count() {return 0;}
contextmenu_item_node * get_child(t_size) {return NULL;}
};
class NOVTABLE contextmenu_item_node_root_leaf : public contextmenu_item_node_root
{
public:
t_type get_type() {return TYPE_COMMAND;}
t_size get_children_count() {return 0;}
contextmenu_item_node * get_child(t_size) {return NULL;}
};
class NOVTABLE contextmenu_item_node_popup : public contextmenu_item_node
{
public:
t_type get_type() {return TYPE_POPUP;}
void execute(metadb_handle_list_cref data,const GUID & caller) {}
bool get_description(pfc::string_base & p_out) {return false;}
};
class NOVTABLE contextmenu_item_node_root_popup : public contextmenu_item_node_root
{
public:
t_type get_type() {return TYPE_POPUP;}
void execute(metadb_handle_list_cref data,const GUID & caller) {}
bool get_description(pfc::string_base & p_out) {return false;}
};
class contextmenu_item_node_separator : public contextmenu_item_node
{
public:
t_type get_type() {return TYPE_SEPARATOR;}
void execute(metadb_handle_list_cref data,const GUID & caller) {}
bool get_description(pfc::string_base & p_out) {return false;}
t_size get_children_count() {return 0;}
bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller)
{
p_displayflags = 0;
p_out = "---";
return true;
}
contextmenu_item_node * get_child(t_size) {return NULL;}
GUID get_guid() {return pfc::guid_null;}
bool is_mappable_shortcut() {return false;}
};
/*!
Service class for declaring context menu commands.\n
See contextmenu_item_simple for implementation helper without dynamic menu generation features.\n
All methods are valid from main app thread only.
*/
class NOVTABLE contextmenu_item : public service_base {
public:
enum t_enabled_state {
FORCE_OFF,
DEFAULT_OFF,
DEFAULT_ON,
};
//! Retrieves number of menu items provided by this contextmenu_item implementation.
virtual unsigned get_num_items() = 0;
//! Instantiates a context menu item (including sub-node tree for items that contain dynamically-generated sub-items).
virtual contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller) = 0;
//! Retrieves GUID of the context menu item.
virtual GUID get_item_guid(unsigned p_index) = 0;
//! Retrieves human-readable name of the context menu item.
virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0;
//! Retrieves default path of the context menu item ("" for root).
virtual void get_item_default_path(unsigned p_index,pfc::string_base & p_out) = 0;
//! Retrieves item's description to show in the status bar. Set p_out to the string to be displayed and return true if you provide a description, return false otherwise.
virtual bool get_item_description(unsigned p_index,pfc::string_base & p_out) = 0;
//! Signals whether the item should be forcefully hidden (FORCE_OFF), hidden by default but possible to add (DEFAULT_OFF) or shown by default (DEFAULT_ON).
virtual t_enabled_state get_enabled_state(unsigned p_index) = 0;
//! Executes the menu item command without going thru the instantiate_item path. For items with dynamically-generated sub-items, p_node is identifies of the sub-item command to execute.
virtual void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller) = 0;
bool item_get_display_data_root(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller);
bool item_get_display_data(pfc::string_base & p_out,unsigned & displayflags,unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller);
//! Deprecated - use caller_active_playlist_selection instead.
static const GUID caller_playlist;
static const GUID caller_active_playlist_selection, caller_active_playlist, caller_playlist_manager, caller_now_playing, caller_keyboard_shortcut_list, caller_media_library_viewer;
static const GUID caller_undefined;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_item);
};
//! contextmenu_item implementation helper for implementing non-dynamically-generated context menu items; derive from this instead of from contextmenu_item directly if your menu items are static.
class NOVTABLE contextmenu_item_simple : public contextmenu_item {
private:
public:
//! Same as contextmenu_item_node::t_flags.
enum t_flags
{
FLAG_CHECKED = 1,
FLAG_DISABLED = 2,
FLAG_GRAYED = 4,
FLAG_DISABLED_GRAYED = FLAG_DISABLED|FLAG_GRAYED,
FLAG_RADIOCHECKED = 8, //new in 0.9.5.2 - overrides FLAG_CHECKED, set together with FLAG_CHECKED for backwards compatibility.
};
// Functions to be overridden by implementers (some are not mandatory).
virtual t_enabled_state get_enabled_state(unsigned p_index) {return contextmenu_item::DEFAULT_ON;}
virtual unsigned get_num_items() = 0;
virtual void get_item_name(unsigned p_index,pfc::string_base & p_out) = 0;
virtual void get_item_default_path(unsigned p_index,pfc::string_base & p_out) = 0;
virtual void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) = 0;
virtual bool context_get_display(unsigned p_index,metadb_handle_list_cref p_data,pfc::string_base & p_out,unsigned & p_displayflags,const GUID & p_caller) {
PFC_ASSERT(p_index>=0 && p_index<get_num_items());
get_item_name(p_index,p_out);
return true;
}
virtual GUID get_item_guid(unsigned p_index) = 0;
virtual bool get_item_description(unsigned p_index,pfc::string_base & p_out) = 0;
private:
class contextmenu_item_node_impl : public contextmenu_item_node_root_leaf {
public:
contextmenu_item_node_impl(contextmenu_item_simple * p_owner,unsigned p_index) : m_owner(p_owner), m_index(p_index) {}
bool get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,metadb_handle_list_cref p_data,const GUID & p_caller) {return m_owner->get_display_data(m_index,p_data,p_out,p_displayflags,p_caller);}
void execute(metadb_handle_list_cref p_data,const GUID & p_caller) {m_owner->context_command(m_index,p_data,p_caller);}
bool get_description(pfc::string_base & p_out) {return m_owner->get_item_description(m_index,p_out);}
GUID get_guid() {return pfc::guid_null;}
bool is_mappable_shortcut() {return m_owner->item_is_mappable_shortcut(m_index);}
private:
service_ptr_t<contextmenu_item_simple> m_owner;
unsigned m_index;
};
contextmenu_item_node_root * instantiate_item(unsigned p_index,metadb_handle_list_cref p_data,const GUID & p_caller)
{
return new contextmenu_item_node_impl(this,p_index);
}
void item_execute_simple(unsigned p_index,const GUID & p_node,metadb_handle_list_cref p_data,const GUID & p_caller)
{
if (p_node == pfc::guid_null)
context_command(p_index,p_data,p_caller);
}
virtual bool item_is_mappable_shortcut(unsigned p_index)
{
return true;
}
virtual bool get_display_data(unsigned n,metadb_handle_list_cref data,pfc::string_base & p_out,unsigned & displayflags,const GUID & caller)
{
bool rv = false;
assert(n>=0 && n<get_num_items());
if (data.get_count()>0)
{
rv = context_get_display(n,data,p_out,displayflags,caller);
}
return rv;
}
};
//! Helper.
template<typename T>
class contextmenu_item_factory_t : public service_factory_single_t<T> {};
//! Helper.
#define DECLARE_CONTEXT_MENU_ITEM(P_CLASSNAME,P_NAME,P_DEFAULTPATH,P_FUNC,P_GUID,P_DESCRIPTION) \
namespace { \
class P_CLASSNAME : public contextmenu_item_simple { \
public: \
unsigned get_num_items() {return 1;} \
void get_item_name(unsigned p_index,pfc::string_base & p_out) {p_out = P_NAME;} \
void get_item_default_path(unsigned p_index,pfc::string_base & p_out) {p_out = P_DEFAULTPATH;} \
void context_command(unsigned p_index,metadb_handle_list_cref p_data,const GUID& p_caller) {P_FUNC(p_data);} \
GUID get_item_guid(unsigned p_index) {return P_GUID;} \
bool get_item_description(unsigned p_index,pfc::string_base & p_out) {if (P_DESCRIPTION[0] == 0) return false;p_out = P_DESCRIPTION; return true;} \
}; \
static contextmenu_item_factory_t<P_CLASSNAME> g_##P_CLASSNAME##_factory; \
}
//! New in 0.9.5.1. Static methods safe to use in prior versions as it will use slow fallback mode when the service isn't present. \n
//! Functionality provided by menu_item_resolver methods isn't much different from just walking all registered contextmenu_item / mainmenu_commands implementations to find the command we want, but it uses a hint map to locate the service we're looking for without walking all of them which may be significantly faster in certain scenarios.
class menu_item_resolver : public service_base {
public:
virtual bool resolve_context_command(const GUID & id, service_ptr_t<class contextmenu_item> & out, t_uint32 & out_index) = 0;
virtual bool resolve_main_command(const GUID & id, service_ptr_t<class mainmenu_commands> & out, t_uint32 & out_index) = 0;
static bool g_resolve_context_command(const GUID & id, service_ptr_t<class contextmenu_item> & out, t_uint32 & out_index);
static bool g_resolve_main_command(const GUID & id, service_ptr_t<class mainmenu_commands> & out, t_uint32 & out_index);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(menu_item_resolver)
};

View File

@ -1,109 +0,0 @@
class NOVTABLE keyboard_shortcut_manager : public service_base
{
public:
static bool g_get(service_ptr_t<keyboard_shortcut_manager> & p_out) {return service_enum_create_t(p_out,0);}
enum shortcut_type
{
TYPE_MAIN,
TYPE_CONTEXT,
TYPE_CONTEXT_PLAYLIST,
TYPE_CONTEXT_NOW_PLAYING,
};
virtual bool process_keydown(shortcut_type type,const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned keycode)=0;
virtual bool process_keydown_ex(shortcut_type type,const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned keycode,const GUID & caller)=0;
bool on_keydown(shortcut_type type,WPARAM wp);
bool on_keydown_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
bool on_keydown_auto(WPARAM wp);
bool on_keydown_auto_playlist(WPARAM wp);
bool on_keydown_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
bool on_keydown_restricted_auto(WPARAM wp);
bool on_keydown_restricted_auto_playlist(WPARAM wp);
bool on_keydown_restricted_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller);
virtual bool get_key_description_for_action(const GUID & p_command,const GUID & p_subcommand, pfc::string_base & out, shortcut_type type, bool is_global)=0;
static bool is_text_key(t_uint32 vkCode);
static bool is_typing_key(t_uint32 vkCode);
static bool is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers);
static bool is_typing_modifier(t_uint32 flags);
static bool is_typing_message(HWND editbox, const MSG * msg);
static bool is_typing_message(const MSG * msg);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(keyboard_shortcut_manager);
};
//! New in 0.9.5.
class keyboard_shortcut_manager_v2 : public keyboard_shortcut_manager {
public:
//! Deprecates old keyboard_shortcut_manager methods. If the action requires selected items, they're obtained from ui_selection_manager API automatically.
virtual bool process_keydown_simple(t_uint32 keycode) = 0;
//! Helper for use with message filters.
bool pretranslate_message(const MSG * msg, HWND thisPopupWnd);
FB2K_MAKE_SERVICE_INTERFACE(keyboard_shortcut_manager_v2,keyboard_shortcut_manager);
};
class NOVTABLE contextmenu_node {
public:
virtual contextmenu_item_node::t_type get_type()=0;
virtual const char * get_name()=0;
virtual t_size get_num_children()=0;//TYPE_POPUP only
virtual contextmenu_node * get_child(t_size n)=0;//TYPE_POPUP only
virtual unsigned get_display_flags()=0;//TYPE_COMMAND/TYPE_POPUP only, see contextmenu_item::FLAG_*
virtual unsigned get_id()=0;//TYPE_COMMAND only, returns zero-based index (helpful for win32 menu command ids)
virtual void execute()=0;//TYPE_COMMAND only
virtual bool get_description(pfc::string_base & out)=0;//TYPE_COMMAND only
virtual bool get_full_name(pfc::string_base & out)=0;//TYPE_COMMAND only
virtual void * get_glyph()=0;//RESERVED, do not use
protected:
contextmenu_node() {}
~contextmenu_node() {}
};
class NOVTABLE contextmenu_manager : public service_base
{
public:
enum
{
FLAG_SHOW_SHORTCUTS = 1,
FLAG_SHOW_SHORTCUTS_GLOBAL = 2,
};
virtual void init_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned flags)=0;//flags - see FLAG_* above
virtual void init_context_playlist(unsigned flags)=0;
virtual contextmenu_node * get_root()=0;//releasing contextmenu_manager service releaases nodes; root may be null in case of error or something
virtual contextmenu_node * find_by_id(unsigned id)=0;
virtual void set_shortcut_preference(const keyboard_shortcut_manager::shortcut_type * data,unsigned count)=0;
static void g_create(service_ptr_t<contextmenu_manager> & p_out) {p_out = standard_api_create_t<contextmenu_manager>();}
#ifdef WIN32
static void win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id);//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
static void win32_run_menu_context(HWND parent,const pfc::list_base_const_t<metadb_handle_ptr> & data, const POINT * pt = 0,unsigned flags = 0);
static void win32_run_menu_context_playlist(HWND parent,const POINT * pt = 0,unsigned flags = 0);
void win32_run_menu_popup(HWND parent,const POINT * pt = 0);
void win32_build_menu(HMENU menu,int base_id,int max_id) {win32_build_menu(menu,get_root(),base_id,max_id);}
#endif
virtual void init_context_ex(const pfc::list_base_const_t<metadb_handle_ptr> & data,unsigned flags,const GUID & caller)=0;
virtual bool init_context_now_playing(unsigned flags)=0;//returns false if not playing
bool execute_by_id(unsigned id);
bool get_description_by_id(unsigned id,pfc::string_base & out);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(contextmenu_manager);
};

View File

@ -1,33 +0,0 @@
#ifndef _CORE_API_H_
#define _CORE_API_H_
namespace core_api {
//! Exception thrown by APIs locked to main app thread when called from another thread.
PFC_DECLARE_EXCEPTION(exception_wrong_thread,pfc::exception_bug_check,"This method can be called only from the main thread");
//! Retrieves HINSTANCE of calling DLL.
HINSTANCE get_my_instance();
//! Retrieves filename of calling dll, excluding extension, e.g. "foo_asdf"
const char * get_my_file_name();
//! Retrieves full path of calling dll, e.g. file://c:\blah\foobar2000\foo_asdf.dll
const char * get_my_full_path();
//! Retrieves main app window. WARNING: this is provided for parent of dialog windows and such only; using it for anything else (such as hooking windowproc to alter app behaviors) is absolutely illegal.
HWND get_main_window();
//! Tests whether services are available at this time. They are not available only during DLL startup or shutdown (e.g. inside static object constructors or destructors).
bool are_services_available();
//! Tests whether calling thread is main app thread, and shows diagnostic message in debugger output if it's not.
bool assert_main_thread();
//! Throws exception_wrong_thread if calling thread is not main app thread.
void ensure_main_thread();
//! Returns true if calling thread is main app thread, false otherwise.
bool is_main_thread();
//! Returns whether the app is currently shutting down.
bool is_shutting_down();
//! Returns whether the app is currently initializing.
bool is_initializing();
//! Returns filesystem path to directory with user settings, e.g. file://c:\documents_and_settings\username\blah\foobar2000
const char * get_profile_path();
};
#endif

View File

@ -1,36 +0,0 @@
class NOVTABLE core_version_info : public service_base {
public:
virtual const char * get_version_string() = 0;
static const char * g_get_version_string() {return static_api_ptr_t<core_version_info>()->get_version_string();}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(core_version_info);
};
struct t_core_version_data {
t_uint32 m_major, m_minor1, m_minor2, m_minor3;
};
//! New (0.9.4.2)
class NOVTABLE core_version_info_v2 : public core_version_info {
public:
virtual const char * get_name() = 0;//"foobar2000"
virtual const char * get_version_as_text() = 0;//"N.N.N.N"
virtual t_core_version_data get_version() = 0;
//! Determine whether running foobar2000 version is newer or equal to the specified version, eg. test_version(0,9,5,0) for 0.9.5.
bool test_version(t_uint32 major, t_uint32 minor1, t_uint32 minor2, t_uint32 minor3) {
const t_core_version_data v = get_version();
if (v.m_major < major) return false;
else if (v.m_major > major) return true;
// major version matches
else if (v.m_minor1 < minor1) return false;
else if (v.m_minor1 > minor1) return true;
// minor1 version matches
else if (v.m_minor2 < minor2) return false;
else if (v.m_minor2 > minor2) return true;
// minor2 version matches
else if (v.m_minor3 < minor3) return false;
else return true;
}
FB2K_MAKE_SERVICE_INTERFACE(core_version_info_v2, core_version_info);
};

View File

@ -1,395 +0,0 @@
#include "foobar2000.h"
#include <math.h>
t_size dsp_chunk_list_impl::get_count() const {return m_data.get_count();}
audio_chunk * dsp_chunk_list_impl::get_item(t_size n) const {return n>=0 && n<m_data.get_count() ? &*m_data[n] : 0;}
void dsp_chunk_list_impl::remove_by_idx(t_size idx)
{
if (idx>=0 && idx<m_data.get_count())
m_recycled.add_item(m_data.remove_by_idx(idx));
}
void dsp_chunk_list_impl::remove_mask(const bit_array & mask)
{
t_size n, m = m_data.get_count();
for(n=0;n<m;n++)
if (mask[m])
m_recycled.add_item(m_data[n]);
m_data.remove_mask(mask);
}
audio_chunk * dsp_chunk_list_impl::insert_item(t_size idx,t_size hint_size)
{
t_size max = get_count();
if (idx<0) idx=0;
else if (idx>max) idx = max;
pfc::rcptr_t<audio_chunk> ret;
if (m_recycled.get_count()>0)
{
t_size best;
if (hint_size>0)
{
best = 0;
t_size best_found = m_recycled[0]->get_data_size(), n, total = m_recycled.get_count();
for(n=1;n<total;n++)
{
if (best_found==hint_size) break;
t_size size = m_recycled[n]->get_data_size();
int delta_old = abs((int)best_found - (int)hint_size), delta_new = abs((int)size - (int)hint_size);
if (delta_new < delta_old)
{
best_found = size;
best = n;
}
}
}
else best = m_recycled.get_count()-1;
ret = m_recycled.remove_by_idx(best);
ret->set_sample_count(0);
ret->set_channels(0);
ret->set_srate(0);
}
else ret = pfc::rcnew_t<audio_chunk_impl>();
if (idx==max) m_data.add_item(ret);
else m_data.insert_item(ret,idx);
return &*ret;
}
void dsp_chunk_list::remove_bad_chunks()
{
bool blah = false;
t_size idx;
for(idx=0;idx<get_count();)
{
audio_chunk * chunk = get_item(idx);
if (!chunk->is_valid())
{
chunk->reset();
remove_by_idx(idx);
blah = true;
}
else idx++;
}
if (blah) console::info("one or more bad chunks removed from dsp chunk list");
}
bool dsp_entry::g_instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset)
{
service_ptr_t<dsp_entry> ptr;
if (!g_get_interface(ptr,p_preset.get_owner())) return false;
return ptr->instantiate(p_out,p_preset);
}
bool dsp_entry::g_instantiate_default(service_ptr_t<dsp> & p_out,const GUID & p_guid)
{
service_ptr_t<dsp_entry> ptr;
if (!g_get_interface(ptr,p_guid)) return false;
dsp_preset_impl preset;
if (!ptr->get_default_preset(preset)) return false;
return ptr->instantiate(p_out,preset);
}
bool dsp_entry::g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid)
{
service_ptr_t<dsp_entry> ptr;
if (!g_get_interface(ptr,p_guid)) return false;
ptr->get_name(p_out);
return true;
}
bool dsp_entry::g_dsp_exists(const GUID & p_guid)
{
service_ptr_t<dsp_entry> blah;
return g_get_interface(blah,p_guid);
}
bool dsp_entry::g_get_default_preset(dsp_preset & p_out,const GUID & p_guid)
{
service_ptr_t<dsp_entry> ptr;
if (!g_get_interface(ptr,p_guid)) return false;
return ptr->get_default_preset(p_out);
}
void dsp_chain_config::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const {
t_size n, count = get_count();
p_stream->write_lendian_t(count,p_abort);
for(n=0;n<count;n++) {
get_item(n).contents_to_stream(p_stream,p_abort);
}
}
void dsp_chain_config::contents_from_stream(stream_reader * p_stream,abort_callback & p_abort) {
t_uint32 n,count;
remove_all();
p_stream->read_lendian_t(count,p_abort);
dsp_preset_impl temp;
for(n=0;n<count;n++) {
temp.contents_from_stream(p_stream,p_abort);
add_item(temp);
}
}
bool cfg_dsp_chain_config::get_data(dsp_chain_config & p_data) const {
p_data.copy(m_data);
return true;
}
void cfg_dsp_chain_config::set_data(const dsp_chain_config & p_data) {
m_data.copy(p_data);
}
void cfg_dsp_chain_config::reset() {
m_data.remove_all();
}
void cfg_dsp_chain_config::get_data_raw(stream_writer * p_stream,abort_callback & p_abort) {
m_data.contents_to_stream(p_stream,p_abort);
}
void cfg_dsp_chain_config::set_data_raw(stream_reader * p_stream,t_size,abort_callback & p_abort) {
m_data.contents_from_stream(p_stream,p_abort);
}
void dsp_chain_config::remove_item(t_size p_index)
{
remove_mask(bit_array_one(p_index));
}
void dsp_chain_config::add_item(const dsp_preset & p_data)
{
insert_item(p_data,get_count());
}
void dsp_chain_config::remove_all()
{
remove_mask(bit_array_true());
}
void dsp_chain_config::instantiate(service_list_t<dsp> & p_out)
{
p_out.remove_all();
t_size n, m = get_count();
for(n=0;n<m;n++)
{
service_ptr_t<dsp> temp;
if (dsp_entry::g_instantiate(temp,get_item(n)))
p_out.add_item(temp);
}
}
t_size dsp_chain_config_impl::get_count() const
{
return m_data.get_count();
}
const dsp_preset & dsp_chain_config_impl::get_item(t_size p_index) const
{
return *m_data[p_index];
}
void dsp_chain_config_impl::replace_item(const dsp_preset & p_data,t_size p_index)
{
*m_data[p_index] = p_data;
}
void dsp_chain_config_impl::insert_item(const dsp_preset & p_data,t_size p_index)
{
m_data.insert_item(new dsp_preset_impl(p_data),p_index);
}
void dsp_chain_config_impl::remove_mask(const bit_array & p_mask)
{
m_data.delete_mask(p_mask);
}
dsp_chain_config_impl::~dsp_chain_config_impl()
{
m_data.delete_all();
}
void dsp_preset::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const {
t_size size = get_data_size();
p_stream->write_lendian_t(get_owner(),p_abort);
p_stream->write_lendian_t(size,p_abort);
if (size > 0) {
p_stream->write_object(get_data(),size,p_abort);
}
}
void dsp_preset::contents_from_stream(stream_reader * p_stream,abort_callback & p_abort) {
t_uint32 size;
GUID guid;
p_stream->read_lendian_t(guid,p_abort);
set_owner(guid);
p_stream->read_lendian_t(size,p_abort);
if (size > 1024*1024*32) throw exception_io_data();
set_data_from_stream(p_stream,size,p_abort);
}
void dsp_preset::g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort) {
t_uint32 size;
GUID guid;
p_stream->read_lendian_t(guid,p_abort);
p_stream->read_lendian_t(size,p_abort);
if (size > 1024*1024*32) throw exception_io_data();
p_stream->skip_object(size,p_abort);
}
void dsp_preset_impl::set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) {
m_data.set_size(p_bytes);
if (p_bytes > 0) p_stream->read_object(m_data.get_ptr(),p_bytes,p_abort);
}
void dsp_chain_config::copy(const dsp_chain_config & p_source) {
remove_all();
t_size n, m = p_source.get_count();
for(n=0;n<m;n++)
add_item(p_source.get_item(n));
}
bool dsp_entry::g_have_config_popup(const GUID & p_guid)
{
service_ptr_t<dsp_entry> entry;
if (!g_get_interface(entry,p_guid)) return false;
return entry->have_config_popup();
}
bool dsp_entry::g_have_config_popup(const dsp_preset & p_preset)
{
return g_have_config_popup(p_preset.get_owner());
}
bool dsp_entry::g_show_config_popup(dsp_preset & p_preset,HWND p_parent)
{
service_ptr_t<dsp_entry> entry;
if (!g_get_interface(entry,p_preset.get_owner())) return false;
return entry->show_config_popup(p_preset,p_parent);
}
void dsp_entry::g_show_config_popup_v2(const dsp_preset & p_preset,HWND p_parent,dsp_preset_edit_callback & p_callback) {
service_ptr_t<dsp_entry> entry;
if (g_get_interface(entry,p_preset.get_owner())) {
service_ptr_t<dsp_entry_v2> entry_v2;
if (entry->service_query_t(entry_v2)) {
entry_v2->show_config_popup_v2(p_preset,p_parent,p_callback);
} else {
dsp_preset_impl temp(p_preset);
if (entry->show_config_popup(temp,p_parent)) p_callback.on_preset_changed(temp);
}
}
}
bool dsp_entry::g_get_interface(service_ptr_t<dsp_entry> & p_out,const GUID & p_guid)
{
service_ptr_t<dsp_entry> ptr;
service_enum_t<dsp_entry> e;
e.reset();
while(e.next(ptr))
{
if (ptr->get_guid() == p_guid)
{
p_out = ptr;
return true;
}
}
return false;
}
bool resampler_entry::g_get_interface(service_ptr_t<resampler_entry> & p_out,unsigned p_srate_from,unsigned p_srate_to)
{
service_ptr_t<dsp_entry> ptr_dsp;
service_ptr_t<resampler_entry> ptr_resampler;
service_enum_t<dsp_entry> e;
e.reset();
float found_priority = 0;
service_ptr_t<resampler_entry> found;
while(e.next(ptr_dsp))
{
if (ptr_dsp->service_query_t(ptr_resampler))
{
if (p_srate_from == 0 || ptr_resampler->is_conversion_supported(p_srate_from,p_srate_to))
{
float priority = ptr_resampler->get_priority();
if (found.is_empty() || priority > found_priority)
{
found = ptr_resampler;
found_priority = priority;
}
}
}
}
if (found.is_empty()) return false;
p_out = found;
return true;
}
bool resampler_entry::g_create_preset(dsp_preset & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale)
{
service_ptr_t<resampler_entry> entry;
if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false;
return entry->create_preset(p_out,p_srate_to,p_qualityscale);
}
bool resampler_entry::g_create(service_ptr_t<dsp> & p_out,unsigned p_srate_from,unsigned p_srate_to,float p_qualityscale)
{
service_ptr_t<resampler_entry> entry;
if (!g_get_interface(entry,p_srate_from,p_srate_to)) return false;
dsp_preset_impl preset;
if (!entry->create_preset(preset,p_srate_to,p_qualityscale)) return false;
return entry->instantiate(p_out,preset);
}
void dsp_chain_config::get_name_list(pfc::string_base & p_out) const
{
const t_size count = get_count();
bool added = false;
for(unsigned n=0;n<count;n++)
{
service_ptr_t<dsp_entry> ptr;
if (dsp_entry::g_get_interface(ptr,get_item(n).get_owner()))
{
if (added) p_out += ", ";
added = true;
pfc::string8 temp;
ptr->get_name(temp);
p_out += temp;
}
}
}
void dsp::run_abortable(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) {
service_ptr_t<dsp_v2> this_v2;
if (this->service_query_t(this_v2)) this_v2->run_v2(p_chunk_list,p_cur_file,p_flags,p_abort);
else run(p_chunk_list,p_cur_file,p_flags);
}
namespace {
class dsp_preset_edit_callback_impl : public dsp_preset_edit_callback {
public:
dsp_preset_edit_callback_impl(dsp_preset & p_data) : m_data(p_data) {}
void on_preset_changed(const dsp_preset & p_data) {m_data = p_data;}
private:
dsp_preset & m_data;
};
};
bool dsp_entry_v2::show_config_popup(dsp_preset & p_data,HWND p_parent) {
PFC_ASSERT(p_data.get_owner() == get_guid());
dsp_preset_impl temp(p_data);
show_config_popup_v2(p_data,p_parent,dsp_preset_edit_callback_impl(temp));
PFC_ASSERT(temp.get_owner() == get_guid());
if (temp == p_data) return false;
p_data = temp;
return true;
}

View File

@ -1,482 +0,0 @@
//! Interface to a DSP chunk list. A DSP chunk list object is passed to the DSP chain each time, since DSPs are allowed to remove processed chunks or insert new ones.
class NOVTABLE dsp_chunk_list {
public:
virtual t_size get_count() const = 0;
virtual audio_chunk * get_item(t_size n) const = 0;
virtual void remove_by_idx(t_size idx) = 0;
virtual void remove_mask(const bit_array & mask) = 0;
virtual audio_chunk * insert_item(t_size idx,t_size hint_size=0) = 0;
audio_chunk * add_item(t_size hint_size=0) {return insert_item(get_count(),hint_size);}
void remove_all() {remove_mask(bit_array_true());}
double get_duration() {
double rv = 0;
t_size n,m = get_count();
for(n=0;n<m;n++) rv += get_item(n)->get_duration();
return rv;
}
void add_chunk(const audio_chunk * chunk) {
audio_chunk * dst = insert_item(get_count(),chunk->get_data_length());
if (dst) dst->copy(*chunk);
}
void remove_bad_chunks();
protected:
dsp_chunk_list() {}
~dsp_chunk_list() {}
};
class dsp_chunk_list_impl : public dsp_chunk_list//implementation
{
pfc::list_t<pfc::rcptr_t<audio_chunk> > m_data, m_recycled;
public:
t_size get_count() const;
audio_chunk * get_item(t_size n) const;
void remove_by_idx(t_size idx);
void remove_mask(const bit_array & mask);
audio_chunk * insert_item(t_size idx,t_size hint_size=0);
};
//! Instance of a DSP.\n
//! Implementation: Derive from dsp_impl_base instead of deriving from dsp directly.\n
//! Instantiation: Use dsp_entry static helper methods to instantiate DSPs, or dsp_chain_config / dsp_manager to deal with entire DSP chains.
class NOVTABLE dsp : public service_base {
public:
enum {
//! Flush whatever you need to when tracks change.
END_OF_TRACK = 1,
//! Flush everything.
FLUSH = 2
};
//! @param p_chunk_list List of chunks to process. The implementation may alter the list in any way, inserting chunks of different sample rate / channel configuration etc.
//! @param p_cur_file Optional, location of currently decoded file. May be null.
//! @param p_flags Flags. Can be null, or a combination of END_OF_TRACK and FLUSH constants.
virtual void run(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags)=0;
//! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc.
virtual void flush() = 0;
//! Retrieves amount of data buffered by the DSP, for syncing visualisation.
//! @returns Amount of buffered audio data, in seconds.
virtual double get_latency() = 0;
//! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n
//! Signaling this will force-flush any DSPs placed before this DSP so when it gets END_OF_TRACK, relevant chunks contain last samples of the track.\n
//! Signaling this will often break regular gapless playback so don't use it unless you have reasons to.
virtual bool need_track_change_mark() = 0;
void run_abortable(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort);
FB2K_MAKE_SERVICE_INTERFACE(dsp,service_base);
};
//! Backwards-compatible extension to dsp interface, allows abortable operation. Introduced in 0.9.2.
class NOVTABLE dsp_v2 : public dsp {
public:
//! Abortable version of dsp::run(). See dsp::run() for descriptions of parameters.
virtual void run_v2(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) = 0;
private:
void run(dsp_chunk_list * p_chunk_list,const metadb_handle_ptr & p_cur_file,int p_flags) {
run_v2(p_chunk_list,p_cur_file,p_flags,abort_callback_dummy());
}
FB2K_MAKE_SERVICE_INTERFACE(dsp_v2,dsp);
};
//! Helper class for implementing dsps. You should derive from dsp_impl_base instead of from dsp directly.\n
//! The dsp_impl_base_t template allows you to use a custom interface class as a base class for your implementation, in case you provide extended functionality.\n
//! Use dsp_factory_t<> template to register your dsp implementation.
//! The implementation - as required by dsp_factory_t<> template - must also provide following methods:\n
//! A constructor taking const dsp_preset&, initializing the DSP with specified preset data.\n
//! static void g_get_name(pfc::string_base &); - retrieving human-readable name of the DSP to display.\n
//! static bool g_get_default_preset(dsp_preset &); - retrieving default preset for this DSP. Return value is reserved for future use and should always be true.\n
//! static GUID g_get_guid(); - retrieving GUID of your DSP implementation, to be used to identify it when storing DSP chain configuration.\n
//! static bool g_have_config_popup(); - retrieving whether your DSP implementation supplies a popup dialog for configuring it.\n
//! static void g_show_config_popup(const dsp_preset & p_data,HWND p_parent, dsp_preset_edit_callback & p_callback); - displaying your DSP's settings dialog; called only when g_have_config_popup() returns true; call p_callback.on_preset_changed() whenever user has made adjustments to the preset data.\n
template<class t_baseclass>
class dsp_impl_base_t : public t_baseclass {
private:
typedef dsp_impl_base_t<t_baseclass> t_self;
dsp_chunk_list * m_list;
t_size m_chunk_ptr;
metadb_handle* m_cur_file;
void run_v2(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort);
protected:
bool get_cur_file(metadb_handle_ptr & p_out) {p_out = m_cur_file; return p_out.is_valid();}// call only from on_chunk / on_endoftrack (on_endoftrack will give info on track being finished); may return null !!
dsp_impl_base_t() : m_list(NULL), m_cur_file(NULL), m_chunk_ptr(0) {}
audio_chunk * insert_chunk(t_size p_hint_size = 0) //call only from on_endoftrack / on_endofplayback / on_chunk
{//hint_size - optional, amout of buffer space you want to use
PFC_ASSERT(m_list != NULL);
return m_list->insert_item(m_chunk_ptr++,p_hint_size);
}
//! To be overridden by a DSP implementation.\n
//! Called on track change. You can use insert_chunk() to dump any data you have to flush. \n
//! Note that you must implement need_track_change_mark() to return true if you need this method called.
virtual void on_endoftrack(abort_callback & p_abort) = 0;
//! To be overridden by a DSP implementation.\n
//! Called at the end of played stream, typically at the end of last played track, to allow the DSP to return all data it has buffered-ahead.\n
//! Use insert_chunk() to return any data you have buffered.\n
//! Note that this call does not imply that the DSP will be destroyed next. \n
//! This is also called on track changes if some DSP placed after your DSP requests track change marks.
virtual void on_endofplayback(abort_callback & p_abort) = 0;
//! To be overridden by a DSP implementation.\n
//! Processes a chunk of audio data.\n
//! You can call insert_chunk() from inside on_chunk() to insert any audio data before currently processed chunk.\n
//! @param p_chunk Current chunk being processed. You can alter it in any way you like.
//! @returns True to keep p_chunk (with alterations made inside on_chunk()) in the stream, false to remove it.
virtual bool on_chunk(audio_chunk * p_chunk,abort_callback & p_abort) = 0;
public:
//! To be overridden by a DSP implementation.\n
//! Flushes the DSP (reinitializes / drops any buffered data). Called after seeking, etc.
virtual void flush() = 0;
//! To be overridden by a DSP implementation.\n
//! Retrieves amount of data buffered by the DSP, for syncing visualisation.
//! @returns Amount of buffered audio data, in seconds.
virtual double get_latency() = 0;
//! To be overridden by a DSP implementation.\n
//! Returns true if DSP needs to know exact track change point (eg. for crossfading, removing silence).\n
//! Signaling this will force-flush any DSPs placed before this DSP so when it gets on_endoftrack(), relevant chunks contain last samples of the track.\n
//! Signaling this may interfere with gapless playback in certain scenarios (forces flush of DSPs placed before you) so don't use it unless you have reasons to.
virtual bool need_track_change_mark() = 0;
private:
dsp_impl_base_t(const t_self&) {throw pfc::exception_bug_check_v2();}
const t_self & operator=(const t_self &) {throw pfc::exception_bug_check_v2();}
};
template<class t_baseclass>
void dsp_impl_base_t<t_baseclass>::run_v2(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,int p_flags,abort_callback & p_abort) {
pfc::vartoggle_t<dsp_chunk_list*> l_list_toggle(m_list,p_list);
pfc::vartoggle_t<metadb_handle*> l_cur_file_toggle(m_cur_file,p_cur_file.get_ptr());
for(m_chunk_ptr = 0;m_chunk_ptr<m_list->get_count();m_chunk_ptr++) {
audio_chunk * c = m_list->get_item(m_chunk_ptr);
if (c->is_empty() || !on_chunk(c,p_abort))
m_list->remove_by_idx(m_chunk_ptr--);
}
if (p_flags & FLUSH) {
on_endofplayback(p_abort);
} else if (p_flags & END_OF_TRACK) {
if (need_track_change_mark()) on_endoftrack(p_abort);
}
}
typedef dsp_impl_base_t<dsp_v2> dsp_impl_base;
class NOVTABLE dsp_preset {
public:
virtual GUID get_owner() const = 0;
virtual void set_owner(const GUID & p_owner) = 0;
virtual const void * get_data() const = 0;
virtual t_size get_data_size() const = 0;
virtual void set_data(const void * p_data,t_size p_data_size) = 0;
virtual void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) = 0;
const dsp_preset & operator=(const dsp_preset & p_source) {copy(p_source); return *this;}
void copy(const dsp_preset & p_source) {set_owner(p_source.get_owner());set_data(p_source.get_data(),p_source.get_data_size());}
void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const;
void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort);
static void g_contents_from_stream_skip(stream_reader * p_stream,abort_callback & p_abort);
bool operator==(const dsp_preset & p_other) const {
if (get_owner() != p_other.get_owner()) return false;
if (get_data_size() != p_other.get_data_size()) return false;
if (memcmp(get_data(),p_other.get_data(),get_data_size()) != 0) return false;
return true;
}
bool operator!=(const dsp_preset & p_other) const {
return !(*this == p_other);
}
protected:
dsp_preset() {}
~dsp_preset() {}
};
class dsp_preset_writer : public stream_writer {
public:
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
p_abort.check();
m_data.append_fromptr((const t_uint8 *) p_buffer,p_bytes);
}
void flush(dsp_preset & p_preset) {
p_preset.set_data(m_data.get_ptr(),m_data.get_size());
m_data.set_size(0);
}
private:
pfc::array_t<t_uint8,pfc::alloc_fast_aggressive> m_data;
};
class dsp_preset_reader : public stream_reader {
public:
dsp_preset_reader() : m_walk(0) {}
dsp_preset_reader(const dsp_preset_reader & p_source) : m_walk(0) {*this = p_source;}
void init(const dsp_preset & p_preset) {
m_data.set_data_fromptr( (const t_uint8*) p_preset.get_data(), p_preset.get_data_size() );
m_walk = 0;
}
t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
p_abort.check();
t_size todo = pfc::min_t<t_size>(p_bytes,m_data.get_size()-m_walk);
memcpy(p_buffer,m_data.get_ptr()+m_walk,todo);
m_walk += todo;
return todo;
}
bool is_finished() {return m_walk == m_data.get_size();}
private:
t_size m_walk;
pfc::array_t<t_uint8> m_data;
};
class dsp_preset_impl : public dsp_preset
{
public:
dsp_preset_impl() {}
dsp_preset_impl(const dsp_preset_impl & p_source) {copy(p_source);}
dsp_preset_impl(const dsp_preset & p_source) {copy(p_source);}
const dsp_preset_impl& operator=(const dsp_preset_impl & p_source) {copy(p_source); return *this;}
const dsp_preset_impl& operator=(const dsp_preset & p_source) {copy(p_source); return *this;}
GUID get_owner() const {return m_owner;}
void set_owner(const GUID & p_owner) {m_owner = p_owner;}
const void * get_data() const {return m_data.get_ptr();}
t_size get_data_size() const {return m_data.get_size();}
void set_data(const void * p_data,t_size p_data_size) {m_data.set_data_fromptr((const t_uint8*)p_data,p_data_size);}
void set_data_from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort);
private:
GUID m_owner;
pfc::array_t<t_uint8> m_data;
};
class NOVTABLE dsp_preset_edit_callback {
public:
virtual void on_preset_changed(const dsp_preset &) = 0;
private:
dsp_preset_edit_callback(const dsp_preset_edit_callback&) {throw pfc::exception_not_implemented();}
const dsp_preset_edit_callback & operator=(const dsp_preset_edit_callback &) {throw pfc::exception_not_implemented();}
protected:
dsp_preset_edit_callback() {}
~dsp_preset_edit_callback() {}
};
class NOVTABLE dsp_entry : public service_base {
public:
virtual void get_name(pfc::string_base & p_out) = 0;
virtual bool get_default_preset(dsp_preset & p_out) = 0;
virtual bool instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset) = 0;
virtual GUID get_guid() = 0;
virtual bool have_config_popup() = 0;
virtual bool show_config_popup(dsp_preset & p_data,HWND p_parent) = 0;
static bool g_get_interface(service_ptr_t<dsp_entry> & p_out,const GUID & p_guid);
static bool g_instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset);
static bool g_instantiate_default(service_ptr_t<dsp> & p_out,const GUID & p_guid);
static bool g_name_from_guid(pfc::string_base & p_out,const GUID & p_guid);
static bool g_dsp_exists(const GUID & p_guid);
static bool g_get_default_preset(dsp_preset & p_out,const GUID & p_guid);
static bool g_have_config_popup(const GUID & p_guid);
static bool g_have_config_popup(const dsp_preset & p_preset);
static bool g_show_config_popup(dsp_preset & p_preset,HWND p_parent);
static void g_show_config_popup_v2(const dsp_preset & p_preset,HWND p_parent,dsp_preset_edit_callback & p_callback);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_entry);
};
class NOVTABLE dsp_entry_v2 : public dsp_entry {
public:
virtual void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) = 0;
private:
bool show_config_popup(dsp_preset & p_data,HWND p_parent);
FB2K_MAKE_SERVICE_INTERFACE(dsp_entry_v2,dsp_entry);
};
template<class T,class t_entry = dsp_entry>
class dsp_entry_impl_nopreset_t : public t_entry {
public:
void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);}
bool get_default_preset(dsp_preset & p_out)
{
p_out.set_owner(T::g_get_guid());
p_out.set_data(0,0);
return true;
}
bool instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset)
{
if (p_preset.get_owner() == T::g_get_guid() && p_preset.get_data_size() == 0)
{
p_out = new service_impl_t<T>();
return p_out.is_valid();
}
else return false;
}
GUID get_guid() {return T::g_get_guid();}
bool have_config_popup() {return false;}
bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return false;}
};
template<class T, class t_entry = dsp_entry_v2>
class dsp_entry_impl_t : public t_entry {
public:
void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);}
bool get_default_preset(dsp_preset & p_out) {return T::g_get_default_preset(p_out);}
bool instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset) {
if (p_preset.get_owner() == T::g_get_guid()) {
p_out = new service_impl_t<T>(p_preset);
return true;
}
else return false;
}
GUID get_guid() {return T::g_get_guid();}
bool have_config_popup() {return T::g_have_config_popup();}
bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return T::g_show_config_popup(p_data,p_parent);}
//void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) {T::g_show_config_popup(p_data,p_parent,p_callback);}
};
template<class T, class t_entry = dsp_entry_v2>
class dsp_entry_v2_impl_t : public t_entry {
public:
void get_name(pfc::string_base & p_out) {T::g_get_name(p_out);}
bool get_default_preset(dsp_preset & p_out) {return T::g_get_default_preset(p_out);}
bool instantiate(service_ptr_t<dsp> & p_out,const dsp_preset & p_preset) {
if (p_preset.get_owner() == T::g_get_guid()) {
p_out = new service_impl_t<T>(p_preset);
return true;
}
else return false;
}
GUID get_guid() {return T::g_get_guid();}
bool have_config_popup() {return T::g_have_config_popup();}
//bool show_config_popup(dsp_preset & p_data,HWND p_parent) {return T::g_show_config_popup(p_data,p_parent);}
void show_config_popup_v2(const dsp_preset & p_data,HWND p_parent,dsp_preset_edit_callback & p_callback) {T::g_show_config_popup(p_data,p_parent,p_callback);}
};
template<class T>
class dsp_factory_nopreset_t : public service_factory_single_t<dsp_entry_impl_nopreset_t<T> > {};
template<class T>
class dsp_factory_t : public service_factory_single_t<dsp_entry_v2_impl_t<T> > {};
class NOVTABLE dsp_chain_config
{
public:
virtual t_size get_count() const = 0;
virtual const dsp_preset & get_item(t_size p_index) const = 0;
virtual void replace_item(const dsp_preset & p_data,t_size p_index) = 0;
virtual void insert_item(const dsp_preset & p_data,t_size p_index) = 0;
virtual void remove_mask(const bit_array & p_mask) = 0;
void remove_item(t_size p_index);
void remove_all();
void add_item(const dsp_preset & p_data);
void copy(const dsp_chain_config & p_source);
const dsp_chain_config & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;}
void contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const;
void contents_from_stream(stream_reader * p_stream,abort_callback & p_abort);
void instantiate(service_list_t<dsp> & p_out);
void get_name_list(pfc::string_base & p_out) const;
};
FB2K_STREAM_READER_OVERLOAD(dsp_chain_config) {
value.contents_from_stream(&stream.m_stream, stream.m_abort); return stream;
}
FB2K_STREAM_WRITER_OVERLOAD(dsp_chain_config) {
value.contents_to_stream(&stream.m_stream, stream.m_abort); return stream;
}
class dsp_chain_config_impl : public dsp_chain_config
{
public:
dsp_chain_config_impl() {}
dsp_chain_config_impl(const dsp_chain_config & p_source) {copy(p_source);}
dsp_chain_config_impl(const dsp_chain_config_impl & p_source) {copy(p_source);}
t_size get_count() const;
const dsp_preset & get_item(t_size p_index) const;
void replace_item(const dsp_preset & p_data,t_size p_index);
void insert_item(const dsp_preset & p_data,t_size p_index);
void remove_mask(const bit_array & p_mask);
const dsp_chain_config_impl & operator=(const dsp_chain_config & p_source) {copy(p_source); return *this;}
const dsp_chain_config_impl & operator=(const dsp_chain_config_impl & p_source) {copy(p_source); return *this;}
~dsp_chain_config_impl();
private:
pfc::ptr_list_t<dsp_preset_impl> m_data;
};
class cfg_dsp_chain_config : public cfg_var {
protected:
void get_data_raw(stream_writer * p_stream,abort_callback & p_abort);
void set_data_raw(stream_reader * p_stream,t_size p_sizehint,abort_callback & p_abort);
public:
void reset();
inline cfg_dsp_chain_config(const GUID & p_guid) : cfg_var(p_guid) {}
t_size get_count() const {return m_data.get_count();}
const dsp_preset & get_item(t_size p_index) const {return m_data.get_item(p_index);}
bool get_data(dsp_chain_config & p_data) const;
void set_data(const dsp_chain_config & p_data);
private:
dsp_chain_config_impl m_data;
};
//! Helper.
class dsp_preset_parser : public stream_reader_formatter<> {
public:
dsp_preset_parser(const dsp_preset & in) : m_data(in), _m_stream(in.get_data(),in.get_data_size()), stream_reader_formatter(_m_stream,_m_abort) {}
void reset() {_m_stream.reset();}
t_size get_remaining() const {return _m_stream.get_remaining();}
void assume_empty() const {
if (get_remaining() != 0) throw exception_io_data();
}
GUID get_owner() const {return m_data.get_owner();}
private:
const dsp_preset & m_data;
abort_callback_dummy _m_abort;
stream_reader_memblock_ref _m_stream;
};
//! Helper.
class dsp_preset_builder : public stream_writer_formatter<> {
public:
dsp_preset_builder() : stream_writer_formatter(_m_stream,_m_abort) {}
void finish(const GUID & id, dsp_preset & out) {
out.set_owner(id);
out.set_data(_m_stream.m_buffer.get_ptr(), _m_stream.m_buffer.get_size());
}
void reset() {
_m_stream.m_buffer.set_size(0);
}
private:
abort_callback_dummy _m_abort;
stream_writer_buffer_simple _m_stream;
};

View File

@ -1,188 +0,0 @@
#include "foobar2000.h"
void dsp_manager::close() {
m_chain.remove_all();
m_config_changed = true;
}
void dsp_manager::set_config( const dsp_chain_config & p_data )
{
//dsp_chain_config::g_instantiate(m_dsp_list,p_data);
m_config.copy(p_data);
m_config_changed = true;
}
void dsp_manager::dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * p_list,const metadb_handle_ptr & cur_file,unsigned flags,double & latency,abort_callback & p_abort)
{
p_list->remove_bad_chunks();
TRACK_CODE("dsp::run",p_iter->m_dsp->run_abortable(p_list,cur_file,flags,p_abort));
TRACK_CODE("dsp::get_latency",latency += p_iter->m_dsp->get_latency());
}
double dsp_manager::run(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,unsigned p_flags,abort_callback & p_abort) {
TRACK_CALL_TEXT("dsp_manager::run");
try {
fpu_control_default l_fpu_control;
double latency=0;
bool done = false;
t_dsp_chain::const_iterator flush_mark;
if ((p_flags & dsp::END_OF_TRACK) && ! (p_flags & dsp::FLUSH)) {
for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) {
if (iter->m_dsp->need_track_change_mark()) flush_mark = iter;
}
}
if (m_config_changed)
{
t_dsp_chain newchain;
bool recycle_available = true;
for(t_size n=0;n<m_config.get_count();n++) {
service_ptr_t<dsp> temp;
const dsp_preset & preset = m_config.get_item(n);
if (dsp_entry::g_dsp_exists(preset.get_owner())) {
t_dsp_chain::iterator iter = newchain.insert_last();
iter->m_preset = m_config.get_item(n);
iter->m_recycle_flag = false;
}
}
//HACK: recycle existing DSPs in a special case when user has apparently only altered settings of one of DSPs.
if (newchain.get_count() == m_chain.get_count()) {
t_size data_mismatch_count = 0;
t_size owner_mismatch_count = 0;
t_dsp_chain::iterator iter_src, iter_dst;
iter_src = m_chain.first(); iter_dst = newchain.first();
while(iter_src.is_valid() && iter_dst.is_valid()) {
if (iter_src->m_preset.get_owner() != iter_dst->m_preset.get_owner()) {
owner_mismatch_count++;
} else if (iter_src->m_preset != iter_dst->m_preset) {
data_mismatch_count++;
}
++iter_src; ++iter_dst;
}
recycle_available = (owner_mismatch_count == 0 && data_mismatch_count <= 1);
} else {
recycle_available = false;
}
if (recycle_available) {
t_dsp_chain::iterator iter_src, iter_dst;
iter_src = m_chain.first(); iter_dst = newchain.first();
while(iter_src.is_valid() && iter_dst.is_valid()) {
if (iter_src->m_preset == iter_dst->m_preset) {
iter_src->m_recycle_flag = true;
iter_dst->m_dsp = iter_src->m_dsp;
}
++iter_src; ++iter_dst;
}
}
for(t_dsp_chain::iterator iter = newchain.first(); iter.is_valid(); ++iter) {
if (iter->m_dsp.is_empty()) {
if (!dsp_entry::g_instantiate(iter->m_dsp,iter->m_preset)) throw pfc::exception_bug_check_v2();
}
}
if (m_chain.get_count()>0) {
bool flushflag = flush_mark.is_valid();
for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) {
unsigned flags2 = p_flags;
if (iter == flush_mark) flushflag = false;
if (flushflag || !iter->m_recycle_flag) flags2|=dsp::FLUSH;
dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort);
}
done = true;
}
m_chain = newchain;
m_config_changed = false;
}
if (!done)
{
bool flushflag = flush_mark.is_valid();
for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) {
unsigned flags2 = p_flags;
if (iter == flush_mark) flushflag = false;
if (flushflag) flags2|=dsp::FLUSH;
dsp_run(iter,p_list,p_cur_file,flags2,latency,p_abort);
}
done = true;
}
p_list->remove_bad_chunks();
return latency;
} catch(...) {
p_list->remove_all();
throw;
}
}
void dsp_manager::flush()
{
for(t_dsp_chain::const_iterator iter = m_chain.first(); iter.is_valid(); ++iter) {
TRACK_CODE("dsp::flush",iter->m_dsp->flush());
}
}
bool dsp_manager::is_active() const {return m_config.get_count()>0;}
void dsp_config_manager::core_enable_dsp(const dsp_preset & preset) {
dsp_chain_config_impl cfg;
get_core_settings(cfg);
bool found = false;
bool changed = false;
t_size n,m = cfg.get_count();
for(n=0;n<m;n++) {
if (cfg.get_item(n).get_owner() == preset.get_owner()) {
found = true;
if (cfg.get_item(n) != preset) {
cfg.replace_item(preset,n);
changed = true;
}
break;
}
}
if (!found) {cfg.insert_item(preset,0); changed = true;}
if (changed) set_core_settings(cfg);
}
void dsp_config_manager::core_disable_dsp(const GUID & id) {
dsp_chain_config_impl cfg;
get_core_settings(cfg);
t_size n,m = cfg.get_count();
bit_array_bittable mask(m);
bool changed = false;
for(n=0;n<m;n++) {
bool axe = (cfg.get_item(n).get_owner() == id) ? true : false;
if (axe) changed = true;
mask.set(n,axe);
}
if (changed) {
cfg.remove_mask(mask);
set_core_settings(cfg);
}
}
bool dsp_config_manager::core_query_dsp(const GUID & id, dsp_preset & out) {
dsp_chain_config_impl cfg;
get_core_settings(cfg);
for(t_size n=0;n<cfg.get_count();n++) {
const dsp_preset & entry = cfg.get_item(n);
if (entry.get_owner() == id) {
out = entry; return true;
}
}
return false;
}

View File

@ -1,81 +0,0 @@
//! Helper class for running audio data through a DSP chain.
class dsp_manager {
public:
dsp_manager() : m_config_changed(false) {}
//! Alters the DSP chain configuration. Should be called before the first run() to set the configuration but can be also called anytime later between run() calls.
void set_config( const dsp_chain_config & p_data );
//! Runs DSP on the specified chunk list.
//! @returns Current DSP latency in seconds.
double run(dsp_chunk_list * p_list,const metadb_handle_ptr & p_cur_file,unsigned p_flags,abort_callback & p_abort);
//! Flushes the DSP (e.g. when seeking).
void flush();
//! Equivalent to set_config() with empty configuration.
void close();
//! Returns whether there's at least one active DSP in the configuration.
bool is_active() const;
private:
struct t_dsp_chain_entry {
service_ptr_t<dsp> m_dsp;
dsp_preset_impl m_preset;
bool m_recycle_flag;
};
typedef pfc::chain_list_v2_t<t_dsp_chain_entry> t_dsp_chain;
t_dsp_chain m_chain;
dsp_chain_config_impl m_config;
bool m_config_changed;
void dsp_run(t_dsp_chain::const_iterator p_iter,dsp_chunk_list * list,const metadb_handle_ptr & cur_file,unsigned flags,double & latency,abort_callback&);
dsp_manager(const dsp_manager &) {throw pfc::exception_not_implemented();}
const dsp_manager & operator=(const dsp_manager&) {throw pfc::exception_not_implemented();}
};
//! Core API for accessing core playback DSP settings as well as spawning DSP configuration dialogs. \n
//! Use static_api_ptr_t<dsp_config_manager>() to instantiate.
class dsp_config_manager : public service_base {
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_manager);
public:
//! Retrieves current core playback DSP settings.
virtual void get_core_settings(dsp_chain_config & p_out) = 0;
//! Changes current core playback DSP settings.
virtual void set_core_settings(const dsp_chain_config & p_data) = 0;
//! Runs a modal DSP settings dialog.
//! @param p_data DSP chain configuration to edit - contains initial configuration to put in the dialog when called, receives the new configuration on successful edit.
//! @returns True when user approved DSP configuration changes (pressed the "OK" button), false when the user cancelled them ("Cancel" button).
virtual bool configure_popup(dsp_chain_config & p_data,HWND p_parent,const char * p_title) = 0;
//! Spawns an embedded DSP settings dialog.
//! @param p_initdata Initial DSP chain configuration to put in the dialog.
//! @param p_parent Parent window to contain the embedded dialog.
//! @param p_id Control ID of the embedded dialog. The parent window will receive a WM_COMMAND with BN_CLICKED and this identifier when user changes settings in the embedded dialog.
//! @param p_from_modal Must be set to true when the parent window is a modal dialog, false otherwise.
virtual HWND configure_embedded(const dsp_chain_config & p_initdata,HWND p_parent,unsigned p_id,bool p_from_modal) = 0;
//! Retrieves current settings from an embedded DSP settings dialog. See also: configure_embedded().
virtual void configure_embedded_retrieve(HWND wnd,dsp_chain_config & p_data) = 0;
//! Changes current settings in an embedded DSP settings dialog. See also: configure_embedded().
virtual void configure_embedded_change(HWND wnd,const dsp_chain_config & p_data) = 0;
//! Helper - enables a DSP in core playback settings.
void core_enable_dsp(const dsp_preset & preset);
//! Helper - disables a DSP in core playback settings.
void core_disable_dsp(const GUID & id);
//! Helper - if a DSP with the specified identifier is present in playback settings, retrieves its configuration and returns true, otherwise returns false.
bool core_query_dsp(const GUID & id, dsp_preset & out);
};
//! Callback class for getting notified about core playback DSP settings getting altered. \n
//! Register your implementations with static service_factory_single_t<myclass> g_myclass_factory;
class NOVTABLE dsp_config_callback : public service_base {
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(dsp_config_callback);
public:
//! Called when core playback DSP settings change. \n
//! Note: you must not try to alter core playback DSP settings inside this callback, or call anything else that possibly alters core playback DSP settings.
virtual void on_core_settings_change(const dsp_chain_config & p_newdata) = 0;
};

View File

@ -1,19 +0,0 @@
class NOVTABLE event_logger : public service_base {
FB2K_MAKE_SERVICE_INTERFACE(event_logger, service_base);
public:
enum {
severity_status,
severity_warning,
severity_error
};
void log_status(const char * line) {log_entry(line, severity_status);}
void log_warning(const char * line) {log_entry(line, severity_warning);}
void log_error(const char * line) {log_entry(line, severity_error);}
virtual void log_entry(const char * line, unsigned severity) = 0;
};
class event_logger_fallback : public event_logger {
public:
void log_entry(const char * line, unsigned) {console::print(line);}
};

View File

@ -1,451 +0,0 @@
#include "foobar2000.h"
t_size file_info::meta_find_ex(const char * p_name,t_size p_name_length) const
{
t_size n, m = meta_get_count();
for(n=0;n<m;n++)
{
if (pfc::stricmp_ascii_ex(meta_enum_name(n),infinite,p_name,p_name_length) == 0) return n;
}
return infinite;
}
bool file_info::meta_exists_ex(const char * p_name,t_size p_name_length) const
{
return meta_find_ex(p_name,p_name_length) != infinite;
}
void file_info::meta_remove_field_ex(const char * p_name,t_size p_name_length)
{
t_size index = meta_find_ex(p_name,p_name_length);
if (index!=infinite) meta_remove_index(index);
}
void file_info::meta_remove_index(t_size p_index)
{
meta_remove_mask(bit_array_one(p_index));
}
void file_info::meta_remove_all()
{
meta_remove_mask(bit_array_true());
}
void file_info::meta_remove_value(t_size p_index,t_size p_value)
{
meta_remove_values(p_index,bit_array_one(p_value));
}
t_size file_info::meta_get_count_by_name_ex(const char * p_name,t_size p_name_length) const
{
t_size index = meta_find_ex(p_name,p_name_length);
if (index == infinite) return 0;
return meta_enum_value_count(index);
}
t_size file_info::info_find_ex(const char * p_name,t_size p_name_length) const
{
t_size n, m = info_get_count();
for(n=0;n<m;n++) {
if (pfc::stricmp_ascii_ex(info_enum_name(n),infinite,p_name,p_name_length) == 0) return n;
}
return infinite;
}
bool file_info::info_exists_ex(const char * p_name,t_size p_name_length) const
{
return info_find_ex(p_name,p_name_length) != infinite;
}
void file_info::info_remove_index(t_size p_index)
{
info_remove_mask(bit_array_one(p_index));
}
void file_info::info_remove_all()
{
info_remove_mask(bit_array_true());
}
bool file_info::info_remove_ex(const char * p_name,t_size p_name_length)
{
t_size index = info_find_ex(p_name,p_name_length);
if (index != infinite)
{
info_remove_index(index);
return true;
}
else return false;
}
void file_info::copy_meta_single(const file_info & p_source,t_size p_index)
{
copy_meta_single_rename(p_source,p_index,p_source.meta_enum_name(p_index));
}
void file_info::copy_meta_single_nocheck(const file_info & p_source,t_size p_index)
{
const char * name = p_source.meta_enum_name(p_index);
t_size n, m = p_source.meta_enum_value_count(p_index);
t_size new_index = infinite;
for(n=0;n<m;n++)
{
const char * value = p_source.meta_enum_value(p_index,n);
if (n == 0) new_index = meta_set_nocheck(name,value);
else meta_add_value(new_index,value);
}
}
void file_info::copy_meta_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length)
{
t_size index = p_source.meta_find_ex(p_name,p_name_length);
if (index != infinite) copy_meta_single(p_source,index);
}
void file_info::copy_info_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length)
{
t_size index = p_source.info_find_ex(p_name,p_name_length);
if (index != infinite) copy_info_single(p_source,index);
}
void file_info::copy_meta_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length)
{
t_size index = p_source.meta_find_ex(p_name,p_name_length);
if (index != infinite) copy_meta_single_nocheck(p_source,index);
}
void file_info::copy_info_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length)
{
t_size index = p_source.info_find_ex(p_name,p_name_length);
if (index != infinite) copy_info_single_nocheck(p_source,index);
}
void file_info::copy_info_single(const file_info & p_source,t_size p_index)
{
info_set(p_source.info_enum_name(p_index),p_source.info_enum_value(p_index));
}
void file_info::copy_info_single_nocheck(const file_info & p_source,t_size p_index)
{
info_set_nocheck(p_source.info_enum_name(p_index),p_source.info_enum_value(p_index));
}
void file_info::copy_meta(const file_info & p_source)
{
if (&p_source != this) {
meta_remove_all();
t_size n, m = p_source.meta_get_count();
for(n=0;n<m;n++)
copy_meta_single_nocheck(p_source,n);
}
}
void file_info::copy_info(const file_info & p_source)
{
if (&p_source != this) {
info_remove_all();
t_size n, m = p_source.info_get_count();
for(n=0;n<m;n++)
copy_info_single_nocheck(p_source,n);
}
}
void file_info::copy(const file_info & p_source)
{
if (&p_source != this) {
copy_meta(p_source);
copy_info(p_source);
set_length(p_source.get_length());
set_replaygain(p_source.get_replaygain());
}
}
const char * file_info::meta_get_ex(const char * p_name,t_size p_name_length,t_size p_index) const
{
t_size index = meta_find_ex(p_name,p_name_length);
if (index == infinite) return 0;
t_size max = meta_enum_value_count(index);
if (p_index >= max) return 0;
return meta_enum_value(index,p_index);
}
const char * file_info::info_get_ex(const char * p_name,t_size p_name_length) const
{
t_size index = info_find_ex(p_name,p_name_length);
if (index == infinite) return 0;
return info_enum_value(index);
}
t_int64 file_info::info_get_int(const char * name) const
{
PFC_ASSERT(pfc::is_valid_utf8(name));
const char * val = info_get(name);
if (val==0) return 0;
return _atoi64(val);
}
t_int64 file_info::info_get_length_samples() const
{
t_int64 ret = 0;
double len = get_length();
t_int64 srate = info_get_int("samplerate");
if (srate>0 && len>0)
{
ret = audio_math::time_to_samples(len,(unsigned)srate);
}
return ret;
}
double file_info::info_get_float(const char * name) const
{
const char * ptr = info_get(name);
if (ptr) return pfc::string_to_float(ptr);
else return 0;
}
void file_info::info_set_int(const char * name,t_int64 value)
{
PFC_ASSERT(pfc::is_valid_utf8(name));
info_set(name,pfc::format_int(value));
}
void file_info::info_set_float(const char * name,double value,unsigned precision,bool force_sign,const char * unit)
{
PFC_ASSERT(pfc::is_valid_utf8(name));
PFC_ASSERT(unit==0 || strlen(unit) <= 64);
char temp[128];
pfc::float_to_string(temp,64,value,precision,force_sign);
temp[63] = 0;
if (unit)
{
strcat(temp," ");
strcat(temp,unit);
}
info_set(name,temp);
}
void file_info::info_set_replaygain_album_gain(float value)
{
replaygain_info temp = get_replaygain();
temp.m_album_gain = value;
set_replaygain(temp);
}
void file_info::info_set_replaygain_album_peak(float value)
{
replaygain_info temp = get_replaygain();
temp.m_album_peak = value;
set_replaygain(temp);
}
void file_info::info_set_replaygain_track_gain(float value)
{
replaygain_info temp = get_replaygain();
temp.m_track_gain = value;
set_replaygain(temp);
}
void file_info::info_set_replaygain_track_peak(float value)
{
replaygain_info temp = get_replaygain();
temp.m_track_peak = value;
set_replaygain(temp);
}
static bool is_valid_bps(t_int64 val)
{
return val>0 && val<=256;
}
unsigned file_info::info_get_decoded_bps() const
{
t_int64 val = info_get_int("decoded_bitspersample");
if (is_valid_bps(val)) return (unsigned)val;
val = info_get_int("bitspersample");
if (is_valid_bps(val)) return (unsigned)val;
return 0;
}
void file_info::reset()
{
info_remove_all();
meta_remove_all();
set_length(0);
reset_replaygain();
}
void file_info::reset_replaygain()
{
replaygain_info temp;
temp.reset();
set_replaygain(temp);
}
void file_info::copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length)
{
t_size n, m = p_source.meta_enum_value_count(p_index);
t_size new_index = infinite;
for(n=0;n<m;n++)
{
const char * value = p_source.meta_enum_value(p_index,n);
if (n == 0) new_index = meta_set_ex(p_new_name,p_new_name_length,value,infinite);
else meta_add_value(new_index,value);
}
}
t_size file_info::meta_add_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
t_size index = meta_find_ex(p_name,p_name_length);
if (index == infinite) return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
else
{
meta_add_value_ex(index,p_value,p_value_length);
return index;
}
}
void file_info::meta_add_value_ex(t_size p_index,const char * p_value,t_size p_value_length)
{
meta_insert_value_ex(p_index,meta_enum_value_count(p_index),p_value,p_value_length);
}
t_size file_info::meta_calc_total_value_count() const
{
t_size n, m = meta_get_count(), ret = 0;
for(n=0;n<m;n++) ret += meta_enum_value_count(n);
return ret;
}
bool file_info::info_set_replaygain_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len)
{
replaygain_info temp = get_replaygain();
if (temp.set_from_meta_ex(p_name,p_name_len,p_value,p_value_len))
{
set_replaygain(temp);
return true;
}
else return false;
}
void file_info::info_set_replaygain_auto_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len)
{
if (!info_set_replaygain_ex(p_name,p_name_len,p_value,p_value_len))
info_set_ex(p_name,p_name_len,p_value,p_value_len);
}
bool replaygain_info::g_equal(const replaygain_info & item1,const replaygain_info & item2)
{
return item1.m_album_gain == item2.m_album_gain &&
item1.m_track_gain == item2.m_track_gain &&
item1.m_album_peak == item2.m_album_peak &&
item1.m_track_peak == item2.m_track_peak;
}
bool file_info::are_meta_fields_identical(t_size p_index1,t_size p_index2) const
{
const t_size count = meta_enum_value_count(p_index1);
if (count != meta_enum_value_count(p_index2)) return false;
t_size n;
for(n=0;n<count;n++)
{
if (strcmp(meta_enum_value(p_index1,n),meta_enum_value(p_index2,n))) return false;
}
return true;
}
void file_info::meta_format_entry(t_size index, pfc::string_base & out, const char * separator) const {
out.reset();
t_size val, count = meta_enum_value_count(index);
PFC_ASSERT( count > 0);
for(val=0;val<count;val++)
{
if (val > 0) out += separator;
out += meta_enum_value(index,val);
}
}
bool file_info::meta_format(const char * p_name,pfc::string_base & p_out, const char * separator) const {
p_out.reset();
t_size index = meta_find(p_name);
if (index == infinite) return false;
meta_format_entry(index, p_out, separator);
return true;
}
void file_info::info_calculate_bitrate(t_filesize p_filesize,double p_length)
{
info_set_bitrate((unsigned)floor((double)p_filesize * 8 / (p_length * 1000) + 0.5));
}
bool file_info::is_encoding_lossy() const {
const char * encoding = info_get("encoding");
if (encoding != NULL) {
if (pfc::stricmp_ascii(encoding,"lossy") == 0 /*|| pfc::stricmp_ascii(encoding,"hybrid") == 0*/) return true;
} else {
//the old way
if (info_get("bitspersample") == NULL) return true;
}
return false;
}
bool file_info::g_is_meta_equal(const file_info & p_item1,const file_info & p_item2) {
const t_size count = p_item1.meta_get_count();
if (count != p_item2.meta_get_count()) {
//uDebugLog() << "meta count mismatch";
return false;
}
pfc::map_t<const char*,t_size,field_name_comparator> item2_meta_map;
for(t_size n=0; n<count; n++) {
item2_meta_map.set(p_item2.meta_enum_name(n),n);
}
for(t_size n1=0; n1<count; n1++) {
t_size n2;
if (!item2_meta_map.query(p_item1.meta_enum_name(n1),n2)) {
//uDebugLog() << "item2 doesn't have " << p_item1.meta_enum_name(n1);
return false;
}
t_size value_count = p_item1.meta_enum_value_count(n1);
if (value_count != p_item2.meta_enum_value_count(n2)) {
//uDebugLog() << "meta value count mismatch: " << p_item1.meta_enum_name(n1) << " : " << value_count << " vs " << p_item2.meta_enum_value_count(n2);
return false;
}
for(t_size v = 0; v < value_count; v++) {
if (strcmp(p_item1.meta_enum_value(n1,v),p_item2.meta_enum_value(n2,v)) != 0) {
//uDebugLog() << "meta mismatch: " << p_item1.meta_enum_name(n1) << " : " << p_item1.meta_enum_value(n1,v) << " vs " << p_item2.meta_enum_value(n2,v);
return false;
}
}
}
return true;
}
bool file_info::g_is_info_equal(const file_info & p_item1,const file_info & p_item2) {
t_size count = p_item1.info_get_count();
if (count != p_item2.info_get_count()) return false;
for(t_size n1=0; n1<count; n1++) {
t_size n2 = p_item2.info_find(p_item1.info_enum_name(n1));
if (n2 == infinite) return false;
if (strcmp(p_item1.info_enum_value(n1),p_item2.info_enum_value(n2)) != 0) return false;
}
return true;
}
static bool is_valid_field_name_char(char p_char) {
return p_char >= 32 && p_char < 127 && p_char != '=' && p_char != '%' && p_char != '<' && p_char != '>';
}
bool file_info::g_is_valid_field_name(const char * p_name,t_size p_length) {
t_size walk;
for(walk = 0; walk < p_length && p_name[walk] != 0; walk++) {
if (!is_valid_field_name_char(p_name[walk])) return false;
}
return walk > 0;
}

View File

@ -1,230 +0,0 @@
#ifndef _FILE_INFO_H_
#define _FILE_INFO_H_
//! Structure containing ReplayGain scan results from some playable object, also providing various helper methods to manipulate those results.
struct replaygain_info
{
float m_album_gain,m_track_gain;
float m_album_peak,m_track_peak;
enum {text_buffer_size = 16 };
typedef char t_text_buffer[text_buffer_size];
enum { peak_invalid = -1, gain_invalid = -1000 };
static bool g_format_gain(float p_value,char p_buffer[text_buffer_size]);
static bool g_format_peak(float p_value,char p_buffer[text_buffer_size]);
inline bool format_album_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_album_gain,p_buffer);}
inline bool format_track_gain(char p_buffer[text_buffer_size]) const {return g_format_gain(m_track_gain,p_buffer);}
inline bool format_album_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_album_peak,p_buffer);}
inline bool format_track_peak(char p_buffer[text_buffer_size]) const {return g_format_peak(m_track_peak,p_buffer);}
void set_album_gain_text(const char * p_text,t_size p_text_len = infinite);
void set_track_gain_text(const char * p_text,t_size p_text_len = infinite);
void set_album_peak_text(const char * p_text,t_size p_text_len = infinite);
void set_track_peak_text(const char * p_text,t_size p_text_len = infinite);
static bool g_is_meta_replaygain(const char * p_name,t_size p_name_len = infinite);
bool set_from_meta_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
inline bool set_from_meta(const char * p_name,const char * p_value) {return set_from_meta_ex(p_name,infinite,p_value,infinite);}
inline bool is_album_gain_present() const {return m_album_gain != gain_invalid;}
inline bool is_track_gain_present() const {return m_track_gain != gain_invalid;}
inline bool is_album_peak_present() const {return m_album_peak != peak_invalid;}
inline bool is_track_peak_present() const {return m_track_peak != peak_invalid;}
inline void remove_album_gain() {m_album_gain = gain_invalid;}
inline void remove_track_gain() {m_track_gain = gain_invalid;}
inline void remove_album_peak() {m_album_peak = peak_invalid;}
inline void remove_track_peak() {m_track_peak = peak_invalid;}
t_size get_value_count();
static replaygain_info g_merge(replaygain_info r1,replaygain_info r2);
static bool g_equal(const replaygain_info & item1,const replaygain_info & item2);
void reset();
};
inline bool operator==(const replaygain_info & item1,const replaygain_info & item2) {return replaygain_info::g_equal(item1,item2);}
inline bool operator!=(const replaygain_info & item1,const replaygain_info & item2) {return !replaygain_info::g_equal(item1,item2);}
static const replaygain_info replaygain_info_invalid = {replaygain_info::gain_invalid,replaygain_info::gain_invalid,replaygain_info::peak_invalid,replaygain_info::peak_invalid};
//! Main interface class for information about some playable object.
class NOVTABLE file_info {
public:
//! Retrieves length, in seconds.
virtual double get_length() const = 0;
//! Sets length, in seconds.
virtual void set_length(double p_length) = 0;
//! Sets ReplayGain information.
virtual void set_replaygain(const replaygain_info & p_info) = 0;
//! Retrieves ReplayGain information.
virtual replaygain_info get_replaygain() const = 0;
//! Retrieves count of metadata entries.
virtual t_size meta_get_count() const = 0;
//! Retrieves the name of metadata entry of specified index. Return value is a null-terminated UTF-8 encoded string.
virtual const char* meta_enum_name(t_size p_index) const = 0;
//! Retrieves count of values in metadata entry of specified index. The value is always equal to or greater than 1.
virtual t_size meta_enum_value_count(t_size p_index) const = 0;
//! Retrieves specified value from specified metadata entry. Return value is a null-terminated UTF-8 encoded string.
virtual const char* meta_enum_value(t_size p_index,t_size p_value_number) const = 0;
//! Finds index of metadata entry of specified name. Returns infinite when not found.
virtual t_size meta_find_ex(const char * p_name,t_size p_name_length) const;
//! Creates a new metadata entry of specified name with specified value. If an entry of same name already exists, it is erased. Return value is the index of newly created metadata entry.
virtual t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0;
//! Inserts a new value into specified metadata entry.
virtual void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0;
//! Removes metadata entries according to specified bit mask.
virtual void meta_remove_mask(const bit_array & p_mask) = 0;
//! Reorders metadata entries according to specified permutation.
virtual void meta_reorder(const t_size * p_order) = 0;
//! Removes values according to specified bit mask from specified metadata entry. If all values are removed, entire metadata entry is removed as well.
virtual void meta_remove_values(t_size p_index,const bit_array & p_mask) = 0;
//! Alters specified value in specified metadata entry.
virtual void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length) = 0;
//! Retrieves number of technical info entries.
virtual t_size info_get_count() const = 0;
//! Retrieves the name of specified technical info entry. Return value is a null-terminated UTF-8 encoded string.
virtual const char* info_enum_name(t_size p_index) const = 0;
//! Retrieves the value of specified technical info entry. Return value is a null-terminated UTF-8 encoded string.
virtual const char* info_enum_value(t_size p_index) const = 0;
//! Creates a new technical info entry with specified name and specified value. If an entry of the same name already exists, it is erased. Return value is the index of newly created entry.
virtual t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0;
//! Removes technical info entries indicated by specified bit mask.
virtual void info_remove_mask(const bit_array & p_mask) = 0;
//! Finds technical info entry of specified name. Returns index of found entry on success, infinite on failure.
virtual t_size info_find_ex(const char * p_name,t_size p_name_length) const;
//! Copies entire file_info contents from specified file_info object.
virtual void copy(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
//! Copies metadata from specified file_info object.
virtual void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
//! Copies technical info from specified file_info object.
virtual void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
bool meta_exists_ex(const char * p_name,t_size p_name_length) const;
void meta_remove_field_ex(const char * p_name,t_size p_name_length);
void meta_remove_index(t_size p_index);
void meta_remove_all();
void meta_remove_value(t_size p_index,t_size p_value);
const char * meta_get_ex(const char * p_name,t_size p_name_length,t_size p_index) const;
t_size meta_get_count_by_name_ex(const char * p_name,t_size p_name_length) const;
void meta_add_value_ex(t_size p_index,const char * p_value,t_size p_value_length);
t_size meta_add_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
t_size meta_calc_total_value_count() const;
bool meta_format(const char * p_name,pfc::string_base & p_out, const char * separator = ", ") const;
void meta_format_entry(t_size index, pfc::string_base & p_out, const char * separator = ", ") const;//same as meta_format but takes index instead of meta name.
bool info_exists_ex(const char * p_name,t_size p_name_length) const;
void info_remove_index(t_size p_index);
void info_remove_all();
bool info_remove_ex(const char * p_name,t_size p_name_length);
const char * info_get_ex(const char * p_name,t_size p_name_length) const;
inline t_size meta_find(const char * p_name) const {return meta_find_ex(p_name,infinite);}
inline bool meta_exists(const char * p_name) const {return meta_exists_ex(p_name,infinite);}
inline void meta_remove_field(const char * p_name) {meta_remove_field_ex(p_name,infinite);}
inline t_size meta_set(const char * p_name,const char * p_value) {return meta_set_ex(p_name,infinite,p_value,infinite);}
inline void meta_insert_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_insert_value_ex(p_index,p_value_index,p_value,infinite);}
inline void meta_add_value(t_size p_index,const char * p_value) {meta_add_value_ex(p_index,p_value,infinite);}
inline const char* meta_get(const char * p_name,t_size p_index) const {return meta_get_ex(p_name,infinite,p_index);}
inline t_size meta_get_count_by_name(const char * p_name) const {return meta_get_count_by_name_ex(p_name,infinite);}
inline t_size meta_add(const char * p_name,const char * p_value) {return meta_add_ex(p_name,infinite,p_value,infinite);}
inline void meta_modify_value(t_size p_index,t_size p_value_index,const char * p_value) {meta_modify_value_ex(p_index,p_value_index,p_value,infinite);}
inline t_size info_set(const char * p_name,const char * p_value) {return info_set_ex(p_name,infinite,p_value,infinite);}
inline t_size info_find(const char * p_name) const {return info_find_ex(p_name,infinite);}
inline t_size info_exists(const char * p_name) const {return info_exists_ex(p_name,infinite);}
inline bool info_remove(const char * p_name) {return info_remove_ex(p_name,infinite);}
inline const char * info_get(const char * p_name) const {return info_get_ex(p_name,infinite);}
bool info_set_replaygain_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
inline bool info_set_replaygain(const char * p_name,const char * p_value) {return info_set_replaygain_ex(p_name,infinite,p_value,infinite);}
void info_set_replaygain_auto_ex(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
inline void info_set_replaygain_auto(const char * p_name,const char * p_value) {info_set_replaygain_auto_ex(p_name,infinite,p_value,infinite);}
void copy_meta_single(const file_info & p_source,t_size p_index);
void copy_info_single(const file_info & p_source,t_size p_index);
void copy_meta_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length);
void copy_info_single_by_name_ex(const file_info & p_source,const char * p_name,t_size p_name_length);
inline void copy_meta_single_by_name(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_ex(p_source,p_name,infinite);}
inline void copy_info_single_by_name(const file_info & p_source,const char * p_name) {copy_info_single_by_name_ex(p_source,p_name,infinite);}
void reset();
void reset_replaygain();
void copy_meta_single_rename_ex(const file_info & p_source,t_size p_index,const char * p_new_name,t_size p_new_name_length);
inline void copy_meta_single_rename(const file_info & p_source,t_size p_index,const char * p_new_name) {copy_meta_single_rename_ex(p_source,p_index,p_new_name,infinite);}
void overwrite_info(const file_info & p_source);
t_int64 info_get_int(const char * name) const;
t_int64 info_get_length_samples() const;
double info_get_float(const char * name) const;
void info_set_int(const char * name,t_int64 value);
void info_set_float(const char * name,double value,unsigned precision,bool force_sign = false,const char * unit = 0);
void info_set_replaygain_track_gain(float value);
void info_set_replaygain_album_gain(float value);
void info_set_replaygain_track_peak(float value);
void info_set_replaygain_album_peak(float value);
inline t_int64 info_get_bitrate_vbr() const {return info_get_int("bitrate_dynamic");}
inline void info_set_bitrate_vbr(t_int64 val) {info_set_int("bitrate_dynamic",val);}
inline t_int64 info_get_bitrate() const {return info_get_int("bitrate");}
inline void info_set_bitrate(t_int64 val) {info_set_int("bitrate",val);}
bool is_encoding_lossy() const;
void info_calculate_bitrate(t_filesize p_filesize,double p_length);
unsigned info_get_decoded_bps() const;//what bps the stream originally was (before converting to audio_sample), 0 if unknown
void merge(const pfc::list_base_const_t<const file_info*> & p_sources);
bool are_meta_fields_identical(t_size p_index1,t_size p_index2) const;
inline const file_info & operator=(const file_info & p_source) {copy(p_source);return *this;}
static bool g_is_meta_equal(const file_info & p_item1,const file_info & p_item2);
static bool g_is_info_equal(const file_info & p_item1,const file_info & p_item2);
//! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.
t_size __meta_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);}
//! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.
t_size __meta_add_unsafe(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,infinite,p_value,infinite);}
//! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.
t_size __info_add_unsafe_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);}
//! Unsafe - does not check whether the field already exists and will result in duplicates if it does - call only when appropriate checks have been applied externally.
t_size __info_add_unsafe(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,infinite,p_value,infinite);}
static bool g_is_valid_field_name(const char * p_name,t_size p_length = infinite);
//typedef pfc::comparator_stricmp_ascii field_name_comparator;
typedef pfc::string::comparatorCaseInsensitiveASCII field_name_comparator;
protected:
file_info() {}
~file_info() {}
void copy_meta_single_nocheck(const file_info & p_source,t_size p_index);
void copy_info_single_nocheck(const file_info & p_source,t_size p_index);
void copy_meta_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length);
void copy_info_single_by_name_nocheck_ex(const file_info & p_source,const char * p_name,t_size p_name_length);
inline void copy_meta_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_meta_single_by_name_nocheck_ex(p_source,p_name,infinite);}
inline void copy_info_single_by_name_nocheck(const file_info & p_source,const char * p_name) {copy_info_single_by_name_nocheck_ex(p_source,p_name,infinite);}
virtual t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0;
virtual t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) = 0;
inline t_size meta_set_nocheck(const char * p_name,const char * p_value) {return meta_set_nocheck_ex(p_name,infinite,p_value,infinite);}
inline t_size info_set_nocheck(const char * p_name,const char * p_value) {return info_set_nocheck_ex(p_name,infinite,p_value,infinite);}
};
#endif //_FILE_INFO_H_

View File

@ -1,243 +0,0 @@
#include "foobar2000.h"
t_size file_info_impl::meta_get_count() const
{
return m_meta.get_count();
}
const char* file_info_impl::meta_enum_name(t_size p_index) const
{
return m_meta.get_name(p_index);
}
t_size file_info_impl::meta_enum_value_count(t_size p_index) const
{
return m_meta.get_value_count(p_index);
}
const char* file_info_impl::meta_enum_value(t_size p_index,t_size p_value_number) const
{
return m_meta.get_value(p_index,p_value_number);
}
t_size file_info_impl::meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
meta_remove_field_ex(p_name,p_name_length);
return meta_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
}
t_size file_info_impl::meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
return m_meta.add_entry(p_name,p_name_length,p_value,p_value_length);
}
void file_info_impl::meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
{
m_meta.insert_value(p_index,p_value_index,p_value,p_value_length);
}
void file_info_impl::meta_remove_mask(const bit_array & p_mask)
{
m_meta.remove_mask(p_mask);
}
void file_info_impl::meta_reorder(const t_size * p_order)
{
m_meta.reorder(p_order);
}
void file_info_impl::meta_remove_values(t_size p_index,const bit_array & p_mask)
{
m_meta.remove_values(p_index,p_mask);
if (m_meta.get_value_count(p_index) == 0)
m_meta.remove_mask(bit_array_one(p_index));
}
t_size file_info_impl::info_get_count() const
{
return m_info.get_count();
}
const char* file_info_impl::info_enum_name(t_size p_index) const
{
return m_info.get_name(p_index);
}
const char* file_info_impl::info_enum_value(t_size p_index) const
{
return m_info.get_value(p_index);
}
t_size file_info_impl::info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
info_remove_ex(p_name,p_name_length);
return info_set_nocheck_ex(p_name,p_name_length,p_value,p_value_length);
}
t_size file_info_impl::info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
return m_info.add_item(p_name,p_name_length,p_value,p_value_length);
}
void file_info_impl::info_remove_mask(const bit_array & p_mask)
{
m_info.remove_mask(p_mask);
}
file_info_impl::file_info_impl(const file_info & p_source) : m_length(0)
{
copy(p_source);
}
file_info_impl::file_info_impl(const file_info_impl & p_source) : m_length(0)
{
copy(p_source);
}
const file_info_impl & file_info_impl::operator=(const file_info_impl & p_source)
{
copy(p_source);
return *this;
}
file_info_impl::file_info_impl() : m_length(0)
{
m_replaygain.reset();
}
double file_info_impl::get_length() const
{
return m_length;
}
void file_info_impl::set_length(double p_length)
{
m_length = p_length;
}
void file_info_impl::meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
{
m_meta.modify_value(p_index,p_value_index,p_value,p_value_length);
}
replaygain_info file_info_impl::get_replaygain() const
{
return m_replaygain;
}
void file_info_impl::set_replaygain(const replaygain_info & p_info)
{
m_replaygain = p_info;
}
file_info_impl::~file_info_impl()
{
}
t_size file_info_impl_utils::info_storage::add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length) {
t_size index = m_info.get_size();
m_info.set_size(index + 1);
m_info[index].init(p_name,p_name_length,p_value,p_value_length);
return index;
}
void file_info_impl_utils::info_storage::remove_mask(const bit_array & p_mask) {
pfc::remove_mask_t(m_info,p_mask);
}
t_size file_info_impl_utils::meta_storage::add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length)
{
meta_entry temp(p_name,p_name_length,p_value,p_value_length);
return pfc::append_swap_t(m_data,temp);
}
void file_info_impl_utils::meta_storage::insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
{
m_data[p_index].insert_value(p_value_index,p_value,p_value_length);
}
void file_info_impl_utils::meta_storage::modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length)
{
m_data[p_index].modify_value(p_value_index,p_value,p_value_length);
}
void file_info_impl_utils::meta_storage::remove_values(t_size p_index,const bit_array & p_mask)
{
m_data[p_index].remove_values(p_mask);
}
void file_info_impl_utils::meta_storage::remove_mask(const bit_array & p_mask)
{
pfc::remove_mask_t(m_data,p_mask);
}
file_info_impl_utils::meta_entry::meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len)
{
m_name.set_string(p_name,p_name_len);
m_values.set_size(1);
m_values[0].set_string(p_value,p_value_len);
}
void file_info_impl_utils::meta_entry::remove_values(const bit_array & p_mask)
{
pfc::remove_mask_t(m_values,p_mask);
}
void file_info_impl_utils::meta_entry::insert_value(t_size p_value_index,const char * p_value,t_size p_value_length)
{
pfc::string_simple temp;
temp.set_string(p_value,p_value_length);
pfc::insert_swap_t(m_values,temp,p_value_index);
}
void file_info_impl_utils::meta_entry::modify_value(t_size p_value_index,const char * p_value,t_size p_value_length)
{
m_values[p_value_index].set_string(p_value,p_value_length);
}
void file_info_impl_utils::meta_storage::reorder(const t_size * p_order)
{
pfc::reorder_t(m_data,p_order,m_data.get_size());
}
void file_info_impl::copy_meta(const file_info & p_source)
{
m_meta.copy_from(p_source);
}
void file_info_impl::copy_info(const file_info & p_source)
{
m_info.copy_from(p_source);
}
void file_info_impl_utils::meta_storage::copy_from(const file_info & p_info)
{
t_size meta_index,meta_count = p_info.meta_get_count();
m_data.set_size(meta_count);
for(meta_index=0;meta_index<meta_count;meta_index++)
{
meta_entry & entry = m_data[meta_index];
t_size value_index,value_count = p_info.meta_enum_value_count(meta_index);
entry.m_name = p_info.meta_enum_name(meta_index);
entry.m_values.set_size(value_count);
for(value_index=0;value_index<value_count;value_index++)
entry.m_values[value_index] = p_info.meta_enum_value(meta_index,value_index);
}
}
void file_info_impl_utils::info_storage::copy_from(const file_info & p_info)
{
t_size n, count;
count = p_info.info_get_count();
m_info.set_count(count);
for(n=0;n<count;n++) m_info[n].init(p_info.info_enum_name(n),infinite,p_info.info_enum_value(n),infinite);
}

View File

@ -1,144 +0,0 @@
#ifndef _FOOBAR2000_SDK_FILE_INFO_IMPL_H_
#define _FOOBAR2000_SDK_FILE_INFO_IMPL_H_
namespace file_info_impl_utils {
struct info_entry {
void init(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len) {
m_name.set_string(p_name,p_name_len);
m_value.set_string(p_value,p_value_len);
}
inline const char * get_name() const {return m_name;}
inline const char * get_value() const {return m_value;}
pfc::string_simple m_name,m_value;
};
typedef pfc::array_t<info_entry,pfc::alloc_fast> info_entry_array;
}
namespace pfc {
template<> class traits_t<file_info_impl_utils::info_entry> : public traits_t<pfc::string_simple> {};
};
namespace file_info_impl_utils {
class info_storage
{
public:
t_size add_item(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
void remove_mask(const bit_array & p_mask);
inline t_size get_count() const {return m_info.get_count();}
inline const char * get_name(t_size p_index) const {return m_info[p_index].get_name();}
inline const char * get_value(t_size p_index) const {return m_info[p_index].get_value();}
void copy_from(const file_info & p_info);
private:
info_entry_array m_info;
};
}
namespace file_info_impl_utils {
typedef pfc::array_hybrid_t<pfc::string_simple,1,pfc::alloc_fast > meta_value_array;
struct meta_entry {
meta_entry() {}
meta_entry(const char * p_name,t_size p_name_len,const char * p_value,t_size p_value_len);
void remove_values(const bit_array & p_mask);
void insert_value(t_size p_value_index,const char * p_value,t_size p_value_length);
void modify_value(t_size p_value_index,const char * p_value,t_size p_value_length);
inline const char * get_name() const {return m_name;}
inline const char * get_value(t_size p_index) const {return m_values[p_index];}
inline t_size get_value_count() const {return m_values.get_size();}
pfc::string_simple m_name;
meta_value_array m_values;
};
typedef pfc::array_hybrid_t<meta_entry,10, pfc::alloc_fast> meta_entry_array;
}
namespace pfc {
template<> class traits_t<file_info_impl_utils::meta_entry> : public pfc::traits_combined<pfc::string_simple,file_info_impl_utils::meta_value_array> {};
}
namespace file_info_impl_utils {
class meta_storage
{
public:
t_size add_entry(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
void insert_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
void modify_value(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
void remove_values(t_size p_index,const bit_array & p_mask);
void remove_mask(const bit_array & p_mask);
void copy_from(const file_info & p_info);
inline void reorder(const t_size * p_order);
inline t_size get_count() const {return m_data.get_size();}
inline const char * get_name(t_size p_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_name();}
inline const char * get_value(t_size p_index,t_size p_value_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_value(p_value_index);}
inline t_size get_value_count(t_size p_index) const {assert(p_index < m_data.get_size()); return m_data[p_index].get_value_count();}
private:
meta_entry_array m_data;
};
}
//! Implements file_info.
class file_info_impl : public file_info
{
public:
file_info_impl(const file_info_impl & p_source);
file_info_impl(const file_info & p_source);
file_info_impl();
~file_info_impl();
double get_length() const;
void set_length(double p_length);
void copy_meta(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
void copy_info(const file_info & p_source);//virtualized for performance reasons, can be faster in two-pass
t_size meta_get_count() const;
const char* meta_enum_name(t_size p_index) const;
t_size meta_enum_value_count(t_size p_index) const;
const char* meta_enum_value(t_size p_index,t_size p_value_number) const;
t_size meta_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
void meta_insert_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
void meta_remove_mask(const bit_array & p_mask);
void meta_reorder(const t_size * p_order);
void meta_remove_values(t_size p_index,const bit_array & p_mask);
void meta_modify_value_ex(t_size p_index,t_size p_value_index,const char * p_value,t_size p_value_length);
t_size info_get_count() const;
const char* info_enum_name(t_size p_index) const;
const char* info_enum_value(t_size p_index) const;
t_size info_set_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
void info_remove_mask(const bit_array & p_mask);
const file_info_impl & operator=(const file_info_impl & p_source);
replaygain_info get_replaygain() const;
void set_replaygain(const replaygain_info & p_info);
protected:
t_size meta_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
t_size info_set_nocheck_ex(const char * p_name,t_size p_name_length,const char * p_value,t_size p_value_length);
private:
file_info_impl_utils::meta_storage m_meta;
file_info_impl_utils::info_storage m_info;
double m_length;
replaygain_info m_replaygain;
};
#endif

View File

@ -1,130 +0,0 @@
#include "foobar2000.h"
static t_size merge_tags_calc_rating_by_index(const file_info & p_info,t_size p_index) {
t_size n,m = p_info.meta_enum_value_count(p_index);
t_size ret = 0;
for(n=0;n<m;n++)
ret += strlen(p_info.meta_enum_value(p_index,n)) + 10;//yes, strlen on utf8 data, plus a slight bump to prefer multivalue over singlevalue w/ separator
return ret;
}
static t_size merge_tags_calc_rating(const file_info & p_info,const char * p_field) {
t_size field_index = p_info.meta_find(p_field);
t_size ret = 0;
if (field_index != infinite) {
return merge_tags_calc_rating_by_index(p_info,field_index);
} else {
return 0;
}
}
static void merge_tags_copy_info(const char * field,const file_info * from,file_info * to)
{
const char * val = from->info_get(field);
if (val) to->info_set(field,val);
}
namespace {
struct meta_merge_entry {
meta_merge_entry() : m_rating(0) {}
t_size m_rating;
pfc::array_t<const char *> m_data;
};
class meta_merge_map_enumerator {
public:
meta_merge_map_enumerator(file_info & p_out) : m_out(p_out) {
m_out.meta_remove_all();
}
void operator() (const char * p_name, const meta_merge_entry & p_entry) {
if (p_entry.m_data.get_size() > 0) {
t_size index = m_out.__meta_add_unsafe(p_name,p_entry.m_data[0]);
for(t_size walk = 1; walk < p_entry.m_data.get_size(); ++walk) {
m_out.meta_add_value(index,p_entry.m_data[walk]);
}
}
}
private:
file_info & m_out;
};
}
static void merge_meta(file_info & p_out,const pfc::list_base_const_t<const file_info*> & p_in) {
pfc::map_t<const char *,meta_merge_entry,pfc::comparator_stricmp_ascii> map;
for(t_size in_walk = 0; in_walk < p_in.get_count(); in_walk++) {
const file_info & in = * p_in[in_walk];
for(t_size meta_walk = 0, meta_count = in.meta_get_count(); meta_walk < meta_count; meta_walk++ ) {
meta_merge_entry & entry = map.find_or_add(in.meta_enum_name(meta_walk));
t_size rating = merge_tags_calc_rating_by_index(in,meta_walk);
if (rating > entry.m_rating) {
entry.m_rating = rating;
const t_size value_count = in.meta_enum_value_count(meta_walk);
entry.m_data.set_size(value_count);
for(t_size value_walk = 0; value_walk < value_count; value_walk++ ) {
entry.m_data[value_walk] = in.meta_enum_value(meta_walk,value_walk);
}
}
}
}
map.enumerate(meta_merge_map_enumerator(p_out));
}
void file_info::merge(const pfc::list_base_const_t<const file_info*> & p_in)
{
t_size in_count = p_in.get_count();
if (in_count == 0)
{
meta_remove_all();
return;
}
else if (in_count == 1)
{
const file_info * info = p_in[0];
copy_meta(*info);
set_replaygain(replaygain_info::g_merge(get_replaygain(),info->get_replaygain()));
overwrite_info(*info);
//copy_info_single_by_name(*info,"tagtype");
return;
}
merge_meta(*this,p_in);
{
pfc::string8_fastalloc tagtype;
replaygain_info rg = get_replaygain();
t_size in_ptr;
for(in_ptr = 0; in_ptr < in_count; in_ptr++ )
{
const file_info * info = p_in[in_ptr];
rg = replaygain_info::g_merge(rg, info->get_replaygain());
t_size field_ptr, field_max = info->info_get_count();
for(field_ptr = 0; field_ptr < field_max; field_ptr++ )
{
const char * field_name = info->info_enum_name(field_ptr), * field_value = info->info_enum_value(field_ptr);
if (*field_value)
{
if (!stricmp_utf8(field_name,"tagtype"))
{
if (!tagtype.is_empty()) tagtype += "|";
tagtype += field_value;
}
}
}
}
if (!tagtype.is_empty()) info_set("tagtype",tagtype);
set_replaygain(rg);
}
}
void file_info::overwrite_info(const file_info & p_source) {
t_size count = p_source.info_get_count();
for(t_size n=0;n<count;n++) {
info_set(p_source.info_enum_name(n),p_source.info_enum_value(n));
}
}

View File

@ -1,144 +0,0 @@
#include "foobar2000.h"
static void g_on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_items)
{
static_api_ptr_t<library_manager>()->on_files_deleted_sorted(p_items);
static_api_ptr_t<playlist_manager>()->on_files_deleted_sorted(p_items);
service_ptr_t<file_operation_callback> ptr;
service_enum_t<file_operation_callback> e;
while(e.next(ptr))
{
ptr->on_files_deleted_sorted(p_items);
}
}
static void g_on_files_moved_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to)
{
static_api_ptr_t<playlist_manager>()->on_files_moved_sorted(p_from,p_to);
static_api_ptr_t<playlist_manager>()->on_files_deleted_sorted(p_from);
service_ptr_t<file_operation_callback> ptr;
service_enum_t<file_operation_callback> e;
while(e.next(ptr))
{
ptr->on_files_moved_sorted(p_from,p_to);
}
}
static void g_on_files_copied_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to)
{
service_ptr_t<file_operation_callback> ptr;
service_enum_t<file_operation_callback> e;
while(e.next(ptr))
{
ptr->on_files_copied_sorted(p_from,p_to);
}
}
void file_operation_callback::g_on_files_deleted(const pfc::list_base_const_t<const char *> & p_items)
{
core_api::ensure_main_thread();
t_size count = p_items.get_count();
if (count > 0)
{
if (count == 1) g_on_files_deleted_sorted(p_items);
else
{
pfc::array_t<t_size> order; order.set_size(count);
order_helper::g_fill(order);
p_items.sort_get_permutation_t(metadb::path_compare,order.get_ptr());
g_on_files_deleted_sorted(pfc::list_permutation_t<const char*>(p_items,order.get_ptr(),count));
}
}
}
void file_operation_callback::g_on_files_moved(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to)
{
core_api::ensure_main_thread();
pfc::dynamic_assert(p_from.get_count() == p_to.get_count());
t_size count = p_from.get_count();
if (count > 0)
{
if (count == 1) g_on_files_moved_sorted(p_from,p_to);
else
{
pfc::array_t<t_size> order; order.set_size(count);
order_helper::g_fill(order);
p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr());
g_on_files_moved_sorted(pfc::list_permutation_t<const char*>(p_from,order.get_ptr(),count),pfc::list_permutation_t<const char*>(p_to,order.get_ptr(),count));
}
}
}
void file_operation_callback::g_on_files_copied(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to)
{
if (core_api::assert_main_thread())
{
assert(p_from.get_count() == p_to.get_count());
t_size count = p_from.get_count();
if (count > 0)
{
if (count == 1) g_on_files_copied_sorted(p_from,p_to);
else
{
pfc::array_t<t_size> order; order.set_size(count);
order_helper::g_fill(order);
p_from.sort_get_permutation_t(metadb::path_compare,order.get_ptr());
g_on_files_copied_sorted(pfc::list_permutation_t<const char*>(p_from,order.get_ptr(),count),pfc::list_permutation_t<const char*>(p_to,order.get_ptr(),count));
}
}
}
}
bool file_operation_callback::g_search_sorted_list(const pfc::list_base_const_t<const char*> & p_list,const char * p_string,t_size & p_index) {
return pfc::binarySearch<metadb::path_comparator>::run(p_list,0,p_list.get_count(),p_string,p_index);
}
bool file_operation_callback::g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved) {
static_api_ptr_t<metadb> api;
bool changed = false;
itemsAdded.remove_all(); itemsRemoved.remove_all();
for(t_size walk = 0; walk < p_list.get_count(); ++walk) {
metadb_handle_ptr item = p_list[walk];
t_size index;
if (g_search_sorted_list(p_from,item->get_path(),index)) {
metadb_handle_ptr newItem;
api->handle_create_replace_path_canonical(newItem,item,p_to[index]);
p_list.replace_item(walk,newItem);
changed = true;
itemsAdded.add_item(newItem); itemsRemoved.add_item(item);
}
}
return changed;
}
bool file_operation_callback::g_update_list_on_moved(metadb_handle_list_ref p_list,const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) {
static_api_ptr_t<metadb> api;
bool changed = false;
for(t_size walk = 0; walk < p_list.get_count(); ++walk) {
metadb_handle_ptr item = p_list[walk];
t_size index;
if (g_search_sorted_list(p_from,item->get_path(),index)) {
metadb_handle_ptr newItem;
api->handle_create_replace_path_canonical(newItem,item,p_to[index]);
p_list.replace_item(walk,newItem);
changed = true;
}
}
return changed;
}
bool file_operation_callback::g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths) {
bool found = false;
const t_size total = items.get_count();
for(t_size walk = 0; walk < total; ++walk) {
t_size index;
if (g_search_sorted_list(deadPaths,items[walk]->get_path(),index)) {
mask.set(walk,true); found = true;
} else {
mask.set(walk,false);
}
}
return found;
}

View File

@ -1,66 +0,0 @@
#ifndef _FILE_OPERATION_CALLBACK_H_
#define _FILE_OPERATION_CALLBACK_H_
//! Interface to notify component system about files being deleted or moved. Operates in app's main thread only.
class NOVTABLE file_operation_callback : public service_base {
public:
typedef const pfc::list_base_const_t<const char *> & t_pathlist;
//! p_items is a metadb::path_compare sorted list of files that have been deleted.
virtual void on_files_deleted_sorted(t_pathlist p_items) = 0;
//! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations.
virtual void on_files_moved_sorted(t_pathlist p_from,t_pathlist p_to) = 0;
//! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations.
virtual void on_files_copied_sorted(t_pathlist p_from,t_pathlist p_to) = 0;
static void g_on_files_deleted(const pfc::list_base_const_t<const char *> & p_items);
static void g_on_files_moved(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to);
static void g_on_files_copied(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to);
static bool g_search_sorted_list(const pfc::list_base_const_t<const char*> & p_list,const char * p_string,t_size & p_index);
static bool g_update_list_on_moved(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to);
static bool g_update_list_on_moved_ex(metadb_handle_list_ref p_list,t_pathlist p_from,t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved);
static bool g_mark_dead_entries(metadb_handle_list_cref items, bit_array_var & mask, t_pathlist deadPaths);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(file_operation_callback);
};
//! New in 0.9.5.
class NOVTABLE file_operation_callback_dynamic {
public:
//! p_items is a metadb::path_compare sorted list of files that have been deleted.
virtual void on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_items) = 0;
//! p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations.
virtual void on_files_moved_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) = 0;
//! p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations.
virtual void on_files_copied_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) = 0;
};
//! New in 0.9.5.
class NOVTABLE file_operation_callback_dynamic_manager : public service_base {
public:
virtual void register_callback(file_operation_callback_dynamic * p_callback) = 0;
virtual void unregister_callback(file_operation_callback_dynamic * p_callback) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(file_operation_callback_dynamic_manager);
};
//! New in 0.9.5.
class file_operation_callback_dynamic_impl_base : public file_operation_callback_dynamic {
public:
file_operation_callback_dynamic_impl_base() {static_api_ptr_t<file_operation_callback_dynamic_manager>()->register_callback(this);}
~file_operation_callback_dynamic_impl_base() {static_api_ptr_t<file_operation_callback_dynamic_manager>()->unregister_callback(this);}
void on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_items) {}
void on_files_moved_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) {}
void on_files_copied_sorted(const pfc::list_base_const_t<const char *> & p_from,const pfc::list_base_const_t<const char *> & p_to) {}
PFC_CLASS_NOT_COPYABLE_EX(file_operation_callback_dynamic_impl_base);
};
#endif //_FILE_OPERATION_CALLBACK_H_

View File

@ -1,863 +0,0 @@
#include "foobar2000.h"
void unpacker::g_open(service_ptr_t<file> & p_out,const service_ptr_t<file> & p,abort_callback & p_abort)
{
service_enum_t<unpacker> e;
service_ptr_t<unpacker> ptr;
if (e.first(ptr)) do {
p->reopen(p_abort);
try {
ptr->open(p_out,p,p_abort);
return;
} catch(exception_io_data const &) {}
} while(e.next(ptr));
throw exception_io_data();
}
void file::seek_ex(t_sfilesize p_position, file::t_seek_mode p_mode, abort_callback &p_abort) {
switch(p_mode) {
case seek_from_beginning:
seek(p_position,p_abort);
break;
case seek_from_current:
seek(p_position + get_position(p_abort),p_abort);
break;
case seek_from_eof:
seek(p_position + get_size_ex(p_abort),p_abort);
break;
default:
throw exception_io_data();
}
}
t_filesize file::g_transfer(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) {
enum {BUFSIZE = 1024*1024*8};
pfc::array_t<t_uint8> temp;
temp.set_size((t_size)pfc::min_t<t_filesize>(BUFSIZE,p_bytes));
void* ptr = temp.get_ptr();
t_filesize done = 0;
while(done<p_bytes) {
p_abort.check_e();
t_size delta = (t_size)pfc::min_t<t_filesize>(BUFSIZE,p_bytes-done);
delta = p_src->read(ptr,delta,p_abort);
if (delta<=0) break;
p_dst->write(ptr,delta,p_abort);
done += delta;
}
return done;
}
void file::g_transfer_object(stream_reader * p_src,stream_writer * p_dst,t_filesize p_bytes,abort_callback & p_abort) {
if (g_transfer(p_src,p_dst,p_bytes,p_abort) != p_bytes)
throw exception_io_data_truncation();
}
void filesystem::g_get_canonical_path(const char * path,pfc::string_base & out)
{
TRACK_CALL_TEXT("filesystem::g_get_canonical_path");
service_enum_t<filesystem> e;
service_ptr_t<filesystem> ptr;
if (e.first(ptr)) do {
if (ptr->get_canonical_path(path,out)) return;
} while(e.next(ptr));
//no one wants to process this, let's copy over
out = path;
}
void filesystem::g_get_display_path(const char * path,pfc::string_base & out)
{
TRACK_CALL_TEXT("filesystem::g_get_display_path");
service_ptr_t<filesystem> ptr;
if (!g_get_interface(ptr,path))
{
//no one wants to process this, let's copy over
out = path;
}
else
{
if (!ptr->get_display_path(path,out))
out = path;
}
}
bool filesystem::g_get_interface(service_ptr_t<filesystem> & p_out,const char * path)
{
service_enum_t<filesystem> e;
service_ptr_t<filesystem> ptr;
if (e.first(ptr)) do {
if (ptr->is_our_path(path))
{
p_out = ptr;
return true;
}
} while(e.next(ptr));
return false;
}
void filesystem::g_open(service_ptr_t<file> & p_out,const char * path,t_open_mode mode,abort_callback & p_abort)
{
TRACK_CALL_TEXT("filesystem::g_open");
service_ptr_t<filesystem> fs;
if (!g_get_interface(fs,path)) throw exception_io_no_handler_for_path();
fs->open(p_out,path,mode,p_abort);
}
void filesystem::g_open_timeout(service_ptr_t<file> & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_open(p_out,p_path,p_mode,p_abort);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}
bool filesystem::g_exists(const char * p_path,abort_callback & p_abort)
{
t_filestats stats;
bool dummy;
try {
g_get_stats(p_path,stats,dummy,p_abort);
} catch(exception_io_not_found) {return false;}
return true;
}
bool filesystem::g_exists_writeable(const char * p_path,abort_callback & p_abort)
{
t_filestats stats;
bool writeable;
try {
g_get_stats(p_path,stats,writeable,p_abort);
} catch(exception_io_not_found) {return false;}
return writeable;
}
void filesystem::g_remove(const char * p_path,abort_callback & p_abort) {
service_ptr_t<filesystem> fs;
if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path();
fs->remove(p_path,p_abort);
}
void filesystem::g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_remove(p_path,p_abort);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}
void filesystem::g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_move(p_src,p_dst,p_abort);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}
void filesystem::g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_copy(p_src,p_dst,p_abort);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}
void filesystem::g_create_directory(const char * p_path,abort_callback & p_abort)
{
service_ptr_t<filesystem> fs;
if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path();
fs->create_directory(p_path,p_abort);
}
void filesystem::g_move(const char * src,const char * dst,abort_callback & p_abort) {
service_enum_t<filesystem> e;
service_ptr_t<filesystem> ptr;
if (e.first(ptr)) do {
if (ptr->is_our_path(src) && ptr->is_our_path(dst)) {
ptr->move(src,dst,p_abort);
return;
}
} while(e.next(ptr));
throw exception_io_no_handler_for_path();
}
void filesystem::g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort)
{
TRACK_CALL_TEXT("filesystem::g_list_directory");
service_ptr_t<filesystem> ptr;
if (!g_get_interface(ptr,p_path)) throw exception_io_no_handler_for_path();
ptr->list_directory(p_path,p_out,p_abort);
}
static void path_pack_string(pfc::string_base & out,const char * src)
{
out.add_char('|');
out << strlen(src);
out.add_char('|');
out << src;
out.add_char('|');
}
static int path_unpack_string(pfc::string8 & out,const char * src)
{
int ptr=0;
if (src[ptr++]!='|') return -1;
int len = atoi(src+ptr);
if (len<=0) return -1;
while(src[ptr]!=0 && src[ptr]!='|') ptr++;
if (src[ptr]!='|') return -1;
ptr++;
int start = ptr;
while(ptr-start<len)
{
if (src[ptr]==0) return -1;
ptr++;
}
if (src[ptr]!='|') return -1;
out.add_string(&src[start],len);
ptr++;
return ptr;
}
void filesystem::g_open_precache(service_ptr_t<file> & p_out,const char * p_path,abort_callback & p_abort) {
service_ptr_t<filesystem> fs;
if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path();
if (fs->is_remote(p_path)) throw exception_io_object_is_remote();
fs->open(p_out,p_path,open_mode_read,p_abort);
}
bool filesystem::g_is_remote(const char * p_path) {
service_ptr_t<filesystem> fs;
if (g_get_interface(fs,p_path)) return fs->is_remote(p_path);
else throw exception_io_no_handler_for_path();
}
bool filesystem::g_is_recognized_and_remote(const char * p_path) {
service_ptr_t<filesystem> fs;
if (g_get_interface(fs,p_path)) return fs->is_remote(p_path);
else return false;
}
bool filesystem::g_is_remote_or_unrecognized(const char * p_path) {
service_ptr_t<filesystem> fs;
if (g_get_interface(fs,p_path)) return fs->is_remote(p_path);
else return true;
}
bool filesystem::g_relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out)
{
bool rv = false;
service_ptr_t<filesystem> fs;
if (g_get_interface(fs,file_path))
rv = fs->relative_path_create(file_path,playlist_path,out);
return rv;
}
bool filesystem::g_relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out)
{
service_enum_t<filesystem> e;
service_ptr_t<filesystem> ptr;
if (e.first(ptr)) do {
if (ptr->relative_path_parse(relative_path,playlist_path,out)) return true;
} while(e.next(ptr));
return false;
}
bool archive_impl::get_canonical_path(const char * path,pfc::string_base & out)
{
if (is_our_path(path))
{
pfc::string8 archive,file,archive_canonical;
if (g_parse_unpack_path(path,archive,file))
{
g_get_canonical_path(archive,archive_canonical);
make_unpack_path(out,archive_canonical,file);
return true;
}
else return false;
}
else return false;
}
bool archive_impl::is_our_path(const char * path)
{
if (strncmp(path,"unpack://",9)) return false;
const char * type = get_archive_type();
path += 9;
while(*type)
{
if (*type!=*path) return false;
type++;
path++;
}
if (*path!='|') return false;
return true;
}
bool archive_impl::get_display_path(const char * path,pfc::string_base & out)
{
pfc::string8 archive,file;
if (g_parse_unpack_path(path,archive,file))
{
g_get_display_path(archive,out);
out.add_string("|");
out.add_string(file);
return true;
}
else return false;
}
void archive_impl::open(service_ptr_t<file> & p_out,const char * path,t_open_mode mode, abort_callback & p_abort)
{
if (mode != open_mode_read) throw exception_io_denied();
pfc::string8 archive,file;
if (!g_parse_unpack_path(path,archive,file)) throw exception_io_not_found();
open_archive(p_out,archive,file,p_abort);
}
void archive_impl::remove(const char * path,abort_callback & p_abort) {
throw exception_io_denied();
}
void archive_impl::move(const char * src,const char * dst,abort_callback & p_abort) {
throw exception_io_denied();
}
bool archive_impl::is_remote(const char * src) {
pfc::string8 archive,file;
if (g_parse_unpack_path(src,archive,file)) return g_is_remote(archive);
else throw exception_io_not_found();
}
bool archive_impl::relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) {
pfc::string8 archive,file;
if (g_parse_unpack_path(file_path,archive,file))
{
pfc::string8 archive_rel;
if (g_relative_path_create(archive,playlist_path,archive_rel))
{
pfc::string8 out_path;
make_unpack_path(out_path,archive_rel,file);
out.set_string(out_path);
return true;
}
}
return false;
}
bool archive_impl::relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out)
{
if (!is_our_path(relative_path)) return false;
pfc::string8 archive_rel,file;
if (g_parse_unpack_path(relative_path,archive_rel,file))
{
pfc::string8 archive;
if (g_relative_path_parse(archive_rel,playlist_path,archive))
{
pfc::string8 out_path;
make_unpack_path(out_path,archive,file);
out.set_string(out_path);
return true;
}
}
return false;
}
bool archive_impl::g_parse_unpack_path(const char * path,pfc::string8 & archive,pfc::string8 & file)
{
path = strchr(path,'|');
if (!path) return false;
int delta = path_unpack_string(archive,path);
if (delta<0) return false;
path += delta;
file = path;
return true;
}
void archive_impl::g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * name)
{
path = "unpack://";
path += name;
path_pack_string(path,archive);
path += file;
}
void archive_impl::make_unpack_path(pfc::string_base & path,const char * archive,const char * file) {g_make_unpack_path(path,archive,file,get_archive_type());}
FILE * filesystem::streamio_open(const char * path,const char * flags)
{
FILE * ret = 0;
pfc::string8 temp;
g_get_canonical_path(path,temp);
if (!strncmp(temp,"file://",7))
{
ret = _wfopen(pfc::stringcvt::string_wide_from_utf8(path+7),pfc::stringcvt::string_wide_from_utf8(flags));
}
return ret;
}
namespace {
class directory_callback_isempty : public directory_callback
{
bool m_isempty;
public:
directory_callback_isempty() : m_isempty(true) {}
bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats)
{
m_isempty = false;
return false;
}
bool isempty() {return m_isempty;}
};
class directory_callback_dummy : public directory_callback
{
public:
bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) {return false;}
};
}
bool filesystem::g_is_empty_directory(const char * path,abort_callback & p_abort)
{
directory_callback_isempty callback;
try {
g_list_directory(path,callback,p_abort);
} catch(exception_io const &) {return false;}
return callback.isempty();
}
bool filesystem::g_is_valid_directory(const char * path,abort_callback & p_abort) {
try {
g_list_directory(path,directory_callback_dummy(),p_abort);
return true;
} catch(exception_io const &) {return false;}
}
bool directory_callback_impl::on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) {
p_abort.check_e();
if (is_subdirectory) {
if (m_recur) {
try {
owner->list_directory(url,*this,p_abort);
} catch(exception_io const &) {}
}
} else {
m_data.add_item(pfc::rcnew_t<t_entry>(url,p_stats));
}
return true;
}
namespace {
class directory_callback_impl_copy : public directory_callback
{
public:
directory_callback_impl_copy(const char * p_target)
{
m_target = p_target;
m_target.fix_dir_separator('\\');
}
bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats) {
const char * fn = url + pfc::scan_filename(url);
t_size truncat = m_target.length();
m_target += fn;
if (is_subdirectory) {
try {
filesystem::g_create_directory(m_target,p_abort);
} catch(exception_io_already_exists) {}
m_target += "\\";
owner->list_directory(url,*this,p_abort);
} else {
filesystem::g_copy(url,m_target,p_abort);
}
m_target.truncate(truncat);
return true;
}
private:
pfc::string8_fastalloc m_target;
};
}
void filesystem::g_copy_directory(const char * src,const char * dst,abort_callback & p_abort) {
//UNTESTED
filesystem::g_list_directory(src,directory_callback_impl_copy(dst),p_abort);
}
void filesystem::g_copy(const char * src,const char * dst,abort_callback & p_abort) {
service_ptr_t<file> r_src,r_dst;
t_filesize size;
g_open(r_src,src,open_mode_read,p_abort);
size = r_src->get_size_ex(p_abort);
g_open(r_dst,dst,open_mode_write_new,p_abort);
if (size > 0) {
try {
file::g_transfer_object(r_src,r_dst,size,p_abort);
} catch(...) {
r_dst.release();
try {g_remove(dst,abort_callback_impl());} catch(...) {}
throw;
}
}
}
void stream_reader::read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
if (read(p_buffer,p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation();
}
t_filestats file::get_stats(abort_callback & p_abort)
{
t_filestats temp;
temp.m_size = get_size(p_abort);
temp.m_timestamp = get_timestamp(p_abort);
return temp;
}
t_filesize stream_reader::skip(t_filesize p_bytes,abort_callback & p_abort)
{
t_uint8 temp[256];
t_filesize todo = p_bytes, done = 0;
while(todo > 0) {
t_size delta,deltadone;
delta = sizeof(temp);
if (delta > todo) delta = (t_size) todo;
deltadone = read(temp,delta,p_abort);
done += deltadone;
todo -= deltadone;
if (deltadone < delta) break;
}
return done;
}
void stream_reader::skip_object(t_filesize p_bytes,abort_callback & p_abort) {
if (skip(p_bytes,p_abort) != p_bytes) throw exception_io_data_truncation();
}
void filesystem::g_open_write_new(service_ptr_t<file> & p_out,const char * p_path,abort_callback & p_abort) {
g_open(p_out,p_path,open_mode_write_new,p_abort);
}
void file::g_transfer_file(const service_ptr_t<file> & p_from,const service_ptr_t<file> & p_to,abort_callback & p_abort) {
t_filesize length = p_from->get_size_ex(p_abort);
p_from->seek(0,p_abort);
p_to->seek(0,p_abort);
p_to->set_eof(p_abort);
if (length > 0) {
g_transfer_object(p_from,p_to,length,p_abort);
}
}
void filesystem::g_open_temp(service_ptr_t<file> & p_out,abort_callback & p_abort) {
g_open(p_out,"tempfile://",open_mode_write_new,p_abort);
}
void filesystem::g_open_tempmem(service_ptr_t<file> & p_out,abort_callback & p_abort) {
g_open(p_out,"tempmem://",open_mode_write_new,p_abort);
}
void archive_impl::list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort) {
throw exception_io_not_found();
}
void archive_impl::create_directory(const char * path,abort_callback &) {
throw exception_io_denied();
}
void filesystem::g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) {
TRACK_CALL_TEXT("filesystem::g_get_stats");
service_ptr_t<filesystem> fs;
if (!g_get_interface(fs,p_path)) throw exception_io_no_handler_for_path();
return fs->get_stats(p_path,p_stats,p_is_writeable,p_abort);
}
void archive_impl::get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) {
pfc::string8 archive,file;
if (g_parse_unpack_path(p_path,archive,file)) {
if (g_is_remote(archive)) throw exception_io_object_is_remote();
p_is_writeable = false;
p_stats = get_stats_in_archive(archive,file,p_abort);
}
else throw exception_io_not_found();
}
bool file::is_eof(abort_callback & p_abort) {
t_filesize position,size;
position = get_position(p_abort);
size = get_size(p_abort);
if (size == filesize_invalid) return false;
return position >= size;
}
t_filetimestamp foobar2000_io::filetimestamp_from_system_timer()
{
t_filetimestamp ret;
GetSystemTimeAsFileTime((FILETIME*)&ret);
return ret;
}
void stream_reader::read_string_ex(pfc::string_base & p_out,t_size p_bytes,abort_callback & p_abort) {
char * ptr = p_out.lock_buffer(p_bytes);
try {
read_object(ptr,p_bytes,p_abort);
} catch(...) {
p_out.unlock_buffer();
throw;
}
p_out.unlock_buffer();
}
void stream_reader::read_string(pfc::string_base & p_out,abort_callback & p_abort)
{
t_uint32 length;
read_lendian_t(length,p_abort);
read_string_ex(p_out,length,p_abort);
}
void stream_reader::read_string_raw(pfc::string_base & p_out,abort_callback & p_abort) {
enum {delta = 256};
char buffer[delta];
p_out.reset();
for(;;) {
t_size delta_done;
delta_done = read(buffer,delta,p_abort);
p_out.add_string(buffer,delta_done);
if (delta_done < delta) break;
}
}
void stream_writer::write_string(const char * p_string,t_size p_len,abort_callback & p_abort) {
t_uint32 len = pfc::downcast_guarded<t_uint32>(pfc::strlen_max(p_string,p_len));
write_lendian_t(len,p_abort);
write_object(p_string,len,p_abort);
}
void stream_writer::write_string(const char * p_string,abort_callback & p_abort) {
write_string(p_string,infinite,p_abort);
}
void stream_writer::write_string_raw(const char * p_string,abort_callback & p_abort) {
write_object(p_string,strlen(p_string),p_abort);
}
void file::truncate(t_uint64 p_position,abort_callback & p_abort) {
if (p_position < get_size(p_abort)) resize(p_position,p_abort);
}
#ifdef _WIN32
namespace {
//rare/weird win32 errors that didn't make it to the main API
PFC_DECLARE_EXCEPTION(exception_io_device_not_ready, exception_io,"Device not ready");
PFC_DECLARE_EXCEPTION(exception_io_invalid_drive, exception_io_not_found,"Drive not found");
PFC_DECLARE_EXCEPTION(exception_io_win32, exception_io,"Generic win32 I/O error");
PFC_DECLARE_EXCEPTION(exception_io_buffer_overflow, exception_io,"The file name is too long");
PFC_DECLARE_EXCEPTION(exception_io_invalid_path_syntax, exception_io,"Invalid path syntax");
class exception_io_win32_ex : public exception_io_win32 {
public:
exception_io_win32_ex(DWORD p_code) : m_msg(pfc::string_formatter() << "I/O error (win32 #" << (t_uint32)p_code << ")") {}
exception_io_win32_ex(const exception_io_win32_ex & p_other) {*this = p_other;}
const char * what() const throw() {return m_msg;}
private:
pfc::string8 m_msg;
};
}
void foobar2000_io::exception_io_from_win32(DWORD p_code) {
switch(p_code) {
case ERROR_ALREADY_EXISTS:
case ERROR_FILE_EXISTS:
throw exception_io_already_exists();
case ERROR_NETWORK_ACCESS_DENIED:
case ERROR_ACCESS_DENIED:
throw exception_io_denied();
case ERROR_WRITE_PROTECT:
throw exception_io_write_protected();
case ERROR_BUSY:
case ERROR_PATH_BUSY:
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
throw exception_io_sharing_violation();
case ERROR_HANDLE_DISK_FULL:
case ERROR_DISK_FULL:
throw exception_io_device_full();
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
throw exception_io_not_found();
case ERROR_BROKEN_PIPE:
case ERROR_NO_DATA:
throw exception_io_no_data();
case ERROR_NETWORK_UNREACHABLE:
case ERROR_NETNAME_DELETED:
throw exception_io_network_not_reachable();
case ERROR_NOT_READY:
throw exception_io_device_not_ready();
case ERROR_INVALID_DRIVE:
throw exception_io_invalid_drive();
case ERROR_CRC:
case ERROR_FILE_CORRUPT:
case ERROR_DISK_CORRUPT:
throw exception_io_file_corrupted();
case ERROR_BUFFER_OVERFLOW:
throw exception_io_buffer_overflow();
case ERROR_DISK_CHANGE:
throw exception_io_disk_change();
case ERROR_DIR_NOT_EMPTY:
throw exception_io_directory_not_empty();
case ERROR_INVALID_NAME:
throw exception_io_invalid_path_syntax();
default:
throw exception_io_win32_ex(p_code);
}
}
#endif
t_filesize file::get_size_ex(abort_callback & p_abort) {
t_filesize temp = get_size(p_abort);
if (temp == filesize_invalid) throw exception_io_no_length();
return temp;
}
void file::ensure_local() {
if (is_remote()) throw exception_io_object_is_remote();
}
void file::ensure_seekable() {
if (!can_seek()) throw exception_io_object_not_seekable();
}
bool filesystem::g_is_recognized_path(const char * p_path) {
return g_get_interface(service_ptr_t<filesystem>(),p_path);
}
t_filesize file::get_remaining(abort_callback & p_abort) {
t_filesize length = get_size_ex(p_abort);
t_filesize position = get_position(p_abort);
pfc::dynamic_assert(position <= length);
return length - position;
}
t_filesize file::g_transfer(service_ptr_t<file> p_src,service_ptr_t<file> p_dst,t_filesize p_bytes,abort_callback & p_abort) {
return g_transfer(pfc::safe_cast<stream_reader*>(p_src.get_ptr()),pfc::safe_cast<stream_writer*>(p_dst.get_ptr()),p_bytes,p_abort);
}
void file::g_transfer_object(service_ptr_t<file> p_src,service_ptr_t<file> p_dst,t_filesize p_bytes,abort_callback & p_abort) {
if (p_bytes > 1024) /* don't bother on small objects */
{
t_filesize oldsize = p_dst->get_size(p_abort);
if (oldsize != filesize_invalid) {
t_filesize newpos = p_dst->get_position(p_abort) + p_bytes;
if (newpos > oldsize) p_dst->resize(newpos ,p_abort);
}
}
g_transfer_object(pfc::safe_cast<stream_reader*>(p_src.get_ptr()),pfc::safe_cast<stream_writer*>(p_dst.get_ptr()),p_bytes,p_abort);
}
void foobar2000_io::generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic) {
hasher_md5_result hash;
{
static_api_ptr_t<hasher_md5> hasher;
hasher_md5_state state;
hasher->initialize(state);
hasher->process(state,p_origpath,strlen(p_origpath));
hasher->process(state,p_extension,strlen(p_extension));
hasher->process(state,p_magic,strlen(p_magic));
hash = hasher->get_result(state);
}
p_out = p_origpath;
p_out.truncate(p_out.scan_filename());
p_out += "temp-";
p_out += pfc::format_hexdump(hash.m_data,sizeof(hash.m_data),"");
p_out += ".";
p_out += p_extension;
}
t_filesize file::skip(t_filesize p_bytes,abort_callback & p_abort) {
if (p_bytes > 1024 && can_seek()) {
const t_filesize size = get_size(p_abort);
if (size != filesize_invalid) {
const t_filesize position = get_position(p_abort);
const t_filesize toskip = pfc::min_t( p_bytes, size - position );
seek(position + toskip,p_abort);
return toskip;
}
}
return stream_reader::skip(p_bytes,p_abort);
}
bool foobar2000_io::_extract_native_path_ptr(const char * & p_fspath) {
static const char header[] = "file://"; static const t_size headerLen = 7;
if (strncmp(p_fspath,header,headerLen) != 0) return false;
p_fspath += headerLen;
return true;
}
bool foobar2000_io::extract_native_path(const char * p_fspath,pfc::string_base & p_native) {
if (!_extract_native_path_ptr(p_fspath)) return false;
p_native = p_fspath;
return true;
}
bool foobar2000_io::extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native) {
if (!_extract_native_path_ptr(p_fspath)) return false;
if (p_fspath[0] != '\\' || p_fspath[0] != '\\') {
p_native = "\\\\?\\";
p_native += p_fspath;
} else {
p_native = p_fspath;
}
return true;
}
pfc::string stream_reader::read_string(abort_callback & p_abort) {
t_uint32 len;
read_lendian_t(len,p_abort);
return read_string_ex(len,p_abort);
}
pfc::string stream_reader::read_string_ex(t_size p_len,abort_callback & p_abort) {
pfc::rcptr_t<pfc::string8> temp; temp.new_t();
read_object(temp->lock_buffer(p_len),p_len,p_abort);
temp->unlock_buffer();
return pfc::string::t_data(temp);
}

View File

@ -1,598 +0,0 @@
class file_info;
//! Contains various I/O related structures and interfaces.
namespace foobar2000_io
{
//! Type used for file size related variables.
typedef t_uint64 t_filesize;
//! Type used for file size related variables when signed value is needed.
typedef t_int64 t_sfilesize;
//! Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601; 0 for invalid/unknown time.
typedef t_uint64 t_filetimestamp;
//! Invalid/unknown file timestamp constant. Also see: t_filetimestamp.
const t_filetimestamp filetimestamp_invalid = 0;
//! Invalid/unknown file size constant. Also see: t_filesize.
static const t_filesize filesize_invalid = (t_filesize)(~0);
static const t_filetimestamp filetimestamp_1second_increment = 10000000;
//! Generic I/O error. Root class for I/O failure exception. See relevant default message for description of each derived exception class.
PFC_DECLARE_EXCEPTION(exception_io, pfc::exception,"I/O error");
//! Object not found.
PFC_DECLARE_EXCEPTION(exception_io_not_found, exception_io,"Object not found");
//! Access denied.
PFC_DECLARE_EXCEPTION(exception_io_denied, exception_io,"Access denied");
//! Unsupported format or corrupted file (unexpected data encountered).
PFC_DECLARE_EXCEPTION(exception_io_data, exception_io,"Unsupported format or corrupted file");
//! Unsupported format or corrupted file (truncation encountered).
PFC_DECLARE_EXCEPTION(exception_io_data_truncation, exception_io_data,"Unsupported format or corrupted file");
//! Unsupported format (a subclass of "unsupported format or corrupted file" exception).
PFC_DECLARE_EXCEPTION(exception_io_unsupported_format, exception_io_data,"Unsupported file format");
//! Object is remote, while specific operation is supported only for local objects.
PFC_DECLARE_EXCEPTION(exception_io_object_is_remote, exception_io,"This operation is not supported on remote objects");
//! Sharing violation.
PFC_DECLARE_EXCEPTION(exception_io_sharing_violation, exception_io,"Sharing violation");
//! Device full.
PFC_DECLARE_EXCEPTION(exception_io_device_full, exception_io,"Device full");
//! Attempt to seek outside valid range.
PFC_DECLARE_EXCEPTION(exception_io_seek_out_of_range, exception_io,"Seek offset out of range");
//! This operation requires a seekable object.
PFC_DECLARE_EXCEPTION(exception_io_object_not_seekable, exception_io,"Object is not seekable");
//! This operation requires an object with known length.
PFC_DECLARE_EXCEPTION(exception_io_no_length, exception_io,"Length of object is unknown");
//! Invalid path.
PFC_DECLARE_EXCEPTION(exception_io_no_handler_for_path, exception_io,"Invalid path");
//! Object already exists.
PFC_DECLARE_EXCEPTION(exception_io_already_exists, exception_io,"Object already exists");
//! Pipe error.
PFC_DECLARE_EXCEPTION(exception_io_no_data, exception_io,"The process receiving or sending data has terminated");
//! Network not reachable.
PFC_DECLARE_EXCEPTION(exception_io_network_not_reachable,exception_io,"Network not reachable");
//! Media is write protected.
PFC_DECLARE_EXCEPTION(exception_io_write_protected, exception_io_denied,"The media is write protected");
//! File is corrupted. This indicates filesystem call failure, not actual invalid data being read by the app.
PFC_DECLARE_EXCEPTION(exception_io_file_corrupted, exception_io,"The file is corrupted");
//! The disc required for requested operation is not available.
PFC_DECLARE_EXCEPTION(exception_io_disk_change, exception_io,"Disc not available");
//! The directory is not empty.
PFC_DECLARE_EXCEPTION(exception_io_directory_not_empty, exception_io,"Directory not empty");
//! Stores file stats (size and timestamp).
struct t_filestats {
//! Size of the file.
t_filesize m_size;
//! Time of last file modification.
t_filetimestamp m_timestamp;
inline bool operator==(const t_filestats & param) const {return m_size == param.m_size && m_timestamp == param.m_timestamp;}
inline bool operator!=(const t_filestats & param) const {return m_size != param.m_size || m_timestamp != param.m_timestamp;}
};
//! Invalid/unknown file stats constant. See: t_filestats.
static const t_filestats filestats_invalid = {filesize_invalid,filetimestamp_invalid};
#ifdef _WIN32
void exception_io_from_win32(DWORD p_code);
#define WIN32_IO_OP(X) {SetLastError(NO_ERROR); if (!(X)) exception_io_from_win32(GetLastError());}
#endif
//! Generic interface to read data from a nonseekable stream. Also see: stream_writer, file. \n
//! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled.
class NOVTABLE stream_reader {
public:
//! Attempts to reads specified number of bytes from the stream.
//! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated.
//! @param p_bytes Number of bytes to read.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns Number of bytes actually read. May be less than requested when EOF was reached.
virtual t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0;
//! Reads specified number of bytes from the stream. If requested amount of bytes can't be read (e.g. EOF), throws exception_io_data_truncation.
//! @param p_buffer Receives data being read. Must have at least p_bytes bytes of space allocated.
//! @param p_bytes Number of bytes to read.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void read_object(void * p_buffer,t_size p_bytes,abort_callback & p_abort);
//! Attempts to skip specified number of bytes in the stream.
//! @param p_bytes Number of bytes to skip.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns Number of bytes actually skipped, May be less than requested when EOF was reached.
virtual t_filesize skip(t_filesize p_bytes,abort_callback & p_abort);
//! Skips specified number of bytes in the stream. If requested amount of bytes can't be skipped (e.g. EOF), throws exception_io_data_truncation.
//! @param p_bytes Number of bytes to skip.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void skip_object(t_filesize p_bytes,abort_callback & p_abort);
//! Helper template built around read_object. Reads single raw object from the stream.
//! @param p_object Receives object read from the stream on success.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void read_object_t(T& p_object,abort_callback & p_abort) {pfc::assert_raw_type<T>(); read_object(&p_object,sizeof(p_object),p_abort);}
//! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses little endian order.
//! @param p_object Receives object read from the stream on success.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void read_lendian_t(T& p_object,abort_callback & p_abort) {read_object_t(p_object,p_abort); byte_order::order_le_to_native_t(p_object);}
//! Helper template built around read_object. Reads single raw object from the stream; corrects byte order assuming stream uses big endian order.
//! @param p_object Receives object read from the stream on success.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void read_bendian_t(T& p_object,abort_callback & p_abort) {read_object_t(p_object,p_abort); byte_order::order_be_to_native_t(p_object);}
//! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator).
void read_string(pfc::string_base & p_out,abort_callback & p_abort);
//! Helper function; alternate way of storing strings; assumes string takes space up to end of stream.
void read_string_raw(pfc::string_base & p_out,abort_callback & p_abort);
//! Helper function; reads a string (with a 32-bit header indicating length in bytes followed by UTF-8 encoded data without a null terminator).
pfc::string read_string(abort_callback & p_abort);
//! Helper function; reads a string of specified length from the stream.
void read_string_ex(pfc::string_base & p_out,t_size p_bytes,abort_callback & p_abort);
//! Helper function; reads a string of specified length from the stream.
pfc::string read_string_ex(t_size p_len,abort_callback & p_abort);
protected:
stream_reader() {}
~stream_reader() {}
};
//! Generic interface to write data to a nonseekable stream. Also see: stream_reader, file. \n
//! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled.
class NOVTABLE stream_writer {
public:
//! Writes specified number of bytes from specified buffer to the stream.
//! @param p_buffer Buffer with data to write. Must contain at least p_bytes bytes.
//! @param p_bytes Number of bytes to write.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) = 0;
//! Helper. Same as write(), provided for consistency.
inline void write_object(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {write(p_buffer,p_bytes,p_abort);}
//! Helper template. Writes single raw object to the stream.
//! @param p_object Object to write.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void write_object_t(const T & p_object, abort_callback & p_abort) {pfc::assert_raw_type<T>(); write_object(&p_object,sizeof(p_object),p_abort);}
//! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses little endian order.
//! @param p_object Object to write.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void write_lendian_t(const T & p_object, abort_callback & p_abort) {T temp = p_object; byte_order::order_native_to_le_t(temp); write_object_t(temp,p_abort);}
//! Helper template. Writes single raw object to the stream; corrects byte order assuming stream uses big endian order.
//! @param p_object Object to write.
//! @param p_abort abort_callback object signaling user aborting the operation.
template<typename T> inline void write_bendian_t(const T & p_object, abort_callback & p_abort) {T temp = p_object; byte_order::order_native_to_be_t(temp); write_object_t(temp,p_abort);}
//! Helper function; writes string (with 32-bit header indicating length in bytes followed by UTF-8 encoded data without null terminator).
void write_string(const char * p_string,abort_callback & p_abort);
void write_string(const char * p_string,t_size p_len,abort_callback & p_abort);
template<typename T>
void write_string(const T& val,abort_callback & p_abort) {write_string(pfc::stringToPtr(val),p_abort);}
//! Helper function; writes raw string to the stream, with no length info or null terminators.
void write_string_raw(const char * p_string,abort_callback & p_abort);
protected:
stream_writer() {}
~stream_writer() {}
};
//! A class providing abstraction for an open file object, with reading/writing/seeking methods. See also: stream_reader, stream_writer (which it inherits read/write methods from). \n
//! Error handling: all methods may throw exception_io or one of derivatives on failure; exception_aborted when abort_callback is signaled.
class NOVTABLE file : public service_base, public stream_reader, public stream_writer {
public:
//! Seeking mode constants. Note: these are purposedly defined to same values as standard C SEEK_* constants
enum t_seek_mode {
//! Seek relative to beginning of file (same as seeking to absolute offset).
seek_from_beginning = 0,
//! Seek relative to current position.
seek_from_current = 1,
//! Seek relative to end of file.
seek_from_eof = 2,
};
//! Retrieves size of the file.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns File size on success; filesize_invalid if unknown (nonseekable stream etc).
virtual t_filesize get_size(abort_callback & p_abort) = 0;
//! Retrieves read/write cursor position in the file. In case of non-seekable stream, this should return number of bytes read so far since open/reopen call.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns Read/write cursor position
virtual t_filesize get_position(abort_callback & p_abort) = 0;
//! Resizes file to the specified size in bytes.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void resize(t_filesize p_size,abort_callback & p_abort) = 0;
//! Sets read/write cursor position to the specified offset.
//! @param p_position position to seek to.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void seek(t_filesize p_position,abort_callback & p_abort) = 0;
//! Sets read/write cursor position to the specified offset; extended form allowing seeking relative to current position or to end of file.
//! @param p_position Position to seek to; interpretation of this value depends on p_mode parameter.
//! @param p_mode Seeking mode; see t_seek_mode enum values for further description.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void seek_ex(t_sfilesize p_position,t_seek_mode p_mode,abort_callback & p_abort);
//! Returns whether the file is seekable or not. If can_seek() returns false, all seek() or seek_ex() calls will fail; reopen() is still usable on nonseekable streams.
virtual bool can_seek() = 0;
//! Retrieves mime type of the file.
//! @param p_out Receives content type string on success.
virtual bool get_content_type(pfc::string_base & p_out) = 0;
//! Hint, returns whether the file is already fully buffered into memory.
virtual bool is_in_memory() {return false;}
//! Optional, called by owner thread before sleeping.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void on_idle(abort_callback & p_abort) {}
//! Retrieves last modification time of the file.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns Last modification time o fthe file; filetimestamp_invalid if N/A.
virtual t_filetimestamp get_timestamp(abort_callback & p_abort) {return filetimestamp_invalid;}
//! Resets non-seekable stream, or seeks to zero on seekable file.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void reopen(abort_callback & p_abort) = 0;
//! Indicates whether the file is a remote resource and non-sequential access may be slowed down by lag. This is typically returns to true on non-seekable sources but may also return true on seekable sources indicating that seeking is supported but will be relatively slow.
virtual bool is_remote() = 0;
//! Retrieves file stats structure. Usese get_size() and get_timestamp().
t_filestats get_stats(abort_callback & p_abort);
//! Returns whether read/write cursor position is at the end of file.
bool is_eof(abort_callback & p_abort);
//! Truncates file to specified size (while preserving read/write cursor position if possible); uses set_eof().
void truncate(t_filesize p_position,abort_callback & p_abort);
//! Truncates the file at current read/write cursor position.
void set_eof(abort_callback & p_abort) {resize(get_position(p_abort),p_abort);}
//! Helper; retrieves size of the file. If size is not available (get_size() returns filesize_invalid), throws exception_io_no_length.
t_filesize get_size_ex(abort_callback & p_abort);
//! Helper; retrieves amount of bytes between read/write cursor position and end of file. Fails when length can't be determined.
t_filesize get_remaining(abort_callback & p_abort);
//! Helper; throws exception_io_object_not_seekable if file is not seekable.
void ensure_seekable();
//! Helper; throws exception_io_object_is_remote if the file is remote.
void ensure_local();
//! Helper; transfers specified number of bytes between streams.
//! @returns number of bytes actually transferred. May be less than requested if e.g. EOF is reached.
static t_filesize g_transfer(stream_reader * src,stream_writer * dst,t_filesize bytes,abort_callback & p_abort);
//! Helper; transfers specified number of bytes between streams. Throws exception if requested number of bytes could not be read (EOF).
static void g_transfer_object(stream_reader * src,stream_writer * dst,t_filesize bytes,abort_callback & p_abort);
//! Helper; transfers entire file content from one file to another, erasing previous content.
static void g_transfer_file(const service_ptr_t<file> & p_from,const service_ptr_t<file> & p_to,abort_callback & p_abort);
//! Helper; improved performance over g_transfer on streams (avoids disk fragmentation when transferring large blocks).
static t_filesize g_transfer(service_ptr_t<file> p_src,service_ptr_t<file> p_dst,t_filesize p_bytes,abort_callback & p_abort);
//! Helper; improved performance over g_transfer_file on streams (avoids disk fragmentation when transferring large blocks).
static void g_transfer_object(service_ptr_t<file> p_src,service_ptr_t<file> p_dst,t_filesize p_bytes,abort_callback & p_abort);
t_filesize skip(t_filesize p_bytes,abort_callback & p_abort);
FB2K_MAKE_SERVICE_INTERFACE(file,service_base);
};
typedef service_ptr_t<file> file_ptr;
//! Special hack for shoutcast metadata nonsense handling. Documentme.
class file_dynamicinfo : public file {
public:
//! Retrieves "static" info that doesn't change in the middle of stream, such as station names etc. Returns true on success; false when static info is not available.
virtual bool get_static_info(class file_info & p_out) = 0;
//! Returns whether dynamic info is available on this stream or not.
virtual bool is_dynamic_info_enabled()=0;
//! Retrieves dynamic stream info (e.g. online stream track titles). Returns true on success, false when info has not changed since last call.
virtual bool get_dynamic_info(class file_info & p_out) = 0;
FB2K_MAKE_SERVICE_INTERFACE(file_dynamicinfo,file);
};
//! Implementation helper - contains dummy implementations of methods that modify the file
template<typename t_base> class file_readonly_t : public t_base {
public:
void resize(t_filesize p_size,abort_callback & p_abort) {throw exception_io_denied();}
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {throw exception_io_denied();}
};
typedef file_readonly_t<file> file_readonly;
class filesystem;
class NOVTABLE directory_callback {
public:
//! @returns true to continue enumeration, false to abort.
virtual bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats)=0;
};
//! Entrypoint service for all filesystem operations.\n
//! Implementation: standard implementations for local filesystem etc are provided by core.\n
//! Instantiation: use static helper functions rather than calling filesystem interface methods directly, e.g. filesystem::g_open() to open a file.
class NOVTABLE filesystem : public service_base {
public:
//! Enumeration specifying how to open a file. See: filesystem::open(), filesystem::g_open().
enum t_open_mode {
//! Opens an existing file for reading; if the file does not exist, the operation will fail.
open_mode_read,
//! Opens an existing file for writing; if the file does not exist, the operation will fail.
open_mode_write_existing,
//! Opens a new file for writing; if the file exists, its contents will be wiped.
open_mode_write_new,
};
virtual bool get_canonical_path(const char * p_path,pfc::string_base & p_out)=0;
virtual bool is_our_path(const char * p_path)=0;
virtual bool get_display_path(const char * p_path,pfc::string_base & p_out)=0;
virtual void open(service_ptr_t<file> & p_out,const char * p_path, t_open_mode p_mode,abort_callback & p_abort)=0;
virtual void remove(const char * p_path,abort_callback & p_abort)=0;
virtual void move(const char * p_src,const char * p_dst,abort_callback & p_abort)=0;
//! Queries whether a file at specified path belonging to this filesystem is a remove object or not.
virtual bool is_remote(const char * p_src) = 0;
//! Retrieves stats of a file at specified path.
virtual void get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort) = 0;
virtual bool relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out) {return false;}
virtual bool relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out) {return false;}
//! Creates a directory.
virtual void create_directory(const char * p_path,abort_callback & p_abort) = 0;
virtual void list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort)=0;
//! Hint; returns whether this filesystem supports mime types. \n
//! When this returns false, all file::get_content_type() calls on files opened thru this filesystem implementation will return false; otherwise, file::get_content_type() calls may return true depending on the file.
virtual bool supports_content_types() = 0;
static void g_get_canonical_path(const char * path,pfc::string_base & out);
static void g_get_display_path(const char * path,pfc::string_base & out);
static bool g_get_interface(service_ptr_t<filesystem> & p_out,const char * path);//path is AFTER get_canonical_path
static bool g_is_remote(const char * p_path);//path is AFTER get_canonical_path
static bool g_is_recognized_and_remote(const char * p_path);//path is AFTER get_canonical_path
static bool g_is_remote_safe(const char * p_path) {return g_is_recognized_and_remote(p_path);}
static bool g_is_remote_or_unrecognized(const char * p_path);
static bool g_is_recognized_path(const char * p_path);
//! Opens file at specified path, with specified access privileges.
static void g_open(service_ptr_t<file> & p_out,const char * p_path,t_open_mode p_mode,abort_callback & p_abort);
//! Attempts to open file at specified path; if the operation fails with sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.
static void g_open_timeout(service_ptr_t<file> & p_out,const char * p_path,t_open_mode p_mode,double p_timeout,abort_callback & p_abort);
static void g_open_write_new(service_ptr_t<file> & p_out,const char * p_path,abort_callback & p_abort);
static void g_open_read(service_ptr_t<file> & p_out,const char * path,abort_callback & p_abort) {return g_open(p_out,path,open_mode_read,p_abort);}
static void g_open_precache(service_ptr_t<file> & p_out,const char * path,abort_callback & p_abort);//open only for precaching data (eg. will fail on http etc)
static bool g_exists(const char * p_path,abort_callback & p_abort);
static bool g_exists_writeable(const char * p_path,abort_callback & p_abort);
//! Removes file at specified path.
static void g_remove(const char * p_path,abort_callback & p_abort);
//! Attempts to remove file at specified path; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.
static void g_remove_timeout(const char * p_path,double p_timeout,abort_callback & p_abort);
//! Moves file from one path to another.
static void g_move(const char * p_src,const char * p_dst,abort_callback & p_abort);
//! Attempts to move file from one path to another; if the operation fails with a sharing violation error, keeps retrying (with short sleep period between retries) for specified amount of time.
static void g_move_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort);
static void g_copy(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path
static void g_copy_timeout(const char * p_src,const char * p_dst,double p_timeout,abort_callback & p_abort);//needs canonical path
static void g_copy_directory(const char * p_src,const char * p_dst,abort_callback & p_abort);//needs canonical path
static void g_get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort);
static bool g_relative_path_create(const char * p_file_path,const char * p_playlist_path,pfc::string_base & out);
static bool g_relative_path_parse(const char * p_relative_path,const char * p_playlist_path,pfc::string_base & out);
static void g_create_directory(const char * p_path,abort_callback & p_abort);
//! If for some bloody reason you ever need stream io compatibility, use this, INSTEAD of calling fopen() on the path string you've got; will only work with file:// (and not with http://, unpack:// or whatever)
static FILE * streamio_open(const char * p_path,const char * p_flags);
static void g_open_temp(service_ptr_t<file> & p_out,abort_callback & p_abort);
static void g_open_tempmem(service_ptr_t<file> & p_out,abort_callback & p_abort);
static void g_list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort);// path must be canonical
static bool g_is_valid_directory(const char * path,abort_callback & p_abort);
static bool g_is_empty_directory(const char * path,abort_callback & p_abort);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(filesystem);
};
class directory_callback_impl : public directory_callback
{
struct t_entry
{
pfc::string_simple m_path;
t_filestats m_stats;
t_entry(const char * p_path, const t_filestats & p_stats) : m_path(p_path), m_stats(p_stats) {}
};
pfc::list_t<pfc::rcptr_t<t_entry> > m_data;
bool m_recur;
static int sortfunc(const pfc::rcptr_t<const t_entry> & p1, const pfc::rcptr_t<const t_entry> & p2) {return stricmp_utf8(p1->m_path,p2->m_path);}
public:
bool on_entry(filesystem * owner,abort_callback & p_abort,const char * url,bool is_subdirectory,const t_filestats & p_stats);
directory_callback_impl(bool p_recur) : m_recur(p_recur) {}
t_size get_count() {return m_data.get_count();}
const char * operator[](t_size n) const {return m_data[n]->m_path;}
const char * get_item(t_size n) const {return m_data[n]->m_path;}
const t_filestats & get_item_stats(t_size n) const {return m_data[n]->m_stats;}
void sort() {m_data.sort_t(sortfunc);}
};
class archive;
class NOVTABLE archive_callback : public abort_callback {
public:
virtual bool on_entry(archive * owner,const char * url,const t_filestats & p_stats,const service_ptr_t<file> & p_reader) = 0;
};
//! Interface for archive reader services. When implementing, derive from archive_impl rather than from deriving from archive directly.
class NOVTABLE archive : public filesystem {
public:
virtual void archive_list(const char * p_path,const service_ptr_t<file> & p_reader,archive_callback & p_callback,bool p_want_readers) = 0;
FB2K_MAKE_SERVICE_INTERFACE(archive,filesystem);
};
//! Root class for archive implementations. Derive from this instead of from archive directly.
class NOVTABLE archive_impl : public archive {
private:
//do not override these
bool get_canonical_path(const char * path,pfc::string_base & out);
bool is_our_path(const char * path);
bool get_display_path(const char * path,pfc::string_base & out);
void remove(const char * path,abort_callback & p_abort);
void move(const char * src,const char * dst,abort_callback & p_abort);
bool is_remote(const char * src);
bool relative_path_create(const char * file_path,const char * playlist_path,pfc::string_base & out);
bool relative_path_parse(const char * relative_path,const char * playlist_path,pfc::string_base & out);
void open(service_ptr_t<file> & p_out,const char * path, t_open_mode mode,abort_callback & p_abort);
void create_directory(const char * path,abort_callback &);
void list_directory(const char * p_path,directory_callback & p_out,abort_callback & p_abort);
void get_stats(const char * p_path,t_filestats & p_stats,bool & p_is_writeable,abort_callback & p_abort);
protected:
//override these
virtual const char * get_archive_type()=0;//eg. "zip", must be lowercase
virtual t_filestats get_stats_in_archive(const char * p_archive,const char * p_file,abort_callback & p_abort) = 0;
virtual void open_archive(service_ptr_t<file> & p_out,const char * archive,const char * file, abort_callback & p_abort)=0;//opens for reading
public:
//override these
virtual void archive_list(const char * path,const service_ptr_t<file> & p_reader,archive_callback & p_out,bool p_want_readers)=0;
static bool g_parse_unpack_path(const char * path,pfc::string8 & archive,pfc::string8 & file);
static void g_make_unpack_path(pfc::string_base & path,const char * archive,const char * file,const char * name);
void make_unpack_path(pfc::string_base & path,const char * archive,const char * file);
};
template<typename T>
class archive_factory_t : public service_factory_single_t<T> {};
t_filetimestamp filetimestamp_from_system_timer();
#ifdef _WIN32
inline t_filetimestamp import_filetimestamp(FILETIME ft) {
return *reinterpret_cast<t_filetimestamp*>(&ft);
}
#endif
void generate_temp_location_for_file(pfc::string_base & p_out, const char * p_origpath,const char * p_extension,const char * p_magic);
static file_ptr fileOpen(const char * p_path,filesystem::t_open_mode p_mode,abort_callback & p_abort,double p_timeout) {
file_ptr temp; filesystem::g_open_timeout(temp,p_path,p_mode,p_timeout,p_abort); PFC_ASSERT(temp.is_valid()); return temp;
}
static file_ptr fileOpenReadExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) {
return fileOpen(p_path,filesystem::open_mode_read,p_abort,p_timeout);
}
static file_ptr fileOpenWriteExisting(const char * p_path,abort_callback & p_abort,double p_timeout = 0) {
return fileOpen(p_path,filesystem::open_mode_write_existing,p_abort,p_timeout);
}
static file_ptr fileOpenWriteNew(const char * p_path,abort_callback & p_abort,double p_timeout = 0) {
return fileOpen(p_path,filesystem::open_mode_write_new,p_abort,p_timeout);
}
template<typename t_list>
class directory_callback_retrieveList : public directory_callback {
public:
directory_callback_retrieveList(t_list & p_list,bool p_getFiles,bool p_getSubDirectories) : m_list(p_list), m_getFiles(p_getFiles), m_getSubDirectories(p_getSubDirectories) {}
bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) {
p_abort.check();
if (p_is_subdirectory ? m_getSubDirectories : m_getFiles) {
m_list.add_item(p_url);
}
return true;
}
private:
const bool m_getSubDirectories;
const bool m_getFiles;
t_list & m_list;
};
template<typename t_list>
class directory_callback_retrieveListEx : public directory_callback {
public:
directory_callback_retrieveListEx(t_list & p_files, t_list & p_directories) : m_files(p_files), m_directories(p_directories) {}
bool on_entry(filesystem * p_owner,abort_callback & p_abort,const char * p_url,bool p_is_subdirectory,const t_filestats & p_stats) {
p_abort.check();
if (p_is_subdirectory) m_directories += p_url;
else m_files += p_url;
return true;
}
private:
t_list & m_files;
t_list & m_directories;
};
template<typename t_list> class directory_callback_retrieveListRecur : public directory_callback {
public:
directory_callback_retrieveListRecur(t_list & p_list) : m_list(p_list) {}
bool on_entry(filesystem * owner,abort_callback & p_abort,const char * path, bool isSubdir, const t_filestats&) {
if (isSubdir) {
try { owner->list_directory(path,*this,p_abort); } catch(exception_io) {}
} else {
m_list.add_item(path);
}
return true;
}
private:
t_list & m_list;
};
template<typename t_list>
static void listFiles(const char * p_path,t_list & p_out,abort_callback & p_abort) {
directory_callback_retrieveList<t_list> callback(p_out,true,false);
filesystem::g_list_directory(p_path,callback,p_abort);
}
template<typename t_list>
static void listDirectories(const char * p_path,t_list & p_out,abort_callback & p_abort) {
directory_callback_retrieveList<t_list> callback(p_out,false,true);
filesystem::g_list_directory(p_path,callback,p_abort);
}
template<typename t_list>
static void listFilesAndDirectories(const char * p_path,t_list & p_files,t_list & p_directories,abort_callback & p_abort) {
directory_callback_retrieveListEx<t_list> callback(p_files,p_directories);
filesystem::g_list_directory(p_path,callback,p_abort);
}
template<typename t_list>
static void listFilesRecur(const char * p_path,t_list & p_out,abort_callback & p_abort) {
directory_callback_retrieveListRecur<t_list> callback(p_out);
filesystem::g_list_directory(p_path,callback,p_abort);
}
bool extract_native_path(const char * p_fspath,pfc::string_base & p_native);
bool _extract_native_path_ptr(const char * & p_fspath);
bool extract_native_path_ex(const char * p_fspath, pfc::string_base & p_native);//prepends \\?\ where needed
template<typename T>
pfc::string getPathDisplay(const T& source) {
pfc::string_formatter temp;
filesystem::g_get_display_path(pfc::stringToPtr(source),temp);
return temp.toString();
}
template<typename T>
pfc::string getPathCanonical(const T& source) {
pfc::string_formatter temp;
filesystem::g_get_canonical_path(pfc::stringToPtr(source),temp);
return temp.toString();
}
}
using namespace foobar2000_io;
#include "filesystem_helper.h"

View File

@ -1,106 +0,0 @@
#include "foobar2000.h"
void stream_writer_chunk::write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
t_size remaining = p_bytes, written = 0;
while(remaining > 0) {
t_size delta = sizeof(m_buffer) - m_buffer_state;
if (delta > remaining) delta = remaining;
memcpy(m_buffer,(const t_uint8*)p_buffer + written,delta);
written += delta;
remaining -= delta;
if (m_buffer_state == sizeof(m_buffer)) {
m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort);
m_writer->write_object(m_buffer,m_buffer_state,p_abort);
m_buffer_state = 0;
}
}
}
void stream_writer_chunk::flush(abort_callback & p_abort)
{
m_writer->write_lendian_t((t_uint8)m_buffer_state,p_abort);
if (m_buffer_state > 0) {
m_writer->write_object(m_buffer,m_buffer_state,p_abort);
m_buffer_state = 0;
}
}
/*
stream_writer * m_writer;
unsigned m_buffer_state;
unsigned char m_buffer[255];
*/
t_size stream_reader_chunk::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort)
{
t_size todo = p_bytes, done = 0;
while(todo > 0) {
if (m_buffer_size == m_buffer_state) {
if (m_eof) break;
t_uint8 temp;
m_reader->read_lendian_t(temp,p_abort);
m_buffer_size = temp;
if (temp != sizeof(m_buffer)) m_eof = true;
m_buffer_state = 0;
if (m_buffer_size>0) {
m_reader->read_object(m_buffer,m_buffer_size,p_abort);
}
}
t_size delta = m_buffer_size - m_buffer_state;
if (delta > todo) delta = todo;
if (delta > 0) {
memcpy((unsigned char*)p_buffer + done,m_buffer + m_buffer_state,delta);
todo -= delta;
done += delta;
m_buffer_state += delta;
}
}
return done;
}
void stream_reader_chunk::flush(abort_callback & p_abort) {
while(!m_eof) {
p_abort.check_e();
t_uint8 temp;
m_reader->read_lendian_t(temp,p_abort);
m_buffer_size = temp;
if (temp != sizeof(m_buffer)) m_eof = true;
m_buffer_state = 0;
if (m_buffer_size>0) {
m_reader->skip_object(m_buffer_size,p_abort);
}
}
}
/*
stream_reader * m_reader;
unsigned m_buffer_state, m_buffer_size;
bool m_eof;
unsigned char m_buffer[255];
*/
void stream_reader_chunk::g_skip(stream_reader * p_stream,abort_callback & p_abort) {
stream_reader_chunk(p_stream).flush(p_abort);
}
t_size reader_membuffer_base::read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
p_abort.check_e();
t_size max = get_buffer_size();
if (max < m_offset) throw pfc::exception_bug_check_v2();
max -= m_offset;
t_size delta = p_bytes;
if (delta > max) delta = max;
memcpy(p_buffer,(char*)get_buffer() + m_offset,delta);
m_offset += delta;
return delta;
}
void reader_membuffer_base::seek(t_filesize position,abort_callback & p_abort) {
p_abort.check_e();
t_filesize max = get_buffer_size();
if (position == filesize_invalid || position > max) throw exception_io_seek_out_of_range();
m_offset = (t_size)position;
}

View File

@ -1,579 +0,0 @@
//helper
class file_path_canonical {
public:
file_path_canonical(const char * src) {filesystem::g_get_canonical_path(src,m_data);}
operator const char * () const {return m_data.get_ptr();}
const char * get_ptr() const {return m_data.get_ptr();}
t_size get_length() const {return m_data.get_length();}
private:
pfc::string8 m_data;
};
class file_path_display {
public:
file_path_display(const char * src) {filesystem::g_get_display_path(src,m_data);}
operator const char * () const {return m_data.get_ptr();}
const char * get_ptr() const {return m_data.get_ptr();}
t_size get_length() const {return m_data.get_length();}
private:
pfc::string8 m_data;
};
class NOVTABLE reader_membuffer_base : public file_readonly {
public:
reader_membuffer_base() : m_offset(0) {}
t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort);
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {throw exception_io_denied();}
t_filesize get_size(abort_callback & p_abort) {return get_buffer_size();}
t_filesize get_position(abort_callback & p_abort) {return m_offset;}
void seek(t_filesize position,abort_callback & p_abort);
void reopen(abort_callback & p_abort) {seek(0,p_abort);}
bool can_seek() {return true;}
bool is_in_memory() {return true;}
protected:
virtual const void * get_buffer() = 0;
virtual t_size get_buffer_size() = 0;
virtual t_filetimestamp get_timestamp(abort_callback & p_abort) = 0;
virtual bool get_content_type(pfc::string_base &) {return false;}
inline void seek_internal(t_size p_offset) {if (p_offset > get_buffer_size()) throw exception_io_seek_out_of_range(); m_offset = p_offset;}
private:
t_size m_offset;
};
class reader_membuffer_mirror : public reader_membuffer_base
{
public:
t_filetimestamp get_timestamp(abort_callback & p_abort) {return m_timestamp;}
bool is_remote() {return m_remote;}
//! Returns false when the object could not be mirrored (too big) or did not need mirroring.
static bool g_create(service_ptr_t<file> & p_out,const service_ptr_t<file> & p_src,abort_callback & p_abort) {
service_ptr_t<reader_membuffer_mirror> ptr = new service_impl_t<reader_membuffer_mirror>();
if (!ptr->init(p_src,p_abort)) return false;
p_out = ptr.get_ptr();
return true;
}
private:
const void * get_buffer() {return m_buffer.get_ptr();}
t_size get_buffer_size() {return m_buffer.get_size();}
bool init(const service_ptr_t<file> & p_src,abort_callback & p_abort) {
if (p_src->is_in_memory()) return false;//already buffered
m_remote = p_src->is_remote();
t_size size = pfc::downcast_guarded<t_size>(p_src->get_size(p_abort));
m_buffer.set_size(size);
p_src->reopen(p_abort);
p_src->read_object(m_buffer.get_ptr(),size,p_abort);
m_timestamp = p_src->get_timestamp(p_abort);
return true;
}
t_filetimestamp m_timestamp;
pfc::array_t<char> m_buffer;
bool m_remote;
};
class reader_limited : public file_readonly {
service_ptr_t<file> r;
t_filesize begin;
t_filesize end;
public:
static file::ptr g_create(file::ptr base, t_filesize offset, t_filesize size, abort_callback & abort) {
service_ptr_t<reader_limited> r = new service_impl_t<reader_limited>();
if (offset + size < offset) throw pfc::exception_overflow();
r->init(base, offset, offset + size, abort);
return r;
}
reader_limited() {begin=0;end=0;}
reader_limited(const service_ptr_t<file> & p_r,t_filesize p_begin,t_filesize p_end,abort_callback & p_abort) {
r = p_r;
begin = p_begin;
end = p_end;
r->seek(begin,p_abort);
}
void init(const service_ptr_t<file> & p_r,t_filesize p_begin,t_filesize p_end,abort_callback & p_abort) {
r = p_r;
begin = p_begin;
end = p_end;
r->seek(begin,p_abort);
}
t_filetimestamp get_timestamp(abort_callback & p_abort) {return r->get_timestamp(p_abort);}
t_size read(void *p_buffer, t_size p_bytes,abort_callback & p_abort) {
t_filesize pos;
pos = r->get_position(p_abort);
if (p_bytes > end - pos) p_bytes = (t_size)(end - pos);
return r->read(p_buffer,p_bytes,p_abort);
}
t_filesize get_size(abort_callback & p_abort) {return end-begin;}
t_filesize get_position(abort_callback & p_abort) {
return r->get_position(p_abort) - begin;
}
void seek(t_filesize position,abort_callback & p_abort) {
r->seek(position+begin,p_abort);
}
bool can_seek() {return r->can_seek();}
bool is_remote() {return r->is_remote();}
bool get_content_type(pfc::string_base &) {return false;}
void reopen(abort_callback & p_abort) {seek(0,p_abort);}
};
class stream_reader_memblock_ref : public stream_reader
{
public:
template<typename t_array> stream_reader_memblock_ref(const t_array & p_array) : m_data(p_array.get_ptr()), m_data_size(p_array.get_size()), m_pointer(0) {
pfc::assert_byte_type<typename t_array::t_item>();
}
stream_reader_memblock_ref(const void * p_data,t_size p_data_size) : m_data((const unsigned char*)p_data), m_data_size(p_data_size), m_pointer(0) {}
stream_reader_memblock_ref() : m_data(NULL), m_data_size(0), m_pointer(0) {}
template<typename t_array> void set_data(const t_array & data) {
pfc::assert_byte_type<typename t_array::t_item>();
set_data(data.get_ptr(), data.get_size());
}
void set_data(const void * data, t_size dataSize) {
m_pointer = 0;
m_data = reinterpret_cast<const unsigned char*>(data);
m_data_size = dataSize;
}
t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
t_size remaining = m_data_size - m_pointer;
t_size toread = p_bytes;
if (toread > remaining) toread = remaining;
if (toread > 0) {
memcpy(p_buffer,m_data+m_pointer,toread);
m_pointer += toread;
}
return toread;
}
t_size get_remaining() const {return m_data_size - m_pointer;}
void reset() {m_pointer = 0;}
private:
const unsigned char * m_data;
t_size m_data_size,m_pointer;
};
class stream_writer_buffer_simple : public stream_writer {
public:
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
p_abort.check();
t_size base = m_buffer.get_size();
if (base + p_bytes < base) throw std::bad_alloc();
m_buffer.set_size(base + p_bytes);
memcpy( (t_uint8*) m_buffer.get_ptr() + base, p_buffer, p_bytes );
}
typedef pfc::array_t<t_uint8,pfc::alloc_fast> t_buffer;
pfc::array_t<t_uint8,pfc::alloc_fast> m_buffer;
};
template<class t_storage>
class stream_writer_buffer_append_ref_t : public stream_writer
{
public:
stream_writer_buffer_append_ref_t(t_storage & p_output) : m_output(p_output) {}
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
pfc::static_assert< sizeof(m_output[0]) == 1>();
p_abort.check();
t_size base = m_output.get_size();
if (base + p_bytes < base) throw std::bad_alloc();
m_output.set_size(base + p_bytes);
memcpy( (t_uint8*) m_output.get_ptr() + base, p_buffer, p_bytes );
}
private:
t_storage & m_output;
};
class stream_reader_limited_ref : public stream_reader {
public:
stream_reader_limited_ref(stream_reader * p_reader,t_filesize p_limit) : m_reader(p_reader), m_remaining(p_limit) {}
t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
if (p_bytes > m_remaining) p_bytes = (t_size)m_remaining;
t_size done = m_reader->read(p_buffer,p_bytes,p_abort);
m_remaining -= done;
return done;
}
inline t_filesize get_remaining() const {return m_remaining;}
t_filesize skip(t_filesize p_bytes,abort_callback & p_abort) {
if (p_bytes > m_remaining) p_bytes = m_remaining;
t_filesize done = m_reader->skip(p_bytes,p_abort);
m_remaining -= done;
return done;
}
void flush_remaining(abort_callback & p_abort) {
if (m_remaining > 0) skip_object(m_remaining,p_abort);
}
private:
stream_reader * m_reader;
t_filesize m_remaining;
};
class stream_writer_chunk_dwordheader : public stream_writer
{
public:
stream_writer_chunk_dwordheader(const service_ptr_t<file> & p_writer) : m_writer(p_writer) {}
void initialize(abort_callback & p_abort) {
m_headerposition = m_writer->get_position(p_abort);
m_written = 0;
m_writer->write_lendian_t((t_uint32)0,p_abort);
}
void finalize(abort_callback & p_abort) {
t_filesize end_offset;
end_offset = m_writer->get_position(p_abort);
m_writer->seek(m_headerposition,p_abort);
m_writer->write_lendian_t(pfc::downcast_guarded<t_uint32>(m_written),p_abort);
m_writer->seek(end_offset,p_abort);
}
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
m_writer->write(p_buffer,p_bytes,p_abort);
m_written += p_bytes;
}
private:
service_ptr_t<file> m_writer;
t_filesize m_headerposition;
t_filesize m_written;
};
class stream_writer_chunk : public stream_writer
{
public:
stream_writer_chunk(stream_writer * p_writer) : m_writer(p_writer), m_buffer_state(0) {}
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort);
void flush(abort_callback & p_abort);//must be called after writing before object is destroyed
private:
stream_writer * m_writer;
unsigned m_buffer_state;
unsigned char m_buffer[255];
};
class stream_reader_chunk : public stream_reader
{
public:
stream_reader_chunk(stream_reader * p_reader) : m_reader(p_reader), m_buffer_state(0), m_buffer_size(0), m_eof(false) {}
t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort);
void flush(abort_callback & p_abort);//must be called after reading before object is destroyed
static void g_skip(stream_reader * p_stream,abort_callback & p_abort);
private:
stream_reader * m_reader;
t_size m_buffer_state, m_buffer_size;
bool m_eof;
unsigned char m_buffer[255];
};
class stream_reader_dummy : public stream_reader { t_size read(void * p_buffer,t_size p_bytes,abort_callback & p_abort) {return 0;} };
template<bool isBigEndian = false> class stream_reader_formatter {
public:
stream_reader_formatter(stream_reader & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {}
template<typename t_int> void read_int(t_int & p_out) {
if (isBigEndian) m_stream.read_bendian_t(p_out,m_abort);
else m_stream.read_lendian_t(p_out,m_abort);
}
void read_raw(void * p_buffer,t_size p_bytes) {
m_stream.read_object(p_buffer,p_bytes,m_abort);
}
void skip(t_size p_bytes) {m_stream.skip_object(p_bytes,m_abort);}
template<typename TArray> void read_raw(TArray& data) {
pfc::assert_byte_type<typename TArray::t_item>();
read_raw(data.get_ptr(),data.get_size());
}
template<typename TArray> void read_byte_block(TArray & data) {
pfc::assert_byte_type<typename TArray::t_item>();
t_uint32 size; read_int(size); data.set_size(size);
read_raw(data);
}
template<typename TArray> void read_array(TArray & data) {
t_uint32 size; *this >> size; data.set_size(size);
for(t_uint32 walk = 0; walk < size; ++walk) *this >> data[walk];
}
stream_reader & m_stream;
abort_callback & m_abort;
};
template<bool isBigEndian = false> class stream_writer_formatter {
public:
stream_writer_formatter(stream_writer & p_stream,abort_callback & p_abort) : m_stream(p_stream), m_abort(p_abort) {}
template<typename t_int> void write_int(t_int p_int) {
if (isBigEndian) m_stream.write_bendian_t(p_int,m_abort);
else m_stream.write_lendian_t(p_int,m_abort);
}
void write_raw(const void * p_buffer,t_size p_bytes) {
m_stream.write_object(p_buffer,p_bytes,m_abort);
}
template<typename TArray> void write_raw(const TArray& data) {
pfc::assert_byte_type<typename TArray::t_item>();
write_raw(data.get_ptr(),data.get_size());
}
template<typename TArray> void write_byte_block(const TArray& data) {
pfc::assert_byte_type<typename TArray::t_item>();
write_int( pfc::downcast_guarded<t_uint32>(data.get_size()) );
write_raw( data );
}
template<typename TArray> void write_array(const TArray& data) {
const t_uint32 size = pfc::downcast_guarded<t_uint32>(data.get_size());
*this << size;
for(t_uint32 walk = 0; walk < size; ++walk) *this << data[walk];
}
void write_string(const char * str) {
const t_size len = strlen(str);
*this << pfc::downcast_guarded<t_uint32>(len);
write_raw(str, len);
}
void write_string(const char * str, t_size len_) {
const t_size len = pfc::strlen_max(str, len_);
*this << pfc::downcast_guarded<t_uint32>(len);
write_raw(str, len);
}
stream_writer & m_stream;
abort_callback & m_abort;
};
#define __DECLARE_UINT_OVERLOADS(TYPE) \
template<bool isBigEndian> inline stream_reader_formatter<isBigEndian> & operator>>(stream_reader_formatter<isBigEndian> & p_stream,TYPE & p_int) {p_stream.read_int(p_int); return p_stream;} \
template<bool isBigEndian> inline stream_writer_formatter<isBigEndian> & operator<<(stream_writer_formatter<isBigEndian> & p_stream,TYPE p_int) {p_stream.write_int(p_int); return p_stream;}
__DECLARE_UINT_OVERLOADS(t_uint8);
__DECLARE_UINT_OVERLOADS(t_uint16);
__DECLARE_UINT_OVERLOADS(t_uint32);
__DECLARE_UINT_OVERLOADS(t_uint64);
#ifdef _MSC_VER
//SPECIAL FIX
__DECLARE_UINT_OVERLOADS(unsigned long);
#endif
#undef __DECLARE_UINT_OVERLOADS
#define __DECLARE_INT_OVERLOADS(TYPE) \
template<bool isBigEndian> inline stream_reader_formatter<isBigEndian> & operator>>(stream_reader_formatter<isBigEndian> & p_stream,TYPE & p_int) {typename pfc::sized_int_t<sizeof(TYPE)>::t_unsigned temp;p_stream.read_int(temp); p_int = (TYPE) temp; return p_stream;} \
template<bool isBigEndian> inline stream_writer_formatter<isBigEndian> & operator<<(stream_writer_formatter<isBigEndian> & p_stream,TYPE p_int) {p_stream.write_int((typename pfc::sized_int_t<sizeof(TYPE)>::t_unsigned)p_int); return p_stream;}
__DECLARE_INT_OVERLOADS(t_int8);
__DECLARE_INT_OVERLOADS(t_int16);
__DECLARE_INT_OVERLOADS(t_int32);
__DECLARE_INT_OVERLOADS(t_int64);
#ifdef _MSC_VER
//SPECIAL FIX
__DECLARE_INT_OVERLOADS(long);
#endif
#undef __DECLARE_INT_OVERLOADS
template<typename TVal> class __IsTypeByte {
public:
enum {value = pfc::is_same_type<TVal,t_int8>::value || pfc::is_same_type<TVal,t_uint8>::value};
};
template<bool isBigEndian,typename TVal,size_t Count> stream_reader_formatter<isBigEndian> & operator>>(stream_reader_formatter<isBigEndian> & p_stream,TVal (& p_array)[Count]) {
if (__IsTypeByte<TVal>::value) {
p_stream.read_raw(p_array,Count);
} else {
for(t_size walk = 0; walk < Count; ++walk) p_stream >> p_array[walk];
}
return p_stream;
}
template<bool isBigEndian,typename TVal,size_t Count> stream_writer_formatter<isBigEndian> & operator<<(stream_writer_formatter<isBigEndian> & p_stream,TVal const (& p_array)[Count]) {
if (__IsTypeByte<TVal>::value) {
p_stream.write_raw(p_array,Count);
} else {
for(t_size walk = 0; walk < Count; ++walk) p_stream << p_array[walk];
}
return p_stream;
}
#define FB2K_STREAM_READER_OVERLOAD(type) \
template<bool isBigEndian> stream_reader_formatter<isBigEndian> & operator>>(stream_reader_formatter<isBigEndian> & stream,type & value)
#define FB2K_STREAM_WRITER_OVERLOAD(type) \
template<bool isBigEndian> stream_writer_formatter<isBigEndian> & operator<<(stream_writer_formatter<isBigEndian> & stream,const type & value)
FB2K_STREAM_READER_OVERLOAD(GUID) {
return stream >> value.Data1 >> value.Data2 >> value.Data3 >> value.Data4;
}
FB2K_STREAM_WRITER_OVERLOAD(GUID) {
return stream << value.Data1 << value.Data2 << value.Data3 << value.Data4;
}
FB2K_STREAM_READER_OVERLOAD(pfc::string) {
t_uint32 len; stream >> len;
value = stream.m_stream.read_string_ex(len,stream.m_abort);
return stream;
}
FB2K_STREAM_WRITER_OVERLOAD(pfc::string) {
stream << pfc::downcast_guarded<t_uint32>(value.length());
stream.write_raw(value.ptr(),value.length());
return stream;
}
FB2K_STREAM_READER_OVERLOAD(pfc::string_base) {
t_uint32 len; stream >> len;
try {
char * buf = value.lock_buffer(len);
stream.read_raw(buf,len);
} catch(...) {
value.unlock_buffer(); throw;
}
value.unlock_buffer();
return stream;
}
FB2K_STREAM_WRITER_OVERLOAD(pfc::string_base) {
const char * val = value.get_ptr();
const t_size len = strlen(val);
stream << pfc::downcast_guarded<t_uint32>(len);
stream.write_raw(val,len);
return stream;
}
FB2K_STREAM_WRITER_OVERLOAD(float) {
union {
float f; t_uint32 i;
} u; u.f = value;
return stream << u.i;
}
FB2K_STREAM_READER_OVERLOAD(float) {
union { float f; t_uint32 i;} u;
stream >> u.i; value = u.f;
return stream;
}
FB2K_STREAM_WRITER_OVERLOAD(double) {
union {
double f; t_uint64 i;
} u; u.f = value;
return stream << u.i;
}
FB2K_STREAM_READER_OVERLOAD(double) {
union { double f; t_uint64 i;} u;
stream >> u.i; value = u.f;
return stream;
}
template<bool BE = false>
class stream_writer_formatter_simple : public stream_writer_formatter<BE> {
public:
stream_writer_formatter_simple() : stream_writer_formatter(_m_stream,_m_abort), m_buffer(_m_stream.m_buffer) {}
typedef stream_writer_buffer_simple::t_buffer t_buffer;
t_buffer & m_buffer;
private:
stream_writer_buffer_simple _m_stream;
abort_callback_dummy _m_abort;
};
template<bool BE = false>
class stream_reader_formatter_simple_ref : public stream_reader_formatter<BE> {
public:
stream_reader_formatter_simple_ref(const void * source, t_size sourceSize) : stream_reader_formatter(_m_stream,_m_abort), _m_stream(source,sourceSize) {}
template<typename TSource> stream_reader_formatter_simple_ref(const TSource& source) : stream_reader_formatter(_m_stream,_m_abort), _m_stream(source) {}
stream_reader_formatter_simple_ref() : stream_reader_formatter(_m_stream,_m_abort) {}
void set_data(const void * source, t_size sourceSize) {_m_stream.set_data(source,sourceSize);}
template<typename TSource> void set_data(const TSource & source) {_m_stream.set_data(source);}
void reset() {_m_stream.reset();}
t_size get_remaining() {return _m_stream.get_remaining();}
private:
stream_reader_memblock_ref _m_stream;
abort_callback_dummy _m_abort;
};
template<bool BE = false>
class stream_reader_formatter_simple : public stream_reader_formatter_simple_ref<BE> {
public:
stream_reader_formatter_simple() {}
stream_reader_formatter_simple(const void * source, t_size sourceSize) {set_data(source,sourceSize);}
template<typename TSource> stream_reader_formatter_simple(const TSource & source) {set_data(source);}
void set_data(const void * source, t_size sourceSize) {
m_content.set_data_fromptr(reinterpret_cast<const t_uint8*>(source), sourceSize);
onContentChange();
}
template<typename TSource> void set_data(const TSource & source) {
m_content = source;
onContentChange();
}
private:
void onContentChange() {
stream_reader_formatter_simple_ref<BE>::set_data(m_content);
}
pfc::array_t<t_uint8> m_content;
};

View File

@ -1,95 +0,0 @@
// This is the master foobar2000 SDK header file; it includes headers for all functionality exposed through the SDK project. #include this in your source code, never reference any of the other headers directly.
#ifndef _FOOBAR2000_H_
#define _FOOBAR2000_H_
#ifndef UNICODE
#error Only UNICODE environment supported.
#endif
#include "../../pfc/pfc.h"
#include "../shared/shared.h"
#ifndef NOTHROW
#ifdef _MSC_VER
#define NOTHROW __declspec(nothrow)
#else
#define NOTHROW
#endif
#endif
#define FB2KAPI /*NOTHROW*/
typedef const char * pcchar;
#include "core_api.h"
#include "service.h"
#include "completion_notify.h"
#include "abort_callback.h"
#include "componentversion.h"
#include "preferences_page.h"
#include "coreversion.h"
#include "filesystem.h"
#include "audio_chunk.h"
#include "cfg_var.h"
#include "mem_block_container.h"
#include "audio_postprocessor.h"
#include "playable_location.h"
#include "file_info.h"
#include "file_info_impl.h"
#include "metadb_handle.h"
#include "metadb.h"
#include "console.h"
#include "dsp.h"
#include "dsp_manager.h"
#include "initquit.h"
#include "event_logger.h"
#include "input.h"
#include "input_impl.h"
#include "menu.h"
#include "contextmenu.h"
#include "contextmenu_manager.h"
#include "menu_helpers.h"
#include "modeless_dialog.h"
#include "playback_control.h"
#include "play_callback.h"
#include "playlist.h"
#include "playlist_loader.h"
#include "replaygain.h"
#include "resampler.h"
#include "tag_processor.h"
#include "titleformat.h"
#include "ui.h"
#include "unpack.h"
#include "vis.h"
#include "packet_decoder.h"
#include "commandline.h"
#include "genrand.h"
#include "file_operation_callback.h"
#include "library_manager.h"
#include "config_io_callback.h"
#include "popup_message.h"
#include "app_close_blocker.h"
#include "config_object.h"
#include "config_object_impl.h"
#include "threaded_process.h"
#include "hasher_md5.h"
#include "message_loop.h"
#include "input_file_type.h"
#include "chapterizer.h"
#include "link_resolver.h"
#include "main_thread_callback.h"
#include "advconfig.h"
#include "info_lookup_handler.h"
#include "track_property.h"
#include "album_art.h"
#include "icon_remap.h"
#include "ole_interaction.h"
#include "search_tools.h"
#include "autoplaylist.h"
#include "replaygain_scanner.h"
#endif //_FOOBAR2000_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
//! PRNG service. Implemented by the core, do not reimplement. Use g_create() helper function to instantiate.
class NOVTABLE genrand_service : public service_base
{
public:
//! Seeds the PRNG with specified value.
virtual void seed(unsigned val) = 0;
//! Returns random value N, where 0 <= N < range.
virtual unsigned genrand(unsigned range)=0;
static service_ptr_t<genrand_service> g_create() {return standard_api_create_t<genrand_service>();}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(genrand_service);
};

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
#include "foobar2000.h"
GUID hasher_md5::guid_from_result(const hasher_md5_result & param)
{
assert(sizeof(GUID) == sizeof(hasher_md5_result));
GUID temp = * reinterpret_cast<const GUID*>(&param);
byte_order::order_le_to_native_t(temp);
return temp;
}
hasher_md5_result hasher_md5::process_single(const void * p_buffer,t_size p_bytes)
{
hasher_md5_state state;
initialize(state);
process(state,p_buffer,p_bytes);
return get_result(state);
}
GUID hasher_md5::process_single_guid(const void * p_buffer,t_size p_bytes)
{
return guid_from_result(process_single(p_buffer,p_bytes));
}

View File

@ -1,73 +0,0 @@
struct hasher_md5_state {
char m_data[128];
};
struct hasher_md5_result {
char m_data[16];
};
inline bool operator==(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) == 0;}
inline bool operator!=(const hasher_md5_result & p_item1,const hasher_md5_result & p_item2) {return memcmp(&p_item1,&p_item2,sizeof(hasher_md5_result)) != 0;}
namespace pfc {
template<> class traits_t<hasher_md5_state> : public traits_rawobject {};
template<> class traits_t<hasher_md5_result> : public traits_rawobject {};
}
class NOVTABLE hasher_md5 : public service_base
{
public:
virtual void initialize(hasher_md5_state & p_state) = 0;
virtual void process(hasher_md5_state & p_state,const void * p_buffer,t_size p_bytes) = 0;
virtual hasher_md5_result get_result(const hasher_md5_state & p_state) = 0;
static GUID guid_from_result(const hasher_md5_result & param);
hasher_md5_result process_single(const void * p_buffer,t_size p_bytes);
GUID process_single_guid(const void * p_buffer,t_size p_bytes);
GUID get_result_guid(const hasher_md5_state & p_state) {return guid_from_result(get_result(p_state));}
//! Helper
void process_string(hasher_md5_state & p_state,const char * p_string,t_size p_length = infinite) {return process(p_state,p_string,pfc::strlen_max(p_string,p_length));}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(hasher_md5);
};
class stream_writer_hasher_md5 : public stream_writer {
public:
stream_writer_hasher_md5() {
m_hasher->initialize(m_state);
}
void write(const void * p_buffer,t_size p_bytes,abort_callback & p_abort) {
p_abort.check();
m_hasher->process(m_state,p_buffer,p_bytes);
}
hasher_md5_result result() const {
return m_hasher->get_result(m_state);
}
GUID resultGuid() const {
return hasher_md5::guid_from_result(result());
}
private:
hasher_md5_state m_state;
static_api_ptr_t<hasher_md5> m_hasher;
};
template<bool isBigEndian = false>
class stream_formatter_hasher_md5 : public stream_writer_formatter<isBigEndian> {
public:
stream_formatter_hasher_md5() : stream_writer_formatter<isBigEndian>(_m_stream,_m_abort) {}
hasher_md5_result result() const {
return _m_stream.result();
}
GUID resultGuid() const {
return hasher_md5::guid_from_result(result());
}
private:
abort_callback_dummy _m_abort;
stream_writer_hasher_md5 _m_stream;
};

View File

@ -1,26 +0,0 @@
//! New in 0.9.5; allows your file format to use another icon than <extension>.ico when registering the file type with Windows shell. \n
//! Implementation: use icon_remapping_impl, or simply: static service_factory_single_t<icon_remapping_impl> myicon("ext","iconname.ico");
class icon_remapping : public service_base {
public:
//! @param p_extension File type extension being queried.
//! @param p_iconname Receives the icon name to use, including the .ico extension.
//! @returns True when p_iconname has been set, false if we don't recognize the specified extension.
virtual bool query(const char * p_extension,pfc::string_base & p_iconname) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(icon_remapping);
};
//! Standard implementation of icon_remapping.
class icon_remapping_impl : public icon_remapping {
public:
icon_remapping_impl(const char * p_extension,const char * p_iconname) : m_extension(p_extension), m_iconname(p_iconname) {}
bool query(const char * p_extension,pfc::string_base & p_iconname) {
if (stricmp_utf8(p_extension,m_extension) == 0) {
p_iconname = m_iconname; return true;
} else {
return false;
}
}
private:
pfc::string8 m_extension,m_iconname;
};

View File

@ -1,24 +0,0 @@
//! Service used to access various external (online) track info lookup services, such as freedb, to update file tags with info retrieved from those services.
class NOVTABLE info_lookup_handler : public service_base {
public:
enum {
flag_album_lookup = 1 << 0,
flag_track_lookup = 1 << 1,
};
//! Retrieves human-readable name of the lookup handler to display in user interface.
virtual void get_name(pfc::string_base & p_out) = 0;
//! Returns one or more of flag_track_lookup, and flag_album_lookup.
virtual t_uint32 get_flags() = 0;
virtual HICON get_icon(int p_width, int p_height) = 0;
//! Performs a lookup. Creates a modeless dialog and returns immediately.
//! @param p_items Items to look up.
//! @param p_notify Callback to notify caller when the operation has completed. Call on_completion with status code 0 to signal failure/abort, or with code 1 to signal success / new infos in metadb.
//! @param p_parent Parent window for the lookup dialog. Caller will typically disable the window while lookup is in progress and enable it back when completion is signaled.
virtual void lookup(const pfc::list_base_const_t<metadb_handle_ptr> & p_items,completion_notify_ptr p_notify,HWND p_parent) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(info_lookup_handler);
};

View File

@ -1,13 +0,0 @@
//! Basic callback startup/shutdown callback, on_init is called after the main window has been created, on_quit is called before the main window is destroyed.
//! To register: static initquit_factory_t<myclass> myclass_factory;
class NOVTABLE initquit : public service_base
{
public:
virtual void on_init() {}
virtual void on_quit() {}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(initquit);
};
template<typename T>
class initquit_factory_t : public service_factory_single_t<T> {};

View File

@ -1,248 +0,0 @@
#include "foobar2000.h"
bool input_entry::g_find_service_by_path(service_ptr_t<input_entry> & p_out,const char * p_path)
{
service_ptr_t<input_entry> ptr;
service_enum_t<input_entry> e;
pfc::string_extension ext(p_path);
while(e.next(ptr))
{
if (ptr->is_our_path(p_path,ext))
{
p_out = ptr;
return true;
}
}
return false;
}
bool input_entry::g_find_service_by_content_type(service_ptr_t<input_entry> & p_out,const char * p_content_type)
{
service_ptr_t<input_entry> ptr;
service_enum_t<input_entry> e;
while(e.next(ptr))
{
if (ptr->is_our_content_type(p_content_type))
{
p_out = ptr;
return true;
}
}
return false;
}
static void prepare_for_open(service_ptr_t<input_entry> & p_service,service_ptr_t<file> & p_file,const char * p_path,filesystem::t_open_mode p_open_mode,abort_callback & p_abort,bool p_from_redirect)
{
if (p_file.is_empty())
{
service_ptr_t<filesystem> fs;
if (filesystem::g_get_interface(fs,p_path)) {
if (fs->supports_content_types()) {
fs->open(p_file,p_path,p_open_mode,p_abort);
}
}
}
if (p_file.is_valid())
{
pfc::string8 content_type;
if (p_file->get_content_type(content_type))
{
if (input_entry::g_find_service_by_content_type(p_service,content_type))
return;
}
}
if (input_entry::g_find_service_by_path(p_service,p_path))
{
if (p_from_redirect && p_service->is_redirect()) throw exception_io_unsupported_format();
return;
}
throw exception_io_unsupported_format();
}
namespace {
bool g_find_inputs_by_content_type(pfc::list_base_t<service_ptr_t<input_entry> > & p_out,const char * p_content_type,bool p_from_redirect) {
service_enum_t<input_entry> e;
service_ptr_t<input_entry> ptr;
bool ret = false;
while(e.next(ptr)) {
if (!(p_from_redirect && ptr->is_redirect())) {
if (ptr->is_our_content_type(p_content_type)) {p_out.add_item(ptr); ret = true;}
}
}
return ret;
}
bool g_find_inputs_by_path(pfc::list_base_t<service_ptr_t<input_entry> > & p_out,const char * p_path,bool p_from_redirect) {
service_enum_t<input_entry> e;
service_ptr_t<input_entry> ptr;
pfc::string_extension extension(p_path);
bool ret = false;
while(e.next(ptr)) {
if (!(p_from_redirect && ptr->is_redirect())) {
if (ptr->is_our_path(p_path,extension)) {p_out.add_item(ptr); ret = true;}
}
}
return ret;
}
template<typename t_service> void g_open_from_list(service_ptr_t<t_service> & p_instance,pfc::list_base_const_t<service_ptr_t<input_entry> > const & p_list,service_ptr_t<file> const & p_filehint,const char * p_path,abort_callback & p_abort) {
const t_size count = p_list.get_count();
if (count == 1) {
p_list[0]->open(p_instance,p_filehint,p_path,p_abort);
} else {
bool got_bad_data = false, got_bad_data_multi = false;
bool done = false;
pfc::string8 bad_data_message;
for(t_size n=0;n<count && !done;n++) {
try {
p_list[n]->open(p_instance,p_filehint,p_path,p_abort);
done = true;
} catch(exception_io_unsupported_format) {
//do nothing, skip over
} catch(exception_io_data const & e) {
if (!got_bad_data) bad_data_message = e.what();
else got_bad_data_multi = true;
got_bad_data = true;
}
}
if (!done) {
if (got_bad_data_multi) throw exception_io_data();
else if (got_bad_data) throw exception_io_data(bad_data_message);
else throw exception_io_unsupported_format();
}
}
}
template<typename t_service> bool needs_write_access() {return false;}
template<> bool needs_write_access<input_info_writer>() {return true;}
template<typename t_service> void g_open_t(service_ptr_t<t_service> & p_instance,service_ptr_t<file> const & p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) {
service_ptr_t<file> l_file = p_filehint;
if (l_file.is_empty()) {
service_ptr_t<filesystem> fs;
if (filesystem::g_get_interface(fs,p_path)) {
if (fs->supports_content_types()) {
fs->open(l_file,p_path,needs_write_access<t_service>() ? filesystem::open_mode_write_existing : filesystem::open_mode_read,p_abort);
}
}
}
if (l_file.is_valid()) {
pfc::string8 content_type;
if (l_file->get_content_type(content_type)) {
pfc::list_hybrid_t<service_ptr_t<input_entry>,4> list;
if (g_find_inputs_by_content_type(list,content_type,p_from_redirect)) {
g_open_from_list(p_instance,list,l_file,p_path,p_abort);
return;
}
}
}
{
pfc::list_hybrid_t<service_ptr_t<input_entry>,4> list;
if (g_find_inputs_by_path(list,p_path,p_from_redirect)) {
g_open_from_list(p_instance,list,l_file,p_path,p_abort);
return;
}
}
throw exception_io_unsupported_format();
}
};
void input_entry::g_open_for_decoding(service_ptr_t<input_decoder> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) {
TRACK_CALL_TEXT("input_entry::g_open_for_decoding");
#if 1
g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect);
#else
service_ptr_t<file> filehint = p_filehint;
service_ptr_t<input_entry> entry;
prepare_for_open(entry,filehint,p_path,filesystem::open_mode_read,p_abort,p_from_redirect);
entry->open_for_decoding(p_instance,filehint,p_path,p_abort);
#endif
}
void input_entry::g_open_for_info_read(service_ptr_t<input_info_reader> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) {
TRACK_CALL_TEXT("input_entry::g_open_for_info_read");
#if 1
g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect);
#else
service_ptr_t<file> filehint = p_filehint;
service_ptr_t<input_entry> entry;
prepare_for_open(entry,filehint,p_path,filesystem::open_mode_read,p_abort,p_from_redirect);
entry->open_for_info_read(p_instance,filehint,p_path,p_abort);
#endif
}
void input_entry::g_open_for_info_write(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect) {
TRACK_CALL_TEXT("input_entry::g_open_for_info_write");
#if 1
g_open_t(p_instance,p_filehint,p_path,p_abort,p_from_redirect);
#else
service_ptr_t<file> filehint = p_filehint;
service_ptr_t<input_entry> entry;
prepare_for_open(entry,filehint,p_path,filesystem::open_mode_write_existing,p_abort,p_from_redirect);
entry->open_for_info_write(p_instance,filehint,p_path,p_abort);
#endif
}
void input_entry::g_open_for_info_write_timeout(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect) {
pfc::lores_timer timer;
timer.start();
for(;;) {
try {
g_open_for_info_write(p_instance,p_filehint,p_path,p_abort,p_from_redirect);
break;
} catch(exception_io_sharing_violation) {
if (timer.query() > p_timeout) throw;
p_abort.sleep(0.01);
}
}
}
bool input_entry::g_is_supported_path(const char * p_path)
{
service_ptr_t<input_entry> ptr;
service_enum_t<input_entry> e;
pfc::string_extension ext(p_path);
while(e.next(ptr))
{
if (ptr->is_our_path(p_path,ext)) return true;
}
return false;
}
void input_open_file_helper(service_ptr_t<file> & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort)
{
if (p_file.is_empty()) {
switch(p_reason) {
default:
throw pfc::exception_bug_check_v2();
case input_open_info_read:
case input_open_decode:
filesystem::g_open(p_file,p_path,filesystem::open_mode_read,p_abort);
break;
case input_open_info_write:
filesystem::g_open(p_file,p_path,filesystem::open_mode_write_existing,p_abort);
break;
}
} else {
p_file->reopen(p_abort);
}
}

View File

@ -1,189 +0,0 @@
enum {
input_flag_no_seeking = 1 << 0,
input_flag_no_looping = 1 << 1,
input_flag_playback = 1 << 2,
input_flag_testing_integrity = 1 << 3,
input_flag_allow_inaccurate_seeking = 1 << 4,
input_flag_simpledecode = input_flag_no_seeking|input_flag_no_looping,
};
//! Class providing interface for retrieval of information (metadata, duration, replaygain, other tech infos) from files. Also see: file_info. \n
//! Instantiating: see input_entry.\n
//! Implementing: see input_impl.
class NOVTABLE input_info_reader : public service_base
{
public:
//! Retrieves count of subsongs in the file. 1 for non-multisubsong-enabled inputs.
//! Note: multi-subsong handling is disabled for remote files (see: filesystem::is_remote) for performance reasons. Remote files are always assumed to be single-subsong, with null index.
virtual t_uint32 get_subsong_count() = 0;
//! Retrieves identifier of specified subsong; this identifier is meant to be used in playable_location as well as a parameter for input_info_reader::get_info().
//! @param p_index Index of subsong to query. Must be >=0 and < get_subsong_count().
virtual t_uint32 get_subsong(t_uint32 p_index) = 0;
//! Retrieves information about specified subsong.
//! @param p_subsong Identifier of the subsong to query. See: input_info_reader::get_subsong(), playable_location.
//! @param p_info file_info object to fill. Must be empty on entry.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) = 0;
//! Retrieves file stats. Equivalent to calling get_stats() on file object.
virtual t_filestats get_file_stats(abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(input_info_reader,service_base);
};
//! Class providing interface for retrieval of PCM audio data from files.\n
//! Instantiating: see input_entry.\n
//! Implementing: see input_impl.
class NOVTABLE input_decoder : public input_info_reader
{
public:
//! Prepares to decode specified subsong; resets playback position to the beginning of specified subsong. This must be called first, before any other input_decoder methods (other than those inherited from input_info_reader). \n
//! It is legal to set initialize() more than once, with same or different subsong, to play either the same subsong again or another subsong from same file without full reopen.\n
//! Warning: this interface inherits from input_info_reader, it is legal to call any input_info_reader methods even during decoding! Call order is not defined, other than initialize() requirement before calling other input_decoder methods.\n
//! @param p_subsong Subsong to decode. Should always be 0 for non-multi-subsong-enabled inputs.
//! @param p_flags Specifies additional hints for decoding process. It can be null, or a combination of one or more following constants: \n
//! input_flag_no_seeking - Indicates that seek() will never be called. Can be used to avoid building potentially expensive seektables when only sequential reading is needed.\n
//! input_flag_no_looping - Certain input implementations can be configured to utilize looping info from file formats they process and keep playing single file forever, or keep repeating it specified number of times. This flag indicates that such features should be disabled, for e.g. ReplayGain scan or conversion.\n
//! input_flag_playback - Indicates that decoding process will be used for realtime playback rather than conversion. This can be used to reconfigure features that are relevant only for conversion and take a lot of resources, such as very slow secure CDDA reading. \n
//! input_flag_testing_integrity - Indicates that we're testing integrity of the file. Any recoverable problems where decoding would normally continue should cause decoder to fail with exception_io_data.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) = 0;
//! Reads/decodes one chunk of audio data. Use false return value to signal end of file (no more data to return). Before calling run(), decoding must be initialized by initialize() call.
//! @param p_chunk audio_chunk object receiving decoded data. Contents are valid only the method returns true.
//! @param p_abort abort_callback object signaling user aborting the operation.
//! @returns true on success (new data decoded), false on EOF.
virtual bool run(audio_chunk & p_chunk,abort_callback & p_abort) = 0;
//! Seeks to specified time offset. Before seeking or other decoding calls, decoding must be initialized with initialize() call.
//! @param p_seconds Time to seek to, in seconds. If p_seconds exceeds length of the object being decoded, succeed, and then return false from next run() call.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void seek(double p_seconds,abort_callback & p_abort) = 0;
//! Queries whether resource being read/decoded is seekable. If p_value is set to false, all seek() calls will fail. Before calling can_seek() or other decoding calls, decoding must be initialized with initialize() call.
virtual bool can_seek() = 0;
//! This function is used to signal dynamic VBR bitrate, etc. Called after each run() (or not called at all if caller doesn't care about dynamic info).
//! @param p_out Initially contains currently displayed info (either last get_dynamic_info result or current cached info), use this object to return changed info.
//! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0.
//! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed.
virtual bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) = 0;
//! This function is used to signal dynamic live stream song titles etc. Called after each run() (or not called at all if caller doesn't care about dynamic info). The difference between this and get_dynamic_info() is frequency and relevance of dynamic info changes - get_dynamic_info_track() returns new info only on track change in the stream, returning new titles etc.
//! @param p_out Initially contains currently displayed info (either last get_dynamic_info_track result or current cached info), use this object to return changed info.
//! @param p_timestamp_delta Indicates when returned info should be displayed (in seconds, relative to first sample of last decoded chunk), initially set to 0.
//! @returns false to keep old info, or true to indicate that changes have been made to p_info and those should be displayed.
virtual bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) = 0;
//! Called from playback thread before sleeping.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void on_idle(abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(input_decoder,input_info_reader);
};
class NOVTABLE input_decoder_v2 : public input_decoder {
FB2K_MAKE_SERVICE_INTERFACE(input_decoder_v2, input_decoder)
public:
//! OPTIONAL, throws pfc::exception_not_implemented() when not supported by this implementation.
//! Special version of run(). Returns an audio_chunk object as well as a raw data block containing original PCM stream. This is mainly used for MD5 checks on lossless formats. \n
//! If you set a "MD5" tech info entry in get_info(), you should make sure that run_raw() returns data stream that can be used to verify it. \n
//! Returned raw data should be possible to cut into individual samples; size in bytes should be divisible by audio_chunk's sample count for splitting in case partial output is needed (with cuesheets etc).
virtual bool run_raw(audio_chunk & out, mem_block_container & outRaw, abort_callback & abort) = 0;
//! OPTIONAL, the call is ignored if this implementation doesn't support status logging. \n
//! Mainly used to generate logs when ripping CDs etc.
virtual void set_logger(event_logger::ptr ptr) = 0;
};
//! Class providing interface for writing metadata and replaygain info to files. Also see: file_info. \n
//! Instantiating: see input_entry.\n
//! Implementing: see input_impl.
class NOVTABLE input_info_writer : public input_info_reader
{
public:
//! Tells the service to update file tags with new info for specified subsong.
//! @param p_subsong Subsong to update. Should be always 0 for non-multisubsong-enabled inputs.
//! @param p_info New info to write. Sometimes not all contents of p_info can be written. Caller will typically read info back after successful write, so e.g. tech infos that change with retag are properly maintained.
//! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first.
virtual void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) = 0;
//! Commits pending updates. In case of multisubsong inputs, set_info should queue the update and perform actual file access in commit(). Otherwise, actual writing can be done in set_info() and then Commit() can just do nothing and always succeed.
//! @param p_abort abort_callback object signaling user aborting the operation. WARNING: abort_callback object is provided for consistency; if writing tags actually gets aborted, user will be likely left with corrupted file. Anything calling this should make sure that aborting is either impossible, or gives appropriate warning to the user first.
virtual void commit(abort_callback & p_abort) = 0;
FB2K_MAKE_SERVICE_INTERFACE(input_info_writer,input_info_reader);
};
class NOVTABLE input_entry : public service_base
{
public:
//! Determines whether specified content type can be handled by this input.
//! @param p_type Content type string to test.
virtual bool is_our_content_type(const char * p_type)=0;
//! Determines whether specified file type can be handled by this input. This must not use any kind of file access; the result should be only based on file path / extension.
//! @param p_full_path Full URL of file being tested.
//! @param p_extension Extension of file being tested, provided by caller for performance reasons.
virtual bool is_our_path(const char * p_full_path,const char * p_extension)=0;
//! Opens specified resource for decoding.
//! @param p_instance Receives new input_decoder instance if successful.
//! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example).
//! @param p_path URL of resource being opened.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void open_for_decoding(service_ptr_t<input_decoder> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) = 0;
//! Opens specified file for reading info.
//! @param p_instance Receives new input_info_reader instance if successful.
//! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example).
//! @param p_path URL of resource being opened.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void open_for_info_read(service_ptr_t<input_info_reader> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) = 0;
//! Opens specified file for writing info.
//! @param p_instance Receives new input_info_writer instance if successful.
//! @param p_filehint Optional; passes file object to use for the operation; if set to null, the service will handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example).
//! @param p_path URL of resource being opened.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void open_for_info_write(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) = 0;
//! Reserved for future use. Do nothing and return until specifications are finalized.
virtual void get_extended_data(service_ptr_t<file> p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) = 0;
enum {
//! Indicates that this service implements some kind of redirector that opens another input for decoding, used to avoid circular call possibility.
flag_redirect = 1,
//! Indicates that multi-CPU optimizations should not be used.
flag_parallel_reads_slow = 2,
};
//! See flag_* enums.
virtual unsigned get_flags() = 0;
inline bool is_redirect() {return (get_flags() & flag_redirect) != 0;}
inline bool are_parallel_reads_slow() {return (get_flags() & flag_parallel_reads_slow) != 0;}
static bool g_find_service_by_path(service_ptr_t<input_entry> & p_out,const char * p_path);
static bool g_find_service_by_content_type(service_ptr_t<input_entry> & p_out,const char * p_content_type);
static void g_open_for_decoding(service_ptr_t<input_decoder> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false);
static void g_open_for_info_read(service_ptr_t<input_info_reader> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false);
static void g_open_for_info_write(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,bool p_from_redirect = false);
static void g_open_for_info_write_timeout(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort,double p_timeout,bool p_from_redirect = false);
static bool g_is_supported_path(const char * p_path);
void open(service_ptr_t<input_decoder> & p_instance,service_ptr_t<file> const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_decoding(p_instance,p_filehint,p_path,p_abort);}
void open(service_ptr_t<input_info_reader> & p_instance,service_ptr_t<file> const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_read(p_instance,p_filehint,p_path,p_abort);}
void open(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> const & p_filehint,const char * p_path,abort_callback & p_abort) {open_for_info_write(p_instance,p_filehint,p_path,p_abort);}
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_entry);
};

View File

@ -1,65 +0,0 @@
#include "foobar2000.h"
typedef pfc::avltree_t<pfc::string8,pfc::io::path::comparator> t_fnList;
static void formatMaskList(pfc::string_base & out, t_fnList const & in) {
pfc::const_iterator<pfc::string8> walk = in.first();
if (walk.is_valid()) {
out << *walk; ++walk;
while(walk.is_valid()) {
out << ";" << *walk; ++walk;
}
}
}
static void formatMaskList(pfc::string_base & out, t_fnList const & in, const char * label) {
if (in.get_count() > 0) {
out << label << "|";
formatMaskList(out,in);
out << "|";
}
}
void input_file_type::build_openfile_mask(pfc::string_base & out, bool b_include_playlists)
{
t_fnList extensionsAll, extensionsPl;;
if (b_include_playlists) {
service_enum_t<playlist_loader> e; service_ptr_t<playlist_loader> ptr;
while(e.next(ptr)) {
if (ptr->is_associatable()) {
pfc::string_formatter temp; temp << "*." << ptr->get_extension();
extensionsPl += temp;
extensionsAll += temp;
}
}
}
typedef pfc::map_t<pfc::string8,t_fnList,pfc::string::comparatorCaseInsensitive> t_masks;
t_masks masks;
{
service_enum_t<input_file_type> e;
service_ptr_t<input_file_type> ptr;
pfc::string_formatter name, mask;
while(e.next(ptr)) {
const unsigned count = ptr->get_count();
for(unsigned n=0;n<count;n++) {
name.reset();
mask.reset();
if (ptr->get_name(n,name) && ptr->get_mask(n,mask)) {
if (!strchr(name,'|') && !strchr(mask,'|')) {
masks.find_or_add(name) += mask;
extensionsAll += mask;
}
}
}
}
}
pfc::string_formatter outBuf;
outBuf << "All files|*.*|";
formatMaskList(outBuf, extensionsAll, "All supported types");
formatMaskList(outBuf, extensionsPl, "Playlists");
for(t_masks::const_iterator walk = masks.first(); walk.is_valid(); ++walk) {
formatMaskList(outBuf,walk->m_value,walk->m_key);
}
out = outBuf;
}

View File

@ -1,94 +0,0 @@
//! Entrypoint interface for registering media file types that can be opened through "open file" dialogs or associated with foobar2000 application in Windows shell. \n
//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros.
class input_file_type : public service_base {
public:
virtual unsigned get_count()=0;
virtual bool get_name(unsigned idx,pfc::string_base & out)=0;//eg. "MPEG files"
virtual bool get_mask(unsigned idx,pfc::string_base & out)=0;//eg. "*.MP3;*.MP2"; separate with semicolons
virtual bool is_associatable(unsigned idx) = 0;
static void build_openfile_mask(pfc::string_base & out,bool b_include_playlists=true);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(input_file_type);
};
//! Extended interface for registering media file types that can be associated with foobar2000 application in Windows shell. \n
//! Instead of implementing this directly, use DECLARE_FILE_TYPE() / DECLARE_FILE_TYPE_EX() macros.
class input_file_type_v2 : public input_file_type {
public:
virtual void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) = 0;
virtual void get_extensions(unsigned idx, pfc::string_base & out) = 0;
//Deprecated input_file_type method implementations:
bool get_name(unsigned idx, pfc::string_base & out) {get_format_name(idx, out, true); return true;}
bool get_mask(unsigned idx, pfc::string_base & out) {
pfc::string_formatter temp; get_extensions(idx,temp);
pfc::chain_list_v2_t<pfc::string> exts; pfc::splitStringSimple_toList(exts,";",temp);
if (exts.get_count() == 0) return false;//should not happen
temp.reset();
for(pfc::const_iterator<pfc::string> walk = exts.first(); walk.is_valid(); ++walk) {
if (!temp.is_empty()) temp << ";";
temp << "*." << walk->get_ptr();
}
out = temp;
return true;
}
FB2K_MAKE_SERVICE_INTERFACE(input_file_type_v2,input_file_type)
};
//! Implementation helper.
class input_file_type_impl : public service_impl_single_t<input_file_type>
{
const char * name, * mask;
bool m_associatable;
public:
input_file_type_impl(const char * p_name, const char * p_mask,bool p_associatable) : name(p_name), mask(p_mask), m_associatable(p_associatable) {}
unsigned get_count() {return 1;}
bool get_name(unsigned idx,pfc::string_base & out) {if (idx==0) {out = name; return true;} else return false;}
bool get_mask(unsigned idx,pfc::string_base & out) {if (idx==0) {out = mask; return true;} else return false;}
bool is_associatable(unsigned idx) {return m_associatable;}
};
//! Helper macro for registering our media file types.
//! Usage: DECLARE_FILE_TYPE("Blah files","*.blah;*.bleh");
#define DECLARE_FILE_TYPE(NAME,MASK) \
namespace { static input_file_type_impl g_filetype_instance(NAME,MASK,true); \
static service_factory_single_ref_t<input_file_type_impl> g_filetype_service(g_filetype_instance); }
//! Implementation helper.
//! Usage: static input_file_type_factory mytype("blah type","*.bla;*.meh",true);
class input_file_type_factory : private service_factory_single_transparent_t<input_file_type_impl>
{
public:
input_file_type_factory(const char * p_name,const char * p_mask,bool p_associatable)
: service_factory_single_transparent_t<input_file_type_impl>(p_name,p_mask,p_associatable) {}
};
class input_file_type_v2_impl : public input_file_type_v2 {
public:
input_file_type_v2_impl(const char * extensions,const char * name, const char * namePlural) : m_extensions(extensions), m_name(name), m_namePlural(namePlural) {}
unsigned get_count() {return 1;}
bool is_associatable(unsigned idx) {return true;}
void get_format_name(unsigned idx, pfc::string_base & out, bool isPlural) {
out = isPlural ? m_namePlural : m_name;
}
void get_extensions(unsigned idx, pfc::string_base & out) {
out = m_extensions;
}
private:
const pfc::string8 m_name, m_namePlural, m_extensions;
};
//! Helper macro for registering our media file types, extended version providing separate singular/plural type names.
//! Usage: DECLARE_FILE_TYPE_EX("mp1;mp2;mp3","MPEG file","MPEG files")
#define DECLARE_FILE_TYPE_EX(extensions, name, namePlural) \
namespace { static service_factory_single_t<input_file_type_v2_impl> g_myfiletype(extensions, name, namePlural); }

View File

@ -1,314 +0,0 @@
enum t_input_open_reason {
input_open_info_read,
input_open_decode,
input_open_info_write
};
//! Helper function for input implementation use; ensures that file is open with relevant access mode. This is typically called from input_impl::open() and such.
//! @param p_file File object pointer to process. If passed pointer is non-null, the function does nothing and always succeeds; otherwise it attempts to open the file using filesystem API methods.
//! @param p_path Path to the file.
//! @param p_reason Type of input operation requested. See: input_impl::open() parameters.
//! @param p_abort abort_callback object signaling user aborting the operation.
void input_open_file_helper(service_ptr_t<file> & p_file,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort);
//! This is a class that just declares prototypes of functions that each input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_impl as virtual functions are not used on implementation class level. Use input_factory_t template to register input class based on input_impl.
class input_impl
{
public:
//! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails.
//! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write).
//! @param p_path URL of resource being opened.
//! @param p_reason Type of operation requested. Possible values are: \n
//! - input_open_info_read - info retrieval methods are valid; \n
//! - input_open_decode - info retrieval and decoding methods are valid; \n
//! - input_open_info_write - info retrieval and retagging methods are valid; \n
//! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period.
//! @param p_abort abort_callback object signaling user aborting the operation.
void open(service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort);
//! See: input_info_reader::get_subsong_count(). Valid after open() with any reason.
unsigned get_subsong_count();
//! See: input_info_reader::get_subsong(). Valid after open() with any reason.
t_uint32 get_subsong(unsigned p_index);
//! See: input_info_reader::get_info(). Valid after open() with any reason.
void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort);
//! See: input_info_reader::get_file_stats(). Valid after open() with any reason.
t_filestats get_file_stats(abort_callback & p_abort);
//! See: input_decoder::initialize(). Valid after open() with input_open_decode reason.
void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort);
//! See: input_decoder::run(). Valid after decode_initialize().
bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort);
//! See: input_decoder::seek(). Valid after decode_initialize().
void decode_seek(double p_seconds,abort_callback & p_abort);
//! See: input_decoder::can_seek(). Valid after decode_initialize().
bool decode_can_seek();
//! See: input_decoder::get_dynamic_info(). Valid after decode_initialize().
bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta);
//! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize().
bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta);
//! See: input_decoder::on_idle(). Valid after decode_initialize().
void decode_on_idle(abort_callback & p_abort);
//! See: input_info_writer::set_info(). Valid after open() with input_open_info_write reason.
void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort);
//! See: input_info_writer::commit(). Valid after open() with input_open_info_write reason.
void retag_commit(abort_callback & p_abort);
//! See: input_entry::is_our_content_type().
static bool g_is_our_content_type(const char * p_content_type);
//! See: input_entry::is_our_path().
static bool g_is_our_path(const char * p_path,const char * p_extension);
protected:
input_impl() {}
~input_impl() {}
};
//! This is a class that just declares prototypes of functions that each non-multitrack-enabled input needs to implement. See input_decoder / input_info_reader / input_info_writer interfaces for full descriptions of member functions. Since input implementation class is instantiated using a template, you don't need to derive from input_singletrack_impl as virtual functions are not used on implementation class level. Use input_singletrack_factory_t template to register input class based on input_singletrack_impl.
class input_singletrack_impl
{
public:
//! Opens specified file for info read / decoding / info write. This is called only once, immediately after object creation, before any other methods, and no other methods are called if open() fails.
//! @param p_filehint Optional; passes file object to use for the operation; if set to null, the implementation should handle opening file by itself. Note that not all inputs operate on physical files that can be reached through filesystem API, some of them require this parameter to be set to null (tone and silence generators for an example). Typically, an input implementation that requires file access calls input_open_file_helper() function to ensure that file is open with relevant access mode (read or read/write).
//! @param p_path URL of resource being opened.
//! @param p_reason Type of operation requested. Possible values are: \n
//! - input_open_info_read - info retrieval methods are valid; \n
//! - input_open_decode - info retrieval and decoding methods are valid; \n
//! - input_open_info_write - info retrieval and retagging methods are valid; \n
//! Note that info retrieval methods are valid in all cases, and they may be called at any point of decoding/retagging process. Results of info retrieval methods (other than get_subsong_count() / get_subsong()) between retag_set_info() and retag_commit() are undefined however; those should not be called during that period.
//! @param p_abort abort_callback object signaling user aborting the operation.
void open(service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort);
//! See: input_info_reader::get_info(). Valid after open() with any reason. \n
//! Implementation warning: this is typically also called immediately after tag update and should return newly written content then.
void get_info(file_info & p_info,abort_callback & p_abort);
//! See: input_info_reader::get_file_stats(). Valid after open() with any reason. \n
//! Implementation warning: this is typically also called immediately after tag update and should return new values then.
t_filestats get_file_stats(abort_callback & p_abort);
//! See: input_decoder::initialize(). Valid after open() with input_open_decode reason.
void decode_initialize(unsigned p_flags,abort_callback & p_abort);
//! See: input_decoder::run(). Valid after decode_initialize().
bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort);
//! See: input_decoder::seek(). Valid after decode_initialize().
void decode_seek(double p_seconds,abort_callback & p_abort);
//! See: input_decoder::can_seek(). Valid after decode_initialize().
bool decode_can_seek();
//! See: input_decoder::get_dynamic_info(). Valid after decode_initialize().
bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta);
//! See: input_decoder::get_dynamic_info_track(). Valid after decode_initialize().
bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta);
//! See: input_decoder::on_idle(). Valid after decode_initialize().
void decode_on_idle(abort_callback & p_abort);
//! See: input_info_writer::set_info(). Note that input_info_writer::commit() call isn't forwarded because it's useless in case of non-multitrack-enabled inputs. Valid after open() with input_open_info_write reason.
void retag(const file_info & p_info,abort_callback & p_abort);
//! See: input_entry::is_our_content_type().
static bool g_is_our_content_type(const char * p_content_type);
//! See: input_entry::is_our_path().
static bool g_is_our_path(const char * p_path,const char * p_extension);
protected:
input_singletrack_impl() {}
~input_singletrack_impl() {}
};
//! Used internally by standard input_entry implementation; do not use directly. Translates input_decoder / input_info_reader / input_info_writer calls to input_impl calls.
template<typename I, typename t_base>
class input_impl_interface_wrapper_t : public t_base
{
public:
void open(service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) {
m_instance.open(p_filehint,p_path,p_reason,p_abort);
}
// input_info_reader methods
t_uint32 get_subsong_count() {
return m_instance.get_subsong_count();
}
t_uint32 get_subsong(t_uint32 p_index) {
return m_instance.get_subsong(p_index);
}
void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) {
m_instance.get_info(p_subsong,p_info,p_abort);
}
t_filestats get_file_stats(abort_callback & p_abort) {
return m_instance.get_file_stats(p_abort);
}
// input_decoder methods
void initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) {
m_instance.decode_initialize(p_subsong,p_flags,p_abort);
}
bool run(audio_chunk & p_chunk,abort_callback & p_abort) {
return m_instance.decode_run(p_chunk,p_abort);
}
bool run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) {
return m_instance.decode_run_raw(p_chunk, p_raw, p_abort);
}
void seek(double p_seconds,abort_callback & p_abort) {
m_instance.decode_seek(p_seconds,p_abort);
}
bool can_seek() {
return m_instance.decode_can_seek();
}
bool get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {
return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta);
}
bool get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {
return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta);
}
void on_idle(abort_callback & p_abort) {
m_instance.decode_on_idle(p_abort);
}
void set_logger(event_logger::ptr ptr) {
m_instance.set_logger(ptr);
}
// input_info_writer methods
void set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) {
m_instance.retag_set_info(p_subsong,p_info,p_abort);
}
void commit(abort_callback & p_abort) {
m_instance.retag_commit(p_abort);
}
private:
I m_instance;
};
//! Helper used by input_singletrack_factory_t, do not use directly. Translates input_impl calls to input_singletrack_impl calls.
template<typename I>
class input_wrapper_singletrack_t
{
public:
input_wrapper_singletrack_t() {}
void open(service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort) {
m_instance.open(p_filehint,p_path,p_reason,p_abort);
}
void get_info(t_uint32 p_subsong,file_info & p_info,abort_callback & p_abort) {
if (p_subsong != 0) throw exception_io_data();
m_instance.get_info(p_info,p_abort);
}
t_uint32 get_subsong_count() {
return 1;
}
t_uint32 get_subsong(t_uint32 p_index) {
assert(p_index == 0);
return 0;
}
t_filestats get_file_stats(abort_callback & p_abort) {
return m_instance.get_file_stats(p_abort);
}
void decode_initialize(t_uint32 p_subsong,unsigned p_flags,abort_callback & p_abort) {
if (p_subsong != 0) throw exception_io_data();
m_instance.decode_initialize(p_flags,p_abort);
}
bool decode_run(audio_chunk & p_chunk,abort_callback & p_abort) {return m_instance.decode_run(p_chunk,p_abort);}
void decode_seek(double p_seconds,abort_callback & p_abort) {m_instance.decode_seek(p_seconds,p_abort);}
bool decode_can_seek() {return m_instance.decode_can_seek();}
bool decode_get_dynamic_info(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info(p_out,p_timestamp_delta);}
bool decode_get_dynamic_info_track(file_info & p_out, double & p_timestamp_delta) {return m_instance.decode_get_dynamic_info_track(p_out,p_timestamp_delta);}
void decode_on_idle(abort_callback & p_abort) {m_instance.decode_on_idle(p_abort);}
void retag_set_info(t_uint32 p_subsong,const file_info & p_info,abort_callback & p_abort) {
if (p_subsong != 0) throw exception_io_data();
m_instance.retag(p_info,p_abort);
}
bool decode_run_raw(audio_chunk & p_chunk, mem_block_container & p_raw, abort_callback & p_abort) {
return m_instance.decode_run_raw(p_chunk, p_raw, p_abort);
}
void set_logger(event_logger::ptr ptr) {m_instance.set_logger(ptr);}
void retag_commit(abort_callback & p_abort) {}
static bool g_is_our_content_type(const char * p_content_type) {return I::g_is_our_content_type(p_content_type);}
static bool g_is_our_path(const char * p_path,const char * p_extension) {return I::g_is_our_path(p_path,p_extension);}
private:
I m_instance;
};
//! Helper; standard input_entry implementation. Do not instantiate this directly, use input_factory_t or one of other input_*_factory_t helpers instead.
template<typename I,unsigned t_flags, typename t_decoder = input_decoder, typename t_inforeader = input_info_reader, typename t_infowriter = input_info_writer>
class input_entry_impl_t : public input_entry
{
private:
template<typename T, typename out>
void instantiate_t(service_ptr_t<out> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,t_input_open_reason p_reason,abort_callback & p_abort)
{
service_ptr_t< service_impl_t<input_impl_interface_wrapper_t<I,T> > > temp;
temp = new service_impl_t<input_impl_interface_wrapper_t<I,T> >();
temp->open(p_filehint,p_path,p_reason,p_abort);
p_instance = temp.get_ptr();
}
public:
bool is_our_content_type(const char * p_type) {return I::g_is_our_content_type(p_type);}
bool is_our_path(const char * p_full_path,const char * p_extension) {return I::g_is_our_path(p_full_path,p_extension);}
void open_for_decoding(service_ptr_t<input_decoder> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) {
instantiate_t<t_decoder>(p_instance,p_filehint,p_path,input_open_decode,p_abort);
}
void open_for_info_read(service_ptr_t<input_info_reader> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) {
instantiate_t<t_inforeader>(p_instance,p_filehint,p_path,input_open_info_read,p_abort);
}
void open_for_info_write(service_ptr_t<input_info_writer> & p_instance,service_ptr_t<file> p_filehint,const char * p_path,abort_callback & p_abort) {
instantiate_t<t_infowriter>(p_instance,p_filehint,p_path,input_open_info_write,p_abort);
}
void get_extended_data(service_ptr_t<file> p_filehint,const playable_location & p_location,const GUID & p_guid,mem_block_container & p_out,abort_callback & p_abort) {
p_out.reset();
}
unsigned get_flags() {return t_flags;}
};
//! Stardard input factory. For reference of functions that must be supported by registered class, see input_impl.\n Usage: static input_factory_t<myinputclass> g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly.
template<typename T>
class input_factory_t : public service_factory_single_t<input_entry_impl_t<T,0> > {};
//! Non-multitrack-enabled input factory (helper) - hides multitrack management functions from input implementation; use this for inputs that handle file types where each physical file can contain only one user-visible playable track. For reference of functions that must be supported by registered class, see input_singletrack_impl.\n Usage: static input_singletrack_factory_t<myinputclass> g_myinputclass_factory;\n Note that input classes can't be registered through service_factory_t template directly.template<class T>
template<typename T>
class input_singletrack_factory_t : public service_factory_single_t<input_entry_impl_t<input_wrapper_singletrack_t<T>,0> > {};
//! Extended version of input_factory_t, with non-default flags and supported interfaces. See: input_factory_t, input_entry::get_flags().
template<typename T,unsigned t_flags = 0, typename t_decoder = input_decoder, typename t_inforeader = input_info_reader, typename t_infowriter = input_info_writer>
class input_factory_ex_t : public service_factory_single_t<input_entry_impl_t<T,t_flags, t_decoder, t_inforeader, t_infowriter> > {};
//! Extended version of input_singletrack_factory_t, with non-default flags and supported interfaces. See: input_singletrack_factory_t, input_entry::get_flags().
template<typename T,unsigned t_flags = 0, typename t_decoder = input_decoder, typename t_inforeader = input_info_reader, typename t_infowriter = input_info_writer>
class input_singletrack_factory_ex_t : public service_factory_single_t<input_entry_impl_t<input_wrapper_singletrack_t<T>,t_flags, t_decoder, t_inforeader, t_infowriter> > {};

View File

@ -1,181 +0,0 @@
/*!
This service implements methods allowing you to interact with the Media Library.\n
All methods are valid from main thread only, unless noted otherwise.\n
To avoid race conditions, methods that alter library contents should not be called from inside global callbacks.\n
Usage: Use static_api_ptr_t<library_manager> to instantiate. \n
Future compatibility notes: \n
In 0.9.6, the Media Library backend will be entirely reimplemented to perform tracking of folder content changes on its own. This API will still be provided for backwards compatibility, though most of methods will become stubs as their original purpose will be no longer valid. \n
To keep your component working sanely in future foobar2000 releases, do not depend on functions flagged as scheduled to be dropped - you can still call them, but keep in mind that they will become meaningless in the next major release.
*/
class NOVTABLE library_manager : public service_base {
public:
//! Interface for use with library_manager::enum_items().
class NOVTABLE enum_callback {
public:
//! Return true to continue enumeration, false to abort.
virtual bool on_item(const metadb_handle_ptr & p_item) = 0;
};
//! Returns whether the specified item is in the Media Library or not.
virtual bool is_item_in_library(const metadb_handle_ptr & p_item) = 0;
//! Returns whether current user settings allow the specified item to be added to the Media Library or not.
virtual bool is_item_addable(const metadb_handle_ptr & p_item) = 0;
//! Returns whether current user settings allow the specified item path to be added to the Media Library or not.
virtual bool is_path_addable(const char * p_path) = 0;
//! Retrieves path of the specified item relative to the Media Library folder it is in. Returns true on success, false when the item is not in the Media Library.
//! SPECIAL WARNING: to allow multi-CPU optimizations to parse relative track paths, this API works in threads other than the main app thread. Main thread MUST be blocked while working in such scenarios, it's NOT safe to call from worker threads while the Media Library content/configuration might be getting altered.
virtual bool get_relative_path(const metadb_handle_ptr & p_item,pfc::string_base & p_out) = 0;
//! Calls callback method for every item in the Media Library. Note that order of items in Media Library is undefined.
virtual void enum_items(enum_callback & p_callback) = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing). \n
//! Adds specified items to the Media Library (items actually added will be filtered according to user settings).
virtual void add_items(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing). \n
//! Removes specified items from the Media Library (does nothing if specific item is not in the Media Library).
virtual void remove_items(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing). \n
//! Adds specified items to the Media Library (items actually added will be filtered according to user settings). The difference between this and add_items() is that items are not added immediately; the operation is queued and executed later, so it is safe to call from e.g. global callbacks.
virtual void add_items_async(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing). \n
//! For internal use only; p_data must be sorted by metadb::path_compare; use file_operation_callback static methods instead of calling this directly.
virtual void on_files_deleted_sorted(const pfc::list_base_const_t<const char *> & p_data) = 0;
//! Retrieves the entire Media Library content.
virtual void get_all_items(pfc::list_base_t<metadb_handle_ptr> & p_out) = 0;
//! Returns whether Media Library functionality is enabled or not (to be exact: whether there's at least one Media Library folder present in settings), for e.g. notifying the user to change settings when trying to use a Media Library viewer without having configured the Media Library first.
virtual bool is_library_enabled() = 0;
//! Pops up the Media Library preferences page.
virtual void show_preferences() = 0;
//! Scheduled to be dropped in 0.9.6. \n
//! Deprecated; use library_manager_v2::rescan_async() when possible.\n
//! Rescans user-specified Media Library directories for new files and removes references to files that no longer exist from the Media Library.\n
//! Note that this function creates modal dialog and does not return until the operation has completed.\n
virtual void rescan() = 0;
//! Scheduled to be dropped in 0.9.6. \n
//! Deprecated; use library_manager_v2::check_dead_entries_async() when possible.\n
//! Hints Media Library about possible dead items, typically used for "remove dead entries" context action in ML viewers. The implementation will verify whether the items are actually dead before ML contents are altered.\n
//! Note that this function creates modal dialog and does not return until the operation has completed.\n
virtual void check_dead_entries(const pfc::list_base_t<metadb_handle_ptr> & p_list) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_manager);
};
//! \since 0.9.3
class NOVTABLE library_manager_v2 : public library_manager {
public:
//! Scheduled to be dropped in 0.9.6 (will always return false). \n
//! Returns whether a rescan process is currently running.
virtual bool is_rescan_running() = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing and instantly signal completion). \n
//! Starts an async rescan process. Note that if another process is already running, the process is silently aborted.
//! @param p_parent Parent window for displayed progress dialog.
//! @param p_notify Allows caller to receive notifications about the process finishing. Status code: 1 on success, 0 on user abort. Pass NULL if caller doesn't care.
virtual void rescan_async(HWND p_parent,completion_notify_ptr p_notify) = 0;
//! Scheduled to be dropped in 0.9.6 (will do nothing and instantly signal completion). \n
//! Hints Media Library about possible dead items, typically used for "remove dead entries" context action in ML viewers. The implementation will verify whether the items are actually dead before ML contents are altered.\n
//! @param p_list List of items to process.
//! @param p_parent Parent window for displayed progress dialog.
//! @param p_notify Allows caller to receive notifications about the process finishing. Status code: 1 on success, 0 on user abort. Pass NULL if caller doesn't care.
virtual void check_dead_entries_async(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,HWND p_parent,completion_notify_ptr p_notify) = 0;
FB2K_MAKE_SERVICE_INTERFACE(library_manager_v2,library_manager);
};
class NOVTABLE library_callback_dynamic {
public:
//! Called when new items are added to the Media Library.
virtual void on_items_added(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Called when some items have been removed from the Media Library.
virtual void on_items_removed(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Called when some items in the Media Library have been modified.
virtual void on_items_modified(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
};
//! \since 0.9.5
class NOVTABLE library_manager_v3 : public library_manager_v2 {
public:
//! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved tracks.
//! @returns True on success, false when the feature has not been configured.
virtual bool get_new_file_pattern_tracks(pfc::string_base & p_directory,pfc::string_base & p_format) = 0;
//! Retrieves directory path and subdirectory/filename formatting scheme for newly encoded/copied/moved full album images.
//! @returns True on success, false when the feature has not been configured.
virtual bool get_new_file_pattern_images(pfc::string_base & p_directory,pfc::string_base & p_format) = 0;
virtual void register_callback(library_callback_dynamic * p_callback) = 0;
virtual void unregister_callback(library_callback_dynamic * p_callback) = 0;
FB2K_MAKE_SERVICE_INTERFACE(library_manager_v3,library_manager_v2);
};
class library_callback_dynamic_impl_base : public library_callback_dynamic {
public:
library_callback_dynamic_impl_base() {static_api_ptr_t<library_manager_v3>()->register_callback(this);}
~library_callback_dynamic_impl_base() {static_api_ptr_t<library_manager_v3>()->unregister_callback(this);}
//stub implementations - avoid pure virtual function call issues
void on_items_added(metadb_handle_list_cref p_data) {}
void on_items_removed(metadb_handle_list_cref p_data) {}
void on_items_modified(metadb_handle_list_cref p_data) {}
PFC_CLASS_NOT_COPYABLE_EX(library_callback_dynamic_impl_base);
};
//! Callback service receiving notifications about Media Library content changes. Methods called only from main thread.\n
//! Use library_callback_factory_t template to register.
class NOVTABLE library_callback : public service_base {
public:
//! Called when new items are added to the Media Library.
virtual void on_items_added(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Called when some items have been removed from the Media Library.
virtual void on_items_removed(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
//! Called when some items in the Media Library have been modified.
virtual void on_items_modified(const pfc::list_base_const_t<metadb_handle_ptr> & p_data) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_callback);
};
template<typename T>
class library_callback_factory_t : public service_factory_single_t<T> {};
//! Implement this service to appear on "library viewers" list in Media Library preferences page.\n
//! Use library_viewer_factory_t to register.
class NOVTABLE library_viewer : public service_base {
public:
//! Retrieves GUID of your preferences page (pfc::guid_null if you don't have one).
virtual GUID get_preferences_page() = 0;
//! Queries whether "activate" action is supported (relevant button will be disabled if it's not).
virtual bool have_activate() = 0;
//! Activates your Media Library viewer component (e.g. shows its window).
virtual void activate() = 0;
//! Retrieves GUID of your library_viewer implementation, for internal identification. Note that this not the same as preferences page GUID.
virtual GUID get_guid() = 0;
//! Retrieves name of your Media Library viewer, a null-terminated UTF-8 encoded string.
virtual const char * get_name() = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_viewer);
};
template<typename T>
class library_viewer_factory_t : public service_factory_single_t<T> {};
//! \since 0.9.5.4
//! Allows you to spawn a popup Media Library Search window with any query string that you specify. \n
//! Usage: static_api_ptr_t<library_search_ui>()->show("querygoeshere");
class NOVTABLE library_search_ui : public service_base {
public:
virtual void show(const char * query) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_search_ui)
};

View File

@ -1,17 +0,0 @@
#include "foobar2000.h"
bool link_resolver::g_find(service_ptr_t<link_resolver> & p_out,const char * p_path)
{
service_enum_t<link_resolver> e;
service_ptr_t<link_resolver> ptr;
pfc::string_extension ext(p_path);
while(e.next(ptr))
{
if (ptr->is_our_path(p_path,ext))
{
p_out = ptr;
return true;
}
}
return false;
}

View File

@ -1,33 +0,0 @@
#ifndef _foobar2000_sdk_link_resolver_h_
#define _foobar2000_sdk_link_resolver_h_
//! Interface for resolving different sorts of link files.
//! Utilized by mechanisms that convert filesystem path into list of playable locations.
//! For security reasons, link may only point to playable object path, not to a playlist or another link.
class NOVTABLE link_resolver : public service_base
{
public:
//! Tests whether specified file is supported by this link_resolver service.
//! @param p_path Path of file being queried.
//! @param p_extension Extension of file being queried. This is provided for performance reasons, path already includes it.
virtual bool is_our_path(const char * p_path,const char * p_extension) = 0;
//! Resolves a link file. Before this is called, path must be accepted by is_our_path().
//! @param p_filehint Optional file interface to use. If null/empty, implementation should open file by itself.
//! @param p_path Path of link file to resolve.
//! @param p_out Receives path the link is pointing to.
//! @param p_abort abort_callback object signaling user aborting the operation.
virtual void resolve(service_ptr_t<file> p_filehint,const char * p_path,pfc::string_base & p_out,abort_callback & p_abort) = 0;
//! Helper function; finds link_resolver interface that supports specified link file.
//! @param p_out Receives link_resolver interface on success.
//! @param p_path Path of file to query.
//! @returns True on success, false on failure (no interface that supports specified path could be found).
static bool g_find(service_ptr_t<link_resolver> & p_out,const char * p_path);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(link_resolver);
};
#endif //_foobar2000_sdk_link_resolver_h_

View File

@ -1,20 +0,0 @@
//! Callback object class for main_thread_callback_manager service.
class NOVTABLE main_thread_callback : public service_base {
public:
//! Gets called from main app thread. See main_thread_callback_manager description for more info.
virtual void callback_run() = 0;
FB2K_MAKE_SERVICE_INTERFACE(main_thread_callback,service_base);
};
/*!
Allows you to queue a callback object to be called from main app thread. This is commonly used to trigger main-thread-only API calls from worker threads.\n
This can be also used from main app thread, to avoid race conditions when trying to use APIs that dispatch global callbacks from inside some other global callback, or using message loops / modal dialogs inside global callbacks.
*/
class NOVTABLE main_thread_callback_manager : public service_base {
public:
//! Queues a callback object. This can be called from any thread, implementation ensures multithread safety. Implementation will call p_callback->callback_run() once later. To get it called repeatedly, you would need to add your callback again.
virtual void add_callback(service_ptr_t<main_thread_callback> p_callback) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(main_thread_callback_manager);
};

View File

@ -1,34 +0,0 @@
#include "foobar2000.h"
bool mainmenu_commands::g_execute(const GUID & p_guid,service_ptr_t<service_base> p_callback) {
service_enum_t<mainmenu_commands> e;
service_ptr_t<mainmenu_commands> ptr;
while(e.next(ptr)) {
const t_uint32 count = ptr->get_command_count();
for(t_uint32 n=0;n<count;n++) {
if (ptr->get_command(n) == p_guid) {
ptr->execute(n,p_callback);
return true;
}
}
}
return false;
}
bool mainmenu_commands::g_find_by_name(const char * p_name,GUID & p_guid) {
service_enum_t<mainmenu_commands> e;
service_ptr_t<mainmenu_commands> ptr;
pfc::string8_fastalloc temp;
while(e.next(ptr)) {
const t_uint32 count = ptr->get_command_count();
for(t_uint32 n=0;n<count;n++) {
ptr->get_name(n,temp);
if (stricmp_utf8(temp,p_name) == 0) {
p_guid = ptr->get_command(n);
return true;
}
}
}
return false;
}

View File

@ -1,12 +0,0 @@
#include "foobar2000.h"
void mem_block_container::from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort) {
if (p_bytes == 0) {set_size(0);}
set_size(p_bytes);
p_stream->read_object(get_ptr(),p_bytes,p_abort);
}
void mem_block_container::set(const void * p_buffer,t_size p_size) {
set_size(p_size);
memcpy(get_ptr(),p_buffer,p_size);
}

View File

@ -1,68 +0,0 @@
//! Generic interface for a memory block; used by various other interfaces to return memory blocks while allowing caller to allocate.
class NOVTABLE mem_block_container {
public:
virtual const void * get_ptr() const = 0;
virtual void * get_ptr() = 0;
virtual t_size get_size() const = 0;
virtual void set_size(t_size p_size) = 0;
void from_stream(stream_reader * p_stream,t_size p_bytes,abort_callback & p_abort);
void set(const void * p_buffer,t_size p_size);
void set(const mem_block_container & source) {copy(source);}
template<typename t_source> void set(const t_source & source) {
pfc::static_assert<sizeof(source[0]) == 1>();
set(source.get_ptr(), source.get_size());
}
inline void copy(const mem_block_container & p_source) {set(p_source.get_ptr(),p_source.get_size());}
inline void reset() {set_size(0);}
const mem_block_container & operator=(const mem_block_container & p_source) {copy(p_source);return *this;}
protected:
mem_block_container() {}
~mem_block_container() {}
};
//! mem_block_container implementation.
template<template<typename> class t_alloc = pfc::alloc_standard>
class mem_block_container_impl_t : public mem_block_container {
public:
const void * get_ptr() const {return m_data.get_ptr();}
void * get_ptr() {return m_data.get_ptr();}
t_size get_size() const {return m_data.get_size();}
void set_size(t_size p_size) {
m_data.set_size(p_size);
}
private:
pfc::array_t<t_uint8,t_alloc> m_data;
};
typedef mem_block_container_impl_t<> mem_block_container_impl;
class mem_block_container_temp_impl : public mem_block_container {
public:
mem_block_container_temp_impl(void * p_buffer,t_size p_size) : m_buffer(p_buffer), m_buffer_size(p_size), m_size(0) {}
const void * get_ptr() const {return m_buffer;}
void * get_ptr() {return m_buffer;}
t_size get_size() const {return m_size;}
void set_size(t_size p_size) {if (p_size > m_buffer_size) throw pfc::exception_overflow(); m_size = p_size;}
private:
t_size m_size,m_buffer_size;
void * m_buffer;
};
template<typename t_ref>
class mem_block_container_ref_impl : public mem_block_container {
public:
mem_block_container_ref_impl(t_ref & ref) : m_ref(ref) {
pfc::static_assert<sizeof(ref[0]) == 1>();
}
const void * get_ptr() const {return m_ref.get_ptr();}
void * get_ptr() {return m_ref.get_ptr();}
t_size get_size() const {return m_ref.get_size();}
void set_size(t_size p_size) {m_ref.set_size(p_size);}
private:
t_ref & m_ref;
};

View File

@ -1,128 +0,0 @@
class NOVTABLE mainmenu_group : public service_base {
public:
virtual GUID get_guid() = 0;
virtual GUID get_parent() = 0;
virtual t_uint32 get_sort_priority() = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_group);
};
class NOVTABLE mainmenu_group_popup : public mainmenu_group {
public:
virtual void get_display_string(pfc::string_base & p_out) = 0;
FB2K_MAKE_SERVICE_INTERFACE(mainmenu_group_popup,mainmenu_group);
};
class NOVTABLE mainmenu_commands : public service_base {
public:
enum {
flag_disabled = 1<<0,
flag_checked = 1<<1,
flag_radiochecked = 1<<2,
sort_priority_base = 0x10000,
sort_priority_dontcare = 0x80000000,
sort_priority_last = infinite,
};
//! Retrieves number of implemented commands. Index parameter of other methods must be in 0....command_count-1 range.
virtual t_uint32 get_command_count() = 0;
//! Retrieves GUID of specified command.
virtual GUID get_command(t_uint32 p_index) = 0;
//! Retrieves name of item, for list of commands to assign keyboard shortcuts to etc.
virtual void get_name(t_uint32 p_index,pfc::string_base & p_out) = 0;
//! Retrieves item's description for statusbar etc.
virtual bool get_description(t_uint32 p_index,pfc::string_base & p_out) = 0;
//! Retrieves GUID of owning menu group.
virtual GUID get_parent() = 0;
//! Retrieves sorting priority of the command; the lower the number, the upper in the menu your commands will appear. Third party components should use sorting_priority_base and up (values below are reserved for internal use). In case of equal priority, order is undefined.
virtual t_uint32 get_sort_priority() {return sort_priority_dontcare;}
//! Retrieves display string and display flags to use when menu is about to be displayed. If returns false, menu item won't be displayed. You can create keyboard-shortcut-only commands by always returning false from get_display().
virtual bool get_display(t_uint32 p_index,pfc::string_base & p_text,t_uint32 & p_flags) {p_flags = 0;get_name(p_index,p_text);return true;}
//! Executes the command. p_callback parameter is reserved for future use and should be ignored / set to null pointer.
virtual void execute(t_uint32 p_index,service_ptr_t<service_base> p_callback) = 0;
static bool g_execute(const GUID & p_guid,service_ptr_t<service_base> p_callback = service_ptr_t<service_base>());
static bool g_find_by_name(const char * p_name,GUID & p_guid);
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_commands);
};
class NOVTABLE mainmenu_manager : public service_base {
public:
enum {
flag_show_shortcuts = 1 << 0,
flag_show_shortcuts_global = 1 << 1,
};
virtual void instantiate(const GUID & p_root) = 0;
#ifdef _WIN32
virtual void generate_menu_win32(HMENU p_menu,t_uint32 p_id_base,t_uint32 p_id_count,t_uint32 p_flags) = 0;
#else
#error portme
#endif
//@param p_id Identifier of command to execute, relative to p_id_base of generate_menu_*()
//@returns true if command was executed successfully, false if not (e.g. command with given identifier not found).
virtual bool execute_command(t_uint32 p_id,service_ptr_t<service_base> p_callback = service_ptr_t<service_base>()) = 0;
virtual bool get_description(t_uint32 p_id,pfc::string_base & p_out) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(mainmenu_manager);
};
class mainmenu_groups {
public:
static const GUID file,view,edit,playback,library,help;
static const GUID file_open,file_add,file_playlist,file_etc;
static const GUID playback_controls,playback_etc;
static const GUID view_visualisations, view_alwaysontop;
static const GUID edit_part1,edit_part2,edit_part3;
static const GUID edit_part2_selection,edit_part2_sort,edit_part2_selection_sort;
static const GUID file_etc_preferences, file_etc_exit;
static const GUID help_about;
static const GUID library_refresh;
enum {priority_edit_part1,priority_edit_part2,priority_edit_part3};
enum {priority_edit_part2_commands,priority_edit_part2_selection,priority_edit_part2_sort};
enum {priority_edit_part2_selection_commands,priority_edit_part2_selection_sort};
enum {priority_file_open,priority_file_add,priority_file_playlist,priority_file_etc = mainmenu_commands::sort_priority_last};
};
class mainmenu_group_impl : public mainmenu_group {
public:
mainmenu_group_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority) {}
GUID get_guid() {return m_guid;}
GUID get_parent() {return m_parent;}
t_uint32 get_sort_priority() {return m_priority;}
private:
GUID m_guid,m_parent; t_uint32 m_priority;
};
class mainmenu_group_popup_impl : public mainmenu_group_popup {
public:
mainmenu_group_popup_impl(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : m_guid(p_guid), m_parent(p_parent), m_priority(p_priority), m_name(p_name) {}
GUID get_guid() {return m_guid;}
GUID get_parent() {return m_parent;}
t_uint32 get_sort_priority() {return m_priority;}
void get_display_string(pfc::string_base & p_out) {p_out = m_name;}
private:
GUID m_guid,m_parent; t_uint32 m_priority; pfc::string8 m_name;
};
typedef service_factory_single_t<mainmenu_group_impl> __mainmenu_group_factory;
typedef service_factory_single_t<mainmenu_group_popup_impl> __mainmenu_group_popup_factory;
class mainmenu_group_factory : public __mainmenu_group_factory {
public:
inline mainmenu_group_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority) : __mainmenu_group_factory(p_guid,p_parent,p_priority) {}
};
class mainmenu_group_popup_factory : public __mainmenu_group_popup_factory {
public:
inline mainmenu_group_popup_factory(const GUID & p_guid,const GUID & p_parent,t_uint32 p_priority,const char * p_name) : __mainmenu_group_popup_factory(p_guid,p_parent,p_priority,p_name) {}
};
template<typename T>
class mainmenu_commands_factory_t : public service_factory_single_t<T> {};

View File

@ -1,326 +0,0 @@
#include "foobar2000.h"
bool menu_helpers::context_get_description(const GUID& p_guid,pfc::string_base & out) {
service_ptr_t<contextmenu_item> ptr; t_uint32 index;
if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false;
bool rv = ptr->get_item_description(index, out);
if (!rv) out.reset();
return rv;
}
static bool run_context_command_internal(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller) {
if (data.get_count() == 0) return false;
service_ptr_t<contextmenu_item> ptr; t_uint32 index;
if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false;
{
TRACK_CALL_TEXT("menu_helpers::run_command(), by GUID");
ptr->item_execute_simple(index, p_subcommand, data, caller);
}
return true;
}
bool menu_helpers::run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data)
{
return run_context_command_internal(p_command,p_subcommand,data,contextmenu_item::caller_undefined);
}
bool menu_helpers::run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller)
{
return run_context_command_internal(p_command,p_subcommand,data,caller);
}
bool menu_helpers::test_command_context(const GUID & p_guid)
{
service_ptr_t<contextmenu_item> ptr; t_uint32 index;
return menu_item_resolver::g_resolve_context_command(p_guid, ptr, index);
}
static bool g_is_checked(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller)
{
service_ptr_t<contextmenu_item> ptr; t_uint32 index;
if (!menu_item_resolver::g_resolve_context_command(p_command, ptr, index)) return false;
unsigned displayflags = 0;
pfc::string_formatter dummystring;
if (!ptr->item_get_display_data(dummystring,displayflags,index,p_subcommand,data,caller)) return false;
return (displayflags & contextmenu_item_node::FLAG_CHECKED) != 0;
}
bool menu_helpers::is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data)
{
return g_is_checked(p_command,p_subcommand,data,contextmenu_item::caller_undefined);
}
bool menu_helpers::is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand)
{
metadb_handle_list temp;
static_api_ptr_t<playlist_manager> api;
api->activeplaylist_get_selected_items(temp);
return g_is_checked(p_command,p_subcommand,temp,contextmenu_item::caller_playlist);
}
bool menu_helpers::run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand)
{
metadb_handle_list temp;
static_api_ptr_t<playlist_manager> api;
api->activeplaylist_get_selected_items(temp);
return run_command_context_ex(p_command,p_subcommand,temp,contextmenu_item::caller_playlist);
}
bool menu_helpers::run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand)
{
metadb_handle_ptr item;
if (!static_api_ptr_t<playback_control>()->get_now_playing(item)) return false;//not playing
return run_command_context_ex(p_command,p_subcommand,pfc::list_single_ref_t<metadb_handle_ptr>(item),contextmenu_item::caller_now_playing);
}
bool menu_helpers::guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out)
{
service_enum_t<contextmenu_item> e;
service_ptr_t<contextmenu_item> ptr;
pfc::string8_fastalloc nametemp;
while(e.next(ptr))
{
unsigned n, m = ptr->get_num_items();
for(n=0;n<m;n++)
{
ptr->get_item_name(n,nametemp);
if (!strcmp_ex(nametemp,infinite,p_name,p_name_len))
{
p_out = ptr->get_item_guid(n);
return true;
}
}
}
return false;
}
bool menu_helpers::name_from_guid(const GUID & p_guid,pfc::string_base & p_out) {
service_ptr_t<contextmenu_item> ptr; t_uint32 index;
if (!menu_item_resolver::g_resolve_context_command(p_guid, ptr, index)) return false;
ptr->get_item_name(index, p_out);
return true;
}
static unsigned calc_total_action_count()
{
service_enum_t<contextmenu_item> e;
service_ptr_t<contextmenu_item> ptr;
unsigned ret = 0;
while(e.next(ptr))
ret += ptr->get_num_items();
return ret;
}
const char * menu_helpers::guid_to_name_table::search(const GUID & p_guid)
{
if (!m_inited)
{
m_data.set_size(calc_total_action_count());
t_size dataptr = 0;
pfc::string8_fastalloc nametemp;
service_enum_t<contextmenu_item> e;
service_ptr_t<contextmenu_item> ptr;
while(e.next(ptr))
{
unsigned n, m = ptr->get_num_items();
for(n=0;n<m;n++)
{
assert(dataptr < m_data.get_size());
ptr->get_item_name(n,nametemp);
m_data[dataptr].m_name = _strdup(nametemp);
m_data[dataptr].m_guid = ptr->get_item_guid(n);
dataptr++;
}
}
assert(dataptr == m_data.get_size());
pfc::sort_t(m_data,entry_compare,m_data.get_size());
m_inited = true;
}
t_size index;
if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,p_guid,index))
return m_data[index].m_name;
else
return 0;
}
int menu_helpers::guid_to_name_table::entry_compare_search(const entry & entry1,const GUID & entry2)
{
return pfc::guid_compare(entry1.m_guid,entry2);
}
int menu_helpers::guid_to_name_table::entry_compare(const entry & entry1,const entry & entry2)
{
return pfc::guid_compare(entry1.m_guid,entry2.m_guid);
}
menu_helpers::guid_to_name_table::guid_to_name_table()
{
m_inited = false;
}
menu_helpers::guid_to_name_table::~guid_to_name_table()
{
t_size n, m = m_data.get_size();
for(n=0;n<m;n++) free(m_data[n].m_name);
}
int menu_helpers::name_to_guid_table::entry_compare_search(const entry & entry1,const search_entry & entry2)
{
return stricmp_utf8_ex(entry1.m_name,infinite,entry2.m_name,entry2.m_name_len);
}
int menu_helpers::name_to_guid_table::entry_compare(const entry & entry1,const entry & entry2)
{
return stricmp_utf8(entry1.m_name,entry2.m_name);
}
bool menu_helpers::name_to_guid_table::search(const char * p_name,unsigned p_name_len,GUID & p_out)
{
if (!m_inited)
{
m_data.set_size(calc_total_action_count());
t_size dataptr = 0;
pfc::string8_fastalloc nametemp;
service_enum_t<contextmenu_item> e;
service_ptr_t<contextmenu_item> ptr;
while(e.next(ptr))
{
unsigned n, m = ptr->get_num_items();
for(n=0;n<m;n++)
{
assert(dataptr < m_data.get_size());
ptr->get_item_name(n,nametemp);
m_data[dataptr].m_name = _strdup(nametemp);
m_data[dataptr].m_guid = ptr->get_item_guid(n);
dataptr++;
}
}
assert(dataptr == m_data.get_size());
pfc::sort_t(m_data,entry_compare,m_data.get_size());
m_inited = true;
}
t_size index;
search_entry temp = {p_name,p_name_len};
if (pfc::bsearch_t(m_data.get_size(),m_data,entry_compare_search,temp,index))
{
p_out = m_data[index].m_guid;
return true;
}
else
return false;
}
menu_helpers::name_to_guid_table::name_to_guid_table()
{
m_inited = false;
}
menu_helpers::name_to_guid_table::~name_to_guid_table()
{
t_size n, m = m_data.get_size();
for(n=0;n<m;n++) free(m_data[n].m_name);
}
bool menu_helpers::find_command_by_name(const char * p_name,service_ptr_t<contextmenu_item> & p_item,unsigned & p_index)
{
pfc::string8_fastalloc path,name;
service_enum_t<contextmenu_item> e;
service_ptr_t<contextmenu_item> ptr;
if (e.first(ptr)) do {
// if (ptr->get_type()==type)
{
unsigned action,num_actions = ptr->get_num_items();
for(action=0;action<num_actions;action++)
{
ptr->get_item_default_path(action,path); ptr->get_item_name(action,name);
if (!path.is_empty()) path += "/";
path += name;
if (!stricmp_utf8(p_name,path))
{
p_item = ptr;
p_index = action;
return true;
}
}
}
} while(e.next(ptr));
return false;
}
bool menu_helpers::find_command_by_name(const char * p_name,GUID & p_command)
{
service_ptr_t<contextmenu_item> item;
unsigned index;
bool ret = find_command_by_name(p_name,item,index);
if (ret) p_command = item->get_item_guid(index);
return ret;
}
bool standard_commands::run_main(const GUID & p_guid) {
t_uint32 index;
mainmenu_commands::ptr ptr;
if (!menu_item_resolver::g_resolve_main_command(p_guid, ptr, index)) return false;
ptr->execute(index,service_ptr_t<service_base>());
return true;
}
bool menu_item_resolver::g_resolve_context_command(const GUID & id, contextmenu_item::ptr & out, t_uint32 & out_index) {
menu_item_resolver::ptr api;
if (service_enum_t<menu_item_resolver>().first(api)) {
return api->resolve_context_command(id, out, out_index);
} else {
service_enum_t<contextmenu_item> e; service_ptr_t<contextmenu_item> ptr;
while(e.next(ptr)) {
const unsigned num_actions = ptr->get_num_items();
for(unsigned action=0;action<num_actions;action++) {
if (id == ptr->get_item_guid(action)) {
out_index = action; out = ptr; return true;
}
}
}
return false;
}
}
bool menu_item_resolver::g_resolve_main_command(const GUID & id, mainmenu_commands::ptr & out, t_uint32 & out_index) {
menu_item_resolver::ptr api;
if (service_enum_t<menu_item_resolver>().first(api)) {
return api->resolve_main_command(id, out, out_index);
} else {
service_enum_t<mainmenu_commands> e; service_ptr_t<mainmenu_commands> ptr;
while(e.next(ptr)) {
const t_uint32 total = ptr->get_command_count();
for(t_uint32 walk = 0; walk < total; ++walk) {
if (id == ptr->get_command(walk)) {
out_index = walk; out = ptr; return true;
}
}
}
return false;
}
}

View File

@ -1,182 +0,0 @@
namespace menu_helpers {
#ifdef _WIN32
void win32_auto_mnemonics(HMENU menu);
#endif
bool run_command_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data);
bool run_command_context_ex(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data,const GUID & caller);
bool run_command_context_playlist(const GUID & p_command,const GUID & p_subcommand);
bool run_command_context_now_playing(const GUID & p_command,const GUID & p_subcommand);
bool test_command_context(const GUID & p_guid);
bool is_command_checked_context(const GUID & p_command,const GUID & p_subcommand,const pfc::list_base_const_t<metadb_handle_ptr> & data);
bool is_command_checked_context_playlist(const GUID & p_command,const GUID & p_subcommand);
bool find_command_by_name(const char * p_name,service_ptr_t<contextmenu_item> & p_item,unsigned & p_index);
bool find_command_by_name(const char * p_name,GUID & p_command);
bool context_get_description(const GUID& p_guid,pfc::string_base & out);
bool guid_from_name(const char * p_name,unsigned p_name_len,GUID & p_out);
bool name_from_guid(const GUID & p_guid,pfc::string_base & p_out);
class guid_to_name_table
{
public:
guid_to_name_table();
~guid_to_name_table();
const char * search(const GUID & p_guid);
private:
struct entry {
char* m_name;
GUID m_guid;
};
pfc::array_t<entry> m_data;
bool m_inited;
static int entry_compare_search(const entry & entry1,const GUID & entry2);
static int entry_compare(const entry & entry1,const entry & entry2);
};
class name_to_guid_table
{
public:
name_to_guid_table();
~name_to_guid_table();
bool search(const char * p_name,unsigned p_name_len,GUID & p_out);
private:
struct entry {
char* m_name;
GUID m_guid;
};
pfc::array_t<entry> m_data;
bool m_inited;
struct search_entry {
const char * m_name; unsigned m_name_len;
};
static int entry_compare_search(const entry & entry1,const search_entry & entry2);
static int entry_compare(const entry & entry1,const entry & entry2);
};
};
class standard_commands
{
public:
static const GUID
guid_context_file_properties, guid_context_file_open_directory, guid_context_copy_names,
guid_context_send_to_playlist, guid_context_reload_info, guid_context_reload_info_if_changed,
guid_context_rewrite_info, guid_context_remove_tags,
guid_context_convert_run, guid_context_convert_run_singlefile,guid_context_convert_run_withcue,
guid_context_write_cd,
guid_context_rg_scan_track, guid_context_rg_scan_album, guid_context_rg_scan_album_multi,
guid_context_rg_remove, guid_context_save_playlist, guid_context_masstag_edit,
guid_context_masstag_rename,
guid_main_always_on_top, guid_main_preferences, guid_main_about,
guid_main_exit, guid_main_restart, guid_main_activate,
guid_main_hide, guid_main_activate_or_hide, guid_main_titleformat_help,
guid_main_next, guid_main_previous,
guid_main_next_or_random, guid_main_random, guid_main_pause,
guid_main_play, guid_main_play_or_pause, guid_main_rg_set_album,
guid_main_rg_set_track, guid_main_rg_disable, guid_main_stop,
guid_main_stop_after_current, guid_main_volume_down, guid_main_volume_up,
guid_main_volume_mute, guid_main_add_directory, guid_main_add_files,
guid_main_add_location, guid_main_add_playlist, guid_main_clear_playlist,
guid_main_create_playlist, guid_main_highlight_playing, guid_main_load_playlist,
guid_main_next_playlist, guid_main_previous_playlist, guid_main_open,
guid_main_remove_playlist, guid_main_remove_dead_entries, guid_main_remove_duplicates,
guid_main_rename_playlist, guid_main_save_all_playlists, guid_main_save_playlist,
guid_main_playlist_search, guid_main_playlist_sel_crop, guid_main_playlist_sel_remove,
guid_main_playlist_sel_invert, guid_main_playlist_undo, guid_main_show_console,
guid_main_play_cd, guid_main_restart_resetconfig, guid_main_record,
guid_main_playlist_moveback, guid_main_playlist_moveforward, guid_main_playlist_redo,
guid_main_playback_follows_cursor, guid_main_cursor_follows_playback, guid_main_saveconfig,
guid_main_playlist_select_all, guid_main_show_now_playing,
guid_seek_ahead_1s, guid_seek_ahead_5s, guid_seek_ahead_10s, guid_seek_ahead_30s,
guid_seek_ahead_1min, guid_seek_ahead_2min, guid_seek_ahead_5min, guid_seek_ahead_10min,
guid_seek_back_1s, guid_seek_back_5s, guid_seek_back_10s, guid_seek_back_30s,
guid_seek_back_1min, guid_seek_back_2min, guid_seek_back_5min, guid_seek_back_10min
;
static bool run_main(const GUID & guid);
static inline bool run_context(const GUID & guid,const pfc::list_base_const_t<metadb_handle_ptr> &data) {return menu_helpers::run_command_context(guid,pfc::guid_null,data);}
static inline bool run_context(const GUID & guid,const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller) {return menu_helpers::run_command_context_ex(guid,pfc::guid_null,data,caller);}
static inline bool context_file_properties(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_properties,data,caller);}
static inline bool context_file_open_directory(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_file_open_directory,data,caller);}
static inline bool context_copy_names(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_copy_names,data,caller);}
static inline bool context_send_to_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_send_to_playlist,data,caller);}
static inline bool context_reload_info(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info,data,caller);}
static inline bool context_reload_info_if_changed(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_reload_info_if_changed,data,caller);}
static inline bool context_rewrite_info(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rewrite_info,data,caller);}
static inline bool context_remove_tags(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_remove_tags,data,caller);}
static inline bool context_convert_run(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run,data,caller);}
static inline bool context_convert_run_singlefile(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_convert_run_singlefile,data,caller);}
static inline bool context_write_cd(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_write_cd,data,caller);}
static inline bool context_rg_scan_track(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_track,data,caller);}
static inline bool context_rg_scan_album(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album,data,caller);}
static inline bool context_rg_scan_album_multi(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_scan_album_multi,data,caller);}
static inline bool context_rg_remove(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_rg_remove,data,caller);}
static inline bool context_save_playlist(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_save_playlist,data,caller);}
static inline bool context_masstag_edit(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_edit,data,caller);}
static inline bool context_masstag_rename(const pfc::list_base_const_t<metadb_handle_ptr> &data,const GUID& caller = contextmenu_item::caller_undefined) {return run_context(guid_context_masstag_rename,data,caller);}
static inline bool main_always_on_top() {return run_main(guid_main_always_on_top);}
static inline bool main_preferences() {return run_main(guid_main_preferences);}
static inline bool main_about() {return run_main(guid_main_about);}
static inline bool main_exit() {return run_main(guid_main_exit);}
static inline bool main_restart() {return run_main(guid_main_restart);}
static inline bool main_activate() {return run_main(guid_main_activate);}
static inline bool main_hide() {return run_main(guid_main_hide);}
static inline bool main_activate_or_hide() {return run_main(guid_main_activate_or_hide);}
static inline bool main_titleformat_help() {return run_main(guid_main_titleformat_help);}
static inline bool main_playback_follows_cursor() {return run_main(guid_main_playback_follows_cursor);}
static inline bool main_next() {return run_main(guid_main_next);}
static inline bool main_previous() {return run_main(guid_main_previous);}
static inline bool main_next_or_random() {return run_main(guid_main_next_or_random);}
static inline bool main_random() {return run_main(guid_main_random);}
static inline bool main_pause() {return run_main(guid_main_pause);}
static inline bool main_play() {return run_main(guid_main_play);}
static inline bool main_play_or_pause() {return run_main(guid_main_play_or_pause);}
static inline bool main_rg_set_album() {return run_main(guid_main_rg_set_album);}
static inline bool main_rg_set_track() {return run_main(guid_main_rg_set_track);}
static inline bool main_rg_disable() {return run_main(guid_main_rg_disable);}
static inline bool main_stop() {return run_main(guid_main_stop);}
static inline bool main_stop_after_current() {return run_main(guid_main_stop_after_current);}
static inline bool main_volume_down() {return run_main(guid_main_volume_down);}
static inline bool main_volume_up() {return run_main(guid_main_volume_up);}
static inline bool main_volume_mute() {return run_main(guid_main_volume_mute);}
static inline bool main_add_directory() {return run_main(guid_main_add_directory);}
static inline bool main_add_files() {return run_main(guid_main_add_files);}
static inline bool main_add_location() {return run_main(guid_main_add_location);}
static inline bool main_add_playlist() {return run_main(guid_main_add_playlist);}
static inline bool main_clear_playlist() {return run_main(guid_main_clear_playlist);}
static inline bool main_create_playlist() {return run_main(guid_main_create_playlist);}
static inline bool main_highlight_playing() {return run_main(guid_main_highlight_playing);}
static inline bool main_load_playlist() {return run_main(guid_main_load_playlist);}
static inline bool main_next_playlist() {return run_main(guid_main_next_playlist);}
static inline bool main_previous_playlist() {return run_main(guid_main_previous_playlist);}
static inline bool main_open() {return run_main(guid_main_open);}
static inline bool main_remove_playlist() {return run_main(guid_main_remove_playlist);}
static inline bool main_remove_dead_entries() {return run_main(guid_main_remove_dead_entries);}
static inline bool main_remove_duplicates() {return run_main(guid_main_remove_duplicates);}
static inline bool main_rename_playlist() {return run_main(guid_main_rename_playlist);}
static inline bool main_save_all_playlists() {return run_main(guid_main_save_all_playlists);}
static inline bool main_save_playlist() {return run_main(guid_main_save_playlist);}
static inline bool main_playlist_search() {return run_main(guid_main_playlist_search);}
static inline bool main_playlist_sel_crop() {return run_main(guid_main_playlist_sel_crop);}
static inline bool main_playlist_sel_remove() {return run_main(guid_main_playlist_sel_remove);}
static inline bool main_playlist_sel_invert() {return run_main(guid_main_playlist_sel_invert);}
static inline bool main_playlist_undo() {return run_main(guid_main_playlist_undo);}
static inline bool main_show_console() {return run_main(guid_main_show_console);}
static inline bool main_play_cd() {return run_main(guid_main_play_cd);}
static inline bool main_restart_resetconfig() {return run_main(guid_main_restart_resetconfig);}
static inline bool main_playlist_moveback() {return run_main(guid_main_playlist_moveback);}
static inline bool main_playlist_moveforward() {return run_main(guid_main_playlist_moveforward);}
static inline bool main_saveconfig() {return run_main(guid_main_saveconfig);}
};

View File

@ -1,40 +0,0 @@
#include "foobar2000.h"
bool contextmenu_item::item_get_display_data_root(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const pfc::list_base_const_t<metadb_handle_ptr> & p_data,const GUID & p_caller)
{
bool status = false;
pfc::ptrholder_t<contextmenu_item_node_root> root ( instantiate_item(p_index,p_data,p_caller) );
if (root.is_valid()) status = root->get_display_data(p_out,p_displayflags,p_data,p_caller);
return status;
}
static contextmenu_item_node * g_find_node(const GUID & p_guid,contextmenu_item_node * p_parent)
{
if (p_parent->get_guid() == p_guid) return p_parent;
else if (p_parent->get_type() == contextmenu_item_node::TYPE_POPUP)
{
t_size n, m = p_parent->get_children_count();
for(n=0;n<m;n++)
{
contextmenu_item_node * temp = g_find_node(p_guid,p_parent->get_child(n));
if (temp) return temp;
}
return 0;
}
else return 0;
}
bool contextmenu_item::item_get_display_data(pfc::string_base & p_out,unsigned & p_displayflags,unsigned p_index,const GUID & p_node,const pfc::list_base_const_t<metadb_handle_ptr> & p_data,const GUID & p_caller)
{
bool status = false;
pfc::ptrholder_t<contextmenu_item_node_root> root ( instantiate_item(p_index,p_data,p_caller) );
if (root.is_valid())
{
contextmenu_item_node * node = g_find_node(p_node,root.get_ptr());
if (node) status = node->get_display_data(p_out,p_displayflags,p_data,p_caller);
}
return status;
}

View File

@ -1,401 +0,0 @@
#include "foobar2000.h"
#ifdef WIN32
static void fix_ampersand(const char * src,pfc::string_base & out)
{
out.reset();
unsigned ptr = 0;
while(src[ptr])
{
if (src[ptr]=='&')
{
out.add_string("&&");
ptr++;
while(src[ptr]=='&')
{
out.add_string("&&");
ptr++;
}
}
else out.add_byte(src[ptr++]);
}
}
static unsigned flags_to_win32(unsigned flags)
{
unsigned ret = 0;
if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) {/* dealt with elsewhere */}
else if (flags & contextmenu_item_node::FLAG_CHECKED) ret |= MF_CHECKED;
if (flags & contextmenu_item_node::FLAG_DISABLED) ret |= MF_DISABLED;
if (flags & contextmenu_item_node::FLAG_GRAYED) ret |= MF_GRAYED;
return ret;
}
void contextmenu_manager::win32_build_menu(HMENU menu,contextmenu_node * parent,int base_id,int max_id)//menu item identifiers are base_id<=N<base_id+max_id (if theres too many items, they will be clipped)
{
if (parent!=0 && parent->get_type()==contextmenu_item_node::TYPE_POPUP)
{
pfc::string8_fastalloc temp;
t_size child_idx,child_num = parent->get_num_children();
for(child_idx=0;child_idx<child_num;child_idx++)
{
contextmenu_node * child = parent->get_child(child_idx);
if (child)
{
const char * name = child->get_name();
if (strchr(name,'&')) {fix_ampersand(name,temp);name=temp;}
contextmenu_item_node::t_type type = child->get_type();
if (type==contextmenu_item_node::TYPE_POPUP)
{
HMENU new_menu = CreatePopupMenu();
uAppendMenu(menu,MF_STRING|MF_POPUP | flags_to_win32(child->get_display_flags()),(UINT_PTR)new_menu,name);
win32_build_menu(new_menu,child,base_id,max_id);
}
else if (type==contextmenu_item_node::TYPE_SEPARATOR)
{
uAppendMenu(menu,MF_SEPARATOR,0,0);
}
else if (type==contextmenu_item_node::TYPE_COMMAND)
{
int id = child->get_id();
if (id>=0 && (max_id<0 || id<max_id))
{
const unsigned flags = child->get_display_flags();
const UINT ID = base_id+id;
uAppendMenu(menu,MF_STRING | flags_to_win32(flags),ID,name);
if (flags & contextmenu_item_node::FLAG_RADIOCHECKED) CheckMenuRadioItem(menu,ID,ID,ID,MF_BYCOMMAND);
}
}
}
}
}
}
#endif
bool contextmenu_manager::get_description_by_id(unsigned id,pfc::string_base & out) {
contextmenu_node * ptr = find_by_id(id);
if (ptr == NULL) return false;
return ptr->get_description(out);
}
bool contextmenu_manager::execute_by_id(unsigned id) {
contextmenu_node * ptr = find_by_id(id);
if (ptr == NULL) return false;
ptr->execute();
return true;
}
#ifdef WIN32
void contextmenu_manager::win32_run_menu_popup(HWND parent,const POINT * pt)
{
enum {ID_CUSTOM_BASE = 1};
int cmd;
{
POINT p;
if (pt) p = *pt;
else GetCursorPos(&p);
HMENU hmenu = CreatePopupMenu();
try {
win32_build_menu(hmenu,ID_CUSTOM_BASE,-1);
menu_helpers::win32_auto_mnemonics(hmenu);
cmd = TrackPopupMenu(hmenu,TPM_RIGHTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,p.x,p.y,0,parent,0);
} catch(...) {DestroyMenu(hmenu); throw;}
DestroyMenu(hmenu);
}
if (cmd>0)
{
if (cmd>=ID_CUSTOM_BASE)
{
execute_by_id(cmd - ID_CUSTOM_BASE);
}
}
}
void contextmenu_manager::win32_run_menu_context(HWND parent,const pfc::list_base_const_t<metadb_handle_ptr> & data,const POINT * pt,unsigned flags)
{
service_ptr_t<contextmenu_manager> manager;
contextmenu_manager::g_create(manager);
manager->init_context(data,flags);
manager->win32_run_menu_popup(parent,pt);
}
void contextmenu_manager::win32_run_menu_context_playlist(HWND parent,const POINT * pt,unsigned flags)
{
service_ptr_t<contextmenu_manager> manager;
contextmenu_manager::g_create(manager);
manager->init_context_playlist(flags);
manager->win32_run_menu_popup(parent,pt);
}
namespace {
class mnemonic_manager
{
pfc::string8_fastalloc used;
bool is_used(unsigned c)
{
char temp[8];
temp[pfc::utf8_encode_char(uCharLower(c),temp)]=0;
return !!strstr(used,temp);
}
static bool is_alphanumeric(char c)
{
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9');
}
void insert(const char * src,unsigned idx,pfc::string_base & out)
{
out.reset();
out.add_string(src,idx);
out.add_string("&");
out.add_string(src+idx);
used.add_char(uCharLower(src[idx]));
}
public:
bool check_string(const char * src)
{//check for existing mnemonics
const char * ptr = src;
while(ptr = strchr(ptr,'&'))
{
if (ptr[1]=='&') ptr+=2;
else
{
unsigned c = 0;
if (pfc::utf8_decode_char(ptr+1,c)>0)
{
if (!is_used(c)) used.add_char(uCharLower(c));
}
return true;
}
}
return false;
}
bool process_string(const char * src,pfc::string_base & out)//returns if changed
{
if (check_string(src)) {out=src;return false;}
unsigned idx=0;
while(src[idx]==' ') idx++;
while(src[idx])
{
if (is_alphanumeric(src[idx]) && !is_used(src[idx]))
{
insert(src,idx,out);
return true;
}
while(src[idx] && src[idx]!=' ' && src[idx]!='\t') idx++;
if (src[idx]=='\t') break;
while(src[idx]==' ') idx++;
}
//no success picking first letter of one of words
idx=0;
while(src[idx])
{
if (src[idx]=='\t') break;
if (is_alphanumeric(src[idx]) && !is_used(src[idx]))
{
insert(src,idx,out);
return true;
}
idx++;
}
//giving up
out = src;
return false;
}
};
}
void menu_helpers::win32_auto_mnemonics(HMENU menu)
{
mnemonic_manager mgr;
unsigned n, m = GetMenuItemCount(menu);
pfc::string8_fastalloc temp,temp2;
for(n=0;n<m;n++)//first pass, check existing mnemonics
{
unsigned type = uGetMenuItemType(menu,n);
if (type==MFT_STRING)
{
uGetMenuString(menu,n,temp,MF_BYPOSITION);
mgr.check_string(temp);
}
}
for(n=0;n<m;n++)
{
HMENU submenu = GetSubMenu(menu,n);
if (submenu) win32_auto_mnemonics(submenu);
{
unsigned type = uGetMenuItemType(menu,n);
if (type==MFT_STRING)
{
unsigned state = submenu ? 0 : GetMenuState(menu,n,MF_BYPOSITION);
unsigned id = GetMenuItemID(menu,n);
uGetMenuString(menu,n,temp,MF_BYPOSITION);
if (mgr.process_string(temp,temp2))
{
uModifyMenu(menu,n,MF_BYPOSITION|MF_STRING|state,id,temp2);
}
}
}
}
}
#endif
static bool test_key(unsigned k)
{
return (GetKeyState(k) & 0x8000) ? true : false;
}
#define F_SHIFT (HOTKEYF_SHIFT<<8)
#define F_CTRL (HOTKEYF_CONTROL<<8)
#define F_ALT (HOTKEYF_ALT<<8)
#define F_WIN (HOTKEYF_EXT<<8)
static t_uint32 get_key_code(WPARAM wp) {
t_uint32 code = (t_uint32)(wp & 0xFF);
if (test_key(VK_CONTROL)) code|=F_CTRL;
if (test_key(VK_SHIFT)) code|=F_SHIFT;
if (test_key(VK_MENU)) code|=F_ALT;
if (test_key(VK_LWIN) || test_key(VK_RWIN)) code|=F_WIN;
return code;
}
static t_uint32 get_key_code(WPARAM wp, t_uint32 mods) {
t_uint32 code = (t_uint32)(wp & 0xFF);
if (mods & MOD_CONTROL) code|=F_CTRL;
if (mods & MOD_SHIFT) code|=F_SHIFT;
if (mods & MOD_ALT) code|=F_ALT;
if (mods & MOD_WIN) code|=F_WIN;
return code;
}
bool keyboard_shortcut_manager::on_keydown(shortcut_type type,WPARAM wp)
{
if (type==TYPE_CONTEXT) return false;
metadb_handle_list dummy;
return process_keydown(type,dummy,get_key_code(wp));
}
bool keyboard_shortcut_manager::on_keydown_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller)
{
if (data.get_count()==0) return false;
return process_keydown_ex(TYPE_CONTEXT,data,get_key_code(wp),caller);
}
bool keyboard_shortcut_manager::on_keydown_auto(WPARAM wp)
{
if (on_keydown(TYPE_MAIN,wp)) return true;
if (on_keydown(TYPE_CONTEXT_PLAYLIST,wp)) return true;
if (on_keydown(TYPE_CONTEXT_NOW_PLAYING,wp)) return true;
return false;
}
bool keyboard_shortcut_manager::on_keydown_auto_playlist(WPARAM wp)
{
metadb_handle_list data;
static_api_ptr_t<playlist_manager> api;
api->activeplaylist_get_selected_items(data);
return on_keydown_auto_context(data,wp,contextmenu_item::caller_playlist);
}
bool keyboard_shortcut_manager::on_keydown_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller)
{
if (on_keydown_context(data,wp,caller)) return true;
else return on_keydown_auto(wp);
}
static bool should_relay_key_restricted(UINT p_key) {
switch(p_key) {
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
return false;
default:
return (p_key >= VK_F1 && p_key <= VK_F24) || IsKeyPressed(VK_CONTROL) || IsKeyPressed(VK_LWIN) || IsKeyPressed(VK_RWIN);
}
}
bool keyboard_shortcut_manager::on_keydown_restricted_auto(WPARAM wp) {
if (!should_relay_key_restricted(wp)) return false;
return on_keydown_auto(wp);
}
bool keyboard_shortcut_manager::on_keydown_restricted_auto_playlist(WPARAM wp) {
if (!should_relay_key_restricted(wp)) return false;
return on_keydown_auto_playlist(wp);
}
bool keyboard_shortcut_manager::on_keydown_restricted_auto_context(const pfc::list_base_const_t<metadb_handle_ptr> & data,WPARAM wp,const GUID & caller) {
if (!should_relay_key_restricted(wp)) return false;
return on_keydown_auto_context(data,wp,caller);
}
bool keyboard_shortcut_manager_v2::pretranslate_message(const MSG * msg, HWND thisPopupWnd) {
switch(msg->message) {
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
if (thisPopupWnd != NULL && FindOwningPopup(msg->hwnd) == thisPopupWnd) {
const t_uint32 modifiers = GetHotkeyModifierFlags();
/*if (filterTypableWindowMessage(msg, modifiers))*/ {
if (process_keydown_simple(get_key_code(msg->wParam,modifiers))) return true;
}
}
return false;
default:
return false;
}
}
bool keyboard_shortcut_manager::is_text_key(t_uint32 vkCode) {
return vkCode == VK_SPACE
|| (vkCode >= '0' && vkCode < 0x40)
|| (vkCode > 0x40 && vkCode < VK_LWIN)
|| (vkCode >= VK_NUMPAD0 && vkCode <= VK_DIVIDE)
|| (vkCode >= VK_OEM_1 && vkCode <= VK_OEM_3)
|| (vkCode >= VK_OEM_4 && vkCode <= VK_OEM_8)
;
}
bool keyboard_shortcut_manager::is_typing_key(t_uint32 vkCode) {
return is_text_key(vkCode)
|| vkCode == VK_BACK
|| vkCode == VK_RETURN
|| vkCode == VK_INSERT
|| (vkCode > VK_SPACE && vkCode < '0');
}
bool keyboard_shortcut_manager::is_typing_key_combo(t_uint32 vkCode, t_uint32 modifiers) {
if (!is_typing_modifier(modifiers)) return false;
return is_typing_key(vkCode);
}
bool keyboard_shortcut_manager::is_typing_modifier(t_uint32 flags) {
flags &= ~MOD_SHIFT;
return flags == 0 || flags == (MOD_ALT | MOD_CONTROL);
}
bool keyboard_shortcut_manager::is_typing_message(HWND editbox, const MSG * msg) {
if (msg->hwnd != editbox) return false;
return is_typing_message(msg);
}
bool keyboard_shortcut_manager::is_typing_message(const MSG * msg) {
if (msg->message != WM_KEYDOWN && msg->message != WM_SYSKEYDOWN) return false;
return is_typing_key_combo(msg->wParam, GetHotkeyModifierFlags());
}

View File

@ -1,80 +0,0 @@
class NOVTABLE message_filter
{
public:
virtual bool pretranslate_message(MSG * p_msg) = 0;
};
class NOVTABLE idle_handler {
public:
virtual bool on_idle() = 0;
};
class NOVTABLE message_loop : public service_base
{
public:
virtual void add_message_filter(message_filter * ptr) = 0;
virtual void remove_message_filter(message_filter * ptr) = 0;
virtual void add_idle_handler(idle_handler * ptr) = 0;
virtual void remove_idle_handler(idle_handler * ptr) = 0;
FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(message_loop);
};
class NOVTABLE message_loop_v2 : public message_loop {
public:
virtual void add_message_filter_ex(message_filter * ptr, t_uint32 lowest, t_uint32 highest) = 0;
FB2K_MAKE_SERVICE_INTERFACE(message_loop_v2, message_loop);
};
class message_filter_impl_base : public message_filter {
public:
message_filter_impl_base() {static_api_ptr_t<message_loop>()->add_message_filter(this);}
message_filter_impl_base(t_uint32 lowest, t_uint32 highest) {
static_api_ptr_t<message_loop> api;
message_loop_v2::ptr apiV2;
if (api->service_query_t(apiV2)) {
apiV2->add_message_filter_ex(this, lowest, highest);
} else {
api->add_message_filter(this);
}
}
~message_filter_impl_base() {static_api_ptr_t<message_loop>()->remove_message_filter(this);}
bool pretranslate_message(MSG * p_msg) {return false;}
PFC_CLASS_NOT_COPYABLE(message_filter_impl_base,message_filter_impl_base);
};
class message_filter_impl_accel : public message_filter_impl_base {
protected:
bool pretranslate_message(MSG * p_msg) {
if (m_wnd != NULL) {
if (GetActiveWindow() == m_wnd) {
if (TranslateAccelerator(m_wnd,m_accel.get(),p_msg) != 0) {
return true;
}
}
}
return false;
}
public:
message_filter_impl_accel(HINSTANCE p_instance,const TCHAR * p_accel) : m_wnd(NULL) {
m_accel.load(p_instance,p_accel);
}
void set_wnd(HWND p_wnd) {m_wnd = p_wnd;}
private:
HWND m_wnd;
win32_accelerator m_accel;
PFC_CLASS_NOT_COPYABLE(message_filter_impl_accel,message_filter_impl_accel);
};
class idle_handler_impl_base : public idle_handler {
public:
idle_handler_impl_base() {static_api_ptr_t<message_loop>()->add_idle_handler(this);}
~idle_handler_impl_base() {static_api_ptr_t<message_loop>()->remove_idle_handler(this);}
bool on_idle() {return true;}
PFC_CLASS_NOT_COPYABLE_EX(idle_handler_impl_base)
};

View File

@ -1,76 +0,0 @@
#include "foobar2000.h"
void metadb::handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) {
handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index()));
}
void metadb::handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path) {
pfc::string8 path;
filesystem::g_get_canonical_path(p_new_path,path);
handle_create_replace_path_canonical(p_out,p_source,path);
}
void metadb::handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path) {
metadb_handle_ptr temp;
handle_create_replace_path_canonical(temp,p_out,p_new_path);
p_out = temp;
}
metadb_io::t_load_info_state metadb_io::load_info(metadb_handle_ptr p_item,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors) {
return load_info_multi(pfc::list_single_ref_t<metadb_handle_ptr>(p_item),p_type,p_parent_window,p_show_errors);
}
metadb_io::t_update_info_state metadb_io::update_info(metadb_handle_ptr p_item,file_info & p_info,HWND p_parent_window,bool p_show_errors)
{
file_info * blah = &p_info;
return update_info_multi(pfc::list_single_ref_t<metadb_handle_ptr>(p_item),pfc::list_single_ref_t<file_info*>(blah),p_parent_window,p_show_errors);
}
void metadb_io::hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh)
{
const file_info * blargh = &p_info;
hint_multi_async(pfc::list_single_ref_t<metadb_handle_ptr>(p_item),pfc::list_single_ref_t<const file_info *>(blargh),pfc::list_single_ref_t<t_filestats>(p_stats),bit_array_val(p_fresh));
}
bool metadb::g_get_random_handle(metadb_handle_ptr & p_out) {
if (static_api_ptr_t<playback_control>()->get_now_playing(p_out)) return true;
{
static_api_ptr_t<playlist_manager> api;
t_size playlist_count = api->get_playlist_count();
t_size active_playlist = api->get_active_playlist();
if (active_playlist != infinite) {
if (api->playlist_get_focus_item_handle(p_out,active_playlist)) return true;
}
for(t_size n = 0; n < playlist_count; n++) {
if (api->playlist_get_focus_item_handle(p_out,n)) return true;
}
if (active_playlist != infinite) {
t_size item_count = api->playlist_get_item_count(active_playlist);
if (item_count > 0) {
if (api->playlist_get_item_handle(p_out,active_playlist,0)) return true;
}
}
for(t_size n = 0; n < playlist_count; n++) {
t_size item_count = api->playlist_get_item_count(n);
if (item_count > 0) {
if (api->playlist_get_item_handle(p_out,n,0)) return true;
}
}
}
return false;
}
void metadb_io_v2::update_info_async_simple(const pfc::list_base_const_t<metadb_handle_ptr> & p_list,const pfc::list_base_const_t<const file_info*> & p_new_info, HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) {
update_info_async(p_list,new service_impl_t<file_info_filter_impl>(p_list,p_new_info),p_parent_window,p_op_flags,p_notify);
}

Some files were not shown because too many files have changed in this diff Show More