











If you want to use the method here, don't forget to adjust the commands accordingly so that it fits your sound card. You can find information via executing amixer -c CARD_ID.
So, I have to find a way to mute the sound output just before the audio stream is closed. The best way would be to find a simple command line audio player with the minimal number of code, since I don't want to view a huge codebase and potentially mess everything up. Fortunately, there's a program called ogg123, created by the awesome lads at Xiph.org Foundation1. This is a very basic audio player, which is desirable for this project.
After grabbing a copy of vorbis-tools (which contains ogg123), we can take a look. The main sound output codes are located at ogg123/audio.c. And surely, there is a function called void free_audio_devices. All we have to do should be add some codes to mute the output before the free process actually begins.
I can do it cleanly by using the user space library for ALSA, but that means I may have to investigate a good amount of hours into learning, and I'm kinda busy. So nah, I just hacked it.
Since we already know how to use amixer to mute the command, we can just use system() function (provided by stdlib.h) to execute a shell command. It is not expandable and flexible AT ALL, but it works and it does not kill my brain cells.
So, the free_audio_devices looks like this now:
|
|
Then we can trigger make and compile the patched code. Since I don't want to use this version globally, I did not install it.
Then the updated script should look like this:
|
|
Since now ogg123 is responsible to mute the output, we can save a line here.
And now it works! No more additional empty tracks, only accurate track data.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。