virtual bool bring_app_to_foreground(const std::string& appid) = 0;
virtual bool launch_app_async(const std::string& appid, bool background) = 0;
virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) = 0;
+ virtual boost::optional<pid_t> get_pid_by_appid(const std::string& appid) = 0;
};
#ifdef __cplusplus
virtual bool bring_app_to_foreground(const std::string& appid) override;
virtual bool launch_app_async(const std::string& appid, bool background) override;
virtual boost::optional<std::string> get_appid_by_pid(pid_t pid) override;
+ boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override;
};
#ifdef __cplusplus
void set_client_manager(CClientManager* manager) {
mClientManager = manager;
}
+ void set_application_manager(IApplicationManager* manager) {
+ mApplicationManager = manager;
+ }
void set_service_ipc_observer(IServiceIpcObserver* observer) {
mDispatcher.set_ipc_observer(observer);
}
int mStreamingDataSerial{0};
CClientManager* mClientManager{nullptr};
+ IApplicationManager* mApplicationManager{nullptr};
};
#ifdef __cplusplus
int mas_ui_client_change_assistant(const char* appid);
int mas_get_current_client_pid();
int mas_get_current_preprocessing_client_pid();
+ pid_t mas_get_current_audio_processing_pid();
int mas_get_client_pid_by_wakeup_word(const char *wakeup_word);
int mas_get_client_pid_by_appid(const char *appid);
std::string mas_get_client_appid_by_pid(int pid);
ma_preprocessing_allow_mode_e preprocessing_allow_mode;
char preprocessing_allow_appid[MAX_APPID_LEN];
+
+ boost::optional<std::string> audio_processing_appid;
} ma_client_info;
ma_client_info mClientInfo[MAX_MACLIENT_INFO_NUM];
return ret;
}
+
+boost::optional<pid_t> CApplicationManagerAul::get_pid_by_appid(const std::string& appid)
+{
+ boost::optional<pid_t> ret;
+
+ int pid = aul_app_get_pid(appid.c_str());
+ if (pid >= 0) {
+ ret = pid;
+ }
+
+ return ret;
+}
\ No newline at end of file
bundle *b = bundle_create();
if (b) {
bundle_add_byte(b, "content", pending_buffer, pending_buffer_size);
- int ret = message_port_send_message(
- mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b);
- if (MESSAGE_PORT_ERROR_NONE != ret)
- masc_message_port_error(ret);
+ boost::optional<std::string> appid = mApplicationManager->get_appid_by_pid(pid);
+ if (appid) {
+ int ret = message_port_send_message((*appid).c_str(), message_port, b);
+ if (MESSAGE_PORT_ERROR_NONE != ret)
+ masc_message_port_error(ret);
+ } else {
+ MAS_LOGE("AppID for PID %d not found!!!", pid);
+ }
pending_buffer_size = 0;
bundle_free(b);
bundle *b = bundle_create();
if (b) {
bundle_add_byte(b, "content", buffer, total_size);
- int ret = message_port_send_message(
- mClientManager->find_client_appid_by_pid(pid).c_str(), message_port, b);
- if (MESSAGE_PORT_ERROR_NONE != ret)
- masc_message_port_error(ret);
+ boost::optional<std::string> appid = mApplicationManager->get_appid_by_pid(pid);
+ if (appid) {
+ int ret = message_port_send_message((*appid).c_str(), message_port, b);
+ if (MESSAGE_PORT_ERROR_NONE != ret)
+ masc_message_port_error(ret);
+ } else {
+ MAS_LOGE("AppID for PID %d not found!!!", pid);
+ }
bundle_free(b);
} else {
return ret;
}
+pid_t CServiceMain::mas_get_current_audio_processing_pid()
+{
+ pid_t ret = -1;
+ if (mCurrentClientInfo >= 0 && mCurrentClientInfo < MAX_MACLIENT_INFO_NUM) {
+ boost::optional<std::string> audio_processing_appid =
+ mClientInfo[mCurrentClientInfo].audio_processing_appid;
+ if (audio_processing_appid) {
+ boost::optional<pid_t> optional_pid_t;
+ optional_pid_t = mApplicationManager.get_pid_by_appid((*audio_processing_appid).c_str());
+ if (optional_pid_t) {
+ ret = *optional_pid_t;
+ }
+ }
+ }
+ return ret;
+}
+
int CServiceMain::mas_get_client_pid_by_appid(const char *appid)
{
int ret = -1;
mClientManager.set_application_manager(&mApplicationManager);
mServiceIpc.set_client_manager(&mClientManager);
+ mServiceIpc.set_application_manager(&mApplicationManager);
mServiceIpc.set_service_ipc_observer(this);
mServicePlugin.set_service_ipc(&mServiceIpc);
}
if (service_ipc && service_main) {
- int pid = service_main->mas_get_current_client_pid();
+ /* First check if we have dedicated audio processing app for current client */
+ pid_t pid = service_main->mas_get_current_audio_processing_pid();
+ /* If not, send audio data to the main client */
+ if (-1 == pid) pid = service_main->mas_get_current_client_pid();
+
int preprocessing_pid = service_main->mas_get_current_preprocessing_client_pid();
if (pid == -1) {
MAS_LOGE("[ERROR] Fail to retrieve pid of current MA client");
bool bring_app_to_foreground(const std::string& appid) override { return true; }
bool launch_app_async(const std::string& appid, bool background) override { return true; }
boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
+ boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
};
class StorageWithNoClient : public testing::Test
return true;
}
boost::optional<std::string> get_appid_by_pid(pid_t pid) override { return boost::optional<std::string>{}; }
+ boost::optional<pid_t> get_pid_by_appid(const std::string& appid) override { return boost::optional<pid_t>{-1}; };
public:
boost::optional<std::string> launched_appid;
boost::optional<bool> launched_option_background;