未验证 提交 c9da48d0 编写于 作者: O openharmony_ci 提交者: Gitee

!76 audio capturer 服务化

Merge pull request !76 from starfish/master
......@@ -29,6 +29,24 @@ executable("camera_sample") {
output_dir = "$root_out_dir/dev_tools"
}
executable("audio_capture_sample") {
sources = [ "audio_capture_sample.cpp" ]
cflags = [ "-Wall" ]
cflags_cc = cflags
include_dirs = [ "//foundation/multimedia/audio_lite/interfaces/kits" ]
include_dirs += [ "//foundation/multimedia/utils/lite/interfaces/kits" ]
ldflags = [ "-lstdc++" ]
ldflags += [ "-lpthread" ]
ldflags += [ "-Wl,-rpath-link=$ohos_root_path/$root_out_dir" ]
deps = [
"//foundation/multimedia/audio_lite/frameworks:audio_capturer_lite",
"//third_party/bounds_checking_function:libsec_shared",
]
output_dir = "$root_out_dir/dev_tools"
}
executable("player_sample") {
sources = [ "player_sample.cpp" ]
cflags = [ "-Wall" ]
......@@ -48,5 +66,6 @@ lite_component("media_sample") {
features = [
":camera_sample",
":player_sample",
":audio_capture_sample",
]
}
......@@ -15,8 +15,9 @@
#include <ctime>
#include <iostream>
#include <thread>
#include <string>
#include <thread>
#include <unistd.h>
#include "audio_capturer.h"
#include "media_errors.h"
#include "securec.h"
......@@ -93,6 +94,7 @@ static char *GernerateFileName(AudioCodecFormat format)
static void AudioInputSourceProcess(AudioSourceInput *audioSourceInput)
{
const int32_t waitTimeUs = 20000;
std::cout << "audioSourceInput: " << audioSourceInput << std::endl;
if (audioSourceInput == nullptr) {
return;
......@@ -114,8 +116,9 @@ static void AudioInputSourceProcess(AudioSourceInput *audioSourceInput)
while (audioSourceInput->bThreadRun) {
int ret = audioSourceInput->audioCap->Read(audioSourceInput->buffer,
audioSourceInput->framesize, false);
if (ret == -1) {
if (ret <= 0) {
std::cout << "audioCap Read failed ret:" << ret << std::endl;
usleep(waitTimeUs);
continue;
}
if (fwrite(audioSourceInput->buffer, 1, ret, pfd) != ret) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册