Fix WAV call recording/playback, ALSA call audio routing, and tracker ringtones
This commit is contained in:
1 parent
b706865ee8
commit
f4fe5ce8e9
21 files changed
+339
-33
No files matched your search
@@ -275,6 +275,7 @@ void applySystemSpeakerVol(int pct) {
|
||||
int rx3 = (pct <= 0) ? 0 : (54 + (pct * 38) / 100);
|
||||
runAsyncCmd("amixer -c 0 cset \"name='SPK DAC Switch'\" " +
|
||||
std::string(pct > 0 ? "1" : "0") + " >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='RX3 Digital Volume'\" " +
|
||||
std::to_string(rx3) + " >/dev/null 2>&1; "
|
||||
"wpctl set-mute @DEFAULT_AUDIO_SINK@ " +
|
||||
@@ -433,7 +434,12 @@ int runMusicApp(int argc, char** argv) {
|
||||
ipcReadBuf.clear();
|
||||
if (mpvPid > 0) {
|
||||
::kill(mpvPid, SIGTERM);
|
||||
::waitpid(mpvPid, nullptr, WNOHANG);
|
||||
for (int i = 0; i < 15; ++i) {
|
||||
if (::waitpid(mpvPid, nullptr, WNOHANG) == mpvPid) {
|
||||
break;
|
||||
}
|
||||
usleep(10000);
|
||||
}
|
||||
mpvPid = -1;
|
||||
}
|
||||
::unlink(kMpvSockPath);
|
||||
@@ -456,6 +462,12 @@ int runMusicApp(int argc, char** argv) {
|
||||
pid_t pid = ::fork();
|
||||
if (pid == 0) {
|
||||
::setsid();
|
||||
std::string runtimeDir = "/run/user/" + std::to_string(::getuid());
|
||||
const char* xdg = std::getenv("XDG_RUNTIME_DIR");
|
||||
struct stat stRuntime {};
|
||||
if (!xdg || !*xdg || ::stat(xdg, &stRuntime) != 0) {
|
||||
::setenv("XDG_RUNTIME_DIR", runtimeDir.c_str(), 1);
|
||||
}
|
||||
int devNull = ::open("/dev/null", O_RDWR);
|
||||
if (devNull >= 0) {
|
||||
::dup2(devNull, STDIN_FILENO);
|
||||
@@ -466,8 +478,9 @@ int runMusicApp(int argc, char** argv) {
|
||||
std::string ipcArg =
|
||||
std::string("--input-ipc-server=") + kMpvSockPath;
|
||||
::execlp("mpv", "mpv", "--no-video", "--no-terminal", "--quiet",
|
||||
"--idle=yes", "--keep-open=no", "--volume-max=150",
|
||||
"--volume=100", ipcArg.c_str(),
|
||||
"--ao=pipewire,pulse,alsa", "--audio-channels=stereo",
|
||||
"--audio-samplerate=48000", "--idle=yes", "--keep-open=no",
|
||||
"--volume-max=150", "--volume=100", ipcArg.c_str(),
|
||||
static_cast<char*>(nullptr));
|
||||
::_exit(127);
|
||||
} else if (pid > 0) {
|
||||
@@ -519,7 +532,9 @@ int runMusicApp(int argc, char** argv) {
|
||||
isPaused = false;
|
||||
ignoreEofUntilMs = nowMs() + 450;
|
||||
|
||||
runAsyncCmd("amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; "
|
||||
runAsyncCmd("amixer -c 0 cset \"name='EAR_S'\" 0 >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='SPK DAC Switch'\" 1 >/dev/null 2>&1; "
|
||||
"amixer -c 0 cset \"name='RX3 MIX1 INP1'\" 3 >/dev/null 2>&1; "
|
||||
"wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1");
|
||||
|
||||
ensureMpvRunning();
|
||||
|
||||
Reference in new issue
Block a user