代码中添加audiodump方法
- 抓取dump的命令:
setprop vendor.vidc.dec.log.in 1
setprop vendor.vidc.dec.log.out 1
dumpsys | grep -iE ‘audio|media’ > data/vendor/media/audio_dump.txt
adb shell dumpsys media.audio_flinger - 修改代码:
AudioFlinger
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 364e339..aa2f014 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -25,6 +25,10 @@
#include <sys/syscall.h>
#include <utils/Log.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <private/media/AudioTrackShared.h>
#include "AudioMixer.h"
@@ -569,6 +573,17 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer(
} else {
mAudioTrackServerProxy->tallyUnderrunFrames(0);
}
+ {
+ char fname[100];
+ sprintf(fname, "/data/misc/audio/%s-session-%d.pcm", mThread.promote()->mThreadName, mSessionId);
+ int tmpFd = ::open(fname, O_CREAT | O_WRONLY | O_APPEND, 0776);
+ if ( tmpFd < 0 ) {
+ ALOGE("Fail to open dumpTrack file");
+ } else {
+ ::write(tmpFd, buffer->raw, buffer->frameCount * TrackBase::mChannelCount * 2);
+ ::close(tmpFd);
+ }
+ }
return status;
}
------------------------------------------------------------------------
HAL
hardware/qcom/audio/hal/audio_hw.c
+#include <fcntl.h>
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
@@ -1632,6 +1633,18 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
if (out->muted)
memset((void *)buffer, 0, bytes);
ALOGVV("%s: writing buffer (%d bytes) to pcm device", __func__, bytes);
+ {
+ int tmpFd = open("/data/misc/audio/dumpTrack_hal.pcm", O_CREAT | O_WRONLY | O_APPEND, 0777);
+ if ( tmpFd < 0 ) {
+ ALOGE("Fail to open dumpTrack_hal file");
+ } else {
+ write(tmpFd, buffer, bytes);
+ close(tmpFd);
+ }
+ }
ret = pcm_write(out->pcm, (void *)buffer, bytes);