#include "dependency_default_audio.h"
#include "dependency_default_button.h"
+#include <dlog.h>
+#include <service_app_extension.h>
+
+#include <thread>
+
static mas_proxy_interface g_proxy_interface;
const int g_dependency_version = 1;
+static bool g_should_exit = false;
+
int mas_dependency_initialize(mas_proxy_interface interface, int *dependency_version)
{
g_proxy_interface = interface;
*dependency_version = g_dependency_version;
}
+ /* If the service process has to terminate in certain circumstances,
+ set g_should_exit variable to true as below. */
+ // g_should_exit = true;
+
+ if (g_should_exit) {
+ LOGE("g_should_exit value contains positive value, registering timer");
+ std::thread([]() {
+ std::this_thread::sleep_for(std::chrono::milliseconds(1000));
+ LOGE("Now trying to exit");
+ mas_dependency_deinitialize();
+ service_app_exit_without_restart();
+ }).detach();
+ }
+
return 0;
}
void dependency_default_audio_deinitialize()
{
+ dependency_default_audio_stop_recording();
+
int ret = 0;
if (g_virtual_sound_stream) {
sound_manager_stop_virtual_stream(g_virtual_sound_stream);
void dependency_default_audio_start_recording()
{
- int ret = audio_in_resume(g_audio_in);
- if (AUDIO_IO_ERROR_NONE != ret) {
- LOGD("[Recorder ERROR] Fail to resume audio in : %d", ret);
+ if (g_audio_in) {
+ int ret = audio_in_resume(g_audio_in);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ LOGD("[Recorder ERROR] Fail to resume audio in : %d", ret);
+ }
+ g_stop_recorder_thread.store(false);
+ LOGD("Starting recorder thread");
+ g_recorder_thread = thread(recorder_thread_func);
}
- g_stop_recorder_thread.store(false);
- LOGD("Starting recorder thread");
- g_recorder_thread = thread(recorder_thread_func);
}
void dependency_default_audio_stop_recording()
g_stop_recorder_thread.store(true);
g_recorder_thread.join();
}
- int ret = audio_in_pause(g_audio_in);
- if (AUDIO_IO_ERROR_NONE != ret) {
- LOGD("[Recorder ERROR] Fail to pause audio in : %d", ret);
+ if (g_audio_in) {
+ int ret = audio_in_pause(g_audio_in);
+ if (AUDIO_IO_ERROR_NONE != ret) {
+ LOGD("[Recorder ERROR] Fail to pause audio in : %d", ret);
+ }
}
}