codehub issues fix

Signed-off-by: Anoop Kant <anoop.kant@huawei.com>
This commit is contained in:
Anoop Kant 2022-03-23 11:58:52 +05:30
parent c1a5d95bc4
commit b55ae4b43d
35 changed files with 192 additions and 114 deletions

View File

@ -121,7 +121,7 @@ static void NativeVolumeEventToJsObj(const napi_env& env, napi_value& jsObj,
void AudioVolumeKeyEventNapi::OnJsCallbackVolumeEvent(std::unique_ptr<AudioVolumeKeyEventJsCallback> &jsCb)
{
MEDIA_ERR_LOG("AudioVolumeKeyEventNapi:OnJsCallbackVolumeEvent");
MEDIA_INFO_LOG("AudioVolumeKeyEventNapi:OnJsCallbackVolumeEvent");
uv_loop_s *loop = nullptr;
napi_get_uv_event_loop(env_, &loop);
if (loop == nullptr) {

View File

@ -320,5 +320,5 @@ napi_value AudioRendererInfoNapi::SetRendererFlags(napi_env env, napi_callback_i
return jsResult;
}
}
}
} // namespace AudioStandard
} // namespace OHOS

View File

@ -252,5 +252,5 @@ napi_value RingtoneOptionsNapi::SetLoop(napi_env env, napi_callback_info info)
return jsResult;
}
}
}
} // namespace AudioStandard
} // namespace OHOS

View File

@ -36,7 +36,7 @@ public:
virtual void OnSessionRemoved(const uint32_t sessionID) = 0;
virtual ~AudioServiceAdapterCallback() {};
virtual ~AudioServiceAdapterCallback() {}
};
class AudioServiceAdapter {

View File

@ -25,7 +25,7 @@ namespace OHOS {
namespace AudioStandard {
class PulseAudioServiceAdapterImpl : public AudioServiceAdapter {
public:
PulseAudioServiceAdapterImpl(std::unique_ptr<AudioServiceAdapterCallback> &cb);
explicit PulseAudioServiceAdapterImpl(std::unique_ptr<AudioServiceAdapterCallback> &cb);
~PulseAudioServiceAdapterImpl();
bool Connect() override;

View File

@ -90,14 +90,6 @@ 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 != nullptr) {
pa_context_disconnect(mContext);
pa_context_set_state_callback(mContext, nullptr, nullptr);
@ -560,7 +552,7 @@ void PulseAudioServiceAdapterImpl::PaGetSinkInputInfoVolumeCb(pa_context *c, con
UserData *userData = reinterpret_cast<UserData*>(userdata);
PulseAudioServiceAdapterImpl *thiz = userData->thiz;
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] GetSinkInputInfoVolumeCb");
MEDIA_INFO_LOG("[PulseAudioServiceAdapterImpl] GetSinkInputInfoVolumeCb");
if (eol < 0) {
delete userData;
MEDIA_ERR_LOG("[PulseAudioServiceAdapterImpl] Failed to get sink input information: %{public}s",

View File

@ -92,7 +92,7 @@ void AudioRendererSink::DeInit()
#endif // DUMPFILE
}
int32_t InitAttrs(struct AudioSampleAttributes &attrs)
void InitAttrs(struct AudioSampleAttributes &attrs)
{
/* Initialization of audio parameters for playback */
#ifdef PRODUCT_M40
@ -113,8 +113,6 @@ int32_t InitAttrs(struct AudioSampleAttributes &attrs)
attrs.startThreshold = DEEP_BUFFER_RENDER_PERIOD_SIZE / (attrs.frameSize);
attrs.stopThreshold = INT_32_MAX;
attrs.silenceThreshold = 0;
return SUCCESS;
}
static int32_t SwitchAdapterRender(struct AudioAdapterDescriptor *descs, string adapterNameCase,
@ -169,7 +167,7 @@ uint32_t PcmFormatToBits(enum AudioFormat format)
return PCM_32_BIT;
default:
return PCM_24_BIT;
};
}
}
int32_t AudioRendererSink::CreateRender(struct AudioPort &renderPort)
@ -182,7 +180,7 @@ int32_t AudioRendererSink::CreateRender(struct AudioPort &renderPort)
param.format = attr_.format;
param.frameSize = PcmFormatToBits(param.format) * param.channelCount / PCM_8_BIT;
param.startThreshold = DEEP_BUFFER_RENDER_PERIOD_SIZE / (param.frameSize);
MEDIA_ERR_LOG("AudioRendererSink Create render format: %{public}d", param.format);
MEDIA_INFO_LOG("AudioRendererSink Create render format: %{public}d", param.format);
struct AudioDeviceDescriptor deviceDesc;
deviceDesc.portId = renderPort.portId;
deviceDesc.pins = PIN_OUT_SPEAKER;

View File

@ -94,7 +94,7 @@ void BluetoothRendererSink::DeInit()
#endif // BT_DUMPFILE
}
int32_t InitAttrs(struct AudioSampleAttributes &attrs)
void InitAttrs(struct AudioSampleAttributes &attrs)
{
/* Initialization of audio parameters for playback */
attrs.format = AUDIO_FORMAT_PCM_16_BIT;
@ -109,8 +109,6 @@ int32_t InitAttrs(struct AudioSampleAttributes &attrs)
attrs.startThreshold = DEEP_BUFFER_RENDER_PERIOD_SIZE / (attrs.frameSize);
attrs.stopThreshold = INT_32_MAX;
attrs.silenceThreshold = 0;
return SUCCESS;
}
static int32_t SwitchAdapter(struct AudioAdapterDescriptor *descs, string adapterNameCase,
@ -199,7 +197,7 @@ int32_t BluetoothRendererSink::CreateRender(struct AudioPort &renderPort)
param.format = attr_.format;
param.frameSize = PcmFormatToBits(param.format) * param.channelCount / PCM_8_BIT;
param.startThreshold = DEEP_BUFFER_RENDER_PERIOD_SIZE / (param.frameSize);
MEDIA_ERR_LOG("BluetoothRendererSink Create render format: %{public}d", param.format);
MEDIA_INFO_LOG("BluetoothRendererSink Create render format: %{public}d", param.format);
struct AudioDeviceDescriptor deviceDesc;
deviceDesc.portId = renderPort.portId;
deviceDesc.pins = PIN_OUT_SPEAKER;

View File

@ -238,6 +238,7 @@ static int SinkProcessMsg(pa_msgobject *o, int code, void *data, int64_t offset,
pa_memchunk *chunk)
{
struct Userdata *u = PA_SINK(o)->userdata;
pa_assert(u);
switch (code) {
case PA_SINK_MESSAGE_GET_LATENCY: {
uint64_t latency;
@ -342,7 +343,7 @@ static int32_t PrepareDevice(struct Userdata *u)
enum AudioFormat format = ConvertToHDIAudioFormat(u->ss.format);
sample_attrs.format = format;
sample_attrs.sampleFmt = format;
MEDIA_ERR_LOG("audiorenderer format: %d", sample_attrs.format);
MEDIA_INFO_LOG("audiorenderer format: %d", sample_attrs.format);
sample_attrs.sampleRate = u->ss.rate;
sample_attrs.channel = u->ss.channels;
@ -420,6 +421,7 @@ pa_sink *PaHdiSinkNew(pa_module *m, pa_modargs *ma, const char *driver)
pa_assert(ma);
u = pa_xnew0(struct Userdata, 1);
pa_assert(u);
u->core = m->core;
u->module = m;

View File

@ -97,6 +97,7 @@ static void userdata_free(struct Userdata *u)
static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk)
{
struct Userdata *u = PA_SOURCE(o)->userdata;
pa_assert(u);
switch (code) {
case PA_SOURCE_MESSAGE_GET_LATENCY: {

View File

@ -116,6 +116,6 @@ public:
*/
virtual int32_t Release() = 0;
};
} // AudioStandard
} // OHOS
} // namespace AudioStandard
} // namespace OHOS
#endif // IRINGTONE_PLAYER_H

View File

@ -132,6 +132,6 @@ private:
std::shared_ptr<CapturerPeriodPositionCallback> periodPositionCBNapi_ = nullptr;
std::shared_ptr<AudioCapturerCallback> callbackNapi_ = nullptr;
};
}
}
} // namespace AudioStandard
} // namespace OHOS
#endif /* AUDIO_CAPTURER_NAPI_H_ */

View File

@ -190,6 +190,6 @@ static const std::map<std::string, RendererState> audioStateMap = {
{"STATE_RELEASED", RENDERER_RELEASED},
{"STATE_PAUSED", RENDERER_PAUSED}
};
}
}
} // namespace AudioStandard
} // namespace OHOS
#endif /* AUDIO_RENDERER_NAPI_H_ */

View File

@ -78,6 +78,6 @@ public:
public:
DECLARE_INTERFACE_DESCRIPTOR(u"IAudioPolicy");
};
} // AudioStandard
} // namespace AudioStandard
} // namespace OHOS
#endif // I_AUDIO_POLICY_BASE_H

View File

@ -53,6 +53,6 @@ private:
void GetDevicesInternal(MessageParcel &data, MessageParcel &reply);
void SetDeviceChangeCallbackInternal(MessageParcel &data, MessageParcel &reply);
};
} // AudioStandard
} // namespace AudioStandard
} // namespace OHOS
#endif // AUDIO_POLICY_MANAGER_STUB_H

View File

@ -35,7 +35,7 @@ template <typename...Args>
void AppendFormat(std::string& out, const char* fmt, Args&& ... args)
{
char buf[STRING_BUFFER_SIZE] = {0};
int len = ::snprintf_s(buf, sizeof(buf), sizeof(buf)-1, fmt, args...);
int len = ::sprintf_s(buf, sizeof(buf), fmt, args...);
if (len <= 0) {
MEDIA_ERR_LOG("snprintf_s error : buffer allocation fails");
return;
@ -103,14 +103,14 @@ private:
pa_mainloop_api *api;
pa_context *context;
std::mutex ctrlMutex;
bool isMainLoopStarted;
bool isContextConnected;
AudioData audioData_;
int32_t ConnectStreamToPA();
void ResetPAAudioDump();
void PlaybackStreamDump(std::string &dumpString);
void RecordStreamDump(std::string &dumpString);
void HDFModulesDump(std::string &dumpString);
@ -126,7 +126,7 @@ private:
static const std::string GetDeviceTypeName(DeviceType deviceType);
static bool IsEndWith(const std::string &mainStr, const std::string &toMatch);
static bool IsValidModule (const std::string moduleName);
// Callbacks
static void PAContextStateCb(pa_context *context, void *userdata);
static void PASinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, void *userdata);

View File

@ -23,7 +23,7 @@ namespace OHOS {
namespace AudioStandard {
class AudioServerDeathRecipient : public IRemoteObject::DeathRecipient {
public:
explicit AudioServerDeathRecipient(pid_t pid) : pid_(pid) {};
explicit AudioServerDeathRecipient(pid_t pid) : pid_(pid) {}
virtual ~AudioServerDeathRecipient() = default;
DISALLOW_COPY_AND_MOVE(AudioServerDeathRecipient);
void OnRemoteDied(const wptr<IRemoteObject> &remote)

View File

@ -161,7 +161,7 @@ int32_t AudioPolicyManager::UnsetRingerModeCallback(const int32_t clientId)
int32_t AudioPolicyManager::SetDeviceChangeCallback(const std::shared_ptr<AudioManagerDeviceChangeCallback> &callback)
{
MEDIA_ERR_LOG("Entered %{public}s", __func__);
MEDIA_INFO_LOG("Entered %{public}s", __func__);
if (callback == nullptr) {
MEDIA_ERR_LOG("AudioPolicyManager: callback is nullptr");
return ERR_INVALID_PARAM;

View File

@ -718,5 +718,5 @@ void AudioServiceDump::PASourceOutputInfoCallback(pa_context *c, const pa_source
}
asDump->audioData_.streamData.sourceOutputs.push_back(sourceOutputInfo);
}
} // namespace AudoStandard
} // namespace AudioStandard
} // namespace OHOS

View File

@ -618,5 +618,5 @@ DeviceRole AudioPolicyService::GetDeviceRole(const std::string &role)
return DeviceRole::DEVICE_ROLE_NONE;
}
}
}
}
} // namespace AudioStandard
} // namespace OHOS

View File

@ -210,5 +210,5 @@ void AudioFocusParser::ParseAllowedStreams(xmlNode *node, char *curStream)
currNode = currNode->next;
}
}
}
}
} // namespace AudioStandard
} // namespace OHOS

View File

@ -33,6 +33,11 @@ bool AudioAdapterManager::ConnectServiceAdapter()
std::unique_ptr<AudioAdapterManager> audioAdapterManager(this);
std::unique_ptr<PolicyCallbackImpl> policyCallbackImpl = std::make_unique<PolicyCallbackImpl>(audioAdapterManager);
mAudioServiceAdapter = AudioServiceAdapter::CreateAudioAdapter(std::move(policyCallbackImpl));
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] Error in audio adapter initialization");
return false;
}
bool result = mAudioServiceAdapter->Connect();
if (!result) {
MEDIA_ERR_LOG("[AudioAdapterManager] Error in connecting audio adapter");
@ -53,6 +58,11 @@ void AudioAdapterManager::InitKVStore()
void AudioAdapterManager::Deinit(void)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return;
}
return mAudioServiceAdapter->Disconnect();
}
@ -69,6 +79,11 @@ int32_t AudioAdapterManager::SetAudioSessionCallback(AudioSessionCallback *callb
int32_t AudioAdapterManager::SetStreamVolume(AudioStreamType streamType, float volume)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return ERR_OPERATION_FAILED;
}
// Incase if KvStore didnot connect during bootup
if (mAudioPolicyKvStore == nullptr) {
bool isFirstBoot = false;
@ -91,27 +106,52 @@ float AudioAdapterManager::GetStreamVolume(AudioStreamType streamType)
int32_t AudioAdapterManager::SetStreamMute(AudioStreamType streamType, bool mute)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return ERR_OPERATION_FAILED;
}
return mAudioServiceAdapter->SetMute(streamType, mute);
}
bool AudioAdapterManager::GetStreamMute(AudioStreamType streamType) const
{
return mAudioServiceAdapter->IsMute(streamType);
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return false;
}
return mAudioServiceAdapter->IsMute(streamType);
}
bool AudioAdapterManager::IsStreamActive(AudioStreamType streamType)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return false;
}
return mAudioServiceAdapter->IsStreamActive(streamType);
}
int32_t AudioAdapterManager::SuspendAudioDevice(std::string &portName, bool isSuspend)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return ERR_OPERATION_FAILED;
}
return mAudioServiceAdapter->SuspendAudioDevice(portName, isSuspend);
}
int32_t AudioAdapterManager::SetDeviceActive(AudioIOHandle ioHandle, InternalDeviceType deviceType,
std::string name, bool active)
{
if (!mAudioServiceAdapter) {
MEDIA_ERR_LOG("[AudioAdapterManager] audio adapter null");
return ERR_OPERATION_FAILED;
}
switch (deviceType) {
case InternalDeviceType::DEVICE_TYPE_SPEAKER:
case InternalDeviceType::DEVICE_TYPE_WIRED_HEADSET:

View File

@ -65,7 +65,7 @@ int32_t AudioManagerProxy::GetMinVolume(AudioSystemManager::AudioVolumeType volu
return error;
}
float volume = reply.ReadInt32();
int32_t volume = reply.ReadInt32();
return volume;
}

View File

@ -187,6 +187,7 @@ void RingtonePlayer::InitialisePlayer()
int32_t RingtonePlayer::PrepareRingtonePlayer(bool isReInitNeeded)
{
MEDIA_INFO_LOG("RingtonePlayer::%{public}s", __func__);
CHECK_AND_RETURN_RET_LOG(player_ != nullptr, ERR_INVALID_PARAM, "Ringtone player instance is null");
// fetch uri from kvstore
auto kvstoreUri = audioRingtoneMgr_.GetSystemRingtoneUri(context_, type_);
@ -299,6 +300,8 @@ RingtoneState RingtonePlayer::GetRingtoneState()
void RingtonePlayer::SetPlayerState(RingtoneState ringtoneState)
{
CHECK_AND_RETURN_LOG(player_ != nullptr, "Ringtone player instance is null");
if (ringtoneState_ != RingtoneState::STATE_RELEASED) {
ringtoneState_ = ringtoneState;
}
@ -380,37 +383,37 @@ void RingtonePlayerCallback::OnError(PlayerErrorType errorType, int32_t errorCod
void RingtonePlayerCallback::OnInfo(PlayerOnInfoType type, int32_t extra, const Format &infoBody)
{
if (type == INFO_TYPE_STATE_CHANGE) {
state_ = static_cast<PlayerStates>(extra);
switch (state_) {
case PLAYER_STATE_ERROR:
ringtoneState_ = STATE_INVALID;
break;
case PLAYER_IDLE:
case PLAYER_INITIALIZED:
case PLAYER_PREPARING:
ringtoneState_ = STATE_NEW;
break;
case PLAYER_PREPARED:
ringtoneState_ = STATE_PREPARED;
break;
case PLAYER_STARTED:
ringtoneState_ = STATE_RUNNING;
break;
case PLAYER_PAUSED:
ringtoneState_ = STATE_PAUSED;
break;
case PLAYER_STOPPED:
case PLAYER_PLAYBACK_COMPLETE:
ringtoneState_ = STATE_STOPPED;
break;
default:
break;
}
ringtonePlayer_.SetPlayerState(ringtoneState_);
if (type != INFO_TYPE_STATE_CHANGE) {
return;
}
state_ = static_cast<PlayerStates>(extra);
switch (state_) {
case PLAYER_STATE_ERROR:
ringtoneState_ = STATE_INVALID;
break;
case PLAYER_IDLE:
case PLAYER_INITIALIZED:
case PLAYER_PREPARING:
ringtoneState_ = STATE_NEW;
break;
case PLAYER_PREPARED:
ringtoneState_ = STATE_PREPARED;
break;
case PLAYER_STARTED:
ringtoneState_ = STATE_RUNNING;
break;
case PLAYER_PAUSED:
ringtoneState_ = STATE_PAUSED;
break;
case PLAYER_STOPPED:
case PLAYER_PLAYBACK_COMPLETE:
ringtoneState_ = STATE_STOPPED;
break;
default:
break;
}
ringtonePlayer_.SetPlayerState(ringtoneState_);
}
} // AudioStandard
} // OHOS
} // namesapce AudioStandard
} // namespace OHOS

View File

@ -135,9 +135,7 @@ pa_sample_spec AudioServiceClient::ConvertToPAAudioParams(AudioStreamParams audi
static size_t AlignToAudioFrameSize(size_t l, const pa_sample_spec &ss)
{
size_t fs;
fs = pa_frame_size(&ss);
size_t fs = pa_frame_size(&ss);
if (fs == 0) {
MEDIA_ERR_LOG(" Error: pa_frame_size returned 0");
return 0;
@ -148,10 +146,11 @@ static size_t AlignToAudioFrameSize(size_t l, const pa_sample_spec &ss)
void AudioServiceClient::PAStreamStartSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (userdata == nullptr) {
MEDIA_ERR_LOG(" Error: userData is null!");
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamStartSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = static_cast<AudioServiceClient *>(userdata);
pa_threaded_mainloop *mainLoop = static_cast<pa_threaded_mainloop *>(asClient->mainLoop);
@ -166,6 +165,11 @@ void AudioServiceClient::PAStreamStartSuccessCb(pa_stream *stream, int32_t succe
void AudioServiceClient::PAStreamStopSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamStopSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = static_cast<AudioServiceClient *>(userdata);
pa_threaded_mainloop *mainLoop = static_cast<pa_threaded_mainloop *>(asClient->mainLoop);
@ -180,6 +184,11 @@ void AudioServiceClient::PAStreamStopSuccessCb(pa_stream *stream, int32_t succes
void AudioServiceClient::PAStreamPauseSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamPauseSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = static_cast<AudioServiceClient *>(userdata);
pa_threaded_mainloop *mainLoop = static_cast<pa_threaded_mainloop *>(asClient->mainLoop);
@ -194,6 +203,11 @@ void AudioServiceClient::PAStreamPauseSuccessCb(pa_stream *stream, int32_t succe
void AudioServiceClient::PAStreamDrainSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamDrainSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = (AudioServiceClient *)userdata;
pa_threaded_mainloop *mainLoop = (pa_threaded_mainloop *)asClient->mainLoop;
@ -203,6 +217,10 @@ void AudioServiceClient::PAStreamDrainSuccessCb(pa_stream *stream, int32_t succe
void AudioServiceClient::PAStreamFlushSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamFlushSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = (AudioServiceClient *)userdata;
pa_threaded_mainloop *mainLoop = (pa_threaded_mainloop *)asClient->mainLoop;
@ -218,6 +236,10 @@ void AudioServiceClient::PAStreamReadCb(pa_stream *stream, size_t length, void *
void AudioServiceClient::PAStreamSetBufAttrSuccessCb(pa_stream *stream, int32_t success, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamSetBufAttrSuccessCb: userdata is null");
return;
}
AudioServiceClient *asClient = (AudioServiceClient *)userdata;
pa_threaded_mainloop *mainLoop = (pa_threaded_mainloop *)asClient->mainLoop;
@ -282,6 +304,11 @@ int32_t AudioServiceClient::SaveWriteCallback(const std::weak_ptr<AudioRendererW
void AudioServiceClient::PAStreamWriteCb(pa_stream *stream, size_t length, void *userdata)
{
MEDIA_INFO_LOG("AudioServiceClient::Inside PA write callback");
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamWriteCb: userdata is null");
return;
}
auto asClient = static_cast<AudioServiceClient *>(userdata);
auto mainLoop = static_cast<pa_threaded_mainloop *>(asClient->mainLoop);
pa_threaded_mainloop_signal(mainLoop, 0);
@ -304,6 +331,11 @@ void AudioServiceClient::PAStreamWriteCb(pa_stream *stream, size_t length, void
void AudioServiceClient::PAStreamUnderFlowCb(pa_stream *stream, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamUnderFlowCb: userdata is null");
return;
}
AudioServiceClient *asClient = (AudioServiceClient *)userdata;
asClient->underFlowCount++;
}
@ -316,6 +348,11 @@ void AudioServiceClient::PAStreamLatencyUpdateCb(pa_stream *stream, void *userda
void AudioServiceClient::PAStreamStateCb(pa_stream *stream, void *userdata)
{
if (!userdata) {
MEDIA_ERR_LOG("AudioServiceClient::PAStreamStateCb: userdata is null");
return;
}
AudioServiceClient *asClient = (AudioServiceClient *)userdata;
pa_threaded_mainloop *mainLoop = (pa_threaded_mainloop *)asClient->mainLoop;

View File

@ -688,5 +688,5 @@ void AudioStream::WriteBuffers()
}
MEDIA_INFO_LOG("AudioStream::WriteBuffers thread end");
}
} // namspace AudioStandard
} // namespace AudioStandard
} // namespace OHOS

View File

@ -273,7 +273,7 @@ bool AudioSystemManager::IsStreamMute(AudioSystemManager::AudioVolumeType volume
int32_t AudioSystemManager::SetDeviceChangeCallback(const std::shared_ptr<AudioManagerDeviceChangeCallback> &callback)
{
MEDIA_ERR_LOG("Entered AudioSystemManager::%{public}s", __func__);
MEDIA_INFO_LOG("Entered AudioSystemManager::%{public}s", __func__);
if (callback == nullptr) {
MEDIA_ERR_LOG("SetDeviceChangeCallback: callback is nullptr");
return ERR_INVALID_PARAM;

View File

@ -82,6 +82,8 @@ int AudioManagerStub::OnRemoteRequest(
if (size > 0) {
MEDIA_DEBUG_LOG("cookie received from server");
reply.WriteRawData(static_cast<const void *>(cookieInfo), size);
free((void *)cookieInfo);
cookieInfo = nullptr;
}
return MEDIA_OK;

View File

@ -99,8 +99,7 @@ const std::string AudioServer::GetAudioParameter(const std::string &key)
if (AudioServer::audioParameters.count(key)) {
return AudioServer::audioParameters[key];
} else {
const std::string value = "";
return value;
return "";
}
}
@ -109,19 +108,25 @@ const char *AudioServer::RetrieveCookie(int32_t &size)
char *cookieInfo = nullptr;
size = 0;
std::ifstream cookieFile(DEFAULT_COOKIE_PATH, std::ifstream::binary);
if (cookieFile) {
cookieFile.seekg (0, cookieFile.end);
size = cookieFile.tellg();
cookieFile.seekg (0, cookieFile.beg);
if ((size > 0) && (size < PATH_MAX)) {
cookieInfo = (char *)malloc(size * sizeof(char));
MEDIA_DEBUG_LOG("Reading: %{public}d characters...", size);
cookieFile.read(cookieInfo, size);
}
cookieFile.close();
if (!cookieFile) {
return cookieInfo;
}
cookieFile.seekg (0, cookieFile.end);
size = cookieFile.tellg();
cookieFile.seekg (0, cookieFile.beg);
if ((size > 0) && (size < PATH_MAX)) {
cookieInfo = (char *)malloc(size * sizeof(char));
if (cookieInfo == nullptr) {
MEDIA_ERR_LOG("AudioServer::RetrieveCookie: No memory");
cookieFile.close();
return cookieInfo;
}
MEDIA_DEBUG_LOG("Reading: %{public}d characters...", size);
cookieFile.read(cookieInfo, size);
}
cookieFile.close();
return cookieInfo;
}

View File

@ -260,8 +260,8 @@ void AudioInterruptTest::SaveStreamInfo(ContentType contentType, StreamUsage str
contentType_ = contentType;
streamUsage_ = streamUsage;
}
} // AudioStandard
} // OHOS
} // namespace AudioStandard
} // namespace OHOS
using namespace OHOS;
using namespace OHOS::AudioStandard;

View File

@ -50,6 +50,6 @@ private:
ContentType contentType_ = ContentType::CONTENT_TYPE_MUSIC;
StreamUsage streamUsage_ = StreamUsage::STREAM_USAGE_MEDIA;
};
} // AudioStandard
} // OHOS
} // namespace AudioStandard
} // namespace OHOS
#endif // AUDIO_INTERRUPT_TEST_H

View File

@ -286,8 +286,8 @@ int32_t InterruptMultiRendererTest::TestPlayback(int argc, char *argv[]) const
return 0;
}
} // AudioStandard
} // OHOS
} // namespace AudioStandard
} // namespace OHOS
using namespace OHOS;
using namespace OHOS::AudioStandard;

View File

@ -39,6 +39,6 @@ private:
const std::shared_ptr<AudioRendererCallbackTestImpl> &cb) const;
int32_t ValidateFile(char *filePath, char path[]) const;
};
} // AudioStandard
} // OHOS
} // namespace AudioStandard
} // namespace OHOS
#endif // INTERRUPT_MULTI_RENDERER_TEST_H

View File

@ -62,7 +62,7 @@ public:
// TearDown: Called after each test cases
void TearDown(void) override;
};
}
}
}
} // namespace V1_0
} // namespace AudioStandard
} // namespace OHOS
#endif // AUDIO_POLICY_TEST_H

View File

@ -563,6 +563,6 @@ INSTANTIATE_TEST_CASE_P(
GetAudioScene,
AudioPolicyGetAudioSceneTest,
ValuesIn(AUDIO_SCENE_PARAMS));
} // V1_0
} // AudioStandard
} // OHOS
} // namespace V1_0
} // namespace AudioStandard
} // namespace OHOS