mirror of
https://github.com/openharmony/multimedia_audio_standard.git
synced 2026-06-30 22:17:58 -04:00
Resolve conflict files ,and replace marco function with standard function
Signed-off-by: zhujie <zhujie81@h-partners.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
<!-- Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@
|
||||
limitations under the License.
|
||||
|
||||
Notes:
|
||||
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun@huawei.com.
|
||||
This is project config file for OpenHarmony OSS Audit Tool, if you have any questions or concerns, please email chenyaxun.
|
||||
-->
|
||||
<!-- OAT(OSS Audit Tool) configuration guide:
|
||||
basedir: Root dir, the basedir + project path is the real source file location.
|
||||
|
||||
@@ -280,7 +280,7 @@ You can use the APIs provided in this repository for your application to record
|
||||
```
|
||||
audioCapturer->GetBufferSize(bufferLen);
|
||||
```
|
||||
9. Read the captured audio data and convert it to a byte stream. Call the read function repeatedly to read data untill you want to stop recording
|
||||
9. Read the captured audio data and convert it to a byte stream. Call the read function repeatedly to read data until you want to stop recording
|
||||
```
|
||||
// set isBlocking = true/false for blocking/non-blocking read
|
||||
bytesRead = audioCapturer->Read(*buffer, bufferLen, isBlocking);
|
||||
@@ -289,7 +289,7 @@ You can use the APIs provided in this repository for your application to record
|
||||
if (bytesRead < 0) {
|
||||
break;
|
||||
} else if (bytesRead > 0) {
|
||||
fwrite(buffer, size, bytesRead, recFile); // example shows writes the recored data into a file
|
||||
fwrite(buffer, size, bytesRead, recFile); // example shows writes the recorded data into a file
|
||||
numBuffersToCapture--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -78,6 +78,13 @@ void AudioCapturerCallbackNapi::OnJsCallbackStateChange(std::unique_ptr<AudioCap
|
||||
MEDIA_ERR_LOG("AudioCapturerCallbackNapi: OnJsCallbackStateChange: No memory");
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioCapturerCallbackNapi: OnJsCallbackStateChange: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -36,13 +36,13 @@ std::unique_ptr<AudioParameters> AudioCapturerNapi::sAudioParameters_ = nullptr;
|
||||
std::unique_ptr<AudioCapturerOptions> AudioCapturerNapi::sAudioCapturerOptions_ = nullptr;
|
||||
|
||||
namespace {
|
||||
const int ARGS_ONE = 1;
|
||||
const int ARGS_TWO = 2;
|
||||
const int ARGS_THREE = 3;
|
||||
constexpr int ARGS_ONE = 1;
|
||||
constexpr int ARGS_TWO = 2;
|
||||
constexpr int ARGS_THREE = 3;
|
||||
|
||||
const int PARAM0 = 0;
|
||||
const int PARAM1 = 1;
|
||||
const int PARAM2 = 2;
|
||||
constexpr int PARAM0 = 0;
|
||||
constexpr int PARAM1 = 1;
|
||||
constexpr int PARAM2 = 2;
|
||||
|
||||
constexpr HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "AudioCapturerNapi"};
|
||||
|
||||
@@ -456,6 +456,21 @@ void AudioCapturerNapi::IsTrueAsyncCallbackComplete(napi_env env, napi_status st
|
||||
}
|
||||
}
|
||||
|
||||
void AudioCapturerNapi::GetBufferSizeAsyncCallbackComplete(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
auto asyncContext = static_cast<AudioCapturerAsyncContext*>(data);
|
||||
napi_value valueParam = nullptr;
|
||||
|
||||
if (asyncContext != nullptr) {
|
||||
if (!asyncContext->status) {
|
||||
napi_create_uint32(env, asyncContext->bufferSize, &valueParam);
|
||||
}
|
||||
CommonCallbackRoutine(env, asyncContext, valueParam);
|
||||
} else {
|
||||
HiLog::Error(LABEL, "ERROR: AudioCapturerAsyncContext* is Null!");
|
||||
}
|
||||
}
|
||||
|
||||
void AudioCapturerNapi::GetIntValueAsyncCallbackComplete(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
auto asyncContext = static_cast<AudioCapturerAsyncContext*>(data);
|
||||
@@ -496,6 +511,7 @@ napi_value AudioCapturerNapi::GetCapturerInfo(napi_env env, napi_callback_info i
|
||||
GET_PARAMS(env, info, ARGS_ONE);
|
||||
|
||||
unique_ptr<AudioCapturerAsyncContext> asyncContext = make_unique<AudioCapturerAsyncContext>();
|
||||
NAPI_ASSERT(env, asyncContext != nullptr, "no memory");
|
||||
status = napi_unwrap(env, thisVar, reinterpret_cast<void**>(&asyncContext->objectInfo));
|
||||
if (status == napi_ok && asyncContext->objectInfo != nullptr) {
|
||||
for (size_t i = PARAM0; i < argc; i++) {
|
||||
@@ -616,6 +632,7 @@ napi_value AudioCapturerNapi::Start(napi_env env, napi_callback_info info)
|
||||
GET_PARAMS(env, info, ARGS_ONE);
|
||||
|
||||
unique_ptr<AudioCapturerAsyncContext> asyncContext = make_unique<AudioCapturerAsyncContext>();
|
||||
NAPI_ASSERT(env, asyncContext != nullptr, "no memory");
|
||||
|
||||
status = napi_unwrap(env, thisVar, reinterpret_cast<void**>(&asyncContext->objectInfo));
|
||||
if (status == napi_ok && asyncContext->objectInfo != nullptr) {
|
||||
@@ -1138,10 +1155,10 @@ napi_value AudioCapturerNapi::GetBufferSize(napi_env env, napi_callback_info inf
|
||||
size_t bufferSize;
|
||||
context->status = context->objectInfo->audioCapturer_->GetBufferSize(bufferSize);
|
||||
if (context->status == SUCCESS) {
|
||||
context->intValue = bufferSize;
|
||||
context->bufferSize = bufferSize;
|
||||
}
|
||||
},
|
||||
GetIntValueAsyncCallbackComplete, static_cast<void*>(asyncContext.get()), &asyncContext->work);
|
||||
GetBufferSizeAsyncCallbackComplete, static_cast<void*>(asyncContext.get()), &asyncContext->work);
|
||||
if (status != napi_ok) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
@@ -1278,5 +1295,5 @@ napi_value AudioCapturerNapi::CreateAudioCapturerWrapper(napi_env env, unique_pt
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioStandard
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -156,7 +156,7 @@ napi_value AudioParametersNapi::CreateEncodingTypeObject(napi_env env)
|
||||
}
|
||||
}
|
||||
}
|
||||
HiLog::Error(LABEL, "CreateEncodingTypeObject is Failed!");
|
||||
HiLog::Error(LABEL, "CreateEncodingTypeObject is failed!");
|
||||
napi_get_undefined(env, &result);
|
||||
|
||||
return result;
|
||||
@@ -410,6 +410,10 @@ napi_value AudioParametersNapi::GetAudioSampleFormat(napi_env env, napi_callback
|
||||
|
||||
status = napi_unwrap(env, jsThis, (void **)&audioParametersNapi);
|
||||
if (status == napi_ok) {
|
||||
if (!((audioParametersNapi != nullptr) && (audioParametersNapi->audioParameters_ != nullptr))) {
|
||||
HiLog::Error(LABEL, "Get audio sample format fail to napi_unwrap");
|
||||
return jsResult;
|
||||
}
|
||||
audioSampleFormat = audioParametersNapi->audioParameters_->format;
|
||||
status = napi_create_int32(env, audioSampleFormat, &jsResult);
|
||||
if (status == napi_ok) {
|
||||
@@ -867,7 +871,7 @@ napi_value AudioParametersNapi::SetDeviceType(napi_env env, napi_callback_info i
|
||||
napi_get_undefined(env, &jsResult);
|
||||
|
||||
status = napi_get_cb_info(env, info, &argc, args, &jsThis, nullptr);
|
||||
if (status != napi_ok || jsThis == nullptr || args[0] == nullptr) {
|
||||
if ((status != napi_ok) || (jsThis == nullptr) || (args[0] == nullptr)) {
|
||||
HiLog::Error(LABEL, "set device type fail to napi_get_cb_info");
|
||||
return jsResult;
|
||||
}
|
||||
@@ -889,5 +893,5 @@ napi_value AudioParametersNapi::SetDeviceType(napi_env env, napi_callback_info i
|
||||
|
||||
return jsResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioStandard
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -47,6 +47,7 @@ void CapturerPeriodPositionCallbackNapi::SaveCallbackReference(const std::string
|
||||
"CapturerPeriodPositionCallbackNapi: creating reference for callback fail");
|
||||
|
||||
std::shared_ptr<AutoRef> cb = std::make_shared<AutoRef>(env_, callback);
|
||||
CHECK_AND_RETURN_LOG(cb != nullptr, "No memory");
|
||||
if (callbackName == CAPTURER_PERIOD_POSITION_CALLBACK_NAME) {
|
||||
capturerPeriodPositionCallback_ = cb;
|
||||
} else {
|
||||
@@ -82,6 +83,13 @@ void CapturerPeriodPositionCallbackNapi::OnJsCapturerPeriodPositionCallback(
|
||||
MEDIA_ERR_LOG("CapturerPeriodPositionCallbackNapi: OnJsCapturerPeriodPositionCallback: No memory");
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("CapturerPeriodPositionCallbackNapi: OnJsCapturerPeriodPositionCallback: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -81,6 +81,11 @@ void CapturerPositionCallbackNapi::OnJsCapturerPositionCallback(std::unique_ptr<
|
||||
MEDIA_ERR_LOG("CapturerPositionCallbackNapi: OnJsCapturerPositionCallback: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("CapturerPositionCallbackNapi: OnJsCapturerPositionCallback: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
virtual ~AudioVolumeKeyEventNapi();
|
||||
|
||||
/**
|
||||
* @brief OnAudioVolumeKeyEvent will be executed when hard volume key is pressed up/down
|
||||
* @brief OnVolumeKeyEvent will be executed when hard volume key is pressed up/down
|
||||
*
|
||||
* @param streamType the stream type for which volume must be updated.
|
||||
* @param volumeLevel the volume level to be updated.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -48,6 +48,7 @@ void AudioDeviceDescriptorNapi::Destructor(napi_env env, void *nativeObject, voi
|
||||
if (nativeObject != nullptr) {
|
||||
auto obj = static_cast<AudioDeviceDescriptorNapi*>(nativeObject);
|
||||
delete obj;
|
||||
obj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,12 +13,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "audio_manager_callback_napi.h"
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
#include "audio_device_descriptor_napi.h"
|
||||
#include "audio_errors.h"
|
||||
#include "media_log.h"
|
||||
#include "audio_device_descriptor_napi.h"
|
||||
#include "audio_manager_callback_napi.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AudioStandard {
|
||||
@@ -107,6 +108,13 @@ void AudioManagerCallbackNapi::OnJsCallbackDeviceChange(std::unique_ptr<AudioMan
|
||||
MEDIA_ERR_LOG("AudioManagerCallbackNapi: OnJsCallbackDeviceChange: No memory");
|
||||
return;
|
||||
}
|
||||
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioManagerCallbackNapi: OnJsCallbackDeviceChange: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -108,6 +108,7 @@ void AudioManagerNapi::Destructor(napi_env env, void *nativeObject, void *finali
|
||||
if (nativeObject != nullptr) {
|
||||
auto obj = static_cast<AudioManagerNapi*>(nativeObject);
|
||||
delete obj;
|
||||
obj = nullptr;
|
||||
MEDIA_DEBUG_LOG("AudioManagerNapi::Destructor delete AudioManagerNapi obj done");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -104,6 +104,11 @@ void AudioRingerModeCallbackNapi::OnJsCallbackRingerMode(std::unique_ptr<AudioRi
|
||||
MEDIA_ERR_LOG("AudioRingerModeCallbackNapi: OnJsCallbackRingerMode: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioRingerModeCallbackNapi: OnJsCallbackRingerMode: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,12 +13,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "audio_volume_key_event_napi.h"
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
#include "media_log.h"
|
||||
|
||||
#include "audio_volume_key_event_napi.h"
|
||||
|
||||
using namespace std;
|
||||
namespace {
|
||||
const std::string VOLUME_KEY_EVENT_CALLBACK_NAME = "volumeChange";
|
||||
@@ -135,6 +135,11 @@ void AudioVolumeKeyEventNapi::OnJsCallbackVolumeEvent(std::unique_ptr<AudioVolum
|
||||
MEDIA_ERR_LOG("AudioVolumeKeyEventNapi: OnJsCallBackInterrupt: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioVolumeKeyEventNapi: OnJsCallBackInterrupt: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -96,6 +96,11 @@ void AudioRendererCallbackNapi::OnJsCallbackInterrupt(std::unique_ptr<AudioRende
|
||||
MEDIA_ERR_LOG("AudioRendererCallbackNapi: OnJsCallBackInterrupt: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioRendererCallbackNapi: OnJsCallBackInterrupt: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
@@ -163,6 +168,11 @@ void AudioRendererCallbackNapi::OnJsCallbackStateChange(std::unique_ptr<AudioRen
|
||||
MEDIA_ERR_LOG("AudioRendererCallbackNapi: OnJsCallbackStateChange: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioRendererCallbackNapi: OnJsCallbackStateChange: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -80,6 +80,7 @@ void AudioRendererNapi::Destructor(napi_env env, void *nativeObject, void *final
|
||||
if (nativeObject != nullptr) {
|
||||
auto obj = static_cast<AudioRendererNapi *>(nativeObject);
|
||||
delete obj;
|
||||
obj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,7 +560,7 @@ void AudioRendererNapi::WriteAsyncCallbackComplete(napi_env env, napi_status sta
|
||||
|
||||
if (asyncContext != nullptr) {
|
||||
if (!asyncContext->status) {
|
||||
napi_create_int32(env, asyncContext->intValue, &valueParam);
|
||||
napi_create_uint32(env, asyncContext->totalBytesWritten, &valueParam);
|
||||
}
|
||||
if (!asyncContext->status) {
|
||||
napi_get_undefined(env, &result[PARAM0]);
|
||||
@@ -799,6 +800,21 @@ void AudioRendererNapi::VoidAsyncCallbackComplete(napi_env env, napi_status stat
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRendererNapi::GetBufferSizeAsyncCallbackComplete(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
auto asyncContext = static_cast<AudioRendererAsyncContext *>(data);
|
||||
napi_value valueParam = nullptr;
|
||||
|
||||
if (asyncContext != nullptr) {
|
||||
if (!asyncContext->status) {
|
||||
napi_create_uint32(env, asyncContext->bufferSize, &valueParam);
|
||||
}
|
||||
CommonCallbackRoutine(env, asyncContext, valueParam);
|
||||
} else {
|
||||
HiLog::Error(LABEL, "ERROR: AudioRendererAsyncContext* is Null!");
|
||||
}
|
||||
}
|
||||
|
||||
void AudioRendererNapi::GetIntValueAsyncCallbackComplete(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
auto asyncContext = static_cast<AudioRendererAsyncContext *>(data);
|
||||
@@ -1114,17 +1130,20 @@ napi_value AudioRendererNapi::Write(napi_env env, napi_callback_info info)
|
||||
}
|
||||
|
||||
int32_t bytesWritten = 0;
|
||||
size_t totalBytesWritten = 0;
|
||||
size_t minBytes = 4;
|
||||
while ((bytesWritten < bufferLen) && ((bufferLen - bytesWritten) > minBytes)) {
|
||||
bytesWritten += context->objectInfo->audioRenderer_->Write(buffer.get() + bytesWritten,
|
||||
bufferLen - bytesWritten);
|
||||
while ((totalBytesWritten < bufferLen) && ((bufferLen - totalBytesWritten) > minBytes)) {
|
||||
bytesWritten = context->objectInfo->audioRenderer_->Write(buffer.get() + totalBytesWritten,
|
||||
bufferLen - totalBytesWritten);
|
||||
if (bytesWritten < 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
totalBytesWritten += bytesWritten;
|
||||
}
|
||||
|
||||
context->status = SUCCESS;
|
||||
context->intValue = bytesWritten;
|
||||
context->totalBytesWritten = totalBytesWritten;
|
||||
},
|
||||
WriteAsyncCallbackComplete, static_cast<void *>(asyncContext.get()), &asyncContext->work);
|
||||
if (status != napi_ok) {
|
||||
@@ -1480,10 +1499,10 @@ napi_value AudioRendererNapi::GetBufferSize(napi_env env, napi_callback_info inf
|
||||
size_t bufferSize;
|
||||
context->status = context->objectInfo->audioRenderer_->GetBufferSize(bufferSize);
|
||||
if (context->status == SUCCESS) {
|
||||
context->intValue = bufferSize;
|
||||
context->bufferSize = bufferSize;
|
||||
}
|
||||
},
|
||||
GetIntValueAsyncCallbackComplete, static_cast<void *>(asyncContext.get()), &asyncContext->work);
|
||||
GetBufferSizeAsyncCallbackComplete, static_cast<void *>(asyncContext.get()), &asyncContext->work);
|
||||
if (status != napi_ok) {
|
||||
result = nullptr;
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -82,6 +82,11 @@ void RendererPeriodPositionCallbackNapi::OnJsRendererPeriodPositionCallback(
|
||||
MEDIA_ERR_LOG("RendererPeriodPositionCallbackNapi: OnJsRendererPeriodPositionCallback: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("RendererPeriodPositionCallbackNapi: OnJsRendererPeriodPositionCallback: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -81,6 +81,11 @@ void RendererPositionCallbackNapi::OnJsRendererPositionCallback(std::unique_ptr<
|
||||
MEDIA_ERR_LOG("RendererPositionCallbackNapi: OnJsRendererPositionCallback: No memory");
|
||||
return;
|
||||
}
|
||||
if (jsCb.get() == nullptr) {
|
||||
MEDIA_ERR_LOG("RendererPositionCallbackNapi: OnJsRendererPositionCallback: jsCb.get() is null");
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
work->data = reinterpret_cast<void *>(jsCb.get());
|
||||
|
||||
int ret = uv_queue_work(loop, work, [] (uv_work_t *work) {}, [] (uv_work_t *work, int status) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -45,6 +45,7 @@ void AudioRendererInfoNapi::Destructor(napi_env env, void *nativeObject, void *f
|
||||
if (nativeObject != nullptr) {
|
||||
auto obj = static_cast<AudioRendererInfoNapi *>(nativeObject);
|
||||
delete obj;
|
||||
obj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,12 +241,15 @@ napi_value AudioRendererInfoNapi::SetStreamUsage(napi_env env, napi_callback_inf
|
||||
}
|
||||
|
||||
status = napi_unwrap(env, jsThis, (void **)&audioRendererInfoNapi);
|
||||
if (status == napi_ok) {
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
if (napi_typeof(env, args[0], &valueType) != napi_ok || valueType != napi_number) {
|
||||
HiLog::Error(LABEL, "set stream usage fail: wrong data type");
|
||||
return jsResult;
|
||||
}
|
||||
if (status != napi_ok) {
|
||||
HiLog::Error(LABEL, "Napi unwrap failed");
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
if (napi_typeof(env, args[0], &valueType) != napi_ok || valueType != napi_number) {
|
||||
HiLog::Error(LABEL, "set stream usage fail: wrong data type");
|
||||
return jsResult;
|
||||
}
|
||||
|
||||
status = napi_get_value_int32(env, args[0], &usage);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -47,6 +47,7 @@ void RingtoneOptionsNapi::Destructor(napi_env env, void *nativeObject, void *fin
|
||||
if (nativeObject != nullptr) {
|
||||
auto obj = static_cast<RingtoneOptionsNapi *>(nativeObject);
|
||||
delete obj;
|
||||
obj = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
*
|
||||
* @param audioPortName name of the audio modules to be loaded
|
||||
* @param moduleArgs audio module info like rate, channel etc
|
||||
* @return Returns module index if module loaded sucessfully; returns an error code
|
||||
* @return Returns module index if module loaded successfully; returns an error code
|
||||
* defined in {@link audio_errors.h} otherwise.
|
||||
*/
|
||||
virtual uint32_t OpenAudioPort(std::string audioPortName, std::string moduleArgs) = 0;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,12 +16,13 @@
|
||||
#ifndef ST_PULSEAUDIO_AUDIO_SERVICE_ADAPTER_IMPL_H
|
||||
#define ST_PULSEAUDIO_AUDIO_SERVICE_ADAPTER_IMPL_H
|
||||
|
||||
#include "pulse_audio_service_adapter_impl.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "audio_errors.h"
|
||||
#include "media_log.h"
|
||||
#include "pulse_audio_service_adapter_impl.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -62,10 +63,11 @@ bool PulseAudioServiceAdapterImpl::Connect()
|
||||
while (true) {
|
||||
pa_context_state_t state;
|
||||
|
||||
if (mContext != NULL) {
|
||||
if (mContext != nullptr) {
|
||||
state = pa_context_get_state(mContext);
|
||||
if (state == PA_CONTEXT_READY)
|
||||
if (state == PA_CONTEXT_READY) {
|
||||
break;
|
||||
}
|
||||
// if pulseaudio is ready, retry connect to pulseaudio. before retry wait for sometime. reduce sleep later
|
||||
usleep(PA_CONNECT_RETRY_SLEEP_IN_MICRO_SECONDS);
|
||||
}
|
||||
@@ -89,28 +91,33 @@ bool PulseAudioServiceAdapterImpl::Connect()
|
||||
bool PulseAudioServiceAdapterImpl::ConnectToPulseAudio()
|
||||
{
|
||||
unique_ptr<UserData> userData = make_unique<UserData>();
|
||||
if (userData == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] UserData memory alloc failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
userData->thiz = this;
|
||||
|
||||
if (mContext != NULL) {
|
||||
if (mContext != nullptr) {
|
||||
pa_context_disconnect(mContext);
|
||||
pa_context_set_state_callback(mContext, NULL, NULL);
|
||||
pa_context_set_subscribe_callback(mContext, NULL, NULL);
|
||||
pa_context_set_state_callback(mContext, nullptr, nullptr);
|
||||
pa_context_set_subscribe_callback(mContext, nullptr, nullptr);
|
||||
pa_context_unref(mContext);
|
||||
}
|
||||
|
||||
pa_proplist *proplist = pa_proplist_new();
|
||||
pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "PulseAudio Service");
|
||||
pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "com.ohos.pulseaudio.service");
|
||||
mContext = pa_context_new_with_proplist(pa_threaded_mainloop_get_api(mMainLoop), NULL, proplist);
|
||||
mContext = pa_context_new_with_proplist(pa_threaded_mainloop_get_api(mMainLoop), nullptr, proplist);
|
||||
pa_proplist_free(proplist);
|
||||
|
||||
if (mContext == NULL) {
|
||||
if (mContext == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] creating pa context failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_context_set_state_callback(mContext, PulseAudioServiceAdapterImpl::PaContextStateCb, this);
|
||||
if (pa_context_connect(mContext, NULL, PA_CONTEXT_NOFAIL, NULL) < 0) {
|
||||
if (pa_context_connect(mContext, nullptr, PA_CONTEXT_NOFAIL, nullptr) < 0) {
|
||||
if (pa_context_errno(mContext) == PA_ERR_INVALID) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa context connect failed: %{public}s",
|
||||
pa_strerror(pa_context_errno(mContext)));
|
||||
@@ -122,8 +129,8 @@ bool PulseAudioServiceAdapterImpl::ConnectToPulseAudio()
|
||||
|
||||
Fail:
|
||||
/* Make sure we don't get any further callbacks */
|
||||
pa_context_set_state_callback(mContext, NULL, NULL);
|
||||
pa_context_set_subscribe_callback(mContext, NULL, NULL);
|
||||
pa_context_set_state_callback(mContext, nullptr, nullptr);
|
||||
pa_context_set_subscribe_callback(mContext, nullptr, nullptr);
|
||||
pa_context_unref(mContext);
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +143,7 @@ uint32_t PulseAudioServiceAdapterImpl::OpenAudioPort(string audioPortName, strin
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
pa_operation *operation = pa_context_load_module(mContext, audioPortName.c_str(), moduleArgs.c_str(),
|
||||
PaModuleLoadCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_load_module returned nullptr");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERR_INVALID_HANDLE;
|
||||
@@ -161,8 +168,8 @@ int32_t PulseAudioServiceAdapterImpl::CloseAudioPort(int32_t audioHandleIndex)
|
||||
{
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
|
||||
pa_operation *operation = pa_context_unload_module(mContext, audioHandleIndex, NULL, NULL);
|
||||
if (operation == NULL) {
|
||||
pa_operation *operation = pa_context_unload_module(mContext, audioHandleIndex, nullptr, nullptr);
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_unload_module returned nullptr!");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERROR;
|
||||
@@ -179,8 +186,9 @@ int32_t PulseAudioServiceAdapterImpl::SuspendAudioDevice(string &audioPortName,
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
|
||||
auto suspendFlag = isSuspend ? 1 : 0;
|
||||
pa_operation *operation = pa_context_suspend_sink_by_name(mContext, audioPortName.c_str(), suspendFlag, NULL, NULL);
|
||||
if (operation == NULL) {
|
||||
pa_operation *operation = pa_context_suspend_sink_by_name(mContext, audioPortName.c_str(), suspendFlag,
|
||||
nullptr, nullptr);
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_suspend_sink_by_name failed!");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERR_OPERATION_FAILED;
|
||||
@@ -195,8 +203,8 @@ int32_t PulseAudioServiceAdapterImpl::SuspendAudioDevice(string &audioPortName,
|
||||
int32_t PulseAudioServiceAdapterImpl::SetDefaultSink(string name)
|
||||
{
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
pa_operation *operation = pa_context_set_default_sink(mContext, name.c_str(), NULL, NULL);
|
||||
if (operation == NULL) {
|
||||
pa_operation *operation = pa_context_set_default_sink(mContext, name.c_str(), nullptr, nullptr);
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_set_default_sink failed!");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERR_OPERATION_FAILED;
|
||||
@@ -210,8 +218,8 @@ int32_t PulseAudioServiceAdapterImpl::SetDefaultSink(string name)
|
||||
int32_t PulseAudioServiceAdapterImpl::SetDefaultSource(string name)
|
||||
{
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
pa_operation *operation = pa_context_set_default_source(mContext, name.c_str(), NULL, NULL);
|
||||
if (operation == NULL) {
|
||||
pa_operation *operation = pa_context_set_default_source(mContext, name.c_str(), nullptr, nullptr);
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_set_default_source failed!");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERR_OPERATION_FAILED;
|
||||
@@ -225,18 +233,23 @@ int32_t PulseAudioServiceAdapterImpl::SetDefaultSource(string name)
|
||||
int32_t PulseAudioServiceAdapterImpl::SetVolume(AudioStreamType streamType, float volume)
|
||||
{
|
||||
unique_ptr<UserData> userData = make_unique<UserData>();
|
||||
if (userData == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] SetVolume UserData memory alloc failed");
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
userData->thiz = this;
|
||||
userData->volume = volume;
|
||||
userData->streamType = streamType;
|
||||
|
||||
if (mContext == NULL) {
|
||||
if (mContext == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] SetVolume mContext is nullptr");
|
||||
return ERROR;
|
||||
}
|
||||
pa_threaded_mainloop_lock(mMainLoop);
|
||||
pa_operation *operation = pa_context_get_sink_input_info_list(mContext,
|
||||
PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_get_sink_input_info_list nullptr");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERROR;
|
||||
@@ -258,7 +271,7 @@ int32_t PulseAudioServiceAdapterImpl::SetMute(AudioStreamType streamType, bool m
|
||||
userData->mute = mute;
|
||||
userData->streamType = streamType;
|
||||
|
||||
if (mContext == NULL) {
|
||||
if (mContext == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] SetMute mContext is nullptr");
|
||||
return ERROR;
|
||||
}
|
||||
@@ -266,7 +279,7 @@ int32_t PulseAudioServiceAdapterImpl::SetMute(AudioStreamType streamType, bool m
|
||||
|
||||
pa_operation *operation = pa_context_get_sink_input_info_list(mContext,
|
||||
PulseAudioServiceAdapterImpl::PaGetSinkInputInfoMuteCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_get_sink_input_info_list returned nullptr");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return ERROR;
|
||||
@@ -289,7 +302,7 @@ bool PulseAudioServiceAdapterImpl::IsMute(AudioStreamType streamType)
|
||||
userData->streamType = streamType;
|
||||
userData->mute = false;
|
||||
|
||||
if (mContext == NULL) {
|
||||
if (mContext == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] IsMute mContext is nullptr");
|
||||
return false;
|
||||
}
|
||||
@@ -298,7 +311,7 @@ bool PulseAudioServiceAdapterImpl::IsMute(AudioStreamType streamType)
|
||||
|
||||
pa_operation *operation = pa_context_get_sink_input_info_list(mContext,
|
||||
PulseAudioServiceAdapterImpl::PaGetSinkInputInfoMuteStatusCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_get_sink_input_info_list returned nullptr");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return false;
|
||||
@@ -321,7 +334,7 @@ bool PulseAudioServiceAdapterImpl::IsStreamActive(AudioStreamType streamType)
|
||||
userData->streamType = streamType;
|
||||
userData->isCorked = true;
|
||||
|
||||
if (mContext == NULL) {
|
||||
if (mContext == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] IsStreamActive mContext is nullptr");
|
||||
return false;
|
||||
}
|
||||
@@ -330,7 +343,7 @@ bool PulseAudioServiceAdapterImpl::IsStreamActive(AudioStreamType streamType)
|
||||
|
||||
pa_operation *operation = pa_context_get_sink_input_info_list(mContext,
|
||||
PulseAudioServiceAdapterImpl::PaGetSinkInputInfoCorkStatusCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[IsStreamActive] pa_context_get_sink_input_info_list returned nullptr");
|
||||
pa_threaded_mainloop_unlock(mMainLoop);
|
||||
return false;
|
||||
@@ -351,20 +364,18 @@ bool PulseAudioServiceAdapterImpl::IsStreamActive(AudioStreamType streamType)
|
||||
|
||||
void PulseAudioServiceAdapterImpl::Disconnect()
|
||||
{
|
||||
if (mContext != NULL) {
|
||||
if (mContext != nullptr) {
|
||||
pa_context_disconnect(mContext);
|
||||
/* Make sure we don't get any further callbacks */
|
||||
pa_context_set_state_callback(mContext, NULL, NULL);
|
||||
pa_context_set_subscribe_callback(mContext, NULL, NULL);
|
||||
pa_context_set_state_callback(mContext, nullptr, nullptr);
|
||||
pa_context_set_subscribe_callback(mContext, nullptr, nullptr);
|
||||
pa_context_unref(mContext);
|
||||
}
|
||||
|
||||
if (mMainLoop != NULL) {
|
||||
if (mMainLoop != nullptr) {
|
||||
pa_threaded_mainloop_stop(mMainLoop);
|
||||
pa_threaded_mainloop_free(mMainLoop);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
string PulseAudioServiceAdapterImpl::GetNameByStreamType(AudioStreamType streamType)
|
||||
@@ -433,13 +444,13 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoMuteStatusCb(pa_context *c,
|
||||
return;
|
||||
}
|
||||
|
||||
if (i->proplist == NULL) {
|
||||
if (i->proplist == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid Proplist for sink input (%{public}d).", i->index);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *streamtype = pa_proplist_gets(i->proplist, "stream.type");
|
||||
if (streamtype == NULL) {
|
||||
if (streamtype == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid StreamType.");
|
||||
return;
|
||||
}
|
||||
@@ -471,20 +482,20 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoMuteCb(pa_context *c, const
|
||||
return;
|
||||
}
|
||||
|
||||
if (i->proplist == NULL) {
|
||||
if (i->proplist == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid Proplist for sink input (%{public}d).", i->index);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *streamtype = pa_proplist_gets(i->proplist, "stream.type");
|
||||
if (streamtype == NULL) {
|
||||
if (streamtype == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid StreamType.");
|
||||
return;
|
||||
}
|
||||
|
||||
string streamType(streamtype);
|
||||
if (!streamType.compare(thiz->GetNameByStreamType(userData->streamType))) {
|
||||
pa_operation_unref(pa_context_set_sink_input_mute(c, i->index, (userData->mute) ? 1 : 0, NULL, NULL));
|
||||
pa_operation_unref(pa_context_set_sink_input_mute(c, i->index, (userData->mute) ? 1 : 0, nullptr, nullptr));
|
||||
MEDIA_INFO_LOG("[PulseAudioServiceAdapterImpl] Applied Mute : %{public}d for stream : %{public}s",
|
||||
userData->mute, i->name);
|
||||
}
|
||||
@@ -509,8 +520,8 @@ void PulseAudioServiceAdapterImpl::PaContextStateCb(pa_context *c, void *userdat
|
||||
pa_operation *operation = pa_context_subscribe(c, (pa_subscription_mask_t)
|
||||
(PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE |
|
||||
PA_SUBSCRIPTION_MASK_SINK_INPUT | PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT |
|
||||
PA_SUBSCRIPTION_MASK_CARD), NULL, NULL);
|
||||
if (operation == NULL) {
|
||||
PA_SUBSCRIPTION_MASK_CARD), nullptr, nullptr);
|
||||
if (operation == nullptr) {
|
||||
pa_threaded_mainloop_signal(thiz->mMainLoop, 0);
|
||||
return;
|
||||
}
|
||||
@@ -563,7 +574,7 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb(pa_context *c, con
|
||||
return;
|
||||
}
|
||||
|
||||
if (i->proplist == NULL) {
|
||||
if (i->proplist == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid Proplist for sink input (%{public}d).", i->index);
|
||||
return;
|
||||
}
|
||||
@@ -571,7 +582,7 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb(pa_context *c, con
|
||||
const char *streamtype = pa_proplist_gets(i->proplist, "stream.type");
|
||||
const char *streamVolume = pa_proplist_gets(i->proplist, "stream.volumeFactor");
|
||||
const char *sessionCStr = pa_proplist_gets(i->proplist, "stream.sessionID");
|
||||
if ((streamtype == NULL) || (streamVolume == NULL) || (sessionCStr == NULL)) {
|
||||
if ((streamtype == nullptr) || (streamVolume == nullptr) || (sessionCStr == nullptr)) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid StreamType or streamVolume or SessionID");
|
||||
return;
|
||||
}
|
||||
@@ -593,17 +604,15 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb(pa_context *c, con
|
||||
pa_cvolume cv = i->volume;
|
||||
uint32_t volume = pa_sw_volume_from_linear(vol);
|
||||
pa_cvolume_set(&cv, i->channel_map.channels, volume);
|
||||
pa_operation_unref(pa_context_set_sink_input_volume(c, i->index, &cv, NULL, NULL));
|
||||
pa_operation_unref(pa_context_set_sink_input_volume(c, i->index, &cv, nullptr, nullptr));
|
||||
|
||||
if (streamID == userData->streamType) {
|
||||
if (i->mute) {
|
||||
pa_operation_unref(pa_context_set_sink_input_mute(c, i->index, 0, NULL, NULL));
|
||||
pa_operation_unref(pa_context_set_sink_input_mute(c, i->index, 0, nullptr, nullptr));
|
||||
}
|
||||
}
|
||||
MEDIA_INFO_LOG("[PulseAudioServiceAdapterImpl]volume : %{public}f for stream : %{public}s, volumeInt%{public}d",
|
||||
vol, i->name, volume);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoCorkStatusCb(pa_context *c, const pa_sink_input_info *i, int eol,
|
||||
@@ -623,13 +632,13 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoCorkStatusCb(pa_context *c,
|
||||
return;
|
||||
}
|
||||
|
||||
if (i->proplist == NULL) {
|
||||
if (i->proplist == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid Proplist for sink input (%{public}d).", i->index);
|
||||
return;
|
||||
}
|
||||
|
||||
const char *streamtype = pa_proplist_gets(i->proplist, "stream.type");
|
||||
if (streamtype == NULL) {
|
||||
if (streamtype == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Invalid StreamType.");
|
||||
return;
|
||||
}
|
||||
@@ -640,8 +649,6 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoCorkStatusCb(pa_context *c,
|
||||
MEDIA_INFO_LOG("[PulseAudioServiceAdapterImpl] corked : %{public}d for stream : %{public}s",
|
||||
userData->isCorked, i->name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void PulseAudioServiceAdapterImpl::PaSubscribeCb(pa_context *c, pa_subscription_event_type_t t, uint32_t idx,
|
||||
@@ -662,7 +669,7 @@ void PulseAudioServiceAdapterImpl::PaSubscribeCb(pa_context *c, pa_subscription_
|
||||
pa_threaded_mainloop_lock(thiz->mMainLoop);
|
||||
pa_operation *operation = pa_context_get_sink_input_info(c, idx,
|
||||
PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb, reinterpret_cast<void*>(userData.get()));
|
||||
if (operation == NULL) {
|
||||
if (operation == nullptr) {
|
||||
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] pa_context_get_sink_input_info_list nullptr");
|
||||
pa_threaded_mainloop_unlock(thiz->mMainLoop);
|
||||
return;
|
||||
@@ -684,8 +691,6 @@ void PulseAudioServiceAdapterImpl::PaSubscribeCb(pa_context *c, pa_subscription_
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
} // namespace AudioStandard
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -19,8 +19,8 @@ ohos_shared_library("audio_capturer_source") {
|
||||
sources = [ "//foundation/multimedia/audio_standard/frameworks/native/audiocapturer/src/audio_capturer_source.cpp" ]
|
||||
cflags = [ "-fPIC" ]
|
||||
cflags += [ "-Wall" ]
|
||||
if (device_name == "baltimore") {
|
||||
cflags += [ "-DDEVICE_BALTIMORE" ]
|
||||
if ("${product_name}" == "m40") {
|
||||
cflags += [ "-DPRODUCT_M40" ]
|
||||
}
|
||||
cflags_cc = cflags
|
||||
|
||||
@@ -45,7 +45,7 @@ ohos_shared_library("audio_capturer_source") {
|
||||
"//third_party/bounds_checking_function:libsec_static",
|
||||
]
|
||||
|
||||
if (device_name == "baltimore") {
|
||||
if ("${product_name}" == "m40") {
|
||||
deps += [ "//drivers/peripheral/adapter/audio/interfaces:hdi_audio_client" ]
|
||||
} else {
|
||||
deps +=
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -78,7 +78,7 @@ void AudioCapturerSource::DeInit()
|
||||
#endif // CAPTURE_DUMP
|
||||
}
|
||||
|
||||
int32_t InitAttrsCapture(struct AudioSampleAttributes &attrs)
|
||||
void InitAttrsCapture(struct AudioSampleAttributes &attrs)
|
||||
{
|
||||
/* Initialization of audio parameters for playback */
|
||||
attrs.format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
@@ -95,12 +95,10 @@ int32_t InitAttrsCapture(struct AudioSampleAttributes &attrs)
|
||||
attrs.stopThreshold = INT_32_MAX;
|
||||
/* 16 * 1024 */
|
||||
attrs.silenceThreshold = AUDIO_BUFF_SIZE;
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SwitchAdapterCapture(struct AudioAdapterDescriptor *descs, string adapterNameCase,
|
||||
enum AudioPortDirection portFlag, struct AudioPort &capturePort, const int32_t size)
|
||||
int32_t SwitchAdapterCapture(struct AudioAdapterDescriptor *descs, int32_t size, const std::string &adapterNameCase,
|
||||
enum AudioPortDirection portFlag, struct AudioPort &capturePort)
|
||||
{
|
||||
if (descs == nullptr) {
|
||||
return ERROR;
|
||||
@@ -111,7 +109,7 @@ int32_t SwitchAdapterCapture(struct AudioAdapterDescriptor *descs, string adapte
|
||||
if (desc == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(desc->adapterName, adapterNameCase.c_str())) {
|
||||
if (!adapterNameCase.compare(desc->adapterName)) {
|
||||
for (uint32_t port = 0; port < desc->portNum; port++) {
|
||||
// Only find out the port of out in the sound card
|
||||
if (desc->ports[port].dir == portFlag) {
|
||||
@@ -121,7 +119,7 @@ int32_t SwitchAdapterCapture(struct AudioAdapterDescriptor *descs, string adapte
|
||||
}
|
||||
}
|
||||
}
|
||||
MEDIA_ERR_LOG("SwitchAdapter Fail");
|
||||
MEDIA_ERR_LOG("SwitchAdapterCapture Fail");
|
||||
|
||||
return ERR_INVALID_INDEX;
|
||||
}
|
||||
@@ -188,9 +186,9 @@ int32_t AudioCapturerSource::Init(AudioSourceAttr &attr)
|
||||
|
||||
// Get qualified sound card and port
|
||||
string adapterNameCase = "internal";
|
||||
index = SwitchAdapterCapture(descs, adapterNameCase, PORT_IN, audioPort, size);
|
||||
index = SwitchAdapterCapture(descs, size, adapterNameCase, PORT_IN, audioPort);
|
||||
if (index < 0) {
|
||||
MEDIA_ERR_LOG("Switch Adapter Fail");
|
||||
MEDIA_ERR_LOG("Switch Adapter Capture Fail");
|
||||
return ERR_NOT_STARTED;
|
||||
}
|
||||
|
||||
@@ -204,7 +202,7 @@ int32_t AudioCapturerSource::Init(AudioSourceAttr &attr)
|
||||
return ERR_NOT_STARTED;
|
||||
}
|
||||
|
||||
// Inittialization port information, can fill through mode and other paramters
|
||||
// Inittialization port information, can fill through mode and other parameters
|
||||
ret = audioAdapter_->InitAllPorts(audioAdapter_);
|
||||
if (ret != 0) {
|
||||
MEDIA_ERR_LOG("InitAllPorts failed");
|
||||
@@ -216,7 +214,7 @@ int32_t AudioCapturerSource::Init(AudioSourceAttr &attr)
|
||||
return ERR_NOT_STARTED;
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
ret = OpenInput(DEVICE_TYPE_MIC);
|
||||
if (ret < 0) {
|
||||
MEDIA_ERR_LOG("AudioRendererSink: update route FAILED: %{public}d", ret);
|
||||
@@ -341,7 +339,7 @@ int32_t AudioCapturerSource::GetMute(bool &isMute)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
static AudioCategory GetAudioCategory(AudioScene audioScene)
|
||||
{
|
||||
AudioCategory audioCategory;
|
||||
@@ -440,7 +438,7 @@ int32_t AudioCapturerSource::SetAudioScene(AudioScene audioScene)
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
int32_t ret = OpenInput(DEVICE_TYPE_MIC);
|
||||
if (ret < 0) {
|
||||
MEDIA_ERR_LOG("AudioCapturerSource: Update route FAILED: %{public}d", ret);
|
||||
@@ -449,8 +447,8 @@ int32_t AudioCapturerSource::SetAudioScene(AudioScene audioScene)
|
||||
struct AudioSceneDescriptor scene;
|
||||
scene.scene.id = GetAudioCategory(audioScene);
|
||||
scene.desc.pins = PIN_IN_MIC;
|
||||
if (audioCapture_->scene.SelectScene == NULL) {
|
||||
MEDIA_ERR_LOG("AudioCapturerSource: Select scene NULL");
|
||||
if (audioCapture_->scene.SelectScene == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioCapturerSource: Select scene nullptr");
|
||||
return ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -22,8 +22,8 @@ ohos_shared_library("audio_renderer_sink") {
|
||||
|
||||
cflags = [ "-fPIC" ]
|
||||
cflags += [ "-Wall" ]
|
||||
if (device_name == "baltimore") {
|
||||
cflags += [ "-DDEVICE_BALTIMORE" ]
|
||||
if ("${product_name}" == "m40") {
|
||||
cflags += [ "-DPRODUCT_M40" ]
|
||||
}
|
||||
cflags_cc = cflags
|
||||
|
||||
@@ -50,7 +50,7 @@ ohos_shared_library("audio_renderer_sink") {
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
if (device_name == "baltimore") {
|
||||
if ("${product_name}" == "m40") {
|
||||
deps += [ "//drivers/peripheral/adapter/audio/interfaces:hdi_audio_client" ]
|
||||
} else {
|
||||
deps +=
|
||||
@@ -68,11 +68,7 @@ ohos_shared_library("bluetooth_renderer_sink") {
|
||||
|
||||
cflags = [ "-fPIC" ]
|
||||
cflags += [ "-Wall" ]
|
||||
if (device_name == "baltimore") {
|
||||
cflags += [ "-DDEVICE_BALTIMORE" ]
|
||||
} else if (device_name == "rk3566" || device_name == "rk3568") {
|
||||
cflags += [ "-DDEVICE_RK" ]
|
||||
}
|
||||
|
||||
cflags_cc = cflags
|
||||
|
||||
include_dirs = [
|
||||
@@ -101,6 +97,53 @@ ohos_shared_library("bluetooth_renderer_sink") {
|
||||
subsystem_name = "multimedia"
|
||||
}
|
||||
|
||||
ohos_shared_library("audio_bluetooth_client") {
|
||||
install_enable = true
|
||||
sources = [
|
||||
"//foundation/multimedia/audio_standard/services/src/audio_bluetooth/client/audio_bluetooth_manager.cpp",
|
||||
"//foundation/multimedia/audio_standard/services/src/audio_bluetooth/client/bluetooth_a2dp_audio_src_observer_stub.cpp",
|
||||
"//foundation/multimedia/audio_standard/services/src/audio_bluetooth/client/bluetooth_a2dp_src_observer.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"//foundation/communication/bluetooth/services/bluetooth_standard/ipc/include",
|
||||
"//foundation/communication/bluetooth/services/bluetooth_standard/common/",
|
||||
"//foundation/communication/bluetooth/interfaces/innerkits/native_cpp/include",
|
||||
"//foundation/communication/bluetooth/interfaces/innerkits/native_cpp/framework/common",
|
||||
"//foundation/communication/bluetooth/interfaces/innerkits/native_c/include",
|
||||
"//foundation/multimedia/audio_standard/services/src/audio_policy/server/service/include/interface",
|
||||
"//foundation/multimedia/audio_standard/services/include/audio_bluetooth/client",
|
||||
"//foundation/multimedia/audio_standard/frameworks/native/audiorenderer/include",
|
||||
"//foundation/multimedia/audio_standard/interfaces/inner_api/native/audiocommon/include",
|
||||
"//utils/native/base/include",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits/include",
|
||||
"//drivers/peripheral/bluetooth/audio/interfaces/include",
|
||||
"//drivers/peripheral/bluetooth/audio/hal/hdi_binder/proxy/include",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"$hdf_uhdf_path/hdi:libhdi",
|
||||
"$hdf_uhdf_path/host:libhdf_host",
|
||||
"$hdf_uhdf_path/ipc:libhdf_ipc_adapter",
|
||||
"$hdf_uhdf_path/utils:libhdf_utils",
|
||||
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog",
|
||||
"//foundation/communication/bluetooth/services/bluetooth_standard/ipc:btipc_static",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/multimedia/audio_standard/frameworks/native/audiorenderer:bluetooth_renderer_sink",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr_standard:samgr_proxy",
|
||||
]
|
||||
|
||||
part_name = "multimedia_audio_standard"
|
||||
subsystem_name = "multimedia"
|
||||
}
|
||||
|
||||
ohos_shared_library("renderer_sink_adapter") {
|
||||
install_enable = true
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -64,13 +64,13 @@ public:
|
||||
int32_t Clear() const override;
|
||||
int32_t GetBufQueueState(BufferQueueState &bufState) const override;
|
||||
|
||||
std::shared_ptr<AudioStream> audioStream_;
|
||||
AudioRendererInfo rendererInfo_ = {};
|
||||
|
||||
explicit AudioRendererPrivate(AudioStreamType audioStreamType);
|
||||
~AudioRendererPrivate();
|
||||
|
||||
private:
|
||||
std::shared_ptr<AudioStream> audioStream_;
|
||||
std::shared_ptr<AudioInterruptCallback> audioInterruptCallback_ = nullptr;
|
||||
std::shared_ptr<AudioStreamCallback> audioStreamCallback_ = nullptr;
|
||||
AudioInterrupt audioInterrupt_ =
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
bool HandleForceDucking(const InterruptEventInternal &interruptEvent);
|
||||
std::shared_ptr<AudioStream> audioStream_;
|
||||
std::weak_ptr<AudioRendererCallback> callback_;
|
||||
std::shared_ptr<AudioRendererCallback> cb;
|
||||
std::shared_ptr<AudioRendererCallback> cb_;
|
||||
AudioInterrupt audioInterrupt_ {};
|
||||
bool isForcePaused_ = false;
|
||||
bool isForceDucked_ = false;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
struct AudioProxyManager *audioManager_;
|
||||
struct AudioAdapter *audioAdapter_;
|
||||
struct AudioRender *audioRender_;
|
||||
struct AudioPort audioPort;
|
||||
struct AudioPort audioPort_;
|
||||
|
||||
int32_t CreateRender(struct AudioPort &renderPort);
|
||||
int32_t InitAudioManager();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -44,7 +44,7 @@ std::unique_ptr<AudioRenderer> AudioRenderer::Create(const AudioRendererOptions
|
||||
"Invalid content type");
|
||||
|
||||
StreamUsage streamUsage = rendererOptions.rendererInfo.streamUsage;
|
||||
CHECK_AND_RETURN_RET_LOG(streamUsage >= STREAM_USAGE_UNKNOWN && streamUsage <= STREAM_USAGE_VOICE_ASSISTANT,
|
||||
CHECK_AND_RETURN_RET_LOG(streamUsage >= STREAM_USAGE_UNKNOWN && streamUsage <= STREAM_USAGE_NOTIFICATION_RINGTONE,
|
||||
nullptr, "Invalid stream usage");
|
||||
|
||||
AudioStreamType audioStreamType = AudioStream::GetStreamType(contentType, streamUsage);
|
||||
@@ -381,11 +381,11 @@ void AudioInterruptCallbackImpl::NotifyEvent(const InterruptEvent &interruptEven
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: NotifyEvent: Hint: %{public}d", interruptEvent.hintType);
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: NotifyEvent: eventType: %{public}d", interruptEvent.eventType);
|
||||
|
||||
if (cb != nullptr) {
|
||||
cb->OnInterrupt(interruptEvent);
|
||||
if (cb_ != nullptr) {
|
||||
cb_->OnInterrupt(interruptEvent);
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: OnInterrupt : NotifyEvent to app complete");
|
||||
} else {
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: cb == nullptr cannont NotifyEvent to app");
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: cb_ == nullptr cannont NotifyEvent to app");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ void AudioInterruptCallbackImpl::HandleAndNotifyForcedEvent(const InterruptEvent
|
||||
|
||||
void AudioInterruptCallbackImpl::OnInterrupt(const InterruptEventInternal &interruptEvent)
|
||||
{
|
||||
cb = callback_.lock();
|
||||
cb_ = callback_.lock();
|
||||
InterruptForceType forceType = interruptEvent.forceType;
|
||||
MEDIA_DEBUG_LOG("AudioRendererPrivate: OnInterrupt InterruptForceType: %{public}d", forceType);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -95,7 +95,7 @@ void AudioRendererSink::DeInit()
|
||||
int32_t InitAttrs(struct AudioSampleAttributes &attrs)
|
||||
{
|
||||
/* Initialization of audio parameters for playback */
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
attrs.format = AUDIO_FORMAT_PCM_32_BIT;
|
||||
attrs.frameSize = PCM_32_BIT * attrs.channelCount / PCM_8_BIT;
|
||||
#else
|
||||
@@ -117,7 +117,7 @@ int32_t InitAttrs(struct AudioSampleAttributes &attrs)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SwitchAdapter(struct AudioAdapterDescriptor *descs, string adapterNameCase,
|
||||
static int32_t SwitchAdapterRender(struct AudioAdapterDescriptor *descs, string adapterNameCase,
|
||||
enum AudioPortDirection portFlag, struct AudioPort &renderPort, int32_t size)
|
||||
{
|
||||
if (descs == nullptr) {
|
||||
@@ -139,7 +139,7 @@ static int32_t SwitchAdapter(struct AudioAdapterDescriptor *descs, string adapte
|
||||
}
|
||||
}
|
||||
}
|
||||
MEDIA_ERR_LOG("SwitchAdapter Fail");
|
||||
MEDIA_ERR_LOG("SwitchAdapterRender Fail");
|
||||
|
||||
return ERR_INVALID_INDEX;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ int32_t AudioRendererSink::CreateRender(struct AudioPort &renderPort)
|
||||
int32_t AudioRendererSink::Init(AudioSinkAttr &attr)
|
||||
{
|
||||
attr_ = attr;
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
string adapterNameCase = "internal"; // Set sound card information
|
||||
#else
|
||||
string adapterNameCase = "usb"; // Set sound card information
|
||||
@@ -222,7 +222,7 @@ int32_t AudioRendererSink::Init(AudioSinkAttr &attr)
|
||||
}
|
||||
|
||||
// Get qualified sound card and port
|
||||
int32_t index = SwitchAdapter(descs, adapterNameCase, port, audioPort, size);
|
||||
int32_t index = SwitchAdapterRender(descs, adapterNameCase, port, audioPort_, size);
|
||||
if (index < 0) {
|
||||
MEDIA_ERR_LOG("Switch Adapter Fail");
|
||||
return ERR_NOT_STARTED;
|
||||
@@ -245,12 +245,12 @@ int32_t AudioRendererSink::Init(AudioSinkAttr &attr)
|
||||
return ERR_NOT_STARTED;
|
||||
}
|
||||
|
||||
if (CreateRender(audioPort) != 0) {
|
||||
MEDIA_ERR_LOG("Create render faied");
|
||||
if (CreateRender(audioPort_) != 0) {
|
||||
MEDIA_ERR_LOG("Create render failed, Audio Port: %{public}d", audioPort_.portId);
|
||||
return ERR_NOT_STARTED;
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
ret = OpenOutput(DEVICE_TYPE_SPEAKER);
|
||||
if (ret < 0) {
|
||||
MEDIA_ERR_LOG("AudioRendererSink: Update route FAILED: %{public}d", ret);
|
||||
@@ -367,7 +367,7 @@ int32_t AudioRendererSink::GetLatency(uint32_t *latency)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
static AudioCategory GetAudioCategory(AudioScene audioScene)
|
||||
{
|
||||
AudioCategory audioCategory;
|
||||
@@ -436,7 +436,7 @@ int32_t AudioRendererSink::OpenOutput(DeviceType outputDevice)
|
||||
source.ext.mix.moduleId = 0;
|
||||
source.ext.mix.streamId = INTERNAL_OUTPUT_STREAM_ID;
|
||||
|
||||
sink.portId = audioPort.portId;
|
||||
sink.portId = audioPort_.portId;
|
||||
sink.role = AUDIO_PORT_SINK_ROLE;
|
||||
sink.type = AUDIO_PORT_DEVICE_TYPE;
|
||||
sink.ext.device.moduleId = 0;
|
||||
@@ -466,7 +466,7 @@ int32_t AudioRendererSink::SetAudioScene(AudioScene audioScene)
|
||||
return ERR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
int32_t ret = OpenOutput(DEVICE_TYPE_SPEAKER);
|
||||
if (ret < 0) {
|
||||
MEDIA_ERR_LOG("AudioRendererSink: Update route FAILED: %{public}d", ret);
|
||||
@@ -475,8 +475,8 @@ int32_t AudioRendererSink::SetAudioScene(AudioScene audioScene)
|
||||
struct AudioSceneDescriptor scene;
|
||||
scene.scene.id = GetAudioCategory(audioScene);
|
||||
scene.desc.pins = PIN_OUT_SPEAKER;
|
||||
if (audioRender_->scene.SelectScene == NULL) {
|
||||
MEDIA_ERR_LOG("AudioRendererSink: Select scene NULL");
|
||||
if (audioRender_->scene.SelectScene == nullptr) {
|
||||
MEDIA_ERR_LOG("AudioRendererSink: Select scene nullptr");
|
||||
return ERR_OPERATION_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -36,12 +36,12 @@ public:
|
||||
int32_t SetAudioStreamInfo(const AudioStreamParams info);
|
||||
int32_t GetAudioStreamInfo(AudioStreamParams &info);
|
||||
|
||||
int32_t GetAudioSessionID(uint32_t &sessionID);
|
||||
int32_t GetAudioSessionID(uint32_t &sessionID) const;
|
||||
State GetState();
|
||||
bool GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base);
|
||||
int32_t GetBufferSize(size_t &bufferSize);
|
||||
int32_t GetFrameCount(uint32_t &frameCount);
|
||||
int32_t GetLatency(uint64_t &latency);
|
||||
bool GetAudioTime(Timestamp ×tamp, Timestamp::Timestampbase base) const;
|
||||
int32_t GetBufferSize(size_t &bufferSize) const;
|
||||
int32_t GetFrameCount(uint32_t &frameCount) const;
|
||||
int32_t GetLatency(uint64_t &latency) const;
|
||||
static AudioStreamType GetStreamType(ContentType contentType, StreamUsage streamUsage);
|
||||
int32_t SetAudioStreamType(AudioStreamType audioStreamType);
|
||||
int32_t SetVolume(float volume);
|
||||
@@ -56,10 +56,10 @@ public:
|
||||
int32_t Enqueue(const BufferDesc &bufDesc);
|
||||
int32_t Clear();
|
||||
|
||||
std::vector<AudioSampleFormat> GetSupportedFormats();
|
||||
std::vector<AudioChannel> GetSupportedChannels();
|
||||
std::vector<AudioEncodingType> GetSupportedEncodingTypes();
|
||||
std::vector<AudioSamplingRate> GetSupportedSamplingRates();
|
||||
std::vector<AudioSampleFormat> GetSupportedFormats() const;
|
||||
std::vector<AudioChannel> GetSupportedChannels() const;
|
||||
std::vector<AudioEncodingType> GetSupportedEncodingTypes() const;
|
||||
std::vector<AudioSamplingRate> GetSupportedSamplingRates() const;
|
||||
|
||||
// Common APIs
|
||||
bool StartAudioStream();
|
||||
@@ -90,14 +90,8 @@ private:
|
||||
bool isReadyToWrite_;
|
||||
void WriteBuffers();
|
||||
|
||||
static constexpr AudioStreamType streamTypeMap_[CONTENT_TYPE_RINGTONE + 1][STREAM_USAGE_VOICE_ASSISTANT + 1] = {
|
||||
{STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
|
||||
{STREAM_MUSIC, STREAM_VOICE_ASSISTANT, STREAM_VOICE_CALL, STREAM_MUSIC, STREAM_VOICE_ASSISTANT},
|
||||
{STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC, STREAM_RING, STREAM_VOICE_ASSISTANT},
|
||||
{STREAM_MEDIA, STREAM_MEDIA, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
|
||||
{STREAM_NOTIFICATION, STREAM_NOTIFICATION, STREAM_MUSIC, STREAM_MUSIC, STREAM_MUSIC},
|
||||
{STREAM_RING, STREAM_RING, STREAM_MUSIC, STREAM_RING, STREAM_MUSIC}
|
||||
};
|
||||
static const std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> streamTypeMap_;
|
||||
static std::map<std::pair<ContentType, StreamUsage>, AudioStreamType> CreateStreamMap();
|
||||
};
|
||||
} // namespace AudioStandard
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -42,6 +42,9 @@ static SLresult CreateAudioPlayer(
|
||||
}
|
||||
ClassTable *audioPlayerClass = ObjectIdToClass(SL_OBJECTID_AUDIOPLAYER);
|
||||
CAudioPlayer *thiz = (CAudioPlayer *) Construct(audioPlayerClass, self);
|
||||
if (thiz == nullptr) {
|
||||
return SL_RESULT_PARAMETER_INVALID;
|
||||
}
|
||||
thiz->mId = audioplayerId;
|
||||
IObjectInit(&thiz->mObject);
|
||||
IPlayInit(&thiz->mPlay, audioplayerId);
|
||||
@@ -92,6 +95,9 @@ static SLresult CreateOutputMix(
|
||||
}
|
||||
ClassTable *outputMixClass = ObjectIdToClass(SL_OBJECTID_OUTPUTMIX);
|
||||
COutputMix *thiz = (COutputMix *) Construct(outputMixClass, self);
|
||||
if (thiz == nullptr) {
|
||||
return SL_RESULT_PARAMETER_INVALID;
|
||||
}
|
||||
IObjectInit(&thiz->mObject);
|
||||
*pMix = &thiz->mObject.mItf;
|
||||
return SL_RESULT_SUCCESS;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -24,6 +24,9 @@ SLresult SLAPIENTRY slCreateEngine(SLObjectItf *pEngine, SLuint32 numOptions,
|
||||
}
|
||||
ClassTable *engineClass = ObjectIdToClass(SL_OBJECTID_ENGINE);
|
||||
CEngine *thiz = (CEngine *) Construct(engineClass, nullptr);
|
||||
if (thiz == nullptr) {
|
||||
return SL_RESULT_PARAMETER_INVALID;
|
||||
}
|
||||
IObjectInit(&thiz->mObject);
|
||||
IEngineInit(&thiz->mEngine);
|
||||
*pEngine = &thiz->mObject.mItf;
|
||||
@@ -45,6 +48,9 @@ ClassTable *ObjectIdToClass(SLuint32 objectId)
|
||||
|
||||
IObject *Construct(const ClassTable *classTable, SLEngineItf engine)
|
||||
{
|
||||
if (classTable == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
IObject *thiz = (IObject *) calloc(1, classTable->mSize);
|
||||
if (thiz != nullptr) {
|
||||
IEngine *thisEngine = (IEngine *) engine;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -28,4 +28,4 @@ ClassTable AudioPlayerTab = {
|
||||
ClassTable OutputMixTab = {
|
||||
SL_OBJECTID_OUTPUTMIX,
|
||||
sizeof(CAudioPlayer),
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -13,38 +13,43 @@
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
pulseaudio_build_path = "//foundation/multimedia/audio_standard/frameworks/native/pulseaudio"
|
||||
libsndfile_build_path = "//foundation/multimedia/audio_standard/frameworks/native/libsnd"
|
||||
pulseaudio_build_path =
|
||||
"//foundation/multimedia/audio_standard/frameworks/native/pulseaudio"
|
||||
libsndfile_build_path =
|
||||
"//foundation/multimedia/audio_standard/frameworks/native/libsnd"
|
||||
|
||||
group("pulseaudio_packages") {
|
||||
deps = [
|
||||
# ":gen_config_header",
|
||||
"$libsndfile_build_path:sndfile",
|
||||
"$pulseaudio_build_path/src:pulsecommon",
|
||||
"$pulseaudio_build_path/src/pulse:pulse",
|
||||
"$pulseaudio_build_path/src:pa_client_config",
|
||||
"$pulseaudio_build_path/src:pa_daemon_config",
|
||||
"$pulseaudio_build_path/src:pa_default_config",
|
||||
"$pulseaudio_build_path/src:pa_client_config",
|
||||
"$pulseaudio_build_path/src/pulse:pulse-simple",
|
||||
"$pulseaudio_build_path/src/pulse:pulse-mainloop-glib",
|
||||
"$pulseaudio_build_path/src/pulsecore:pulsecore",
|
||||
"$pulseaudio_build_path/src/pulsecore:protocol-native",
|
||||
"$pulseaudio_build_path/src/pulsecore:cli",
|
||||
"$pulseaudio_build_path/src/pulsecore:protocol-cli",
|
||||
"$pulseaudio_build_path/src:pulsecommon",
|
||||
"$pulseaudio_build_path/src/daemon:pulseaudio",
|
||||
"$pulseaudio_build_path/src/utils:pacmd",
|
||||
"$pulseaudio_build_path/src/utils:pacat",
|
||||
"$pulseaudio_build_path/src/utils:pactl",
|
||||
"$pulseaudio_build_path/src/modules:modules",
|
||||
"$pulseaudio_build_path/src/modules/hdi:module-hdi-sink",
|
||||
"$pulseaudio_build_path/src/modules/hdi:module-hdi-source",
|
||||
"$pulseaudio_build_path/src/pulse:pulse",
|
||||
"$pulseaudio_build_path/src/pulse:pulse-mainloop-glib",
|
||||
"$pulseaudio_build_path/src/pulse:pulse-simple",
|
||||
"$pulseaudio_build_path/src/pulsecore:cli",
|
||||
"$pulseaudio_build_path/src/pulsecore:protocol-cli",
|
||||
"$pulseaudio_build_path/src/pulsecore:protocol-native",
|
||||
"$pulseaudio_build_path/src/pulsecore:pulsecore",
|
||||
"$pulseaudio_build_path/src/utils:pacat",
|
||||
"$pulseaudio_build_path/src/utils:pacmd",
|
||||
"$pulseaudio_build_path/src/utils:pactl",
|
||||
]
|
||||
}
|
||||
|
||||
action("gen_config_header") {
|
||||
script = "$pulseaudio_build_path/ohos_paconfig.sh"
|
||||
|
||||
args = [ rebase_path("//third_party/pulseaudio", root_build_dir), rebase_path( "${target_gen_dir}/", root_build_dir),]
|
||||
args = [
|
||||
rebase_path("//third_party/pulseaudio", root_build_dir),
|
||||
rebase_path("${target_gen_dir}/", root_build_dir),
|
||||
]
|
||||
|
||||
outputs = [ "${target_gen_dir}/config.h", ]
|
||||
outputs = [ "${target_gen_dir}/config.h" ]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -51,8 +51,8 @@ ohos_shared_library("module-hdi-sink") {
|
||||
configs = [ ":hdi_config" ]
|
||||
|
||||
cflags = [ "-DPA_MODULE_NAME=libmodule_hdi_sink_z_so" ]
|
||||
if (device_name == "baltimore") {
|
||||
cflags += [ "-DDEVICE_BALTIMORE" ]
|
||||
if ("${product_name}" == "m40") {
|
||||
cflags += [ "-DPRODUCT_M40" ]
|
||||
}
|
||||
|
||||
ldflags = [
|
||||
@@ -82,12 +82,10 @@ ohos_shared_library("module-hdi-source") {
|
||||
configs = [ ":hdi_config" ]
|
||||
|
||||
cflags = [ "-DPA_MODULE_NAME=libmodule_hdi_source_z_so" ]
|
||||
if (device_name == "baltimore") {
|
||||
cflags += [ "-DDEVICE_BALTIMORE" ]
|
||||
}
|
||||
|
||||
if (device_name == "rk3568") {
|
||||
cflags += [ "-DDEVICE_RK3568" ]
|
||||
if ("${product_name}" == "m40") {
|
||||
cflags += [ "-DPRODUCT_M40" ]
|
||||
} else if ("${product_name}" == "rk3568") {
|
||||
cflags += [ "-DPRODUCT_RK3568" ]
|
||||
}
|
||||
|
||||
deps = [
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -139,8 +139,9 @@ static void ProcessRenderUseTiming(struct Userdata *u, pa_usec_t now)
|
||||
u->bytes_dropped = 0;
|
||||
}
|
||||
|
||||
if (u->bytes_dropped == 0 && dropped != 0)
|
||||
if (u->bytes_dropped == 0 && dropped != 0) {
|
||||
MEDIA_INFO_LOG("HDI-sink just dropped %zu bytes", dropped);
|
||||
}
|
||||
|
||||
u->bytes_dropped += dropped;
|
||||
|
||||
@@ -166,11 +167,13 @@ static void ThreadFuncUseTiming(void *userdata)
|
||||
pa_usec_t now = 0;
|
||||
int ret;
|
||||
|
||||
if (PA_SINK_IS_RUNNING(u->sink->thread_info.state))
|
||||
if (PA_SINK_IS_RUNNING(u->sink->thread_info.state)) {
|
||||
now = pa_rtclock_now();
|
||||
}
|
||||
|
||||
if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
|
||||
if (PA_UNLIKELY(u->sink->thread_info.rewind_requested)) {
|
||||
pa_sink_process_rewind(u->sink, 0);
|
||||
}
|
||||
|
||||
// Render some data and drop it immediately
|
||||
if (PA_SINK_IS_RUNNING(u->sink->thread_info.state)) {
|
||||
@@ -178,12 +181,14 @@ static void ThreadFuncUseTiming(void *userdata)
|
||||
ProcessRenderUseTiming(u, now);
|
||||
|
||||
pa_rtpoll_set_timer_absolute(u->rtpoll, u->timestamp);
|
||||
} else
|
||||
} else {
|
||||
pa_rtpoll_set_timer_disabled(u->rtpoll);
|
||||
}
|
||||
|
||||
// Hmm, nothing to do. Let's sleep
|
||||
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0)
|
||||
if ((ret = pa_rtpoll_run(u->rtpoll)) < 0) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
goto finish;
|
||||
@@ -201,7 +206,7 @@ finish:
|
||||
MEDIA_INFO_LOG("Thread (use timing) shutting down");
|
||||
}
|
||||
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
static void SinkUpdateRequestedLatencyCb(pa_sink *s)
|
||||
{
|
||||
struct Userdata *u = NULL;
|
||||
@@ -325,11 +330,7 @@ static int32_t PrepareDevice(struct Userdata *u)
|
||||
{
|
||||
SinkAttr sample_attrs;
|
||||
int32_t ret;
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
sample_attrs.format = AUDIO_FORMAT_PCM_32_BIT;
|
||||
#else
|
||||
sample_attrs.format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
#endif
|
||||
|
||||
enum AudioFormat format = ConvertToHDIAudioFormat(u->ss.format);
|
||||
sample_attrs.format = format;
|
||||
sample_attrs.sampleFmt = format;
|
||||
@@ -437,7 +438,7 @@ pa_sink *PaHdiSinkNew(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
|
||||
u->sink->parent.process_msg = SinkProcessMsg;
|
||||
u->sink->set_state_in_io_thread = SinkSetStateInIoThreadCb;
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
u->sink->update_requested_latency = SinkUpdateRequestedLatencyCb;
|
||||
#endif
|
||||
u->sink->userdata = u;
|
||||
@@ -453,26 +454,22 @@ pa_sink *PaHdiSinkNew(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
}
|
||||
|
||||
u->block_usec = pa_bytes_to_usec(u->buffer_size, &u->sink->sample_spec);
|
||||
#ifdef DEVICE_BALTIMORE
|
||||
#ifdef PRODUCT_M40
|
||||
pa_sink_set_latency_range(u->sink, 0, u->block_usec);
|
||||
#else
|
||||
pa_sink_set_fixed_latency(u->sink, u->block_usec);
|
||||
#endif
|
||||
pa_sink_set_max_request(u->sink, u->buffer_size);
|
||||
|
||||
threadName = pa_sprintf_malloc("hdi-sink-playback");
|
||||
threadName = "hdi-sink-playback";
|
||||
if (!(u->thread = pa_thread_new(threadName, ThreadFuncUseTiming, u))) {
|
||||
MEDIA_ERR_LOG("Failed to create thread.");
|
||||
goto fail;
|
||||
}
|
||||
pa_xfree(threadName);
|
||||
threadName = NULL;
|
||||
|
||||
pa_sink_put(u->sink);
|
||||
|
||||
return u->sink;
|
||||
fail:
|
||||
pa_xfree(threadName);
|
||||
UserdataFree(u);
|
||||
|
||||
return NULL;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -330,7 +330,7 @@ static int pa_set_source_properties(pa_module *m, pa_modargs *ma, const pa_sampl
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef DEVICE_RK3568
|
||||
#ifndef PRODUCT_RK3568
|
||||
static enum AudioFormat ConvertToHDIAudioFormat(pa_sample_format_t format)
|
||||
{
|
||||
enum AudioFormat hdiAudioFormat;
|
||||
@@ -376,7 +376,7 @@ static bool GetEndianInfo(pa_sample_format_t format)
|
||||
|
||||
return isBigEndian;
|
||||
}
|
||||
#endif // #ifndef DEVICE_RK3568
|
||||
#endif // #ifndef PRODUCT_RK3568
|
||||
|
||||
pa_source *pa_hdi_source_new(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
{
|
||||
@@ -395,10 +395,12 @@ pa_source *pa_hdi_source_new(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
/* Override with modargs if provided */
|
||||
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
|
||||
MEDIA_INFO_LOG("Failed to parse sample specification and channel map");
|
||||
goto fail;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
u = pa_xnew0(struct Userdata, 1);
|
||||
pa_assert(u);
|
||||
|
||||
u->core = m->core;
|
||||
u->module = m;
|
||||
u->rtpoll = pa_rtpoll_new();
|
||||
@@ -411,7 +413,7 @@ pa_source *pa_hdi_source_new(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
u->buffer_size = DEFAULT_BUFFER_SIZE;
|
||||
u->attrs.sampleRate = ss.rate;
|
||||
// The values for rk are hardcoded due to config mismatch in hdi. To be removed once hdi issue is fixed.
|
||||
#ifdef DEVICE_RK3568
|
||||
#ifdef PRODUCT_RK3568
|
||||
int32_t channelCount = 2;
|
||||
u->attrs.channel = channelCount;
|
||||
u->attrs.format = AUDIO_FORMAT_PCM_16_BIT;
|
||||
@@ -437,26 +439,21 @@ pa_source *pa_hdi_source_new(pa_module *m, pa_modargs *ma, const char *driver)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
thread_name = pa_sprintf_malloc("hdi-source-record");
|
||||
thread_name = "hdi-source-record";
|
||||
if (!(u->thread = pa_thread_new(thread_name, thread_func, u))) {
|
||||
MEDIA_INFO_LOG("Failed to create hdi-source-record thread!");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_xfree(thread_name);
|
||||
thread_name = NULL;
|
||||
pa_source_put(u->source);
|
||||
return u->source;
|
||||
|
||||
fail:
|
||||
pa_xfree(thread_name);
|
||||
|
||||
if (u) {
|
||||
if (u->IsCapturerStarted) {
|
||||
pa_capturer_exit();
|
||||
}
|
||||
userdata_free(u);
|
||||
if (u->IsCapturerStarted) {
|
||||
pa_capturer_exit();
|
||||
}
|
||||
userdata_free(u);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -62,8 +62,9 @@ int pa__init(pa_module *m)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!(m->userdata = pa_hdi_source_new(m, ma, __FILE__)))
|
||||
if (!(m->userdata = pa_hdi_source_new(m, ma, __FILE__))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pa_modargs_free(ma);
|
||||
|
||||
@@ -71,8 +72,9 @@ int pa__init(pa_module *m)
|
||||
|
||||
fail:
|
||||
|
||||
if (ma)
|
||||
if (ma) {
|
||||
pa_modargs_free(ma);
|
||||
}
|
||||
|
||||
pa__done(m);
|
||||
|
||||
@@ -95,6 +97,7 @@ void pa__done(pa_module *m)
|
||||
|
||||
pa_assert(m);
|
||||
|
||||
if ((source = m->userdata))
|
||||
if ((source = m->userdata)) {
|
||||
pa_hdi_source_free(source);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -31,6 +31,7 @@ constexpr int32_t MAX_NUM_STREAMS = 3;
|
||||
constexpr int32_t RENDERER_STREAM_USAGE_SHIFT = 16;
|
||||
constexpr int32_t MINIMUM_BUFFER_SIZE_MSEC = 5;
|
||||
constexpr int32_t MAXIMUM_BUFFER_SIZE_MSEC = 20;
|
||||
constexpr int32_t MIN_SERVICE_COUNT = 2;
|
||||
|
||||
|
||||
enum DeviceFlag {
|
||||
@@ -283,8 +284,8 @@ enum StreamUsage {
|
||||
STREAM_USAGE_UNKNOWN = 0,
|
||||
STREAM_USAGE_MEDIA = 1,
|
||||
STREAM_USAGE_VOICE_COMMUNICATION = 2,
|
||||
STREAM_USAGE_NOTIFICATION_RINGTONE = 3,
|
||||
STREAM_USAGE_VOICE_ASSISTANT = 4
|
||||
STREAM_USAGE_VOICE_ASSISTANT = 4,
|
||||
STREAM_USAGE_NOTIFICATION_RINGTONE = 6
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -517,6 +518,11 @@ struct InterruptAction {
|
||||
InterruptType interruptType;
|
||||
InterruptHint interruptHint;
|
||||
};
|
||||
|
||||
enum AudioServiceIndex {
|
||||
HDI_SERVICE_INDEX = 0,
|
||||
AUDIO_SERVICE_INDEX
|
||||
};
|
||||
} // namespace AudioStandard
|
||||
} // namespace OHOS
|
||||
#endif // AUDIO_INFO_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
bool IsMicrophoneMute(void) const;
|
||||
std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag);
|
||||
const std::string GetAudioParameter(const std::string key) const;
|
||||
void SetAudioParameter(const std::string key, const std::string value) const;
|
||||
void SetAudioParameter(const std::string &key, const std::string &value) const;
|
||||
const char *RetrieveCookie(int32_t &size) const;
|
||||
int32_t SetDeviceActive(ActiveDeviceType deviceType, bool flag) const;
|
||||
bool IsDeviceActive(ActiveDeviceType deviceType) const;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user