mirror of
http://mpg123.de/trunk/.git
synced 2025-07-31 13:24:22 +03:00
Handles which are opened by _topen must be used with _read and _close functions
Added a MSVC++ scan project for the scan.c example git-svn-id: svn://scm.orgis.org/mpg123/trunk@1841 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
@ -13,10 +13,14 @@
|
||||
#include <mpg123.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
int _tmain(int argc, _TCHAR* argv[])
|
||||
#else
|
||||
int main(int argc, char **argv)
|
||||
#endif
|
||||
{
|
||||
mpg123_handle *m;
|
||||
int i;
|
||||
int i, res;
|
||||
if(argc < 2)
|
||||
{
|
||||
fprintf(stderr, "\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
|
||||
@ -29,12 +33,26 @@ int main(int argc, char **argv)
|
||||
for(i = 1; i < argc; ++i)
|
||||
{
|
||||
off_t a, b;
|
||||
mpg123_open(m, argv[i]);
|
||||
a = mpg123_length(m);
|
||||
mpg123_scan(m);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
res = mpg123_topen(m, argv[i]);
|
||||
#else
|
||||
res = mpg123_open(m, argv[i]);
|
||||
#endif
|
||||
|
||||
a = mpg123_length(m);
|
||||
res = mpg123_scan(m);
|
||||
b = mpg123_length(m);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
res = mpg123_tclose(m);
|
||||
#else
|
||||
res = mpg123_close(m);
|
||||
#endif
|
||||
|
||||
printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b);
|
||||
}
|
||||
|
||||
mpg123_delete(m);
|
||||
mpg123_exit();
|
||||
return 0;
|
||||
|
@ -626,6 +626,10 @@
|
||||
RelativePath="..\..\..\..\src\libmpg123\readers.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\src\libmpg123\sample.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\src\libmpg123\stringbuf.c"
|
||||
>
|
||||
@ -638,10 +642,6 @@
|
||||
RelativePath="..\..\..\..\src\libmpg123\synth.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\src\libmpg123\sample.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\src\libmpg123\synth_8bit.c"
|
||||
>
|
||||
|
@ -7,6 +7,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mpglib", "mpglib\mpglib.vcp
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "feedseek", "feedseek\feedseek.vcproj", "{472481BF-11B6-41A9-BF6A-8BE16A7F8FD6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scan", "scan\scan.vcproj", "{245C2785-2FA9-4A6B-8558-35BB8473AEA1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug_Generic|Win32 = Debug_Generic|Win32
|
||||
@ -67,6 +69,22 @@ Global
|
||||
{472481BF-11B6-41A9-BF6A-8BE16A7F8FD6}.Release_i486|Win32.Build.0 = Release|Win32
|
||||
{472481BF-11B6-41A9-BF6A-8BE16A7F8FD6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{472481BF-11B6-41A9-BF6A-8BE16A7F8FD6}.Release|Win32.Build.0 = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_Generic|Win32.ActiveCfg = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_Generic|Win32.Build.0 = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_i386|Win32.ActiveCfg = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_i386|Win32.Build.0 = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_i486|Win32.ActiveCfg = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug_i486|Win32.Build.0 = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_Generic|Win32.ActiveCfg = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_Generic|Win32.Build.0 = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_i386|Win32.ActiveCfg = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_i386|Win32.Build.0 = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_i486|Win32.ActiveCfg = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release_i486|Win32.Build.0 = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{245C2785-2FA9-4A6B-8558-35BB8473AEA1}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
195
ports/MSVC++/2008/scan/scan.vcproj
Normal file
195
ports/MSVC++/2008/scan/scan.vcproj
Normal file
@ -0,0 +1,195 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="scan"
|
||||
ProjectGUID="{245C2785-2FA9-4A6B-8558-35BB8473AEA1}"
|
||||
RootNamespace="scan"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../..;../../../../src/libmpg123"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="false"
|
||||
ExceptionHandling="0"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="1"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="../..;../../../../src/libmpg123"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="true"
|
||||
EnableEnhancedInstructionSet="1"
|
||||
FloatingPointModel="2"
|
||||
RuntimeTypeInfo="false"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="0"
|
||||
CompileAs="1"
|
||||
DisableSpecificWarnings="4996"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
<ProjectReference
|
||||
ReferencedProjectIdentifier="{67CAA87B-7CF1-4F93-BB67-21C513F40803}"
|
||||
RelativePathToProject=".\libmpg123\libmpg123.vcproj"
|
||||
/>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="..\..\..\..\doc\examples\scan.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
@ -25,6 +25,7 @@ extern "C" {
|
||||
// Wrapper around mpg123_open that supports path names with unicode
|
||||
// characters
|
||||
EXPORT int mpg123_topen(mpg123_handle *fr, const _TCHAR *path);
|
||||
EXPORT int mpg123_tclose(mpg123_handle *fr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -18,8 +18,15 @@
|
||||
|
||||
int mpg123_topen(mpg123_handle *fr, const _TCHAR *path)
|
||||
{
|
||||
int ret;
|
||||
int filept; /* descriptor of opened file/stream */
|
||||
|
||||
ret = mpg123_replace_reader(fr, _read, _lseek);
|
||||
if(ret != MPG123_OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
if((filept = _topen(path, O_RDONLY|O_BINARY)) < 0)
|
||||
{
|
||||
/* Will not work with unicode path name
|
||||
@ -31,13 +38,21 @@ int mpg123_topen(mpg123_handle *fr, const _TCHAR *path)
|
||||
}
|
||||
|
||||
if(mpg123_open_fd(fr, filept) == MPG123_OK) {
|
||||
/* Tell mpg123 that it is allowed to close the fd and be happy. */
|
||||
fr->rdat.flags |= READER_FD_OPENED;
|
||||
return MPG123_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
close(filept);
|
||||
_close(filept);
|
||||
return MPG123_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
int mpg123_tclose(mpg123_handle *fr)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = mpg123_close(fr);
|
||||
_close(fr->rdat.filept);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user