コード例 #1
0
void AutoConfig::SaveSettings()
{
	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

	if (recordingEncoder != Encoder::Stream)
		config_set_string(main->Config(), "SimpleOutput", "RecEncoder",
				GetEncoderId(recordingEncoder));

	const char *quality = recordingQuality == Quality::High
		? "Small"
		: "Stream";

	config_set_string(main->Config(), "Output", "Mode", "Simple");
	config_set_string(main->Config(), "SimpleOutput", "RecQuality", quality);
	config_set_int(main->Config(), "Video", "BaseCX", baseResolutionCX);
	config_set_int(main->Config(), "Video", "BaseCY", baseResolutionCY);
	config_set_int(main->Config(), "Video", "OutputCX", idealResolutionCX);
	config_set_int(main->Config(), "Video", "OutputCY", idealResolutionCY);

	if (fpsType != FPSType::UseCurrent) {
		config_set_uint(main->Config(), "Video", "FPSType", 0);
		config_set_string(main->Config(), "Video", "FPSCommon",
				std::to_string(idealFPSNum).c_str());
	}

	main->ResetVideo();
	main->ResetOutputs();
	config_save_safe(main->Config(), "tmp", nullptr);
}
コード例 #2
0
static void command_task(struct ETSEventTag *event)
{
	switch(event->sig)
	{
		case(command_task_reset):
		{
			reset();
			break;
		}

		case(command_task_uart_bridge):
		{
			background_task_bridge_uart();
			stat_update_uart++;
			break;
		}

		case(command_task_init_i2c_sensors):
		{
			if(i2c_sensors_init())
				dispatch_post_command(command_task_init_i2c_sensors);
			break;
		}

		case(command_task_periodic_i2c_sensors):
		{
			i2c_sensors_periodic();
			break;
		}

		case(command_task_init_displays):
		{
			uint32_t now = system_get_time();
			display_init();
			stat_display_init_time_us = system_get_time() - now;
			break;
		}

		case(command_task_received_command):
		{
			app_action_t action;

			if(lwip_if_received_tcp(&command_socket))
				stat_update_command_tcp++;

			if(lwip_if_received_udp(&command_socket))
				stat_update_command_udp++;

			if(lwip_if_send_buffer_locked(&command_socket))
			{
				stat_cmd_send_buffer_overflow++;
				string_clear(&command_socket_receive_buffer);
				lwip_if_receive_buffer_unlock(&command_socket);
				break;
			}

			string_clear(&command_socket_send_buffer);

			action = application_content(&command_socket_receive_buffer, &command_socket_send_buffer);

			string_clear(&command_socket_receive_buffer);
			lwip_if_receive_buffer_unlock(&command_socket);

			if(action == app_action_empty)
			{
				string_clear(&command_socket_send_buffer);
				string_append(&command_socket_send_buffer, "> empty command\n");
			}

			if(action == app_action_disconnect)
			{
				string_clear(&command_socket_send_buffer);
				string_append(&command_socket_send_buffer, "> disconnect\n");
			}

			if(action == app_action_reset)
			{
				string_clear(&command_socket_send_buffer);
				string_append(&command_socket_send_buffer, "> reset\n");
			}

			if(!lwip_if_send(&command_socket))
				log("lwip send failed\n");

			if(action == app_action_disconnect)
				lwip_if_close(&command_socket);

			/*
			 * === ugly workaround ===
			 *
			 * For tcp connections we can use the "sent" callback to make sure all
			 * of our data has been sent before rebooting. For udp there is no such
			 * callback and waiting for it to happen does not work (need a return to
			 * SDK code to achieve it). So lwip_if_reboot will take care for it itself
			 * when possible (tcp), otherwise (udp) it will return false here and the
			 * application needs to finish the operation via a task call.
			 */

			if(action == app_action_reset)
				if(!lwip_if_reboot(&command_socket))
					dispatch_post_command(command_task_reset);

			break;
		}

		case(command_task_display_update):
		{
			stat_update_display++;

			if(display_periodic())
				dispatch_post_command(command_task_display_update);

			break;
		}

		case(command_task_fallback_wlan):
		{
			config_wlan_mode_t wlan_mode;
			unsigned int wlan_mode_int;

			if(config_get_uint("wlan.mode", &wlan_mode_int, -1, -1))
				wlan_mode = (config_wlan_mode_t)wlan_mode_int;
			else
				wlan_mode = config_wlan_mode_client;

			if(wlan_mode == config_wlan_mode_client)
			{
				wlan_mode_int = config_wlan_mode_ap;
				config_open_write();
				config_set_uint("wlan.mode", wlan_mode_int, -1, -1);
				config_close_write();
				config_get_uint("wlan.mode", &wlan_mode_int, -1, -1);
				wlan_init();
			}

			break;
		}

		case(command_task_update_time):
		{
			time_periodic();
			break;
		}

		case(command_task_run_sequencer):
		{
			sequencer_run();
			break;
		}

		case(command_task_alert_association):
		{
			if((assoc_alert.io >= 0) && (assoc_alert.pin >= 0))
				io_trigger_pin((string_t *)0, assoc_alert.io, assoc_alert.pin, io_trigger_on);

			break;
		}

		case(command_task_alert_disassociation):
		{
			if((assoc_alert.io >= 0) && (assoc_alert.pin >= 0))
				io_trigger_pin((string_t *)0, assoc_alert.io, assoc_alert.pin, io_trigger_off);

			break;
		}

		case(command_task_alert_status):
		{
			if((trigger_alert.io >= 0) && (trigger_alert.pin >= 0))
				io_trigger_pin((string_t *)0, trigger_alert.io, trigger_alert.pin, io_trigger_on);

			break;
		}
	}
}