-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Samples count is always zero in write callback for Ogg FLAC #661
Comments
I got no reaction to this for eight months, so I took a look at it myself now. The problem isn’t difficult to find, indeed it’s stated in a comment in on line 195 of
This is exactly the problem: just passing zero is not what we should do according to the documentation. What to do about it is less obvious, unfortunately. The way I understand it, I’m submitting a pull request with this change, including a corresponding documentation correction+update for |
The documentation of
FLAC__StreamEncoderWriteCallback
says “Unlike when writing to native FLAC, when writing to Ogg FLAC the write callback will be called twice when writing each audio frame; once for the page header, and once for the page body. When writing the page header, the samples argument to the write callback will be 0.” Unfortunately, it appears that the samples argument is always 0 with Ogg FLAC.The code below demonstrates the problem, encoding a buffer of 100 zero samples with native and Ogg FLAC. It prints (where both should be 100):
I tested it with the same results with FLAC 1.4.3 installed via Homebrew in macOS, and with 1.3.3 on Ubuntu (1.3.3-2ubuntu0.2, the version that standard package management on Ubuntu 22.04.3 LTS supplies for package libflac-dev).
This breaks the use of Ogg FLAC in my application, since I need to determine the number of samples actually output in order not to flood the recipient of the stream. (The number of output samples is sometimes much smaller than the number of processed samples for highly compressible audio.)
The text was updated successfully, but these errors were encountered: