Don't create empty .wav files
Bug: 78287983
Test: follow the tee sink documentation, and then verify there are no empty files
Change-Id: I0aa98aff5d0d47b86f36dd38a54d0daf3feb1965
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 54121cd..66520d6 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3446,8 +3446,13 @@
// FIXME not big-endian safe
write(teeFd, &temp, sizeof(temp));
close(teeFd);
- if (fd >= 0) {
- dprintf(fd, "tee copied to %s\n", teePath);
+ // TODO Should create file with temporary name and then rename to final if non-empty.
+ if (total > 0) {
+ if (fd >= 0) {
+ dprintf(fd, "tee copied to %s\n", teePath);
+ }
+ } else {
+ unlink(teePath);
}
} else {
if (fd >= 0) {