-
Notifications
You must be signed in to change notification settings - Fork 285
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
Don't just pass 0 for samples in Ogg/FLAC callback #731
Conversation
I see a problem here when very small frames are generated by libFLAC, for example on silence. In that case the write callback isn't called at all, the frame is kept in memory. It seems fixable though. I suggest adding a variable to the FLAC__OggEncoderAspect struct (defined in ogg_encoder_aspect.h) and then doing the following (I haven't tested this, I assume you have a good way to test this as you actually use this code)
If you have a better name for the new variable, feel free to change it. Thanks for looking into this, I couldn't find the time to work on this. |
@ktmf01 Yes, I see how that could be a potential problem, and your suggestion should work (assuming that you meant to replace pass_samples with aspect->samples_in_submit_buffer for the write_callback parameter as well), although handling the case of encoding silence is precisely my reason for looking at the samples parameter in the write callback (I wrote a blog post about it), and it didn’t happen in that case. I have committed a change based on your suggestion. It works fine in my context. Please tell me if there’s something more I should do – some specific test or something. |
Ok. Still, as libogg is an external component we should follow the described behaviour (which is that it is possible a packet is held back) in this case, and not rely on observed behaviour.
I think it is fine. I will take another look at it next week and merge it if I don't think of anything else that needs improvement. Once again, thanks for picking this up. |
I noticed another thing when making the change: However, when looking into this I also realized that if I understand correctly, the |
I just read your blog entry, are you familiar with the 'limit minimum bitrate' function? See https://www.xiph.org/flac/api/group__flac__stream__encoder.html#gac8c5f361b441d528b7a6791b66bb9d40 I'll review your change next week |
Thanks, yes I had failed to noticed the FLAC__stream_encoder_set_limit_min_bitrate function. I don’t currently seem to need it, but I’ll think about incorporating it. |
I'm not sure that last commit is necessary: metadata is always written first and samples last, but I don't think it can hurt. |
In any case, I think the last commit makes the execution more logical and reduces coupling with the calling order. So are you going to merge it? |
Yes, I'd like to merge it, with "squash and merge". However, I just noticed that the email address you used for your commits is not the same as the address you use for github. Does it matter to you under which email address the commit is credited? |
No big deal, but the one I use for commits is my general “repository address” also outside of github, and more likely to remain “forever” than the alias I created for the github account. I’ve used the commit address on the libFLAC mailing list also, BTW, |
This is a fix for #661
Sorry if I’m confused, but is the change supposed to be merged to master on this repo now? It doesn’t seem to be. Maybe I made a mistake when I created the PR: I was confused about what was left vs right in the Github web interface and may have switched the branches around. |
The problem is, I prefer to have commits in a PR squashed if there is some back-and-forth or when there are fixups. Usually I just press 'squash and merge' to get the whole PR into one commit, but in that case github takes the github email address for the commit, and not the email address in the commits themselves. So, yesterday, I squashed your commits by hand, and let the checks run again. Not because it is necessary, but because I prefer it that way. I just merged that squashed commit with 'rebase and merge'. |
Ok, great, I like squashing too. It was unclear to me that this was what was happening in the Github interface. (The more I learn to love Git, the less I tend to like Github.) |
Yeah, I agree that github feels a little crude if you are familiar with the finer points of git, like |
This is a fix for issue #661 where I motivated it in a comment, but the comments in the code are actually probably enough to explain it.