From 05ce5e9f2b625a022204285e5d03508c52b48b5f Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 13 Nov 2024 13:33:29 -0500 Subject: [PATCH 1/4] Ensure WAV file header is cross-platform consistent --- ldac_dec_test.c | 8 ++++---- ldac_enc_test.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ldac_dec_test.c b/ldac_dec_test.c index a0c9a4a..132d20e 100644 --- a/ldac_dec_test.c +++ b/ldac_dec_test.c @@ -103,7 +103,7 @@ typedef char ID[4]; typedef union { struct { ID groupID; - long size; + uint32_t size; ID riffType; }; uint8_t data[0xc]; @@ -112,8 +112,8 @@ typedef union { typedef union { struct { ID chunkID; - long chunkSize; - short wFormatTag; + uint32_t chunkSize; + uint16_t wFormatTag; uint16_t wChannels; uint32_t dwSamplesPerSec; uint32_t dwAvgBytesPerSec; @@ -127,7 +127,7 @@ typedef union { typedef union { struct { ID chunkID; - long chunkSize; + uint32_t chunkSize; }; uint8_t data[8]; } DATACHUNK; diff --git a/ldac_enc_test.c b/ldac_enc_test.c index df6ef78..6f5a7cb 100644 --- a/ldac_enc_test.c +++ b/ldac_enc_test.c @@ -103,7 +103,7 @@ typedef char ID[4]; typedef union { struct { ID groupID; - long size; + uint32_t size; ID riffType; }; uint8_t data[0xc]; @@ -112,8 +112,8 @@ typedef union { typedef union { struct { ID chunkID; - long chunkSize; - short wFormatTag; + uint32_t chunkSize; + uint16_t wFormatTag; uint16_t wChannels; uint32_t dwSamplesPerSec; uint32_t dwAvgBytesPerSec; @@ -126,7 +126,7 @@ typedef union { typedef union { struct { ID chunkID; - long chunkSize; + uint32_t chunkSize; }; uint8_t data[8]; } DATACHUNK; From 86d55b0a6622c0da4d8a35b6fe1119807ab4b913 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 13 Nov 2024 13:34:01 -0500 Subject: [PATCH 2/4] Fix compile on non-WIN32 platforms --- ldac_dec_test.c | 4 +++- ldac_enc_test.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ldac_dec_test.c b/ldac_dec_test.c index 132d20e..5ca39af 100644 --- a/ldac_dec_test.c +++ b/ldac_dec_test.c @@ -254,9 +254,9 @@ int main(int argc, char *argv[]) { #if __WIN32 unsigned __int64 t0 = *( unsigned __int64 *)(0x7FFE0000 + 0x8); // like QueryUnbiasedInterruptTime + __int64 npack = 0; #endif - __int64 npack = 0; while ((streamSize - used_Stream_count) > streamUsed) { @@ -265,7 +265,9 @@ int main(int argc, char *argv[]) { frame_size, &streamUsed, &out_pcm_szie); out_pcm_count += out_pcm_szie; used_Stream_count += streamUsed; +#if __WIN32 npack += 1; +#endif } if (result != 0) { printf("%s\r\n",get_error_code_string(ldacBT_get_error_code(ldacBT_dec_handle))); diff --git a/ldac_enc_test.c b/ldac_enc_test.c index 6f5a7cb..a189cb6 100644 --- a/ldac_enc_test.c +++ b/ldac_enc_test.c @@ -255,15 +255,17 @@ int main(int argc, char *argv[]) { #if __WIN32 unsigned __int64 t0 = *( unsigned __int64 *)(0x7FFE0000 + 0x8); // like QueryUnbiasedInterruptTime -#endif __int64 npack = 0; +#endif while ((input_pcm_size - pcmUsedcount) >= pcmUsed) { result |= ldacBT_encode(ldacBT_enc_handle, input_pcm + pcmUsedcount, &pcmUsed, pStream + streamoutputcount, &streamSize, &frameNum); pcmUsedcount += pcmUsed; streamoutputcount += streamSize; +#if __WIN32 npack += 1; +#endif } // ldacBT_encode(ldacBT_enc_handle, input_pcm + 44 + pcmUsed, &pcmUsed, // pStream, &streamSize, &frameNum); From 333f16cc9d88beb1118e7e34d78e1c2a7a8ce5d2 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 13 Nov 2024 13:34:15 -0500 Subject: [PATCH 3/4] Add missing header for linux compile --- auto_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/auto_test.c b/auto_test.c index fc41a09..8da52fa 100644 --- a/auto_test.c +++ b/auto_test.c @@ -2,6 +2,10 @@ #include #include #include +#ifdef __linux__ +#include +#endif + int main() { From ee76d338c0eee2787707824433fbfe9578440da5 Mon Sep 17 00:00:00 2001 From: Chris Johnson Date: Wed, 13 Nov 2024 13:39:53 -0500 Subject: [PATCH 4/4] Fix linker error on Linux --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5273bf..b77b23d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ add_library( ${enc_dic}/ldaclib.c ) +target_link_libraries(ldac_enc_lib m) add_executable(ldac_encoder ldac_enc_test.c) add_executable(ldac_decoder ldac_dec_test.c) @@ -57,5 +58,5 @@ add_executable(auto_test auto_test.c) target_link_libraries(ldac_encoder ldac_enc_lib) -target_link_libraries(ldac_decoder ldac_dec_lib) +target_link_libraries(ldac_decoder ldac_dec_lib m) endif()