From 1f7bb8a96e2edc90b149659ddb4feb85254a5ce8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E7=BD=97=E6=AD=A3?= <1732036298@qq.com> Date: Tue, 5 Nov 2024 08:53:56 +0000 Subject: [PATCH] Merge #1342 into sdk602patch0911 from refs/changes/1342/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 罗正 * refs/changes/1342/head: (7 commits squashed) - Applist样式:弧形列表优化UI显示 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 采用WEARABLE_LOGD代替WEARABLE_LOGE,控制log打印 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 1.关闭多余打印(包含player_impl文件的一个打印) 2.解决手表重启立马同步音乐成功后,点击播放按钮不播放需要在切Slice才能播放bug 3.解决在手表只有一首歌曲时候且在播放,手机app删除本地音乐,手表不会会停止当前播放的歌曲bug - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 - 优化手机与手表a2dp连接下,若在音乐播放器界面,手机控制播放暂停,只有在手机音乐才能更新显示 Signed-off-by: 罗正 <1732036298@qq.com> Reviewed-by: Caisking <3449750381@qq.com> Reviewed-by: 罗正 <1732036298@qq.com> Reviewed-by: aliyun8003852482 <1224667075@qq.com> Reviewed-by: snickersun@163.com Reviewed-by: aliyun6865282430 <1624952103@qq.com> Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1342 --- .../nativeui/alarm/src/AlarmClockModel.cpp | 2 +- .../bluetooth/src/BluetoothHeadsetEvent.cpp | 18 ++--- .../nativeui/bluetooth/src/BluetoothModel.cpp | 6 +- .../nativeui/player/src/PlayersModel.cpp | 9 ++- .../player/frameworks/player_impl.cpp | 74 +++++++++---------- 5 files changed, 57 insertions(+), 52 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp index 5fc0d55d2..5f66a125f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp @@ -337,7 +337,7 @@ bool AlarmClockModel::JudgeClockModel(uint16_t num) uint8_t AlarmClockModel::GetAlarmId(void) { for (int num = 0; num < CLOCK_MAX; num++) { - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::GetAlarmId alarmId[%d] = %d", num, alarmId[num]); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "AlarmClockModel::GetAlarmId alarmId[%d] = %d", num, alarmId[num]); } for (int num = 0; num < CLOCK_MAX; num++) { if (alarmId[num] == 0) { //如果某个元素的值为 0,表示这个 ID 尚未被使用 diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp index bc1379a4b..6702977f9 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothHeadsetEvent.cpp @@ -30,7 +30,7 @@ BtAvrcpTgInf g_avrcp_srv_inf; void BtAvrcpVolumeChangedSyncMedia(uint8_t a2dp_volume) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[BtAvrcpVolumeChangedSyncMedia]::a2dp_volume = 0x%x\r\n", a2dp_volume); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[BtAvrcpVolumeChangedSyncMedia]::a2dp_volume = 0x%x\r\n", a2dp_volume); int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100; AudioManager::GetInstance().SetVolume(AUDIO_STREAM_A2DP_MUSIC, audio_volume); /* 设置增益音量 */ g_avrcp_tg_local_media_vol = a2dp_volume; @@ -97,7 +97,7 @@ void PressButtonStatusCallback(td_u32 keyOperation, td_u32 keyValue) void BtAvrcpTgNotifyVolumeChangedProc(uint8_t a2dp_volume) { int32_t audio_volume = a2dp_volume * BT_A2DP_MEDIA_VOL_LEVEL / AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100; - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "NotifyVolume = %d", audio_volume); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "NotifyVolume = %d", audio_volume); AudioManager::GetInstance().SetVolume(AUDIO_STREAM_MUSIC, audio_volume); // 耳机连接手表场景调节手表音量 /* ---------------------------- 若当前音乐播放器为手机音乐则同步更新音乐播放器的声音进度条 --------------------------- */ if(PlayersModel::GetInstance()->GetMusicSource()) @@ -161,11 +161,11 @@ uint8_t BtAvrcpTgGetLocMediaVolume(void) if (g_avrcp_tg_local_media_vol == AVRCP_ABSOLUTE_VOLUME_INVALID) { int32_t audio_volume = AudioManager::GetInstance().GetVolume(AUDIO_STREAM_A2DP_MUSIC); uint8_t a2dp_volume = (uint8_t)(audio_volume * AVRCP_ABSOLUTE_VOLUME_PERCENTAGE_100 / BT_A2DP_MEDIA_VOL_LEVEL); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "audio_volume 0x%x, a2dp_volume 0x%x\n", audio_volume, a2dp_volume); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "audio_volume 0x%x, a2dp_volume 0x%x\n", audio_volume, a2dp_volume); g_avrcp_tg_local_media_vol = a2dp_volume; } - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", g_avrcp_tg_local_media_vol); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "get local media volume, a2dp_volume = 0x%x", g_avrcp_tg_local_media_vol); return g_avrcp_tg_local_media_vol; } @@ -234,7 +234,7 @@ static bd_addr_t *BtAvrcpSrvGetActiveAddr(void) void ConnectTgStateChangedCallback(const bd_addr_t *bdAddr, profile_connect_state_t state) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp tg update conn stat:%u", state); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp tg update conn stat:%u", state); if (bdAddr == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "bdaddr nullptr"); return; @@ -344,7 +344,7 @@ static void BtAvrcpPressReleaseButtonLog(uint32_t key_operation) static void BtAvrcpCtReleaseButtonRspCallback(const bd_addr_t *bd_addr, int32_t key_operation) { UNUSED(bd_addr); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "avrcp ct release button cbk key:%x\n", key_operation); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct release button cbk key:%x\n", key_operation); if (g_avrcp_srv_inf.avrcp_button_flag == AVRCP_SRV_PRESS_VALUE) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "avrcp ct released button button_flag change:%u->%u\n", g_avrcp_srv_inf.avrcp_button_flag, AVRCP_SRV_RELEASED_VALUE); @@ -375,14 +375,14 @@ static void BtAvrcpCtSupportEventCallback(const bd_addr_t *bd_addr, avrcp_ct_sup for (uint8_t i = 0; i < event->event_num; i++) { if (event->event_id[i] == AVRCP_NOTIFY_EVENT_VOLUME_CHANGED) { int ret = avrcp_ct_register_notification(bd_addr, event->event_id[i], 0); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); } } for (uint8_t i = 0; i < event->event_num; i++) { if (event->event_id[i] != AVRCP_NOTIFY_EVENT_VOLUME_CHANGED) { int ret = avrcp_ct_register_notification(bd_addr, event->event_id[i], 0); - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "register event_id: 0x%x, ret = 0x%x", event->event_id[i], ret); } } } @@ -453,7 +453,7 @@ static void BtAvrcpCtGetPlayStatusCallback(const bd_addr_t *bd_addr, avrcp_ct_pl static void BtAvrcpCtHdlNotifyVolumeRspCbk(avrcp_ct_notification_value_cb_t *notification) { - WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "[BtAvrcpCtHdlNotifyVolumeRspCbk] volume: 0x%x\n", + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[BtAvrcpCtHdlNotifyVolumeRspCbk] volume: 0x%x\n", notification->volume); /* 注册事件后通知的音量 */ BtAvrcpTgNotifyVolumeChangedProc((uint8_t)notification->volume); } diff --git a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp index 372226898..ac80b05da 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bluetooth/src/BluetoothModel.cpp @@ -1504,7 +1504,8 @@ static void BtA2dpSnkStartStreamReqCb(bd_addr_t *bd_addr) WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x \n", bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0]); /* 3 2 1 0 idx */ BtA2dpSnkAudioCreate(); - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PlayersModel::set_player_state, OHOS::PlayersModel::GetInstance(),true)); + if(PlayersModel::GetInstance()->GetMusicSource())//如果是手机音乐才更新显示 + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PlayersModel::set_player_state, OHOS::PlayersModel::GetInstance(),true)); // PlayersModel::GetInstance()->get_avrcp_ct_get_element_attributes(); } @@ -1513,7 +1514,8 @@ static void BtA2dpSnkPlayingStateChangedCb(bd_addr_t *bd_addr, int playing_state WEARABLE_LOGI(WEARABLE_LOG_MODULE_APP, "addr: ****%02x%02x%02x%02x playing_state: %x\n", bd_addr->addr[3], bd_addr->addr[2], bd_addr->addr[1], bd_addr->addr[0], playing_state); /* 3 2 1 0 idx */ if (playing_state == A2DP_NOT_PLAYING) { - GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PlayersModel::set_player_state, OHOS::PlayersModel::GetInstance(),false)); + if(PlayersModel::GetInstance()->GetMusicSource())//如果是手机音乐才更新显示 + GraphicService::GetInstance()->PostGraphicEvent(std::bind(&OHOS::PlayersModel::set_player_state, OHOS::PlayersModel::GetInstance(),false)); BtA2dpSnkAudioDestroy(); } } diff --git a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp index 255ad686a..4d768468d 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/player/src/PlayersModel.cpp @@ -255,6 +255,8 @@ int PlayersModel::PlayerInit(void) sliceId = PlayersListGroup::GetInstance()->GetCase(currentIndex); if (sliceId == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCase %d sliceId err !!!", currentIndex); + PlayersModel::GetInstance()->PlayerStop(); /*停止音乐*/ + PlayersModel::GetInstance()->ClearActivateAudioInterrupt(); char strFile[BUFFER_SIZE] = "No music files"; sliceId = strFile; } @@ -759,13 +761,13 @@ void PlayersModel::GetDuration(int64_t &duration) bool PlayersModel::CreateMusicPlayDirectory(const char* path) { if (access(path, F_OK) == -1) { // 如果路径不存在 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Directory %s not exist, creating directory\n", path); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s not exist, creating directory\n", path); if (mkdir(path, 0777)!= 0) { // 尝试创建目录,如果创建失败 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Create directory %s failed\n", path); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Create directory %s failed\n", path); return false; } } else { // 如果路径存在 - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "Directory %s already exists\n", path); + WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Directory %s already exists\n", path); } return true; } @@ -791,6 +793,7 @@ void PlayersModel::UpdateMusicPlayerList(void) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "PlayersModel::UpdateMusicPlayerList"); PlayersListGroup::GetInstance()->SetUpListCase(); + PlayersModel::GetInstance()->PlayerInit(); PlayersView *playersView = PlayersView::GetInstance(); if (playersView == nullptr) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "OptionsButtonOnClick playersView nullptr err"); diff --git a/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp b/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp index 42dc93487..2f250a1ff 100755 --- a/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp +++ b/code/sdk/middleware/services/media/foundation/player/frameworks/player_impl.cpp @@ -665,7 +665,7 @@ bool Player::PlayerImpl::IsSingleLooping() int32_t Player::PlayerImpl::GetPlayerState(int32_t &state) { - MEDIA_INFO_LOG("process in"); + // MEDIA_INFO_LOG("process in");//关闭这个打印 MediaMutexLock(lock_); CHECK_FAILED_RETURN_WITH_UNLOCK(released_, false, -1, "have released or not create", lock_); state = currentState_; @@ -1481,10 +1481,10 @@ void Player::PlayerImpl::PrintAudioAndVideoDumpInfo(const PlayerAudioDebugInfo * void Player::PlayerImpl::PrintPlayerDumpInfo(const PlayerDebugInfo *playerInfo) { - if (formatFileInfo_.s64Duration != -1) { - printf("-----------Player file info-----------\n"); - PrintFileDumpInfo(&playerInfo->fileDebugInfo); - printf("\n"); + if (formatFileInfo_.s64Duration != -1) { + printf("-----------Player file info-----------\n"); + PrintFileDumpInfo(&playerInfo->fileDebugInfo); + printf("\n"); } if (player_ != nullptr) { printf("-----------Player stream info-----------\n"); @@ -1503,40 +1503,40 @@ void Player::PlayerImpl::PlayerThreadCondSignal(void) int32_t Player::PlayerImpl::DumpInfo(PlayerDebugInfo *playerInfo) { - if (playerInfo == nullptr) { - MEDIA_ERR_LOG("playerInfo is NULL!"); - return -1; + if (playerInfo == nullptr) { + MEDIA_ERR_LOG("playerInfo is NULL!"); + return -1; } playerInfo->fileDebugInfo.streamType = audioStreamType_; - if (formatFileInfo_.s64Duration != -1) { - playerInfo->fileDebugInfo.s64StartTime = formatFileInfo_.s64StartTime; - playerInfo->fileDebugInfo.s64Duration = formatFileInfo_.s64Duration; - playerInfo->fileDebugInfo.s64FileSize = formatFileInfo_.s64FileSize; - playerInfo->fileDebugInfo.s32UsedAudioStreamIndex = formatFileInfo_.s32UsedAudioStreamIndex; - playerInfo->fileDebugInfo.s32UsedVideoStreamIndex = formatFileInfo_.s32UsedVideoStreamIndex; - if (formatFileInfo_.s32UsedVideoStreamIndex >= 0) { - playerInfo->videoDebugInfo.s32UsedVideoStreamIndex = formatFileInfo_.s32UsedVideoStreamIndex; - } - if (formatFileInfo_.s32UsedAudioStreamIndex >= 0) { - playerInfo->audioDebugInfo.s32UsedAudioStreamIndex = formatFileInfo_.s32UsedAudioStreamIndex; - playerInfo->audioDebugInfo.sampleFmt = formatFileInfo_.sampleFmt; - playerInfo->audioDebugInfo.u32SampleRate = formatFileInfo_.u32SampleRate; - playerInfo->audioDebugInfo.u32AudioChannelCnt = formatFileInfo_.u32AudioChannelCnt; - } - } - if (player_ != nullptr) { - player_->GetPlayerControlDumpInfo(playerInfo->playControlInfo); - playerInfo->playControlInfo.speed = speed_; - playerInfo->playControlInfo.rewindPosition = rewindPosition_; - playerInfo->playControlInfo.playerControlState = playerControlState_; - playerInfo->playControlInfo.isSingleLoop = isSingleLoop_; - player_->GetPlayerFileDumpInfo(playerInfo->fileDebugInfo); - if (formatFileInfo_.s32UsedVideoStreamIndex >= 0) { - player_->GetPlayerVideoDumpInfo(playerInfo->videoDebugInfo); - } - if (formatFileInfo_.s32UsedAudioStreamIndex >= 0) { - player_->GetPlayerAudioDumpInfo(playerInfo->audioDebugInfo); - } + if (formatFileInfo_.s64Duration != -1) { + playerInfo->fileDebugInfo.s64StartTime = formatFileInfo_.s64StartTime; + playerInfo->fileDebugInfo.s64Duration = formatFileInfo_.s64Duration; + playerInfo->fileDebugInfo.s64FileSize = formatFileInfo_.s64FileSize; + playerInfo->fileDebugInfo.s32UsedAudioStreamIndex = formatFileInfo_.s32UsedAudioStreamIndex; + playerInfo->fileDebugInfo.s32UsedVideoStreamIndex = formatFileInfo_.s32UsedVideoStreamIndex; + if (formatFileInfo_.s32UsedVideoStreamIndex >= 0) { + playerInfo->videoDebugInfo.s32UsedVideoStreamIndex = formatFileInfo_.s32UsedVideoStreamIndex; + } + if (formatFileInfo_.s32UsedAudioStreamIndex >= 0) { + playerInfo->audioDebugInfo.s32UsedAudioStreamIndex = formatFileInfo_.s32UsedAudioStreamIndex; + playerInfo->audioDebugInfo.sampleFmt = formatFileInfo_.sampleFmt; + playerInfo->audioDebugInfo.u32SampleRate = formatFileInfo_.u32SampleRate; + playerInfo->audioDebugInfo.u32AudioChannelCnt = formatFileInfo_.u32AudioChannelCnt; + } + } + if (player_ != nullptr) { + player_->GetPlayerControlDumpInfo(playerInfo->playControlInfo); + playerInfo->playControlInfo.speed = speed_; + playerInfo->playControlInfo.rewindPosition = rewindPosition_; + playerInfo->playControlInfo.playerControlState = playerControlState_; + playerInfo->playControlInfo.isSingleLoop = isSingleLoop_; + player_->GetPlayerFileDumpInfo(playerInfo->fileDebugInfo); + if (formatFileInfo_.s32UsedVideoStreamIndex >= 0) { + player_->GetPlayerVideoDumpInfo(playerInfo->videoDebugInfo); + } + if (formatFileInfo_.s32UsedAudioStreamIndex >= 0) { + player_->GetPlayerAudioDumpInfo(playerInfo->audioDebugInfo); + } } PrintPlayerDumpInfo(playerInfo); return 0; -- 2.17.1