diff --git a/CMakeLists.txt b/CMakeLists.txt index 1212c7f..00a1a40 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,10 +139,12 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") else() - if(MSVC) - list(APPEND EXTRA_CXX_FLAGS "/DXLIB_BASED 1") - else() - list(APPEND EXTRA_CXX_FLAGS "-DXLIB_BASED 1") + if(NOT ${SFML_USE_DRM}) + if(MSVC) + list(APPEND EXTRA_CXX_FLAGS "/DXLIB_BASED 1") + else() + list(APPEND EXTRA_CXX_FLAGS "-DXLIB_BASED 1") + endif() endif() endif() diff --git a/docker-scripts/docker_build_android b/docker-scripts/docker_build_android index 9d891a2..1b8400d 100644 --- a/docker-scripts/docker_build_android +++ b/docker-scripts/docker_build_android @@ -2,7 +2,7 @@ SFML_EXTRACTED_TO_FOLDER=~ LIBUSB_EXTRACTED_TO_FOLDER=~ -SFML_BRANCH_NAME=master +SFML_BRANCH_NAME=android_fullscreen_stuff LIBUSB_BRANCH_NAME=android-rebase-2022-07 SFML_EXTRACTED_FOLDER=${SFML_EXTRACTED_TO_FOLDER}/SFML-${SFML_BRANCH_NAME} LIBUSB_EXTRACTED_FOLDER=${LIBUSB_EXTRACTED_TO_FOLDER}/libusb-${LIBUSB_BRANCH_NAME} @@ -16,7 +16,7 @@ ANDROID_FOLDER=android export LANG=C.UTF-8 -(cd ${SFML_EXTRACTED_TO_FOLDER} ; rm -f ${SFML_BRANCH_NAME}.zip ; wget https://github.com/SFML/SFML/archive/refs/heads/${SFML_BRANCH_NAME}.zip ; unzip ${SFML_BRANCH_NAME}.zip) +(cd ${SFML_EXTRACTED_TO_FOLDER} ; rm -f ${SFML_BRANCH_NAME}.zip ; wget https://github.com/Lorenzooone/SFML/archive/refs/heads/${SFML_BRANCH_NAME}.zip ; unzip ${SFML_BRANCH_NAME}.zip) (cd ${LIBUSB_EXTRACTED_TO_FOLDER} ; rm -f ${LIBUSB_BRANCH_NAME}.zip ; wget https://github.com/jagheterfredrik/libusb/archive/refs/heads/${LIBUSB_BRANCH_NAME}.zip ; unzip ${LIBUSB_BRANCH_NAME}.zip) ${BUILD_LIBS_COMMAND} ${LIBUSB_EXTRACTED_FOLDER} ${SFML_EXTRACTED_FOLDER} ${STL_CHOSEN} ${RELEASE_TYPE} diff --git a/include/frontend.hpp b/include/frontend.hpp index 0766314..d23ea5c 100755 --- a/include/frontend.hpp +++ b/include/frontend.hpp @@ -90,6 +90,8 @@ public: void process_own_out_text_data(bool print_to_notification = true); int load_data(); int save_data(); + bool is_open(); + bool has_focus(); bool open_capture(); bool close_capture(); bool scheduled_split(); @@ -448,6 +450,7 @@ void get_par_size(float &width, float &height, float multiplier_factor, const PA SecondScreen3DRelativePosition get_second_screen_pos(ScreenInfo* info, ScreenType stype); +bool should_do_output(FrontendData* frontend_data); void update_output(FrontendData* frontend_data, double frame_time = 0.0, VideoOutputData *out_buf = NULL, InputVideoDataType video_data_type = VIDEO_DATA_RGB); void update_connected_3ds_ds(FrontendData* frontend_data, const CaptureDevice &old_cc_device, const CaptureDevice &new_cc_device); void update_connected_specific_settings(FrontendData* frontend_data, const CaptureDevice &cc_device); diff --git a/source/WindowScreen.cpp b/source/WindowScreen.cpp index e7b2b23..3447900 100755 --- a/source/WindowScreen.cpp +++ b/source/WindowScreen.cpp @@ -265,6 +265,14 @@ void WindowScreen::end() { this->display_lock.unlock(); } +bool WindowScreen::is_open() { + return this->m_win.isOpen(); +} + +bool WindowScreen::has_focus() { + return this->m_win.isOpen() && this->m_win.hasFocus(); +} + void WindowScreen::after_thread_join() { if(this->m_win.isOpen()) { this->draw_lock->lock(); diff --git a/source/cc3dsfs.cpp b/source/cc3dsfs.cpp index 3da5e1d..7a861cc 100755 --- a/source/cc3dsfs.cpp +++ b/source/cc3dsfs.cpp @@ -407,7 +407,7 @@ static bool handleAudioDeviceChanges(Audio &audio, AudioData *audio_data, std::o return success; } -static void soundCall(AudioData *audio_data, CaptureData* capture_data) { +static void soundCall(AudioData *audio_data, CaptureData* capture_data, volatile bool* can_do_output) { std::int16_t (*out_buf)[MAX_SAMPLES_IN] = new std::int16_t[NUM_CONCURRENT_AUDIO_BUFFERS][MAX_SAMPLES_IN]; Audio audio(audio_data); int audio_buf_counter = 0; @@ -419,7 +419,7 @@ static void soundCall(AudioData *audio_data, CaptureData* capture_data) { std::chrono::time_point last_device_check_time = std::chrono::high_resolution_clock::now(); while(capture_data->status.running) { - if(capture_data->status.connected && capture_data->status.device.has_audio) { + if(capture_data->status.connected && capture_data->status.device.has_audio && (*can_do_output)) { bool timed_out = !capture_data->status.audio_wait.timed_lock(); if(!capture_data->status.cooldown_curr_in) { @@ -520,7 +520,7 @@ static float get_time_multiplier(CaptureData* capture_data, bool should_ignore_d } } -static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, bool created_proper_folder, override_all_data &override_data) { +static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, bool created_proper_folder, override_all_data &override_data, volatile bool* can_do_output) { VideoOutputData *out_buf; double last_frame_time = 0.0; FrontendData frontend_data; @@ -648,7 +648,10 @@ static int mainVideoOutputCall(AudioData* audio_data, CaptureData* capture_data, if(frontend_data.shared_data.input_data.fast_poll) poll_all_windows(&frontend_data, poll_everything, polled); - update_output(&frontend_data, last_frame_time, chosen_buf, video_data_type); + *can_do_output = should_do_output(&frontend_data); + + if(*can_do_output) + update_output(&frontend_data, last_frame_time, chosen_buf, video_data_type); if(!frontend_data.shared_data.input_data.fast_poll) poll_all_windows(&frontend_data, poll_everything, polled); @@ -806,6 +809,7 @@ int main(int argc, char **argv) { int power_id = -1; bool use_pud_up = true; bool created_proper_folder = create_out_folder(); + volatile bool can_do_output = true; bool mono_app_default_value = false; #ifdef ANDROID_COMPILATION mono_app_default_value = true; @@ -928,9 +932,9 @@ int main(int argc, char **argv) { std::thread capture_thread(captureCall, capture_data); std::thread audio_thread; if(!override_data.no_audio) - audio_thread = std::thread(soundCall, &audio_data, capture_data); + audio_thread = std::thread(soundCall, &audio_data, capture_data, &can_do_output); - int ret_val = mainVideoOutputCall(&audio_data, capture_data, created_proper_folder, override_data); + int ret_val = mainVideoOutputCall(&audio_data, capture_data, created_proper_folder, override_data, &can_do_output); if(!override_data.no_audio) audio_thread.join(); capture_thread.join(); diff --git a/source/frontend.cpp b/source/frontend.cpp index cea53d6..b18703a 100755 --- a/source/frontend.cpp +++ b/source/frontend.cpp @@ -1,4 +1,5 @@ #include "frontend.hpp" +#include "utils.hpp" #include #include #include @@ -1039,6 +1040,20 @@ JoystickAction get_joystick_action(uint32_t joystickId, uint32_t joy_button) { return JOY_ACTION_NONE; } +bool should_do_output(FrontendData* frontend_data) { + #ifndef ANDROID_COMPILATION + return (frontend_data->joint_screen->m_info.window_enabled) || (frontend_data->bot_screen->m_info.window_enabled) || (frontend_data->top_screen->m_info.window_enabled); + #else + if(frontend_data->joint_screen->m_info.window_enabled) + return (!frontend_data->joint_screen->is_open()) || frontend_data->joint_screen->has_focus(); + if(frontend_data->bot_screen->m_info.window_enabled) + return (!frontend_data->bot_screen->is_open()) || frontend_data->bot_screen->has_focus(); + if(frontend_data->top_screen->m_info.window_enabled) + return (!frontend_data->top_screen->is_open()) || frontend_data->top_screen->has_focus(); + return false; + #endif +} + void update_output(FrontendData* frontend_data, double frame_time, VideoOutputData *out_buf, InputVideoDataType video_data_type) { if(frontend_data->reload) { frontend_data->top_screen->reload();