[C/C++] Encoding/decoding ALAC using Apple's codec (find problem in existing code)
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

The solution has been found, please don't start working on this if you just found it! See comments below for more info.

I have a feeling this is just a case of me missing something obvious, but I've spent way too many hours trying to figure out what so I'm hoping someone else can help me find the mistake.

I have a StackOverflow question on this already, so most of the explanation can be found there. However, I'll add some extra details below which should help you get the example up and running:

I've forked the official ALAC github repo, made it buildable with CMake, and added my example code which doesn't work, and it can be found here (in the branch "example_usage"). I've currently only had time trying to build it on Windows, so there might be something missing for it to run on Linux/OSX, but it's probably only missing a #define if that's the case.

So, what I want is to find what the problem is in this file, and if it's not too obvious, I'd like an explanation to why it didn't work. The decoding fails with error -50 when I try to decode the encoded buffer on line 123. I do want it to be solved for the current contents of pcm_buffer as well as any other arbitrary PCM data.

I will most likely accept the very first answer which manages to find the problem and contains an explanation (again, explanation only needed if it's not something obvious, which it probably is).

What exactly causes it to not work for you? When I initially ran your example, it seemed to work. It printed out "Encoding succeeded" I of course did not change anything yet. Line 123 did not seem to cause any problem. Possibly a windows/linux issue?
jduplessis294 over 3 years ago
Same here, I ran it on Linux and got Encoding succeeded (4438 bytes) Decoding succeeded (16384 bytes) as output.
gabrielsimoes over 3 years ago
Oh, damn, if that's the case then I guess the issue is to find out what's missing when compiling on Windows. Possibly some #define in libalac? I won't have time until tomorrow but there's actually sln/vcproj files in the original repo; could probably find what's missing by looking how it's configured.
aejt over 3 years ago
Okay, I couldn't sleep because I was thinking of what it could be, so I went up and found the problem myself. Since no solution has been posted yet, I'm not sure what the consensus is. Should we let it go to charity? If either of you are still working on this and you post the solution shortly, I'll of course let you have it since you put down time on it (and I wouldn't have been able to solve it this easily without your comments).
aejt over 3 years ago
Its totally up to you. I posted a dummy solution, if you feel I or gabrielsimoes deserves it, feel free to award it to one of us.
jduplessis294 over 3 years ago
Well, if you've both been working on it from when you read the post until now, it'd be wrong to not award it to one of you since I wouldn't have found it without your comments. Anyways, the problem was a #define, just like I thought. I'll decide what to do tomorrow, hopefully I can get some sleep now at least!
aejt over 3 years ago
I can't speak for who should get the bounty, but I will say that I started working on your problem and found out that issue 15 minutes after you posted it. Oh sorry! I know what its like to lose sleep on compiler issues!
jduplessis294 over 3 years ago
awarded to jduplessis294

Crowdsource coding tasks.

1 Solution

Winning solution

The problem was a windows/linux issue