mirror of
https://github.com/claunia/cuetools.net.git
synced 2025-12-16 18:14:25 +00:00
All audio formats can now be read from a .rar archive.
Cleaned up .APE library of outdated code.
This commit is contained in:
@@ -45,32 +45,32 @@ namespace WavPackDotNet {
|
||||
int write_block(void *id, void *data, int32_t length);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int32_t DecoderReadDelegate(void *id, void *data, int32_t bcount);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate uint32_t DecoderTellDelegate(void *id);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderSeekDelegate(void *id, uint32_t pos);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderSeekRelativeDelegate(void *id, int32_t delta, int mode);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderPushBackDelegate(void *id, int c);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate uint32_t DecoderLengthDelegate(void *id);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderCanSeekDelegate(void *id);
|
||||
public delegate int32_t DecoderReadDelegate(void *id, void *data, int32_t bcount);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate uint32_t DecoderTellDelegate(void *id);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderSeekDelegate(void *id, uint32_t pos);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderSeekRelativeDelegate(void *id, int32_t delta, int mode);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderPushBackDelegate(void *id, int c);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate uint32_t DecoderLengthDelegate(void *id);
|
||||
[UnmanagedFunctionPointer(CallingConvention::Cdecl)]
|
||||
public delegate int DecoderCanSeekDelegate(void *id);
|
||||
|
||||
public ref class WavPackReader {
|
||||
public:
|
||||
WavPackReader(String^ path, Stream^ IO, Stream^ IO_WVC) {
|
||||
char errorMessage[256];
|
||||
|
||||
_readDel = gcnew DecoderReadDelegate (this, &WavPackReader::ReadCallback);
|
||||
_tellDel = gcnew DecoderTellDelegate (this, &WavPackReader::TellCallback);
|
||||
_seekDel = gcnew DecoderSeekDelegate (this, &WavPackReader::SeekCallback);
|
||||
_seekRelDel = gcnew DecoderSeekRelativeDelegate (this, &WavPackReader::SeekRelCallback);
|
||||
_pushBackDel = gcnew DecoderPushBackDelegate (this, &WavPackReader::PushBackCallback);
|
||||
_lengthDel = gcnew DecoderLengthDelegate (this, &WavPackReader::LengthCallback);
|
||||
_canSeekDel = gcnew DecoderCanSeekDelegate (this, &WavPackReader::CanSeekCallback);
|
||||
_readDel = gcnew DecoderReadDelegate (this, &WavPackReader::ReadCallback);
|
||||
_tellDel = gcnew DecoderTellDelegate (this, &WavPackReader::TellCallback);
|
||||
_seekDel = gcnew DecoderSeekDelegate (this, &WavPackReader::SeekCallback);
|
||||
_seekRelDel = gcnew DecoderSeekRelativeDelegate (this, &WavPackReader::SeekRelCallback);
|
||||
_pushBackDel = gcnew DecoderPushBackDelegate (this, &WavPackReader::PushBackCallback);
|
||||
_lengthDel = gcnew DecoderLengthDelegate (this, &WavPackReader::LengthCallback);
|
||||
_canSeekDel = gcnew DecoderCanSeekDelegate (this, &WavPackReader::CanSeekCallback);
|
||||
|
||||
ioReader = new WavpackStreamReader;
|
||||
ioReader->read_bytes = (int32_t (*)(void *, void *, int32_t)) Marshal::GetFunctionPointerForDelegate(_readDel).ToPointer();
|
||||
@@ -212,18 +212,18 @@ namespace WavPackDotNet {
|
||||
String^ _path;
|
||||
Stream^ _IO;
|
||||
Stream^ _IO_WVC;
|
||||
DecoderReadDelegate^ _readDel;
|
||||
DecoderTellDelegate^ _tellDel;
|
||||
DecoderSeekDelegate^ _seekDel;
|
||||
DecoderSeekRelativeDelegate^ _seekRelDel;
|
||||
DecoderPushBackDelegate^ _pushBackDel;
|
||||
DecoderLengthDelegate^ _lengthDel;
|
||||
DecoderCanSeekDelegate^ _canSeekDel;
|
||||
array<unsigned char>^ _readBuffer;
|
||||
int _IO_ungetc, _IO_WVC_ungetc;
|
||||
WavpackStreamReader* ioReader;
|
||||
|
||||
int32_t ReadCallback (void *id, void *data, int32_t bcount)
|
||||
DecoderReadDelegate^ _readDel;
|
||||
DecoderTellDelegate^ _tellDel;
|
||||
DecoderSeekDelegate^ _seekDel;
|
||||
DecoderSeekRelativeDelegate^ _seekRelDel;
|
||||
DecoderPushBackDelegate^ _pushBackDel;
|
||||
DecoderLengthDelegate^ _lengthDel;
|
||||
DecoderCanSeekDelegate^ _canSeekDel;
|
||||
array<unsigned char>^ _readBuffer;
|
||||
int _IO_ungetc, _IO_WVC_ungetc;
|
||||
WavpackStreamReader* ioReader;
|
||||
|
||||
int32_t ReadCallback (void *id, void *data, int32_t bcount)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
int IO_ungetc = (*(char*)id=='c') ? _IO_WVC_ungetc : _IO_ungetc;
|
||||
@@ -256,15 +256,15 @@ namespace WavPackDotNet {
|
||||
return IO->Position;
|
||||
}
|
||||
|
||||
int SeekCallback (void *id, uint32_t pos)
|
||||
{
|
||||
int SeekCallback (void *id, uint32_t pos)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
IO->Position = pos;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SeekRelCallback (void *id, int32_t delta, int mode)
|
||||
{
|
||||
IO->Position = pos;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SeekRelCallback (void *id, int32_t delta, int mode)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
switch (mode)
|
||||
{
|
||||
@@ -279,37 +279,37 @@ namespace WavPackDotNet {
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PushBackCallback (void *id, int c)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
if (IO == _IO)
|
||||
{
|
||||
if (_IO_ungetc != -1)
|
||||
throw gcnew Exception("Double PushBackCallback unsupported.");
|
||||
_IO_ungetc = c;
|
||||
} else
|
||||
{
|
||||
if (_IO_WVC_ungetc != -1)
|
||||
throw gcnew Exception("Double PushBackCallback unsupported.");
|
||||
_IO_WVC_ungetc = c;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t LengthCallback (void *id)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
return IO->Length;
|
||||
}
|
||||
|
||||
int CanSeekCallback(void *id)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
return IO->CanSeek;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PushBackCallback (void *id, int c)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
if (IO == _IO)
|
||||
{
|
||||
if (_IO_ungetc != -1)
|
||||
throw gcnew Exception("Double PushBackCallback unsupported.");
|
||||
_IO_ungetc = c;
|
||||
} else
|
||||
{
|
||||
if (_IO_WVC_ungetc != -1)
|
||||
throw gcnew Exception("Double PushBackCallback unsupported.");
|
||||
_IO_WVC_ungetc = c;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t LengthCallback (void *id)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
return IO->Length;
|
||||
}
|
||||
|
||||
int CanSeekCallback(void *id)
|
||||
{
|
||||
Stream^ IO = (*(char*)id=='c') ? _IO_WVC : _IO;
|
||||
return IO->CanSeek;
|
||||
}
|
||||
};
|
||||
|
||||
public ref class WavPackWriter {
|
||||
@@ -498,4 +498,4 @@ namespace WavPackDotNet {
|
||||
int write_block(void *id, void *data, int32_t length) {
|
||||
return (fwrite(data, 1, length, (FILE*)id) == length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user