Help - Search - Members - Calendar
Full Version: Problem using TAK SDK v1.0.6
Hydrogenaudio Forums > Lossless Audio Compression > Lossless / Other Codecs
shaohao
Hi, TBeck:
The new TAK SDK v1.0.6 is still error, I cannot make my code work with the latest version.
I've posted this bug on v1.0.2 here:
http://www.hydrogenaudio.org/forums/index....st&p=528513
But you have not fixed it. The decoder exit decoding loop immediately after decoding only one frame.

And

you forgot the code for C header file:
CODE

#ifndef _TAK_DECO_LIB
#define _TAK_DECO_LIB
...
#endif


Please, Please fix it. I want to use your TAK in my player:(
TBeck
QUOTE(shaohao @ Mar 19 2008, 16:08) *

Hi, TBeck:
The new TAK SDK v1.0.6 is still error, I cannot make my code work with the latest version.
I've posted this bug on v1.0.2 here:
http://www.hydrogenaudio.org/forums/index....st&p=528513
But you have not fixed it. The decoder exit decoding loop immediately after decoding only one frame.

I don't know what to fix...

The TAK applications and the decoding library are using exactly the same code. The decoding library only adds a simple layer to wrap Delphi's object methods to function calls. There have been no reports of any problems when decoding with the applications (compatibility issues with piping are irrelevant in this context).

The decoding library is also beeing used by fossion's foobar plugin and it's working perfectly.

I am quite sure, your code is doing something wrong.

Have you checked what i have asked you for?
QUOTE

You don't check the success of _tfopen() before using the file with TAK. Possibly _tfopen() already fails...

What error code is the library returning?

QUOTE(shaohao @ Mar 19 2008, 16:08) *

you forgot the code for C header file:
CODE

#ifndef _TAK_DECO_LIB
#define _TAK_DECO_LIB
...
#endif


Yes, that's true...
shaohao
QUOTE(TBeck @ Mar 20 2008, 13:59) *

Have you checked what i have asked you for?
QUOTE

You don't check the success of _tfopen() before using the file with TAK. Possibly _tfopen() already fails...


Yes, I have checked the file handle returned by _tfopen. It is OK.

QUOTE

What error code is the library returning?

I create a new sample C project and ues your C example in TAK's SDK manual. It still report errors on decoding.

The error code is 2048--InvalidParameter.
I'm use Visual Studio 2005 SP1 under WinXP SP2 (32bit) with AMD64 5000+ cpu.
TBeck
QUOTE(shaohao @ Mar 20 2008, 19:47) *

The error code is 2048--InvalidParameter.
I'm use Visual Studio 2005 SP1 under WinXP SP2 (32bit) with AMD64 5000+ cpu.

tak_SSD_ReadAudio will return tak_res_InvalidParameter, if one of the following conditions is met:

1) ADecoder, ASamples or AReadNum is NULL.

2) A preceding call of a decoder function has already caused a fatal error.

You could try the following:

1) Before entering the read loop call tak_SSD_Valid and check if the result is tak_True. Otherwises an earlier function call has failed. Then you should identify the first function call that failed.

2) If tak_SSD_Valid returns tak_True, use the debugger to check the parameters you are passing to tak_SSD_ReadAudio.

shaohao
QUOTE(TBeck @ Mar 21 2008, 03:52) *

QUOTE(shaohao @ Mar 20 2008, 19:47) *

The error code is 2048--InvalidParameter.
I'm use Visual Studio 2005 SP1 under WinXP SP2 (32bit) with AMD64 5000+ cpu.

tak_SSD_ReadAudio will return tak_res_InvalidParameter, if one of the following conditions is met:

1) ADecoder, ASamples or AReadNum is NULL.

2) A preceding call of a decoder function has already caused a fatal error.

You could try the following:

1) Before entering the read loop call tak_SSD_Valid and check if the result is tak_True. Otherwises an earlier function call has failed. Then you should identify the first function call that failed.

2) If tak_SSD_Valid returns tak_True, use the debugger to check the parameters you are passing to tak_SSD_ReadAudio.


THX for you Help TBeck.
BUT, my plug-in still did not work sad.gif

I compiled my plug-in in "Debug" version with VC8. The player crashed and gave me a exception warning messagbox when the plug-in invoked the "tak_SSD_ReadAudio" at the third time.
Then, I tried to compile my plug-in in "Release" version with VC8.
The invoked APIs were "tak_SSD_Create_FromStream"->"tak_SSD_Valid"->"tak_SSD_GetStreamInfo"->return ERROR. I have tryied to use "tak_SSD_GetErrorString" to catch the error string and the result was "Unknown error".

BTW: Everything played well with your tak_dec_lib.dll v1.0.4, but failed after I updated to v1.0.7.

Is it possible for you to rewrite you code in C/C++?
TBeck
QUOTE(shaohao @ Mar 21 2008, 15:06) *

Then, I tried to compile my plug-in in "Release" version with VC8.
The invoked APIs were "tak_SSD_Create_FromStream"->"tak_SSD_Valid"->"tak_SSD_GetStreamInfo"->return ERROR. I have tryied to use "tak_SSD_GetErrorString" to catch the error string and the result was "Unknown error".

We have to identify the first API call that returns an error. Which one is it?

QUOTE(shaohao @ Mar 21 2008, 15:06) *

Is it possible for you to rewrite you code in C/C++?

I can't see how this would help with your problem. The interface of the dll would be the same (procedural). The internal implementation of the dll shouldn't matter.
shaohao
QUOTE(TBeck @ Mar 21 2008, 16:44) *

We have to identify the first API call that returns an error. Which one is it?

I just catch the first API call that returns an error -- "tak_SSD_Create_FromStream"
But this error only raised in "Release" version.
If I compile my code in "Debug" version, no such error would raise.
TBeck
QUOTE(shaohao @ Mar 21 2008, 18:10) *

QUOTE(TBeck @ Mar 21 2008, 16:44) *

We have to identify the first API call that returns an error. Which one is it?

I just catch the first API call that returns an error -- "tak_SSD_Create_FromStream"
But this error only raised in "Release" version.
If I compile my code in "Debug" version, no such error would raise.

I have to know exactly what happens:

Case 1) You check the return value of tak_SSD_Create_FromStream. If it is NULL, no decoder object could be created and you can't use the return value as decoder parameter in subsequent API calls!

Case 2) The return value of tak_SSD_Create_FromStream is not NULL. Nevertheless an error can have occured. You check this by calling tak_SSD_Valid.

Case 3) You are talking about exceptions raised by C.
shaohao
QUOTE(TBeck @ Mar 21 2008, 17:18) *

I have to know exactly what happens:

Case 1) You check the return value of tak_SSD_Create_FromStream. If it is NULL, no decoder object could be created and you can't use the return value as decoder parameter in subsequent API calls!

Case 2) The return value of tak_SSD_Create_FromStream is not NULL. Nevertheless an error can have occured. You check this by calling tak_SSD_Valid.

Case 3) You are talking about exceptions raised by C.


1) The return value of "tak_SSD_Create_FromSteam" is not NULL.
2) tak_SSD_Valid told me it was an "Unknown ERROR"
3) Here is a piece of my code:
CODE

BOOL ret = FALSE;
TtakResult rst;

if ( NULL == ssd) {
    MessageBoxA( NULL, "It is NULL", "ERROR", 0);
    return ret;
} else {
    if ( tak_True != tak_SSD_Valid( ssd)) {
        char msg[tak_ErrorStringSizeMax];
        tak_SSD_GetErrorString( rst, msg, tak_ErrorStringSizeMax);
        strcat( msg, "\nCreate!!!");
        MessageBoxA( NULL, msg, "ERROR", 0);
        return ret;
    }
    if ( tak_res_Ok != (rst = tak_SSD_GetStreamInfo( ssd, &si))) {
        char msg[tak_ErrorStringSizeMax];
        tak_SSD_GetErrorString( rst, msg, tak_ErrorStringSizeMax);
        strcat( msg, "\nGetStreamInfo");
        MessageBoxA( NULL, msg, "ERROR", 0);
        return ret;
    }
}

What we are talking about is the "Release" Version. I caught the error "Unknown Error\nCreate!!!" by using MessageBox.
But there is no such error in "Debug" version, my plug-in just raised an exception directly, and popupped a system dialog asking me to do debugging. sad.gif
TBeck
QUOTE(shaohao @ Mar 21 2008, 19:28) *

2) tak_SSD_Valid told me it was an "Unknown ERROR"

tak_SSD_Valid will only return tak_True / tak_False but no specific error code. If it returns tak_False, you have to call tak_SSD_State to get the error code. In your code i can't see something like:

CODE

rst = tak_SSD_State (ssd);


shaohao
QUOTE(TBeck @ Mar 21 2008, 18:56) *

tak_SSD_Valid will only return tak_True / tak_False but no specific error code. If it returns tak_False, you have to call tak_SSD_State to get the error code. In your code i can't see something like:

CODE

rst = tak_SSD_State (ssd);


THX TBeck, I just caught the bug: my "CanSeek" callback return "FALSE". I have fixed it:)

But, how to solve the raised "Exception"?
I got an exception warning at the 3nd time of invoking "tak_SSD_ReadAudio" sad.gif
twistedddx
I have TAK using tak_SSD_Create_FromFile working fine in c++ with visual studio 2008. Although I do have an issue with seeking..

What am I missing with the code below(when MS is the time in milliseconds we want to seek to):
tak_SSD_Seek(Decoder, (*MS / 1000) * StreamInfo.Audio.SampleRate);
TBeck
QUOTE(twistedddx @ Apr 3 2008, 13:17) *

I have TAK using tak_SSD_Create_FromFile working fine in c++ with visual studio 2008. Although I do have an issue with seeking..

What am I missing with the code below(when MS is the time in milliseconds we want to seek to):
tak_SSD_Seek(Decoder, (*MS / 1000) * StreamInfo.Audio.SampleRate);

What issue do you have?

For now i have to ask my crystal ball. Things to care for:

1) The Result of your expression must not exceed file size in samples - 1.
2) I am not sure, how your compiler will evaluate this expression. If it calculates MS / 1000 as integers, you will only get a temporal resolution of multiples of seconds.

Thomas


twistedddx
It is calculated as an unsigned long(which did end up rounding a fair bit)

So now I will work it out as (*MS * StreamInfo.Audio.SampleRate)/1000 which ofcourse will have less/no rounding unless we overflow an unsigned long.

Anyways:

The error is that the entire decoder bombs out on the next read. (OpResult != tak_res_Ok) tak_res_Ok is 0.
And the tak_SSD_GetErrorString is invalid mode.

As a heads up there was no Options.Flags set(at all only Options.Cpu = tak_Cpu_Any). Which seems to have set tak_ssd_opt_SequentialRead.

My fix just now was to do:
Options.Flags = NULL;

I assumed setting no flags would not have defaulted to using flags?

TBeck
QUOTE(twistedddx @ Apr 3 2008, 14:42) *

As a heads up there was no Options.Flags set(at all only Options.Cpu = tak_Cpu_Any). Which seems to have set tak_ssd_opt_SequentialRead.

My fix just now was to do:
Options.Flags = NULL;

I assumed setting no flags would not have defaulted to using flags?

If you don't initialize the Options structure, it can contain arbitrary values, can't it?
foosion
I just released the source code for foo_input_tak on my components page. It uses the BSD license, so if you want to look at a working example for using tak_deco_lib in C++ you are welcome to check it out. It also comes with a smart pointer class for the TAK SSD, optionally with a convenience wrapper that extends the seekable range to include the end-of-stream position, so every position that can be reached by decoding the stream can also be the target of a seek operation.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.