can be of use later

This commit is contained in:
chudov
2009-01-15 23:16:12 +00:00
parent 1a25107348
commit dc9168dcf9
10 changed files with 818 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
#include "stdafx.h"
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::CompilerServices;
using namespace System::Runtime::InteropServices;
using namespace System::Security::Permissions;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly:AssemblyTitleAttribute("CUEToolsCodecsTTA")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("Microsoft")];
[assembly:AssemblyProductAttribute("CUEToolsCodecsTTA")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) Microsoft 2009")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the value or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly:AssemblyVersionAttribute("1.0.*")];
[assembly:ComVisible(false)];
[assembly:CLSCompliantAttribute(true)];
[assembly:SecurityPermission(SecurityAction::RequestMinimum, UnmanagedCode = true)];

View File

@@ -0,0 +1,232 @@
// This is the main DLL file.
#include "stdafx.h"
#include "CUETools.Codecs.TTA.h"
typedef void * HANDLE;
#include "../TTALib-1.1/TTAReader.h"
#include "../TTALib-1.1/TTAError.h"
namespace CUETools {
namespace Codecs {
namespace TTA {
static const char *TTAErrorsStr[] = {
"no errors found",
"not compatible file format",
"file is corrupted",
"file(s) not found",
"problem creating directory",
"can't open file",
"can't write to output file",
"can't read from input file",
"insufficient memory available",
"operation canceled"
};
public ref class TTAReader : public IAudioSource
{
public:
TTAReader(String^ path, Stream^ IO)
{
_tags = gcnew NameValueCollection();
_sampleOffset = 0;
_sampleBuffer = nullptr;
_path = path;
_bufferOffset = 0;
_bufferLength = 0;
_IO = (IO != nullptr) ? IO : gcnew FileStream (path, FileMode::Open, FileAccess::Read, FileShare::Read);
// skip ID3v2
if (_IO->ReadByte() == 'I' && _IO->ReadByte() == 'D' && _IO->ReadByte() == '3')
{
_IO->ReadByte();
_IO->ReadByte();
int flags = _IO->ReadByte();
int sz = _IO->ReadByte();
if (sz & 0x80)
throw gcnew Exception("Invalid ID3 tag.");
int offset = sz;
offset = (offset << 7) | (_IO->ReadByte() & 0x7f);
offset = (offset << 7) | (_IO->ReadByte() & 0x7f);
offset = (offset << 7) | (_IO->ReadByte() & 0x7f);
if (flags & (1 << 4))
offset += 10;
_IO->Position = 10 + offset;
} else
_IO->Position = 0;
try
{
_ttaReader = new TTALib::TTAReader((HANDLE)((FileStream^) _IO)->Handle);
} catch (TTALib::TTAException ex)
{
throw gcnew Exception(String::Format("TTA decoder: {0}", gcnew String(TTAErrorsStr[ex.GetErrNo()])));
}
if (WAVE_FORMAT_PCM != _ttaReader->ttahdr.AudioFormat)
throw gcnew Exception("floating point format not supported.");
_channelCount = _ttaReader->ttahdr.NumChannels;
_bitsPerSample = _ttaReader->ttahdr.BitsPerSample;
_sampleRate = _ttaReader->ttahdr.SampleRate;
_sampleCount = _ttaReader->ttahdr.DataLength;
}
~TTAReader ()
{
Close ();
}
virtual property Int32 BitsPerSample {
Int32 get() {
return _bitsPerSample;
}
}
virtual property Int32 ChannelCount {
Int32 get() {
return _channelCount;
}
}
virtual property Int32 SampleRate {
Int32 get() {
return _sampleRate;
}
}
virtual property UInt64 Length {
UInt64 get() {
return _sampleCount;
}
}
virtual property UInt64 Position {
UInt64 get()
{
return _sampleOffset - SamplesInBuffer;
}
void set(UInt64 offset)
{
_sampleOffset = offset;
_bufferOffset = 0;
_bufferLength = 0;
throw gcnew Exception("Unable to seek.");
}
}
virtual property String^ Path {
String^ get() {
return _path;
}
}
virtual property NameValueCollection^ Tags {
NameValueCollection^ get () {
return _tags;
}
void set (NameValueCollection ^tags) {
_tags = tags;
}
}
virtual bool UpdateTags (bool preserveTime)
{
return false;
}
virtual property UInt64 Remaining {
UInt64 get() {
return _sampleCount - _sampleOffset + SamplesInBuffer;
}
}
virtual void Close() {
if (_ttaReader)
{
delete _ttaReader;
_ttaReader = nullptr;
}
if (_IO != nullptr)
{
_IO->Close ();
_IO = nullptr;
}
}
virtual array<Int32, 2>^ Read(array<Int32, 2>^ buff)
{
return AudioSamples::Read(this, buff);
}
void processBlock (long * buffer, int sampleCount)
{
if (_bufferLength > 0)
throw gcnew Exception("Received unrequested samples.");
if ((_sampleBuffer == nullptr) || (_sampleBuffer->GetLength(0) < sampleCount))
_sampleBuffer = gcnew array<Int32, 2>(sampleCount, _channelCount);
interior_ptr<Int32> pMyBuffer = &_sampleBuffer[0, 0];
const long *pTTABuffer = buffer;
const long *pTTABufferEnd = pTTABuffer + sampleCount * _channelCount;
while (pTTABuffer < pTTABufferEnd)
*(pMyBuffer++) = *(pTTABuffer++);
_bufferLength = sampleCount;
}
virtual UInt32 Read([Out] array<Int32, 2>^ buff, UInt32 sampleCount)
{
UInt32 buffOffset = 0;
UInt32 samplesNeeded = sampleCount;
while (samplesNeeded != 0)
{
if (SamplesInBuffer == 0)
{
_bufferOffset = 0;
_bufferLength = 0;
do
{
long * buf;
int samplesInBuf = _ttaReader->GetBlock(&buf);
if (samplesInBuf == 0)
throw gcnew Exception("An error occurred while decoding.");
processBlock (buf, samplesInBuf);
} while (_bufferLength == 0);
_sampleOffset += _bufferLength;
}
UInt32 copyCount = Math::Min(samplesNeeded, SamplesInBuffer);
Array::Copy(_sampleBuffer, _bufferOffset * _channelCount, buff, buffOffset * _channelCount, copyCount * _channelCount);
samplesNeeded -= copyCount;
buffOffset += copyCount;
_bufferOffset += copyCount;
}
return sampleCount;
}
private:
Int64 _sampleCount, _sampleOffset;
Int32 _bitsPerSample, _channelCount, _sampleRate;
array<Int32, 2>^ _sampleBuffer;
array<unsigned char>^ _readBuffer;
NameValueCollection^ _tags;
String^ _path;
Stream^ _IO;
UInt32 _bufferOffset, _bufferLength;
TTALib::TTAReader * _ttaReader;
property UInt32 SamplesInBuffer {
UInt32 get ()
{
return (UInt32) (_bufferLength - _bufferOffset);
}
}
};
}
}
}

View File

@@ -0,0 +1,11 @@
// CUETools.Codecs.TTA.h
#pragma once
using namespace System;
using namespace System::Text;
using namespace System::IO;
using namespace System::Collections::Generic;
using namespace System::Collections::Specialized;
using namespace System::Runtime::InteropServices;
using namespace CUETools::Codecs;

View File

@@ -0,0 +1,426 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="CUETools.Codecs.TTA"
ProjectGUID="{1D1E99BC-6D22-41C0-BD94-FF4DD5EC725B}"
RootNamespace="CUEToolsCodecsTTA"
Keyword="ManagedCProj"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)..\bin\$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)..\obj\$(ProjectName)\$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="2"
GenerateDebugInformation="true"
AssemblyDebug="1"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
ManagedExtensions="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="$(NoInherit)"
LinkIncremental="1"
GenerateDebugInformation="true"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
/>
<ProjectReference
ReferencedProjectIdentifier="{6458A13A-30EF-45A9-9D58-E5031B17BEE2}"
RelativePathToProject="..\CUETools.Codecs\CUETools.Codecs.csproj"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\AssemblyInfo.cpp"
>
</File>
<File
RelativePath=".\CUETools.Codecs.TTA.cpp"
>
</File>
<File
RelativePath=".\Stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\CUETools.Codecs.TTA.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\Stdafx.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
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=".\app.ico"
>
</File>
<File
RelativePath=".\app.rc"
>
</File>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,31 @@
========================================================================
DYNAMIC LINK LIBRARY : CUETools.Codecs.TTA Project Overview
========================================================================
AppWizard has created this CUETools.Codecs.TTA DLL for you.
This file contains a summary of what you will find in each of the files that
make up your CUETools.Codecs.TTA application.
CUETools.Codecs.TTA.vcproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
CUETools.Codecs.TTA.cpp
This is the main DLL source file.
CUETools.Codecs.TTA.h
This file contains a class declaration.
AssemblyInfo.cpp
Contains custom attributes for modifying assembly metadata.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// CUETools.Codecs.TTA.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

View File

@@ -0,0 +1,7 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once

BIN
CUETools.Codecs.TTA/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,63 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon placed first or with lowest ID value becomes application icon
LANGUAGE 25, 1
#pragma code_page(1251)
1 ICON "app.ico"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
"\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@@ -0,0 +1,3 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by app.rc