From 3950b01cdd38a8e9188ac52519c9c971e73b8aab Mon Sep 17 00:00:00 2001 From: Niranjan Yardi Date: Tue, 10 Sep 2024 07:50:33 -0700 Subject: [PATCH] Merge feature/sb17 into origin/main (#4096) b/360216121 Removes windows based builds and SB15, SB16 code --------- Co-authored-by: Madhura Jayaraman Co-authored-by: Hao <131711973+haozheng-cobalt@users.noreply.github.com> Co-authored-by: Jelle Foks Co-authored-by: Oscar Vestlie Co-authored-by: Yijia Zhang <45114178+yjzhang111@users.noreply.github.com> Co-authored-by: Kaido Kert Co-authored-by: Colin Liang Co-authored-by: Colin Liang Co-authored-by: xiaomings --- .github/config/evergreen-arm-hardfp.json | 20 - .github/config/evergreen-arm-softfp.json | 20 - .github/config/evergreen-arm64.json | 20 - .github/config/evergreen-x64.json | 18 - .github/config/linux.json | 14 - .github/config/raspi-2.json | 18 - base/synchronization/condition_variable.h | 9 - .../condition_variable_starboard.cc | 32 - base/synchronization/lock_impl.h | 19 - base/synchronization/lock_impl_starboard.cc | 19 - base/threading/platform_thread.h | 4 - base/threading/platform_thread_ref.h | 4 - base/threading/platform_thread_starboard.cc | 16 - cobalt/browser/application.cc | 5 - cobalt/browser/switches.cc | 11 - cobalt/browser/switches.h | 4 - cobalt/browser/user_agent_platform_info.h | 8 +- cobalt/browser/web_module.cc | 4 - .../dom/captions/system_caption_settings.cc | 4 - cobalt/dom/captions/system_caption_settings.h | 4 - cobalt/h5vcc/h5vcc_accessibility.cc | 4 - cobalt/media/base/sbplayer_bridge.cc | 44 - cobalt/media/base/sbplayer_interface.cc | 19 - cobalt/media/base/sbplayer_interface.h | 13 +- cobalt/media/decoder_buffer_allocator.cc | 8 +- cobalt/ui_navigation/interface.cc | 26 - cobalt/ui_navigation/interface.h | 4 - starboard/BUILD.gn | 7 - starboard/accessibility.h | 214 --- starboard/android/shared/BUILD.gn | 91 -- .../android/shared/configuration_constants.cc | 5 - .../android/shared/configuration_public.h | 26 - starboard/android/shared/directory_close.cc | 33 - .../android/shared/directory_get_next.cc | 42 - starboard/android/shared/directory_internal.h | 37 - starboard/android/shared/directory_open.cc | 44 - starboard/android/shared/file_can_open.cc | 48 - starboard/android/shared/file_close.cc | 34 - starboard/android/shared/file_delete.cc | 26 - starboard/android/shared/file_exists.cc | 23 - starboard/android/shared/file_flush.cc | 26 - starboard/android/shared/file_get_info.cc | 38 - .../android/shared/file_get_path_info.cc | 55 - starboard/android/shared/file_open.cc | 110 -- starboard/android/shared/file_read.cc | 36 - starboard/android/shared/file_seek.cc | 32 - starboard/android/shared/file_truncate.cc | 26 - starboard/android/shared/file_write.cc | 26 - starboard/android/shared/posix_emu/dirent.cc | 1 - starboard/android/shared/posix_emu/stat.cc | 1 - starboard/android/shared/thread_create.cc | 151 -- starboard/android/shared/thread_get_name.cc | 24 - starboard/atomic.h | 6 - starboard/build/platforms.py | 2 - starboard/byte_swap.h | 68 - starboard/common/condition_variable.cc | 25 - starboard/common/condition_variable.h | 4 - starboard/common/memory.h | 4 - starboard/common/mutex.cc | 24 - starboard/common/mutex.h | 9 - starboard/common/storage.cc | 36 +- starboard/common/storage.h | 11 - starboard/configuration.h | 30 +- starboard/configuration_constants.h | 5 - starboard/directory.h | 60 - starboard/elf_loader/exported_symbols.cc | 173 --- starboard/event.h | 12 - .../arm/hardfp/configuration_public.h | 26 - .../arm/softfp/configuration_public.h | 26 - .../evergreen/arm64/configuration_public.h | 26 - .../evergreen/x64/configuration_public.h | 26 - starboard/file.h | 218 +-- starboard/image.h | 57 - starboard/linux/shared/BUILD.gn | 83 - .../linux/shared/configuration_constants.cc | 5 - starboard/linux/shared/configuration_public.h | 26 - starboard/linux/x64x11/shared/BUILD.gn | 2 - .../linux/x64x11/system_get_property_impl.cc | 8 - starboard/log.h | 5 - starboard/media.h | 26 - starboard/memory.h | 193 --- starboard/nplb/BUILD.gn | 63 - starboard/nplb/accessibility_test.cc | 158 -- starboard/nplb/byte_swap_test.cc | 80 - .../nplb/condition_variable_broadcast_test.cc | 40 - .../nplb/condition_variable_create_test.cc | 89 -- .../nplb/condition_variable_destroy_test.cc | 42 - .../nplb/condition_variable_signal_test.cc | 40 - .../nplb/condition_variable_wait_test.cc | 94 -- .../condition_variable_wait_timed_test.cc | 176 --- starboard/nplb/directory_can_open_test.cc | 68 - starboard/nplb/directory_close_test.cc | 32 - starboard/nplb/directory_create_test.cc | 115 -- starboard/nplb/directory_get_next_test.cc | 213 --- starboard/nplb/directory_open_test.cc | 156 -- starboard/nplb/extern_c_test.cc | 16 - starboard/nplb/file_can_open_test.cc | 76 - starboard/nplb/file_close_test.cc | 35 - starboard/nplb/file_delete_test.cc | 69 - starboard/nplb/file_flush_test.cc | 36 - starboard/nplb/file_get_info_test.cc | 93 -- starboard/nplb/file_get_path_info_test.cc | 120 -- .../nplb/file_mode_string_to_flags_test.cc | 65 - starboard/nplb/file_open_test.cc | 171 -- starboard/nplb/file_read_test.cc | 300 ---- starboard/nplb/file_read_write_all_test.cc | 69 - starboard/nplb/file_seek_test.cc | 241 --- starboard/nplb/file_truncate_test.cc | 121 -- starboard/nplb/file_write_test.cc | 173 --- starboard/nplb/image_test.cc | 56 - starboard/nplb/include_all.c | 16 - starboard/nplb/log_is_tty_test.cc | 35 - starboard/nplb/media_buffer_test.cc | 58 - .../nplb/memory_allocate_aligned_test.cc | 74 - starboard/nplb/memory_allocate_test.cc | 66 - .../nplb/memory_deallocate_aligned_test.cc | 43 - starboard/nplb/memory_deallocate_test.cc | 40 - starboard/nplb/memory_map_test.cc | 300 ---- starboard/nplb/memory_reallocate_test.cc | 150 -- starboard/nplb/mutex_acquire_test.cc | 109 -- starboard/nplb/mutex_acquire_try_test.cc | 88 -- starboard/nplb/mutex_create_test.cc | 70 - starboard/nplb/mutex_destroy_test.cc | 42 - .../nplb_evergreen_compat_tests/sabi_test.cc | 115 -- starboard/nplb/once_test.cc | 169 -- .../posix_compliance/posix_memory_map_test.cc | 7 - starboard/nplb/storage_helpers.h | 16 - .../nplb/string_compare_no_case_n_test.cc | 63 - starboard/nplb/string_compare_no_case_test.cc | 43 - starboard/nplb/string_duplicate_test.cc | 45 - starboard/nplb/string_format_test.cc | 50 - starboard/nplb/string_format_wide_test.cc | 53 - starboard/nplb/string_scan_test.cc | 99 -- starboard/nplb/thread_create_test.cc | 175 --- starboard/nplb/thread_detach_test.cc | 46 - starboard/nplb/thread_get_current_test.cc | 51 - starboard/nplb/thread_get_name_test.cc | 50 - starboard/nplb/thread_helpers.cc | 97 -- starboard/nplb/thread_helpers.h | 183 +-- starboard/nplb/thread_is_equal_test.cc | 43 - starboard/nplb/thread_join_test.cc | 77 - starboard/nplb/thread_local_value_test.cc | 195 --- starboard/nplb/thread_sampler_test.cc | 13 - starboard/nplb/thread_set_name_test.cc | 65 - starboard/nplb/thread_sleep_test.cc | 63 - starboard/nplb/thread_yield_test.cc | 124 -- starboard/nplb/time_constants.h | 49 +- starboard/nplb/time_get_monotonic_now_test.cc | 56 - starboard/nplb/time_get_now_test.cc | 64 - starboard/nplb/time_narrow_test.cc | 43 - starboard/nplb/ui_navigation_test.cc | 9 - starboard/nplb/user_get_current_test.cc | 41 - starboard/nplb/user_get_property_test.cc | 86 -- starboard/nplb/user_get_signed_in_test.cc | 63 - starboard/once.h | 77 +- starboard/raspi/shared/BUILD.gn | 80 - .../raspi/shared/configuration_constants.cc | 5 - starboard/raspi/shared/configuration_public.h | 26 - .../raspi/shared/open_max/image_decode.cc | 47 - .../open_max/image_is_decode_supported.cc | 45 - starboard/shared/iso/directory_close.cc | 22 - starboard/shared/iso/directory_get_next.cc | 25 - starboard/shared/iso/directory_internal.h | 29 - starboard/shared/iso/directory_open.cc | 22 - starboard/shared/iso/impl/directory_close.h | 49 - .../shared/iso/impl/directory_get_next.h | 63 - starboard/shared/iso/impl/directory_impl.h | 28 - starboard/shared/iso/impl/directory_open.h | 92 -- starboard/shared/iso/string_scan.cc | 26 - starboard/shared/libjpeg/image_decode.cc | 34 - .../libjpeg/image_is_decode_supported.cc | 40 - starboard/shared/linux/byte_swap.cc | 48 - starboard/shared/linux/thread_get_name.cc | 25 - starboard/shared/linux/thread_set_name.cc | 47 - starboard/shared/nouser/user_get_current.cc | 27 - starboard/shared/nouser/user_get_property.cc | 65 - starboard/shared/nouser/user_get_signed_in.cc | 31 - starboard/shared/nouser/user_internal.cc | 33 - starboard/shared/nouser/user_internal.h | 41 - starboard/shared/opus/opus_audio_decoder.cc | 12 - starboard/shared/posix/directory_create.cc | 77 - starboard/shared/posix/file_can_open.cc | 25 - starboard/shared/posix/file_close.cc | 25 - starboard/shared/posix/file_delete.cc | 25 - starboard/shared/posix/file_exists.cc | 25 - starboard/shared/posix/file_flush.cc | 25 - starboard/shared/posix/file_get_info.cc | 25 - starboard/shared/posix/file_get_path_info.cc | 25 - starboard/shared/posix/file_open.cc | 29 - starboard/shared/posix/file_read.cc | 25 - starboard/shared/posix/file_seek.cc | 25 - starboard/shared/posix/file_truncate.cc | 25 - starboard/shared/posix/file_write.cc | 25 - .../shared/posix/impl/file_get_path_info.h | 38 +- starboard/shared/posix/log_is_tty.cc | 23 - starboard/shared/posix/memory_flush.cc | 50 - starboard/shared/posix/memory_map.cc | 25 - starboard/shared/posix/memory_protect.cc | 25 - starboard/shared/posix/memory_unmap.cc | 24 - starboard/shared/posix/page_internal.cc | 54 - starboard/shared/posix/page_internal.h | 26 - .../shared/posix/string_compare_no_case.cc | 24 - .../shared/posix/string_compare_no_case_n.cc | 26 - starboard/shared/posix/string_format.cc | 27 - starboard/shared/posix/string_format_wide.cc | 28 - .../shared/posix/time_get_monotonic_now.cc | 34 - .../posix/time_get_monotonic_thread_now.cc | 34 - starboard/shared/posix/time_get_now.cc | 34 - starboard/shared/posix/time_internal.h | 42 +- .../time_is_time_thread_now_supported.cc | 23 - .../pthread/condition_variable_broadcast.cc | 43 - .../pthread/condition_variable_create.cc | 91 -- .../pthread/condition_variable_destroy.cc | 43 - .../pthread/condition_variable_signal.cc | 43 - .../shared/pthread/condition_variable_wait.cc | 51 - .../pthread/condition_variable_wait_timed.cc | 83 - starboard/shared/pthread/mutex_acquire.cc | 53 - starboard/shared/pthread/mutex_acquire_try.cc | 46 - starboard/shared/pthread/mutex_create.cc | 39 - starboard/shared/pthread/mutex_destroy.cc | 44 - starboard/shared/pthread/mutex_release.cc | 38 - starboard/shared/pthread/once.cc | 47 - starboard/shared/pthread/thread_create.cc | 133 -- .../shared/pthread/thread_create_local_key.cc | 32 - .../pthread/thread_destroy_local_key.cc | 32 - starboard/shared/pthread/thread_detach.cc | 31 - .../shared/pthread/thread_get_current.cc | 26 - .../shared/pthread/thread_get_local_value.cc | 31 - starboard/shared/pthread/thread_is_equal.cc | 28 - starboard/shared/pthread/thread_join.cc | 42 - .../pthread/thread_local_key_internal.h | 14 +- .../shared/pthread/thread_sampler_create.cc | 9 - .../shared/pthread/thread_sampler_internal.cc | 4 - .../shared/pthread/thread_sampler_internal.h | 12 - .../shared/pthread/thread_set_local_value.cc | 35 - .../shared/starboard/directory_can_open.cc | 33 - .../starboard/file_mode_string_to_flags.cc | 70 - .../file_storage/storage_delete_record.cc | 5 - .../file_storage/storage_open_record.cc | 5 - .../media/media_get_buffer_storage_type.cc | 21 - .../shared/starboard/media/media_util.cc | 10 - starboard/shared/starboard/memory.cc | 119 -- .../shared/starboard/string_duplicate.cc | 32 - .../accessibility_get_caption_settings.cc | 33 - .../accessibility_get_display_settings.cc | 32 - ...cessibility_get_text_to_speech_settings.cc | 32 - .../accessibility_set_captions_enabled.cc | 24 - starboard/shared/stub/byte_swap.cc | 46 - .../stub/condition_variable_broadcast.cc | 22 - .../shared/stub/condition_variable_create.cc | 22 - .../shared/stub/condition_variable_destroy.cc | 22 - .../shared/stub/condition_variable_signal.cc | 22 - .../shared/stub/condition_variable_wait.cc | 24 - .../stub/condition_variable_wait_timed.cc | 25 - starboard/shared/stub/directory_can_open.cc | 21 - starboard/shared/stub/directory_close.cc | 20 - starboard/shared/stub/directory_create.cc | 23 - starboard/shared/stub/directory_get_next.cc | 22 - starboard/shared/stub/directory_open.cc | 20 - starboard/shared/stub/file_can_open.cc | 23 - starboard/shared/stub/file_close.cc | 23 - starboard/shared/stub/file_delete.cc | 23 - starboard/shared/stub/file_exists.cc | 23 - starboard/shared/stub/file_flush.cc | 23 - starboard/shared/stub/file_get_info.cc | 23 - starboard/shared/stub/file_get_path_info.cc | 23 - starboard/shared/stub/file_open.cc | 26 - starboard/shared/stub/file_read.cc | 23 - starboard/shared/stub/file_seek.cc | 23 - starboard/shared/stub/file_truncate.cc | 23 - starboard/shared/stub/file_write.cc | 23 - starboard/shared/stub/image_decode.cc | 28 - .../shared/stub/image_is_decode_supported.cc | 25 - .../stub/media_get_buffer_storage_type.cc | 21 - starboard/shared/stub/mutex_acquire.cc | 22 - starboard/shared/stub/mutex_acquire_try.cc | 22 - starboard/shared/stub/mutex_create.cc | 22 - starboard/shared/stub/mutex_destroy.cc | 22 - starboard/shared/stub/mutex_release.cc | 22 - starboard/shared/stub/once.cc | 23 - .../shared/stub/storage_delete_record.cc | 4 - starboard/shared/stub/storage_open_record.cc | 4 - .../shared/stub/string_compare_no_case.cc | 21 - .../shared/stub/string_compare_no_case_n.cc | 23 - starboard/shared/stub/string_duplicate.cc | 23 - starboard/shared/stub/string_format.cc | 24 - starboard/shared/stub/string_format_wide.cc | 24 - starboard/shared/stub/string_scan.cc | 23 - starboard/shared/stub/thread_create.cc | 28 - .../shared/stub/thread_create_local_key.cc | 23 - .../shared/stub/thread_destroy_local_key.cc | 21 - starboard/shared/stub/thread_detach.cc | 19 - starboard/shared/stub/thread_get_current.cc | 23 - .../shared/stub/thread_get_local_value.cc | 23 - starboard/shared/stub/thread_get_name.cc | 21 - starboard/shared/stub/thread_is_equal.cc | 23 - starboard/shared/stub/thread_join.cc | 22 - .../shared/stub/thread_sampler_create.cc | 4 - .../shared/stub/thread_set_local_value.cc | 23 - starboard/shared/stub/thread_set_name.cc | 21 - .../shared/stub/time_get_monotonic_now.cc | 23 - .../stub/time_get_monotonic_thread_now.cc | 23 - starboard/shared/stub/time_get_now.cc | 23 - .../stub/time_is_time_thread_now_supported.cc | 23 - starboard/shared/stub/ui_nav_get_interface.cc | 23 - starboard/shared/stub/user_get_current.cc | 23 - starboard/shared/stub/user_get_property.cc | 30 - starboard/shared/stub/user_get_signed_in.cc | 23 - .../stub/window_blur_on_screen_keyboard.cc | 21 - .../stub/window_focus_on_screen_keyboard.cc | 21 - ...ow_get_on_screen_keyboard_bounding_rect.cc | 24 - .../stub/window_hide_on_screen_keyboard.cc | 21 - .../window_is_on_screen_keyboard_shown.cc | 23 - .../window_on_screen_keyboard_is_supported.cc | 23 - ...n_screen_keyboard_suggestions_supported.cc | 23 - ...indow_set_on_screen_keyboard_keep_focus.cc | 21 - .../stub/window_show_on_screen_keyboard.cc | 23 - ...w_update_on_screen_keyboard_suggestions.cc | 24 - .../shared/uwp/analog_thumbstick_input.cc | 100 -- .../shared/uwp/analog_thumbstick_input.h | 44 - .../uwp/analog_thumbstick_input_thread.cc | 135 -- .../uwp/analog_thumbstick_input_thread.h | 57 - starboard/shared/uwp/app_accessors.h | 60 - starboard/shared/uwp/application_uwp.cc | 1373 ----------------- starboard/shared/uwp/application_uwp.h | 235 --- .../shared/uwp/application_uwp_key_event.cc | 478 ------ starboard/shared/uwp/async_utils.h | 68 - .../shared/uwp/audio_renderer_passthrough.cc | 360 ----- .../shared/uwp/audio_renderer_passthrough.h | 140 -- starboard/shared/uwp/decoder_utils.cc | 99 -- starboard/shared/uwp/decoder_utils.h | 64 - .../shared/uwp/extended_resources_manager.cc | 574 ------- .../shared/uwp/extended_resources_manager.h | 112 -- starboard/shared/uwp/get_home_directory.cc | 39 - starboard/shared/uwp/keys.cc | 27 - starboard/shared/uwp/keys.h | 28 - starboard/shared/uwp/log_file_impl.cc | 95 -- starboard/shared/uwp/log_file_impl.h | 37 - starboard/shared/uwp/log_raw.cc | 53 - starboard/shared/uwp/log_raw_format.cc | 23 - starboard/shared/uwp/log_writer_interface.h | 33 - starboard/shared/uwp/log_writer_uwp.cc | 156 -- starboard/shared/uwp/log_writer_uwp.h | 36 - starboard/shared/uwp/log_writer_win32.cc | 75 - starboard/shared/uwp/log_writer_win32.h | 32 - .../uwp/media_get_audio_configuration.cc | 41 - .../shared/uwp/media_is_audio_supported.cc | 53 - .../shared/uwp/media_is_video_supported.cc | 271 ---- starboard/shared/uwp/microphone_impl.cc | 574 ------- .../shared/uwp/player_components_factory.cc | 311 ---- starboard/shared/uwp/system_get_property.cc | 350 ----- .../shared/uwp/system_get_property_test.cc | 31 - .../shared/uwp/system_get_total_cpu_memory.cc | 21 - .../shared/uwp/system_get_used_cpu_memory.cc | 21 - .../uwp/system_platform_error_internal.cc | 86 -- .../uwp/system_platform_error_internal.h | 54 - .../shared/uwp/system_raise_platform_error.cc | 38 - starboard/shared/uwp/time_zone_get_name.cc | 45 - starboard/shared/uwp/wasapi_audio.cc | 237 --- starboard/shared/uwp/wasapi_audio.h | 92 -- starboard/shared/uwp/wasapi_audio_sink.cc | 305 ---- starboard/shared/uwp/wasapi_audio_sink.h | 189 --- starboard/shared/uwp/wasapi_audio_test.cc | 255 --- starboard/shared/uwp/watchdog_log.cc | 95 -- starboard/shared/uwp/watchdog_log.h | 35 - starboard/shared/uwp/window_create.cc | 27 - starboard/shared/uwp/window_destroy.cc | 21 - .../uwp/window_get_diagonal_size_in_inches.cc | 30 - .../shared/uwp/window_get_platform_handle.cc | 26 - starboard/shared/uwp/window_get_size.cc | 31 - starboard/shared/uwp/window_internal.cc | 36 - starboard/shared/uwp/window_internal.h | 41 - .../shared/uwp/window_set_default_options.cc | 22 - starboard/shared/uwp/xb1_get_type.cc | 52 - starboard/shared/uwp/xb1_get_type.h | 36 - .../shared/uwp/xb1_media_session_client.cc | 243 --- .../shared/uwp/xb1_media_session_client.h | 33 - starboard/shared/win32/__init__.py | 0 starboard/shared/win32/adapter_utils.cc | 87 -- starboard/shared/win32/adapter_utils.h | 52 - starboard/shared/win32/application_win32.cc | 348 ----- starboard/shared/win32/application_win32.h | 137 -- .../win32/application_win32_key_event.cc | 390 ----- starboard/shared/win32/atomic_public.h | 257 --- starboard/shared/win32/atomic_queue.h | 75 - starboard/shared/win32/audio_decoder.cc | 155 -- starboard/shared/win32/audio_decoder.h | 80 - .../shared/win32/audio_decoder_thread.cc | 130 -- starboard/shared/win32/audio_decoder_thread.h | 71 - starboard/shared/win32/audio_sink.cc | 613 -------- .../win32/audio_sink_get_max_channels.cc | 19 - ..._get_nearest_supported_sample_frequency.cc | 26 - ...k_is_audio_frame_storage_type_supported.cc | 30 - ...dio_sink_is_audio_sample_type_supported.cc | 29 - starboard/shared/win32/audio_transform.cc | 215 --- starboard/shared/win32/audio_transform.h | 35 - starboard/shared/win32/auto_event_handle.h | 57 - starboard/shared/win32/byte_swap.cc | 48 - .../win32/condition_variable_broadcast.cc | 31 - .../shared/win32/condition_variable_create.cc | 35 - .../win32/condition_variable_destroy.cc | 28 - .../shared/win32/condition_variable_signal.cc | 31 - .../shared/win32/condition_variable_wait.cc | 36 - .../win32/condition_variable_wait_timed.cc | 58 - starboard/shared/win32/configuration.cc | 73 - starboard/shared/win32/configuration.h | 28 - .../shared/win32/decode_target_internal.cc | 60 - .../shared/win32/decode_target_internal.h | 34 - starboard/shared/win32/decrypting_decoder.cc | 366 ----- starboard/shared/win32/decrypting_decoder.h | 86 -- starboard/shared/win32/dialog.cc | 252 --- starboard/shared/win32/dialog.h | 48 - starboard/shared/win32/directory_can_open.cc | 55 - starboard/shared/win32/directory_close.cc | 32 - starboard/shared/win32/directory_create.cc | 46 - starboard/shared/win32/directory_get_next.cc | 98 -- starboard/shared/win32/directory_internal.cc | 108 -- starboard/shared/win32/directory_internal.h | 80 - starboard/shared/win32/directory_open.cc | 65 - starboard/shared/win32/drm_create_system.cc | 48 - .../shared/win32/drm_system_playready.cc | 378 ----- starboard/shared/win32/drm_system_playready.h | 132 -- .../shared/win32/dx_context_video_decoder.cc | 70 - .../shared/win32/dx_context_video_decoder.h | 38 - starboard/shared/win32/environment.cc | 33 - starboard/shared/win32/error_utils.cc | 197 --- starboard/shared/win32/error_utils.h | 66 - starboard/shared/win32/file_atomic_replace.cc | 68 - starboard/shared/win32/file_can_open.cc | 58 - starboard/shared/win32/file_close.cc | 42 - starboard/shared/win32/file_delete.cc | 43 - starboard/shared/win32/file_exists.cc | 56 - starboard/shared/win32/file_flush.cc | 32 - starboard/shared/win32/file_get_info.cc | 62 - starboard/shared/win32/file_get_path_info.cc | 108 -- starboard/shared/win32/file_internal.cc | 192 --- starboard/shared/win32/file_internal.h | 74 - starboard/shared/win32/file_open.cc | 45 - starboard/shared/win32/file_read.cc | 51 - starboard/shared/win32/file_seek.cc | 42 - starboard/shared/win32/file_truncate.cc | 106 -- starboard/shared/win32/file_write.cc | 46 - starboard/shared/win32/get_home_directory.cc | 92 -- starboard/shared/win32/graphics.cc | 53 - starboard/shared/win32/graphics.h | 28 - starboard/shared/win32/gyp_configuration.py | 23 - .../win32/hardware_decode_target_internal.cc | 385 ----- .../win32/hardware_decode_target_internal.h | 68 - starboard/shared/win32/log.cc | 19 - starboard/shared/win32/log_file_impl.cc | 123 -- starboard/shared/win32/log_file_impl.h | 50 - starboard/shared/win32/log_flush.cc | 21 - starboard/shared/win32/log_format.cc | 19 - starboard/shared/win32/log_raw.cc | 32 - starboard/shared/win32/log_raw_dump_stack.cc | 19 - starboard/shared/win32/log_raw_format.cc | 34 - starboard/shared/win32/media_common.cc | 156 -- starboard/shared/win32/media_common.h | 78 - .../shared/win32/media_foundation_utils.cc | 273 ---- .../shared/win32/media_foundation_utils.h | 37 - .../win32/media_get_max_buffer_capacity.cc | 25 - .../shared/win32/media_is_audio_supported.cc | 31 - starboard/shared/win32/media_is_supported.cc | 28 - .../shared/win32/media_is_video_supported.cc | 137 -- starboard/shared/win32/media_transform.cc | 384 ----- starboard/shared/win32/media_transform.h | 115 -- .../memory_allocate_aligned_unchecked.cc | 23 - .../shared/win32/memory_allocate_unchecked.cc | 21 - starboard/shared/win32/memory_flush.cc | 32 - starboard/shared/win32/memory_free.cc | 21 - starboard/shared/win32/memory_free_aligned.cc | 23 - starboard/shared/win32/memory_map.cc | 53 - starboard/shared/win32/memory_protect.cc | 61 - .../win32/memory_reallocate_unchecked.cc | 27 - starboard/shared/win32/memory_unmap.cc | 26 - starboard/shared/win32/mini_dump_printer.py | 60 - starboard/shared/win32/minidump.cc | 130 -- starboard/shared/win32/minidump.h | 37 - starboard/shared/win32/mutex_acquire.cc | 31 - starboard/shared/win32/mutex_acquire_try.cc | 31 - starboard/shared/win32/mutex_create.cc | 34 - starboard/shared/win32/mutex_destroy.cc | 41 - starboard/shared/win32/mutex_release.cc | 31 - starboard/shared/win32/once.cc | 44 - .../shared/win32/player_components_factory.cc | 118 -- starboard/shared/win32/playready_license.cc | 31 - starboard/shared/win32/posix_emu/dirent.cc | 241 --- starboard/shared/win32/posix_emu/ifaddrs.cc | 70 - .../win32/posix_emu/include/arpa/inet.h | 25 - .../shared/win32/posix_emu/include/dirent.h | 55 - .../shared/win32/posix_emu/include/fcntl.h | 67 - .../shared/win32/posix_emu/include/ifaddrs.h | 38 - .../shared/win32/posix_emu/include/malloc.h | 34 - .../shared/win32/posix_emu/include/netdb.h | 22 - .../win32/posix_emu/include/netinet/in.h | 23 - .../win32/posix_emu/include/netinet/tcp.h | 20 - .../shared/win32/posix_emu/include/pthread.h | 113 -- .../remove_problematic_windows_macros.h | 26 - .../shared/win32/posix_emu/include/sched.h | 28 - .../shared/win32/posix_emu/include/stdlib.h | 36 - .../shared/win32/posix_emu/include/string.h | 33 - .../shared/win32/posix_emu/include/strings.h | 32 - .../shared/win32/posix_emu/include/sys/mman.h | 43 - .../win32/posix_emu/include/sys/socket.h | 81 - .../shared/win32/posix_emu/include/sys/stat.h | 44 - .../shared/win32/posix_emu/include/sys/time.h | 37 - .../shared/win32/posix_emu/include/time.h | 42 - .../shared/win32/posix_emu/include/unistd.h | 48 - starboard/shared/win32/posix_emu/mman.cc | 103 -- starboard/shared/win32/posix_emu/pthread.cc | 412 ----- starboard/shared/win32/posix_emu/sched.cc | 24 - starboard/shared/win32/posix_emu/socket.cc | 547 ------- starboard/shared/win32/posix_emu/stat.cc | 23 - starboard/shared/win32/posix_emu/stdlib.cc | 102 -- starboard/shared/win32/posix_emu/string.cc | 23 - starboard/shared/win32/posix_emu/strings.cc | 28 - starboard/shared/win32/posix_emu/time.cc | 110 -- starboard/shared/win32/posix_emu/usleep.cc | 28 - .../shared/win32/set_non_blocking_internal.cc | 31 - .../shared/win32/set_non_blocking_internal.h | 33 - starboard/shared/win32/socket_accept.cc | 52 - starboard/shared/win32/socket_bind.cc | 95 -- .../shared/win32/socket_clear_last_error.cc | 26 - starboard/shared/win32/socket_connect.cc | 59 - starboard/shared/win32/socket_create.cc | 122 -- starboard/shared/win32/socket_destroy.cc | 39 - .../shared/win32/socket_free_resolution.cc | 29 - .../win32/socket_get_interface_address.cc | 288 ---- .../shared/win32/socket_get_last_error.cc | 25 - .../shared/win32/socket_get_local_address.cc | 66 - starboard/shared/win32/socket_internal.cc | 205 --- starboard/shared/win32/socket_internal.h | 163 -- starboard/shared/win32/socket_is_connected.cc | 41 - .../win32/socket_is_connected_and_idle.cc | 40 - .../win32/socket_join_multicast_group.cc | 52 - starboard/shared/win32/socket_listen.cc | 57 - starboard/shared/win32/socket_receive_from.cc | 107 -- starboard/shared/win32/socket_resolve.cc | 90 -- starboard/shared/win32/socket_send_to.cc | 110 -- .../shared/win32/socket_set_broadcast.cc | 26 - .../win32/socket_set_receive_buffer_size.cc | 26 - .../shared/win32/socket_set_reuse_address.cc | 26 - .../win32/socket_set_send_buffer_size.cc | 26 - .../shared/win32/socket_set_tcp_keep_alive.cc | 28 - .../shared/win32/socket_set_tcp_no_delay.cc | 26 - .../win32/socket_set_tcp_window_scaling.cc | 47 - starboard/shared/win32/socket_waiter_add.cc | 78 - .../shared/win32/socket_waiter_create.cc | 21 - .../shared/win32/socket_waiter_destroy.cc | 25 - .../shared/win32/socket_waiter_internal.cc | 759 --------- .../shared/win32/socket_waiter_internal.h | 213 --- .../shared/win32/socket_waiter_remove.cc | 35 - starboard/shared/win32/socket_waiter_wait.cc | 25 - .../shared/win32/socket_waiter_wait_timed.cc | 26 - .../shared/win32/socket_waiter_wake_up.cc | 25 - starboard/shared/win32/starboard_main.cc | 101 -- starboard/shared/win32/starboard_main.h | 22 - .../shared/win32/storage_write_record.cc | 104 -- .../shared/win32/string_compare_no_case.cc | 23 - .../shared/win32/string_compare_no_case_n.cc | 25 - starboard/shared/win32/string_format.cc | 24 - starboard/shared/win32/string_format_wide.cc | 26 - .../win32/system_break_into_debugger.cc | 27 - .../shared/win32/system_clear_last_error.cc | 21 - .../shared/win32/system_get_error_string.cc | 31 - .../shared/win32/system_get_extensions.cc | 31 - .../shared/win32/system_get_last_error.cc | 21 - .../shared/win32/system_get_locale_id.cc | 54 - .../win32/system_get_number_of_processors.cc | 24 - starboard/shared/win32/system_get_property.cc | 83 - .../shared/win32/system_get_random_data.cc | 42 - .../shared/win32/system_get_random_uint64.cc | 21 - starboard/shared/win32/system_get_stack.cc | 24 - .../win32/system_get_total_cpu_memory.cc | 24 - .../win32/system_get_used_cpu_memory.cc | 29 - .../win32/system_is_debugger_attached.cc | 21 - .../win32/system_raise_platform_error.cc | 25 - starboard/shared/win32/system_symbolize.cc | 108 -- starboard/shared/win32/test_filters.py | 50 - starboard/shared/win32/thread_create.cc | 233 --- .../shared/win32/thread_create_local_key.cc | 73 - .../shared/win32/thread_destroy_local_key.cc | 46 - starboard/shared/win32/thread_detach.cc | 37 - starboard/shared/win32/thread_get_current.cc | 28 - starboard/shared/win32/thread_get_id.cc | 21 - .../shared/win32/thread_get_local_value.cc | 33 - starboard/shared/win32/thread_get_name.cc | 32 - starboard/shared/win32/thread_is_equal.cc | 23 - starboard/shared/win32/thread_join.cc | 51 - .../shared/win32/thread_local_internal.cc | 72 - .../shared/win32/thread_local_internal.h | 37 - starboard/shared/win32/thread_private.cc | 87 -- starboard/shared/win32/thread_private.h | 136 -- .../shared/win32/thread_set_local_value.cc | 33 - starboard/shared/win32/thread_set_name.cc | 70 - starboard/shared/win32/thread_sleep.cc | 28 - starboard/shared/win32/thread_yield.cc | 21 - .../shared/win32/time_get_monotonic_now.cc | 51 - starboard/shared/win32/time_get_now.cc | 34 - starboard/shared/win32/time_utils.h | 56 - .../shared/win32/time_zone_get_current.cc | 36 - starboard/shared/win32/time_zone_get_name.cc | 62 - starboard/shared/win32/types_internal.h | 33 - starboard/shared/win32/video_decoder.cc | 797 ---------- starboard/shared/win32/video_decoder.h | 170 -- starboard/shared/win32/wasapi_include.h | 67 - starboard/shared/win32/wchar_utils.h | 60 - starboard/shared/win32/win32_audio_decoder.cc | 255 --- starboard/shared/win32/win32_audio_decoder.h | 61 - starboard/shared/win32/window_create.cc | 23 - starboard/shared/win32/window_destroy.cc | 22 - .../win32/window_get_platform_handle.cc | 26 - starboard/shared/win32/window_get_size.cc | 30 - starboard/shared/win32/window_internal.cc | 32 - starboard/shared/win32/window_internal.h | 42 - .../win32/window_set_default_options.cc | 23 - starboard/shared/win32/wrm_header.cc | 395 ----- starboard/shared/win32/wrm_header.h | 57 - starboard/storage.h | 34 - starboard/stub/BUILD.gn | 74 - starboard/stub/configuration_constants.cc | 5 - starboard/stub/configuration_public.h | 8 - starboard/thread.h | 178 +-- starboard/time.h | 92 -- starboard/tools/port_symlink.py | 47 +- starboard/tools/port_symlink_test.py | 3 +- starboard/tools/win_symlink.py | 288 ---- starboard/tools/win_symlink_fast.py | 223 --- starboard/tools/win_symlink_fast_test.py | 54 - starboard/tools/win_symlink_test.py | 85 - starboard/ui_navigation.h | 277 ---- starboard/user.h | 94 -- starboard/win/__init__.py | 0 starboard/win/i18n/en-US.xlb | 7 - starboard/win/shared/BUILD.gn | 352 ----- .../win/shared/configuration_constants.cc | 148 -- starboard/win/shared/configuration_public.h | 60 - .../shared/platform_configuration/BUILD.gn | 97 -- .../platform_configuration/configuration.gni | 29 - starboard/win/shared/system_get_path.cc | 179 --- starboard/win/win32/BUILD.gn | 85 - starboard/win/win32/__init__.py | 0 starboard/win/win32/args.gn | 18 - starboard/win/win32/atomic_public.h | 20 - starboard/win/win32/cobalt/configuration.py | 59 - starboard/win/win32/configuration_public.h | 23 - starboard/win/win32/gyp_configuration.py | 43 - starboard/win/win32/i18n/BUILD.gn | 20 - starboard/win/win32/i18n/en.xlb | 8 - starboard/win/win32/launcher.py | 90 -- starboard/win/win32/main.cc | 19 - .../win/win32/platform_configuration/BUILD.gn | 72 - .../platform_configuration/configuration.gni | 19 - starboard/win/win32/test_filters.py | 108 -- starboard/win/win32/toolchain/BUILD.gn | 31 - starboard/window.h | 88 -- starboard/xb1/BUILD.gn | 253 --- starboard/xb1/__init__.py | 17 - starboard/xb1/appx_product_settings.py | 75 - starboard/xb1/args.gn | 18 - .../assets/Square150x150Logo.scale-100.png | Bin 7212 -> 0 bytes .../assets/Square310x310Logo.scale-100.png | Bin 16100 -> 0 bytes .../xb1/assets/Square44x44Logo.scale-100.png | Bin 2106 -> 0 bytes .../xb1/assets/Square71x71Logo.scale-100.png | Bin 3405 -> 0 bytes .../xb1/assets/Wide310x150Logo.scale-100.png | Bin 10063 -> 0 bytes starboard/xb1/atomic_public.h | 20 - starboard/xb1/cert/README.md | 32 - starboard/xb1/cert/cobalt.pfx | Bin 3255 -> 0 bytes starboard/xb1/cobalt/__init__.py | 0 starboard/xb1/cobalt/configuration.py | 48 - starboard/xb1/cobalt/package.py | 35 - starboard/xb1/configuration_public.h | 25 - starboard/xb1/gyp_configuration.py | 38 - starboard/xb1/i18n/BUILD.gn | 57 - starboard/xb1/i18n/da.xlb | 12 - starboard/xb1/i18n/de-AT.xlb | 12 - starboard/xb1/i18n/de-CH.xlb | 12 - starboard/xb1/i18n/de.xlb | 12 - starboard/xb1/i18n/en-AU.xlb | 12 - starboard/xb1/i18n/en-CA.xlb | 12 - starboard/xb1/i18n/en-GB.xlb | 12 - starboard/xb1/i18n/en-IE.xlb | 12 - starboard/xb1/i18n/en.xlb | 12 - starboard/xb1/i18n/es-419.xlb | 12 - starboard/xb1/i18n/es-AR.xlb | 12 - starboard/xb1/i18n/es-CL.xlb | 12 - starboard/xb1/i18n/es-CO.xlb | 12 - starboard/xb1/i18n/es-MX.xlb | 12 - starboard/xb1/i18n/es-US.xlb | 12 - starboard/xb1/i18n/es.xlb | 12 - starboard/xb1/i18n/fi.xlb | 12 - starboard/xb1/i18n/fr-CA.xlb | 12 - starboard/xb1/i18n/fr-CH.xlb | 12 - starboard/xb1/i18n/fr.xlb | 12 - starboard/xb1/i18n/it.xlb | 12 - starboard/xb1/i18n/ja.xlb | 12 - starboard/xb1/i18n/ko.xlb | 12 - starboard/xb1/i18n/nb.xlb | 12 - starboard/xb1/i18n/nl.xlb | 12 - starboard/xb1/i18n/pl.xlb | 12 - starboard/xb1/i18n/pt-BR.xlb | 12 - starboard/xb1/i18n/pt-PT.xlb | 12 - starboard/xb1/i18n/pt.xlb | 12 - starboard/xb1/i18n/ru.xlb | 12 - starboard/xb1/i18n/sv.xlb | 12 - starboard/xb1/i18n/tr.xlb | 12 - starboard/xb1/i18n/zh-CN.xlb | 12 - starboard/xb1/i18n/zh-HK.xlb | 12 - starboard/xb1/i18n/zh-TW.xlb | 12 - starboard/xb1/i18n/zh.xlb | 12 - starboard/xb1/install_target.gni | 168 -- starboard/xb1/install_target/BUILD.gn | 64 - starboard/xb1/launcher.py | 72 - starboard/xb1/platform_configuration/BUILD.gn | 83 - .../platform_configuration/configuration.gni | 25 - starboard/xb1/public_system_properties.cc | 18 - starboard/xb1/shared/BUILD.gn | 30 - starboard/xb1/shared/configuration.cc | 73 - starboard/xb1/shared/configuration.h | 28 - .../xb1/shared/configuration_constants.cc | 145 -- starboard/xb1/shared/configuration_public.h | 60 - .../xb1/shared/gpu_base_video_decoder.cc | 793 ---------- starboard/xb1/shared/gpu_base_video_decoder.h | 268 ---- starboard/xb1/shared/internal_shims.h | 41 - starboard/xb1/shared/internal_stubs.cc | 44 - starboard/xb1/shared/playready_license.cc | 371 ----- starboard/xb1/shared/system_get_extensions.cc | 36 - starboard/xb1/shared/system_get_path.cc | 228 --- starboard/xb1/shared/video_decoder_uwp.cc | 107 -- starboard/xb1/shared/video_decoder_uwp.h | 64 - starboard/xb1/shared/video_frame_impl.h | 46 - starboard/xb1/system_properties.h | 23 - .../templates/ApplicationSection.xml.template | 50 - .../xb1/templates/AppxManifest.xml.template | 229 --- starboard/xb1/test_filters.py | 71 - starboard/xb1/toolchain/BUILD.gn | 31 - starboard/xb1/tools/__init__.py | 0 .../tools/application_section_generator.py | 126 -- starboard/xb1/tools/appx.py | 200 --- .../xb1/tools/list_apps_in_uwp_package.ps1 | 30 - .../xb1/tools/list_running_processes.ps1 | 17 - starboard/xb1/tools/list_uwp_packages.ps1 | 15 - starboard/xb1/tools/packager.py | 321 ---- starboard/xb1/tools/register_uwp_package.ps1 | 16 - starboard/xb1/tools/remove_uwp_package.ps1 | 16 - starboard/xb1/tools/stop_process_by_id.ps1 | 16 - starboard/xb1/tools/uwp_api.py | 443 ------ starboard/xb1/tools/uwp_launcher.py | 273 ---- starboard/xb1/tools/xb1_launcher.py | 640 -------- starboard/xb1/tools/xb1_network_api.py | 843 ---------- .../include/gtest/internal/gtest-port.h | 5 - third_party/musl/BUILD.gn | 17 - third_party/musl/src/starboard/dirent.c | 67 - .../src/starboard/errno/__errno_location.c | 48 - .../musl/src/starboard/malloc/malloc.c | 27 - .../src/starboard/malloc/posix_memalign.c | 22 - third_party/musl/src/starboard/mman/mman.c | 61 - .../musl/src/starboard/network/socket.c | 959 ------------ .../musl/src/starboard/pthread/pthread.c | 262 ---- third_party/musl/src/starboard/sched/sched.c | 25 - .../musl/src/starboard/stdio/vsnprintf.c | 10 - .../musl/src/starboard/stdio/vsscanf.c | 10 - .../musl/src/starboard/stdio/vswprintf.c | 10 - third_party/musl/src/starboard/sys/stat.c | 56 - .../src/starboard/sys/time/gettimeofday.c | 22 - .../musl/src/starboard/time/clock_gettime.c | 39 - .../musl/src/starboard/time/gmtime_r.c | 28 - third_party/musl/src/starboard/time/time.c | 18 - .../musl/src/starboard/unistd/unistd.c | 44 - v8/src/base/platform/condition-variable.cc | 28 - v8/src/base/platform/condition-variable.h | 8 - v8/src/base/platform/mutex.cc | 16 - v8/src/base/platform/mutex.h | 4 - v8/src/libsampler/sampler.cc | 8 - 774 files changed, 29 insertions(+), 53945 deletions(-) delete mode 100644 starboard/android/shared/directory_close.cc delete mode 100644 starboard/android/shared/directory_get_next.cc delete mode 100644 starboard/android/shared/directory_internal.h delete mode 100644 starboard/android/shared/directory_open.cc delete mode 100644 starboard/android/shared/file_can_open.cc delete mode 100644 starboard/android/shared/file_close.cc delete mode 100644 starboard/android/shared/file_delete.cc delete mode 100644 starboard/android/shared/file_exists.cc delete mode 100644 starboard/android/shared/file_flush.cc delete mode 100644 starboard/android/shared/file_get_info.cc delete mode 100644 starboard/android/shared/file_get_path_info.cc delete mode 100644 starboard/android/shared/file_open.cc delete mode 100644 starboard/android/shared/file_read.cc delete mode 100644 starboard/android/shared/file_seek.cc delete mode 100644 starboard/android/shared/file_truncate.cc delete mode 100644 starboard/android/shared/file_write.cc delete mode 100644 starboard/android/shared/thread_create.cc delete mode 100644 starboard/android/shared/thread_get_name.cc delete mode 100644 starboard/nplb/accessibility_test.cc delete mode 100644 starboard/nplb/byte_swap_test.cc delete mode 100644 starboard/nplb/condition_variable_broadcast_test.cc delete mode 100644 starboard/nplb/condition_variable_create_test.cc delete mode 100644 starboard/nplb/condition_variable_destroy_test.cc delete mode 100644 starboard/nplb/condition_variable_signal_test.cc delete mode 100644 starboard/nplb/condition_variable_wait_test.cc delete mode 100644 starboard/nplb/condition_variable_wait_timed_test.cc delete mode 100644 starboard/nplb/directory_can_open_test.cc delete mode 100644 starboard/nplb/directory_close_test.cc delete mode 100644 starboard/nplb/directory_create_test.cc delete mode 100644 starboard/nplb/directory_get_next_test.cc delete mode 100644 starboard/nplb/directory_open_test.cc delete mode 100644 starboard/nplb/file_can_open_test.cc delete mode 100644 starboard/nplb/file_close_test.cc delete mode 100644 starboard/nplb/file_delete_test.cc delete mode 100644 starboard/nplb/file_flush_test.cc delete mode 100644 starboard/nplb/file_get_info_test.cc delete mode 100644 starboard/nplb/file_get_path_info_test.cc delete mode 100644 starboard/nplb/file_mode_string_to_flags_test.cc delete mode 100644 starboard/nplb/file_open_test.cc delete mode 100644 starboard/nplb/file_read_test.cc delete mode 100644 starboard/nplb/file_read_write_all_test.cc delete mode 100644 starboard/nplb/file_seek_test.cc delete mode 100644 starboard/nplb/file_truncate_test.cc delete mode 100644 starboard/nplb/file_write_test.cc delete mode 100644 starboard/nplb/image_test.cc delete mode 100644 starboard/nplb/log_is_tty_test.cc delete mode 100644 starboard/nplb/memory_allocate_aligned_test.cc delete mode 100644 starboard/nplb/memory_allocate_test.cc delete mode 100644 starboard/nplb/memory_deallocate_aligned_test.cc delete mode 100644 starboard/nplb/memory_deallocate_test.cc delete mode 100644 starboard/nplb/memory_map_test.cc delete mode 100644 starboard/nplb/memory_reallocate_test.cc delete mode 100644 starboard/nplb/mutex_acquire_test.cc delete mode 100644 starboard/nplb/mutex_acquire_try_test.cc delete mode 100644 starboard/nplb/mutex_create_test.cc delete mode 100644 starboard/nplb/mutex_destroy_test.cc delete mode 100644 starboard/nplb/once_test.cc delete mode 100644 starboard/nplb/string_compare_no_case_n_test.cc delete mode 100644 starboard/nplb/string_compare_no_case_test.cc delete mode 100644 starboard/nplb/string_duplicate_test.cc delete mode 100644 starboard/nplb/string_format_test.cc delete mode 100644 starboard/nplb/string_format_wide_test.cc delete mode 100644 starboard/nplb/string_scan_test.cc delete mode 100644 starboard/nplb/thread_create_test.cc delete mode 100644 starboard/nplb/thread_detach_test.cc delete mode 100644 starboard/nplb/thread_get_current_test.cc delete mode 100644 starboard/nplb/thread_get_name_test.cc delete mode 100644 starboard/nplb/thread_helpers.cc delete mode 100644 starboard/nplb/thread_is_equal_test.cc delete mode 100644 starboard/nplb/thread_join_test.cc delete mode 100644 starboard/nplb/thread_local_value_test.cc delete mode 100644 starboard/nplb/thread_set_name_test.cc delete mode 100644 starboard/nplb/thread_sleep_test.cc delete mode 100644 starboard/nplb/thread_yield_test.cc delete mode 100644 starboard/nplb/time_get_monotonic_now_test.cc delete mode 100644 starboard/nplb/time_get_now_test.cc delete mode 100644 starboard/nplb/time_narrow_test.cc delete mode 100644 starboard/nplb/user_get_current_test.cc delete mode 100644 starboard/nplb/user_get_property_test.cc delete mode 100644 starboard/nplb/user_get_signed_in_test.cc delete mode 100644 starboard/raspi/shared/open_max/image_decode.cc delete mode 100644 starboard/raspi/shared/open_max/image_is_decode_supported.cc delete mode 100644 starboard/shared/iso/directory_close.cc delete mode 100644 starboard/shared/iso/directory_get_next.cc delete mode 100644 starboard/shared/iso/directory_internal.h delete mode 100644 starboard/shared/iso/directory_open.cc delete mode 100644 starboard/shared/iso/impl/directory_close.h delete mode 100644 starboard/shared/iso/impl/directory_get_next.h delete mode 100644 starboard/shared/iso/impl/directory_impl.h delete mode 100644 starboard/shared/iso/impl/directory_open.h delete mode 100644 starboard/shared/iso/string_scan.cc delete mode 100644 starboard/shared/libjpeg/image_decode.cc delete mode 100644 starboard/shared/libjpeg/image_is_decode_supported.cc delete mode 100644 starboard/shared/linux/byte_swap.cc delete mode 100644 starboard/shared/linux/thread_get_name.cc delete mode 100644 starboard/shared/linux/thread_set_name.cc delete mode 100644 starboard/shared/nouser/user_get_current.cc delete mode 100644 starboard/shared/nouser/user_get_property.cc delete mode 100644 starboard/shared/nouser/user_get_signed_in.cc delete mode 100644 starboard/shared/nouser/user_internal.cc delete mode 100644 starboard/shared/nouser/user_internal.h delete mode 100644 starboard/shared/posix/directory_create.cc delete mode 100644 starboard/shared/posix/file_can_open.cc delete mode 100644 starboard/shared/posix/file_close.cc delete mode 100644 starboard/shared/posix/file_delete.cc delete mode 100644 starboard/shared/posix/file_exists.cc delete mode 100644 starboard/shared/posix/file_flush.cc delete mode 100644 starboard/shared/posix/file_get_info.cc delete mode 100644 starboard/shared/posix/file_get_path_info.cc delete mode 100644 starboard/shared/posix/file_open.cc delete mode 100644 starboard/shared/posix/file_read.cc delete mode 100644 starboard/shared/posix/file_seek.cc delete mode 100644 starboard/shared/posix/file_truncate.cc delete mode 100644 starboard/shared/posix/file_write.cc delete mode 100644 starboard/shared/posix/log_is_tty.cc delete mode 100644 starboard/shared/posix/memory_flush.cc delete mode 100644 starboard/shared/posix/memory_map.cc delete mode 100644 starboard/shared/posix/memory_protect.cc delete mode 100644 starboard/shared/posix/memory_unmap.cc delete mode 100644 starboard/shared/posix/string_compare_no_case.cc delete mode 100644 starboard/shared/posix/string_compare_no_case_n.cc delete mode 100644 starboard/shared/posix/string_format.cc delete mode 100644 starboard/shared/posix/string_format_wide.cc delete mode 100644 starboard/shared/posix/time_get_monotonic_now.cc delete mode 100644 starboard/shared/posix/time_get_monotonic_thread_now.cc delete mode 100644 starboard/shared/posix/time_get_now.cc delete mode 100644 starboard/shared/posix/time_is_time_thread_now_supported.cc delete mode 100644 starboard/shared/pthread/condition_variable_broadcast.cc delete mode 100644 starboard/shared/pthread/condition_variable_create.cc delete mode 100644 starboard/shared/pthread/condition_variable_destroy.cc delete mode 100644 starboard/shared/pthread/condition_variable_signal.cc delete mode 100644 starboard/shared/pthread/condition_variable_wait.cc delete mode 100644 starboard/shared/pthread/condition_variable_wait_timed.cc delete mode 100644 starboard/shared/pthread/mutex_acquire.cc delete mode 100644 starboard/shared/pthread/mutex_acquire_try.cc delete mode 100644 starboard/shared/pthread/mutex_create.cc delete mode 100644 starboard/shared/pthread/mutex_destroy.cc delete mode 100644 starboard/shared/pthread/mutex_release.cc delete mode 100644 starboard/shared/pthread/once.cc delete mode 100644 starboard/shared/pthread/thread_create.cc delete mode 100644 starboard/shared/pthread/thread_create_local_key.cc delete mode 100644 starboard/shared/pthread/thread_destroy_local_key.cc delete mode 100644 starboard/shared/pthread/thread_detach.cc delete mode 100644 starboard/shared/pthread/thread_get_current.cc delete mode 100644 starboard/shared/pthread/thread_get_local_value.cc delete mode 100644 starboard/shared/pthread/thread_is_equal.cc delete mode 100644 starboard/shared/pthread/thread_join.cc delete mode 100644 starboard/shared/pthread/thread_set_local_value.cc delete mode 100644 starboard/shared/starboard/directory_can_open.cc delete mode 100644 starboard/shared/starboard/file_mode_string_to_flags.cc delete mode 100644 starboard/shared/starboard/media/media_get_buffer_storage_type.cc delete mode 100644 starboard/shared/starboard/memory.cc delete mode 100644 starboard/shared/starboard/string_duplicate.cc delete mode 100644 starboard/shared/stub/accessibility_get_caption_settings.cc delete mode 100644 starboard/shared/stub/accessibility_get_display_settings.cc delete mode 100644 starboard/shared/stub/accessibility_get_text_to_speech_settings.cc delete mode 100644 starboard/shared/stub/accessibility_set_captions_enabled.cc delete mode 100644 starboard/shared/stub/byte_swap.cc delete mode 100644 starboard/shared/stub/condition_variable_broadcast.cc delete mode 100644 starboard/shared/stub/condition_variable_create.cc delete mode 100644 starboard/shared/stub/condition_variable_destroy.cc delete mode 100644 starboard/shared/stub/condition_variable_signal.cc delete mode 100644 starboard/shared/stub/condition_variable_wait.cc delete mode 100644 starboard/shared/stub/condition_variable_wait_timed.cc delete mode 100644 starboard/shared/stub/directory_can_open.cc delete mode 100644 starboard/shared/stub/directory_close.cc delete mode 100644 starboard/shared/stub/directory_create.cc delete mode 100644 starboard/shared/stub/directory_get_next.cc delete mode 100644 starboard/shared/stub/directory_open.cc delete mode 100644 starboard/shared/stub/file_can_open.cc delete mode 100644 starboard/shared/stub/file_close.cc delete mode 100644 starboard/shared/stub/file_delete.cc delete mode 100644 starboard/shared/stub/file_exists.cc delete mode 100644 starboard/shared/stub/file_flush.cc delete mode 100644 starboard/shared/stub/file_get_info.cc delete mode 100644 starboard/shared/stub/file_get_path_info.cc delete mode 100644 starboard/shared/stub/file_open.cc delete mode 100644 starboard/shared/stub/file_read.cc delete mode 100644 starboard/shared/stub/file_seek.cc delete mode 100644 starboard/shared/stub/file_truncate.cc delete mode 100644 starboard/shared/stub/file_write.cc delete mode 100644 starboard/shared/stub/image_decode.cc delete mode 100644 starboard/shared/stub/image_is_decode_supported.cc delete mode 100644 starboard/shared/stub/media_get_buffer_storage_type.cc delete mode 100644 starboard/shared/stub/mutex_acquire.cc delete mode 100644 starboard/shared/stub/mutex_acquire_try.cc delete mode 100644 starboard/shared/stub/mutex_create.cc delete mode 100644 starboard/shared/stub/mutex_destroy.cc delete mode 100644 starboard/shared/stub/mutex_release.cc delete mode 100644 starboard/shared/stub/once.cc delete mode 100644 starboard/shared/stub/string_compare_no_case.cc delete mode 100644 starboard/shared/stub/string_compare_no_case_n.cc delete mode 100644 starboard/shared/stub/string_duplicate.cc delete mode 100644 starboard/shared/stub/string_format.cc delete mode 100644 starboard/shared/stub/string_format_wide.cc delete mode 100644 starboard/shared/stub/string_scan.cc delete mode 100644 starboard/shared/stub/thread_create.cc delete mode 100644 starboard/shared/stub/thread_create_local_key.cc delete mode 100644 starboard/shared/stub/thread_destroy_local_key.cc delete mode 100644 starboard/shared/stub/thread_detach.cc delete mode 100644 starboard/shared/stub/thread_get_current.cc delete mode 100644 starboard/shared/stub/thread_get_local_value.cc delete mode 100644 starboard/shared/stub/thread_get_name.cc delete mode 100644 starboard/shared/stub/thread_is_equal.cc delete mode 100644 starboard/shared/stub/thread_join.cc delete mode 100644 starboard/shared/stub/thread_set_local_value.cc delete mode 100644 starboard/shared/stub/thread_set_name.cc delete mode 100644 starboard/shared/stub/time_get_monotonic_now.cc delete mode 100644 starboard/shared/stub/time_get_monotonic_thread_now.cc delete mode 100644 starboard/shared/stub/time_get_now.cc delete mode 100644 starboard/shared/stub/time_is_time_thread_now_supported.cc delete mode 100644 starboard/shared/stub/ui_nav_get_interface.cc delete mode 100644 starboard/shared/stub/user_get_current.cc delete mode 100644 starboard/shared/stub/user_get_property.cc delete mode 100644 starboard/shared/stub/user_get_signed_in.cc delete mode 100644 starboard/shared/stub/window_blur_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_focus_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc delete mode 100644 starboard/shared/stub/window_hide_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_is_on_screen_keyboard_shown.cc delete mode 100644 starboard/shared/stub/window_on_screen_keyboard_is_supported.cc delete mode 100644 starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc delete mode 100644 starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc delete mode 100644 starboard/shared/stub/window_show_on_screen_keyboard.cc delete mode 100644 starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc delete mode 100644 starboard/shared/uwp/analog_thumbstick_input.cc delete mode 100644 starboard/shared/uwp/analog_thumbstick_input.h delete mode 100644 starboard/shared/uwp/analog_thumbstick_input_thread.cc delete mode 100644 starboard/shared/uwp/analog_thumbstick_input_thread.h delete mode 100644 starboard/shared/uwp/app_accessors.h delete mode 100644 starboard/shared/uwp/application_uwp.cc delete mode 100644 starboard/shared/uwp/application_uwp.h delete mode 100644 starboard/shared/uwp/application_uwp_key_event.cc delete mode 100644 starboard/shared/uwp/async_utils.h delete mode 100644 starboard/shared/uwp/audio_renderer_passthrough.cc delete mode 100644 starboard/shared/uwp/audio_renderer_passthrough.h delete mode 100644 starboard/shared/uwp/decoder_utils.cc delete mode 100644 starboard/shared/uwp/decoder_utils.h delete mode 100644 starboard/shared/uwp/extended_resources_manager.cc delete mode 100644 starboard/shared/uwp/extended_resources_manager.h delete mode 100644 starboard/shared/uwp/get_home_directory.cc delete mode 100644 starboard/shared/uwp/keys.cc delete mode 100644 starboard/shared/uwp/keys.h delete mode 100644 starboard/shared/uwp/log_file_impl.cc delete mode 100644 starboard/shared/uwp/log_file_impl.h delete mode 100644 starboard/shared/uwp/log_raw.cc delete mode 100644 starboard/shared/uwp/log_raw_format.cc delete mode 100644 starboard/shared/uwp/log_writer_interface.h delete mode 100644 starboard/shared/uwp/log_writer_uwp.cc delete mode 100644 starboard/shared/uwp/log_writer_uwp.h delete mode 100644 starboard/shared/uwp/log_writer_win32.cc delete mode 100644 starboard/shared/uwp/log_writer_win32.h delete mode 100644 starboard/shared/uwp/media_get_audio_configuration.cc delete mode 100644 starboard/shared/uwp/media_is_audio_supported.cc delete mode 100644 starboard/shared/uwp/media_is_video_supported.cc delete mode 100644 starboard/shared/uwp/microphone_impl.cc delete mode 100644 starboard/shared/uwp/player_components_factory.cc delete mode 100644 starboard/shared/uwp/system_get_property.cc delete mode 100644 starboard/shared/uwp/system_get_property_test.cc delete mode 100644 starboard/shared/uwp/system_get_total_cpu_memory.cc delete mode 100644 starboard/shared/uwp/system_get_used_cpu_memory.cc delete mode 100644 starboard/shared/uwp/system_platform_error_internal.cc delete mode 100644 starboard/shared/uwp/system_platform_error_internal.h delete mode 100644 starboard/shared/uwp/system_raise_platform_error.cc delete mode 100644 starboard/shared/uwp/time_zone_get_name.cc delete mode 100644 starboard/shared/uwp/wasapi_audio.cc delete mode 100644 starboard/shared/uwp/wasapi_audio.h delete mode 100644 starboard/shared/uwp/wasapi_audio_sink.cc delete mode 100644 starboard/shared/uwp/wasapi_audio_sink.h delete mode 100644 starboard/shared/uwp/wasapi_audio_test.cc delete mode 100644 starboard/shared/uwp/watchdog_log.cc delete mode 100644 starboard/shared/uwp/watchdog_log.h delete mode 100644 starboard/shared/uwp/window_create.cc delete mode 100644 starboard/shared/uwp/window_destroy.cc delete mode 100644 starboard/shared/uwp/window_get_diagonal_size_in_inches.cc delete mode 100644 starboard/shared/uwp/window_get_platform_handle.cc delete mode 100644 starboard/shared/uwp/window_get_size.cc delete mode 100644 starboard/shared/uwp/window_internal.cc delete mode 100644 starboard/shared/uwp/window_internal.h delete mode 100644 starboard/shared/uwp/window_set_default_options.cc delete mode 100644 starboard/shared/uwp/xb1_get_type.cc delete mode 100644 starboard/shared/uwp/xb1_get_type.h delete mode 100644 starboard/shared/uwp/xb1_media_session_client.cc delete mode 100644 starboard/shared/uwp/xb1_media_session_client.h delete mode 100644 starboard/shared/win32/__init__.py delete mode 100644 starboard/shared/win32/adapter_utils.cc delete mode 100644 starboard/shared/win32/adapter_utils.h delete mode 100644 starboard/shared/win32/application_win32.cc delete mode 100644 starboard/shared/win32/application_win32.h delete mode 100644 starboard/shared/win32/application_win32_key_event.cc delete mode 100644 starboard/shared/win32/atomic_public.h delete mode 100644 starboard/shared/win32/atomic_queue.h delete mode 100644 starboard/shared/win32/audio_decoder.cc delete mode 100644 starboard/shared/win32/audio_decoder.h delete mode 100644 starboard/shared/win32/audio_decoder_thread.cc delete mode 100644 starboard/shared/win32/audio_decoder_thread.h delete mode 100644 starboard/shared/win32/audio_sink.cc delete mode 100644 starboard/shared/win32/audio_sink_get_max_channels.cc delete mode 100644 starboard/shared/win32/audio_sink_get_nearest_supported_sample_frequency.cc delete mode 100644 starboard/shared/win32/audio_sink_is_audio_frame_storage_type_supported.cc delete mode 100644 starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc delete mode 100644 starboard/shared/win32/audio_transform.cc delete mode 100644 starboard/shared/win32/audio_transform.h delete mode 100644 starboard/shared/win32/auto_event_handle.h delete mode 100644 starboard/shared/win32/byte_swap.cc delete mode 100644 starboard/shared/win32/condition_variable_broadcast.cc delete mode 100644 starboard/shared/win32/condition_variable_create.cc delete mode 100644 starboard/shared/win32/condition_variable_destroy.cc delete mode 100644 starboard/shared/win32/condition_variable_signal.cc delete mode 100644 starboard/shared/win32/condition_variable_wait.cc delete mode 100644 starboard/shared/win32/condition_variable_wait_timed.cc delete mode 100644 starboard/shared/win32/configuration.cc delete mode 100644 starboard/shared/win32/configuration.h delete mode 100644 starboard/shared/win32/decode_target_internal.cc delete mode 100644 starboard/shared/win32/decode_target_internal.h delete mode 100644 starboard/shared/win32/decrypting_decoder.cc delete mode 100644 starboard/shared/win32/decrypting_decoder.h delete mode 100644 starboard/shared/win32/dialog.cc delete mode 100644 starboard/shared/win32/dialog.h delete mode 100644 starboard/shared/win32/directory_can_open.cc delete mode 100644 starboard/shared/win32/directory_close.cc delete mode 100644 starboard/shared/win32/directory_create.cc delete mode 100644 starboard/shared/win32/directory_get_next.cc delete mode 100644 starboard/shared/win32/directory_internal.cc delete mode 100644 starboard/shared/win32/directory_internal.h delete mode 100644 starboard/shared/win32/directory_open.cc delete mode 100644 starboard/shared/win32/drm_create_system.cc delete mode 100644 starboard/shared/win32/drm_system_playready.cc delete mode 100644 starboard/shared/win32/drm_system_playready.h delete mode 100644 starboard/shared/win32/dx_context_video_decoder.cc delete mode 100644 starboard/shared/win32/dx_context_video_decoder.h delete mode 100644 starboard/shared/win32/environment.cc delete mode 100644 starboard/shared/win32/error_utils.cc delete mode 100644 starboard/shared/win32/error_utils.h delete mode 100644 starboard/shared/win32/file_atomic_replace.cc delete mode 100644 starboard/shared/win32/file_can_open.cc delete mode 100644 starboard/shared/win32/file_close.cc delete mode 100644 starboard/shared/win32/file_delete.cc delete mode 100644 starboard/shared/win32/file_exists.cc delete mode 100644 starboard/shared/win32/file_flush.cc delete mode 100644 starboard/shared/win32/file_get_info.cc delete mode 100644 starboard/shared/win32/file_get_path_info.cc delete mode 100644 starboard/shared/win32/file_internal.cc delete mode 100644 starboard/shared/win32/file_internal.h delete mode 100644 starboard/shared/win32/file_open.cc delete mode 100644 starboard/shared/win32/file_read.cc delete mode 100644 starboard/shared/win32/file_seek.cc delete mode 100644 starboard/shared/win32/file_truncate.cc delete mode 100644 starboard/shared/win32/file_write.cc delete mode 100644 starboard/shared/win32/get_home_directory.cc delete mode 100644 starboard/shared/win32/graphics.cc delete mode 100644 starboard/shared/win32/graphics.h delete mode 100644 starboard/shared/win32/gyp_configuration.py delete mode 100644 starboard/shared/win32/hardware_decode_target_internal.cc delete mode 100644 starboard/shared/win32/hardware_decode_target_internal.h delete mode 100644 starboard/shared/win32/log.cc delete mode 100644 starboard/shared/win32/log_file_impl.cc delete mode 100644 starboard/shared/win32/log_file_impl.h delete mode 100644 starboard/shared/win32/log_flush.cc delete mode 100644 starboard/shared/win32/log_format.cc delete mode 100644 starboard/shared/win32/log_raw.cc delete mode 100644 starboard/shared/win32/log_raw_dump_stack.cc delete mode 100644 starboard/shared/win32/log_raw_format.cc delete mode 100644 starboard/shared/win32/media_common.cc delete mode 100644 starboard/shared/win32/media_common.h delete mode 100644 starboard/shared/win32/media_foundation_utils.cc delete mode 100644 starboard/shared/win32/media_foundation_utils.h delete mode 100644 starboard/shared/win32/media_get_max_buffer_capacity.cc delete mode 100644 starboard/shared/win32/media_is_audio_supported.cc delete mode 100644 starboard/shared/win32/media_is_supported.cc delete mode 100644 starboard/shared/win32/media_is_video_supported.cc delete mode 100644 starboard/shared/win32/media_transform.cc delete mode 100644 starboard/shared/win32/media_transform.h delete mode 100644 starboard/shared/win32/memory_allocate_aligned_unchecked.cc delete mode 100644 starboard/shared/win32/memory_allocate_unchecked.cc delete mode 100644 starboard/shared/win32/memory_flush.cc delete mode 100644 starboard/shared/win32/memory_free.cc delete mode 100644 starboard/shared/win32/memory_free_aligned.cc delete mode 100644 starboard/shared/win32/memory_map.cc delete mode 100644 starboard/shared/win32/memory_protect.cc delete mode 100644 starboard/shared/win32/memory_reallocate_unchecked.cc delete mode 100644 starboard/shared/win32/memory_unmap.cc delete mode 100644 starboard/shared/win32/mini_dump_printer.py delete mode 100644 starboard/shared/win32/minidump.cc delete mode 100644 starboard/shared/win32/minidump.h delete mode 100644 starboard/shared/win32/mutex_acquire.cc delete mode 100644 starboard/shared/win32/mutex_acquire_try.cc delete mode 100644 starboard/shared/win32/mutex_create.cc delete mode 100644 starboard/shared/win32/mutex_destroy.cc delete mode 100644 starboard/shared/win32/mutex_release.cc delete mode 100644 starboard/shared/win32/once.cc delete mode 100644 starboard/shared/win32/player_components_factory.cc delete mode 100644 starboard/shared/win32/playready_license.cc delete mode 100644 starboard/shared/win32/posix_emu/dirent.cc delete mode 100644 starboard/shared/win32/posix_emu/ifaddrs.cc delete mode 100644 starboard/shared/win32/posix_emu/include/arpa/inet.h delete mode 100644 starboard/shared/win32/posix_emu/include/dirent.h delete mode 100644 starboard/shared/win32/posix_emu/include/fcntl.h delete mode 100644 starboard/shared/win32/posix_emu/include/ifaddrs.h delete mode 100644 starboard/shared/win32/posix_emu/include/malloc.h delete mode 100644 starboard/shared/win32/posix_emu/include/netdb.h delete mode 100644 starboard/shared/win32/posix_emu/include/netinet/in.h delete mode 100644 starboard/shared/win32/posix_emu/include/netinet/tcp.h delete mode 100644 starboard/shared/win32/posix_emu/include/pthread.h delete mode 100644 starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h delete mode 100644 starboard/shared/win32/posix_emu/include/sched.h delete mode 100644 starboard/shared/win32/posix_emu/include/stdlib.h delete mode 100644 starboard/shared/win32/posix_emu/include/string.h delete mode 100644 starboard/shared/win32/posix_emu/include/strings.h delete mode 100644 starboard/shared/win32/posix_emu/include/sys/mman.h delete mode 100644 starboard/shared/win32/posix_emu/include/sys/socket.h delete mode 100644 starboard/shared/win32/posix_emu/include/sys/stat.h delete mode 100644 starboard/shared/win32/posix_emu/include/sys/time.h delete mode 100644 starboard/shared/win32/posix_emu/include/time.h delete mode 100644 starboard/shared/win32/posix_emu/include/unistd.h delete mode 100644 starboard/shared/win32/posix_emu/mman.cc delete mode 100644 starboard/shared/win32/posix_emu/pthread.cc delete mode 100644 starboard/shared/win32/posix_emu/sched.cc delete mode 100644 starboard/shared/win32/posix_emu/socket.cc delete mode 100644 starboard/shared/win32/posix_emu/stat.cc delete mode 100644 starboard/shared/win32/posix_emu/stdlib.cc delete mode 100644 starboard/shared/win32/posix_emu/string.cc delete mode 100644 starboard/shared/win32/posix_emu/strings.cc delete mode 100644 starboard/shared/win32/posix_emu/time.cc delete mode 100644 starboard/shared/win32/posix_emu/usleep.cc delete mode 100644 starboard/shared/win32/set_non_blocking_internal.cc delete mode 100644 starboard/shared/win32/set_non_blocking_internal.h delete mode 100644 starboard/shared/win32/socket_accept.cc delete mode 100644 starboard/shared/win32/socket_bind.cc delete mode 100644 starboard/shared/win32/socket_clear_last_error.cc delete mode 100644 starboard/shared/win32/socket_connect.cc delete mode 100644 starboard/shared/win32/socket_create.cc delete mode 100644 starboard/shared/win32/socket_destroy.cc delete mode 100644 starboard/shared/win32/socket_free_resolution.cc delete mode 100644 starboard/shared/win32/socket_get_interface_address.cc delete mode 100644 starboard/shared/win32/socket_get_last_error.cc delete mode 100644 starboard/shared/win32/socket_get_local_address.cc delete mode 100644 starboard/shared/win32/socket_internal.cc delete mode 100644 starboard/shared/win32/socket_internal.h delete mode 100644 starboard/shared/win32/socket_is_connected.cc delete mode 100644 starboard/shared/win32/socket_is_connected_and_idle.cc delete mode 100644 starboard/shared/win32/socket_join_multicast_group.cc delete mode 100644 starboard/shared/win32/socket_listen.cc delete mode 100644 starboard/shared/win32/socket_receive_from.cc delete mode 100644 starboard/shared/win32/socket_resolve.cc delete mode 100644 starboard/shared/win32/socket_send_to.cc delete mode 100644 starboard/shared/win32/socket_set_broadcast.cc delete mode 100644 starboard/shared/win32/socket_set_receive_buffer_size.cc delete mode 100644 starboard/shared/win32/socket_set_reuse_address.cc delete mode 100644 starboard/shared/win32/socket_set_send_buffer_size.cc delete mode 100644 starboard/shared/win32/socket_set_tcp_keep_alive.cc delete mode 100644 starboard/shared/win32/socket_set_tcp_no_delay.cc delete mode 100644 starboard/shared/win32/socket_set_tcp_window_scaling.cc delete mode 100644 starboard/shared/win32/socket_waiter_add.cc delete mode 100644 starboard/shared/win32/socket_waiter_create.cc delete mode 100644 starboard/shared/win32/socket_waiter_destroy.cc delete mode 100644 starboard/shared/win32/socket_waiter_internal.cc delete mode 100644 starboard/shared/win32/socket_waiter_internal.h delete mode 100644 starboard/shared/win32/socket_waiter_remove.cc delete mode 100644 starboard/shared/win32/socket_waiter_wait.cc delete mode 100644 starboard/shared/win32/socket_waiter_wait_timed.cc delete mode 100644 starboard/shared/win32/socket_waiter_wake_up.cc delete mode 100644 starboard/shared/win32/starboard_main.cc delete mode 100644 starboard/shared/win32/starboard_main.h delete mode 100644 starboard/shared/win32/storage_write_record.cc delete mode 100644 starboard/shared/win32/string_compare_no_case.cc delete mode 100644 starboard/shared/win32/string_compare_no_case_n.cc delete mode 100644 starboard/shared/win32/string_format.cc delete mode 100644 starboard/shared/win32/string_format_wide.cc delete mode 100644 starboard/shared/win32/system_break_into_debugger.cc delete mode 100644 starboard/shared/win32/system_clear_last_error.cc delete mode 100644 starboard/shared/win32/system_get_error_string.cc delete mode 100644 starboard/shared/win32/system_get_extensions.cc delete mode 100644 starboard/shared/win32/system_get_last_error.cc delete mode 100644 starboard/shared/win32/system_get_locale_id.cc delete mode 100644 starboard/shared/win32/system_get_number_of_processors.cc delete mode 100644 starboard/shared/win32/system_get_property.cc delete mode 100644 starboard/shared/win32/system_get_random_data.cc delete mode 100644 starboard/shared/win32/system_get_random_uint64.cc delete mode 100644 starboard/shared/win32/system_get_stack.cc delete mode 100644 starboard/shared/win32/system_get_total_cpu_memory.cc delete mode 100644 starboard/shared/win32/system_get_used_cpu_memory.cc delete mode 100644 starboard/shared/win32/system_is_debugger_attached.cc delete mode 100644 starboard/shared/win32/system_raise_platform_error.cc delete mode 100644 starboard/shared/win32/system_symbolize.cc delete mode 100644 starboard/shared/win32/test_filters.py delete mode 100644 starboard/shared/win32/thread_create.cc delete mode 100644 starboard/shared/win32/thread_create_local_key.cc delete mode 100644 starboard/shared/win32/thread_destroy_local_key.cc delete mode 100644 starboard/shared/win32/thread_detach.cc delete mode 100644 starboard/shared/win32/thread_get_current.cc delete mode 100644 starboard/shared/win32/thread_get_id.cc delete mode 100644 starboard/shared/win32/thread_get_local_value.cc delete mode 100644 starboard/shared/win32/thread_get_name.cc delete mode 100644 starboard/shared/win32/thread_is_equal.cc delete mode 100644 starboard/shared/win32/thread_join.cc delete mode 100644 starboard/shared/win32/thread_local_internal.cc delete mode 100644 starboard/shared/win32/thread_local_internal.h delete mode 100644 starboard/shared/win32/thread_private.cc delete mode 100644 starboard/shared/win32/thread_private.h delete mode 100644 starboard/shared/win32/thread_set_local_value.cc delete mode 100644 starboard/shared/win32/thread_set_name.cc delete mode 100644 starboard/shared/win32/thread_sleep.cc delete mode 100644 starboard/shared/win32/thread_yield.cc delete mode 100644 starboard/shared/win32/time_get_monotonic_now.cc delete mode 100644 starboard/shared/win32/time_get_now.cc delete mode 100644 starboard/shared/win32/time_utils.h delete mode 100644 starboard/shared/win32/time_zone_get_current.cc delete mode 100644 starboard/shared/win32/time_zone_get_name.cc delete mode 100644 starboard/shared/win32/types_internal.h delete mode 100644 starboard/shared/win32/video_decoder.cc delete mode 100644 starboard/shared/win32/video_decoder.h delete mode 100644 starboard/shared/win32/wasapi_include.h delete mode 100644 starboard/shared/win32/wchar_utils.h delete mode 100644 starboard/shared/win32/win32_audio_decoder.cc delete mode 100644 starboard/shared/win32/win32_audio_decoder.h delete mode 100644 starboard/shared/win32/window_create.cc delete mode 100644 starboard/shared/win32/window_destroy.cc delete mode 100644 starboard/shared/win32/window_get_platform_handle.cc delete mode 100644 starboard/shared/win32/window_get_size.cc delete mode 100644 starboard/shared/win32/window_internal.cc delete mode 100644 starboard/shared/win32/window_internal.h delete mode 100644 starboard/shared/win32/window_set_default_options.cc delete mode 100644 starboard/shared/win32/wrm_header.cc delete mode 100644 starboard/shared/win32/wrm_header.h delete mode 100644 starboard/tools/win_symlink.py delete mode 100644 starboard/tools/win_symlink_fast.py delete mode 100644 starboard/tools/win_symlink_fast_test.py delete mode 100644 starboard/tools/win_symlink_test.py delete mode 100644 starboard/win/__init__.py delete mode 100644 starboard/win/i18n/en-US.xlb delete mode 100644 starboard/win/shared/BUILD.gn delete mode 100644 starboard/win/shared/configuration_constants.cc delete mode 100644 starboard/win/shared/configuration_public.h delete mode 100644 starboard/win/shared/platform_configuration/BUILD.gn delete mode 100644 starboard/win/shared/platform_configuration/configuration.gni delete mode 100644 starboard/win/shared/system_get_path.cc delete mode 100644 starboard/win/win32/BUILD.gn delete mode 100644 starboard/win/win32/__init__.py delete mode 100644 starboard/win/win32/args.gn delete mode 100644 starboard/win/win32/atomic_public.h delete mode 100644 starboard/win/win32/cobalt/configuration.py delete mode 100644 starboard/win/win32/configuration_public.h delete mode 100644 starboard/win/win32/gyp_configuration.py delete mode 100644 starboard/win/win32/i18n/BUILD.gn delete mode 100644 starboard/win/win32/i18n/en.xlb delete mode 100644 starboard/win/win32/launcher.py delete mode 100644 starboard/win/win32/main.cc delete mode 100644 starboard/win/win32/platform_configuration/BUILD.gn delete mode 100644 starboard/win/win32/platform_configuration/configuration.gni delete mode 100644 starboard/win/win32/test_filters.py delete mode 100644 starboard/win/win32/toolchain/BUILD.gn delete mode 100644 starboard/xb1/BUILD.gn delete mode 100644 starboard/xb1/__init__.py delete mode 100644 starboard/xb1/appx_product_settings.py delete mode 100644 starboard/xb1/args.gn delete mode 100644 starboard/xb1/assets/Square150x150Logo.scale-100.png delete mode 100644 starboard/xb1/assets/Square310x310Logo.scale-100.png delete mode 100644 starboard/xb1/assets/Square44x44Logo.scale-100.png delete mode 100644 starboard/xb1/assets/Square71x71Logo.scale-100.png delete mode 100644 starboard/xb1/assets/Wide310x150Logo.scale-100.png delete mode 100644 starboard/xb1/atomic_public.h delete mode 100644 starboard/xb1/cert/README.md delete mode 100644 starboard/xb1/cert/cobalt.pfx delete mode 100644 starboard/xb1/cobalt/__init__.py delete mode 100644 starboard/xb1/cobalt/configuration.py delete mode 100644 starboard/xb1/cobalt/package.py delete mode 100644 starboard/xb1/configuration_public.h delete mode 100644 starboard/xb1/gyp_configuration.py delete mode 100644 starboard/xb1/i18n/BUILD.gn delete mode 100644 starboard/xb1/i18n/da.xlb delete mode 100644 starboard/xb1/i18n/de-AT.xlb delete mode 100644 starboard/xb1/i18n/de-CH.xlb delete mode 100644 starboard/xb1/i18n/de.xlb delete mode 100644 starboard/xb1/i18n/en-AU.xlb delete mode 100644 starboard/xb1/i18n/en-CA.xlb delete mode 100644 starboard/xb1/i18n/en-GB.xlb delete mode 100644 starboard/xb1/i18n/en-IE.xlb delete mode 100644 starboard/xb1/i18n/en.xlb delete mode 100644 starboard/xb1/i18n/es-419.xlb delete mode 100644 starboard/xb1/i18n/es-AR.xlb delete mode 100644 starboard/xb1/i18n/es-CL.xlb delete mode 100644 starboard/xb1/i18n/es-CO.xlb delete mode 100644 starboard/xb1/i18n/es-MX.xlb delete mode 100644 starboard/xb1/i18n/es-US.xlb delete mode 100644 starboard/xb1/i18n/es.xlb delete mode 100644 starboard/xb1/i18n/fi.xlb delete mode 100644 starboard/xb1/i18n/fr-CA.xlb delete mode 100644 starboard/xb1/i18n/fr-CH.xlb delete mode 100644 starboard/xb1/i18n/fr.xlb delete mode 100644 starboard/xb1/i18n/it.xlb delete mode 100644 starboard/xb1/i18n/ja.xlb delete mode 100644 starboard/xb1/i18n/ko.xlb delete mode 100644 starboard/xb1/i18n/nb.xlb delete mode 100644 starboard/xb1/i18n/nl.xlb delete mode 100644 starboard/xb1/i18n/pl.xlb delete mode 100644 starboard/xb1/i18n/pt-BR.xlb delete mode 100644 starboard/xb1/i18n/pt-PT.xlb delete mode 100644 starboard/xb1/i18n/pt.xlb delete mode 100644 starboard/xb1/i18n/ru.xlb delete mode 100644 starboard/xb1/i18n/sv.xlb delete mode 100644 starboard/xb1/i18n/tr.xlb delete mode 100644 starboard/xb1/i18n/zh-CN.xlb delete mode 100644 starboard/xb1/i18n/zh-HK.xlb delete mode 100644 starboard/xb1/i18n/zh-TW.xlb delete mode 100644 starboard/xb1/i18n/zh.xlb delete mode 100644 starboard/xb1/install_target.gni delete mode 100644 starboard/xb1/install_target/BUILD.gn delete mode 100644 starboard/xb1/launcher.py delete mode 100644 starboard/xb1/platform_configuration/BUILD.gn delete mode 100644 starboard/xb1/platform_configuration/configuration.gni delete mode 100644 starboard/xb1/public_system_properties.cc delete mode 100644 starboard/xb1/shared/BUILD.gn delete mode 100644 starboard/xb1/shared/configuration.cc delete mode 100644 starboard/xb1/shared/configuration.h delete mode 100644 starboard/xb1/shared/configuration_constants.cc delete mode 100644 starboard/xb1/shared/configuration_public.h delete mode 100644 starboard/xb1/shared/gpu_base_video_decoder.cc delete mode 100644 starboard/xb1/shared/gpu_base_video_decoder.h delete mode 100644 starboard/xb1/shared/internal_shims.h delete mode 100644 starboard/xb1/shared/internal_stubs.cc delete mode 100644 starboard/xb1/shared/playready_license.cc delete mode 100644 starboard/xb1/shared/system_get_extensions.cc delete mode 100644 starboard/xb1/shared/system_get_path.cc delete mode 100644 starboard/xb1/shared/video_decoder_uwp.cc delete mode 100644 starboard/xb1/shared/video_decoder_uwp.h delete mode 100644 starboard/xb1/shared/video_frame_impl.h delete mode 100644 starboard/xb1/system_properties.h delete mode 100644 starboard/xb1/templates/ApplicationSection.xml.template delete mode 100644 starboard/xb1/templates/AppxManifest.xml.template delete mode 100644 starboard/xb1/test_filters.py delete mode 100644 starboard/xb1/toolchain/BUILD.gn delete mode 100644 starboard/xb1/tools/__init__.py delete mode 100644 starboard/xb1/tools/application_section_generator.py delete mode 100644 starboard/xb1/tools/appx.py delete mode 100644 starboard/xb1/tools/list_apps_in_uwp_package.ps1 delete mode 100644 starboard/xb1/tools/list_running_processes.ps1 delete mode 100644 starboard/xb1/tools/list_uwp_packages.ps1 delete mode 100644 starboard/xb1/tools/packager.py delete mode 100644 starboard/xb1/tools/register_uwp_package.ps1 delete mode 100644 starboard/xb1/tools/remove_uwp_package.ps1 delete mode 100644 starboard/xb1/tools/stop_process_by_id.ps1 delete mode 100644 starboard/xb1/tools/uwp_api.py delete mode 100644 starboard/xb1/tools/uwp_launcher.py delete mode 100644 starboard/xb1/tools/xb1_launcher.py delete mode 100644 starboard/xb1/tools/xb1_network_api.py delete mode 100644 third_party/musl/src/starboard/dirent.c delete mode 100644 third_party/musl/src/starboard/errno/__errno_location.c delete mode 100644 third_party/musl/src/starboard/malloc/malloc.c delete mode 100644 third_party/musl/src/starboard/malloc/posix_memalign.c delete mode 100644 third_party/musl/src/starboard/mman/mman.c delete mode 100644 third_party/musl/src/starboard/network/socket.c delete mode 100644 third_party/musl/src/starboard/pthread/pthread.c delete mode 100644 third_party/musl/src/starboard/sched/sched.c delete mode 100644 third_party/musl/src/starboard/stdio/vsnprintf.c delete mode 100644 third_party/musl/src/starboard/stdio/vsscanf.c delete mode 100644 third_party/musl/src/starboard/stdio/vswprintf.c delete mode 100644 third_party/musl/src/starboard/sys/stat.c delete mode 100644 third_party/musl/src/starboard/sys/time/gettimeofday.c delete mode 100644 third_party/musl/src/starboard/time/clock_gettime.c delete mode 100644 third_party/musl/src/starboard/time/gmtime_r.c delete mode 100644 third_party/musl/src/starboard/time/time.c delete mode 100644 third_party/musl/src/starboard/unistd/unistd.c diff --git a/.github/config/evergreen-arm-hardfp.json b/.github/config/evergreen-arm-hardfp.json index 113fd11ab46f..1be38f06260d 100644 --- a/.github/config/evergreen-arm-hardfp.json +++ b/.github/config/evergreen-arm-hardfp.json @@ -13,8 +13,6 @@ }, "platforms": [ "evergreen-arm-hardfp", - "evergreen-arm-hardfp-sbversion-15", - "evergreen-arm-hardfp-sbversion-16", "evergreen-arm-hardfp-sbversion-17" ], "includes": [ @@ -27,24 +25,6 @@ "evergreen_loader_extra_gn_arguments": "use_asan=false is_clang=false", "dimension": "release_version=regex:10.*" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm-hardfp-sbversion-15", - "target_platform":"evergreen-arm-hardfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "evergreen_loader_extra_gn_arguments":"use_asan=false is_clang=false", - "sb_api_version": "15" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm-hardfp-sbversion-16", - "target_platform":"evergreen-arm-hardfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "evergreen_loader_extra_gn_arguments":"use_asan=false is_clang=false", - "sb_api_version": "16" - }, { "name":"sbversion-17", "platform":"evergreen-arm-hardfp-sbversion-17", diff --git a/.github/config/evergreen-arm-softfp.json b/.github/config/evergreen-arm-softfp.json index 0594f2d36bf9..104809b19832 100644 --- a/.github/config/evergreen-arm-softfp.json +++ b/.github/config/evergreen-arm-softfp.json @@ -13,8 +13,6 @@ }, "platforms": [ "evergreen-arm-softfp", - "evergreen-arm-softfp-sbversion-15", - "evergreen-arm-softfp-sbversion-16", "evergreen-arm-softfp-sbversion-17" ], "includes": [ @@ -26,24 +24,6 @@ "extra_gn_arguments":"use_asan=false", "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm-softfp-sbversion-15", - "target_platform":"evergreen-arm-softfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm-softfp-sbversion-16", - "target_platform":"evergreen-arm-softfp", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, { "name":"sbversion-17", "platform":"evergreen-arm-softfp-sbversion-17", diff --git a/.github/config/evergreen-arm64.json b/.github/config/evergreen-arm64.json index 981f77a45a68..e11fb6f41055 100644 --- a/.github/config/evergreen-arm64.json +++ b/.github/config/evergreen-arm64.json @@ -3,8 +3,6 @@ "evergreen_loader": "android-arm64", "platforms": [ "evergreen-arm64", - "evergreen-arm64-sbversion-15", - "evergreen-arm64-sbversion-16", "evergreen-arm64-sbversion-17" ], "includes": [ @@ -16,24 +14,6 @@ "extra_gn_arguments":"use_asan=false", "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" }, - { - "name":"sbversion-15", - "platform":"evergreen-arm64-sbversion-15", - "target_platform":"evergreen-arm64", - "target_cpu":"target_cpu=\\\"arm64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, - { - "name":"sbversion-16", - "platform":"evergreen-arm64-sbversion-16", - "target_platform":"evergreen-arm64", - "target_cpu":"target_cpu=\\\"arm64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16", - "evergreen_loader_extra_gn_arguments": "target_os=\\\"android\\\" sb_is_evergreen_compatible=true" - }, { "name":"sbversion-17", "platform":"evergreen-arm64-sbversion-17", diff --git a/.github/config/evergreen-x64.json b/.github/config/evergreen-x64.json index 21bc0e713971..e8b3bb2bc392 100644 --- a/.github/config/evergreen-x64.json +++ b/.github/config/evergreen-x64.json @@ -5,8 +5,6 @@ "on_host_test_shards": ["0", "1", "2", "3", "blackbox", "wpt", "evergreen"], "platforms": [ "evergreen-x64", - "evergreen-x64-sbversion-15", - "evergreen-x64-sbversion-16", "evergreen-x64-sbversion-17" ], "includes": [ @@ -17,22 +15,6 @@ "target_cpu":"target_cpu=\\\"x64\\\"", "extra_gn_arguments":"use_asan=false" }, - { - "name":"sbversion-15", - "platform":"evergreen-x64-sbversion-15", - "target_platform":"evergreen-x64", - "target_cpu":"target_cpu=\\\"x64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"15" - }, - { - "name":"sbversion-16", - "platform":"evergreen-x64-sbversion-16", - "target_platform":"evergreen-x64", - "target_cpu":"target_cpu=\\\"x64\\\"", - "extra_gn_arguments":"use_asan=false", - "sb_api_version":"16" - }, { "name":"sbversion-17", "platform":"evergreen-x64-sbversion-17", diff --git a/.github/config/linux.json b/.github/config/linux.json index 4f591b034796..3c2b325eaa46 100644 --- a/.github/config/linux.json +++ b/.github/config/linux.json @@ -7,8 +7,6 @@ "linux-x64x11", "linux-x64x11-egl", "linux-x64x11-skia", - "linux-x64x11-sbversion-15", - "linux-x64x11-sbversion-16", "linux-x64x11-sbversion-17" ], "includes": [ @@ -27,18 +25,6 @@ "platform":"linux-x64x11-skia", "target_platform":"linux-x64x11-skia" }, - { - "name":"sbversion-15", - "platform":"linux-x64x11-sbversion-15", - "target_platform":"linux-x64x11", - "sb_api_version":"15" - }, - { - "name":"sbversion-16", - "platform":"linux-x64x11-sbversion-16", - "target_platform":"linux-x64x11", - "sb_api_version":"16" - }, { "name":"sbversion-17", "platform":"linux-x64x11-sbversion-17", diff --git a/.github/config/raspi-2.json b/.github/config/raspi-2.json index 1df9213251b9..f5b897329872 100644 --- a/.github/config/raspi-2.json +++ b/.github/config/raspi-2.json @@ -13,8 +13,6 @@ }, "platforms": [ "raspi-2", - "raspi-2-sbversion-15", - "raspi-2-sbversion-16", "raspi-2-sbversion-17" ], "includes": [ @@ -25,22 +23,6 @@ "target_cpu":"target_cpu=\\\"arm\\\"", "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false" }, - { - "name":"sbversion-15", - "platform":"raspi-2-sbversion-15", - "target_platform":"raspi-2", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false", - "sb_api_version": "15" - }, - { - "name":"sbversion-16", - "platform":"raspi-2-sbversion-16", - "target_platform":"raspi-2", - "target_cpu":"target_cpu=\\\"arm\\\"", - "extra_gn_arguments": "build_with_separate_cobalt_toolchain=true use_asan=false", - "sb_api_version": "16" - }, { "name":"sbversion-17", "platform":"raspi-2-sbversion-17", diff --git a/base/synchronization/condition_variable.h b/base/synchronization/condition_variable.h index 4c84bc200b25..6491e357e216 100644 --- a/base/synchronization/condition_variable.h +++ b/base/synchronization/condition_variable.h @@ -70,11 +70,7 @@ #include "base/synchronization/lock.h" #if defined(STARBOARD) -#if SB_API_VERSION < 16 -#include "starboard/condition_variable.h" -#else #include -#endif // SB_API_VERSION < 16 #else #if BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) #include @@ -122,13 +118,8 @@ class BASE_EXPORT ConditionVariable { private: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - SbConditionVariable condition_; - SbMutex* user_mutex_; -#else pthread_cond_t condition_; pthread_mutex_t* user_mutex_; -#endif // SB_API_VERSION < 16 #elif BUILDFLAG(IS_WIN) CHROME_CONDITION_VARIABLE cv_; const raw_ptr srwlock_; diff --git a/base/synchronization/condition_variable_starboard.cc b/base/synchronization/condition_variable_starboard.cc index c46217e0490d..9c4bffae13df 100644 --- a/base/synchronization/condition_variable_starboard.cc +++ b/base/synchronization/condition_variable_starboard.cc @@ -30,10 +30,6 @@ ConditionVariable::ConditionVariable(Lock* user_lock) user_lock_(user_lock) #endif { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableCreate(&condition_, user_mutex_); - DCHECK(result); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -47,17 +43,11 @@ ConditionVariable::ConditionVariable(Lock* user_lock) int result = pthread_cond_init(&condition_, nullptr); DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableDestroy(&condition_); - DCHECK(result); -#else int result = pthread_cond_destroy(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait() { @@ -69,14 +59,8 @@ void ConditionVariable::Wait() { #if DCHECK_IS_ON() user_lock_->CheckHeldAndUnmark(); #endif -#if SB_API_VERSION < 16 - SbConditionVariableResult result = - SbConditionVariableWait(&condition_, user_mutex_); - DCHECK(SbConditionVariableIsSignaled(result)); -#else int result = pthread_cond_wait(&condition_, user_mutex_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 #if DCHECK_IS_ON() user_lock_->CheckUnheldAndMark(); #endif @@ -92,11 +76,6 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { #if DCHECK_IS_ON() user_lock_->CheckHeldAndUnmark(); #endif -#if SB_API_VERSION < 16 - SbConditionVariableResult result = - SbConditionVariableWaitTimed(&condition_, user_mutex_, duration); - DCHECK_NE(kSbConditionVariableFailed, result); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) int64_t timeout_time_usec = starboard::CurrentMonotonicTime(); #else @@ -110,30 +89,19 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { int result = pthread_cond_timedwait(&condition_, user_mutex_, &timeout); DCHECK(result == 0 || result == ETIMEDOUT); -#endif #if DCHECK_IS_ON() user_lock_->CheckUnheldAndMark(); #endif } void ConditionVariable::Broadcast() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableBroadcast(&condition_); - DCHECK(result); -#else int result = pthread_cond_broadcast(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Signal() { -#if SB_API_VERSION < 16 - bool result = SbConditionVariableSignal(&condition_); - DCHECK(result); -#else int result = pthread_cond_signal(&condition_); DCHECK(result == 0); -#endif // SB_API_VERSION < 16 } } // namespace base diff --git a/base/synchronization/lock_impl.h b/base/synchronization/lock_impl.h index 76b692a80d4c..39d7d471b9d1 100644 --- a/base/synchronization/lock_impl.h +++ b/base/synchronization/lock_impl.h @@ -12,11 +12,7 @@ #include "build/build_config.h" #if defined(STARBOARD) -#if SB_API_VERSION < 16 -#include "starboard/common/mutex.h" -#else #include -#endif #include "base/check_op.h" #elif BUILDFLAG(IS_WIN) #include "base/win/windows_types.h" @@ -53,11 +49,7 @@ class BASE_EXPORT LockImpl { friend class base::win::internal::ScopedHandleVerifier; #if defined(STARBOARD) -#if SB_API_VERSION < 16 - using NativeHandle = SbMutex; -#else using NativeHandle = pthread_mutex_t; -#endif // SB_API_VERSION < 16 #elif BUILDFLAG(IS_WIN) using NativeHandle = CHROME_SRWLOCK; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) @@ -108,24 +100,13 @@ void LockImpl::Lock() { #if defined(STARBOARD) bool LockImpl::Try() { -#if SB_API_VERSION < 16 - SbMutexResult result = SbMutexAcquireTry(&native_handle_); - DCHECK_NE(kSbMutexDestroyed, result); - return SbMutexIsSuccess(result); -#else int result = pthread_mutex_trylock(&native_handle_); return result == 0; -#endif // SB_API_VERSION < 16 } void LockImpl::Unlock() { -#if SB_API_VERSION < 16 - bool result = SbMutexRelease(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_unlock(&native_handle_); DCHECK(result == 0); -#endif //SB_API_VERSION < 16 } #elif BUILDFLAG(IS_WIN) bool LockImpl::Try() { diff --git a/base/synchronization/lock_impl_starboard.cc b/base/synchronization/lock_impl_starboard.cc index 545ba4c9646b..7b25b0042c01 100644 --- a/base/synchronization/lock_impl_starboard.cc +++ b/base/synchronization/lock_impl_starboard.cc @@ -16,41 +16,22 @@ #include "base/check_op.h" -#if SB_API_VERSION < 16 -#include "starboard/mutex.h" -#endif // SB_API_VERSION < 16 - namespace base { namespace internal { LockImpl::LockImpl() { -#if SB_API_VERSION < 16 - bool result = SbMutexCreate(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_init(&native_handle_, nullptr); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } LockImpl::~LockImpl() { -#if SB_API_VERSION < 16 - bool result = SbMutexDestroy(&native_handle_); - DCHECK(result); -#else int result = pthread_mutex_destroy(&native_handle_); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } void LockImpl::LockInternal() { -#if SB_API_VERSION < 16 - SbMutexResult result = SbMutexAcquire(&native_handle_); - DCHECK_NE(kSbMutexDestroyed, result); -#else int result = pthread_mutex_lock(&native_handle_); DCHECK_EQ(result, 0); -#endif // SB_API_VERSION < 16 } } // namespace internal diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h index 0623f595f790..edcf0af6c5b5 100644 --- a/base/threading/platform_thread.h +++ b/base/threading/platform_thread.h @@ -55,11 +55,7 @@ static_assert(std::is_integral_v, "Always an integer value."); class PlatformThreadHandle { public: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - typedef SbThread Handle; -#else typedef pthread_t Handle; -#endif #elif BUILDFLAG(IS_WIN) typedef void* Handle; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) diff --git a/base/threading/platform_thread_ref.h b/base/threading/platform_thread_ref.h index 04142c433765..b87cf099aa0c 100644 --- a/base/threading/platform_thread_ref.h +++ b/base/threading/platform_thread_ref.h @@ -37,11 +37,7 @@ namespace base { class PlatformThreadRef { public: #if defined(STARBOARD) -#if SB_API_VERSION < 16 - typedef SbThread RefType; -#else using RefType = pthread_t; -#endif #elif BUILDFLAG(IS_WIN) using RefType = DWORD; #elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA) diff --git a/base/threading/platform_thread_starboard.cc b/base/threading/platform_thread_starboard.cc index 594ede6c08f1..3a7513fdf8a0 100644 --- a/base/threading/platform_thread_starboard.cc +++ b/base/threading/platform_thread_starboard.cc @@ -159,21 +159,13 @@ PlatformThreadId PlatformThread::CurrentId() { // static PlatformThreadRef PlatformThread::CurrentRef() { -#if SB_API_VERSION < 16 - return PlatformThreadRef(SbThreadGetCurrent()); -#else return PlatformThreadRef(pthread_self()); -#endif // SB_API_VERSION < 16 } // static PlatformThreadHandle PlatformThread::CurrentHandle() { -#if SB_API_VERSION < 16 - return PlatformThreadHandle(SbThreadGetCurrent()); -#else return PlatformThreadHandle(pthread_self()); -#endif // SB_API_VERSION < 16 } // static @@ -225,19 +217,11 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) { // the thread referred to by |thread_handle| may still be running long-lived / // blocking tasks. internal::AssertBlockingAllowed(); -#if SB_API_VERSION < 16 - SbThreadJoin(thread_handle.platform_handle(), NULL); -#else pthread_join(thread_handle.platform_handle(), NULL); -#endif // SB_API_VERSION < 16 } void PlatformThread::Detach(PlatformThreadHandle thread_handle) { -#if SB_API_VERSION < 16 - SbThreadDetach(thread_handle.platform_handle()); -#else pthread_detach(thread_handle.platform_handle()); -#endif // SB_API_VERSION < 16 } void internal::SetCurrentThreadTypeImpl(ThreadType /* thread_type */, MessagePumpType /*pump_type_hint*/) { diff --git a/cobalt/browser/application.cc b/cobalt/browser/application.cc index 7b852d31905d..f708ebcacc33 100644 --- a/cobalt/browser/application.cc +++ b/cobalt/browser/application.cc @@ -901,12 +901,7 @@ Application::Application(const base::Closure& quit_closure, bool should_preload, AddCrashHandlerAnnotations(platform_info); #if SB_IS(EVERGREEN) -#if SB_API_VERSION < 16 - if (SbSystemGetExtension(kCobaltExtensionInstallationManagerName) && - !command_line->HasSwitch(switches::kDisableUpdaterModule)) { -#else if (SbSystemGetExtension(kCobaltExtensionInstallationManagerName)) { -#endif uint64_t update_check_delay_sec = cobalt::updater::kDefaultUpdateCheckDelaySeconds; if (command_line->HasSwitch(browser::switches::kUpdateCheckDelaySeconds)) { diff --git a/cobalt/browser/switches.cc b/cobalt/browser/switches.cc index 7a3b5026324e..6e569a59e042 100644 --- a/cobalt/browser/switches.cc +++ b/cobalt/browser/switches.cc @@ -243,14 +243,6 @@ const char kDisableTimerResolutionLimitHelp[] = "removed and the resolution will be 1us (or larger depending on the " "platform."; -#if SB_API_VERSION < 16 -const char kDisableUpdaterModule[] = "disable_updater_module"; -const char kDisableUpdaterModuleHelp[] = - "Disables the Cobalt Evergreen UpdaterModule which is responsible for " - "downloading and installing new Cobalt updates. Passing the flag is " - "equivalent to opting out from further updates."; -#endif - const char kEnableSkiaRasterizer[] = "enable_skia_rasterizer"; const char kEnableSkiaRasterizerHelp[] = "Enables/disables the skia rendering engine. If it's disabled, direct-gles" @@ -487,9 +479,6 @@ std::string HelpMessage() { {kDisableJavaScriptJit, kDisableJavaScriptJitHelp}, {kDisableMapToMesh, kDisableMapToMeshHelp}, {kDisableTimerResolutionLimit, kDisableTimerResolutionLimitHelp}, -#if SB_API_VERSION < 16 - {kDisableUpdaterModule, kDisableUpdaterModuleHelp}, -#endif {kEnableSkiaRasterizer, kEnableSkiaRasterizerHelp}, {kEncodedImageCacheSizeInBytes, kEncodedImageCacheSizeInBytesHelp}, {kForceMigrationForStoragePartitioning, diff --git a/cobalt/browser/switches.h b/cobalt/browser/switches.h index 982389104553..faab46122d04 100644 --- a/cobalt/browser/switches.h +++ b/cobalt/browser/switches.h @@ -98,10 +98,6 @@ extern const char kDisableMapToMesh[]; extern const char kDisableMapToMeshHelp[]; extern const char kDisableTimerResolutionLimit[]; extern const char kDisableTimerResolutionLimitHelp[]; -#if SB_API_VERSION < 16 -extern const char kDisableUpdaterModule[]; -extern const char kDisableUpdaterModuleHelp[]; -#endif extern const char kEnableSkiaRasterizer[]; extern const char kEnableSkiaRasterizerHelp[]; extern const char kEncodedImageCacheSizeInBytes[]; diff --git a/cobalt/browser/user_agent_platform_info.h b/cobalt/browser/user_agent_platform_info.h index f9267345dff2..193b7691bee9 100644 --- a/cobalt/browser/user_agent_platform_info.h +++ b/cobalt/browser/user_agent_platform_info.h @@ -44,10 +44,6 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { return original_design_manufacturer_; } -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type() const override { return device_type_; } -#endif - const std::string& device_type_string() const override { return device_type_string_; } @@ -132,9 +128,7 @@ class UserAgentPlatformInfo : public web::UserAgentPlatformInfo { std::string starboard_version_; std::string os_name_and_version_; base::Optional original_design_manufacturer_; -#if SB_API_VERSION < 15 - SbSystemDeviceType device_type_ = kSbSystemDeviceTypeUnknown; -#endif + std::string device_type_string_; base::Optional chipset_model_number_; base::Optional model_year_; diff --git a/cobalt/browser/web_module.cc b/cobalt/browser/web_module.cc index 09b65e0f372c..5b32ed451141 100644 --- a/cobalt/browser/web_module.cc +++ b/cobalt/browser/web_module.cc @@ -79,11 +79,7 @@ #include "cobalt/web/environment_settings.h" #include "cobalt/web/event.h" #include "cobalt/web/url.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/gles.h" #if defined(ENABLE_DEBUGGER) diff --git a/cobalt/dom/captions/system_caption_settings.cc b/cobalt/dom/captions/system_caption_settings.cc index 222d9d5168ec..b0f978f631ff 100644 --- a/cobalt/dom/captions/system_caption_settings.cc +++ b/cobalt/dom/captions/system_caption_settings.cc @@ -27,11 +27,7 @@ #include "cobalt/dom/captions/caption_opacity_percentage.h" #include "cobalt/dom/captions/caption_state.h" #include "cobalt/web/event_target.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/memory.h" namespace cobalt { diff --git a/cobalt/dom/captions/system_caption_settings.h b/cobalt/dom/captions/system_caption_settings.h index 1446fa77fdc6..359689ff969f 100644 --- a/cobalt/dom/captions/system_caption_settings.h +++ b/cobalt/dom/captions/system_caption_settings.h @@ -28,11 +28,7 @@ #include "cobalt/dom/captions/caption_state.h" #include "cobalt/script/environment_settings.h" #include "cobalt/web/event_target.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 namespace cobalt { namespace dom { diff --git a/cobalt/h5vcc/h5vcc_accessibility.cc b/cobalt/h5vcc/h5vcc_accessibility.cc index a57f0ff98144..70b09024293d 100644 --- a/cobalt/h5vcc/h5vcc_accessibility.cc +++ b/cobalt/h5vcc/h5vcc_accessibility.cc @@ -20,11 +20,7 @@ #include "cobalt/base/accessibility_settings_changed_event.h" #include "cobalt/base/accessibility_text_to_speech_settings_changed_event.h" #include "cobalt/browser/switches.h" -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#else // SB_API_VERSION < 16 #include "starboard/extension/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/memory.h" namespace cobalt { diff --git a/cobalt/media/base/sbplayer_bridge.cc b/cobalt/media/base/sbplayer_bridge.cc index 3d0305fb7fff..e9a7cad71ccd 100644 --- a/cobalt/media/base/sbplayer_bridge.cc +++ b/cobalt/media/base/sbplayer_bridge.cc @@ -73,11 +73,7 @@ void SetStreamInfo(const SbMediaAudioStreamInfo& stream_info, SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); -#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; -#else // SB_API_VERSION >= 15 - *sample_info = stream_info; -#endif // SB_API_VERSION >= 15} } void SetStreamInfo( @@ -96,12 +92,7 @@ void SetStreamInfo( void SetStreamInfo(const SbMediaVideoStreamInfo& stream_info, SbMediaVideoSampleInfo* sample_info) { DCHECK(sample_info); - -#if SB_API_VERSION >= 15 sample_info->stream_info = stream_info; -#else // SB_API_VERSION >= 15 - *sample_info = stream_info; -#endif // SB_API_VERSION >= 15} } void SetDiscardPadding( @@ -120,12 +111,10 @@ void SetDiscardPadding( SbMediaAudioSampleInfo* sample_info) { DCHECK(sample_info); -#if SB_API_VERSION >= 15 sample_info->discarded_duration_from_front = discard_padding.first.InMicroseconds(); sample_info->discarded_duration_from_back = discard_padding.second.InMicroseconds(); -#endif // SB_API_VERSION >= 15} } } // namespace @@ -467,7 +456,6 @@ void SbPlayerBridge::GetInfo(uint32* video_frames_decoded, GetInfo_Locked(video_frames_decoded, video_frames_dropped, media_time); } -#if SB_API_VERSION >= 15 std::vector SbPlayerBridge::GetAudioConfigurations() { base::AutoLock auto_lock(lock_); @@ -496,7 +484,6 @@ SbPlayerBridge::GetAudioConfigurations() { return configurations; } -#endif // SB_API_VERSION >= 15 #if SB_HAS(PLAYER_WITH_URL) void SbPlayerBridge::GetUrlPlayerBufferedTimeRanges( @@ -538,11 +525,7 @@ void SbPlayerBridge::GetVideoResolution(int* frame_width, int* frame_height) { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo out_player_info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 out_player_info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &out_player_info); video_stream_info_.frame_width = out_player_info.frame_width; @@ -561,11 +544,7 @@ TimeDelta SbPlayerBridge::GetDuration() { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); if (info.duration == SB_PLAYER_NO_DURATION) { // URL-based player may not have loaded asset yet, so map no duration to 0. @@ -583,11 +562,7 @@ TimeDelta SbPlayerBridge::GetStartDate() { DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); return TimeDelta::FromMicroseconds(info.start_date); } @@ -760,22 +735,13 @@ void SbPlayerBridge::CreatePlayer() { SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; -#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; -#else // SB_API_VERSION >= 15 - creation_param.audio_sample_info = audio_stream_info_; - creation_param.video_sample_info = video_stream_info_; -#endif // SB_API_VERSION >= 15 // TODO: This is temporary for supporting background media playback. // Need to be removed with media refactor. if (!is_visible) { -#if SB_API_VERSION >= 15 creation_param.video_stream_info.codec = kSbMediaVideoCodecNone; -#else // SB_API_VERSION >= 15 - creation_param.video_sample_info.codec = kSbMediaVideoCodecNone; -#endif // SB_API_VERSION >= 15 } creation_param.output_mode = output_mode_; DCHECK_EQ(sbplayer_interface_->GetPreferredOutputMode(&creation_param), @@ -1010,11 +976,7 @@ void SbPlayerBridge::GetInfo_Locked(uint32* video_frames_decoded, DCHECK(SbPlayerIsValid(player_)); -#if SB_API_VERSION >= 15 SbPlayerInfo info; -#else // SB_API_VERSION >= 15 - SbPlayerInfo2 info; -#endif // SB_API_VERSION >= 15 sbplayer_interface_->GetInfo(player_, &info); if (media_time) { @@ -1259,14 +1221,8 @@ SbPlayerOutputMode SbPlayerBridge::ComputeSbPlayerOutputMode( SbPlayerOutputMode default_output_mode) const { SbPlayerCreationParam creation_param = {}; creation_param.drm_system = drm_system_; - -#if SB_API_VERSION >= 15 creation_param.audio_stream_info = audio_stream_info_; creation_param.video_stream_info = video_stream_info_; -#else // SB_API_VERSION >= 15 - creation_param.audio_sample_info = audio_stream_info_; - creation_param.video_sample_info = video_stream_info_; -#endif // SB_API_VERSION >= 15 if (default_output_mode != kSbPlayerOutputModeDecodeToTexture && video_stream_info_.codec != kSbMediaVideoCodecNone) { diff --git a/cobalt/media/base/sbplayer_interface.cc b/cobalt/media/base/sbplayer_interface.cc index 6b367d4c15ef..37de8f32b5ce 100644 --- a/cobalt/media/base/sbplayer_interface.cc +++ b/cobalt/media/base/sbplayer_interface.cc @@ -97,11 +97,7 @@ void DefaultSbPlayerInterface::Seek(SbPlayer player, base::TimeDelta seek_to_timestamp, int ticket) { media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SEEK); -#if SB_API_VERSION >= 15 SbPlayerSeek(player, seek_to_timestamp.InMicroseconds(), ticket); -#else // SB_API_VERSION >= 15 - SbPlayerSeek2(player, seek_to_timestamp.InMicroseconds(), ticket); -#endif // SB_API_VERSION >= 15 media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SEEK); } @@ -113,13 +109,8 @@ void DefaultSbPlayerInterface::WriteSamples( SbPlayer player, SbMediaType sample_type, const SbPlayerSampleInfo* sample_infos, int number_of_sample_infos) { DCHECK(!IsEnhancedAudioExtensionEnabled()); -#if SB_API_VERSION >= 15 SbPlayerWriteSamples(player, sample_type, sample_infos, number_of_sample_infos); -#else // SB_API_VERSION >= 15 - SbPlayerWriteSample2(player, sample_type, sample_infos, - number_of_sample_infos); -#endif // SB_API_VERSION >= 15 } void DefaultSbPlayerInterface::WriteSamples( @@ -170,15 +161,9 @@ void DefaultSbPlayerInterface::SetVolume(SbPlayer player, double volume) { } void DefaultSbPlayerInterface::GetInfo(SbPlayer player, -#if SB_API_VERSION >= 15 SbPlayerInfo* out_player_info) { media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO); SbPlayerGetInfo(player, out_player_info); -#else // SB_API_VERSION >= 15 - SbPlayerInfo2* out_player_info2) { - media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO); - SbPlayerGetInfo2(player, out_player_info2); -#endif // SB_API_VERSION >= 15 media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_GET_INFO); } @@ -223,8 +208,6 @@ void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo( } #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 - bool DefaultSbPlayerInterface::GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) { @@ -237,7 +220,5 @@ bool DefaultSbPlayerInterface::GetAudioConfiguration( return audio_configuration; } -#endif // SB_API_VERSION >= 15 - } // namespace media } // namespace cobalt diff --git a/cobalt/media/base/sbplayer_interface.h b/cobalt/media/base/sbplayer_interface.h index 4aba0395eaa0..8a9f18ef8417 100644 --- a/cobalt/media/base/sbplayer_interface.h +++ b/cobalt/media/base/sbplayer_interface.h @@ -62,11 +62,8 @@ class SbPlayerInterface { virtual bool SetPlaybackRate(SbPlayer player, double playback_rate) = 0; virtual void SetVolume(SbPlayer player, double volume) = 0; -#if SB_API_VERSION >= 15 virtual void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) = 0; -#else // SB_API_VERSION >= 15 - virtual void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) = 0; -#endif // SB_API_VERSION >= 15 + virtual SbDecodeTarget GetCurrentFrame(SbPlayer player) = 0; #if SB_HAS(PLAYER_WITH_URL) @@ -84,11 +81,9 @@ class SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) = 0; #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 virtual bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) = 0; -#endif // SB_API_VERSION >= 15 // disabled by default, but can be enabled via h5vcc setting. void EnableCValStats(bool should_enable) { @@ -131,11 +126,7 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface { int height) override; bool SetPlaybackRate(SbPlayer player, double playback_rate) override; void SetVolume(SbPlayer player, double volume) override; -#if SB_API_VERSION >= 15 void GetInfo(SbPlayer player, SbPlayerInfo* out_player_info) override; -#else // SB_API_VERSION >= 15 - void GetInfo(SbPlayer player, SbPlayerInfo2* out_player_info2) override; -#endif // SB_API_VERSION >= 15 SbDecodeTarget GetCurrentFrame(SbPlayer player) override; #if SB_HAS(PLAYER_WITH_URL) @@ -151,11 +142,9 @@ class DefaultSbPlayerInterface final : public SbPlayerInterface { SbPlayer player, SbUrlPlayerExtraInfo* out_url_player_info) override; #endif // SB_HAS(PLAYER_WITH_URL) -#if SB_API_VERSION >= 15 bool GetAudioConfiguration( SbPlayer player, int index, SbMediaAudioConfiguration* out_audio_configuration) override; -#endif // SB_API_VERSION >= 15 private: void (*enhanced_audio_player_write_samples_)( diff --git a/cobalt/media/decoder_buffer_allocator.cc b/cobalt/media/decoder_buffer_allocator.cc index 6c91b45a3592..eb3607ef7551 100644 --- a/cobalt/media/decoder_buffer_allocator.cc +++ b/cobalt/media/decoder_buffer_allocator.cc @@ -127,13 +127,7 @@ int DecoderBufferAllocator::GetAudioBufferBudget() const { return SbMediaGetAudioBufferBudget(); } -int DecoderBufferAllocator::GetBufferAlignment() const { -#if SB_API_VERSION < 16 - return SbMediaGetBufferAlignment(); -#else - return sizeof(void*); -#endif // SB_API_VERSION < 16 -} +int DecoderBufferAllocator::GetBufferAlignment() const { return sizeof(void*); } int DecoderBufferAllocator::GetBufferPadding() const { return SbMediaGetBufferPadding(); diff --git a/cobalt/ui_navigation/interface.cc b/cobalt/ui_navigation/interface.cc index 372ef681f207..e4ae99fcff26 100644 --- a/cobalt/ui_navigation/interface.cc +++ b/cobalt/ui_navigation/interface.cc @@ -143,31 +143,6 @@ void DoBatchUpdate(void (*update_function)(void*), void* context) { NativeInterface InitializeInterface() { NativeInterface interface = {0}; -#if SB_API_VERSION < 16 - SbUiNavInterface sb_ui_interface = {0}; - if (SbUiNavGetInterface(&sb_ui_interface)) { - interface.create_item = sb_ui_interface.create_item; - interface.destroy_item = sb_ui_interface.destroy_item; - interface.set_item_bounds = nullptr; - interface.get_item_bounds = nullptr; - interface.set_focus = sb_ui_interface.set_focus; - interface.set_item_enabled = sb_ui_interface.set_item_enabled; - interface.set_item_dir = sb_ui_interface.set_item_dir; - interface.set_item_size = sb_ui_interface.set_item_size; - interface.set_item_transform = sb_ui_interface.set_item_transform; - interface.get_item_focus_transform = - sb_ui_interface.get_item_focus_transform; - interface.get_item_focus_vector = sb_ui_interface.get_item_focus_vector; - interface.set_item_container_window = - sb_ui_interface.set_item_container_window; - interface.set_item_container_item = sb_ui_interface.set_item_container_item; - interface.set_item_content_offset = sb_ui_interface.set_item_content_offset; - interface.get_item_content_offset = sb_ui_interface.get_item_content_offset; - interface.set_item_focus_duration = sb_ui_interface.set_item_focus_duration; - interface.do_batch_update = sb_ui_interface.do_batch_update; - return interface; - } -#else // SB_API_VERSION < 16 const SbUiNavInterface* sb_ui_interface = static_cast( SbSystemGetExtension(kCobaltExtensionUiNavigationName)); @@ -199,7 +174,6 @@ NativeInterface InitializeInterface() { interface.do_batch_update = sb_ui_interface->do_batch_update; return interface; } -#endif // SB_API_VERSION < 16 interface.create_item = &CreateItem; interface.destroy_item = &DestroyItem; interface.set_item_bounds = &SetItemBounds; diff --git a/cobalt/ui_navigation/interface.h b/cobalt/ui_navigation/interface.h index c38d39017174..1ad29cc9c48c 100644 --- a/cobalt/ui_navigation/interface.h +++ b/cobalt/ui_navigation/interface.h @@ -16,11 +16,7 @@ #define COBALT_UI_NAVIGATION_INTERFACE_H_ #include "starboard/configuration.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#else #include "starboard/extension/ui_navigation.h" -#endif // SB_API_VERSION namespace cobalt { namespace ui_navigation { diff --git a/starboard/BUILD.gn b/starboard/BUILD.gn index 5502dd25ed75..b37a076eeda1 100644 --- a/starboard/BUILD.gn +++ b/starboard/BUILD.gn @@ -177,8 +177,6 @@ source_set("starboard_headers_only") { sources = [ "atomic.h", "audio_sink.h", - "byte_swap.h", - "condition_variable.h", "configuration.h", "configuration_constants.h", "cpu_features.h", @@ -196,20 +194,15 @@ source_set("starboard_headers_only") { "media.h", "memory.h", "microphone.h", - "mutex.h", - "once.h", "player.h", "queue.h", "socket.h", "socket_waiter.h", "storage.h", - "string.h", "system.h", "thread.h", - "time.h", "time_zone.h", "types.h", - "user.h", "window.h", ] diff --git a/starboard/accessibility.h b/starboard/accessibility.h index ba7191b5a8bd..3f765b42653d 100644 --- a/starboard/accessibility.h +++ b/starboard/accessibility.h @@ -19,220 +19,6 @@ #ifndef STARBOARD_ACCESSIBILITY_H_ #define STARBOARD_ACCESSIBILITY_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// A group of settings related to text-to-speech functionality, for platforms -// that expose system settings for text-to-speech. -typedef struct SbAccessibilityTextToSpeechSettings { - // Whether this platform has a system setting for text-to-speech or not. - bool has_text_to_speech_setting; - - // Whether the text-to-speech setting is enabled or not. This setting is only - // valid if |has_text_to_speech_setting| is set to true. - bool is_text_to_speech_enabled; -} SbAccessibilityTextToSpeechSettings; - -// Get the platform settings related to the text-to-speech accessibility -// feature. This function returns false if |out_settings| is NULL or if it is -// not zero-initialized. -// -// |out_settings|: A pointer to a zero-initialized -// SbAccessibilityTextToSpeechSettings struct. -SB_EXPORT bool SbAccessibilityGetTextToSpeechSettings( - SbAccessibilityTextToSpeechSettings* out_settings); - -typedef struct SbAccessibilityDisplaySettings { - // Whether this platform has a system setting for high contrast text or not. - bool has_high_contrast_text_setting; - - // Whether the high contrast text setting is enabled or not. - bool is_high_contrast_text_enabled; -} SbAccessibilityDisplaySettings; - -// Get the platform settings related to high contrast text. -// This function returns false if |out_settings| is NULL or if it is -// not zero-initialized. -// -// |out_settings|: A pointer to a zero-initialized -// SbAccessibilityDisplaySettings* struct. -SB_EXPORT bool SbAccessibilityGetDisplaySettings( - SbAccessibilityDisplaySettings* out_settings); - -// Enum for possible closed captioning character edge styles. -typedef enum SbAccessibilityCaptionCharacterEdgeStyle { - kSbAccessibilityCaptionCharacterEdgeStyleNone, - kSbAccessibilityCaptionCharacterEdgeStyleRaised, - kSbAccessibilityCaptionCharacterEdgeStyleDepressed, - kSbAccessibilityCaptionCharacterEdgeStyleUniform, - kSbAccessibilityCaptionCharacterEdgeStyleDropShadow, -} SbAccessibilityCaptionCharacterEdgeStyle; - -// Enum for possible closed captioning colors. -typedef enum SbAccessibilityCaptionColor { - kSbAccessibilityCaptionColorBlue, - kSbAccessibilityCaptionColorBlack, - kSbAccessibilityCaptionColorCyan, - kSbAccessibilityCaptionColorGreen, - kSbAccessibilityCaptionColorMagenta, - kSbAccessibilityCaptionColorRed, - kSbAccessibilityCaptionColorWhite, - kSbAccessibilityCaptionColorYellow, -} SbAccessibilityCaptionColor; - -// Enum for possible closed captioning font families -typedef enum SbAccessibilityCaptionFontFamily { - kSbAccessibilityCaptionFontFamilyCasual, - kSbAccessibilityCaptionFontFamilyCursive, - kSbAccessibilityCaptionFontFamilyMonospaceSansSerif, - kSbAccessibilityCaptionFontFamilyMonospaceSerif, - kSbAccessibilityCaptionFontFamilyProportionalSansSerif, - kSbAccessibilityCaptionFontFamilyProportionalSerif, - kSbAccessibilityCaptionFontFamilySmallCapitals, -} SbAccessibilityCaptionFontFamily; - -// Enum for possible closed captioning font size percentages. -typedef enum SbAccessibilityCaptionFontSizePercentage { - kSbAccessibilityCaptionFontSizePercentage25, - kSbAccessibilityCaptionFontSizePercentage50, - kSbAccessibilityCaptionFontSizePercentage75, - kSbAccessibilityCaptionFontSizePercentage100, - kSbAccessibilityCaptionFontSizePercentage125, - kSbAccessibilityCaptionFontSizePercentage150, - kSbAccessibilityCaptionFontSizePercentage175, - kSbAccessibilityCaptionFontSizePercentage200, - kSbAccessibilityCaptionFontSizePercentage225, - kSbAccessibilityCaptionFontSizePercentage250, - kSbAccessibilityCaptionFontSizePercentage275, - kSbAccessibilityCaptionFontSizePercentage300, -} SbAccessibilityCaptionFontSizePercentage; - -// Enum for possible closed captioning opacity percentages. -typedef enum SbAccessibilityCaptionOpacityPercentage { - kSbAccessibilityCaptionOpacityPercentage0, - kSbAccessibilityCaptionOpacityPercentage25, - kSbAccessibilityCaptionOpacityPercentage50, - kSbAccessibilityCaptionOpacityPercentage75, - kSbAccessibilityCaptionOpacityPercentage100, -} SbAccessibilityCaptionOpacityPercentage; - -// Enum for possible states of closed captioning properties. -typedef enum SbAccessibilityCaptionState { - // The property is not supported by the system. The application should provide - // a way to set this property, otherwise it will not be changeable. - // For any given closed captioning property, if its corresponding state - // property has a value of |kSbAccessibilityCaptionStateUnsupported|, then its - // own value is undefined. For example, if - // |SbAccessibilityCaptionColor::background_color_state| has a value of - // |kSbAccessibilityCaptionStateUnsupported|, then the value of - // |SbAccessibilityCaptionColor::background_color| is undefined. - kSbAccessibilityCaptionStateUnsupported = 0, - - // The property is supported by the system, but the user has not set it. - // The application should provide a default setting for the property to - // handle this case. - kSbAccessibilityCaptionStateUnset, - - // The user has set this property as a system default, meaning that it should - // take priority over app defaults. If - // SbAccessibilityCaptionSettings.supportsOverride contains true, this value - // should be interpreted as explicitly saying "do not override." If it - // contains false, it is up to the application to interpret any additional - // meaning of this value. - kSbAccessibilityCaptionStateSet, - - // This property should take priority over everything but application-level - // overrides, including video caption data. If - // SbAccessibilityCaptionSettings.supportsOverride contains false, then no - // fields of SbAccessibilityCaptionSettings will ever contain this value. - kSbAccessibilityCaptionStateOverride, -} SbAccessibilityCaptionState; - -// A group of settings related to system-level closed captioning settings, for -// platforms that expose closed captioning settings. -typedef struct SbAccessibilityCaptionSettings { - SbAccessibilityCaptionColor background_color; - SbAccessibilityCaptionState background_color_state; - - SbAccessibilityCaptionOpacityPercentage background_opacity; - SbAccessibilityCaptionState background_opacity_state; - - SbAccessibilityCaptionCharacterEdgeStyle character_edge_style; - SbAccessibilityCaptionState character_edge_style_state; - - SbAccessibilityCaptionColor font_color; - SbAccessibilityCaptionState font_color_state; - - SbAccessibilityCaptionFontFamily font_family; - SbAccessibilityCaptionState font_family_state; - - SbAccessibilityCaptionOpacityPercentage font_opacity; - SbAccessibilityCaptionState font_opacity_state; - - SbAccessibilityCaptionFontSizePercentage font_size; - SbAccessibilityCaptionState font_size_state; - - SbAccessibilityCaptionColor window_color; - SbAccessibilityCaptionState window_color_state; - - SbAccessibilityCaptionOpacityPercentage window_opacity; - SbAccessibilityCaptionState window_opacity_state; - - // The |is_enabled| attribute determines if the user has chosen to enable - // closed captions on their system. - bool is_enabled; - - // Some platforms support enabling or disabling captions, some support reading - // whether they are enabled from the system settings, and others support - // neither. As a result, there are separate checks for getting and setting - // the value that is contained in the |is_enabled| attribute. Modifying the - // attribute via |SbAccessibilitySetCaptionsEnabled| will change the setting - // system-wide. Attempting to read |is_enabled| when the value of - // |supports_is_enabled| is false will always return false. Attempting to set - // |is_enabled| via |SbAccessibilitySetCaptionsEnabled| when the value of - // |supports_set_enabled| is false will fail silently. - bool supports_is_enabled; - bool supports_set_enabled; - - // Some platforms may specify that when setting a property, it should override - // data from video streams and application settings (unless the application - // has its own overrides). Depending on whether this attribute contains true - // or false, the values of |SbAccessibilityCaptionState| should be interpreted - // differently. - bool supports_override; -} SbAccessibilityCaptionSettings; - -// Get the platform's settings for system-level closed captions. This function -// returns false if |caption_settings| is NULL or if it is not zero-initialized. -// -// |caption_settings|: A pointer to a zero-initialized -// SbAccessibilityTextToSpeechSettings struct. -SB_EXPORT bool SbAccessibilityGetCaptionSettings( - SbAccessibilityCaptionSettings* caption_settings); - -// Modifies whether closed captions are enabled at a system level. This -// function returns false if this feature is not supported by the platform, or -// if changing the setting is unsuccessful. This function will modify the -// setting system-wide. -// -// |enabled|: A boolean indicating whether captions should be turned on (true) -// or off (false). -SB_EXPORT bool SbAccessibilitySetCaptionsEnabled(bool enabled); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_ACCESSIBILITY_H_ diff --git a/starboard/android/shared/BUILD.gn b/starboard/android/shared/BUILD.gn index 5ec6ffbdb79a..9bdb0352196e 100644 --- a/starboard/android/shared/BUILD.gn +++ b/starboard/android/shared/BUILD.gn @@ -60,13 +60,9 @@ static_library("starboard_platform") { "//starboard/shared/gles/gl_call.h", "//starboard/shared/gles/system_gles2.cc", "//starboard/shared/internal_only.h", - "//starboard/shared/iso/impl/directory_close.h", - "//starboard/shared/iso/impl/directory_get_next.h", - "//starboard/shared/iso/impl/directory_open.h", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libevent/socket_waiter_add.cc", "//starboard/shared/libevent/socket_waiter_create.cc", "//starboard/shared/libevent/socket_waiter_destroy.cc", @@ -75,7 +71,6 @@ static_library("starboard_platform") { "//starboard/shared/libevent/socket_waiter_wait.cc", "//starboard/shared/libevent/socket_waiter_wait_timed.cc", "//starboard/shared/libevent/socket_waiter_wake_up.cc", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/system_get_random_data.cc", "//starboard/shared/linux/system_get_total_cpu_memory.cc", @@ -83,34 +78,12 @@ static_library("starboard_platform") { "//starboard/shared/linux/system_is_debugger_attached.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_set_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", - "//starboard/shared/nouser/user_internal.h", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/impl/file_can_open.h", - "//starboard/shared/posix/impl/file_close.h", - "//starboard/shared/posix/impl/file_delete.h", - "//starboard/shared/posix/impl/file_flush.h", - "//starboard/shared/posix/impl/file_get_info.h", - "//starboard/shared/posix/impl/file_get_path_info.h", - "//starboard/shared/posix/impl/file_open.h", - "//starboard/shared/posix/impl/file_read.h", - "//starboard/shared/posix/impl/file_seek.h", - "//starboard/shared/posix/impl/file_truncate.h", - "//starboard/shared/posix/impl/file_write.h", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -139,44 +112,17 @@ static_library("starboard_platform") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", "//starboard/shared/posix/system_get_last_error.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", "//starboard/shared/pthread/thread_sampler_freeze.cc", @@ -184,7 +130,6 @@ static_library("starboard_platform") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/signal/crash_signals.h", "//starboard/shared/signal/crash_signals_sigaction.cc", @@ -201,7 +146,6 @@ static_library("starboard_platform") { "//starboard/shared/starboard/audio_sink/stub_audio_sink_type.h", "//starboard/shared/starboard/command_line.cc", "//starboard/shared/starboard/command_line.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/drm/drm_close_session.cc", "//starboard/shared/starboard/drm/drm_destroy_system.cc", "//starboard/shared/starboard/drm/drm_generate_session_update_request.cc", @@ -214,7 +158,6 @@ static_library("starboard_platform") { "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -230,10 +173,8 @@ static_library("starboard_platform") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/microphone/microphone_close.cc", "//starboard/shared/starboard/microphone/microphone_create.cc", "//starboard/shared/starboard/microphone/microphone_destroy.cc", @@ -245,13 +186,10 @@ static_library("starboard_platform") { "//starboard/shared/starboard/new.cc", "//starboard/shared/starboard/queue_application.cc", "//starboard/shared/starboard/queue_application.h", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/thread_checker.h", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/image_decode.cc", - "//starboard/shared/stub/image_is_decode_supported.cc", "//starboard/shared/stub/system_get_total_gpu_memory.cc", "//starboard/shared/stub/system_get_used_gpu_memory.cc", "//starboard/shared/stub/system_hide_splash_screen.cc", @@ -259,17 +197,6 @@ static_library("starboard_platform") { "//starboard/shared/stub/system_request_focus.cc", "//starboard/shared/stub/system_request_reveal.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", "accessibility_extension.cc", "accessibility_extension.h", "accessibility_get_caption_settings.cc", @@ -311,28 +238,12 @@ static_library("starboard_platform") { "decode_target_internal.cc", "decode_target_internal.h", "decode_target_release.cc", - "directory_close.cc", - "directory_get_next.cc", - "directory_internal.h", - "directory_open.cc", "drm_create_system.cc", "drm_system.cc", "drm_system.h", "egl_swap_buffers.cc", - "file_can_open.cc", - "file_close.cc", - "file_delete.cc", - "file_exists.cc", - "file_flush.cc", - "file_get_info.cc", - "file_get_path_info.cc", "file_internal.cc", "file_internal.h", - "file_open.cc", - "file_read.cc", - "file_seek.cc", - "file_truncate.cc", - "file_write.cc", "get_home_directory.cc", "graphics.cc", "graphics.h", @@ -410,9 +321,7 @@ static_library("starboard_platform") { "system_request_conceal.cc", "system_request_freeze_no_freezedone_callback.cc", "system_request_stop.cc", - "thread_create.cc", "thread_create_priority.cc", - "thread_get_name.cc", "time_zone_get_name.cc", "trace_util.h", "video_decoder.cc", diff --git a/starboard/android/shared/configuration_constants.cc b/starboard/android/shared/configuration_constants.cc index 6fbbdaf8afe5..f777f984b2bf 100644 --- a/starboard/android/shared/configuration_constants.cc +++ b/starboard/android/shared/configuration_constants.cc @@ -123,11 +123,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/android/shared/configuration_public.h b/starboard/android/shared/configuration_public.h index 036a119bc499..652c332cef70 100644 --- a/starboard/android/shared/configuration_public.h +++ b/starboard/android/shared/configuration_public.h @@ -51,32 +51,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies the platform can map -// memory. This is required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/android/shared/directory_close.cc b/starboard/android/shared/directory_close.cc deleted file mode 100644 index a7718eb0cb8c..000000000000 --- a/starboard/android/shared/directory_close.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/android/shared/file_internal.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/shared/iso/impl/directory_close.h" - -bool SbDirectoryClose(SbDirectory directory) { - if (directory && directory->asset_dir) { - AAssetDir_close(directory->asset_dir); - delete directory; - return true; - } - - return ::starboard::shared::iso::impl::SbDirectoryClose(directory); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/directory_get_next.cc b/starboard/android/shared/directory_get_next.cc deleted file mode 100644 index 6a6ee48214fd..000000000000 --- a/starboard/android/shared/directory_get_next.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include - -#include - -#include "starboard/common/string.h" -#include "starboard/directory.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/iso/impl/directory_get_next.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - if (directory && directory->asset_dir && out_entry && - out_entry_size >= kSbFileMaxName) { - const char* file_name = AAssetDir_getNextFileName(directory->asset_dir); - if (file_name == NULL) { - return false; - } - starboard::strlcpy(out_entry, file_name, out_entry_size); - return true; - } - - return ::starboard::shared::iso::impl::SbDirectoryGetNext( - directory, out_entry, out_entry_size); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/directory_internal.h b/starboard/android/shared/directory_internal.h deleted file mode 100644 index 1e2108b95104..000000000000 --- a/starboard/android/shared/directory_internal.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ -#define STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ - -#include - -#include - -#include "starboard/directory.h" -#include "starboard/shared/internal_only.h" - -struct SbDirectoryPrivate { - // Note: Only one of these two fields will be valid for any given file. - - // The ISO C directory stream handle, or NULL if it's an asset directory. - DIR* directory; - - // If not NULL this is an Android asset directory. - AAssetDir* asset_dir; - - SbDirectoryPrivate() : directory(NULL), asset_dir(NULL) {} -}; - -#endif // STARBOARD_ANDROID_SHARED_DIRECTORY_INTERNAL_H_ diff --git a/starboard/android/shared/directory_open.cc b/starboard/android/shared/directory_open.cc deleted file mode 100644 index bb57549eef66..000000000000 --- a/starboard/android/shared/directory_open.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/android/shared/file_internal.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/shared/iso/impl/directory_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAssetDir; - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::iso::impl::SbDirectoryOpen(path, out_error); - } - - AAssetDir* asset_dir = OpenAndroidAssetDir(path); - if (asset_dir) { - SbDirectory result = new SbDirectoryPrivate(); - result->asset_dir = asset_dir; - return result; - } - - if (out_error) { - *out_error = kSbFileErrorFailed; - } - return kSbDirectoryInvalid; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_can_open.cc b/starboard/android/shared/file_can_open.cc deleted file mode 100644 index 3849cf96cb5a..000000000000 --- a/starboard/android/shared/file_can_open.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include -#include - -#include "starboard/directory.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_can_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -bool SbFileCanOpen(const char* path, int flags) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileCanOpen(path, flags); - } - - SbFile file = SbFileOpen(path, flags | kSbFileOpenOnly, NULL, NULL); - bool result = SbFileIsValid(file); - SbFileClose(file); - - if (!result) { - DIR* directory = opendir(path); - result = directory != nullptr; - closedir(directory); - } - - return result; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_close.cc b/starboard/android/shared/file_close.cc deleted file mode 100644 index b44eeca4ae62..000000000000 --- a/starboard/android/shared/file_close.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_close.h" - -bool SbFileClose(SbFile file) { - if (file && file->asset) { - AAsset_close(file->asset); - delete file; - return true; - } - - return ::starboard::shared::posix::impl::FileClose(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_delete.cc b/starboard/android/shared/file_delete.cc deleted file mode 100644 index 477b6ecc4bf0..000000000000 --- a/starboard/android/shared/file_delete.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_delete.h" - -bool SbFileDelete(const char* path) { - return ::starboard::shared::posix::impl::FileDelete(path); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_exists.cc b/starboard/android/shared/file_exists.cc deleted file mode 100644 index 810315828180..000000000000 --- a/starboard/android/shared/file_exists.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileExists(const char* path) { - return SbFileCanOpen(path, kSbFileRead); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/file_flush.cc b/starboard/android/shared/file_flush.cc deleted file mode 100644 index 7ab036bb0f5c..000000000000 --- a/starboard/android/shared/file_flush.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_flush.h" - -bool SbFileFlush(SbFile file) { - return ::starboard::shared::posix::impl::FileFlush(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_get_info.cc b/starboard/android/shared/file_get_info.cc deleted file mode 100644 index c7979fbee19a..000000000000 --- a/starboard/android/shared/file_get_info.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_get_info.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - if (file && file->asset && out_info) { - out_info->creation_time = 0; - out_info->is_directory = 0; - out_info->is_symbolic_link = 0; - out_info->last_accessed = 0; - out_info->last_modified = 0; - out_info->size = AAsset_getLength(file->asset); - return true; - } - - return ::starboard::shared::posix::impl::FileGetInfo(file, out_info); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_get_path_info.cc b/starboard/android/shared/file_get_path_info.cc deleted file mode 100644 index b1a8d58e9964..000000000000 --- a/starboard/android/shared/file_get_path_info.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -#include "starboard/directory.h" - -#include "starboard/android/shared/directory_internal.h" -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_get_path_info.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileGetPathInfo(path, out_info); - } - - SbFile file = SbFileOpen(path, kSbFileRead, NULL, NULL); - if (file) { - bool result = SbFileGetInfo(file, out_info); - SbFileClose(file); - return result; - } - - SbDirectory directory = SbDirectoryOpen(path, NULL); - if (directory && directory->asset_dir) { - out_info->creation_time = 0; - out_info->is_directory = 1; - out_info->is_symbolic_link = 0; - out_info->last_accessed = 0; - out_info->last_modified = 0; - out_info->size = 0; - SbDirectoryClose(directory); - return true; - } - - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/file_open.cc b/starboard/android/shared/file_open.cc deleted file mode 100644 index 8102b58f32d8..000000000000 --- a/starboard/android/shared/file_open.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_open.h" - -using starboard::android::shared::IsAndroidAssetPath; -using starboard::android::shared::OpenAndroidAsset; - -namespace { - -// Returns the fallback for the given asset path, or an empty string if none. -// NOTE: While Cobalt now provides a mechanism for loading system fonts through -// SbSystemGetPath(), using the fallback logic within SbFileOpen() is -// still preferred for Android's fonts. The reason for this is that the -// Android OS actually allows fonts to be loaded from two locations: one -// that it provides; and one that the devices running its OS, which it -// calls vendors, can provide. Rather than including the full Android font -// package, vendors have the option of using a smaller Android font -// package and supplementing it with their own fonts. -// -// If Android were to use SbSystemGetPath() for its fonts, vendors would -// have no way of providing those supplemental fonts to Cobalt, which -// could result in a limited selection of fonts being available. By -// treating Android's fonts as Cobalt's fonts, Cobalt can still offer a -// straightforward mechanism for including vendor fonts via -// SbSystemGetPath(). -std::string FallbackPath(const std::string& path) { - // We don't package most font files in Cobalt content and fallback to the - // system font file of the same name. - const std::string fonts_xml("fonts.xml"); - const std::string system_fonts_dir("/system/fonts/"); - const std::string cobalt_fonts_dir("/cobalt/assets/fonts/"); - - // Fonts fallback to the system fonts. - if (path.compare(0, cobalt_fonts_dir.length(), cobalt_fonts_dir) == 0) { - std::string file_name = path.substr(cobalt_fonts_dir.length()); - // fonts.xml doesn't fallback. - if (file_name != fonts_xml) { - return system_fonts_dir + file_name; - } - } - return std::string(); -} - -} // namespace - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - if (!IsAndroidAssetPath(path)) { - return ::starboard::shared::posix::impl::FileOpen(path, flags, out_created, - out_error); - } - - // Assets are never created and are always read-only, whether it's actually an - // asset or we end up opening a fallback path. - if (out_created) { - *out_created = false; - } - bool can_read = flags & kSbFileRead; - bool can_write = flags & kSbFileWrite; - if (!can_read || can_write) { - if (out_error) { - *out_error = kSbFileErrorAccessDenied; - } - return kSbFileInvalid; - } - - AAsset* asset = OpenAndroidAsset(path); - if (asset) { - SbFile result = new SbFilePrivate(); - result->asset = asset; - return result; - } - - std::string fallback_path = FallbackPath(path); - if (!fallback_path.empty()) { - SbFile result = ::starboard::shared::posix::impl::FileOpen( - fallback_path.c_str(), flags, out_created, out_error); - return result; - } - - if (out_error) { - *out_error = kSbFileErrorFailed; - } - return kSbFileInvalid; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_read.cc b/starboard/android/shared/file_read.cc deleted file mode 100644 index 2d90d4f8d5b3..000000000000 --- a/starboard/android/shared/file_read.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_read.h" - -int SbFileRead(SbFile file, char* data, int size) { - if (!file || size < 0) { - return -1; - } - - if (file->asset) { - return AAsset_read(file->asset, data, size); - } else { - return ::starboard::shared::posix::impl::FileRead(file, data, size); - } -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_seek.cc b/starboard/android/shared/file_seek.cc deleted file mode 100644 index e64f7fc5b6e9..000000000000 --- a/starboard/android/shared/file_seek.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_seek.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - if (file && file->asset) { - return AAsset_seek64(file->asset, offset, whence); - } else { - return ::starboard::shared::posix::impl::FileSeek(file, whence, offset); - } -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_truncate.cc b/starboard/android/shared/file_truncate.cc deleted file mode 100644 index fe96b632a924..000000000000 --- a/starboard/android/shared/file_truncate.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_truncate.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return ::starboard::shared::posix::impl::FileTruncate(file, length); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/file_write.cc b/starboard/android/shared/file_write.cc deleted file mode 100644 index e6c99cb85515..000000000000 --- a/starboard/android/shared/file_write.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/android/shared/file_internal.h" -#include "starboard/shared/posix/impl/file_write.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return ::starboard::shared::posix::impl::FileWrite(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/android/shared/posix_emu/dirent.cc b/starboard/android/shared/posix_emu/dirent.cc index d3f92f1951e9..507f77ae2810 100644 --- a/starboard/android/shared/posix_emu/dirent.cc +++ b/starboard/android/shared/posix_emu/dirent.cc @@ -18,7 +18,6 @@ #include -#include "starboard/android/shared/directory_internal.h" #include "starboard/android/shared/file_internal.h" #include "starboard/common/mutex.h" #include "starboard/common/string.h" diff --git a/starboard/android/shared/posix_emu/stat.cc b/starboard/android/shared/posix_emu/stat.cc index 572fca2f2dbc..3ed8a9acf5b9 100644 --- a/starboard/android/shared/posix_emu/stat.cc +++ b/starboard/android/shared/posix_emu/stat.cc @@ -18,7 +18,6 @@ #include -#include "starboard/android/shared/directory_internal.h" #include "starboard/android/shared/file_internal.h" #include "starboard/common/log.h" #include "starboard/directory.h" diff --git a/starboard/android/shared/thread_create.cc b/starboard/android/shared/thread_create.cc deleted file mode 100644 index 35fb27f2e6d6..000000000000 --- a/starboard/android/shared/thread_create.cc +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/android/shared/jni_env_ext.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/thread_create_priority.h" -#include "starboard/shared/pthread/types_internal.h" - -namespace starboard { -namespace shared { -namespace pthread { - -void PreThreadRun() {} - -void PostThreadRun() { - // TODO: Currently OnThreadFinish() is specific to the android-forked version - // of this file, thread_create.cc. This functionality could be implemented - // though similar to ThreadSetPriority(), such that we allow platforms to - // override the OnThreadStart()/OnThreadFinish() logic, if they want, and then - // we don't have to fork this file. The only reason that is not done - // currently is because of bad timing with respect to Starboard interface - // changes. - android::shared::JniEnvExt::OnThreadShutdown(); -} - -} // namespace pthread -} // namespace shared -} // namespace starboard - -namespace { - -struct ThreadParams { - SbThreadAffinity affinity; - SbThreadEntryPoint entry_point; - char name[128]; - void* context; - SbThreadPriority priority; -}; - -void* ThreadFunc(void* context) { - ThreadParams* thread_params = static_cast(context); - SbThreadEntryPoint entry_point = thread_params->entry_point; - void* real_context = thread_params->context; - SbThreadAffinity affinity = thread_params->affinity; - if (thread_params->name[0] != '\0') { - pthread_setname_np(pthread_self(), thread_params->name); - } - - starboard::shared::pthread::ThreadSetPriority(thread_params->priority); - - delete thread_params; - - if (SbThreadIsValidAffinity(affinity)) { - cpu_set_t cpu_set; - CPU_ZERO(&cpu_set); - CPU_SET(affinity, &cpu_set); - sched_setaffinity(0, sizeof(cpu_set), &cpu_set); - } - - starboard::shared::pthread::PreThreadRun(); - - void* return_value = entry_point(real_context); - - starboard::shared::pthread::PostThreadRun(); - - return return_value; -} - -} // namespace - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - if (stack_size < 0 || !entry_point) { - return kSbThreadInvalid; - } - -#if defined(ADDRESS_SANITIZER) - // Set a big thread stack size when in ADDRESS_SANITIZER mode. - // This eliminates buffer overflows for deeply nested callstacks. - if (stack_size == 0) { - stack_size = 4096 * 1024; // 4MB - } -#endif - - pthread_attr_t attributes; - int result = pthread_attr_init(&attributes); - if (!IsSuccess(result)) { - return kSbThreadInvalid; - } - - pthread_attr_setdetachstate( - &attributes, - (joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED)); - if (stack_size > 0) { - pthread_attr_setstacksize(&attributes, stack_size); - } - - ThreadParams* params = new ThreadParams(); - params->affinity = affinity; - params->entry_point = entry_point; - params->context = context; - - if (name) { - starboard::strlcpy(params->name, name, SB_ARRAY_SIZE_INT(params->name)); - } else { - params->name[0] = '\0'; - } - - params->priority = priority; - - SbThread thread = kSbThreadInvalid; - SB_COMPILE_ASSERT(sizeof(SbThread) >= sizeof(pthread_t), - pthread_t_larger_than_sb_thread); - result = pthread_create(SB_PTHREAD_INTERNAL_THREAD_PTR(thread), &attributes, - ThreadFunc, params); - - pthread_attr_destroy(&attributes); - if (IsSuccess(result)) { - return thread; - } - - return kSbThreadInvalid; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/android/shared/thread_get_name.cc b/starboard/android/shared/thread_get_name.cc deleted file mode 100644 index 9385ad7f6f83..000000000000 --- a/starboard/android/shared/thread_get_name.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include -#include "starboard/thread.h" - -void SbThreadGetName(char* buffer, int buffer_size) { - prctl(PR_GET_NAME, buffer, 0L, 0L, 0L); -} - -#endif diff --git a/starboard/atomic.h b/starboard/atomic.h index 827117510035..036eb3492dd8 100644 --- a/starboard/atomic.h +++ b/starboard/atomic.h @@ -256,10 +256,4 @@ SbAtomicRelease_LoadPtr(volatile const SbAtomicPtr* ptr) { // as inlined. This macro is defined on the command line by GN. #include STARBOARD_ATOMIC_INCLUDE -#if SB_API_VERSION < 15 && defined(__cplusplus) -extern "C++" { -#include "starboard/common/atomic.h" -} // extern "C++" -#endif // SB_API_VERSION < 15 && defined(__cplusplus) - #endif // STARBOARD_ATOMIC_H_ diff --git a/starboard/build/platforms.py b/starboard/build/platforms.py index 3d01892d753d..5681d3bf11b0 100644 --- a/starboard/build/platforms.py +++ b/starboard/build/platforms.py @@ -41,8 +41,6 @@ 'evergreen-arm-hardfp': 'starboard/evergreen/arm/hardfp', 'evergreen-arm-softfp': 'starboard/evergreen/arm/softfp', 'evergreen-arm64': 'starboard/evergreen/arm64', - 'win-win32': 'starboard/win/win32', - 'xb1': 'starboard/xb1', } PLATFORMS.update(INTERNAL_PLATFORMS) diff --git a/starboard/byte_swap.h b/starboard/byte_swap.h index 55e5263057f8..e86240a8fc06 100644 --- a/starboard/byte_swap.h +++ b/starboard/byte_swap.h @@ -20,74 +20,6 @@ #ifndef STARBOARD_BYTE_SWAP_H_ #define STARBOARD_BYTE_SWAP_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if SB_IS(BIG_ENDIAN) -#define SB_HOST_TO_NET_S16(x) (x) -#define SB_HOST_TO_NET_U16(x) (x) -#define SB_HOST_TO_NET_S32(x) (x) -#define SB_HOST_TO_NET_U32(x) (x) -#define SB_HOST_TO_NET_S64(x) (x) -#define SB_HOST_TO_NET_U64(x) (x) -#else -#define SB_HOST_TO_NET_S16(x) SbByteSwapS16(x) -#define SB_HOST_TO_NET_U16(x) SbByteSwapU16(x) -#define SB_HOST_TO_NET_S32(x) SbByteSwapS32(x) -#define SB_HOST_TO_NET_U32(x) SbByteSwapU32(x) -#define SB_HOST_TO_NET_S64(x) SbByteSwapS64(x) -#define SB_HOST_TO_NET_U64(x) SbByteSwapU64(x) -#endif - -#define SB_NET_TO_HOST_S16(x) SB_HOST_TO_NET_S16(x) -#define SB_NET_TO_HOST_U16(x) SB_HOST_TO_NET_U16(x) -#define SB_NET_TO_HOST_S32(x) SB_HOST_TO_NET_S32(x) -#define SB_NET_TO_HOST_U32(x) SB_HOST_TO_NET_U32(x) -#define SB_NET_TO_HOST_S64(x) SB_HOST_TO_NET_S64(x) -#define SB_NET_TO_HOST_U64(x) SB_HOST_TO_NET_U64(x) - -// TODO: Determine if these need to be inlined for performance reasons, -// and then act on that determination somehow. - -// Unconditionally swaps the byte order in signed 16-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int16_t SbByteSwapS16(int16_t value); - -// Unconditionally swaps the byte order in unsigned 16-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint16_t SbByteSwapU16(uint16_t value); - -// Unconditionally swaps the byte order in signed 32-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int32_t SbByteSwapS32(int32_t value); - -// Unconditionally swaps the byte order in unsigned 32-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint32_t SbByteSwapU32(uint32_t value); - -// Unconditionally swaps the byte order in signed 64-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT int64_t SbByteSwapS64(int64_t value); - -// Unconditionally swaps the byte order in unsigned 64-bit |value|. -// |value|: The value for which the byte order will be swapped. -SB_EXPORT uint64_t SbByteSwapU64(uint64_t value); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_BYTE_SWAP_H_ diff --git a/starboard/common/condition_variable.cc b/starboard/common/condition_variable.cc index 9cc6604a5887..9acbf1029ba8 100644 --- a/starboard/common/condition_variable.cc +++ b/starboard/common/condition_variable.cc @@ -23,9 +23,6 @@ namespace starboard { ConditionVariable::ConditionVariable(const Mutex& mutex) : mutex_(&mutex), condition_() { -#if SB_API_VERSION < 16 - SbConditionVariableCreate(&condition_, mutex_->mutex()); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -39,33 +36,20 @@ ConditionVariable::ConditionVariable(const Mutex& mutex) int result = pthread_cond_init(&condition_, nullptr); SB_DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableDestroy(&condition_); -#else pthread_cond_destroy(&condition_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait() const { mutex_->debugSetReleased(); -#if SB_API_VERSION < 16 - SbConditionVariableWait(&condition_, mutex_->mutex()); -#else pthread_cond_wait(&condition_, mutex_->mutex()); -#endif // SB_API_VERSION < 16 mutex_->debugSetAcquired(); } bool ConditionVariable::WaitTimed(int64_t duration) const { mutex_->debugSetReleased(); -#if SB_API_VERSION < 16 - bool was_signaled = SbConditionVariableIsSignaled( - SbConditionVariableWaitTimed(&condition_, mutex_->mutex(), duration)); -#else if (duration < 0) { duration = 0; } @@ -90,25 +74,16 @@ bool ConditionVariable::WaitTimed(int64_t duration) const { bool was_signaled = pthread_cond_timedwait(&condition_, mutex_->mutex(), &timeout) == 0; -#endif // SB_API_VERSION < 16 mutex_->debugSetAcquired(); return was_signaled; } void ConditionVariable::Broadcast() const { -#if SB_API_VERSION < 16 - SbConditionVariableBroadcast(&condition_); -#else pthread_cond_broadcast(&condition_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Signal() const { -#if SB_API_VERSION < 16 - SbConditionVariableSignal(&condition_); -#else pthread_cond_signal(&condition_); -#endif // SB_API_VERSION < 16 } } // namespace starboard diff --git a/starboard/common/condition_variable.h b/starboard/common/condition_variable.h index 94a46f691359..c7db1264f3f7 100644 --- a/starboard/common/condition_variable.h +++ b/starboard/common/condition_variable.h @@ -50,11 +50,7 @@ class ConditionVariable { private: const Mutex* mutex_; -#if SB_API_VERSION < 16 - mutable SbConditionVariable condition_; -#else mutable pthread_cond_t condition_; -#endif // SB_API_VERSION < 16 }; } // namespace starboard diff --git a/starboard/common/memory.h b/starboard/common/memory.h index 822b80dc9ec9..55ac1a422e82 100644 --- a/starboard/common/memory.h +++ b/starboard/common/memory.h @@ -12,14 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if SB_API_VERSION < 16 -#include "starboard/memory.h" -#else #include #include #include "starboard/configuration.h" #include "starboard/configuration_constants.h" -#endif // SB_API_VERSION < 16 #ifndef STARBOARD_COMMON_MEMORY_H_ #define STARBOARD_COMMON_MEMORY_H_ diff --git a/starboard/common/mutex.cc b/starboard/common/mutex.cc index e9400d7646f7..1d03c64c8028 100644 --- a/starboard/common/mutex.cc +++ b/starboard/common/mutex.cc @@ -18,38 +18,22 @@ namespace starboard { Mutex::Mutex() : mutex_() { -#if SB_API_VERSION < 16 - SbMutexCreate(&mutex_); -#else pthread_mutex_init(&mutex_, nullptr); -#endif // SB_API_VERSION < 16 debugInit(); } Mutex::~Mutex() { -#if SB_API_VERSION < 16 - SbMutexDestroy(&mutex_); -#else pthread_mutex_destroy(&mutex_); -#endif // SB_API_VERSION < 16 } void Mutex::Acquire() const { debugPreAcquire(); -#if SB_API_VERSION < 16 - SbMutexAcquire(&mutex_); -#else pthread_mutex_lock(&mutex_); -#endif // SB_API_VERSION < 16 debugSetAcquired(); } bool Mutex::AcquireTry() const { -#if SB_API_VERSION < 16 - bool ok = SbMutexAcquireTry(&mutex_) == kSbMutexAcquired; -#else bool ok = pthread_mutex_trylock(&mutex_) == 0; -#endif // SB_API_VERSION < 16 if (ok) { debugSetAcquired(); } @@ -58,11 +42,7 @@ bool Mutex::AcquireTry() const { void Mutex::Release() const { debugSetReleased(); -#if SB_API_VERSION < 16 - SbMutexRelease(&mutex_); -#else pthread_mutex_unlock(&mutex_); -#endif // SB_API_VERSION < 16 } void Mutex::DCheckAcquired() const { @@ -97,11 +77,7 @@ void Mutex::debugPreAcquire() const {} void Mutex::debugSetAcquired() const {} #endif -#if SB_API_VERSION < 16 -SbMutex* Mutex::mutex() const { -#else pthread_mutex_t* Mutex::mutex() const { -#endif return &mutex_; } diff --git a/starboard/common/mutex.h b/starboard/common/mutex.h index da95bf5eff48..c9f240c59436 100644 --- a/starboard/common/mutex.h +++ b/starboard/common/mutex.h @@ -22,10 +22,6 @@ #include "starboard/configuration.h" -#if SB_API_VERSION < 16 -#include "starboard/mutex.h" -#endif // SB_API_VERSION < 16 - namespace starboard { // Inline class wrapper for mutex. @@ -54,13 +50,8 @@ class Mutex { #endif friend class ConditionVariable; -#if SB_API_VERSION < 16 - SbMutex* mutex() const; - mutable SbMutex mutex_; -#else pthread_mutex_t* mutex() const; mutable pthread_mutex_t mutex_; -#endif // SB_API_VERSION < 16 Mutex(const Mutex&) = delete; void operator=(const Mutex&) = delete; }; diff --git a/starboard/common/storage.cc b/starboard/common/storage.cc index 61c54a2fc69c..b9d08051f1fc 100644 --- a/starboard/common/storage.cc +++ b/starboard/common/storage.cc @@ -16,37 +16,15 @@ namespace starboard { -StorageRecord::StorageRecord() - : -#if SB_API_VERSION < 16 - user_(SbUserGetCurrent()), -#endif // SB_API_VERSION < 16 - record_(kSbStorageInvalidRecord) { +StorageRecord::StorageRecord() : record_(kSbStorageInvalidRecord) { Initialize(); } StorageRecord::StorageRecord(const char* name) - : -#if SB_API_VERSION < 16 - user_(SbUserGetCurrent()), -#endif // SB_API_VERSION < 16 - name_(name), - record_(kSbStorageInvalidRecord) { + : name_(name), record_(kSbStorageInvalidRecord) { Initialize(); } -#if SB_API_VERSION < 16 -StorageRecord::StorageRecord(SbUser user) - : user_(user), record_(kSbStorageInvalidRecord) { - Initialize(); -} - -StorageRecord::StorageRecord(SbUser user, const char* name) - : user_(user), name_(name), record_(kSbStorageInvalidRecord) { - Initialize(); -} -#endif // SB_API_VERSION < 16 - StorageRecord::~StorageRecord() { Close(); } @@ -78,21 +56,11 @@ bool StorageRecord::Close() { bool StorageRecord::Delete() { Close(); -#if SB_API_VERSION < 16 - return SbStorageDeleteRecord(user_, name_.empty() ? NULL : name_.c_str()); -#else return SbStorageDeleteRecord(name_.empty() ? NULL : name_.c_str()); -#endif // SB_API_VERSION < 16 } void StorageRecord::Initialize() { -#if SB_API_VERSION < 16 - if (SbUserIsValid(user_)) { - record_ = SbStorageOpenRecord(user_, name_.empty() ? NULL : name_.c_str()); - } -#else record_ = SbStorageOpenRecord(name_.empty() ? NULL : name_.c_str()); -#endif // SB_API_VERSION < 16 } } // namespace starboard diff --git a/starboard/common/storage.h b/starboard/common/storage.h index b5239b29e090..1eb05fc0320e 100644 --- a/starboard/common/storage.h +++ b/starboard/common/storage.h @@ -25,9 +25,6 @@ #include "starboard/configuration.h" #include "starboard/storage.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -#endif namespace starboard { @@ -35,10 +32,6 @@ class StorageRecord { public: StorageRecord(); explicit StorageRecord(const char* name); -#if SB_API_VERSION < 16 - explicit StorageRecord(SbUser user); - StorageRecord(SbUser user, const char* name); -#endif ~StorageRecord(); bool IsValid(); @@ -51,10 +44,6 @@ class StorageRecord { private: void Initialize(); - -#if SB_API_VERSION < 16 - SbUser user_; -#endif std::string name_; SbStorageRecord record_; }; diff --git a/starboard/configuration.h b/starboard/configuration.h index 078f74deeaef..4c667619ea3e 100644 --- a/starboard/configuration.h +++ b/starboard/configuration.h @@ -327,11 +327,6 @@ struct CompileAssert {}; #endif // SB_C_FORCE_INLINE annotation for forcing a C function to be inlined. -#if SB_API_VERSION < 16 -#if !defined(SB_C_FORCE_INLINE) -#error "Your platform must define SB_C_FORCE_INLINE." -#endif -#else // SB_API_VERSION < 16 #if defined(SB_C_FORCE_INLINE) #error "Your platform must not define SB_C_FORCE_INLINE" #else // defined(SB_C_FORCE_INLINE) @@ -343,19 +338,12 @@ struct CompileAssert {}; #define SB_C_FORCE_INLINE inline #endif #endif // defined(SB_C_FORCE_INLINE) -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 16 -#if !defined(SB_C_INLINE) -#error "Your platform must define SB_C_INLINE." -#endif -#else #if defined(SB_C_INLINE) #error "Your platform should not define SB_C_INLINE, it is deprecated." #else #define SB_C_INLINE inline #endif -#endif #if SB_API_VERSION >= 16 #if defined(SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES) @@ -363,12 +351,8 @@ struct CompileAssert {}; #endif // defined(SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES) #endif // SB_API_VERSION >= 16 -// SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. -#if SB_API_VERSION < 16 -#if !defined(SB_EXPORT_PLATFORM) -#error "Your platform must define SB_EXPORT_PLATFORM." -#endif -#else // SB_API_VERSION >= 16 +// SB_EXPORT_PLATFORM annotates symbols as exported from shared libraries. // +// SB_API_VERSION >= 16 #if !defined(SB_EXPORT_PLATFORM) // auto-configure #if SB_IS(COMPILER_GCC) #define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) @@ -378,14 +362,9 @@ struct CompileAssert {}; #error "Could not determine compiler, you must define SB_EXPORT_PLATFORM." #endif #endif // !defined(SB_EXPORT_PLATFORM) -#endif // SB_API_VERSION >= 16 -// SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. -#if SB_API_VERSION < 16 -#if !defined(SB_IMPORT_PLATFORM) -#error "Your platform must define SB_IMPORT_PLATFORM." -#endif -#else // SB_API_VERSION >= 16 +// SB_IMPORT_PLATFORM annotates symbols as imported from shared libraries. // +// SB_API_VERSION >= 16 #if !defined(SB_IMPORT_PLATFORM) // auto-configure #if SB_IS(COMPILER_GCC) #define SB_IMPORT_PLATFORM @@ -395,7 +374,6 @@ struct CompileAssert {}; #error "Could not determine compiler, you must define SB_IMPORT_PLATFORM." #endif #endif // !defined(SB_IMPORT_PLATFORM) -#endif // SB_API_VERSION >= 16 // --- Derived Configuration ------------------------------------------------- diff --git a/starboard/configuration_constants.h b/starboard/configuration_constants.h index b0830b6ddc28..65823b954ad2 100644 --- a/starboard/configuration_constants.h +++ b/starboard/configuration_constants.h @@ -138,11 +138,6 @@ SB_EXPORT extern const char kSbPathSepChar; // The string form of SB_PATH_SEP_CHAR. SB_EXPORT extern const char* kSbPathSepString; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -SB_EXPORT extern const uint32_t kSbUserMaxSignedIn; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. SB_EXPORT extern const uint32_t kSbMaxSystemPathCacheDirectorySize; diff --git a/starboard/directory.h b/starboard/directory.h index f872ee924985..c5b5af9250d3 100644 --- a/starboard/directory.h +++ b/starboard/directory.h @@ -42,66 +42,6 @@ static inline bool SbDirectoryIsValid(SbDirectory directory) { return directory != kSbDirectoryInvalid; } -#if SB_API_VERSION < 17 -// DEPRECATED with SB_API_VERSION 16 -// -// Opens the given existing directory for listing. This function returns -// kSbDirectoryInvalidHandle if it is not successful. -// -// If |out_error| is provided by the caller, it will be set to the appropriate -// SbFileError code on failure. -// -// |out_error|: An output parameter that, in case of an error, is set to the -// reason that the directory could not be opened. -SB_EXPORT SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error); - -// DEPRECATED with SB_API_VERSION 16 -// -// Closes an open directory stream handle. The return value indicates whether -// the directory was closed successfully. -// -// |directory|: The directory stream handle to close. -SB_EXPORT bool SbDirectoryClose(SbDirectory directory); - -// DEPRECATED with SB_API_VERSION 16 -// -// Populates |out_entry| with the next entry in the specified directory stream, -// and moves the stream forward by one entry. -// -// Platforms may, but are not required to, return |.| (referring to the -// directory itself) and/or |..| (referring to the directory's parent directory) -// as entries in the directory stream. -// -// This function returns |true| if there was a next directory, and |false| -// at the end of the directory stream or if |out_entry_size| is smaller than -// kSbFileMaxName. -// -// |directory|: The directory stream from which to retrieve the next directory. -// |out_entry|: The null terminated string to be populated with the next -// directory entry. The space allocated for this string should be -// equal to |out_entry_size|. -// |out_entry_size|: The size of the space allocated for |out_entry|. This -// should be at least equal to kSbFileMaxName. -SB_EXPORT bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size); - -#endif // SB_API_VERSION < 17 - -#if SB_API_VERSION < 16 -// Indicates whether SbDirectoryOpen is allowed for the given |path|. -// -// |path|: The path to be checked. -SB_EXPORT bool SbDirectoryCanOpen(const char* path); - -// Creates the directory |path|, assuming the parent directory already exists. -// This function returns |true| if the directory now exists (even if it existed -// before) and returns |false| if the directory does not exist. -// -// |path|: The path to be created. -SB_EXPORT bool SbDirectoryCreate(const char* path); -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/elf_loader/exported_symbols.cc b/starboard/elf_loader/exported_symbols.cc index 7531c5084b33..0d85b766298c 100644 --- a/starboard/elf_loader/exported_symbols.cc +++ b/starboard/elf_loader/exported_symbols.cc @@ -26,13 +26,7 @@ #include #include -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/common/log.h" #include "starboard/condition_variable.h" #include "starboard/configuration.h" @@ -44,10 +38,6 @@ #include "starboard/event.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#include "starboard/once.h" -#endif // SB_API_VERSION < 16 #include "starboard/log.h" #include "starboard/memory.h" #include "starboard/microphone.h" @@ -70,14 +60,7 @@ #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" #define REGISTER_SYMBOL(s) \ @@ -113,19 +96,10 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(kSbPathSepChar); REGISTER_SYMBOL(kSbPathSepString); REGISTER_SYMBOL(kSbPreferredRgbaByteOrder); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(kSbUserMaxSignedIn); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 REGISTER_SYMBOL(kSbCanMapExecutableMemory); REGISTER_SYMBOL(kHasPartialAudioFramesSupport); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbAccessibilityGetCaptionSettings); - REGISTER_SYMBOL(SbAccessibilityGetDisplaySettings); - REGISTER_SYMBOL(SbAccessibilityGetTextToSpeechSettings); - REGISTER_SYMBOL(SbAccessibilitySetCaptionsEnabled); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbAudioSinkCreate); REGISTER_SYMBOL(SbAudioSinkDestroy); REGISTER_SYMBOL(SbAudioSinkGetMaxChannels); @@ -134,36 +108,9 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbAudioSinkIsAudioFrameStorageTypeSupported); REGISTER_SYMBOL(SbAudioSinkIsAudioSampleTypeSupported); REGISTER_SYMBOL(SbAudioSinkIsValid); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbByteSwapS16); - REGISTER_SYMBOL(SbByteSwapS32); - REGISTER_SYMBOL(SbByteSwapS64); - REGISTER_SYMBOL(SbByteSwapU16); - REGISTER_SYMBOL(SbByteSwapU32); - REGISTER_SYMBOL(SbByteSwapU64); - REGISTER_SYMBOL(SbConditionVariableBroadcast); - REGISTER_SYMBOL(SbConditionVariableCreate); - REGISTER_SYMBOL(SbConditionVariableDestroy); - REGISTER_SYMBOL(SbConditionVariableSignal); - REGISTER_SYMBOL(SbConditionVariableWait); - REGISTER_SYMBOL(SbConditionVariableWaitTimed); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbCPUFeaturesGet); REGISTER_SYMBOL(SbDecodeTargetGetInfo); REGISTER_SYMBOL(SbDecodeTargetRelease); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbDirectoryCanOpen); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbDirectoryClose); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbDirectoryCreate); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbDirectoryGetNext); - REGISTER_SYMBOL(SbDirectoryOpen); -#endif // SB_API_VERSION < 17 REGISTER_SYMBOL(SbDrmCloseSession); REGISTER_SYMBOL(SbDrmCreateSystem); REGISTER_SYMBOL(SbDrmDestroySystem); @@ -175,41 +122,11 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbEventCancel); REGISTER_SYMBOL(SbEventSchedule); REGISTER_SYMBOL(SbFileAtomicReplace); -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileCanOpen); - REGISTER_SYMBOL(SbFileClose); - REGISTER_SYMBOL(SbFileDelete); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbFileExists); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileFlush); - REGISTER_SYMBOL(SbFileGetInfo); -#endif // SB_API_VERSION < 17 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbFileGetPathInfo); -#endif // SB_API_VERSION < 16 -#if SB_API_VERSION < 17 - REGISTER_SYMBOL(SbFileModeStringToFlags); - REGISTER_SYMBOL(SbFileOpen); - REGISTER_SYMBOL(SbFileRead); - REGISTER_SYMBOL(SbFileSeek); - REGISTER_SYMBOL(SbFileTruncate); - REGISTER_SYMBOL(SbFileWrite); -#endif // SB_API_VERSION < 17 REGISTER_SYMBOL(SbGetEglInterface); REGISTER_SYMBOL(SbGetGlesInterface); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbImageDecode); - REGISTER_SYMBOL(SbImageIsDecodeSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbLog); REGISTER_SYMBOL(SbLogFlush); REGISTER_SYMBOL(SbLogFormat); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbLogIsTty); -#endif REGISTER_SYMBOL(SbLogRaw); REGISTER_SYMBOL(SbLogRawDumpStack); REGISTER_SYMBOL(SbLogRawFormat); @@ -221,36 +138,12 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMediaGetBufferAllocationUnit); REGISTER_SYMBOL(SbMediaGetBufferGarbageCollectionDurationThreshold); REGISTER_SYMBOL(SbMediaGetBufferPadding); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMediaGetBufferStorageType); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbMediaGetInitialBufferCapacity); REGISTER_SYMBOL(SbMediaGetMaxBufferCapacity); REGISTER_SYMBOL(SbMediaGetProgressiveBufferBudget); REGISTER_SYMBOL(SbMediaGetVideoBufferBudget); REGISTER_SYMBOL(SbMediaIsBufferPoolAllocateOnDemand); REGISTER_SYMBOL(SbMediaIsBufferUsingMemoryPool); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMemoryAllocate); - REGISTER_SYMBOL(SbMemoryAllocateAligned); - REGISTER_SYMBOL(SbMemoryAllocateAlignedUnchecked); - REGISTER_SYMBOL(SbMemoryAllocateNoReport); - REGISTER_SYMBOL(SbMemoryAllocateUnchecked); - REGISTER_SYMBOL(SbMemoryDeallocate); - REGISTER_SYMBOL(SbMemoryDeallocateAligned); - REGISTER_SYMBOL(SbMemoryDeallocateNoReport); -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - REGISTER_SYMBOL(SbMemoryFlush); -#endif // SB_CAN(MAP_EXECUTABLE_MEMORY) - REGISTER_SYMBOL(SbMemoryFree); - REGISTER_SYMBOL(SbMemoryFreeAligned); - REGISTER_SYMBOL(SbMemoryMap); - REGISTER_SYMBOL(SbMemoryProtect); - REGISTER_SYMBOL(SbMemoryReallocate); - REGISTER_SYMBOL(SbMemoryReallocateUnchecked); - REGISTER_SYMBOL(SbMemoryUnmap); -#endif // SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMicrophoneClose); REGISTER_SYMBOL(SbMicrophoneCreate); REGISTER_SYMBOL(SbMicrophoneDestroy); @@ -258,14 +151,6 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbMicrophoneIsSampleRateSupported); REGISTER_SYMBOL(SbMicrophoneOpen); REGISTER_SYMBOL(SbMicrophoneRead); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbMutexAcquire); - REGISTER_SYMBOL(SbMutexAcquireTry); - REGISTER_SYMBOL(SbMutexCreate); - REGISTER_SYMBOL(SbMutexDestroy); - REGISTER_SYMBOL(SbMutexRelease); - REGISTER_SYMBOL(SbOnce); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbPlayerCreate); REGISTER_SYMBOL(SbPlayerDestroy); #if SB_API_VERSION >= 15 @@ -338,14 +223,6 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbStorageOpenRecord); REGISTER_SYMBOL(SbStorageReadRecord); REGISTER_SYMBOL(SbStorageWriteRecord); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbStringCompareNoCase); - REGISTER_SYMBOL(SbStringCompareNoCaseN); - REGISTER_SYMBOL(SbStringDuplicate); - REGISTER_SYMBOL(SbStringFormat); - REGISTER_SYMBOL(SbStringFormatWide); - REGISTER_SYMBOL(SbStringScan); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbSystemBreakIntoDebugger); REGISTER_SYMBOL(SbSystemClearLastError); #if SB_API_VERSION < 15 @@ -380,77 +257,27 @@ ExportedSymbols::ExportedSymbols() { REGISTER_SYMBOL(SbSystemSupportsResume); REGISTER_SYMBOL(SbSystemSymbolize); REGISTER_SYMBOL(SbThreadContextGetPointer); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadCreate); - REGISTER_SYMBOL(SbThreadCreateLocalKey); - REGISTER_SYMBOL(SbThreadDestroyLocalKey); - REGISTER_SYMBOL(SbThreadDetach); - REGISTER_SYMBOL(SbThreadGetCurrent); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadGetId); #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadGetPriority); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadGetLocalValue); - REGISTER_SYMBOL(SbThreadGetName); - REGISTER_SYMBOL(SbThreadIsEqual); - REGISTER_SYMBOL(SbThreadJoin); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbThreadSamplerCreate); REGISTER_SYMBOL(SbThreadSamplerDestroy); REGISTER_SYMBOL(SbThreadSamplerFreeze); REGISTER_SYMBOL(SbThreadSamplerIsSupported); REGISTER_SYMBOL(SbThreadSamplerThaw); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadSetLocalValue); - REGISTER_SYMBOL(SbThreadSetName); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 REGISTER_SYMBOL(SbThreadSetPriority); #endif // SB_API_VERSION >= 16 -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbThreadSleep); - REGISTER_SYMBOL(SbThreadYield); - REGISTER_SYMBOL(SbTimeGetMonotonicNow); - REGISTER_SYMBOL(SbTimeGetMonotonicThreadNow); - REGISTER_SYMBOL(SbTimeGetNow); - REGISTER_SYMBOL(SbTimeIsTimeThreadNowSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbTimeZoneGetCurrent); REGISTER_SYMBOL(SbTimeZoneGetName); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbUiNavGetInterface); - REGISTER_SYMBOL(SbUserGetCurrent); - REGISTER_SYMBOL(SbUserGetProperty); - REGISTER_SYMBOL(SbUserGetPropertySize); - REGISTER_SYMBOL(SbUserGetSignedIn); - REGISTER_SYMBOL(SbWindowBlurOnScreenKeyboard); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowCreate); REGISTER_SYMBOL(SbWindowDestroy); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowFocusOnScreenKeyboard); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowGetDiagonalSizeInInches); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowGetOnScreenKeyboardBoundingRect); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowGetPlatformHandle); REGISTER_SYMBOL(SbWindowGetSize); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowHideOnScreenKeyboard); - REGISTER_SYMBOL(SbWindowIsOnScreenKeyboardShown); - REGISTER_SYMBOL(SbWindowOnScreenKeyboardIsSupported); - REGISTER_SYMBOL(SbWindowOnScreenKeyboardSuggestionsSupported); -#endif // SB_API_VERSION < 16 REGISTER_SYMBOL(SbWindowSetDefaultOptions); -#if SB_API_VERSION < 16 - REGISTER_SYMBOL(SbWindowSetOnScreenKeyboardKeepFocus); - REGISTER_SYMBOL(SbWindowShowOnScreenKeyboard); - REGISTER_SYMBOL(SbWindowUpdateOnScreenKeyboardSuggestions); -#endif // SB_API_VERSION < 16 #if SB_API_VERSION >= 16 // POSIX APIs diff --git a/starboard/event.h b/starboard/event.h index b7f245559b3b..2f885d59df02 100644 --- a/starboard/event.h +++ b/starboard/event.h @@ -261,20 +261,8 @@ typedef enum SbEventType { // kSbEventOnScreenKeyboardInvalidTicket. kSbEventTypeOnScreenKeyboardBlurred, -#if SB_API_VERSION < 16 - // The platform has updated the on screen keyboard suggestions. This event is - // triggered by the system or by the application's OnScreenKeyboard update - // suggestions method. The event has int data representing a ticket. The - // ticket is used by the application to mark individual calls to the update - // suggestions method as successfully completed. Events triggered by the - // application have tickets passed in via - // SbWindowUpdateOnScreenKeyboardSuggestions. System-triggered events have - // ticket value kSbEventOnScreenKeyboardInvalidTicket. - kSbEventTypeOnScreenKeyboardSuggestionsUpdated, -#else // Reserved for deprecated events. kSbEventTypeReserved1, -#endif // SB_API_VERSION < 16 // One or more of the fields returned by SbAccessibilityGetCaptionSettings // has changed. diff --git a/starboard/evergreen/arm/hardfp/configuration_public.h b/starboard/evergreen/arm/hardfp/configuration_public.h index c83d82ff60c1..a30aafb14d7b 100644 --- a/starboard/evergreen/arm/hardfp/configuration_public.h +++ b/starboard/evergreen/arm/hardfp/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/arm/softfp/configuration_public.h b/starboard/evergreen/arm/softfp/configuration_public.h index 792752169c7e..97e37ed7a253 100644 --- a/starboard/evergreen/arm/softfp/configuration_public.h +++ b/starboard/evergreen/arm/softfp/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/arm64/configuration_public.h b/starboard/evergreen/arm64/configuration_public.h index c14e32a3b08b..5e3c77ed4485 100644 --- a/starboard/evergreen/arm64/configuration_public.h +++ b/starboard/evergreen/arm64/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/evergreen/x64/configuration_public.h b/starboard/evergreen/x64/configuration_public.h index 1f9d6a5012f8..22b10cc6b9bd 100644 --- a/starboard/evergreen/x64/configuration_public.h +++ b/starboard/evergreen/x64/configuration_public.h @@ -47,32 +47,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Compiler Configuration ------------------------------------------------ - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/file.h b/starboard/file.h index 697c829d4bc9..6f2641807fbb 100644 --- a/starboard/file.h +++ b/starboard/file.h @@ -129,38 +129,7 @@ static inline bool SbFileIsValid(SbFile file) { return file != kSbFileInvalid; } -// DEPRECATED with SB_API_VERSION 16 -// -// Opens the file at |path|, which must be absolute, creating it if specified by -// |flags|. The read/write position is at the beginning of the file. -// -// Note that this function only guarantees the correct behavior when |path| -// points to a file. The behavior is undefined if |path| points to a directory. -// -// |path|: The absolute path of the file to be opened. -// |flags|: |SbFileFlags| that determine how the file is used in the -// application. Among other things, |flags| can indicate whether the -// application should create |path| if |path| does not already exist. -// |out_created|: Starboard sets this value to |true| if a new file is created -// or if an old file is truncated to zero length to simulate a new file, -// which can happen if the |kSbFileCreateAlways| flag is set. Otherwise, -// Starboard sets this value to |false|. -// |out_error|: If |path| cannot be created, this is set to |kSbFileInvalid|. -// Otherwise, it is |NULL|. -SB_EXPORT SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error); - -// DEPRECATED with SB_API_VERSION 16 -// -// Closes |file|. The return value indicates whether the file was closed -// successfully. -// -// |file|: The absolute path of the file to be closed. -SB_EXPORT bool SbFileClose(SbFile file); - -#endif // SB_API_VERSION < 17 +#endif // Replaces the content of the file at |path| with |data|. Returns whether the // contents of the file were replaced. The replacement of the content is an @@ -173,191 +142,6 @@ SB_EXPORT bool SbFileAtomicReplace(const char* path, const char* data, int64_t data_size); -#if SB_API_VERSION < 17 - -// DEPRECATED with SB_API_VERSION 16 -// -// Changes the current read/write position in |file|. The return value -// identifies the resultant current read/write position in the file (relative -// to the start) or |-1| in case of an error. This function might not support -// seeking past the end of the file on some platforms. -// -// |file|: The SbFile in which the read/write position will be changed. -// |whence|: The starting read/write position. The position is modified relative -// to this value. -// |offset|: The amount that the read/write position is changed, relative to -// |whence|. -SB_EXPORT int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset); - -// DEPRECATED with SB_API_VERSION 16 -// -// Reads |size| bytes (or until EOF is reached) from |file| into |data|, -// starting at the file's current position. -// -// The return value specifies the number of bytes read or |-1| if there was -// an error. Note that this function does NOT make a best effort to read all -// data on all platforms; rather, it just reads however many bytes are quickly -// available. However, this function can be run in a loop to make it a -// best-effort read. -// -// |file|: The SbFile from which to read data. -// |data|: The variable to which data is read. -// |size|: The amount of data (in bytes) to read. -SB_EXPORT int SbFileRead(SbFile file, char* data, int size); - -// DEPRECATED with SB_API_VERSION 16 -// -// Writes the given buffer into |file| at the file's current position, -// overwriting any data that was previously there. -// -// The return value identifies the number of bytes written, or |-1| on error. -// Note that this function does NOT make a best effort to write all data; -// rather, it writes however many bytes can be written quickly. Generally, this -// means that it writes however many bytes as possible without blocking on IO. -// Run this function in a loop to ensure that all data is written. -// -// |file|: The SbFile to which data will be written. -// |data|: The data to be written. -// |size|: The amount of data (in bytes) to write. -SB_EXPORT int SbFileWrite(SbFile file, const char* data, int size); - -// DEPRECATED with SB_API_VERSION 16 -// -// Truncates the given |file| to the given |length|. The return value indicates -// whether the file was truncated successfully. -// -// |file|: The file to be truncated. -// |length|: The expected length of the file after it is truncated. If |length| -// is greater than the current size of the file, then the file is extended -// with zeros. If |length| is negative, then the function is a no-op and -// returns |false|. -SB_EXPORT bool SbFileTruncate(SbFile file, int64_t length); - -// DEPRECATED with SB_API_VERSION 16 -// -// Flushes the write buffer to |file|. Data written via SbFileWrite is not -// necessarily committed until the SbFile is flushed or closed. -// -// |file|: The SbFile to which the write buffer is flushed. -SB_EXPORT bool SbFileFlush(SbFile file); - -// DEPRECATED with SB_API_VERSION 16 -// -// Retrieves information about |file|. The return value indicates whether the -// file information was retrieved successfully. -// -// |file|: The SbFile for which information is retrieved. -// |out_info|: The variable into which the retrieved data is placed. This -// variable is not touched if the operation is not successful. -SB_EXPORT bool SbFileGetInfo(SbFile file, SbFileInfo* out_info); - -// DEPRECATED with SB_API_VERSION 16 -// -// Retrieves information about the file at |path|. The return value indicates -// whether the file information was retrieved successfully. -// -// |file|: The absolute path of the file for which information is retrieved. -// |out_info|: The variable into which the retrieved data is placed. This -// variable is not touched if the operation is not successful. -SB_EXPORT bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info); - -// DEPRECATED with SB_API_VERSION 16 -// -// Deletes the regular file, symlink, or empty directory at |path|. This -// function is used primarily to clean up after unit tests. On some platforms, -// this function fails if the file in question is being held open. -// -// |path|: The absolute path of the file, symlink, or directory to be deleted. -SB_EXPORT bool SbFileDelete(const char* path); - -#endif // SB_API_VERSION < 17 - -#if SB_API_VERSION < 16 -// Indicates whether a file or directory exists at |path|. -// -// |path|: The absolute path of the file or directory being checked. -SB_EXPORT bool SbFileExists(const char* path); -#endif // SB_API_VERSION < 16 - -#if SB_API_VERSION < 17 - -// DEPRECATED with SB_API_VERSION 16 -// -// Indicates whether SbFileOpen() with the given |flags| is allowed for |path|. -// -// |path|: The absolute path to be checked. -// |flags|: The flags that are being evaluated for the given |path|. -SB_EXPORT bool SbFileCanOpen(const char* path, int flags); - -// DEPRECATED with SB_API_VERSION 16 -// -// Converts an ISO |fopen()| mode string into flags that can be equivalently -// passed into SbFileOpen(). -// -// |mode|: The mode string to be converted into flags. -SB_EXPORT int SbFileModeStringToFlags(const char* mode); - -// DEPRECATED with SB_API_VERSION 16 -// -// Reads |size| bytes (or until EOF is reached) from |file| into |data|, -// starting at the file's current position. -// -// The return value specifies the number of bytes read or |-1| if there was -// an error. Note that, unlike |SbFileRead|, this function does make a best -// effort to read all data on all platforms. As such, it is not intended for -// stream-oriented files but instead for cases when the normal expectation is -// that |size| bytes can be read unless there is an error. -// -// |file|: The SbFile from which to read data. -// |data|: The variable to which data is read. -// |size|: The amount of data (in bytes) to read. -static inline int SbFileReadAll(SbFile file, char* data, int size) { - if (!SbFileIsValid(file) || size < 0) { - return -1; - } - int bytes_read = 0; - int rv; - do { - rv = SbFileRead(file, data + bytes_read, size - bytes_read); - if (rv <= 0) { - break; - } - bytes_read += rv; - } while (bytes_read < size); - - return bytes_read ? bytes_read : rv; -} - -// DEPRECATED with SB_API_VERSION 16 -// -// Writes the given buffer into |file|, starting at the beginning of the file, -// and overwriting any data that was previously there. Unlike SbFileWrite, this -// function does make a best effort to write all data on all platforms. -// -// The return value identifies the number of bytes written, or |-1| on error. -// -// |file|: The file to which data will be written. -// |data|: The data to be written. -// |size|: The amount of data (in bytes) to write. -static inline int SbFileWriteAll(SbFile file, const char* data, int size) { - if (!SbFileIsValid(file) || size < 0) { - return -1; - } - int bytes_written = 0; - int rv; - do { - rv = SbFileWrite(file, data + bytes_written, size - bytes_written); - if (rv <= 0) { - break; - } - bytes_written += rv; - } while (bytes_written < size); - - return bytes_written ? bytes_written : rv; -} - -#endif // SB_API_VERSION < 17 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/image.h b/starboard/image.h index 37f29c98ae8b..831abe177b1d 100644 --- a/starboard/image.h +++ b/starboard/image.h @@ -42,63 +42,6 @@ #ifndef STARBOARD_IMAGE_H_ #define STARBOARD_IMAGE_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/decode_target.h" -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Whether the current platform supports hardware accelerated decoding an -// image of mime type |mime_type| into SbDecodeTargetFormat |format|. The -// |mime_type| must not be NULL. The result of this function must not change -// over the course of the program, which means that the results of this function -// may be cached indefinitely. -SB_EXPORT bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format); - -// Attempt to decode encoded |mime_type| image data |data| of size |data_size| -// into an SbDecodeTarget of SbDecodeFormatType |format|, possibly using -// SbDecodeTargetProvider |provider|, if it is non-null. Thus, four following -// scenarios regarding the provider may happen: -// -// 1. The provider is required by the |SbImageDecode| implementation and no -// provider is given. The implementation should gracefully fail by -// immediately returning kSbDecodeTargetInvalid. -// 2. The provider is required and is passed in. The implementation will -// proceed forward, using the SbDecodeTarget from the provider. -// 3. The provider is not required and is passed in. The provider will NOT be -// called, and the implementation will proceed to decoding however it -// desires. -// 4. The provider is not required and is not passed in. The implementation -// will proceed forward. -// The |data| pointer must not be NULL. -// The |mime_type| string must not be NULL. -// Thus, it is NOT safe for clients of this API to assume that the |provider| -// it passes in will be called. Finally, if the decode succeeds, a new -// SbDecodeTarget will be allocated. If |mime_type| image decoding for the -// requested format is not supported or the decode fails, -// kSbDecodeTargetInvalid will be returned, with any intermediate allocations -// being cleaned up in the implementation. -SB_EXPORT SbDecodeTarget -SbImageDecode(SbDecodeTargetGraphicsContextProvider* context_provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_IMAGE_H_ diff --git a/starboard/linux/shared/BUILD.gn b/starboard/linux/shared/BUILD.gn index ab821f26960c..eaa3eec457f5 100644 --- a/starboard/linux/shared/BUILD.gn +++ b/starboard/linux/shared/BUILD.gn @@ -100,13 +100,9 @@ static_library("starboard_platform_sources") { "//starboard/shared/egl/system_egl.cc", "//starboard/shared/gcc/atomic_gcc_public.h", "//starboard/shared/gles/system_gles2.cc", - "//starboard/shared/iso/directory_close.cc", - "//starboard/shared/iso/directory_get_next.cc", - "//starboard/shared/iso/directory_open.cc", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libdav1d/dav1d_video_decoder.cc", "//starboard/shared/libdav1d/dav1d_video_decoder.h", "//starboard/shared/libde265/de265_library_loader.cc", @@ -127,7 +123,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/libfdkaac/libfdkaac_library_loader.h", "//starboard/shared/libvpx/vpx_video_decoder.cc", "//starboard/shared/libvpx/vpx_video_decoder.h", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/dev_input/dev_input.cc", "//starboard/shared/linux/dev_input/dev_input.h", @@ -141,49 +136,25 @@ static_library("starboard_platform_sources") { "//starboard/shared/linux/system_network_status.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_get_name.cc", - "//starboard/shared/linux/thread_set_name.cc", "//starboard/shared/linux/time_zone_get_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", "//starboard/shared/openh264/openh264_library_loader.cc", "//starboard/shared/openh264/openh264_library_loader.h", "//starboard/shared/openh264/openh264_video_decoder.cc", "//starboard/shared/openh264/openh264_video_decoder.h", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/file_can_open.cc", - "//starboard/shared/posix/file_close.cc", - "//starboard/shared/posix/file_delete.cc", - "//starboard/shared/posix/file_exists.cc", - "//starboard/shared/posix/file_flush.cc", - "//starboard/shared/posix/file_get_info.cc", - "//starboard/shared/posix/file_get_path_info.cc", - "//starboard/shared/posix/file_open.cc", - "//starboard/shared/posix/file_read.cc", - "//starboard/shared/posix/file_seek.cc", - "//starboard/shared/posix/file_truncate.cc", - "//starboard/shared/posix/file_write.cc", "//starboard/shared/posix/free_space.cc", "//starboard/shared/posix/free_space.h", "//starboard/shared/posix/log.cc", "//starboard/shared/posix/log_flush.cc", "//starboard/shared/posix/log_format.cc", - "//starboard/shared/posix/log_is_tty.cc", "//starboard/shared/posix/log_raw.cc", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", "//starboard/shared/posix/memory_mapped_file.cc", "//starboard/shared/posix/memory_mapped_file.h", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -212,10 +183,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", @@ -223,35 +190,11 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/system_get_locale_id.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create.cc", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_priority.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", @@ -260,7 +203,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/pulse/pulse_audio_sink_type.cc", "//starboard/shared/pulse/pulse_audio_sink_type.h", @@ -291,12 +233,10 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/crash_handler.cc", "//starboard/shared/starboard/crash_handler.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -314,16 +254,13 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_max_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", "//starboard/shared/starboard/media/media_get_video_buffer_budget.cc", "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/queue_application.cc", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_request_blur.cc", "//starboard/shared/starboard/system_request_focus.cc", @@ -331,10 +268,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/system_request_stop.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/accessibility_get_caption_settings.cc", - "//starboard/shared/stub/accessibility_get_display_settings.cc", - "//starboard/shared/stub/accessibility_get_text_to_speech_settings.cc", - "//starboard/shared/stub/accessibility_set_captions_enabled.cc", "//starboard/shared/stub/microphone_close.cc", "//starboard/shared/stub/microphone_create.cc", "//starboard/shared/stub/microphone_destroy.cc", @@ -351,18 +284,7 @@ static_library("starboard_platform_sources") { "//starboard/shared/stub/system_raise_platform_error.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", "//starboard/shared/stub/thread_create_priority.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", ] sources += common_player_sources @@ -376,11 +298,6 @@ static_library("starboard_platform_sources") { ] } - if (sb_api_version < 15) { - sources -= [ "//starboard/shared/starboard/player/player_write_samples.cc" ] - sources += enhanced_audio_sources - } - configs += [ "//starboard/build/config:starboard_implementation", "//third_party/dav1d:public_dav1d_config", diff --git a/starboard/linux/shared/configuration_constants.cc b/starboard/linux/shared/configuration_constants.cc index c5c5fb9725ea..03688816a91a 100644 --- a/starboard/linux/shared/configuration_constants.cc +++ b/starboard/linux/shared/configuration_constants.cc @@ -122,11 +122,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/linux/shared/configuration_public.h b/starboard/linux/shared/configuration_public.h index e45b0e53f6e6..9319103f9bf2 100644 --- a/starboard/linux/shared/configuration_public.h +++ b/starboard/linux/shared/configuration_public.h @@ -49,32 +49,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Attribute Configuration ----------------------------------------------- - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/linux/x64x11/shared/BUILD.gn b/starboard/linux/x64x11/shared/BUILD.gn index eff90ec89710..bf88c3a5483c 100644 --- a/starboard/linux/x64x11/shared/BUILD.gn +++ b/starboard/linux/x64x11/shared/BUILD.gn @@ -38,8 +38,6 @@ static_library("starboard_platform_sources") { sources = [ "//starboard/linux/x64x11/system_get_property.cc", "//starboard/linux/x64x11/system_get_property_impl.cc", - "//starboard/shared/libjpeg/image_decode.cc", - "//starboard/shared/libjpeg/image_is_decode_supported.cc", "//starboard/shared/libjpeg/jpeg_image_decoder.cc", "//starboard/shared/libjpeg/jpeg_image_decoder.h", "//starboard/shared/starboard/link_receiver.cc", diff --git a/starboard/linux/x64x11/system_get_property_impl.cc b/starboard/linux/x64x11/system_get_property_impl.cc index 9a5f9e3db438..aaa660f57251 100644 --- a/starboard/linux/x64x11/system_get_property_impl.cc +++ b/starboard/linux/x64x11/system_get_property_impl.cc @@ -36,14 +36,6 @@ const char kSystemIntegratorName[] = "SystemIntegratorName"; const char kModelYear[] = "2026"; #endif // SB_API_VERSION == 17 -#if SB_API_VERSION == 16 -const char kModelYear[] = "2025"; -#endif // SB_API_VERSION == 16 - -#if SB_API_VERSION == 15 -const char kModelYear[] = "2024"; -#endif // SB_API_VERSION == 15 - } // namespace // Omit namespace linux due to symbol name conflict. diff --git a/starboard/log.h b/starboard/log.h index 51dc73aa6c32..4052d442a0fb 100644 --- a/starboard/log.h +++ b/starboard/log.h @@ -105,11 +105,6 @@ static inline void SbLogFormatF(const char* format, ...) { // multiple threads. SB_EXPORT void SbLogFlush(); -#if SB_API_VERSION < 16 -// Indicates whether the log output goes to a TTY or is being redirected. -SB_EXPORT bool SbLogIsTty(); -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/media.h b/starboard/media.h index 182e8000e91e..2227ad7de07c 100644 --- a/starboard/media.h +++ b/starboard/media.h @@ -133,9 +133,6 @@ typedef enum SbMediaAudioCodingType { typedef enum SbMediaAudioSampleType { kSbMediaAudioSampleTypeInt16Deprecated, kSbMediaAudioSampleTypeFloat32, -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - kSbMediaAudioSampleTypeInt16 = kSbMediaAudioSampleTypeInt16Deprecated, -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) } SbMediaAudioSampleType; // Possible audio frame storage types. @@ -499,11 +496,6 @@ typedef struct SbMediaVideoSampleInfo { // A structure describing the audio configuration parameters of a single audio // output. typedef struct SbMediaAudioConfiguration { -#if SB_API_VERSION < 15 - // The platform-defined index of the associated audio output. - int index; -#endif // SB_API_VERSION < 15 - #if SB_API_VERSION >= 15 // The type of audio connector. Will be |kSbMediaAudioConnectorUnknown| if // this device cannot provide this information. @@ -685,13 +677,6 @@ SB_EXPORT bool SbMediaGetAudioConfiguration( // Value used when a video's bits per pixel is not known. #define kSbMediaBitsPerPixelInvalid 0 -#if SB_API_VERSION < 16 -typedef enum SbMediaBufferStorageType { - kSbMediaBufferStorageTypeMemory, - kSbMediaBufferStorageTypeFile, -} SbMediaBufferStorageType; -#endif // SB_API_VERSION < 16 - // DEPRECATED with SB_API_VERSION 16 // // SbMediaGetBufferAlignment() was deprecated in Starboard 16, its return value @@ -808,17 +793,6 @@ SB_EXPORT int SbMediaGetProgressiveBufferBudget(SbMediaVideoCodec codec, int resolution_height, int bits_per_pixel); -#if SB_API_VERSION < 16 -// Returns SbMediaBufferStorageType of type |SbMediaStorageTypeMemory| or -// |SbMediaStorageTypeFile|. For memory storage, the media buffers will be -// stored in main memory allocated by malloc functions. For file storage, the -// media buffers will be stored in a temporary file in the system cache folder -// acquired by calling SbSystemGetPath() with "kSbSystemPathCacheDirectory". -// Note that when its value is "file" the media stack will still allocate memory -// to cache the buffers in use. -SB_EXPORT SbMediaBufferStorageType SbMediaGetBufferStorageType(); -#endif // SB_API_VERSION < 16 - // DEPRECATED with SB_API_VERSION 16 // // This function is deprecated in Starboard 16 and no longer used. It's not diff --git a/starboard/memory.h b/starboard/memory.h index cb8a1950f0b1..4ca129afd81e 100644 --- a/starboard/memory.h +++ b/starboard/memory.h @@ -65,199 +65,6 @@ typedef enum SbMemoryMapFlags { kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite, } SbMemoryMapFlags; -#if SB_API_VERSION < 16 - -#define SB_MEMORY_MAP_FAILED ((void*)-1) // NOLINT(readability/casting) - -static SB_C_FORCE_INLINE void SbAbortIfAllocationFailed(size_t requested_bytes, - void* address) { - if (SB_UNLIKELY(requested_bytes > 0 && address == NULL)) { - // Will abort the program if no debugger is attached. - SbSystemBreakIntoDebugger(); - } -} - -// Allocates and returns a chunk of memory of at least |size| bytes. This -// function should be called from the client codebase. It is intended to be a -// drop-in replacement for |malloc|. -// -// Note that this function returns |NULL| if it is unable to allocate the -// memory. -// -// |size|: The amount of memory to be allocated. If |size| is 0, the function -// may return |NULL| or it may return a unique pointer value that can be -// passed to SbMemoryDeallocate. -SB_EXPORT void* SbMemoryAllocate(size_t size); - -// DEPRECATED: Same as SbMemoryAllocate(). -SB_EXPORT void* SbMemoryAllocateNoReport(size_t size); - -// Attempts to resize |memory| to be at least |size| bytes, without touching -// the contents of memory. -// - If the function cannot perform the fast resize, it allocates a new chunk -// of memory, copies the contents over, and frees the previous chunk, -// returning a pointer to the new chunk. -// - If the function cannot perform the slow resize, it returns |NULL|, -// leaving the given memory chunk unchanged. -// -// This function should be called from the client codebase. It is meant to be a -// drop-in replacement for |realloc|. -// -// |memory|: The chunk of memory to be resized. |memory| may be NULL, in which -// case it behaves exactly like SbMemoryAllocateUnchecked. -// |size|: The size to which |memory| will be resized. If |size| is |0|, -// the function may return |NULL| or it may return a unique pointer value -// that can be passed to SbMemoryDeallocate. -SB_EXPORT void* SbMemoryReallocate(void* memory, size_t size); - -// Allocates and returns a chunk of memory of at least |size| bytes, aligned to -// |alignment|. This function should be called from the client codebase. It is -// meant to be a drop-in replacement for |memalign|. -// -// The function returns |NULL| if it cannot allocate the memory. In addition, -// the function's behavior is undefined if |alignment| is not a power of two. -// -// |alignment|: The way that data is arranged and accessed in memory. The value -// must be a power of two. -// |size|: The size of the memory to be allocated. If |size| is |0|, the -// function may return |NULL| or it may return a unique aligned pointer value -// that can be passed to SbMemoryDeallocateAligned. -SB_EXPORT void* SbMemoryAllocateAligned(size_t alignment, size_t size); - -// Frees a previously allocated chunk of memory. If |memory| is NULL, then the -// operation is a no-op. This function should be called from the client -// codebase. It is meant to be a drop-in replacement for |free|. -// -// |memory|: The chunk of memory to be freed. -SB_EXPORT void SbMemoryDeallocate(void* memory); - -// DEPRECATED: Same as SbMemoryDeallocate() -SB_EXPORT void SbMemoryDeallocateNoReport(void* memory); - -// Frees a previously allocated chunk of aligned memory. This function should -// be called from the client codebase. It is meant to be a drop-in replacement -// for |_aligned_free|. - -// |memory|: The chunk of memory to be freed. If |memory| is NULL, then the -// function is a no-op. -SB_EXPORT void SbMemoryDeallocateAligned(void* memory); - -///////////////////////////////////////////////////////////////// -// The following functions must be provided by Starboard ports. -///////////////////////////////////////////////////////////////// - -// This is the implementation of SbMemoryAllocate that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryAllocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryAllocateUnchecked(size_t size)); - -// This is the implementation of SbMemoryReallocate that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryReallocate(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryReallocateUnchecked(void* memory, size_t size)); - -// This is the implementation of SbMemoryAllocateAligned that must be -// provided by Starboard ports. -// -// DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryAllocateAlignedUnchecked(size_t alignment, - size_t size)); - -// This is the implementation of SbMemoryDeallocate that must be provided by -// Starboard ports. -// -// DO NOT CALL. Call SbMemoryDeallocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void SbMemoryFree(void* memory)); - -// This is the implementation of SbMemoryFreeAligned that must be provided by -// Starboard ports. -// -// DO NOT CALL. Call SbMemoryDeallocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void SbMemoryFreeAligned(void* memory)); - -// Allocates |size_bytes| worth of physical memory pages and maps them into -// an available virtual region. This function returns |SB_MEMORY_MAP_FAILED| -// on failure. |NULL| is a valid return value. -// -// |size_bytes|: The amount of physical memory pages to be allocated. -// |flags|: The bitwise OR of the protection flags for the mapped memory -// as specified in |SbMemoryMapFlags|. Allocating executable memory is not -// allowed and will fail. If executable memory is needed, map non-executable -// memory first and then switch access to executable using SbMemoryProtect. -// When kSbMemoryMapProtectReserved is used, the address space will not be -// accessible and, if possible, the platform should not count it against any -// memory budget. -// |name|: A value that appears in the debugger on some platforms. The value -// can be up to 32 bytes. -SB_EXPORT void* SbMemoryMap(int64_t size_bytes, int flags, const char* name); - -// Unmap |size_bytes| of physical pages starting from |virtual_address|, -// returning |true| on success. After this function completes, -// [virtual_address, virtual_address + size_bytes) will not be read/writable. -// This function can unmap multiple contiguous regions that were mapped with -// separate calls to SbMemoryMap(). For example, if one call to -// |SbMemoryMap(0x1000)| returns |(void*)0xA000|, and another call to -// |SbMemoryMap(0x1000)| returns |(void*)0xB000|, -// |SbMemoryUnmap(0xA000, 0x2000)| should free both regions. -SB_EXPORT bool SbMemoryUnmap(void* virtual_address, int64_t size_bytes); - -// Change the protection of |size_bytes| of memory regions, starting from -// |virtual_address|, to |flags|, returning |true| on success. -SB_EXPORT bool SbMemoryProtect(void* virtual_address, - int64_t size_bytes, - int flags); - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) -// Flushes any data in the given virtual address range that is cached locally in -// the current processor core to physical memory, ensuring that data and -// instruction caches are cleared. This is required to be called on executable -// memory that has been written to and might be executed in the future. -SB_EXPORT void SbMemoryFlush(void* virtual_address, int64_t size_bytes); -#endif -#endif // SB_API_VERSION < 16 - -#if SB_API_VERSION < 16 -// A wrapper that implements a drop-in replacement for |calloc|, which is used -// in some packages. -static SB_C_INLINE void* SbMemoryCalloc(size_t count, size_t size) { - size_t total = count * size; - void* result = SbMemoryAllocate(total); - if (result) { - memset(result, 0, total); - } - return result; -} - -///////////////////////////////////////////////////////////////// -// Deprecated. Do not use. -///////////////////////////////////////////////////////////////// - -// Same as SbMemoryAllocateUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryAllocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryAllocateChecked(size_t size)); - -// Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryReallocate(...) instead. -SB_DEPRECATED_EXTERNAL(SB_EXPORT void* SbMemoryReallocateChecked(void* memory, - size_t size)); - -// Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -// allocation failure. -// -// DO NOT CALL. Call SbMemoryAllocateAligned(...) instead. -SB_DEPRECATED_EXTERNAL( - SB_EXPORT void* SbMemoryAllocateAlignedChecked(size_t alignment, - size_t size)); -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/nplb/BUILD.gn b/starboard/nplb/BUILD.gn index 3581c5c5c903..618d9f1a10b5 100644 --- a/starboard/nplb/BUILD.gn +++ b/starboard/nplb/BUILD.gn @@ -37,7 +37,6 @@ target(gtest_target_type, "nplb") { "//starboard/shared/starboard/drm/drm_test_helpers.h", "//starboard/testing/fake_graphics_context_provider.cc", "//starboard/testing/fake_graphics_context_provider.h", - "accessibility_test.cc", "align_test.cc", "atomic_base_test.cc", "atomic_test.cc", @@ -51,21 +50,9 @@ target(gtest_target_type, "nplb") { "audio_sink_is_audio_frame_storage_type_supported_test.cc", "audio_sink_is_audio_sample_type_supported_test.cc", "audio_sink_test.cc", - "byte_swap_test.cc", "char_is_signed_test.cc", - "condition_variable_broadcast_test.cc", - "condition_variable_create_test.cc", - "condition_variable_destroy_test.cc", - "condition_variable_signal_test.cc", - "condition_variable_wait_test.cc", - "condition_variable_wait_timed_test.cc", "configuration_test.cc", "cpu_features_get_test.cc", - "directory_can_open_test.cc", - "directory_close_test.cc", - "directory_create_test.cc", - "directory_get_next_test.cc", - "directory_open_test.cc", "drm_get_metrics_test.cc", "drm_helpers.h", "drm_is_server_certificate_updatable_test.cc", @@ -74,29 +61,15 @@ target(gtest_target_type, "nplb") { "egl_test.cc", "extern_c_test.cc", "file_atomic_replace_test.cc", - "file_can_open_test.cc", - "file_close_test.cc", "file_delete_recursive_test.cc", - "file_delete_test.cc", - "file_get_info_test.cc", - "file_get_path_info_test.cc", "file_helpers.cc", - "file_mode_string_to_flags_test.cc", - "file_open_test.cc", - "file_read_test.cc", - "file_read_write_all_test.cc", - "file_seek_test.cc", - "file_truncate_test.cc", - "file_write_test.cc", "flat_map_test.cc", "gles_test.cc", - "image_test.cc", "include_all.c", "include_all_too.c", "key_test.cc", "log_flush_test.cc", "log_format_test.cc", - "log_is_tty_test.cc", "log_raw_dump_stack_test.cc", "log_raw_test.cc", "log_test.cc", @@ -111,12 +84,6 @@ target(gtest_target_type, "nplb") { "media_can_play_mime_and_key_system_test.cc", "media_configuration_test.cc", "media_set_audio_write_duration_test.cc", - "memory_allocate_aligned_test.cc", - "memory_allocate_test.cc", - "memory_deallocate_aligned_test.cc", - "memory_deallocate_test.cc", - "memory_map_test.cc", - "memory_reallocate_test.cc", "microphone_close_test.cc", "microphone_create_test.cc", "microphone_destroy_test.cc", @@ -126,11 +93,6 @@ target(gtest_target_type, "nplb") { "microphone_read_test.cc", "multiple_player_test.cc", "murmurhash2_test.cc", - "mutex_acquire_test.cc", - "mutex_acquire_try_test.cc", - "mutex_create_test.cc", - "mutex_destroy_test.cc", - "once_test.cc", "optional_test.cc", "player_create_test.cc", "player_creation_param_helpers.cc", @@ -246,14 +208,6 @@ target(gtest_target_type, "nplb") { "storage_get_record_size_test.cc", "storage_read_record_test.cc", "storage_write_record_test.cc", - "string_compare_no_case_n_test.cc", - "string_compare_no_case_test.cc", - "string_duplicate_test.cc", - - # TODO: b/307941391: test "SbStringFormatWideTest" is deprecated in SB16 - "string_format_test.cc", - "string_format_wide_test.cc", - "string_scan_test.cc", "system_clear_last_error_test.cc", "system_get_error_string_test.cc", "system_get_extension_test.cc", @@ -275,32 +229,15 @@ target(gtest_target_type, "nplb") { "system_network_status_test.cc", "system_sign_with_certification_secret_key_test.cc", "system_symbolize_test.cc", - "thread_create_test.cc", - "thread_detach_test.cc", - "thread_get_current_test.cc", "thread_get_id_test.cc", - "thread_get_name_test.cc", - "thread_helpers.cc", - "thread_is_equal_test.cc", - "thread_join_test.cc", - "thread_local_value_test.cc", "thread_priority_test.cc", "thread_sampler_test.cc", - "thread_set_name_test.cc", - "thread_sleep_test.cc", "thread_test.cc", - "thread_yield_test.cc", - "time_get_monotonic_now_test.cc", - "time_get_now_test.cc", - "time_narrow_test.cc", "time_zone_get_current_test.cc", "time_zone_get_name_test.cc", "ui_navigation_test.cc", "undefined_behavior_test.cc", "url_player_create_test.cc", - "user_get_current_test.cc", - "user_get_property_test.cc", - "user_get_signed_in_test.cc", "vertical_video_test.cc", "window_create_test.cc", "window_destroy_test.cc", diff --git a/starboard/nplb/accessibility_test.cc b/starboard/nplb/accessibility_test.cc deleted file mode 100644 index 4b02ceb98fb7..000000000000 --- a/starboard/nplb/accessibility_test.cc +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbAccessibilityTest, CanCallGetTextToSpeechSettings) { - SbAccessibilityTextToSpeechSettings settings = {0}; - EXPECT_TRUE(SbAccessibilityGetTextToSpeechSettings(&settings)); -} - -TEST(SbAccessibilityTest, CallTextToSpeechWithInvalidArgument) { - // |settings| should be zero-initialized. - SbAccessibilityTextToSpeechSettings settings = {1}; - EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetTextToSpeechSettings(NULL)); -} - -TEST(SbAccessibilityTest, CanCallGetDisplaySettings) { - SbAccessibilityDisplaySettings settings = {0}; - EXPECT_TRUE(SbAccessibilityGetDisplaySettings(&settings)); -} - -TEST(SbAccessibilityTest, CallDisplayWithInvalidArgument) { - // |settings| should be zero-initialized. - SbAccessibilityDisplaySettings settings = {1}; - EXPECT_FALSE(SbAccessibilityGetDisplaySettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetDisplaySettings(NULL)); -} - -TEST(SbAccessibilityTest, CallGetCaptionSettingsWithInvalidArgument) { - // |settings| should be zero-initialized. - const int kInvalidValue = 0xFE; - SbAccessibilityCaptionSettings settings; - memset(&settings, kInvalidValue, sizeof(settings)); - EXPECT_FALSE(SbAccessibilityGetCaptionSettings(&settings)); - - // Argument should not be NULL. - EXPECT_FALSE(SbAccessibilityGetCaptionSettings(NULL)); -} - -TEST(SbAccessibilityTest, GetCaptionSettingsReturnIsValid) { - // |settings| should be zero-initialized. - SbAccessibilityCaptionSettings settings; - const int kValidInitialValue = 0; - memset(&settings, kValidInitialValue, sizeof(settings)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings)); - - if (settings.background_color_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.background_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.background_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.background_opacity_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.background_opacity, - kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.background_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } - - if (settings.character_edge_style_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.character_edge_style, - kSbAccessibilityCaptionCharacterEdgeStyleNone); - EXPECT_LE(settings.character_edge_style, - kSbAccessibilityCaptionCharacterEdgeStyleDropShadow); - } - - if (settings.font_color_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.font_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.font_family_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_family, kSbAccessibilityCaptionFontFamilyCasual); - EXPECT_LE(settings.font_family, - kSbAccessibilityCaptionFontFamilySmallCapitals); - } - - if (settings.font_opacity_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_opacity, kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.font_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } - - if (settings.font_size_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.font_size, kSbAccessibilityCaptionFontSizePercentage25); - EXPECT_LE(settings.font_size, kSbAccessibilityCaptionFontSizePercentage300); - } - - if (settings.window_color_state != kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.window_color, kSbAccessibilityCaptionColorBlue); - EXPECT_LE(settings.window_color, kSbAccessibilityCaptionColorYellow); - } - - if (settings.window_opacity_state != - kSbAccessibilityCaptionStateUnsupported) { - EXPECT_GE(settings.window_opacity, - kSbAccessibilityCaptionOpacityPercentage0); - EXPECT_LE(settings.window_opacity, - kSbAccessibilityCaptionOpacityPercentage100); - } -} - -TEST(SbAccessibilityTest, CallSetCaptionsEnabled) { - SbAccessibilityCaptionSettings settings; - const int kValidInitialValue = 0; - memset(&settings, kValidInitialValue, sizeof(settings)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings)); - - if (settings.supports_is_enabled && settings.supports_set_enabled) { - // Try changing the enabled state. - EXPECT_TRUE(SbAccessibilitySetCaptionsEnabled(!settings.is_enabled)); - - SbAccessibilityCaptionSettings settings2; - memset(&settings2, kValidInitialValue, sizeof(settings2)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings2)); - EXPECT_NE(settings.is_enabled, settings2.is_enabled); - - // Reset the enabled state so the unit test doesn't propagate a new setting. - EXPECT_TRUE(SbAccessibilitySetCaptionsEnabled(settings.is_enabled)); - - SbAccessibilityCaptionSettings settings3; - memset(&settings3, kValidInitialValue, sizeof(settings3)); - EXPECT_TRUE(SbAccessibilityGetCaptionSettings(&settings3)); - EXPECT_EQ(settings.is_enabled, settings3.is_enabled); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/byte_swap_test.cc b/starboard/nplb/byte_swap_test.cc deleted file mode 100644 index 83fe64d68ee0..000000000000 --- a/starboard/nplb/byte_swap_test.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -#include - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const uint16_t kTestU16 = 0xABCD; -const uint16_t kExpectedU16 = 0xCDAB; -const int16_t kTestS16 = 0x0123; -const int16_t kExpectedS16 = 0x2301; -const uint32_t kTestU32 = 0xFEDCBA98; -const uint32_t kExpectedU32 = 0x98BADCFE; -const int32_t kTestS32 = 0x01234568; -const int32_t kExpectedS32 = 0x68452301; -const uint64_t kTestU64 = SB_UINT64_C(0xFEDCBA9876543210); -const uint64_t kExpectedU64 = SB_UINT64_C(0x1032547698BADCFE); -const int64_t kTestS64 = static_cast(SB_INT64_C(0xFEDCBA9876543210)); -const int64_t kExpectedS64 = - static_cast(SB_INT64_C(0x1032547698BADCFE)); - -TEST(SbByteSwapTest, SunnyDay) { - EXPECT_EQ(kExpectedU16, SbByteSwapU16(kTestU16)); - EXPECT_EQ(kExpectedS16, SbByteSwapS16(kTestS16)); - - EXPECT_EQ(kExpectedU32, SbByteSwapU32(kTestU32)); - EXPECT_EQ(kExpectedS32, SbByteSwapS32(kTestS32)); - - EXPECT_EQ(kExpectedU64, SbByteSwapU64(kTestU64)); - EXPECT_EQ(kExpectedS64, SbByteSwapS64(kTestS64)); -} - -#if SB_IS(BIG_ENDIAN) -TEST(SbByteSwapTest, BigEndian) { - EXPECT_EQ(kTestU16, SB_HOST_TO_NET_U16(kTestU16)); - EXPECT_EQ(kTestS16, SB_HOST_TO_NET_S16(kTestS16)); - - EXPECT_EQ(kTestU32, SB_HOST_TO_NET_U32(kTestU32)); - EXPECT_EQ(kTestS32, SB_HOST_TO_NET_S32(kTestS32)); - - EXPECT_EQ(kTestU64, SB_HOST_TO_NET_U64(kTestU64)); - EXPECT_EQ(kTestS64, SB_HOST_TO_NET_S64(kTestS64)); -} -#else -TEST(SbByteSwapTest, LittleEndian) { - EXPECT_EQ(kExpectedU16, SB_HOST_TO_NET_U16(kTestU16)); - EXPECT_EQ(kExpectedS16, SB_HOST_TO_NET_S16(kTestS16)); - - EXPECT_EQ(kExpectedU32, SB_HOST_TO_NET_U32(kTestU32)); - EXPECT_EQ(kExpectedS32, SB_HOST_TO_NET_S32(kTestS32)); - - EXPECT_EQ(kExpectedU64, SB_HOST_TO_NET_U64(kTestU64)); - EXPECT_EQ(kExpectedS64, SB_HOST_TO_NET_S64(kTestS64)); -} -#endif - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_broadcast_test.cc b/starboard/nplb/condition_variable_broadcast_test.cc deleted file mode 100644 index fe6bc6dd1bd6..000000000000 --- a/starboard/nplb/condition_variable_broadcast_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Broadcast is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableBroadcastTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableBroadcast(&condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableBroadcastTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableBroadcast(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_create_test.cc b/starboard/nplb/condition_variable_create_test.cc deleted file mode 100644 index d330f1c6c5cb..000000000000 --- a/starboard/nplb/condition_variable_create_test.cc +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/mutex.h" -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const int kALot = 128 * 1024; -const int kABunch = 2 * 1024; - -TEST(SbConditionVariableCreateTest, SunnyDay) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayALot) { - for (int i = 0; i < kALot; ++i) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); - } -} - -TEST(SbConditionVariableCreateTest, SunnyDayABunchAtOnce) { - SbMutex mutexes[kABunch]; - SbConditionVariable conditions[kABunch]; - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexCreate(&mutexes[i])); - EXPECT_TRUE(SbConditionVariableCreate(&conditions[i], &mutexes[i])); - } - - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbConditionVariableDestroy(&conditions[i])); - EXPECT_TRUE(SbMutexDestroy(&mutexes[i])); - } -} - -TEST(SbConditionVariableCreateTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableCreate(NULL, NULL)); - - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_FALSE(SbConditionVariableCreate(NULL, &mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbConditionVariableCreateTest, SunnyDayNullMutex) { - SbConditionVariable condition; - EXPECT_TRUE(SbConditionVariableCreate(&condition, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_destroy_test.cc b/starboard/nplb/condition_variable_destroy_test.cc deleted file mode 100644 index 0b830cafe1c6..000000000000 --- a/starboard/nplb/condition_variable_destroy_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Destroy is mostly Sunny Day tested in Create. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableDestroyTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableDestroyTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableDestroy(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_signal_test.cc b/starboard/nplb/condition_variable_signal_test.cc deleted file mode 100644 index 705aefcd567e..000000000000 --- a/starboard/nplb/condition_variable_signal_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Signal is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableSignalTest, SunnyDayAutoInit) { - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - EXPECT_TRUE(SbConditionVariableSignal(&condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); -} - -TEST(SbConditionVariableSignalTest, RainyDayNull) { - EXPECT_FALSE(SbConditionVariableSignal(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_test.cc b/starboard/nplb/condition_variable_wait_test.cc deleted file mode 100644 index ffb81c1f450a..000000000000 --- a/starboard/nplb/condition_variable_wait_test.cc +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbConditionVariableWaitTest, SunnyDayAutoInit) { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER}; - // Start the thread. - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, &context); - - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding. - context.do_signal.Put(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = - SbConditionVariableWait(&context.condition, &context.mutex); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context.condition)); - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); -} - -TEST(SbConditionVariableWaitTest, SunnyDay) { - const int kMany = kSbMaxThreads > 64 ? 64 : kSbMaxThreads; - WaiterContext context; - - std::vector threads(kMany); - for (int i = 0; i < kMany; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, WaiterEntryPoint, &context); - } - - for (int i = 0; i < kMany; ++i) { - context.WaitForReturnSignal(); - } - - // Signal the conditions to make the thread wake up and exit. - EXPECT_TRUE(SbConditionVariableBroadcast(&context.condition)); - - // Now we wait for the threads to exit. - for (int i = 0; i < kMany; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)) << "thread = " << threads[i]; - } -} - -TEST(SbConditionVariableWaitTest, RainyDayNull) { - SbConditionVariableResult result = SbConditionVariableWait(NULL, NULL); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbMutex mutex = SB_MUTEX_INITIALIZER; - result = SbConditionVariableWait(NULL, &mutex); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - result = SbConditionVariableWait(&condition, NULL); - EXPECT_EQ(kSbConditionVariableFailed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/condition_variable_wait_timed_test.cc b/starboard/nplb/condition_variable_wait_timed_test.cc deleted file mode 100644 index 1079c603231f..000000000000 --- a/starboard/nplb/condition_variable_wait_timed_test.cc +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/common/time.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// The SunnyDay, SunnyDayAutoInit, and SunnyDayNearMaxTime test cases directly -// (performs checks in the test case) or indirectly (invokes DoSunnyDay() which -// performs the checks) rely on timing constraints that are prone to failure, -// such as ensuring an action happens within 10 milliseconds. This requirement -// makes the tests flaky since none of these actions can be guaranteed to always -// run within the specified time. - -void DoSunnyDay(TakeThenSignalContext* context, bool check_timeout) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, context); - - const int64_t kDelay = 10'000; // 10ms - // Allow two-millisecond-level precision. - const int64_t kPrecision = 2'000; // 2ms - - // We know the thread hasn't signaled the condition variable yet, and won't - // unless we tell it, so it should wait at least the whole delay time. - if (check_timeout) { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context->mutex))); - int64_t start = CurrentMonotonicTime(); - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &context->condition, &context->mutex, kDelay); - EXPECT_EQ(kSbConditionVariableTimedOut, result); - int64_t elapsed = CurrentMonotonicTime() - start; - EXPECT_LE(kDelay, elapsed + kPrecision); - EXPECT_GT(kDelay * 2, elapsed - kPrecision); - EXPECT_TRUE(SbMutexRelease(&context->mutex)); - } - - { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context->mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding. - context->do_signal.Put(); - - int64_t start = CurrentMonotonicTime(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &context->condition, &context->mutex, kDelay); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - // We should have waited only a very small amount of time. - EXPECT_GT(kDelay, CurrentMonotonicTime() - start); - - EXPECT_TRUE(SbMutexRelease(&context->mutex)); - } - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context->condition)); - EXPECT_TRUE(SbMutexDestroy(&context->mutex)); -} - -// Test marked as flaky because it calls DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDay) { - TakeThenSignalContext context; - context.delay_after_signal = 0; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&context.condition, &context.mutex)); - DoSunnyDay(&context, true); -} - -// Test marked as flaky because it calls DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDayAutoInit) { - { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, 0}; - DoSunnyDay(&context, true); - } - - // Without the initial timeout test, the two threads will be racing to - // auto-init the mutex and condition variable. So we run several trials in - // this mode, hoping to have the auto-initting contend in various ways. - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, 0}; - DoSunnyDay(&context, false); - } -} - -// Test marked as flaky because it relies on timing sensitive execution similar -// to DoSunnyDay(). -TEST(SbConditionVariableWaitTimedTest, FLAKY_SunnyDayNearMaxTime) { - const int64_t kOtherDelay = 10'000; // 10ms - TakeThenSignalContext context = {TestSemaphore(0), SB_MUTEX_INITIALIZER, - SB_CONDITION_VARIABLE_INITIALIZER, - kOtherDelay}; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&context.condition, &context.mutex)); - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - TakeThenSignalEntryPoint, &context); - - // Try to wait until the end of time. - const int64_t kDelay = kSbInt64Max; - - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - - // Tell the thread to signal the condvar, which will cause it to attempt to - // acquire the mutex we are holding, after it waits for delay_after_signal. - context.do_signal.Put(); - - int64_t start = CurrentMonotonicTime(); - - // We release the mutex when we wait, allowing the thread to actually do the - // signaling, and ensuring we are waiting before it signals. - SbConditionVariableResult result = - SbConditionVariableWaitTimed(&context.condition, &context.mutex, kDelay); - EXPECT_EQ(kSbConditionVariableSignaled, result); - - // We should have waited at least the delay_after_signal amount, but not the - // full delay. - // Add some padding to tolerate slightly imprecise sleeps. - EXPECT_LT(context.delay_after_signal, - CurrentMonotonicTime() - start + (context.delay_after_signal / 10)); - EXPECT_GT(kDelay, CurrentMonotonicTime() - start); - - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - - // Now we wait for the thread to exit. - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_TRUE(SbConditionVariableDestroy(&context.condition)); - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); -} - -TEST(SbConditionVariableWaitTimedTest, RainyDayNull) { - SbConditionVariableResult result = - SbConditionVariableWaitTimed(NULL, NULL, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbMutex mutex = SB_MUTEX_INITIALIZER; - result = SbConditionVariableWaitTimed(NULL, &mutex, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); - - SbConditionVariable condition = SB_CONDITION_VARIABLE_INITIALIZER; - result = SbConditionVariableWaitTimed(&condition, NULL, 0); - EXPECT_EQ(kSbConditionVariableFailed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_can_open_test.cc b/starboard/nplb/directory_can_open_test.cc deleted file mode 100644 index d404c431062c..000000000000 --- a/starboard/nplb/directory_can_open_test.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbDirectoryCanOpenTest, SunnyDay) { - std::string path = starboard::nplb::GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_TRUE(SbFileExists(path.c_str())); - - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCanOpenTest, SunnyDayStaticContent) { - for (auto dir_path : GetFileTestsDirectoryPaths()) { - EXPECT_TRUE(SbDirectoryCanOpen(dir_path.c_str())) - << "Can't open: " << dir_path; - } -} - -TEST(SbDirectoryCanOpenTest, FailureMissingStaticContent) { - std::string directory_path = GetFileTestsDataDir(); - std::string missing_dir = directory_path + kSbFileSepChar + "missing_dir"; - EXPECT_FALSE(SbDirectoryCanOpen(missing_dir.c_str())); -} - -TEST(SbDirectoryCanOpenTest, FailureNull) { - EXPECT_FALSE(SbDirectoryCanOpen(NULL)); -} - -TEST(SbDirectoryCanOpenTest, FailureEmpty) { - EXPECT_FALSE(SbDirectoryCanOpen("")); -} - -TEST(SbDirectoryCanOpenTest, FailureRegularFile) { - starboard::nplb::ScopedRandomFile file; - - EXPECT_TRUE(SbFileExists(file.filename().c_str())); - EXPECT_FALSE(SbDirectoryCanOpen(file.filename().c_str())); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_close_test.cc b/starboard/nplb/directory_close_test.cc deleted file mode 100644 index af3d471eed29..000000000000 --- a/starboard/nplb/directory_close_test.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbDirectoryClose is well-covered in all the other tests, so just the -// leftovers are here. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbDirectoryCloseTest, FailureInvalid) { - EXPECT_FALSE(SbDirectoryClose(kSbDirectoryInvalid)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/directory_create_test.cc b/starboard/nplb/directory_create_test.cc deleted file mode 100644 index 39ac2cbc3adb..000000000000 --- a/starboard/nplb/directory_create_test.cc +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const std::string kManyFileSeparators = // NOLINT(runtime/string) - std::string(kSbFileSepString) + kSbFileSepString + kSbFileSepString + - kSbFileSepString; - -// NOTE: There is a test missing here, for creating a directory right off of the -// root. But, this is likely to fail due to permissions, so we can't make a -// reliable test for this. - -TEST(SbDirectoryCreateTest, SunnyDay) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - - const std::string& path = dir.filename(); - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); - - // Should return true if called redundantly. - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTrailingSeparators) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - - std::string path = dir.filename() + kManyFileSeparators.c_str(); - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_TRUE(SbDirectoryCreate(path.c_str())); - EXPECT_TRUE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTempDirectory) { - std::vector temp_path(kSbFileMaxPath); - bool system_path_success = SbSystemGetPath(kSbSystemPathTempDirectory, - temp_path.data(), kSbFileMaxPath); - ASSERT_TRUE(system_path_success); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); - EXPECT_TRUE(SbDirectoryCreate(temp_path.data())); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); -} - -TEST(SbDirectoryCreateTest, SunnyDayTempDirectoryManySeparators) { - std::vector temp_path(kSbFileMaxPath); - bool system_path_success = SbSystemGetPath( - kSbSystemPathTempDirectory, temp_path.data(), temp_path.size()); - ASSERT_TRUE(system_path_success); - const int new_size = starboard::strlcat( - temp_path.data(), kManyFileSeparators.c_str(), kSbFileMaxPath); - ASSERT_LT(new_size, kSbFileMaxPath); - - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); - EXPECT_TRUE(SbDirectoryCreate(temp_path.data())); - EXPECT_TRUE(SbDirectoryCanOpen(temp_path.data())); -} - -TEST(SbDirectoryCreateTest, FailureNullPath) { - EXPECT_FALSE(SbDirectoryCreate(NULL)); -} - -TEST(SbDirectoryCreateTest, FailureEmptyPath) { - EXPECT_FALSE(SbDirectoryCreate("")); -} - -TEST(SbDirectoryCreateTest, FailureNonexistentParent) { - ScopedRandomFile dir(ScopedRandomFile::kDontCreate); - std::string path = dir.filename() + kSbFileSepString + "test"; - - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); - EXPECT_FALSE(SbDirectoryCreate(path.c_str())); - EXPECT_FALSE(SbDirectoryCanOpen(path.c_str())); -} - -TEST(SbDirectoryCreateTest, FailureNotAbsolute) { - const char* kPath = "hallo"; - - EXPECT_FALSE(SbDirectoryCanOpen(kPath)); - EXPECT_FALSE(SbDirectoryCreate(kPath)); - EXPECT_FALSE(SbDirectoryCanOpen(kPath)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_get_next_test.cc b/starboard/nplb/directory_get_next_test.cc deleted file mode 100644 index f05b838dd458..000000000000 --- a/starboard/nplb/directory_get_next_test.cc +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include -#include -#include - -#include "starboard/configuration.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -typedef std::set StringSet; - -bool FileExists(const char* path) { - struct stat info; - return stat(path, &info) == 0; -} - -TEST(SbDirectoryGetNextTest, SunnyDay) { - const int kNumFiles = 65; - ScopedRandomFile files[kNumFiles]; - - std::string directory_name = files[0].filename(); - directory_name.resize(directory_name.find_last_of(kSbFileSepChar)); - EXPECT_TRUE(FileExists(directory_name.c_str())) - << "Missing directory: " << directory_name; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(directory_name.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - - // Make sure all the files we created are found exactly once. - StringSet names; - for (int i = 0; i < SB_ARRAY_SIZE_INT(files); ++i) { - names.insert(files[i].filename()); - } - - StringSet names_to_find(names); - while (true) { - std::vector entry(kSbFileMaxName, 0); - if (!SbDirectoryGetNext(directory, entry.data(), entry.size())) { - break; - } - const char* entry_name = entry.data(); - - // SbDirectoryEntry just contains the last component of the absolute path to - // the file, but ScopedRandomFile::filename() returns the full path. - std::string filename; - filename += directory_name; - filename += kSbFileSepChar; - filename += entry_name; - - StringSet::iterator iterator = names_to_find.find(filename); - if (iterator != names_to_find.end()) { - names_to_find.erase(iterator); - } else { - // If it isn't in |names_to_find|, make sure it's some external entry and - // not one of ours. Otherwise, an entry must have shown up twice. - EXPECT_TRUE(names.find(entry_name) == names.end()); - } - } - - // Make sure we found all of our names. - EXPECT_EQ(0, names_to_find.size()); - - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryGetNextTest, SunnyDayStaticContent) { - std::string testdata_dir = GetFileTestsDataDir(); - EXPECT_FALSE(testdata_dir.empty()); - EXPECT_TRUE(FileExists(testdata_dir.c_str())) - << "Missing directory: " << testdata_dir; - - // Make sure all the test directories and files are found exactly once. - StringSet paths_to_find; - for (auto path : GetFileTestsDirectoryPaths()) { - paths_to_find.insert(path); - } - for (auto path : GetFileTestsFilePaths()) { - paths_to_find.insert(path); - } - - // Breadth-first traversal of our test data. - std::queue directory_queue; - directory_queue.push(testdata_dir); - while (!directory_queue.empty()) { - std::string path = directory_queue.front(); - directory_queue.pop(); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)) << "Can't open: " << path; - EXPECT_EQ(kSbFileOk, error) << "Error opening: " << path; - - // Iterate all entries in this directory. - while (true) { - std::vector entry(kSbFileMaxName, 0); - if (!SbDirectoryGetNext(directory, entry.data(), entry.size())) { - break; - } - std::string entry_name = entry.data(); - - // Accept and ignore '.' and '..' directories. - if (entry_name == "." || entry_name == "..") { - continue; - } - - // Absolute path of the entry. - std::string entry_path = path + kSbFileSepChar + entry_name; - - StringSet::iterator iterator = paths_to_find.find(entry_path); - if (iterator != paths_to_find.end()) { - paths_to_find.erase(iterator); - } else { - ADD_FAILURE() << "Unexpected entry: " << entry_path; - } - - // Traverse into the subdirectory. - SbFileInfo file_info; - EXPECT_TRUE(SbFileGetPathInfo(entry_path.c_str(), &file_info)); - if (file_info.is_directory) { - directory_queue.push(entry_path); - } - } - - EXPECT_TRUE(SbDirectoryClose(directory)); - } - - // Make sure we found all of test data directories and files. - EXPECT_EQ(0, paths_to_find.size()); - for (auto it = paths_to_find.begin(); it != paths_to_find.end(); ++it) { - ADD_FAILURE() << "Missing entry: " << *it; - } -} - -TEST(SbDirectoryGetNextTest, FailureInvalidSbDirectory) { - std::vector entry(kSbFileMaxName, 0); - EXPECT_FALSE( - SbDirectoryGetNext(kSbDirectoryInvalid, entry.data(), entry.size())); -} - -TEST(SbDirectoryGetNextTest, FailureNullEntry) { - // Ensure there's at least one file in the directory. - ScopedRandomFile file; - - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_TRUE(FileExists(path.c_str())) << "Directory is " << path; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - EXPECT_FALSE(SbDirectoryGetNext(directory, NULL, kSbFileMaxName)); - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryGetNextTest, FailureInvalidAndNull) { - EXPECT_FALSE(SbDirectoryGetNext(kSbDirectoryInvalid, NULL, kSbFileMaxName)); -} - -TEST(SbDirectoryGetNextTest, FailureOnInsufficientSize) { - ScopedRandomFile file; - std::string directory_name = file.filename(); - directory_name.resize(directory_name.find_last_of(kSbFileSepChar)); - EXPECT_TRUE(FileExists(directory_name.c_str())) - << "Directory_name is " << directory_name; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(directory_name.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - - std::vector entry(kSbFileMaxName); - for (int i = 0; i < kSbFileMaxName; i++) - entry[i] = i; - std::vector entry_copy = entry; - EXPECT_EQ(SbDirectoryGetNext(directory, entry.data(), 0), false); - EXPECT_EQ(entry.size(), kSbFileMaxName); - for (int i = 0; i < kSbFileMaxName; i++) - EXPECT_EQ(entry[i], entry_copy[i]); - - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/directory_open_test.cc b/starboard/nplb/directory_open_test.cc deleted file mode 100644 index 06a39ddadc3b..000000000000 --- a/starboard/nplb/directory_open_test.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -#define EXPECT_FILE_EXISTS(path) \ - EXPECT_TRUE(SbFileExists(path.c_str())) << "Filename is " << path.c_str() - -TEST(SbDirectoryOpenTest, SunnyDay) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileOk, error); - EXPECT_TRUE(SbDirectoryClose(directory)); -} -#endif - -TEST(SbDirectoryOpenTest, SunnyDayStaticContent) { - for (auto dir_path : GetFileTestsDirectoryPaths()) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(dir_path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directory)) << dir_path; - EXPECT_EQ(kSbFileOk, error) << "Can't open: " << dir_path; - EXPECT_TRUE(SbDirectoryClose(directory)); - } -} - -#if SB_API_VERSION < 16 -TEST(SbDirectoryOpenTest, SunnyDayWithNullError) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - SbDirectory directory = SbDirectoryOpen(path.c_str(), NULL); - EXPECT_TRUE(SbDirectoryIsValid(directory)); - EXPECT_TRUE(SbDirectoryClose(directory)); -} - -TEST(SbDirectoryOpenTest, ManySunnyDay) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - const int kMany = kSbFileMaxOpen; - std::vector directories(kMany, 0); - - for (int i = 0; i < directories.size(); ++i) { - SbFileError error = kSbFileErrorMax; - directories[i] = SbDirectoryOpen(path.c_str(), &error); - EXPECT_TRUE(SbDirectoryIsValid(directories[i])); - EXPECT_EQ(kSbFileOk, error); - } - - for (int i = 0; i < directories.size(); ++i) { - EXPECT_TRUE(SbDirectoryClose(directories[i])); - } -} - -TEST(SbDirectoryOpenTest, FailsInvalidPath) { - std::string path = GetTempDir(); - EXPECT_FALSE(path.empty()); - EXPECT_FILE_EXISTS(path); - - // Funny way to make sure the directory seems valid but doesn't exist. - int len = static_cast(path.length()); - if (path[len - 1] != 'z') { - path[len - 1] = 'z'; - } else { - path[len - 1] = 'y'; - } - - ASSERT_FALSE(SbFileExists(path.c_str())); - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(path.c_str(), &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} -#endif - -TEST(SbDirectoryOpenTest, FailsNullPath) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(NULL, &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsNullPathWithNullError) { - SbDirectory directory = SbDirectoryOpen(NULL, NULL); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsEmptyPath) { - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen("", &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotFound, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -TEST(SbDirectoryOpenTest, FailsRegularFile) { - ScopedRandomFile file; - - SbFileError error = kSbFileErrorMax; - SbDirectory directory = SbDirectoryOpen(file.filename().c_str(), &error); - EXPECT_FALSE(SbDirectoryIsValid(directory)); - EXPECT_EQ(kSbFileErrorNotADirectory, error); - if (SbDirectoryIsValid(directory)) { - SbDirectoryClose(directory); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/extern_c_test.cc b/starboard/nplb/extern_c_test.cc index 1c42ce015eb0..09b5fc655e34 100644 --- a/starboard/nplb/extern_c_test.cc +++ b/starboard/nplb/extern_c_test.cc @@ -15,14 +15,8 @@ // Ensure that all starboard headers can be included inside extern "C". extern "C" { -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/atomic.h" #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/condition_variable.h" #include "starboard/configuration.h" #include "starboard/cpu_features.h" @@ -34,9 +28,6 @@ extern "C" { #include "starboard/export.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#endif // SB_API_VERSION < 16 #include "starboard/input.h" #include "starboard/key.h" #include "starboard/log.h" @@ -52,14 +43,7 @@ extern "C" { #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" } diff --git a/starboard/nplb/file_can_open_test.cc b/starboard/nplb/file_can_open_test.cc deleted file mode 100644 index 93572606c15e..000000000000 --- a/starboard/nplb/file_can_open_test.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileCanOpenTest, NonExistingFileFails) { - ScopedRandomFile random_file(ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - bool result = SbFileCanOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead); - EXPECT_FALSE(result); - - result = SbFileCanOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite); - EXPECT_FALSE(result); - - result = SbFileCanOpen(filename.c_str(), - kSbFileOpenAlways | kSbFileRead | kSbFileWrite); - EXPECT_FALSE(result); -} - -TEST(SbFileCanOpenTest, ExistingFileSucceeds) { - ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - - bool result = SbFileCanOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead); - EXPECT_TRUE(result); - - result = SbFileCanOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite); - EXPECT_TRUE(result); - - result = SbFileCanOpen(filename.c_str(), - kSbFileOpenAlways | kSbFileRead | kSbFileWrite); - EXPECT_TRUE(result); -} - -TEST(SbFileCanOpenTest, NonExistingStaticContentFileFails) { - std::string directory_path = GetFileTestsDataDir(); - std::string missing_file = directory_path + kSbFileSepChar + "missing_file"; - EXPECT_FALSE( - SbFileCanOpen(missing_file.c_str(), kSbFileOpenOnly | kSbFileRead)); -} - -TEST(SbFileCanOpenTest, ExistingStaticContentFileSucceeds) { - for (auto path : GetFileTestsFilePaths()) { - EXPECT_TRUE(SbFileCanOpen(path.c_str(), kSbFileOpenOnly | kSbFileRead)) - << "Can't open: " << path; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_close_test.cc b/starboard/nplb/file_close_test.cc deleted file mode 100644 index 2a40d4274b36..000000000000 --- a/starboard/nplb/file_close_test.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbFileClose is partially tested in file_open_test.cc. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileCloseTest, CloseInvalidFails) { - bool result = SbFileClose(kSbFileInvalid); - EXPECT_FALSE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_delete_test.cc b/starboard/nplb/file_delete_test.cc deleted file mode 100644 index 95052867700d..000000000000 --- a/starboard/nplb/file_delete_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include - -#include "starboard/directory.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -bool FileExists(const char* path) { - struct stat info; - return stat(path, &info) == 0; -} - -bool DirectoryExists(const char* path) { - struct stat info; - return stat(path, &info) == 0 && S_ISDIR(info.st_mode); -} - -TEST(SbFileDeleteTest, SunnyDayDeleteExistingFile) { - ScopedRandomFile file; - - EXPECT_TRUE(FileExists(file.filename().c_str())); - EXPECT_TRUE(SbFileDelete(file.filename().c_str())); -} - -TEST(SbFileDeleteTest, SunnyDayDeleteExistingDirectory) { - ScopedRandomFile file(ScopedRandomFile::kDontCreate); - - const std::string& path = file.filename(); - - EXPECT_FALSE(FileExists(path.c_str())); - EXPECT_TRUE(mkdir(path.c_str(), 0700) == 0 || DirectoryExists(path.c_str())); - EXPECT_TRUE(DirectoryExists(path.c_str())); - EXPECT_TRUE(SbFileDelete(path.c_str())); -} - -TEST(SbFileDeleteTest, RainyDayNonExistentFileErrors) { - ScopedRandomFile file(ScopedRandomFile::kDontCreate); - - EXPECT_FALSE(FileExists(file.filename().c_str())); - EXPECT_TRUE(SbFileDelete(file.filename().c_str())); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_flush_test.cc b/starboard/nplb/file_flush_test.cc deleted file mode 100644 index 7b8b3143ccbd..000000000000 --- a/starboard/nplb/file_flush_test.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// SbFileFlush is otherwise tested in SbFileWriteTest. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileFlushTest, InvalidFileErrors) { - bool result = SbFileFlush(kSbFileInvalid); - EXPECT_FALSE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_get_info_test.cc b/starboard/nplb/file_get_info_test.cc deleted file mode 100644 index 2bfc5da8120a..000000000000 --- a/starboard/nplb/file_get_info_test.cc +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// GetInfo is mostly tested in the course of other tests. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/common/time.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileGetInfoTest, InvalidFileErrors) { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(kSbFileInvalid, &info); - EXPECT_FALSE(result); -} - -TEST(SbFileGetInfoTest, WorksOnARegularFile) { - // This test is potentially flaky because it's comparing times. So, building - // in extra sensitivity to make flakiness more apparent. - const int kTrials = 100; - for (int i = 0; i < kTrials; ++i) { - // We can't assume filesystem timestamp precision, so go back a minute - // for a better chance to contain the imprecision and rounding errors. - const int64_t kOneMinuteInMicroseconds = 60'000'000; - int64_t time = - PosixTimeToWindowsTime(CurrentPosixTime()) - kOneMinuteInMicroseconds; - - const int kFileSize = 12; - starboard::nplb::ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_EQ(kFileSize, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(time, info.last_modified); - EXPECT_LE(time, info.last_accessed); - EXPECT_LE(time, info.creation_time); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - } -} - -TEST(SbFileGetInfoTest, WorksOnStaticContentFiles) { - for (auto filename : GetFileTestsFilePaths()) { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - size_t content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_EQ(content_length, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - - EXPECT_TRUE(SbFileClose(file)); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_get_path_info_test.cc b/starboard/nplb/file_get_path_info_test.cc deleted file mode 100644 index e775c4526ffa..000000000000 --- a/starboard/nplb/file_get_path_info_test.cc +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// GetInfo is mostly tested in the course of other tests. -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/time.h" -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "starboard/system.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileGetPathInfoTest, InvalidFileErrors) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(NULL, &info); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo("", &info); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo(".", NULL); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo(NULL, NULL); - EXPECT_FALSE(result); - - result = SbFileGetPathInfo("", NULL); - EXPECT_FALSE(result); -} - -TEST(SbFileGetPathInfoTest, WorksOnARegularFile) { - // This test is potentially flaky because it's comparing times. So, building - // in extra sensitivity to make flakiness more apparent. - const int kTrials = 100; - for (int i = 0; i < kTrials; ++i) { - // We can't assume filesystem timestamp precision, so go back a minute - // for a better chance to contain the imprecision and rounding errors. - const int64_t kOneMinuteInMicroseconds = 60'000'000; - int64_t time = - PosixTimeToWindowsTime(CurrentPosixTime()) - kOneMinuteInMicroseconds; - - const int kFileSize = 12; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(filename.c_str(), &info); - EXPECT_EQ(kFileSize, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(time, info.last_modified); - EXPECT_LE(time, info.last_accessed); - EXPECT_LE(time, info.creation_time); - } - } -} - -TEST(SbFileGetPathInfoTest, WorksOnADirectory) { - std::vector path(kSbFileMaxPath); - bool result = - SbSystemGetPath(kSbSystemPathTempDirectory, path.data(), kSbFileMaxPath); - EXPECT_TRUE(result); - - { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(path.data(), &info); - EXPECT_LE(0, info.size); - EXPECT_TRUE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - EXPECT_LE(0, info.last_modified); - EXPECT_LE(0, info.last_accessed); - EXPECT_LE(0, info.creation_time); - } -} - -TEST(SbFileGetPathInfoTest, WorksOnStaticContentFiles) { - for (auto filename : GetFileTestsFilePaths()) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(filename.c_str(), &info); - size_t content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_EQ(content_length, info.size); - EXPECT_FALSE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - } -} - -TEST(SbFileGetPathInfoTest, WorksOnStaticContentDirectories) { - for (auto path : GetFileTestsDirectoryPaths()) { - SbFileInfo info = {0}; - bool result = SbFileGetPathInfo(path.data(), &info); - EXPECT_LE(0, info.size); - EXPECT_TRUE(info.is_directory); - EXPECT_FALSE(info.is_symbolic_link); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/file_mode_string_to_flags_test.cc b/starboard/nplb/file_mode_string_to_flags_test.cc deleted file mode 100644 index 9efdf3a2163e..000000000000 --- a/starboard/nplb/file_mode_string_to_flags_test.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileModeStringToFlagsTest, Empties) { - EXPECT_EQ(0, SbFileModeStringToFlags(NULL)); - EXPECT_EQ(0, SbFileModeStringToFlags("")); -} - -TEST(SbFileModeStringToFlagsTest, Arr) { - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead, SbFileModeStringToFlags("r")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("r+")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("r+b")); - EXPECT_EQ(kSbFileOpenOnly | kSbFileRead | kSbFileWrite, - SbFileModeStringToFlags("rb+")); -} - -TEST(SbFileModeStringToFlagsTest, Wuh) { - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite, SbFileModeStringToFlags("w")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("w+")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("w+b")); - EXPECT_EQ(kSbFileCreateAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("wb+")); -} - -TEST(SbFileModeStringToFlagsTest, Aah) { - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite, SbFileModeStringToFlags("a")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("a+")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("a+b")); - EXPECT_EQ(kSbFileOpenAlways | kSbFileWrite | kSbFileRead, - SbFileModeStringToFlags("ab+")); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_open_test.cc b/starboard/nplb/file_open_test.cc deleted file mode 100644 index 4a99d746c886..000000000000 --- a/starboard/nplb/file_open_test.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include -#include - -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void BasicTest(bool existing, - int open_flags, - bool expected_created, - bool expected_success, - int original_line) { - ScopedRandomFile random_file(existing ? ScopedRandomFile::kCreate - : ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); -#define SB_FILE_OPEN_TEST_CONTEXT \ - "existing=" << existing << ", flags=0x" << std::hex << open_flags \ - << std::dec << ", expected_created=" << expected_created \ - << ", expected_success=" << expected_success \ - << ", filename=" << filename \ - << ", original_line=" << original_line - - if (!existing) { - struct stat info; - EXPECT_FALSE(stat(filename.c_str(), &info) == 0) - << SB_FILE_OPEN_TEST_CONTEXT; - if (stat(filename.c_str(), &info) == 0) { - return; - } - } - - bool created = !expected_created; - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(filename.c_str(), open_flags, &created, &error); - if (!expected_success) { - EXPECT_FALSE(SbFileIsValid(file)) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_EQ(expected_created, created) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_NE(kSbFileOk, error) << SB_FILE_OPEN_TEST_CONTEXT; - - // Try to clean up in case test fails. - if (SbFileIsValid(file)) { - SbFileClose(file); - } - } else { - EXPECT_TRUE(SbFileIsValid(file)); - EXPECT_EQ(expected_created, created) << SB_FILE_OPEN_TEST_CONTEXT; - EXPECT_EQ(kSbFileOk, error) << SB_FILE_OPEN_TEST_CONTEXT; - if (SbFileIsValid(file)) { - bool result = SbFileClose(file); - EXPECT_TRUE(result) << SB_FILE_OPEN_TEST_CONTEXT; - } - } -#undef SB_FILE_OPEN_TEST_CONTEXT -} - -TEST(SbFileOpenTest, OpenOnlyOpensExistingFile) { - BasicTest(true, kSbFileOpenOnly | kSbFileRead, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenOnlyDoesNotOpenNonExistingFile) { - BasicTest(false, kSbFileOpenOnly | kSbFileRead, false, false, __LINE__); -} - -TEST(SbFileOpenTest, CreateOnlyDoesNotCreateExistingFile) { - BasicTest(true, kSbFileCreateOnly | kSbFileWrite, false, false, __LINE__); -} - -TEST(SbFileOpenTest, CreateOnlyCreatesNonExistingFile) { - BasicTest(false, kSbFileCreateOnly | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenAlwaysOpensExistingFile) { - BasicTest(true, kSbFileOpenAlways | kSbFileWrite, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenAlwaysCreatesNonExistingFile) { - BasicTest(false, kSbFileOpenAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, CreateAlwaysTruncatesExistingFile) { - BasicTest(true, kSbFileCreateAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, CreateAlwaysCreatesNonExistingFile) { - BasicTest(false, kSbFileCreateAlways | kSbFileWrite, true, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenTruncatedTruncatesExistingFile) { - BasicTest(true, kSbFileOpenTruncated | kSbFileWrite, false, true, __LINE__); -} - -TEST(SbFileOpenTest, OpenTruncatedDoesNotCreateNonExistingFile) { - BasicTest(false, kSbFileOpenTruncated | kSbFileWrite, false, false, __LINE__); -} - -TEST(SbFileOpenTest, WorksWithNullOutParams) { - ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - - // What error? - { - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, - NULL, &error); - ASSERT_TRUE(SbFileIsValid(file)); - EXPECT_EQ(kSbFileOk, error) << "Failed to set error code for " << filename; - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } - - // Created what? - { - bool created = true; - SbFile file = SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, - &created, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - EXPECT_FALSE(created) << "Failed to set created to false for " << filename; - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } - - // What what? - { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - bool result = SbFileClose(file); - EXPECT_TRUE(result) << "SbFileClose failed for " << filename; - } -} - -TEST(SbFileOpenTest, OpenOnlyDoesNotOpenNonExistingStaticContentFile) { - std::string path = GetFileTestsDataDir(); - std::string missing_file = path + kSbFileSepChar + "missing_file"; - bool created = true; - SbFileError error = kSbFileErrorMax; - SbFile file = SbFileOpen(missing_file.c_str(), kSbFileOpenOnly | kSbFileRead, - &created, &error); - EXPECT_FALSE(SbFileIsValid(file)); - EXPECT_FALSE(created); - EXPECT_NE(kSbFileOk, error); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_read_test.cc b/starboard/nplb/file_read_test.cc deleted file mode 100644 index 7d4d4a0a0d4e..000000000000 --- a/starboard/nplb/file_read_test.cc +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Sets up an empty test fixture, required for typed tests. -template -class SbFileReadTest : public testing::Test {}; - -class SbFileReader { - public: - static int Read(SbFile file, char* data, int size) { - return SbFileRead(file, data, size); - } -}; - -class SbFileReaderAll { - public: - static int Read(SbFile file, char* data, int size) { - return SbFileReadAll(file, data, size); - } -}; - -typedef testing::Types SbFileReadTestTypes; - -TYPED_TEST_CASE(SbFileReadTest, SbFileReadTestTypes); - -const int kBufferLength = 16 * 1024; - -TYPED_TEST(SbFileReadTest, InvalidFileErrors) { - char buffer[kBufferLength]; - int result = TypeParam::Read(kSbFileInvalid, buffer, kBufferLength); - EXPECT_EQ(-1, result); -} - -TYPED_TEST(SbFileReadTest, BasicReading) { - // Create a pattern file that is not an even multiple of the buffer size, - // but is over several times the size of the buffer. - const int kFileSize = kBufferLength * 16 / 3; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read and check the whole file. - int total = 0; - int previous_total = 0; - int max = 0; - while (true) { - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - EXPECT_LT(0, bytes_read); - - // Do some accounting to check later. - previous_total = total; - total += bytes_read; - if (bytes_read > max) { - max = bytes_read; - } - - ScopedRandomFile::ExpectPattern(previous_total, buffer, bytes_read, - __LINE__); - } - - // Check that we read the whole file. - EXPECT_EQ(kFileSize, total); - - // check that we didn't write over any other parts of the buffer. - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + max; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadPastEnd) { - const int kFileSize = kBufferLength; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read off the end of the file. - int position = static_cast(SbFileSeek(file, kSbFileFromEnd, 0)); - EXPECT_EQ(kFileSize, position); - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - EXPECT_EQ(0, bytes_read); - - for (int i = 0; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadZeroBytes) { - const int kFileSize = kBufferLength; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read zero bytes. - for (int i = 0; i < 10; ++i) { - int bytes_read = TypeParam::Read(file, buffer, 0); - EXPECT_EQ(0, bytes_read); - } - - for (int i = 0; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadFromMiddle) { - const int kFileSize = kBufferLength * 2; - ScopedRandomFile random_file(kFileSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read from the middle of the file. - int position = - static_cast(SbFileSeek(file, kSbFileFromBegin, kFileSize / 4)); - EXPECT_EQ(kFileSize / 4, position); - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - EXPECT_GE(kBufferLength, bytes_read); - EXPECT_LT(0, bytes_read); - - ScopedRandomFile::ExpectPattern(position, buffer, bytes_read, __LINE__); - - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + bytes_read; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileReadTest, ReadStaticContent) { - for (auto filename : GetFileTestsFilePaths()) { - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)) << "Can't open: " << filename; - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - const int kRealBufferLength = kBufferLength * 2; - char real_buffer[kRealBufferLength] = {0}; - const int kBufferOffset = kBufferLength / 2; - char* buffer = real_buffer + kBufferOffset; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kRealBufferLength; ++i) { - real_buffer[i] = '\xCD'; - } - - // Read and check the whole file. - std::string content; - int total = 0; - int max = 0; - while (true) { - int bytes_read = TypeParam::Read(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - EXPECT_LT(0, bytes_read); - - // Do some accounting to check later. - total += bytes_read; - if (bytes_read > max) { - max = bytes_read; - } - - // Accumulate the content of the whole file. - content.append(buffer, bytes_read); - } - - // Check that we didn't write over any other parts of the buffer. - for (int i = 0; i < kBufferOffset; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - for (int i = kBufferOffset + max; i < kRealBufferLength; ++i) { - EXPECT_EQ('\xCD', real_buffer[i]); - } - - EXPECT_EQ(GetTestFileExpectedContent(filename), content); - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_read_write_all_test.cc b/starboard/nplb/file_read_write_all_test.cc deleted file mode 100644 index 6dc621363818..000000000000 --- a/starboard/nplb/file_read_write_all_test.cc +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -class SbReadWriteAllTestWithBuffer : public ::testing::TestWithParam { - public: - int GetBufferSize() { return GetParam(); } -}; - -TEST_P(SbReadWriteAllTestWithBuffer, ReadFile) { - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = SbFileOpen(filename.c_str(), kSbFileCreateAlways | kSbFileWrite, - NULL, NULL); - - std::vector file_contents; - file_contents.reserve(GetBufferSize()); - for (int i = 0; i < GetBufferSize(); ++i) { - file_contents.push_back(i % 255); - } - int bytes_written = - SbFileWriteAll(file, file_contents.data(), file_contents.size()); - EXPECT_EQ(GetBufferSize(), bytes_written); - - SbFileClose(file); - - file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - std::vector read_contents(GetBufferSize()); - int bytes_read = - SbFileReadAll(file, read_contents.data(), read_contents.size()); - EXPECT_EQ(GetBufferSize(), bytes_read); - EXPECT_EQ(file_contents, read_contents); - - SbFileClose(file); -} - -INSTANTIATE_TEST_CASE_P( - SbReadAllTestSbReadWriteAllTest, - SbReadWriteAllTestWithBuffer, - ::testing::Values(0, 1, 1024, 16 * 1024, 128 * 1024, 1024 * 1024), - ::testing::PrintToStringParamName()); - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_seek_test.cc b/starboard/nplb/file_seek_test.cc deleted file mode 100644 index 35789796c1e0..000000000000 --- a/starboard/nplb/file_seek_test.cc +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileSeekTest, InvalidFileErrors) { - int result = - static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromBegin, 50)); - EXPECT_EQ(-1, result); - - result = static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromEnd, -50)); - EXPECT_EQ(-1, result); - - result = - static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromCurrent, -50)); - EXPECT_EQ(-1, result); - - result = static_cast(SbFileSeek(kSbFileInvalid, kSbFileFromCurrent, 50)); - EXPECT_EQ(-1, result); -} - -TEST(SbFileSeekTest, FromEndWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromEnd, 0); - EXPECT_EQ(info.size, position); - - int64_t target = -(random_file.size() / 6); - position = SbFileSeek(file, kSbFileFromEnd, target); - EXPECT_EQ(info.size + target, position); - - position = SbFileSeek(file, kSbFileFromEnd, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromCurrentWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(0, position); - - int64_t target = random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, info.size - position); - EXPECT_EQ(info.size, position); - - position = SbFileSeek(file, kSbFileFromCurrent, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromBeginWorks) { - starboard::nplb::ScopedRandomFile random_file; - const std::string& filename = random_file.filename(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromBegin, 0); - EXPECT_EQ(0, position); - - int64_t target = random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = random_file.size() / 3; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = info.size - random_file.size() / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromBegin, info.size); - EXPECT_EQ(info.size, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -std::string GetTestStaticContentFile() { - std::string filename = GetFileTestsFilePaths().front(); - int content_length = GetTestFileExpectedContent(filename).length(); - EXPECT_GT(content_length, 40); - return filename; -} - -TEST(SbFileSeekTest, FromEndInStaticContentWorks) { - std::string filename = GetTestStaticContentFile(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromEnd, 0); - EXPECT_EQ(info.size, position); - - int64_t target = -(content_length / 6); - position = SbFileSeek(file, kSbFileFromEnd, target); - EXPECT_EQ(info.size + target, position); - - position = SbFileSeek(file, kSbFileFromEnd, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromCurrentInStaticContentWorks) { - std::string filename = GetTestStaticContentFile(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(0, position); - - int64_t target = content_length / 6; - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromCurrent, target); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, 0); - EXPECT_EQ(target * 2, position); - - position = SbFileSeek(file, kSbFileFromCurrent, info.size - position); - EXPECT_EQ(info.size, position); - - position = SbFileSeek(file, kSbFileFromCurrent, -info.size); - EXPECT_EQ(0, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileSeekTest, FromBeginInStaticContentWorks) { - std::string filename = GetFileTestsFilePaths().front(); - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - int content_length = GetTestFileExpectedContent(filename).length(); - - SbFileInfo info; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - - int64_t position = SbFileSeek(file, kSbFileFromBegin, 0); - EXPECT_EQ(0, position); - - int64_t target = content_length / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = content_length / 3; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - target = info.size - content_length / 6; - position = SbFileSeek(file, kSbFileFromBegin, target); - EXPECT_EQ(target, position); - - position = SbFileSeek(file, kSbFileFromBegin, info.size); - EXPECT_EQ(info.size, position); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_truncate_test.cc b/starboard/nplb/file_truncate_test.cc deleted file mode 100644 index 6a316d2d7694..000000000000 --- a/starboard/nplb/file_truncate_test.cc +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbFileTruncateTest, InvalidFileErrors) { - bool result = SbFileTruncate(kSbFileInvalid, 0); - EXPECT_FALSE(result); - - result = SbFileTruncate(kSbFileInvalid, -1); - EXPECT_FALSE(result); - - result = SbFileTruncate(kSbFileInvalid, 100); - EXPECT_FALSE(result); -} - -TEST(SbFileTruncateTest, TruncateToZero) { - const int kStartSize = 123; - const int kEndSize = 0; - ScopedRandomFile random_file(kStartSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileWrite | kSbFileRead, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_EQ(kStartSize, info.size); - } - - bool result = SbFileTruncate(file, kEndSize); - EXPECT_TRUE(result); - - { - SbFileInfo info = {0}; - result = SbFileGetInfo(file, &info); - EXPECT_EQ(kEndSize, info.size); - } - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TEST(SbFileTruncateTest, TruncateUpInSize) { - // "Truncate," I don't think that word means what you think it means. - const int kStartSize = 123; - const int kEndSize = kStartSize * 2; - ScopedRandomFile random_file(kStartSize); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileWrite | kSbFileRead, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - { - SbFileInfo info = {0}; - bool result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(kStartSize, info.size); - } - - int position = static_cast(SbFileSeek(file, kSbFileFromCurrent, 0)); - EXPECT_EQ(0, position); - - bool result = SbFileTruncate(file, kEndSize); - EXPECT_TRUE(result); - - position = static_cast(SbFileSeek(file, kSbFileFromCurrent, 0)); - EXPECT_EQ(0, position); - - { - SbFileInfo info = {0}; - result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(kEndSize, info.size); - } - - char buffer[kEndSize] = {0}; - int bytes = SbFileReadAll(file, buffer, kEndSize); - EXPECT_EQ(kEndSize, bytes); - - ScopedRandomFile::ExpectPattern(0, buffer, kStartSize, __LINE__); - - for (int i = kStartSize; i < kEndSize; ++i) { - EXPECT_EQ(0, buffer[i]); - } - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/file_write_test.cc b/starboard/nplb/file_write_test.cc deleted file mode 100644 index 6493a783bc30..000000000000 --- a/starboard/nplb/file_write_test.cc +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Writing is partially tested by some of the file helpers that create files for -// the tests to operate on. - -#if SB_API_VERSION < 17 - -#include - -#include "starboard/file.h" -#include "starboard/nplb/file_helpers.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Sets up an empty test fixture, required for typed tests. -template -class SbFileWriteTest : public testing::Test {}; - -class SbFileWriter { - public: - static int Write(SbFile file, char* data, int size) { - return SbFileWrite(file, data, size); - } -}; - -class SbFileWriterAll { - public: - static int Write(SbFile file, char* data, int size) { - return SbFileWriteAll(file, data, size); - } -}; - -typedef testing::Types SbFileWriteTestTypes; - -TYPED_TEST_CASE(SbFileWriteTest, SbFileWriteTestTypes); - -const int kBufferLength = 16 * 1024; - -TYPED_TEST(SbFileWriteTest, InvalidFileErrors) { - char buffer[kBufferLength] = {0}; - int result = TypeParam::Write(kSbFileInvalid, buffer, kBufferLength); - EXPECT_EQ(-1, result); -} - -TYPED_TEST(SbFileWriteTest, BasicWriting) { - // Choose a file size that is not an even multiple of the buffer size, but - // is over several times the size of the buffer. - const int kFileSize = kBufferLength * 16 / 3; - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = - SbFileOpen(filename.c_str(), - kSbFileCreateAlways | kSbFileWrite | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - // Create a bigger buffer than necessary, so we can test the memory around - // the portion given to SbFileRead. - char buffer[kBufferLength] = {0}; - - // Initialize to some arbitrary pattern so we can verify it later. - for (int i = 0; i < kBufferLength; ++i) { - buffer[i] = static_cast(i & 0xFF); - } - - // Read and check the whole file. - int total = 0; - while (true) { - if (total == kFileSize) { - break; - } - - int remaining = kFileSize - total; - int to_write = remaining < kBufferLength ? remaining : kBufferLength; - int bytes_written = - TypeParam::Write(file, buffer + (total % kBufferLength), to_write); - - // Check that we didn't write more than the buffer size. - EXPECT_GE(to_write, bytes_written); - - // Check that we didn't get an error. - ASSERT_LT(0, bytes_written); - - total += bytes_written; - EXPECT_EQ(total, SbFileSeek(file, kSbFileFromCurrent, 0)); - } - - // Tests reading and writing from same opened file. - bool result = SbFileFlush(file); - ASSERT_TRUE(result); - int position = static_cast(SbFileSeek(file, kSbFileFromBegin, 0)); - ASSERT_EQ(0, position); - - // Read and check the whole file. - total = 0; - int previous_total = 0; - while (true) { - int bytes_read = SbFileReadAll(file, buffer, kBufferLength); - if (bytes_read == 0) { - break; - } - - // Check that we didn't read more than the buffer size. - EXPECT_GE(kBufferLength, bytes_read); - - // Check that we didn't get an error. - ASSERT_LT(0, bytes_read); - - // Do some accounting to check later. - previous_total = total; - total += bytes_read; - - ScopedRandomFile::ExpectPattern(previous_total, buffer, bytes_read, - __LINE__); - } - - // Check that we read the whole file. - EXPECT_EQ(kFileSize, total); - - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -TYPED_TEST(SbFileWriteTest, WriteZeroBytes) { - ScopedRandomFile random_file(0, ScopedRandomFile::kDontCreate); - const std::string& filename = random_file.filename(); - - SbFile file = SbFileOpen(filename.c_str(), kSbFileCreateOnly | kSbFileWrite, - NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - - char buffer[kBufferLength] = {0}; - - // Write zero bytes. - for (int i = 0; i < 10; ++i) { - int bytes_written = TypeParam::Write(file, buffer, 0); - EXPECT_EQ(0, bytes_written); - } - - bool result = SbFileClose(file); - EXPECT_TRUE(result); - - file = - SbFileOpen(filename.c_str(), kSbFileOpenOnly | kSbFileRead, NULL, NULL); - ASSERT_TRUE(SbFileIsValid(file)); - SbFileInfo info; - result = SbFileGetInfo(file, &info); - EXPECT_TRUE(result); - EXPECT_EQ(0, info.size); - result = SbFileClose(file); - EXPECT_TRUE(result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 17 diff --git a/starboard/nplb/image_test.cc b/starboard/nplb/image_test.cc deleted file mode 100644 index f3b12a081826..000000000000 --- a/starboard/nplb/image_test.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const SbDecodeTargetFormat kDecodeTargetFormats[] = { - kSbDecodeTargetFormat1PlaneRGBA, - kSbDecodeTargetFormat1PlaneBGRA, - kSbDecodeTargetFormat2PlaneYUVNV12, - kSbDecodeTargetFormat3PlaneYUVI420, - kSbDecodeTargetFormat3Plane10BitYUVI420, - kSbDecodeTargetFormat1PlaneUYVY, - kSbDecodeTargetFormatInvalid, -}; - -const char* kMimeTypes[] = { - "image/jpeg", "image/png", "image/gif", - "application/json", "image/webp", "invalid", -}; - -// Verify SbImageIsDecodeSupported() can be called with any parameter values. -TEST(ImageTest, IsDecodeSupported) { - for (size_t format = 0; - format < sizeof(kDecodeTargetFormats) / sizeof(kDecodeTargetFormats[0]); - ++format) { - for (size_t mime_type = 0; - mime_type < sizeof(kMimeTypes) / sizeof(kMimeTypes[0]); ++mime_type) { - SbImageIsDecodeSupported(kMimeTypes[mime_type], - kDecodeTargetFormats[format]); - } - } -} - -} // namespace. -} // namespace nplb. -} // namespace starboard. - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/include_all.c b/starboard/nplb/include_all.c index 241c1f385139..1f2c7879367b 100644 --- a/starboard/nplb/include_all.c +++ b/starboard/nplb/include_all.c @@ -14,14 +14,8 @@ // Includes all headers in a C context to make sure they compile as C files. -#if SB_API_VERSION < 16 -#include "starboard/accessibility.h" -#endif // SB_API_VERSION < 16 #include "starboard/atomic.h" #include "starboard/audio_sink.h" -#if SB_API_VERSION < 16 -#include "starboard/byte_swap.h" -#endif // SB_API_VERSION < 16 #include "starboard/condition_variable.h" #include "starboard/configuration.h" #include "starboard/cpu_features.h" @@ -33,9 +27,6 @@ #include "starboard/export.h" #include "starboard/file.h" #include "starboard/gles.h" -#if SB_API_VERSION < 16 -#include "starboard/image.h" -#endif // SB_API_VERSION < 16 #include "starboard/input.h" #include "starboard/key.h" #include "starboard/log.h" @@ -51,15 +42,8 @@ #include "starboard/string.h" #include "starboard/system.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -#include "starboard/time.h" -#endif // SB_API_VERSION < 16 #include "starboard/time_zone.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #include "starboard/window.h" // This doesn't really belong here, but ensures that SB_COMPILE_ASSERT works in diff --git a/starboard/nplb/log_is_tty_test.cc b/starboard/nplb/log_is_tty_test.cc deleted file mode 100644 index b9bf61546cba..000000000000 --- a/starboard/nplb/log_is_tty_test.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbLogIsTtyTest, DontCrashMeBro) { - // Since the tests could be run on a TTY or not, there's no way to decide what - // this function should return. - SbLogIsTty(); - SB_DLOG(INFO) << "Is TTY: " << SbLogIsTty(); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/media_buffer_test.cc b/starboard/nplb/media_buffer_test.cc index d3ee92efa36f..875042817fb9 100644 --- a/starboard/nplb/media_buffer_test.cc +++ b/starboard/nplb/media_buffer_test.cc @@ -116,11 +116,7 @@ std::vector TryToAllocateMemory(int size, ? allocation_unit : (std::rand() % 500 + 100) * 1024; void* allocated_memory = NULL; -#if SB_API_VERSION < 16 - allocated_memory = SbMemoryAllocateAligned(alignment, allocation_increment); -#else posix_memalign(&allocated_memory, alignment, allocation_increment); -#endif EXPECT_NE(allocated_memory, nullptr); if (!allocated_memory) { return allocated_ptrs; @@ -201,32 +197,6 @@ TEST(SbMediaBufferTest, AllocationUnit) { allocated_ptrs = TryToAllocateMemory(initial_buffer_capacity, allocation_unit, sizeof(void*)); } -#if SB_API_VERSION < 16 - if (!HasNonfatalFailure()) { - for (SbMediaType type : kMediaTypes) { - // The test will be run more than once, it's redundant but allows us to - // keep the test logic in one place. - int alignment = SbMediaGetBufferAlignment(); - SB_LOG(INFO) << "alignment=" << alignment; - EXPECT_EQ(alignment & (alignment - 1), 0) - << "Alignment must always be a power of 2"; - if (HasNonfatalFailure()) { - break; - } - int media_budget = type == SbMediaType::kSbMediaTypeAudio - ? kMinAudioBudget - : kMinVideoBudget1080p; - std::vector media_buffer_allocated_memory = - TryToAllocateMemory(media_budget, allocation_unit, alignment); - allocated_ptrs.insert(allocated_ptrs.end(), - media_buffer_allocated_memory.begin(), - media_buffer_allocated_memory.end()); - if (HasNonfatalFailure()) { - break; - } - } - } -#endif // SB_API_VERSION < 16 for (void* ptr : allocated_ptrs) { free(ptr); @@ -305,28 +275,10 @@ TEST(SbMediaBufferTest, ProgressiveBudget) { } } -#if SB_API_VERSION < 16 -TEST(SbMediaBufferTest, StorageType) { - // Just don't crash. - SbMediaBufferStorageType type = SbMediaGetBufferStorageType(); - switch (type) { - case kSbMediaBufferStorageTypeMemory: - case kSbMediaBufferStorageTypeFile: - return; - } - SB_NOTREACHED(); -} -#endif // SB_API_VERSION < 16 - TEST(SbMediaBufferTest, UsingMemoryPool) { -#if SB_API_VERSION < 16 - // Just don't crash. - SbMediaIsBufferUsingMemoryPool(); -#else EXPECT_TRUE(SbMediaIsBufferUsingMemoryPool()) << "This function is deprecated. Media buffer pools are always " << "used in Starboard 16 and newer. Please see starboard/CHANGELOG.md"; -#endif // SB_API_VERSION < 16 } TEST(SbMediaBufferTest, VideoBudget) { @@ -350,18 +302,8 @@ TEST(SbMediaBufferTest, ValidatePerformance) { SbMediaGetBufferGarbageCollectionDurationThreshold); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetInitialBufferCapacity); TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferPoolAllocateOnDemand); -#if SB_API_VERSION < 16 - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferStorageType); -#endif // SB_API_VERSION < 16 TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaIsBufferUsingMemoryPool); -#if SB_API_VERSION < 16 - for (auto type : kMediaTypes) { - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferAlignment); - TEST_PERF_FUNCNOARGS_DEFAULT(SbMediaGetBufferPadding); - } -#endif // SB_API_VERSION < 16 - for (auto resolution : kVideoResolutions) { for (auto bits_per_pixel : kBitsPerPixelValues) { for (auto codec : kVideoCodecs) { diff --git a/starboard/nplb/memory_allocate_aligned_test.cc b/starboard/nplb/memory_allocate_aligned_test.cc deleted file mode 100644 index 1ff841a95935..000000000000 --- a/starboard/nplb/memory_allocate_aligned_test.cc +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/memory.h" -#include "starboard/configuration.h" - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Choose a size that isn't naturally aligned to anything. -const size_t kSize = 1024 * 128 + 1; - -TEST(SbMemoryAllocateAlignedTest, AllocatesAligned) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, kSize); - ASSERT_NE(static_cast(NULL), memory); - EXPECT_TRUE(starboard::common::MemoryIsAligned(memory, align)); - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryAllocateAlignedTest, AllocatesAlignedZero) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, 0); - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return - // NULL. - if (memory) { - EXPECT_TRUE(starboard::common::MemoryIsAligned(memory, align)); - } - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryAllocateAlignedTest, CanReadWriteToResult) { - const size_t kAlign = 4096; - void* memory = SbMemoryAllocateAligned(kAlign, kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocateAligned(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_allocate_test.cc b/starboard/nplb/memory_allocate_test.cc deleted file mode 100644 index ca5aafc2d1fb..000000000000 --- a/starboard/nplb/memory_allocate_test.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryAllocateTest, AllocatesNormally) { - void* memory = SbMemoryAllocate(kSize); - EXPECT_NE(static_cast(NULL), memory); - - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, AllocatesZero) { - void* memory = SbMemoryAllocate(0); - - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return NULL. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, AllocatesOne) { - void* memory = SbMemoryAllocate(1); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryAllocateTest, CanReadWriteToResult) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_deallocate_aligned_test.cc b/starboard/nplb/memory_deallocate_aligned_test.cc deleted file mode 100644 index e6f746ac91b7..000000000000 --- a/starboard/nplb/memory_deallocate_aligned_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryDeallocateAlignedTest, DeallocatesAligned) { - const size_t kMaxAlign = 4096 + 1; - for (size_t align = 2; align < kMaxAlign; align <<= 1) { - void* memory = SbMemoryAllocateAligned(align, kSize); - SbMemoryDeallocateAligned(memory); - } -} - -TEST(SbMemoryDeallocateAlignedTest, FreesNull) { - SbMemoryDeallocateAligned(NULL); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_deallocate_test.cc b/starboard/nplb/memory_deallocate_test.cc deleted file mode 100644 index aaac6da8e72e..000000000000 --- a/starboard/nplb/memory_deallocate_test.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryDeallocateTest, FreesNormally) { - void* memory = SbMemoryAllocate(kSize); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryDeallocateTest, FreesNull) { - SbMemoryDeallocate(NULL); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_map_test.cc b/starboard/nplb/memory_map_test.cc deleted file mode 100644 index 134acc870095..000000000000 --- a/starboard/nplb/memory_map_test.cc +++ /dev/null @@ -1,300 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/common/memory.h" -#include "starboard/configuration_constants.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = kSbMemoryPageSize * 8; -const void* kFailed = SB_MEMORY_MAP_FAILED; - -TEST(SbMemoryMapTest, AllocatesNormally) { - void* memory = SbMemoryMap(kSize, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); -} - -TEST(SbMemoryMapTest, AllocatesZero) { - void* memory = SbMemoryMap(0, kSbMemoryMapProtectRead, "test"); - ASSERT_EQ(kFailed, memory); - EXPECT_FALSE(SbMemoryUnmap(memory, 0)); -} - -TEST(SbMemoryMapTest, AllocatesOne) { - void* memory = SbMemoryMap(1, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, 1)); -} - -TEST(SbMemoryMapTest, AllocatesOnePage) { - void* memory = - SbMemoryMap(kSbMemoryPageSize, kSbMemoryMapProtectRead, "test"); - ASSERT_NE(kFailed, memory); - EXPECT_TRUE(SbMemoryUnmap(memory, kSbMemoryPageSize)); -} - -// Disabled because it is too slow -- currently ~5 seconds on a Linux desktop -// with lots of memory. -TEST(SbMemoryMapTest, DISABLED_DoesNotLeak) { - const int64_t kIterations = 16; - const double kFactor = 1.25; - const size_t kSparseCommittedPages = 256; - - const int64_t kBytesMappedPerIteration = - static_cast(SbSystemGetTotalCPUMemory() * kFactor) / kIterations; - const int64_t kMaxBytesMapped = kBytesMappedPerIteration * kIterations; - - for (int64_t total_bytes_mapped = 0; total_bytes_mapped < kMaxBytesMapped; - total_bytes_mapped += kBytesMappedPerIteration) { - void* memory = - SbMemoryMap(kBytesMappedPerIteration, kSbMemoryMapProtectWrite, "test"); - ASSERT_NE(kFailed, memory); - - // If this is the last iteration of the loop, then force a page commit for - // every single page. For any other iteration, force a page commit for - // |kSparseCommittedPages|. - bool last_iteration = - !(total_bytes_mapped + kBytesMappedPerIteration < kMaxBytesMapped); - uint8_t* first_page = static_cast(memory); - const size_t page_increment_factor = - (last_iteration) - ? size_t(1u) - : std::max(static_cast( - kBytesMappedPerIteration / - (kSparseCommittedPages * kSbMemoryPageSize)), - size_t(1u)); - - for (uint8_t* page = first_page; - page < first_page + kBytesMappedPerIteration; - page += kSbMemoryPageSize * page_increment_factor) { - *page = 0x55; - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kBytesMappedPerIteration)); - } -} - -TEST(SbMemoryMapTest, CanReadWriteToResult) { - void* memory = SbMemoryMap(kSize, kSbMemoryMapProtectReadWrite, "test"); - ASSERT_NE(kFailed, memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = static_cast(i); - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); -} - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - -typedef int (*SumFunction)(int, int); -static int Sum(int x, int y) { - return x + y; -} -static int Sum2(int x, int y) { - return x + y + x; -} - -// Copy the contents of |Sum| into |memory|, returning an assertion result -// indicating whether the copy was successful, a function pointer to the -// possibly copied |Sum| function data and a function pointer to the selected -// original function.. Clients are expected to immediately call |ASSERT| on -// the assertion result. -std::tuple<::testing::AssertionResult, SumFunction, SumFunction> -CopySumFunctionIntoMemory(void* memory) { - // There's no reliable way to determine the size of the 'Sum' function. If we - // assume the function is at most a certain size, then we might try to read - // beyond mapped memory when copying it to the destination address. We can - // get a reasonable upper bound by assuming that the function's implementation - // does not cross a page boundary, and copy the memory from the beginning of - // the function to the end of the page that it is mapped to. - // - // However, since it's possible the function may cross the page boundary, we - // define two functions and use the one closest to the start of a page. There - // is no guarantee that the linker will place these definitions sequentially - // (although it likely will), so we can't use the address of 'Sum2' as the - // end of 'Sum'. - // - // To avoid the possibility that COMDAT folding will combine these two - // definitions into one, make sure they are different. - - // A function pointer can't be cast to void*, but uint8* seems to be okay. So - // cast to a uint* which will be implicitly casted to a void* below. - SumFunction original_function = ∑ - if (reinterpret_cast(&Sum2) % kSbMemoryPageSize < - reinterpret_cast(&Sum) % kSbMemoryPageSize) { - original_function = &Sum2; - } - - uint8_t* sum_function_start = reinterpret_cast(original_function); - - // MIPS16 instruction are kept odd addresses to differentiate between that and - // MIPS32 instructions. Most other instructions are aligned to at least even - // addresses, so this code should do nothing for those architectures. - // https://www.linux-mips.org/wiki/MIPS16 - ptrdiff_t sum_function_offset = - sum_function_start - - reinterpret_cast( - reinterpret_cast(sum_function_start) & ~0x1); - sum_function_start -= sum_function_offset; - - // Get the last address of the page that |sum_function_start| is on. - uint8_t* sum_function_page_end = reinterpret_cast( - (reinterpret_cast(sum_function_start) / kSbMemoryPageSize) * - kSbMemoryPageSize + - kSbMemoryPageSize); - if (!starboard::common::MemoryIsAligned(sum_function_page_end, - kSbMemoryPageSize)) { - return std::make_tuple(::testing::AssertionFailure() - << "Expected |Sum| page end (" - << static_cast(sum_function_page_end) - << ") to be aligned to " << kSbMemoryPageSize, - nullptr, nullptr); - } - if (sum_function_start >= sum_function_page_end) { - return std::make_tuple(::testing::AssertionFailure() - << "Expected |Sum| function page start (" - << static_cast(sum_function_start) - << ") to be less than |Sum| function page end (" - << static_cast(sum_function_page_end) - << ")", - nullptr, nullptr); - } - - size_t bytes_to_copy = sum_function_page_end - sum_function_start; - if (bytes_to_copy > kSbMemoryPageSize) { - return std::make_tuple( - ::testing::AssertionFailure() - << "Expected bytes required to copy |Sum| to be less than " - << kSbMemoryPageSize << ", Actual: " << bytes_to_copy, - nullptr, nullptr); - } - - memcpy(memory, sum_function_start, bytes_to_copy); - SbMemoryFlush(memory, bytes_to_copy); - - SumFunction mapped_function = reinterpret_cast( - reinterpret_cast(memory) + sum_function_offset); - - return std::make_tuple(::testing::AssertionSuccess(), mapped_function, - original_function); -} - -// Cobalt can not map executable memory. If executable memory is needed, map -// non-executable memory first and use SbMemoryProtect to change memory access -// to executable. -TEST(SbMemoryMapTest, CanNotDirectlyMapMemoryWithExecFlag) { - SbMemoryMapFlags exec_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectWrite | kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite | - kSbMemoryMapProtectExec), - }; - for (auto exec_flag : exec_flags) { - void* memory = SbMemoryMap(kSize, exec_flag, "test"); - ASSERT_EQ(kFailed, memory); - EXPECT_FALSE(SbMemoryUnmap(memory, 0)); - } -} -#endif // SB_CAN(MAP_EXECUTABLE_MEMORY) - -TEST(SbMemoryMapTest, CanChangeMemoryProtection) { - SbMemoryMapFlags all_from_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectReserved), - SbMemoryMapFlags(kSbMemoryMapProtectRead), - SbMemoryMapFlags(kSbMemoryMapProtectWrite), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite), - }; - SbMemoryMapFlags all_to_flags[] = { - SbMemoryMapFlags(kSbMemoryMapProtectReserved), - SbMemoryMapFlags(kSbMemoryMapProtectRead), - SbMemoryMapFlags(kSbMemoryMapProtectWrite), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectWrite), -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - SbMemoryMapFlags(kSbMemoryMapProtectExec), - SbMemoryMapFlags(kSbMemoryMapProtectRead | kSbMemoryMapProtectExec), -#endif - }; - - for (SbMemoryMapFlags from_flags : all_from_flags) { - for (SbMemoryMapFlags to_flags : all_to_flags) { - void* memory = SbMemoryMap(kSize, from_flags, "test"); - // If the platform does not support a particular protection flags - // configuration in the first place, then just give them a pass, knowing - // that that feature will be tested elsewhere. - if (memory == SB_MEMORY_MAP_FAILED) { - continue; - } - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - // We can only test the ability to execute memory after changing - // protections if we have write permissions either now or then, because - // we have to actually put a valid function into the mapped memory. - SumFunction mapped_function = nullptr; - SumFunction original_function = nullptr; - if (from_flags & kSbMemoryMapProtectWrite) { - auto copy_sum_function_result = CopySumFunctionIntoMemory(memory); - ASSERT_TRUE(std::get<0>(copy_sum_function_result)); - mapped_function = std::get<1>(copy_sum_function_result); - original_function = std::get<2>(copy_sum_function_result); - } -#endif - - if (!SbMemoryProtect(memory, kSize, to_flags)) { - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); - continue; - } - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if ((to_flags & kSbMemoryMapProtectExec) && mapped_function != nullptr) { - EXPECT_EQ(original_function(0xc0ba178, 0xbadf00d), - mapped_function(0xc0ba178, 0xbadf00d)); - } -#endif - - if (to_flags & kSbMemoryMapProtectRead) { - for (int i = 0; i < kSize; i++) { - volatile uint8_t force_read = static_cast(memory)[i]; - } - } - if (to_flags & kSbMemoryMapProtectWrite) { - for (int i = 0; i < kSize; i++) { - static_cast(memory)[i] = 0xff; - } - } - - EXPECT_TRUE(SbMemoryUnmap(memory, kSize)); - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/memory_reallocate_test.cc b/starboard/nplb/memory_reallocate_test.cc deleted file mode 100644 index 04e91b42f317..000000000000 --- a/starboard/nplb/memory_reallocate_test.cc +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const size_t kSize = 1024 * 128; - -TEST(SbMemoryReallocateTest, AllocatesNormally) { - void* memory = SbMemoryReallocate(NULL, kSize); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, AllocatesZero) { - void* memory = SbMemoryReallocate(NULL, 0); - // We can't expect anything here because some implementations may return an - // allocated zero-size memory block, and some implementations may return NULL. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, AllocatesOne) { - void* memory = SbMemoryReallocate(NULL, 1); - EXPECT_NE(static_cast(NULL), memory); - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, CanReadWriteToResult) { - void* memory = SbMemoryReallocate(NULL, kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatesSmaller) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize / 2); - data = static_cast(memory); - ASSERT_NE(static_cast(NULL), memory); - for (int i = 0; i < kSize / 2; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatesBigger) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize * 2); - - ASSERT_NE(static_cast(NULL), memory); - data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - for (int i = kSize; i < kSize * 2; ++i) { - data[i] = i; - } - - for (int i = kSize; i < kSize * 2; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -// Tests unspecified behavior, currently not stable. -// Should be deleted or fixed. -TEST(SbMemoryReallocateTest, DISABLED_ReallocatestoZero) { - void* memory = SbMemoryAllocate(kSize); - - ASSERT_NE(static_cast(NULL), memory); - memory = SbMemoryReallocate(memory, 0); - - // See allocates zero above. - SbMemoryDeallocate(memory); -} - -TEST(SbMemoryReallocateTest, ReallocatestoSameSize) { - void* memory = SbMemoryAllocate(kSize); - ASSERT_NE(static_cast(NULL), memory); - char* data = static_cast(memory); - for (int i = 0; i < kSize; ++i) { - data[i] = i; - } - - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - memory = SbMemoryReallocate(memory, kSize); - - data = static_cast(memory); - ASSERT_NE(static_cast(NULL), memory); - for (int i = 0; i < kSize; ++i) { - EXPECT_EQ(data[i], static_cast(i)); - } - - SbMemoryDeallocate(memory); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_test.cc b/starboard/nplb/mutex_acquire_test.cc deleted file mode 100644 index e2556bf430e2..000000000000 --- a/starboard/nplb/mutex_acquire_test.cc +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct TestContext { - TestContext() : count(0) {} - SbMutex mutex; - int count; -}; - -const int kLoops = 10000; - -void* EntryPoint(void* parameter) { - TestContext* context = static_cast(parameter); - - for (int i = 0; i < kLoops; ++i) { - SbMutexAcquire(&context->mutex); - int k = context->count; - k = k + 1; - context->count = k; - SbMutexRelease(&context->mutex); - } - - return NULL; -} - -// This test just tries to acquire a mutex repeatedly while other threads are -// doing the same. -TEST(SbMutexAcquireTest, SunnyDayContended) { - TestContext context; - EXPECT_TRUE(SbMutexCreate(&context.mutex)); - const int kThreads = 4; - SbThread threads[kThreads]; - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &context); - } - - for (int i = 0; i < kLoops; ++i) { - for (int j = 0; j < kThreads; ++j) { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&context.mutex))); - int k = context.count; - k = k - 1; - context.count = k; - EXPECT_TRUE(SbMutexRelease(&context.mutex)); - } - } - - // Join other threads and clean up. - for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - } - EXPECT_TRUE(SbMutexDestroy(&context.mutex)); - EXPECT_EQ(0, context.count); -} - -TEST(SbMutexAcquireTest, SunnyDayUncontended) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquire(&mutex); - EXPECT_EQ(kSbMutexAcquired, result); - EXPECT_TRUE(SbMutexIsSuccess(result)); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, SunnyDayStaticallyInitialized) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, RainyDayAcquireNull) { - SbMutexResult result = SbMutexAcquire(NULL); - EXPECT_EQ(kSbMutexDestroyed, result); -} - -TEST(SbMutexAcquireTest, RainyDayReleaseNull) { - EXPECT_FALSE(SbMutexRelease(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_acquire_try_test.cc b/starboard/nplb/mutex_acquire_try_test.cc deleted file mode 100644 index c393478c1525..000000000000 --- a/starboard/nplb/mutex_acquire_try_test.cc +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" - -namespace starboard { -namespace nplb { -namespace { - -struct TestContext { - explicit TestContext(SbMutex* mutex) : was_locked_(false), mutex_(mutex) {} - bool was_locked_; - SbMutex* mutex_; -}; - -void* EntryPoint(void* parameter) { - TestContext* context = static_cast(parameter); - context->was_locked_ = - (SbMutexAcquireTry(context->mutex_) == kSbMutexAcquired); - return NULL; -} - -TEST(SbMutexAcquireTryTest, SunnyDayUncontended) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_EQ(result, kSbMutexAcquired); - EXPECT_TRUE(SbMutexIsSuccess(result)); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTryTest, RainyDayReentrant) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - - SbMutexResult result = SbMutexAcquireTry(&mutex); - EXPECT_EQ(result, kSbMutexAcquired); - EXPECT_TRUE(SbMutexIsSuccess(result)); - - TestContext context(&mutex); - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, &EntryPoint, &context); - - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_FALSE(context.was_locked_); - EXPECT_TRUE(SbMutexRelease(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexAcquireTest, RainyDayAcquireTryNull) { - SbMutexResult result = SbMutexAcquireTry(NULL); - EXPECT_EQ(kSbMutexDestroyed, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_create_test.cc b/starboard/nplb/mutex_create_test.cc deleted file mode 100644 index a1673ceeec17..000000000000 --- a/starboard/nplb/mutex_create_test.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -#include "starboard/common/once.h" -#include "starboard/condition_variable.h" - -namespace starboard { -namespace nplb { -namespace { - -const int kALot = 128 * 1024; -const int kABunch = 2 * 1024; - -TEST(SbMutexCreateTest, SunnyDay) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexCreateTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -TEST(SbMutexCreateTest, SunnyDayALot) { - for (int i = 0; i < kALot; ++i) { - SbMutex mutex; - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); - } -} - -TEST(SbMutexCreateTest, SunnyDayABunchAtOnce) { - SbMutex mutexes[kABunch]; - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexCreate(&mutexes[i])); - } - - for (int i = 0; i < kABunch; ++i) { - EXPECT_TRUE(SbMutexDestroy(&mutexes[i])); - } -} - -TEST(SbMutexCreateTest, RainyDayNull) { - EXPECT_FALSE(SbMutexCreate(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/mutex_destroy_test.cc b/starboard/nplb/mutex_destroy_test.cc deleted file mode 100644 index 6c813388a1b2..000000000000 --- a/starboard/nplb/mutex_destroy_test.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Destroy is mostly Sunny Day tested in Create. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/mutex.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbMutexDestroyTest, SunnyDayAutoInit) { - SbMutex mutex = SB_MUTEX_INITIALIZER; - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -// Destroying a mutex that has already been destroyed is undefined behavior -// and cannot be tested. -TEST(SbMutexDestroyTest, RainyDayNull) { - EXPECT_FALSE(SbMutexDestroy(NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc b/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc index 51328d9a0005..b44c35347df6 100644 --- a/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc +++ b/starboard/nplb/nplb_evergreen_compat_tests/sabi_test.cc @@ -28,115 +28,6 @@ namespace nplb_evergreen_compat_tests { namespace { -#if SB_API_VERSION == 15 -const char* kSabiJsonIdArmHardfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"hard\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":15,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArmSoftfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"softfp\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":15,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArm64 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"aarch64\",\"endianness\":\"little\",\"floating_point_abi\":\"\"," - "\"floating_point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":" - "\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_" - "double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4," - "\"size_of_llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_" - "short\":2,\"target_arch\":\"arm64\",\"target_arch_sub\":\"v8a\",\"word_" - "size\":64}"; - -const char* kSabiJsonIdX86 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":4,\"size_of_pointer\":4,\"size_of_short\":2," - "\"target_arch\":\"x86\",\"target_arch_sub\":\"\",\"word_size\":32}"; - -const char* kSabiJsonIdX64Sysv = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":15,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_short\":2," - "\"target_arch\":\"x64\",\"target_arch_sub\":\"\",\"word_size\":64}"; -#endif // SB_API_VERSION == 15 - -#if SB_API_VERSION == 16 -const char* kSabiJsonIdArmHardfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"hard\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":16,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArmSoftfp = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":4," - "\"alignment_pointer\":4,\"alignment_short\":2,\"calling_convention\":" - "\"eabi\",\"endianness\":\"little\",\"floating_point_abi\":\"softfp\"," - "\"floating_point_fpu\":\"vfpv3\",\"sb_api_version\":16,\"signedness_of_" - "char\":\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1," - "\"size_of_double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_" - "int\":4,\"size_of_llong\":8,\"size_of_long\":4,\"size_of_pointer\":4," - "\"size_of_short\":2,\"target_arch\":\"arm\",\"target_arch_sub\":\"v7a\"," - "\"word_size\":32}"; - -const char* kSabiJsonIdArm64 = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"aarch64\",\"endianness\":\"little\",\"floating_point_abi\":\"\"," - "\"floating_point_fpu\":\"\",\"sb_api_version\":16,\"signedness_of_char\":" - "\"signed\",\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_" - "double\":8,\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4," - "\"size_of_llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_" - "short\":2,\"target_arch\":\"arm64\",\"target_arch_sub\":\"v8a\",\"word_" - "size\":64}"; - -const char* kSabiJsonIdX64Sysv = - "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," - "\"alignment_int\":4,\"alignment_llong\":8,\"alignment_long\":8," - "\"alignment_pointer\":8,\"alignment_short\":2,\"calling_convention\":" - "\"sysv\",\"endianness\":\"little\",\"floating_point_abi\":\"\",\"floating_" - "point_fpu\":\"\",\"sb_api_version\":16,\"signedness_of_char\":\"signed\"," - "\"signedness_of_enum\":\"signed\",\"size_of_char\":1,\"size_of_double\":8," - "\"size_of_enum\":4,\"size_of_float\":4,\"size_of_int\":4,\"size_of_" - "llong\":8,\"size_of_long\":8,\"size_of_pointer\":8,\"size_of_short\":2," - "\"target_arch\":\"x64\",\"target_arch_sub\":\"\",\"word_size\":64}"; -#endif // SB_API_VERSION == 16 - #if SB_API_VERSION == 17 const char* kSabiJsonIdArmHardfp = "{\"alignment_char\":1,\"alignment_double\":8,\"alignment_float\":4," @@ -203,9 +94,6 @@ TEST_F(SabiTest, VerifySABI) { sabi_set.insert(kSabiJsonIdArmHardfp); sabi_set.insert(kSabiJsonIdArmSoftfp); sabi_set.insert(kSabiJsonIdArm64); -#if SB_API_VERSION < 16 - sabi_set.insert(kSabiJsonIdX86); -#endif sabi_set.insert(kSabiJsonIdX64Sysv); ASSERT_NE(sabi_set.find(SB_SABI_JSON_ID), sabi_set.end()) @@ -219,9 +107,6 @@ TEST_F(SabiTest, VerifySABI) { << std::endl << " starboard/sabi/arm64/sabi-v" << SB_API_VERSION << ".json" << std::endl -#if SB_API_VERSION < 16 - << " starboard/sabi/x86/sabi-v" << SB_API_VERSION << ".json" << std::endl -#endif << " starboard/sabi/x64/sysv/sabi-v" << SB_API_VERSION << ".json" << std::endl; } diff --git a/starboard/nplb/once_test.cc b/starboard/nplb/once_test.cc deleted file mode 100644 index dcecfbba6b6a..000000000000 --- a/starboard/nplb/once_test.cc +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Broadcast is Sunny Day tested in most of the other SbConditionVariable tests. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/once.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int s_global_value; - -void IncrementGlobalValue() { - ++s_global_value; -} - -TEST(SbOnceTest, SunnyDaySingleInit) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - - EXPECT_EQ(1, s_global_value); -} - -TEST(SbOnceTest, SunnyDayMultipleInit) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(1, s_global_value); - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(0, s_global_value); - - s_global_value = 0; - EXPECT_TRUE(SbOnce(&once_control, &IncrementGlobalValue)); - EXPECT_EQ(0, s_global_value); -} - -struct RunSbOnceContext { - RunSbOnceContext() : once_control(SB_ONCE_INITIALIZER) { - SbMutexCreate(&mutex); - SbConditionVariableCreate(&condition, &mutex); - } - ~RunSbOnceContext() { - SbConditionVariableDestroy(&condition); - SbMutexDestroy(&mutex); - } - - Semaphore semaphore; - SbMutex mutex; - SbConditionVariable condition; - - SbOnceControl once_control; -}; - -void* RunSbOnceEntryPoint(void* context) { - RunSbOnceContext* run_sbonce_context = - reinterpret_cast(context); - - { - SbMutexAcquire(&run_sbonce_context->mutex); - run_sbonce_context->semaphore.Put(); - SbConditionVariableWait(&run_sbonce_context->condition, - &run_sbonce_context->mutex); - SbMutexRelease(&run_sbonce_context->mutex); - } - - sched_yield(); - static const int kIterationCount = 3; - for (int i = 0; i < kIterationCount; ++i) { - SbOnce(&run_sbonce_context->once_control, &IncrementGlobalValue); - } - - return NULL; -} - -// Here we spawn many threads each of which will call SbOnce multiple times -// using a shared SbOnceControl object. We then test that the initialization -// routine got called exactly one time. -TEST(SbOnceTest, SunnyDayMultipleThreadsInit) { - const int kMany = kSbMaxThreads; - std::vector threads(kMany); - - const int kIterationCount = 10; - for (int i = 0; i < kIterationCount; ++i) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - RunSbOnceContext context; - - s_global_value = 0; - for (int j = 0; j < kMany; ++j) { - threads[j] = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, RunSbOnceEntryPoint, &context); - } - - // Wait for all threads to finish initializing and become ready, then - // broadcast the signal to begin. We do this to increase the chances that - // threads will call SbOnce() at the same time as each other. - for (int j = 0; j < kMany; ++j) { - context.semaphore.Take(); - } - { - SbMutexAcquire(&context.mutex); - SbConditionVariableBroadcast(&context.condition); - SbMutexRelease(&context.mutex); - } - - // Signal threads to beginWait for all threads to complete. - for (int i = 0; i < kMany; ++i) { - void* result; - SbThreadJoin(threads[i], &result); - } - - EXPECT_EQ(1, s_global_value); - } -} - -TEST(SbOnceTest, RainyDayBadOnceControl) { - s_global_value = 0; - EXPECT_FALSE(SbOnce(NULL, &IncrementGlobalValue)); - - EXPECT_EQ(0, s_global_value); -} - -TEST(SbOnceTest, RainyDayBadInitRoutine) { - SbOnceControl once_control = SB_ONCE_INITIALIZER; - - s_global_value = 0; - EXPECT_FALSE(SbOnce(&once_control, NULL)); - - EXPECT_EQ(0, s_global_value); -} - -SB_ONCE_INITIALIZE_FUNCTION(int, GetIntSingleton); -TEST(SbOnceTest, InitializeOnceMacroFunction) { - int* int_singelton = GetIntSingleton(); - ASSERT_TRUE(int_singelton); - EXPECT_EQ(0, *int_singelton) - << "Singleton Macro does not default initialize."; -} - -} // namespace. -} // namespace nplb. -} // namespace starboard. - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/posix_compliance/posix_memory_map_test.cc b/starboard/nplb/posix_compliance/posix_memory_map_test.cc index 147bf8f44109..cbd2566676eb 100644 --- a/starboard/nplb/posix_compliance/posix_memory_map_test.cc +++ b/starboard/nplb/posix_compliance/posix_memory_map_test.cc @@ -183,13 +183,6 @@ TEST(PosixMemoryMapTest, CanChangeMemoryProtection) { continue; } -#if SB_API_VERSION < 16 -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - const bool kSbCanMapExecutableMemory = true; -#else - const bool kSbCanMapExecutableMemory = false; -#endif -#endif SumFunction mapped_function = nullptr; SumFunction original_function = nullptr; if (kSbCanMapExecutableMemory) { diff --git a/starboard/nplb/storage_helpers.h b/starboard/nplb/storage_helpers.h index 3e030d9ae4c4..48df4ea4ae6d 100644 --- a/starboard/nplb/storage_helpers.h +++ b/starboard/nplb/storage_helpers.h @@ -28,40 +28,24 @@ const int64_t kStorageSize2 = kStorageSize * 2 + kStorageOffset; // Deletes the storage. static inline void ClearStorageRecord() { -#if SB_API_VERSION < 16 - SbStorageDeleteRecord(SbUserGetCurrent(), NULL); -#else SbStorageDeleteRecord(NULL); -#endif } // Deletes the named storage record. static inline void ClearStorageRecord(const char* name) { -#if SB_API_VERSION < 16 - SbStorageDeleteRecord(SbUserGetCurrent(), name); -#else SbStorageDeleteRecord(name); -#endif } // Opens the storage record, validating that it is valid. static inline SbStorageRecord OpenStorageRecord() { -#if SB_API_VERSION < 16 - SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent(), NULL); -#else SbStorageRecord record = SbStorageOpenRecord(NULL); -#endif EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } // Opens the named storage record, validating that it is valid. static inline SbStorageRecord OpenStorageRecord(const char* name) { -#if SB_API_VERSION < 16 - SbStorageRecord record = SbStorageOpenRecord(SbUserGetCurrent(), name); -#else SbStorageRecord record = SbStorageOpenRecord(name); -#endif EXPECT_TRUE(SbStorageIsValidRecord(record)); return record; } diff --git a/starboard/nplb/string_compare_no_case_n_test.cc b/starboard/nplb/string_compare_no_case_n_test.cc deleted file mode 100644 index 5cd234978c80..000000000000 --- a/starboard/nplb/string_compare_no_case_n_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -TEST(SbStringCompareNoCaseNTest, SunnyDaySelf) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString, kString, strlen(kString))); - EXPECT_EQ(0, SbStringCompareNoCaseN("", "", 0)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayEmptyLessThanNotEmpty) { - const char kString[] = "0123456789"; - EXPECT_GT(0, SbStringCompareNoCaseN("", kString, strlen(kString))); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayEmptyZeroNEqual) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN("", kString, 0)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayBigN) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString, kString, strlen(kString) * 2)); -} - -TEST(SbStringCompareNoCaseNTest, SunnyDayCase) { - const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ"; - const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_EQ(0, SbStringCompareNoCaseN(kString1, kString2, strlen(kString1))); - EXPECT_EQ(0, SbStringCompareNoCaseN(kString2, kString1, strlen(kString2))); - - const char kString3[] = "aBcDeFgHiJkLmaBcDeFgHiJkLm"; - const char kString4[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_GT(0, SbStringCompareNoCaseN(kString3, kString4, strlen(kString3))); - EXPECT_LT(0, SbStringCompareNoCaseN(kString4, kString3, strlen(kString4))); - EXPECT_EQ(0, - SbStringCompareNoCaseN(kString3, kString4, strlen(kString3) / 2)); - EXPECT_EQ(0, - SbStringCompareNoCaseN(kString4, kString3, strlen(kString4) / 2)); -} -#endif // SB_API_VERSION < 16 - -} // namespace -} // namespace nplb -} // namespace starboard diff --git a/starboard/nplb/string_compare_no_case_test.cc b/starboard/nplb/string_compare_no_case_test.cc deleted file mode 100644 index 73544d0295ca..000000000000 --- a/starboard/nplb/string_compare_no_case_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -#if SB_API_VERSION < 16 -TEST(SbStringCompareNoCaseTest, SunnyDaySelf) { - const char kString[] = "0123456789"; - EXPECT_EQ(0, SbStringCompareNoCase(kString, kString)); - EXPECT_EQ(0, SbStringCompareNoCase("", "")); -} - -TEST(SbStringCompareNoCaseTest, SunnyDayEmptyLessThanNotEmpty) { - const char kString[] = "0123456789"; - EXPECT_GT(0, SbStringCompareNoCase("", kString)); -} - -TEST(SbStringCompareNoCaseTest, SunnyDayCase) { - const char kString1[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ"; - const char kString2[] = "AbCdEfGhIjKlMnOpQrStUvWxYz"; - EXPECT_EQ(0, SbStringCompareNoCase(kString1, kString2)); - EXPECT_EQ(0, SbStringCompareNoCase(kString2, kString1)); -} -#endif // SB_API_VERSION < 16 -} // namespace -} // namespace nplb -} // namespace starboard diff --git a/starboard/nplb/string_duplicate_test.cc b/starboard/nplb/string_duplicate_test.cc deleted file mode 100644 index 27f7fc2f48f2..000000000000 --- a/starboard/nplb/string_duplicate_test.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" -#include "starboard/memory.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 -namespace starboard { -namespace nplb { -namespace { - -void RunTest(const char* input) { - char* dupe = SbStringDuplicate(input); - const char* kNull = NULL; - EXPECT_NE(kNull, dupe); - EXPECT_EQ(0, SbStringCompareNoCase(input, dupe)); - EXPECT_EQ(strlen(input), strlen(dupe)); - SbMemoryDeallocate(dupe); -} - -TEST(SbStringDuplicateTest, SunnyDay) { - RunTest("0123456789"); - RunTest("0"); -} - -TEST(SbStringDuplicateTest, SunnyDayEmpty) { - RunTest(""); -} - -} // namespace -} // namespace nplb -} // namespace starboard -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_format_test.cc b/starboard/nplb/string_format_test.cc deleted file mode 100644 index 465376852c68..000000000000 --- a/starboard/nplb/string_format_test.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int Format(char* out_buffer, size_t buffer_size, const char* format, ...) { - va_list arguments; - va_start(arguments, format); - int result = SbStringFormat(out_buffer, buffer_size, format, arguments); - va_end(arguments); - return result; -} - -TEST(SbStringFormatTest, SunnyDay) { - const char kExpected[] = "a1b2c3test"; - char destination[1024] = {0}; - int result = Format(destination, SB_ARRAY_SIZE(destination), "a%db%dc%d%s", 1, - 2, 3, "test"); - size_t expected_length = strlen(kExpected); - EXPECT_EQ(expected_length, result); - for (size_t i = 0; i <= expected_length; ++i) { - EXPECT_EQ(kExpected[i], destination[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - // -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_format_wide_test.cc b/starboard/nplb/string_format_wide_test.cc deleted file mode 100644 index 9487c7e7eaee..000000000000 --- a/starboard/nplb/string_format_wide_test.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -int Format(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - ...) { - va_list arguments; - va_start(arguments, format); - int result = SbStringFormatWide(out_buffer, buffer_size, format, arguments); - va_end(arguments); - return result; -} - -TEST(SbStringFormatWideTest, SunnyDay) { - const wchar_t kExpected[] = L"a1b2c3test"; - wchar_t destination[1024] = {0}; - int result = Format(destination, SB_ARRAY_SIZE(destination), L"a%db%dc%d%s", - 1, 2, 3, "test"); - size_t expected_length = wcslen(kExpected); - EXPECT_EQ(expected_length, result); - for (size_t i = 0; i <= expected_length; ++i) { - EXPECT_EQ(kExpected[i], destination[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/string_scan_test.cc b/starboard/nplb/string_scan_test.cc deleted file mode 100644 index 0f6d66bc366e..000000000000 --- a/starboard/nplb/string_scan_test.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Here we are not trying to do anything fancy, just to really sanity check that -// this is hooked up to something. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const char kIpGood[] = "192.168.1.2"; -const char kIpBad1[] = "192.1x8.1.2"; -const char kIpBad2[] = "192.1x8"; -const char kIpBad3[] = "x.1.2.3"; -const char kIpBad4[] = "192.168.1.2."; -const char kIpFormat[] = "%u.%u.%u.%u"; - -const char kFloatString[] = "3.14159"; -const char kFloatPattern[] = "%f"; -const char kDoublePattern[] = "%lf"; -const float kExpectedFloat = 3.14159f; -const double kExpectedDouble = 3.14159; - -TEST(SbStringScanTest, SunnyDayIp1) { - unsigned int in[4] = {0}; - EXPECT_EQ(4, SbStringScanF(kIpGood, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(168, in[1]); - EXPECT_EQ(1, in[2]); - EXPECT_EQ(2, in[3]); -} - -TEST(SbStringScanTest, SunnyDayIp2) { - unsigned int in[4] = {0}; - EXPECT_EQ(4, SbStringScanF(kIpBad4, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(168, in[1]); - EXPECT_EQ(1, in[2]); - EXPECT_EQ(2, in[3]); -} - -TEST(SbStringScanTest, SunnyDayFloat) { - float f = 0.0f; - EXPECT_EQ(1, SbStringScanF(kFloatString, kFloatPattern, &f)); - EXPECT_EQ(kExpectedFloat, f); - - double d = 0.0; - EXPECT_EQ(1, SbStringScanF(kFloatString, kDoublePattern, &d)); - EXPECT_EQ(kExpectedDouble, d); -} - -TEST(SbStringScanTest, RainyDayIp1) { - unsigned int in[4] = {0}; - EXPECT_EQ(2, SbStringScanF(kIpBad1, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(1, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -TEST(SbStringScanTest, RainyDayIp2) { - unsigned int in[4] = {0}; - EXPECT_EQ(2, SbStringScanF(kIpBad2, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(192, in[0]); - EXPECT_EQ(1, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -TEST(SbStringScanTest, RainyDayIp3) { - unsigned int in[4] = {0}; - EXPECT_EQ(0, SbStringScanF(kIpBad3, kIpFormat, in, in + 1, in + 2, in + 3)); - EXPECT_EQ(0, in[0]); - EXPECT_EQ(0, in[1]); - EXPECT_EQ(0, in[2]); - EXPECT_EQ(0, in[3]); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_create_test.cc b/starboard/nplb/thread_create_test.cc deleted file mode 100644 index cc06902505cf..000000000000 --- a/starboard/nplb/thread_create_test.cc +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -const SbThreadPriority kAllThreadPriorities[] = { - kSbThreadPriorityLowest, kSbThreadPriorityLow, - kSbThreadPriorityNormal, kSbThreadPriorityHigh, - kSbThreadPriorityHighest, kSbThreadPriorityRealTime, - kSbThreadNoPriority, -}; - -TEST(SbThreadCreateTest, SunnyDay) { - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - SbThread thread = SbThreadCreate( - 0, kSbThreadNoPriority, kSbThreadNoAffinity, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } -} - -TEST(SbThreadCreateTest, SunnyDayWithPriorities) { - const int kTrials = 64; - for (int i = 0; i < kTrials; ++i) { - SbThreadPriority priority; - switch (i % 7) { - case 0: - priority = kSbThreadPriorityLowest; - break; - case 1: - priority = kSbThreadPriorityLow; - break; - case 2: - priority = kSbThreadPriorityNormal; - break; - case 3: - priority = kSbThreadPriorityHigh; - break; - case 4: - priority = kSbThreadPriorityHighest; - break; - case 5: - priority = kSbThreadPriorityRealTime; - break; - case 6: - priority = kSbThreadNoPriority; - break; - } - SbThread thread = SbThreadCreate(0, priority, kSbThreadNoAffinity, true, - nplb::kThreadName, nplb::AddOneEntryPoint, - nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } -} - -void* CreateNestedThreadFunc(void* context) { - for (auto thread_priority : kAllThreadPriorities) { - SbThread thread = SbThreadCreate( - 0, thread_priority, kSbThreadNoAffinity, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); - } - return NULL; -} - -TEST(SbThreadCreateTest, SunnyDayWithNestedPriorities) { - for (auto thread_priority : kAllThreadPriorities) { - SbThread thread = SbThreadCreate( - 0, thread_priority, kSbThreadNoAffinity, true, nplb::kThreadName, - CreateNestedThreadFunc, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - } -} - -TEST(SbThreadCreateTest, SunnyDayNoName) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, NULL, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); -} - -TEST(SbThreadCreateTest, SunnyDayNoContext) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, nplb::AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::ToVoid(1), result); -} - -TEST(SbThreadCreateTest, SunnyDayWithAffinity) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, 0, true, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(thread, &result)); - EXPECT_EQ(nplb::kSomeContextPlusOne, result); -} - -TEST(SbThreadCreateTest, SunnyDayDetached) { - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - false, nplb::kThreadName, - nplb::AddOneEntryPoint, nplb::kSomeContext); - EXPECT_TRUE(SbThreadIsValid(thread)); - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(thread, &result)); -} - -TEST(SbThreadCreateTest, Summertime) { - const int kMany = kSbMaxThreads; - std::vector threads(kMany); - for (int i = 0; i < kMany; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, nplb::kThreadName, nplb::AddOneEntryPoint, - nplb::ToVoid(i)); - EXPECT_TRUE(SbThreadIsValid(threads[i])); - } - - for (int i = 0; i < kMany; ++i) { - void* result = NULL; - void* const kExpected = nplb::ToVoid(i + 1); - EXPECT_TRUE(SbThreadJoin(threads[i], &result)); - EXPECT_EQ(kExpected, result); - } -} - -TEST(SbThreadCreateTest, RainyDayNoEntryPoint) { - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - nplb::kThreadName, NULL, nplb::kSomeContext); - EXPECT_FALSE(SbThreadIsValid(thread)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_detach_test.cc b/starboard/nplb/thread_detach_test.cc deleted file mode 100644 index e50b51be25f5..000000000000 --- a/starboard/nplb/thread_detach_test.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadDetachTest, SunnyDay) { - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - SbThreadDetach(thread); - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(thread, &result)); - EXPECT_EQ(NULL, result); -} - -TEST(SbThreadDetachTest, RainyDayInvalid) { - // No way to verify this, but it shouldn't crash. - SbThreadDetach(kSbThreadInvalid); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_current_test.cc b/starboard/nplb/thread_get_current_test.cc deleted file mode 100644 index db12599d450d..000000000000 --- a/starboard/nplb/thread_get_current_test.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void* EntryPoint(void* context) { - // NOLINTNEXTLINE(readability/casting) - return ToVoid((intptr_t)SbThreadGetCurrent()); -} - -TEST(SbThreadGetCurrentTest, SunnyDay) { - const int kThreads = 16; - SbThread threads[kThreads]; - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(threads[i])); - } - - for (int i = 0; i < kThreads; ++i) { - void* result = NULL; - EXPECT_TRUE(SbThreadJoin(threads[i], &result)); - // NOLINTNEXTLINE(readability/casting) - EXPECT_EQ(ToVoid((intptr_t)threads[i]), result); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_get_name_test.cc b/starboard/nplb/thread_get_name_test.cc deleted file mode 100644 index 555bc4ff7395..000000000000 --- a/starboard/nplb/thread_get_name_test.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -// Returns the thread's ID. -void* GetThreadNameEntryPoint(void* context) { - char name[4096] = {0}; - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - std::string* result = static_cast(context); - *result = name; - return NULL; -} - -TEST(SbThreadGetNameTest, SunnyDay) { - std::string result; - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, GetThreadNameEntryPoint, &result); - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_EQ(kThreadName, result); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/thread_helpers.cc b/starboard/nplb/thread_helpers.cc deleted file mode 100644 index 66e893fb0f77..000000000000 --- a/starboard/nplb/thread_helpers.cc +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/nplb/thread_helpers.h" - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/types.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { - -void DoNotYield() { - // Nope. -} - -// Adds 1 to the input. -void* AddOneEntryPoint(void* context) { - return ToVoid(FromVoid(context) + 1); -} - -void* WaiterEntryPoint(void* context) { - WaiterContext* real_context = static_cast(context); - real_context->Wait(); - return NULL; -} - -void* TakeThenSignalEntryPoint(void* context) { - TakeThenSignalContext* test_context = - static_cast(context); - - // Don't signal the condition variable until we are asked. - test_context->do_signal.Take(); - - if (test_context->delay_after_signal > 0) { - usleep(test_context->delay_after_signal); - } - - // Signal the condition variable. - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&test_context->mutex))); - EXPECT_TRUE(SbConditionVariableSignal(&test_context->condition)); - EXPECT_TRUE(SbMutexRelease(&test_context->mutex)); - - return NULL; -} - -WaiterContext::WaiterContext() : unreturned_waiters(0) { - EXPECT_TRUE(SbMutexCreate(&mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&condition, &mutex)); - EXPECT_TRUE(SbConditionVariableCreate(&return_condition, &mutex)); -} - -WaiterContext::~WaiterContext() { - EXPECT_TRUE(SbConditionVariableDestroy(&return_condition)); - EXPECT_TRUE(SbConditionVariableDestroy(&condition)); - EXPECT_TRUE(SbMutexDestroy(&mutex)); -} - -void WaiterContext::Wait() { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - ++unreturned_waiters; - EXPECT_TRUE(SbConditionVariableSignal(&return_condition)); - EXPECT_TRUE(SbConditionVariableIsSignaled( - SbConditionVariableWait(&condition, &mutex))); - EXPECT_TRUE(SbMutexRelease(&mutex)); -} - -void WaiterContext::WaitForReturnSignal() { - EXPECT_TRUE(SbMutexIsSuccess(SbMutexAcquire(&mutex))); - while (unreturned_waiters == 0) { - EXPECT_TRUE(SbConditionVariableIsSignaled( - SbConditionVariableWait(&return_condition, &mutex))); - } - --unreturned_waiters; - EXPECT_TRUE(SbMutexRelease(&mutex)); -} - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_helpers.h b/starboard/nplb/thread_helpers.h index fcc1a6f8738a..5668cae4f49e 100644 --- a/starboard/nplb/thread_helpers.h +++ b/starboard/nplb/thread_helpers.h @@ -15,187 +15,6 @@ #ifndef STARBOARD_NPLB_THREAD_HELPERS_H_ #define STARBOARD_NPLB_THREAD_HELPERS_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include "starboard/common/mutex.h" -#include "starboard/common/semaphore.h" -#include "starboard/condition_variable.h" -#include "starboard/configuration.h" -#include "starboard/thread.h" -#include "starboard/types.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { - -class TestSemaphore { - public: - TestSemaphore(); // initial_thread_permits = 0; - explicit TestSemaphore(int initial_thread_permits); - - // Copy constructed needed because of tests. - TestSemaphore(const TestSemaphore& other) - : mutex_(), condition_(mutex_), permits_(other.permits_) {} - ~TestSemaphore(); - - // Increases the permits. One thread will be woken up if it is blocked in - // Take(). - void Put(); - - // The caller is blocked if the counter is negative, and will stay blocked - // until Put() is invoked by another thread. The permits is then - // decremented by one. - - void Take(); - - // A non-blocking version of Take(). If the counter is negative then this - // function returns immediately and the semaphore is not modified. If true - // is returned then the effects are the same as Take(). - bool TakeTry(); - - private: - Mutex mutex_; - ConditionVariable condition_; - int permits_; -}; - -inline TestSemaphore::TestSemaphore() - : mutex_(), condition_(mutex_), permits_(0) {} - -inline TestSemaphore::TestSemaphore(int initial_thread_permits) - : mutex_(), condition_(mutex_), permits_(initial_thread_permits) {} - -inline TestSemaphore::~TestSemaphore() {} - -inline void TestSemaphore::Put() { - ScopedLock lock(mutex_); - ++permits_; - condition_.Signal(); -} - -inline void TestSemaphore::Take() { - ScopedLock lock(mutex_); - while (permits_ <= 0) { - condition_.Wait(); - } - --permits_; -} - -inline bool TestSemaphore::TakeTry() { - ScopedLock lock(mutex_); - if (permits_ <= 0) { - return false; - } - --permits_; - return true; -} - -inline void* ToVoid(intptr_t value) { - return reinterpret_cast(value); -} - -inline intptr_t FromVoid(void* value) { - return reinterpret_cast(value); -} - -void* const kSomeContext = ToVoid(1234); -void* const kSomeContextPlusOne = ToVoid(1235); - -const char* const kThreadName = "ThreadName"; -const char* const kAltThreadName = "AltThreadName"; - -// Does not yield, can't you read? -void DoNotYield(); - -// Adds 1 to the input. -void* AddOneEntryPoint(void* context); - -// Acquires the mutex from the WaiterContext, signals the return_condition, then -// waits on the condition. -void* WaiterEntryPoint(void* context); - -// Takes a token from the TakeThenSignalContext semaphore, and then signals the -// condition variable. -void* TakeThenSignalEntryPoint(void* context); - -// A simple struct that will initialize its members on construction and destroy -// them on destruction. -struct WaiterContext { - WaiterContext(); - ~WaiterContext(); - - // Waits on |condition|, incrementing |unreturned_waiters| and signalling - // |return_condition|. - void Wait(); - - // Waits until unreturned_waiters > 0, and then takes one. - void WaitForReturnSignal(); - - SbMutex mutex; - SbConditionVariable condition; - SbConditionVariable return_condition; - int unreturned_waiters; -}; - -// An aggregate type (which can be initialized with aggregate initialization) to -// be used with the TakeThenSignalEntryPoint. -struct TakeThenSignalContext { - TestSemaphore do_signal; - SbMutex mutex; - SbConditionVariable condition; - int64_t delay_after_signal; -}; - -// AbstractTestThread that is a bare bones class wrapper around Starboard -// thread. Subclasses must override Run(). -class AbstractTestThread { - public: - AbstractTestThread() : thread_(kSbThreadInvalid) {} - virtual ~AbstractTestThread() {} - - // Subclasses should override the Run method. - virtual void Run() = 0; - - // Calls SbThreadCreate() with default parameters. - void Start() { - SbThreadEntryPoint entry_point = ThreadEntryPoint; - - thread_ = SbThreadCreate(0, // default stack_size. - kSbThreadNoPriority, // default priority. - kSbThreadNoAffinity, // default affinity. - true, // joinable. - "AbstractTestThread", entry_point, this); - - if (kSbThreadInvalid == thread_) { - ADD_FAILURE_AT(__FILE__, __LINE__) << "Invalid thread."; - } - return; - } - - void Join() { - if (!SbThreadJoin(thread_, NULL)) { - ADD_FAILURE_AT(__FILE__, __LINE__) << "Could not join thread."; - } - } - - SbThread GetThread() { return thread_; } - - private: - static void* ThreadEntryPoint(void* ptr) { - AbstractTestThread* this_ptr = static_cast(ptr); - this_ptr->Run(); - return NULL; - } - - SbThread thread_; - - AbstractTestThread(const AbstractTestThread&) = delete; - void operator=(const AbstractTestThread&) = delete; -}; - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_NPLB_THREAD_HELPERS_H_ diff --git a/starboard/nplb/thread_is_equal_test.cc b/starboard/nplb/thread_is_equal_test.cc deleted file mode 100644 index 5ab5ffd24b51..000000000000 --- a/starboard/nplb/thread_is_equal_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadIsEqualTest, Everything) { - EXPECT_TRUE(SbThreadIsEqual(SbThreadGetCurrent(), SbThreadGetCurrent())); - - SbThread thread = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, AddOneEntryPoint, NULL); - EXPECT_TRUE(SbThreadIsValid(thread)); - - EXPECT_TRUE(SbThreadIsEqual(thread, thread)); - EXPECT_FALSE(SbThreadIsEqual(SbThreadGetCurrent(), thread)); - EXPECT_FALSE(SbThreadIsEqual(thread, SbThreadGetCurrent())); - - EXPECT_TRUE(SbThreadJoin(thread, NULL)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_join_test.cc b/starboard/nplb/thread_join_test.cc deleted file mode 100644 index bf951043c179..000000000000 --- a/starboard/nplb/thread_join_test.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include - -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbThreadJoinTest, RainyDayInvalid) { - void* result = NULL; - EXPECT_FALSE(SbThreadJoin(kSbThreadInvalid, NULL)); - EXPECT_FALSE(SbThreadJoin(kSbThreadInvalid, &result)); - EXPECT_EQ(NULL, result); -} - -// Tests the expectation that SbThreadJoin() will block until -// the thread function has been run. -TEST(SbThreadLocalValueTest, ThreadJoinWaitsForFunctionRun) { - // Thread functionality needs to bind to functions. In C++11 we'd use a - // lambda function to tie everything together locally, but this - // function-scoped struct with static function emulates this functionality - // pretty well. - struct LocalStatic { - static void* ThreadEntryPoint(void* input) { - int* value = static_cast(input); - static const int64_t kSleepTime = 10'000; // 10 ms. - // Wait to write the value to increase likelihood of catching - // a race condition. - usleep(kSleepTime); - (*value)++; - return NULL; - } - }; - - // Try to increase likelihood of a race condition by running multiple times. - for (int i = 0; i < 10; ++i) { - int num_times_thread_entry_point_run = 0; - SbThread thread = - SbThreadCreate(0, // Signals automatic thread stack size. - kSbThreadNoPriority, // Signals default priority. - kSbThreadNoAffinity, // Signals default affinity. - true, // joinable thread. - "TestThread", LocalStatic::ThreadEntryPoint, - &num_times_thread_entry_point_run); - - ASSERT_NE(kSbThreadInvalid, thread) << "Thread creation not successful"; - ASSERT_TRUE(SbThreadJoin(thread, NULL)); - - ASSERT_EQ(1, num_times_thread_entry_point_run) - << "Expected SbThreadJoin() to be blocked until ThreadFunction runs."; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_local_value_test.cc b/starboard/nplb/thread_local_value_test.cc deleted file mode 100644 index c76f8989f4d5..000000000000 --- a/starboard/nplb/thread_local_value_test.cc +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration_constants.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct ThreadLocalValue { - ThreadLocalValue() : destroyed(false) {} - bool destroyed; -}; - -struct Context { - Context() : key(), in_value(), out_value(), destroyed_before_exit(false) {} - - SbThreadLocalKey key; - void* in_value; - void* out_value; - bool destroyed_before_exit; -}; - -void DestroyThreadLocalValue(void* value) { - ThreadLocalValue* thread_local_value = static_cast(value); - thread_local_value->destroyed = true; -} - -void* EntryPoint(void* context) { - Context* real_context = static_cast(context); - SbThreadSetLocalValue(real_context->key, real_context->in_value); - real_context->out_value = SbThreadGetLocalValue(real_context->key); - ThreadLocalValue* thread_local_value = - static_cast(real_context->out_value); - real_context->destroyed_before_exit = thread_local_value->destroyed; - - return NULL; -} - -void DoSunnyDayTest(bool use_destructor) { - const int kThreads = 16; - ThreadLocalValue values[kThreads]; - Context contexts[kThreads]; - SbThread threads[kThreads]; - ThreadLocalValue my_value; - - SbThreadLocalKey key = - SbThreadCreateLocalKey(use_destructor ? DestroyThreadLocalValue : NULL); - EXPECT_TRUE(SbThreadIsValidLocalKey(key)); - SbThreadSetLocalValue(key, &my_value); - for (int i = 0; i < kThreads; ++i) { - contexts[i].key = key; - contexts[i].in_value = &values[i]; - } - - for (int i = 0; i < kThreads; ++i) { - threads[i] = SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, - true, NULL, EntryPoint, &contexts[i]); - } - - for (int i = 0; i < kThreads; ++i) { - EXPECT_TRUE(SbThreadIsValid(threads[i])); - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - EXPECT_EQ(contexts[i].in_value, contexts[i].out_value); - - // The destructor for all thread-local values will be called at thread exit - // time. - EXPECT_FALSE(contexts[i].destroyed_before_exit); - if (use_destructor) { - EXPECT_TRUE(values[i].destroyed); - } else { - EXPECT_FALSE(values[i].destroyed); - } - } - - EXPECT_FALSE(my_value.destroyed); - SbThreadDestroyLocalKey(key); - - // The destructor will never be called on my_value. - EXPECT_FALSE(my_value.destroyed); -} - -// Helper function that ensures that the returned key is not recycled. -SbThreadLocalKey CreateTLSKey_NoRecycle(SbThreadLocalDestructor dtor) { - SbThreadLocalKey key = SbThreadCreateLocalKey(NULL); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - // Some Starboard implementations may recycle the original key, so this test - // ensures that in that case it will be reset to NULL. - SbThreadSetLocalValue(key, reinterpret_cast(1)); - SbThreadDestroyLocalKey(key); - key = SbThreadCreateLocalKey(DestroyThreadLocalValue); - return key; -} - -// Tests the expectation that thread at-exit destructors don't -// run for ThreadLocal pointers that are set to NULL. -TEST(SbThreadLocalValueTest, NoDestructorsForNullValue) { - static int s_num_destructor_calls = 0; // Must be initialized to 0. - s_num_destructor_calls = 0; // Allows test to be re-run. - - // Thread functionality needs to bind to functions. In C++11 we'd use a - // lambda function to tie everything together locally, but this - // function-scoped struct with static members emulates this functionality - // pretty well. - struct LocalStatic { - // Used as a fake destructor for thread-local-storage objects in this - // test. - static void CountsDestructorCalls(void* value) { s_num_destructor_calls++; } - - // Sets a thread local non-NULL value, and then sets it back to NULL. - static void* ThreadEntryPoint(void* ptr) { - SbThreadLocalKey key = *static_cast(ptr); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - // Set the value and then NULL it out. We expect that because the final - // value set was NULL, that the destructor attached to the thread's - // at-exit function will not run. - SbThreadSetLocalValue(key, reinterpret_cast(1)); - SbThreadSetLocalValue(key, NULL); - return NULL; - } - }; - - // Setup the thread key and bind the fake test destructor. - SbThreadLocalKey key = - CreateTLSKey_NoRecycle(LocalStatic::CountsDestructorCalls); - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - - // Spawn the thread. - SbThread thread = SbThreadCreate( - 0, // Signals automatic thread stack size. - kSbThreadNoPriority, // Signals default priority. - kSbThreadNoAffinity, // Signals default affinity. - true, // joinable thread. - "TestThread", LocalStatic::ThreadEntryPoint, static_cast(&key)); - - ASSERT_NE(kSbThreadInvalid, thread) << "Thread creation not successful"; - // 2nd param is return value from ThreadEntryPoint, which is always NULL. - ASSERT_TRUE(SbThreadJoin(thread, NULL)); - - // No destructors should have run. - EXPECT_EQ(0, s_num_destructor_calls); - - SbThreadDestroyLocalKey(key); -} - -TEST(SbThreadLocalValueTest, SunnyDay) { - DoSunnyDayTest(true); -} - -TEST(SbThreadLocalValueTest, SunnyDayNoDestructor) { - DoSunnyDayTest(false); -} - -TEST(SbThreadLocalValueTest, SunnyDayFreshlyCreatedValuesAreNull) { - SbThreadLocalKey key = CreateTLSKey_NoRecycle(NULL); // NULL dtor. - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - - EXPECT_EQ(NULL, SbThreadGetLocalValue(key)); - SbThreadDestroyLocalKey(key); -} - -TEST(SbThreadLocalValueTest, SunnyDayMany) { - const int kMany = (2 * kSbMaxThreadLocalKeys) / 3; - std::vector keys(kMany); - - for (int i = 0; i < kMany; ++i) { - keys[i] = SbThreadCreateLocalKey(NULL); - EXPECT_TRUE(SbThreadIsValidLocalKey(keys[i])) << "key #" << i; - } - - for (int i = 0; i < kMany; ++i) { - SbThreadDestroyLocalKey(keys[i]); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/thread_sampler_test.cc b/starboard/nplb/thread_sampler_test.cc index 65f90fc37dbc..4d58631a3a3d 100644 --- a/starboard/nplb/thread_sampler_test.cc +++ b/starboard/nplb/thread_sampler_test.cc @@ -19,11 +19,7 @@ #include "starboard/common/log.h" #include "starboard/common/time.h" -#if SB_API_VERSION < 16 -#include "starboard/nplb/thread_helpers.h" -#else #include "starboard/nplb/posix_compliance/posix_thread_helpers.h" -#endif #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -31,11 +27,7 @@ namespace starboard { namespace nplb { namespace { -#if SB_API_VERSION < 16 -class CountingThread : public AbstractTestThread { -#else class CountingThread : public posix::AbstractTestThread { -#endif public: ~CountingThread() { Stop(); } @@ -73,12 +65,7 @@ TEST(ThreadSamplerTest, RainyDayCreateSamplerInvalidThread) { // Creating a sampler for an invalid thread should not succeed, and even // without without calling |SbThreadSamplerDelete| ASAN should not detect a // memory leak. - -#if SB_API_VERSION < 16 - SbThreadSampler sampler = SbThreadSamplerCreate(kSbThreadInvalid); -#else SbThreadSampler sampler = SbThreadSamplerCreate(0); -#endif EXPECT_FALSE(SbThreadSamplerIsValid(sampler)); } diff --git a/starboard/nplb/thread_set_name_test.cc b/starboard/nplb/thread_set_name_test.cc deleted file mode 100644 index 8419dc51e248..000000000000 --- a/starboard/nplb/thread_set_name_test.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Thread joining is mostly tested in the other tests. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -struct Context { - std::string got_name1; - std::string name_to_set; - std::string got_name2; -}; - -// Gets the thread's name and sets it in the context. -void* SetThreadNameEntryPoint(void* context) { - char name[4096] = {0}; - Context* real_context = static_cast(context); - - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - real_context->got_name1 = name; - - SbThreadSetName(real_context->name_to_set.c_str()); - - SbThreadGetName(name, SB_ARRAY_SIZE_INT(name)); - real_context->got_name2 = name; - - return NULL; -} - -TEST(SbThreadSetNameTest, SunnyDay) { - Context context; - context.name_to_set = kAltThreadName; - SbThread thread = - SbThreadCreate(0, kSbThreadNoPriority, kSbThreadNoAffinity, true, - kThreadName, SetThreadNameEntryPoint, &context); - EXPECT_TRUE(SbThreadIsValid(thread)); - EXPECT_TRUE(SbThreadJoin(thread, NULL)); - EXPECT_EQ(kThreadName, context.got_name1); - EXPECT_EQ(kAltThreadName, context.got_name2); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/thread_sleep_test.cc b/starboard/nplb/thread_sleep_test.cc deleted file mode 100644 index 1a71668be7ee..000000000000 --- a/starboard/nplb/thread_sleep_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/time.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 - -namespace starboard { -namespace nplb { -namespace { - -// Allow millisecond-level precision. -const int64_t kPrecision = 1000; // 1ms - -TEST(SbThreadSleepTest, SunnyDay) { - SbThreadSleep(0); - // Well, my work here is done. -} - -// My strategy here is to sleep for an amount of time, and ensure that AT LEAST -// that amount of time has passed. There's really no upper bound for how late -// the thread can wake up, something I completely sympathize with. -TEST(SbThreadSleepTest, SunnyDayAtLeastDelay) { - const int kTrials = 12; - const int64_t one = 1; - for (int trial = 0; trial < kTrials; ++trial) { - // This tests several delays, between about 15 to about 4 milliseconds. - const int64_t kDelay = 1'000'000LL / (one << ((trial % 3) + 6)); - int64_t start = CurrentMonotonicTime(); - SbThreadSleep(kDelay); - int64_t end = CurrentMonotonicTime(); - EXPECT_LE(start + kDelay, end + kPrecision) - << "Trial " << trial << ", kDelay=" << kDelay; - } -} - -TEST(SbThreadSleepTest, RainyDayNegativeDuration) { - const int kTrials = 128; - for (int trial = 0; trial < kTrials; ++trial) { - int64_t start = CurrentMonotonicTime(); - SbThreadSleep(-1'000'000); - EXPECT_GT(200'000, CurrentMonotonicTime() - start) << "Trial " << trial; - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 15 diff --git a/starboard/nplb/thread_yield_test.cc b/starboard/nplb/thread_yield_test.cc deleted file mode 100644 index fbbe5c4f1694..000000000000 --- a/starboard/nplb/thread_yield_test.cc +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/time.h" -#include "starboard/nplb/thread_helpers.h" -#include "starboard/thread.h" -#include "testing/gtest/include/gtest/gtest.h" - -#if SB_API_VERSION < 16 - -namespace starboard { -namespace nplb { -namespace { - -// Returns whether a given index is a yielder for the given trial. We alternate -// whether 0 or 1 is a Yielder to avoid the first-started advantage. -inline bool IsYielder(int trial, int index) { - return (trial % 2 ? (index % 2 != 0) : (index % 2 == 0)); -} - -// The more loops, the more the yielders should fall behind. -const int kLoops = 10000; - -void* YieldingEntryPoint(void* context) { - for (int i = 0; i < kLoops; ++i) { - SbThreadYield(); - } - - int64_t* end_time = static_cast(context); - *end_time = CurrentMonotonicTime(); - return NULL; -} - -void* UnyieldingEntryPoint(void* context) { - for (int i = 0; i < kLoops; ++i) { - DoNotYield(); - } - - int64_t* end_time = static_cast(context); - *end_time = CurrentMonotonicTime(); - return NULL; -} - -TEST(SbThreadYieldTest, SunnyDay) { - SbThreadYield(); - // Well, my work here is done. -} - -// Okay, okay, I'm not sure how else to test this other than to try to make sure -// that a thread that yields generally gets more CPU time than one that doesn't. -// -// I did test that racing Unyielding threads against each other causes this test -// to fail regularly. By rerunning the test kTrials times, and by swapping which -// thread gets started first, I hope to make this inherently flaky test not -// flaky. -// -// Note: This test may still be flaky, but it should be a lot less flaky than -// before. If this test starts flaking again, tag it with FLAKY_ again. -TEST(SbThreadYieldTest, SunnyDayRace) { - const int kTrials = 20; - int passes = 0; - for (int trial = 0; trial < kTrials; ++trial) { - // Pin to CPU 0 to make sure the threads don't get distributed onto other - // cores. - SbThreadAffinity affinity = 0; - // We want enough racers such that the threads must contend for cpu time, - // and enough data for the averages to be consistently divergent. - const int64_t kRacers = 32; - SbThread threads[kRacers]; - int64_t end_times[kRacers] = {0}; - for (int i = 0; i < kRacers; ++i) { - threads[i] = SbThreadCreate( - 0, kSbThreadNoPriority, affinity, true, NULL, - (IsYielder(trial, i) ? YieldingEntryPoint : UnyieldingEntryPoint), - &(end_times[i])); - } - - for (int i = 0; i < kRacers; ++i) { - EXPECT_TRUE(SbThreadIsValid(threads[i])) << "thread = " << threads[i]; - } - - for (int i = 0; i < kRacers; ++i) { - EXPECT_TRUE(SbThreadJoin(threads[i], NULL)); - } - - // On average, Unyielders should finish sooner than Yielders. - int64_t average_yielder = 0; - int64_t average_unyielder = 0; - const int64_t kRacersPerGroup = kRacers / 2; - for (int i = 0; i < kRacers; ++i) { - if (IsYielder(trial, i)) { - average_yielder += end_times[i] / kRacersPerGroup; - } else { - average_unyielder += end_times[i] / kRacersPerGroup; - } - } - - // If unyielders took less time then yielders, on average, then we consider - // the trial a pass. - if (average_unyielder < average_yielder) { - ++passes; - } - } - - // We expect at least 2/3 of the trials to pass. - EXPECT_LT(kTrials * 2 / 3, passes); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_constants.h b/starboard/nplb/time_constants.h index 348424741e14..a8c828acc1c7 100644 --- a/starboard/nplb/time_constants.h +++ b/starboard/nplb/time_constants.h @@ -15,53 +15,6 @@ #ifndef STARBOARD_NPLB_TIME_CONSTANTS_H_ #define STARBOARD_NPLB_TIME_CONSTANTS_H_ -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -namespace starboard { -namespace nplb { - -static const SbTime kExtraMilliseconds = 123 * kSbTimeMillisecond; -static const SbTime kTestSbTimeYear = 525949 * kSbTimeMinute; - -// 1443121328 in POSIX time is -// Thursday, 9/24/2015 19:02:08 UTC -static const SbTime kTestTimePositive = SbTimeFromPosix( - SB_INT64_C(1443121328) * kSbTimeSecond + kExtraMilliseconds); - -// 0 in POSIX time is -// Thursday, 1/1/1970 00:00:00 UTC -static const SbTime kTestTimePosixZero = - SbTimeFromPosix(SB_INT64_C(0) * kSbTimeSecond); - -// -771942639 in POSIX time is -// Monday, 7/16/1945 11:29:21 UTC -static const SbTime kTestTimePosixNegative = - SbTimeFromPosix(SB_INT64_C(-771942639) * kSbTimeSecond); - -// 0 in Windows time is -// Monday, 1/1/1601 00:00:00 UTC -static const SbTime kTestTimeWindowsZero = 0; - -// -15065654400 in POSIX time is -// Wednesday, 8/3/1492 00:00:00 UTC -static const SbTime kTestTimeWindowsNegative = - SbTimeFromPosix(SB_INT64_C(-15065654400) * kSbTimeSecond); - -// 1600970155 in POSIX time is -// Thursday, 9/24/2020 17:55:55 UTC -// NOTE: Update this value once every 25 or so years. -static const SbTime kTestTimeWritten = - SbTimeFromPosix(SB_INT64_C(1600970155) * kSbTimeSecond); - -// 25 years after the time this test was written. -static const SbTime kTestTimePastWritten = - SbTimeFromPosix(kTestTimeWritten + (25 * kTestSbTimeYear)); - -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_NPLB_TIME_CONSTANTS_H_ diff --git a/starboard/nplb/time_get_monotonic_now_test.cc b/starboard/nplb/time_get_monotonic_now_test.cc deleted file mode 100644 index d984ecd77b1d..000000000000 --- a/starboard/nplb/time_get_monotonic_now_test.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/time_constants.h" -#include "starboard/time.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeGetMonotonicNowTest, IsMonotonic) { - const int kTrials = 100; - for (int trial = 0; trial < kTrials; ++trial) { - SbTimeMonotonic time1 = SbTimeGetMonotonicNow(); - SbTime clockStart = SbTimeGetNow(); - - // Spin tightly until time changes. - SbTimeMonotonic time2 = 0; - while (true) { - time2 = SbTimeGetMonotonicNow(); - if (time2 != time1) { - EXPECT_GT(time2, time1); - EXPECT_LT(time2 - time1, kSbTimeSecond); - return; - } - - // If time hasn't increased within a second, our "high-resolution" - // monotonic timer is broken. - if (SbTimeGetNow() - clockStart >= kSbTimeSecond) { - GTEST_FAIL() << "SbTimeGetMonotonicNow() hasn't changed within a " - << "second."; - return; - } - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_get_now_test.cc b/starboard/nplb/time_get_now_test.cc deleted file mode 100644 index 32d9f4265e11..000000000000 --- a/starboard/nplb/time_get_now_test.cc +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/nplb/time_constants.h" -#include "starboard/time.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeGetNowTest, IsKindOfSane) { - SbTime time = SbTimeGetNow(); - - // Now should be after the time I wrote this test. - EXPECT_GT(time, kTestTimeWritten); - - // And it should be before 5 years after I wrote this test, at least for a - // while. - EXPECT_LT(time, kTestTimePastWritten); -} - -TEST(SbTimeGetNowTest, HasDecentResolution) { - const int kNumIterations = 100; - for (int i = 0; i < kNumIterations; ++i) { - SbTime time1 = SbTimeGetNow(); - SbTimeMonotonic timerStart = SbTimeGetMonotonicNow(); - - // Spin tightly until time increments. - SbTime time2 = 0; - while (true) { - time2 = SbTimeGetNow(); - if (time2 != time1) { - EXPECT_NE(time2, time1); - break; - } - - // If time hasn't changed within a second, that's beyond low resolution. - if ((SbTimeGetMonotonicNow() - timerStart) >= kSbTimeSecond) { - GTEST_FAIL() << "SbTimeGetNow() hasn't changed within a second."; - break; - } - } - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/time_narrow_test.cc b/starboard/nplb/time_narrow_test.cc deleted file mode 100644 index ee6f3233bd12..000000000000 --- a/starboard/nplb/time_narrow_test.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbTimeNarrowTest, SunnyDay) { - EXPECT_EQ(0, SbTimeNarrow(1, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 1000)); - EXPECT_EQ(1, SbTimeNarrow(1000, 1000)); - EXPECT_EQ(1000, SbTimeNarrow(1000000, 1000)); - EXPECT_EQ(-1000, SbTimeNarrow(-1000000, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1000, 1000)); - EXPECT_EQ(-2, SbTimeNarrow(-1001, 1000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 1000000)); - EXPECT_EQ(-1, SbTimeNarrow(-1, 7)); - EXPECT_EQ(-2, SbTimeNarrow(-8, 7)); - EXPECT_EQ(1, SbTimeNarrow(8, 7)); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/ui_navigation_test.cc b/starboard/nplb/ui_navigation_test.cc index fa24eec71693..52f7d3f45cca 100644 --- a/starboard/nplb/ui_navigation_test.cc +++ b/starboard/nplb/ui_navigation_test.cc @@ -12,12 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#if SB_API_VERSION < 16 -#include "starboard/ui_navigation.h" -#else #include "starboard/extension/ui_navigation.h" #include "starboard/system.h" -#endif // SB_API_VERSION #include "testing/gtest/include/gtest/gtest.h" namespace starboard { @@ -26,14 +22,9 @@ namespace { // This verifies that the UI navigation API is not implemented. TEST(UiNavigationTest, GetInterface) { -#if SB_API_VERSION < 16 - SbUiNavInterface interface; - EXPECT_FALSE(SbUiNavGetInterface(&interface)); -#else const SbUiNavInterface* interface = static_cast( SbSystemGetExtension(kCobaltExtensionUiNavigationName)); EXPECT_FALSE(interface != nullptr); -#endif // SB_API_VERSION } } // namespace. diff --git a/starboard/nplb/user_get_current_test.cc b/starboard/nplb/user_get_current_test.cc deleted file mode 100644 index 705adcf82269..000000000000 --- a/starboard/nplb/user_get_current_test.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbUserGetCurrentTest, SunnyDay) { - SbUser users[10] = {0}; - int result = SbUserGetSignedIn(users, SB_ARRAY_SIZE_INT(users)); - EXPECT_LE(0, result); - - SbUser current = SbUserGetCurrent(); - if (result > 0) { - EXPECT_NE(kSbUserInvalid, current); - } else { - EXPECT_EQ(kSbUserInvalid, current); - } -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/nplb/user_get_property_test.cc b/starboard/nplb/user_get_property_test.cc deleted file mode 100644 index ee09ad703db9..000000000000 --- a/starboard/nplb/user_get_property_test.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -void TestProperty(SbUser user, SbUserPropertyId property_id) { - int size = SbUserGetPropertySize(user, property_id); - EXPECT_LE(0, size); - - if (size > 0) { - char* property = new char[size + 10]; - memset(property, 0, size + 10); - EXPECT_TRUE(SbUserGetProperty(user, property_id, property, size)); - for (int i = 0; i < size - 1; ++i) { - EXPECT_NE(property[i], '\0') << "position " << i; - } - for (int i = size - 1; i < size + 10; ++i) { - EXPECT_EQ(property[i], '\0') << "position " << i; - } - delete[] property; - } else { - char property[10] = {0}; - bool result = SbUserGetProperty(user, property_id, property, 10); - for (int i = 0; i < size; ++i) { - EXPECT_EQ(property[i], '\0') << "position " << i; - } - } -} - -TEST(SbUserGetPropertyTest, SunnyDay) { - SbUser current = SbUserGetCurrent(); - if (!SbUserIsValid(current)) { - // Sadly, we can't really test in this case. - return; - } - - TestProperty(current, kSbUserPropertyUserName); - TestProperty(current, kSbUserPropertyUserId); -#if SB_API_VERSION < 16 - TestProperty(current, kSbUserPropertyAvatarUrl); -#endif -} - -TEST(SbUserGetPropertyTest, MultipleTimes) { - SbUser current = SbUserGetCurrent(); - if (!SbUserIsValid(current)) { - // Sadly, we can't really test in this case. - return; - } - - TestProperty(current, kSbUserPropertyUserName); - TestProperty(current, kSbUserPropertyUserName); - - TestProperty(current, kSbUserPropertyUserId); - TestProperty(current, kSbUserPropertyUserId); - -#if SB_API_VERSION < 16 - TestProperty(current, kSbUserPropertyAvatarUrl); - TestProperty(current, kSbUserPropertyAvatarUrl); -#endif -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/nplb/user_get_signed_in_test.cc b/starboard/nplb/user_get_signed_in_test.cc deleted file mode 100644 index f062f843d3d5..000000000000 --- a/starboard/nplb/user_get_signed_in_test.cc +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace nplb { -namespace { - -TEST(SbUserGetSignedInTest, SunnyDay) { - SbUser users[100] = {0}; - int result = SbUserGetSignedIn(users + 10, SB_ARRAY_SIZE_INT(users) - 10); - EXPECT_LE(0, result); - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(kSbUserInvalid, users[i]); - } - - for (int i = 0; i < result; ++i) { - EXPECT_NE(kSbUserInvalid, users[10 + i]); - } - - for (int i = 0; i < 10; ++i) { - EXPECT_EQ(kSbUserInvalid, users[10 + result + i]); - } -} - -TEST(SbUserGetSignedInTest, NullUsers) { - SbUser users[100] = {0}; - int result = SbUserGetSignedIn(users, SB_ARRAY_SIZE_INT(users)); - EXPECT_LE(0, result); - - int result2 = SbUserGetSignedIn(NULL, SB_ARRAY_SIZE_INT(users)); - EXPECT_EQ(result, result2); - - SbUser users2[100] = {0}; - int result3 = SbUserGetSignedIn(users2, 0); - EXPECT_EQ(result, result3); - for (int i = 0; i < SB_ARRAY_SIZE_INT(users2); ++i) { - EXPECT_EQ(kSbUserInvalid, users2[i]); - } - int result4 = SbUserGetSignedIn(NULL, 0); - EXPECT_EQ(result, result4); -} - -} // namespace -} // namespace nplb -} // namespace starboard - -#endif diff --git a/starboard/once.h b/starboard/once.h index 526e028fa644..d2a54c09a483 100644 --- a/starboard/once.h +++ b/starboard/once.h @@ -20,81 +20,6 @@ #ifndef STARBOARD_ONCE_H_ #define STARBOARD_ONCE_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Max size of the SbOnceControl type. -#define SB_ONCE_MAX_SIZE 64 - -// An opaque handle to a once control type with -// reserved memory buffer of size SB_ONCE_MAX_SIZE and -// aligned at void pointer type. -typedef union SbOnceControl { - // Reserved memory in which the implementation should map its - // native once control variable type. - uint8_t once_buffer[SB_ONCE_MAX_SIZE]; - - // Guarantees alignment of the type to a void pointer. - void* ptr; -} SbOnceControl; - -#ifdef __cplusplus -#define SB_ONCE_INITIALIZER \ - {} -#else -#define SB_ONCE_INITIALIZER \ - { 0 } -#endif - -// Function pointer type for methods that can be called via the SbOnce() system. -typedef void (*SbOnceInitRoutine)(void); - -// Thread-safely runs |init_routine| only once. -// - If this |once_control| has not run a function yet, this function runs -// |init_routine| in a thread-safe way and then returns |true|. -// - If SbOnce() was called with |once_control| before, the function returns -// |true| immediately. -// - If |once_control| or |init_routine| is invalid, the function returns -// |false|. -SB_EXPORT bool SbOnce(SbOnceControl* once_control, - SbOnceInitRoutine init_routine); - -#ifdef __cplusplus -// Defines a function that will initialize the indicated type once and return -// it. This initialization is thread safe if the type being created is side -// effect free. -// -// These macros CAN ONLY BE USED IN A CC file, never in a header file. -// -// Example (in cc file): -// SB_ONCE_INITIALIZE_FUNCTION(MyClass, GetOrCreateMyClass) -// .. -// MyClass* instance = GetOrCreateMyClass(); -// MyClass* instance2 = GetOrCreateMyClass(); -// DCHECK_EQ(instance, instance2); -#define SB_ONCE_INITIALIZE_FUNCTION(Type, FunctionName) \ - Type* FunctionName() { \ - static SbOnceControl s_once_flag = SB_ONCE_INITIALIZER; \ - static Type* s_singleton = NULL; \ - struct Local { \ - static void Init() { \ - s_singleton = new Type(); \ - } \ - }; \ - SbOnce(&s_once_flag, Local::Init); \ - return s_singleton; \ - } -#endif // __cplusplus - -#ifdef __cplusplus -} -#endif - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_ONCE_H_ diff --git a/starboard/raspi/shared/BUILD.gn b/starboard/raspi/shared/BUILD.gn index fcfc835ded38..4644c45355ae 100644 --- a/starboard/raspi/shared/BUILD.gn +++ b/starboard/raspi/shared/BUILD.gn @@ -50,8 +50,6 @@ static_library("starboard_platform_sources") { "//starboard/raspi/shared/open_max/decode_target_release.cc", "//starboard/raspi/shared/open_max/dispmanx_resource_pool.cc", "//starboard/raspi/shared/open_max/dispmanx_resource_pool.h", - "//starboard/raspi/shared/open_max/image_decode.cc", - "//starboard/raspi/shared/open_max/image_is_decode_supported.cc", "//starboard/raspi/shared/open_max/open_max_component.cc", "//starboard/raspi/shared/open_max/open_max_component.h", "//starboard/raspi/shared/open_max/open_max_component_base.cc", @@ -82,13 +80,9 @@ static_library("starboard_platform_sources") { "//starboard/shared/alsa/alsa_util.h", "//starboard/shared/egl/system_egl.cc", "//starboard/shared/gcc/atomic_gcc_public.h", - "//starboard/shared/iso/directory_close.cc", - "//starboard/shared/iso/directory_get_next.cc", - "//starboard/shared/iso/directory_open.cc", "//starboard/shared/iso/memory_allocate_unchecked.cc", "//starboard/shared/iso/memory_free.cc", "//starboard/shared/iso/memory_reallocate_unchecked.cc", - "//starboard/shared/iso/string_scan.cc", "//starboard/shared/libevent/socket_waiter_add.cc", "//starboard/shared/libevent/socket_waiter_create.cc", "//starboard/shared/libevent/socket_waiter_destroy.cc", @@ -97,7 +91,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/libevent/socket_waiter_wait.cc", "//starboard/shared/libevent/socket_waiter_wait_timed.cc", "//starboard/shared/libevent/socket_waiter_wake_up.cc", - "//starboard/shared/linux/byte_swap.cc", "//starboard/shared/linux/cpu_features_get.cc", "//starboard/shared/linux/dev_input/dev_input.cc", "//starboard/shared/linux/get_home_directory.cc", @@ -109,41 +102,17 @@ static_library("starboard_platform_sources") { "//starboard/shared/linux/system_is_debugger_attached.cc", "//starboard/shared/linux/system_symbolize.cc", "//starboard/shared/linux/thread_get_id.cc", - "//starboard/shared/linux/thread_get_name.cc", - "//starboard/shared/linux/thread_set_name.cc", "//starboard/shared/linux/time_zone_get_name.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", "//starboard/shared/opus/opus_audio_decoder.cc", "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/directory_create.cc", "//starboard/shared/posix/environment.cc", "//starboard/shared/posix/file_atomic_replace.cc", - "//starboard/shared/posix/file_can_open.cc", - "//starboard/shared/posix/file_close.cc", - "//starboard/shared/posix/file_delete.cc", - "//starboard/shared/posix/file_exists.cc", - "//starboard/shared/posix/file_flush.cc", - "//starboard/shared/posix/file_get_info.cc", - "//starboard/shared/posix/file_get_path_info.cc", - "//starboard/shared/posix/file_open.cc", - "//starboard/shared/posix/file_read.cc", - "//starboard/shared/posix/file_seek.cc", - "//starboard/shared/posix/file_truncate.cc", - "//starboard/shared/posix/file_write.cc", "//starboard/shared/posix/log.cc", "//starboard/shared/posix/log_flush.cc", "//starboard/shared/posix/log_format.cc", - "//starboard/shared/posix/log_is_tty.cc", "//starboard/shared/posix/log_raw.cc", "//starboard/shared/posix/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/posix/memory_flush.cc", "//starboard/shared/posix/memory_free_aligned.cc", - "//starboard/shared/posix/memory_map.cc", - "//starboard/shared/posix/memory_protect.cc", - "//starboard/shared/posix/memory_unmap.cc", "//starboard/shared/posix/page_internal.cc", "//starboard/shared/posix/set_non_blocking_internal.cc", "//starboard/shared/posix/socket_accept.cc", @@ -172,10 +141,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/socket_set_tcp_no_delay.cc", "//starboard/shared/posix/socket_set_tcp_window_scaling.cc", "//starboard/shared/posix/storage_write_record.cc", - "//starboard/shared/posix/string_compare_no_case.cc", - "//starboard/shared/posix/string_compare_no_case_n.cc", - "//starboard/shared/posix/string_format.cc", - "//starboard/shared/posix/string_format_wide.cc", "//starboard/shared/posix/system_break_into_debugger.cc", "//starboard/shared/posix/system_clear_last_error.cc", "//starboard/shared/posix/system_get_error_string.cc", @@ -183,35 +148,11 @@ static_library("starboard_platform_sources") { "//starboard/shared/posix/system_get_locale_id.cc", "//starboard/shared/posix/system_get_number_of_processors.cc", "//starboard/shared/posix/thread_sleep.cc", - "//starboard/shared/posix/time_get_monotonic_now.cc", - "//starboard/shared/posix/time_get_monotonic_thread_now.cc", - "//starboard/shared/posix/time_get_now.cc", - "//starboard/shared/posix/time_is_time_thread_now_supported.cc", "//starboard/shared/posix/time_zone_get_current.cc", - "//starboard/shared/pthread/condition_variable_broadcast.cc", - "//starboard/shared/pthread/condition_variable_create.cc", - "//starboard/shared/pthread/condition_variable_destroy.cc", - "//starboard/shared/pthread/condition_variable_signal.cc", - "//starboard/shared/pthread/condition_variable_wait.cc", - "//starboard/shared/pthread/condition_variable_wait_timed.cc", - "//starboard/shared/pthread/mutex_acquire.cc", - "//starboard/shared/pthread/mutex_acquire_try.cc", - "//starboard/shared/pthread/mutex_create.cc", - "//starboard/shared/pthread/mutex_destroy.cc", - "//starboard/shared/pthread/mutex_release.cc", - "//starboard/shared/pthread/once.cc", "//starboard/shared/pthread/thread_context_get_pointer.cc", "//starboard/shared/pthread/thread_context_internal.cc", "//starboard/shared/pthread/thread_context_internal.h", - "//starboard/shared/pthread/thread_create.cc", - "//starboard/shared/pthread/thread_create_local_key.cc", "//starboard/shared/pthread/thread_create_priority.h", - "//starboard/shared/pthread/thread_destroy_local_key.cc", - "//starboard/shared/pthread/thread_detach.cc", - "//starboard/shared/pthread/thread_get_current.cc", - "//starboard/shared/pthread/thread_get_local_value.cc", - "//starboard/shared/pthread/thread_is_equal.cc", - "//starboard/shared/pthread/thread_join.cc", "//starboard/shared/pthread/thread_sampler_create.cc", "//starboard/shared/pthread/thread_sampler_destroy.cc", "//starboard/shared/pthread/thread_sampler_freeze.cc", @@ -219,7 +160,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/pthread/thread_sampler_internal.h", "//starboard/shared/pthread/thread_sampler_is_supported.cc", "//starboard/shared/pthread/thread_sampler_thaw.cc", - "//starboard/shared/pthread/thread_set_local_value.cc", "//starboard/shared/pthread/thread_yield.cc", "//starboard/shared/signal/crash_signals.cc", "//starboard/shared/signal/crash_signals.h", @@ -246,12 +186,10 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/crash_handler.cc", "//starboard/shared/starboard/crash_handler.h", - "//starboard/shared/starboard/directory_can_open.cc", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.cc", "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", "//starboard/shared/starboard/file_storage/storage_close_record.cc", "//starboard/shared/starboard/file_storage/storage_delete_record.cc", "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", @@ -269,7 +207,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_max_buffer_capacity.cc", "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", @@ -277,10 +214,8 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/media/media_is_audio_supported_aac_and_opus.cc", "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/new.cc", "//starboard/shared/starboard/queue_application.cc", - "//starboard/shared/starboard/string_duplicate.cc", "//starboard/shared/starboard/system_get_random_uint64.cc", "//starboard/shared/starboard/system_request_blur.cc", "//starboard/shared/starboard/system_request_focus.cc", @@ -288,10 +223,6 @@ static_library("starboard_platform_sources") { "//starboard/shared/starboard/system_request_stop.cc", "//starboard/shared/starboard/system_supports_resume.cc", "//starboard/shared/starboard/window_set_default_options.cc", - "//starboard/shared/stub/accessibility_get_caption_settings.cc", - "//starboard/shared/stub/accessibility_get_display_settings.cc", - "//starboard/shared/stub/accessibility_get_text_to_speech_settings.cc", - "//starboard/shared/stub/accessibility_set_captions_enabled.cc", "//starboard/shared/stub/drm_close_session.cc", "//starboard/shared/stub/drm_create_system.cc", "//starboard/shared/stub/drm_destroy_system.cc", @@ -317,18 +248,7 @@ static_library("starboard_platform_sources") { "//starboard/shared/stub/system_network_is_disconnected.cc", "//starboard/shared/stub/system_raise_platform_error.cc", "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", "run_starboard_main.cc", ] diff --git a/starboard/raspi/shared/configuration_constants.cc b/starboard/raspi/shared/configuration_constants.cc index 2908227f899b..4326c929ffc4 100644 --- a/starboard/raspi/shared/configuration_constants.cc +++ b/starboard/raspi/shared/configuration_constants.cc @@ -124,11 +124,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/raspi/shared/configuration_public.h b/starboard/raspi/shared/configuration_public.h index 41cb48f2ee9e..8e5723392bd8 100644 --- a/starboard/raspi/shared/configuration_public.h +++ b/starboard/raspi/shared/configuration_public.h @@ -45,32 +45,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Attribute Configuration ----------------------------------------------- - -#if SB_API_VERSION < 16 -// The platform's annotation for forcing a C function to be inlined. -#define SB_C_FORCE_INLINE __inline__ __attribute__((always_inline)) - -// The platform's annotation for marking a C function as suggested to be -// inlined. -#define SB_C_INLINE inline - -// The platform's annotation for marking a symbol as exported outside of the -// current shared library. -#define SB_EXPORT_PLATFORM __attribute__((visibility("default"))) - -// The platform's annotation for marking a symbol as imported from outside of -// the current linking unit. -#define SB_IMPORT_PLATFORM - -// --- Memory Configuration -------------------------------------------------- - -// Whether this platform can map executable memory. Implies SB_HAS_MMAP. This is -// required for platforms that want to JIT. -#define SB_CAN_MAP_EXECUTABLE_MEMORY 1 - -#endif // SB_API_VERSION < 16 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/raspi/shared/open_max/image_decode.cc b/starboard/raspi/shared/open_max/image_decode.cc deleted file mode 100644 index fb417eb13be5..000000000000 --- a/starboard/raspi/shared/open_max/image_decode.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/common/mutex.h" -#include "starboard/raspi/shared/open_max/open_max_image_decode_component.h" - -namespace open_max = starboard::raspi::shared::open_max; - -namespace { -starboard::Mutex decode_lock_; -} - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - SB_CHECK(data); - SB_DCHECK(SbImageIsDecodeSupported(mime_type, format)); - SbDecodeTarget target = kSbDecodeTargetInvalid; - - // Only one image can be decoded at a time by the component. - { - starboard::ScopedLock lock(decode_lock_); - open_max::OpenMaxImageDecodeComponent decoder; - target = decoder.Decode(provider, mime_type, format, data, data_size); - } - - return target; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/raspi/shared/open_max/image_is_decode_supported.cc b/starboard/raspi/shared/open_max/image_is_decode_supported.cc deleted file mode 100644 index f392b8299c8b..000000000000 --- a/starboard/raspi/shared/open_max/image_is_decode_supported.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/raspi/shared/open_max/open_max_image_decode_component.h" -#include "starboard/shared/starboard/application.h" - -namespace open_max = starboard::raspi::shared::open_max; - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - using starboard::shared::starboard::Application; - - auto command_line = Application::Get()->GetCommandLine(); - auto value = command_line->GetSwitchValue("enable_sb_image_decoder"); - // Unfortunately, while openmax image decoding is implemented and supported, - // there is a very sporadic (i.e. around every 1 in 200 image decodes) crash - // bug that will go off. This may be due to a threading issue somewhere, but - // it is not clear right now. So by default we report that we do not support - // Starboard image decoding. - if (value != "true") { - return false; - } - - bool type_supported = - OMX_IMAGE_CodingMax != - open_max::OpenMaxImageDecodeComponent::GetCompressionFormat(mime_type); - return type_supported && format == kSbDecodeTargetFormat1PlaneRGBA; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/iso/directory_close.cc b/starboard/shared/iso/directory_close.cc deleted file mode 100644 index f00b716b9b19..000000000000 --- a/starboard/shared/iso/directory_close.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_close.h" - -bool SbDirectoryClose(SbDirectory directory) { - return ::starboard::shared::iso::impl::SbDirectoryClose(directory); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/directory_get_next.cc b/starboard/shared/iso/directory_get_next.cc deleted file mode 100644 index bfb42cef9672..000000000000 --- a/starboard/shared/iso/directory_get_next.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_get_next.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - return ::starboard::shared::iso::impl::SbDirectoryGetNext( - directory, out_entry, out_entry_size); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/directory_internal.h b/starboard/shared/iso/directory_internal.h deleted file mode 100644 index 81e6961d9b26..000000000000 --- a/starboard/shared/iso/directory_internal.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ -#define STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ - -#include -#include - -#include "starboard/directory.h" -#include "starboard/shared/internal_only.h" - -struct SbDirectoryPrivate { - // The ISO C directory stream handle. - DIR* directory; -}; - -#endif // STARBOARD_SHARED_ISO_DIRECTORY_INTERNAL_H_ diff --git a/starboard/shared/iso/directory_open.cc b/starboard/shared/iso/directory_open.cc deleted file mode 100644 index 3e994f751543..000000000000 --- a/starboard/shared/iso/directory_open.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/shared/iso/directory_internal.h" - -#include "starboard/shared/iso/impl/directory_open.h" - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - return ::starboard::shared::iso::impl::SbDirectoryOpen(path, out_error); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/iso/impl/directory_close.h b/starboard/shared/iso/impl/directory_close.h deleted file mode 100644 index c5182e832386..000000000000 --- a/starboard/shared/iso/impl/directory_close.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -bool SbDirectoryClose(SbDirectory directory) { - if (!directory || !directory->directory) { - return false; - } - - bool result = !closedir(directory->directory); - delete directory; - return result; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_CLOSE_H_ diff --git a/starboard/shared/iso/impl/directory_get_next.h b/starboard/shared/iso/impl/directory_get_next.h deleted file mode 100644 index 877b4e2d3aca..000000000000 --- a/starboard/shared/iso/impl/directory_get_next.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - if (out_entry_size < kSbFileMaxName) { - return false; - } - - if (!directory || !directory->directory || !out_entry) { - return false; - } - - struct dirent dirent_buffer; - struct dirent* dirent; - int result = readdir_r(directory->directory, &dirent_buffer, &dirent); - if (result || !dirent) { - return false; - } - - starboard::strlcpy(out_entry, dirent->d_name, out_entry_size); - return true; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_GET_NEXT_H_ diff --git a/starboard/shared/iso/impl/directory_impl.h b/starboard/shared/iso/impl/directory_impl.h deleted file mode 100644 index 883f29cec328..000000000000 --- a/starboard/shared/iso/impl/directory_impl.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ - -#include "starboard/configuration.h" -#include "starboard/directory.h" - -#include "starboard/shared/internal_only.h" - -// Ensure SbDirectory is typedef'd to a SbDirectoryPrivate* that has a directory -// field. -SB_COMPILE_ASSERT(sizeof(((SbDirectory)0)->directory), - SbDirectoryPrivate_must_have_directory); - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_IMPL_H_ diff --git a/starboard/shared/iso/impl/directory_open.h b/starboard/shared/iso/impl/directory_open.h deleted file mode 100644 index 391bce427b64..000000000000 --- a/starboard/shared/iso/impl/directory_open.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ -#define STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/file.h" - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/iso/impl/directory_impl.h" - -namespace starboard { -namespace shared { -namespace iso { -namespace impl { - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - if (!path) { - if (out_error) { - *out_error = kSbFileErrorNotFound; - } - return kSbDirectoryInvalid; - } - - DIR* dir = opendir(path); - if (!dir) { - if (out_error) { - switch (errno) { - case EACCES: - *out_error = kSbFileErrorAccessDenied; - break; - case ELOOP: - *out_error = kSbFileErrorFailed; - break; - case ENAMETOOLONG: - *out_error = kSbFileErrorInvalidOperation; - break; - case ENOENT: - *out_error = kSbFileErrorNotFound; - break; - case ENOTDIR: - *out_error = kSbFileErrorNotADirectory; - break; - case EMFILE: - case ENFILE: - *out_error = kSbFileErrorTooManyOpened; - break; - } - } - - return kSbDirectoryInvalid; - } - - SbDirectory result = new SbDirectoryPrivate(); - if (!result) { - closedir(dir); - if (out_error) { - *out_error = kSbFileErrorNoMemory; - } - return kSbDirectoryInvalid; - } - - result->directory = dir; - if (out_error) { - *out_error = kSbFileOk; - } - return result; -} - -} // namespace impl -} // namespace iso -} // namespace shared -} // namespace starboard -#endif // SB_API_VERSION < 17 - -#endif // STARBOARD_SHARED_ISO_IMPL_DIRECTORY_OPEN_H_ diff --git a/starboard/shared/iso/string_scan.cc b/starboard/shared/iso/string_scan.cc deleted file mode 100644 index 50c0fd4c60d6..000000000000 --- a/starboard/shared/iso/string_scan.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -#include -#include - -int SbStringScan(const char* buffer, const char* pattern, va_list arguments) { - return vsscanf(buffer, pattern, arguments); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/libjpeg/image_decode.cc b/starboard/shared/libjpeg/image_decode.cc deleted file mode 100644 index ac590d090c2f..000000000000 --- a/starboard/shared/libjpeg/image_decode.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/shared/libjpeg/jpeg_image_decoder.h" - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - if (data == NULL || !SbImageIsDecodeSupported(mime_type, format)) { - return kSbDecodeTargetInvalid; - } - - return starboard::shared::libjpeg::Decode( - provider, format, static_cast(data), data_size); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/libjpeg/image_is_decode_supported.cc b/starboard/shared/libjpeg/image_is_decode_supported.cc deleted file mode 100644 index 9effa2086caa..000000000000 --- a/starboard/shared/libjpeg/image_is_decode_supported.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/image.h" - -#include "starboard/common/string.h" -#include "starboard/decode_target.h" -#include "starboard/shared/starboard/application.h" - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - using starboard::shared::starboard::Application; - - auto command_line = Application::Get()->GetCommandLine(); - auto value = command_line->GetSwitchValue("enable_sb_image_decoder"); - if (value == "true") { - if (format != kSbDecodeTargetFormat1PlaneRGBA && - format != kSbDecodeTargetFormat1PlaneBGRA) { - return false; - } - return strcmp(mime_type, "image/jpeg") == 0; - } else { - return false; - } -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/linux/byte_swap.cc b/starboard/shared/linux/byte_swap.cc deleted file mode 100644 index b2a104c142b2..000000000000 --- a/starboard/shared/linux/byte_swap.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -#include - -int16_t SbByteSwapS16(int16_t value) { - return bswap_16(value); -} - -uint16_t SbByteSwapU16(uint16_t value) { - return bswap_16(value); -} - -int32_t SbByteSwapS32(int32_t value) { - return bswap_32(value); -} - -uint32_t SbByteSwapU32(uint32_t value) { - return bswap_32(value); -} - -int64_t SbByteSwapS64(int64_t value) { - return bswap_64(value); -} - -uint64_t SbByteSwapU64(uint64_t value) { - return bswap_64(value); -} - -#endif diff --git a/starboard/shared/linux/thread_get_name.cc b/starboard/shared/linux/thread_get_name.cc deleted file mode 100644 index e2dfe80c4510..000000000000 --- a/starboard/shared/linux/thread_get_name.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -void SbThreadGetName(char* buffer, int buffer_size) { - pthread_getname_np(pthread_self(), buffer, static_cast(buffer_size)); -} - -#endif diff --git a/starboard/shared/linux/thread_set_name.cc b/starboard/shared/linux/thread_set_name.cc deleted file mode 100644 index fbbe5a689743..000000000000 --- a/starboard/shared/linux/thread_set_name.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" - -#include "starboard/configuration_constants.h" - -void SbThreadSetName(const char* name) { - // We don't want to rename the main thread. - if (SbThreadGetId() == getpid()) { - return; - } - - char buffer[kSbMaxThreadNameLength]; - - if (strlen(name) >= SB_ARRAY_SIZE_INT(buffer)) { - starboard::strlcpy(buffer, name, SB_ARRAY_SIZE_INT(buffer)); - name = buffer; - } - - if (pthread_setname_np(pthread_self(), name) != 0) { - SB_DLOG(ERROR) << "Failed to set thread name to " << name; - } -} - -#endif diff --git a/starboard/shared/nouser/user_get_current.cc b/starboard/shared/nouser/user_get_current.cc deleted file mode 100644 index a2fd18e15875..000000000000 --- a/starboard/shared/nouser/user_get_current.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include "starboard/shared/nouser/user_internal.h" - -// Nouser implementation of getting the current user. We always return a user -// with default attributes. -SbUser SbUserGetCurrent() { - return &starboard::shared::nouser::g_user; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/nouser/user_get_property.cc b/starboard/shared/nouser/user_get_property.cc deleted file mode 100644 index 9cbdaa4a359f..000000000000 --- a/starboard/shared/nouser/user_get_property.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/nouser/user_internal.h" - -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) { - if (!SbUserIsValid(user)) { - return 0; - } - - switch (property_id) { - case kSbUserPropertyUserName: - return static_cast(strlen(user->name) + 1); - - case kSbUserPropertyUserId: - return static_cast(strlen(user->id) + 1); - - default: - return 0; - } -} - -bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size) { - if (!SbUserIsValid(user) || !out_value || - value_size < SbUserGetPropertySize(user, property_id)) { - return false; - } - - switch (property_id) { - case kSbUserPropertyUserName: - starboard::strlcpy(out_value, user->name, value_size); - return true; - - case kSbUserPropertyUserId: - starboard::strlcpy(out_value, user->id, value_size); - return true; - - default: - return false; - } -} - -#endif diff --git a/starboard/shared/nouser/user_get_signed_in.cc b/starboard/shared/nouser/user_get_signed_in.cc deleted file mode 100644 index 726ffd8cc602..000000000000 --- a/starboard/shared/nouser/user_get_signed_in.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -#include "starboard/shared/nouser/user_internal.h" - -// Nouser implementation of getting signed-in users. We always return one user -// with default attributes. -int SbUserGetSignedIn(SbUser* out_users, int users_size) { - if (out_users && users_size > 0) { - out_users[0] = &starboard::shared::nouser::g_user; - } - - return 1; -} - -#endif diff --git a/starboard/shared/nouser/user_internal.cc b/starboard/shared/nouser/user_internal.cc deleted file mode 100644 index 83bbba100c85..000000000000 --- a/starboard/shared/nouser/user_internal.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/nouser/user_internal.h" - -#include "starboard/user.h" - -namespace starboard { -namespace shared { -namespace nouser { -// The one instance of the signed-in user. -SbUserPrivate g_user = { - "user", - "user", -}; -} // namespace nouser -} // namespace shared -} // namespace starboard - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/nouser/user_internal.h b/starboard/shared/nouser/user_internal.h deleted file mode 100644 index 728c4b94818f..000000000000 --- a/starboard/shared/nouser/user_internal.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ -#define STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ - -#if SB_API_VERSION < 16 - -#include "starboard/shared/internal_only.h" -#include "starboard/user.h" - -struct SbUserPrivate { - static const int kMaxUserName = 256; - - const char name[kMaxUserName]; - const char id[kMaxUserName]; -}; - -namespace starboard { -namespace shared { -namespace nouser { -// The one instance of the signed-in user. -extern SbUserPrivate g_user; -} // namespace nouser -} // namespace shared -} // namespace starboard - -#endif // SB_API_VERSION < 16 - -#endif // STARBOARD_SHARED_NOUSER_USER_INTERNAL_H_ diff --git a/starboard/shared/opus/opus_audio_decoder.cc b/starboard/shared/opus/opus_audio_decoder.cc index 683e7fd1b29d..79b3a6ffc309 100644 --- a/starboard/shared/opus/opus_audio_decoder.cc +++ b/starboard/shared/opus/opus_audio_decoder.cc @@ -133,19 +133,11 @@ bool OpusAudioDecoder::DecodeInternal( audio_stream_info_.number_of_channels * frames_per_au_ * starboard::media::GetBytesPerSample(GetSampleType())); -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - const char kDecodeFunctionName[] = "opus_multistream_decode"; - int decoded_frames = opus_multistream_decode( - decoder_, static_cast(input_buffer->data()), - input_buffer->size(), - reinterpret_cast(decoded_audio->data()), frames_per_au_, 0); -#else // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) const char kDecodeFunctionName[] = "opus_multistream_decode_float"; int decoded_frames = opus_multistream_decode_float( decoder_, static_cast(input_buffer->data()), input_buffer->size(), reinterpret_cast(decoded_audio->data()), frames_per_au_, 0); -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) if (decoded_frames == OPUS_BUFFER_TOO_SMALL && frames_per_au_ < kMaxOpusFramesPerAU) { frames_per_au_ = kMaxOpusFramesPerAU; @@ -274,11 +266,7 @@ bool OpusAudioDecoder::is_valid() const { SbMediaAudioSampleType OpusAudioDecoder::GetSampleType() const { SB_DCHECK(BelongsToCurrentThread()); -#if SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) - return kSbMediaAudioSampleTypeInt16; -#else // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) return kSbMediaAudioSampleTypeFloat32; -#endif // SB_API_VERSION <= 15 && SB_HAS_QUIRK(SUPPORT_INT16_AUDIO_SAMPLES) } } // namespace opus diff --git a/starboard/shared/posix/directory_create.cc b/starboard/shared/posix/directory_create.cc deleted file mode 100644 index 42ab23b450c3..000000000000 --- a/starboard/shared/posix/directory_create.cc +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/directory.h" - -#include -#include - -#include - -#include "starboard/file.h" - -namespace { - -void RemoveTrailingSeparators(std::string* path) { - size_t found = path->find_last_not_of('/'); - if (found != std::string::npos) { - path->resize(found + 1); - } else { - path->resize(1); - } -} - -std::string GetParent(const std::string& path) { - size_t last_slash = path.find_last_of('/'); - if (last_slash != std::string::npos) { - std::string parent = path.substr(0, last_slash); - RemoveTrailingSeparators(&parent); - return parent; - } - - return ""; -} - -} // namespace - -#if SB_API_VERSION < 16 - -bool SbDirectoryCreate(const char* path) { - // Require a non-empty, absolute path. - if (!path || path[0] != '/') { - return false; - } - - // Clear trailing slashes. - std::string adjusted(path); - RemoveTrailingSeparators(&adjusted); - - if (SbDirectoryCanOpen(adjusted.c_str())) { - return true; - } - - std::string parent = GetParent(adjusted); - if (!parent.empty() && !SbDirectoryCanOpen(parent.c_str())) { - return false; - } - - if (mkdir(adjusted.c_str(), 0700) == 0) { - return true; - } - - // If mkdir failed, the directory may still exist now (because of another - // racing process or thread), so check again. - return SbDirectoryCanOpen(adjusted.c_str()); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_can_open.cc b/starboard/shared/posix/file_can_open.cc deleted file mode 100644 index 896e5faf8b56..000000000000 --- a/starboard/shared/posix/file_can_open.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_can_open.h" - -bool SbFileCanOpen(const char* path, int flags) { - return ::starboard::shared::posix::impl::FileCanOpen(path, flags); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_close.cc b/starboard/shared/posix/file_close.cc deleted file mode 100644 index f9a6f5d638e6..000000000000 --- a/starboard/shared/posix/file_close.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_close.h" - -bool SbFileClose(SbFile file) { - return ::starboard::shared::posix::impl::FileClose(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_delete.cc b/starboard/shared/posix/file_delete.cc deleted file mode 100644 index 3ad7ea095407..000000000000 --- a/starboard/shared/posix/file_delete.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_delete.h" - -bool SbFileDelete(const char* path) { - return ::starboard::shared::posix::impl::FileDelete(path); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_exists.cc b/starboard/shared/posix/file_exists.cc deleted file mode 100644 index 97774b07573d..000000000000 --- a/starboard/shared/posix/file_exists.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_exists.h" - -bool SbFileExists(const char* path) { - return ::starboard::shared::posix::impl::FileExists(path); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_flush.cc b/starboard/shared/posix/file_flush.cc deleted file mode 100644 index 3f1a4c3c9751..000000000000 --- a/starboard/shared/posix/file_flush.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_flush.h" - -bool SbFileFlush(SbFile file) { - return ::starboard::shared::posix::impl::FileFlush(file); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_get_info.cc b/starboard/shared/posix/file_get_info.cc deleted file mode 100644 index 2443587bbce9..000000000000 --- a/starboard/shared/posix/file_get_info.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_get_info.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - return ::starboard::shared::posix::impl::FileGetInfo(file, out_info); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_get_path_info.cc b/starboard/shared/posix/file_get_path_info.cc deleted file mode 100644 index 3f5639cc5a3d..000000000000 --- a/starboard/shared/posix/file_get_path_info.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_get_path_info.h" - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - return ::starboard::shared::posix::impl::FileGetPathInfo(path, out_info); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/file_open.cc b/starboard/shared/posix/file_open.cc deleted file mode 100644 index 56675c63fd7a..000000000000 --- a/starboard/shared/posix/file_open.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_open.h" - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - return ::starboard::shared::posix::impl::FileOpen(path, flags, out_created, - out_error); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_read.cc b/starboard/shared/posix/file_read.cc deleted file mode 100644 index 3721a8b9b500..000000000000 --- a/starboard/shared/posix/file_read.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_read.h" - -int SbFileRead(SbFile file, char* data, int size) { - return ::starboard::shared::posix::impl::FileRead(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_seek.cc b/starboard/shared/posix/file_seek.cc deleted file mode 100644 index ba6ba4ab47b9..000000000000 --- a/starboard/shared/posix/file_seek.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_seek.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - return ::starboard::shared::posix::impl::FileSeek(file, whence, offset); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_truncate.cc b/starboard/shared/posix/file_truncate.cc deleted file mode 100644 index f119fb3d0f4d..000000000000 --- a/starboard/shared/posix/file_truncate.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_truncate.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return ::starboard::shared::posix::impl::FileTruncate(file, length); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/file_write.cc b/starboard/shared/posix/file_write.cc deleted file mode 100644 index 118d183de2b6..000000000000 --- a/starboard/shared/posix/file_write.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/shared/posix/file_internal.h" - -#include "starboard/shared/posix/impl/file_write.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return ::starboard::shared::posix::impl::FileWrite(file, data, size); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/posix/impl/file_get_path_info.h b/starboard/shared/posix/impl/file_get_path_info.h index 588552c8c1c7..25968ecb3712 100644 --- a/starboard/shared/posix/impl/file_get_path_info.h +++ b/starboard/shared/posix/impl/file_get_path_info.h @@ -17,42 +17,6 @@ #ifndef STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ #define STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ -#include "starboard/file.h" - -#include -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/posix/impl/file_impl.h" - -namespace starboard { -namespace shared { -namespace posix { -namespace impl { - -bool FileGetPathInfo(const char* path, SbFileInfo* out_info) { - if (!path || path[0] == '\0' || !out_info) { - return false; - } - - struct stat file_info; - int result = stat(path, &file_info); - if (result) { - return false; - } - - out_info->creation_time = TimeTToWindowsUsec(file_info.st_ctime); - out_info->is_directory = S_ISDIR(file_info.st_mode); - out_info->is_symbolic_link = S_ISLNK(file_info.st_mode); - out_info->last_accessed = TimeTToWindowsUsec(file_info.st_atime); - out_info->last_modified = TimeTToWindowsUsec(file_info.st_mtime); - out_info->size = file_info.st_size; - return true; -} - -} // namespace impl -} // namespace posix -} // namespace shared -} // namespace starboard +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_SHARED_POSIX_IMPL_FILE_GET_PATH_INFO_H_ diff --git a/starboard/shared/posix/log_is_tty.cc b/starboard/shared/posix/log_is_tty.cc deleted file mode 100644 index f4df478ffa0e..000000000000 --- a/starboard/shared/posix/log_is_tty.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/common/log.h" - -#include - -bool SbLogIsTty() { - return isatty(STDERR_FILENO) == 1; -} -#endif // SB_API_VERSION diff --git a/starboard/shared/posix/memory_flush.cc b/starboard/shared/posix/memory_flush.cc deleted file mode 100644 index 8606a8ecb1ed..000000000000 --- a/starboard/shared/posix/memory_flush.cc +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" - -#include - -#include - -#include "starboard/common/log.h" - -#if !SB_CAN(MAP_EXECUTABLE_MEMORY) -#error \ - "You shouldn't implement SbMemoryFlush unless you can map " \ - "memory pages as executable" -#endif - -void SbMemoryFlush(void* virtual_address, int64_t size_bytes) { - char* memory = reinterpret_cast(virtual_address); -#if !SB_IS(ARCH_ARM) && !SB_IS(ARCH_ARM64) - int result = msync(memory, size_bytes, MS_SYNC); - SB_DCHECK(result == 0) << "msync failed: 0x" << std::hex << result << " (" - << std::dec << result << "d)"; -#endif - -#if !defined(__has_builtin) -#define __has_builtin(a) (0) -#endif - -#if __has_builtin(__builtin___clear_cache) - __builtin___clear_cache(memory, memory + size_bytes); -#elif defined(__clear_cache) - __clear_cache(memory, memory + size_bytes); -#endif -} - -#endif diff --git a/starboard/shared/posix/memory_map.cc b/starboard/shared/posix/memory_map.cc deleted file mode 100644 index 97d9e38a9c1e..000000000000 --- a/starboard/shared/posix/memory_map.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -void* SbMemoryMap(int64_t size_bytes, int flags, const char* name) { - void* memory = SbPageMap(size_bytes, flags, name); - return memory; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/memory_protect.cc b/starboard/shared/posix/memory_protect.cc deleted file mode 100644 index f1f544b1a55a..000000000000 --- a/starboard/shared/posix/memory_protect.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -bool SbMemoryProtect(void* virtual_address, int64_t size_bytes, int flags) { - return SbPageProtect(virtual_address, size_bytes, flags); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/memory_unmap.cc b/starboard/shared/posix/memory_unmap.cc deleted file mode 100644 index f539e17b355d..000000000000 --- a/starboard/shared/posix/memory_unmap.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/shared/posix/page_internal.h" - -bool SbMemoryUnmap(void* virtual_address, int64_t size_bytes) { - return SbPageUnmap(virtual_address, size_bytes); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/page_internal.cc b/starboard/shared/posix/page_internal.cc index 97ca18459f87..cf39e2ea6b98 100644 --- a/starboard/shared/posix/page_internal.cc +++ b/starboard/shared/posix/page_internal.cc @@ -54,62 +54,8 @@ int SbMemoryMapFlagsToMmapProtect(int sb_flags) { return mmap_protect; } -#if SB_API_VERSION < 16 -int32_t s_tracked_page_count = 0; - -int32_t GetPageCount(size_t byte_count) { - return static_cast( - starboard::common::MemoryAlignToPageSize(byte_count) / kSbMemoryPageSize); -} - -void* SbPageMapUntracked(size_t size_bytes, - int flags, - const char* unused_name) { -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if (flags & kSbMemoryMapProtectExec) { - // Cobalt does not allow mapping executable memory directly. - return SB_MEMORY_MAP_FAILED; - } -#endif - int mmap_protect = SbMemoryMapFlagsToMmapProtect(flags); - void* mem = mmap(0, size_bytes, mmap_protect, MAP_PRIVATE | MAP_ANON, -1, 0); - return mem; -} - -bool SbPageUnmapUntracked(void* ptr, size_t size_bytes) { - return munmap(ptr, size_bytes) == 0; -} - -#endif // SB_API_VERSION < 16 - } // namespace -#if SB_API_VERSION < 16 -void* SbPageMap(size_t size_bytes, int flags, const char* unused_name) { - void* ret = SbPageMapUntracked(size_bytes, flags, NULL); - if (ret != SB_MEMORY_MAP_FAILED) { - SbAtomicNoBarrier_Increment(&s_tracked_page_count, - GetPageCount(size_bytes)); - } - return ret; -} - -bool SbPageUnmap(void* ptr, size_t size_bytes) { - SbAtomicNoBarrier_Increment(&s_tracked_page_count, -GetPageCount(size_bytes)); - return SbPageUnmapUntracked(ptr, size_bytes); -} - -bool SbPageProtect(void* virtual_address, int64_t size_bytes, int flags) { - int mmap_protect = SbMemoryMapFlagsToMmapProtect(flags); - return mprotect(virtual_address, size_bytes, mmap_protect) == 0; -} - -size_t SbPageGetMappedBytes() { - return static_cast(SbAtomicNoBarrier_Load(&s_tracked_page_count) * - kSbMemoryPageSize); -} -#endif // SB_API_VERSION < 16 - void* SbPageMapFile(void* addr, const char* path, SbMemoryMapFlags flags, diff --git a/starboard/shared/posix/page_internal.h b/starboard/shared/posix/page_internal.h index d65207405327..5dcc9154cfd4 100644 --- a/starboard/shared/posix/page_internal.h +++ b/starboard/shared/posix/page_internal.h @@ -34,32 +34,6 @@ void* SbPageMapFile(void* addr, int64_t file_offset, int64_t size); -#if SB_API_VERSION < 16 -// Allocates |size_bytes| worth of physical memory pages and maps them into an -// available virtual region. On some platforms, |name| appears in the debugger -// and can be up to 32 bytes. Returns SB_MEMORY_MAP_FAILED on failure, as NULL -// is a valid return value. -void* SbPageMap(size_t size_bytes, int flags, const char* name); - -// Unmap |size_bytes| of physical pages starting from |virtual_address|, -// returning true on success. After this, [virtual_address, virtual_address + -// size_bytes) will not be read/writable. SbUnmap() can unmap multiple -// contiguous regions that were mapped with separate calls to -// SbPageMap(). E.g. if one call to SbPageMap(0x1000) returns (void*)0xA000 and -// another call to SbPageMap(0x1000) returns (void*)0xB000, SbPageUnmap(0xA000, -// 0x2000) should free both. -bool SbPageUnmap(void* virtual_address, size_t size_bytes); - -// Change the protection of |size_bytes| of physical pages, starting from -// |virtual_address|, to |flags|, returning |true| on success. -bool SbPageProtect(void* virtual_address, int64_t size_bytes, int flags); - -// Returns the total amount, in bytes, currently allocated via Map(). Should -// always be a multiple of kSbMemoryPageSize. -size_t SbPageGetMappedBytes(); - -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/shared/posix/string_compare_no_case.cc b/starboard/shared/posix/string_compare_no_case.cc deleted file mode 100644 index 79479e7eebe1..000000000000 --- a/starboard/shared/posix/string_compare_no_case.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include // Non-standard, required for some platforms. -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCase(const char* string1, const char* string2) { - return strcasecmp(string1, string2); -} -#endif diff --git a/starboard/shared/posix/string_compare_no_case_n.cc b/starboard/shared/posix/string_compare_no_case_n.cc deleted file mode 100644 index e56c4fb7ebce..000000000000 --- a/starboard/shared/posix/string_compare_no_case_n.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include // Non-standard, required for some platforms. -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCaseN(const char* string1, - const char* string2, - size_t count) { - return ::strncasecmp(string1, string2, count); -} -#endif diff --git a/starboard/shared/posix/string_format.cc b/starboard/shared/posix/string_format.cc deleted file mode 100644 index 6835afe2887a..000000000000 --- a/starboard/shared/posix/string_format.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include -#include - -#if SB_API_VERSION < 16 -int SbStringFormat(char* out_buffer, - size_t buffer_size, - const char* format, - va_list arguments) { - return vsnprintf(out_buffer, buffer_size, format, arguments); -} -#endif diff --git a/starboard/shared/posix/string_format_wide.cc b/starboard/shared/posix/string_format_wide.cc deleted file mode 100644 index 9e77eec6d028..000000000000 --- a/starboard/shared/posix/string_format_wide.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include -#include -#include - -#if SB_API_VERSION < 16 -int SbStringFormatWide(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - va_list arguments) { - return vswprintf(out_buffer, buffer_size, format, arguments); -} -#endif diff --git a/starboard/shared/posix/time_get_monotonic_now.cc b/starboard/shared/posix/time_get_monotonic_now.cc deleted file mode 100644 index b5bdf4aa66f0..000000000000 --- a/starboard/shared/posix/time_get_monotonic_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTimeMonotonic SbTimeGetMonotonicNow() { - struct timespec time; - if (clock_gettime(CLOCK_MONOTONIC, &time) != 0) { - SB_NOTREACHED() << "clock_gettime(CLOCK_MONOTONIC) failed."; - return 0; - } - - return FromTimespecDelta(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_get_monotonic_thread_now.cc b/starboard/shared/posix/time_get_monotonic_thread_now.cc deleted file mode 100644 index 8b23b7ac1b55..000000000000 --- a/starboard/shared/posix/time_get_monotonic_thread_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTimeMonotonic SbTimeGetMonotonicThreadNow() { - struct timespec time; - if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &time) != 0) { - SB_NOTREACHED() << "clock_gettime(CLOCK_THREAD_CPUTIME_ID) failed."; - return 0; - } - - return FromTimespecDelta(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_get_now.cc b/starboard/shared/posix/time_get_now.cc deleted file mode 100644 index 0323fc43fbc3..000000000000 --- a/starboard/shared/posix/time_get_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/posix/time_internal.h" - -SbTime SbTimeGetNow() { - struct timeval time; - if (gettimeofday(&time, NULL) != 0) { - SB_NOTREACHED() << "Could not determine time of day."; - return 0; - } - - return FromTimeval(&time); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/posix/time_internal.h b/starboard/shared/posix/time_internal.h index 6d75f49fae90..16221771b32e 100644 --- a/starboard/shared/posix/time_internal.h +++ b/starboard/shared/posix/time_internal.h @@ -15,46 +15,6 @@ #ifndef STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ #define STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ -#if SB_API_VERSION < 16 - -#include -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/time.h" - -namespace { // NOLINT(build/namespaces_headers) -const int64_t kMillisecondsPerSecond = kSbTimeSecond / kSbTimeMillisecond; -const int64_t kNanosecondsPerMicrosecond = 1000; - -inline SbTime FromSeconds(int64_t secs) { - return secs * kSbTimeSecond; -} - -inline SbTime FromNanoseconds(int64_t ns) { - return ns / kNanosecondsPerMicrosecond; -} - -// Converts a timespec representing a duration into microseconds. -inline int64_t FromTimespecDelta(struct timespec* time) { - return FromSeconds(static_cast(time->tv_sec)) + - FromNanoseconds(static_cast(time->tv_nsec)); -} - -// Converts a timeval (relative to POSIX epoch) into microseconds since the -// Windows epoch (1601). -inline int64_t FromTimeval(const struct timeval* time) { - return SbTimeFromPosix(FromSeconds(static_cast(time->tv_sec)) + - time->tv_usec); -} - -// Converts a time_t (relative to POSIX epoch) into microseconds since the -// Windows epoch (1601). -inline int64_t FromTimeT(time_t time) { - return SbTimeFromPosix(FromSeconds(time)); -} -} // namespace - -#endif // SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. #endif // STARBOARD_SHARED_POSIX_TIME_INTERNAL_H_ diff --git a/starboard/shared/posix/time_is_time_thread_now_supported.cc b/starboard/shared/posix/time_is_time_thread_now_supported.cc deleted file mode 100644 index bb0e7097b11a..000000000000 --- a/starboard/shared/posix/time_is_time_thread_now_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -bool SbTimeIsTimeThreadNowSupported() { - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_broadcast.cc b/starboard/shared/pthread/condition_variable_broadcast.cc deleted file mode 100644 index e45b259dac1d..000000000000 --- a/starboard/shared/pthread/condition_variable_broadcast.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableBroadcast(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to signal so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_broadcast( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_create.cc b/starboard/shared/pthread/condition_variable_create.cc deleted file mode 100644 index 52a98a239062..000000000000 --- a/starboard/shared/pthread/condition_variable_create.cc +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::SetInitialized; - -namespace { -struct ConditionVariableAttributes { - public: - ConditionVariableAttributes() { - valid_ = IsSuccess(pthread_condattr_init(&attributes_)); - } - ~ConditionVariableAttributes() { - if (valid_) { - SB_CHECK(IsSuccess(pthread_condattr_destroy(&attributes_))); - } - } - - bool valid() const { return valid_; } - pthread_condattr_t* attributes() { return &attributes_; } - - private: - bool valid_; - pthread_condattr_t attributes_; -}; -} // namespace - -bool SbConditionVariableCreate(SbConditionVariable* out_condition, - SbMutex* opt_mutex) { - SB_COMPILE_ASSERT( - sizeof(SbConditionVariable) >= sizeof(SbConditionVariablePrivate), - sb_condition_variable_private_larger_than_sb_condition_variable); - if (!out_condition) { - return false; - } - - ConditionVariableAttributes attributes; - if (!attributes.valid()) { - SB_DLOG(ERROR) << "Failed to call pthread_condattr_init()."; - return false; - } - -#if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - // Always use CLOCK_MONOTONIC so that SbConditionVariableWaitTimed() will - // not be based off of the system clock (which can lead to erroneous - // behavior if the system clock is changed while a process is running). - if (!IsSuccess(pthread_condattr_setclock(attributes.attributes(), - CLOCK_MONOTONIC))) { - SB_DLOG(ERROR) << "Failed to call pthread_condattr_setclock()."; - return false; - } -#endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - - bool status = IsSuccess(pthread_cond_init( - &(SB_PTHREAD_INTERNAL_CONDITION(out_condition)->condition), - attributes.attributes())); - - // We mark that we are initialized regardless of whether initialization - // was successful or not. - SetInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(out_condition)->initialized_state)); - - if (!status) { - SB_DLOG(ERROR) << "Failed to call pthread_cond_init()."; - } - - return status; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_destroy.cc b/starboard/shared/pthread/condition_variable_destroy.cc deleted file mode 100644 index 9c8e30f4be9c..000000000000 --- a/starboard/shared/pthread/condition_variable_destroy.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableDestroy(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to destroy so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_destroy( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_signal.cc b/starboard/shared/pthread/condition_variable_signal.cc deleted file mode 100644 index b8ee61d2f45a..000000000000 --- a/starboard/shared/pthread/condition_variable_signal.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbConditionVariableSignal(SbConditionVariable* condition) { - if (!condition) { - return false; - } - - if (!IsInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // If the condition variable is not initialized yet, then there is nothing - // to signal so vacuously return true. - return true; - } - - return IsSuccess(pthread_cond_signal( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait.cc b/starboard/shared/pthread/condition_variable_wait.cc deleted file mode 100644 index 397d94d078ab..000000000000 --- a/starboard/shared/pthread/condition_variable_wait.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; - -SbConditionVariableResult SbConditionVariableWait( - SbConditionVariable* condition, - SbMutex* mutex) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - - if (!EnsureInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // The condition variable is set to SB_CONDITION_VARIABLE_INITIALIZER and - // is uninitialized, so call SbConditionVariableCreate() to initialize the - // condition variable. SbConditionVariableCreate() is responsible for - // marking the variable as initialized. - SbConditionVariableCreate(condition, mutex); - } - - if (IsSuccess(pthread_cond_wait( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition), - SB_PTHREAD_INTERNAL_MUTEX(mutex)))) { - return kSbConditionVariableSignaled; - } - - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/condition_variable_wait_timed.cc b/starboard/shared/pthread/condition_variable_wait_timed.cc deleted file mode 100644 index 8807680cecd0..000000000000 --- a/starboard/shared/pthread/condition_variable_wait_timed.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/condition_variable.h" - -#include -#include -#include - -#include "starboard/common/time.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; - -SbConditionVariableResult SbConditionVariableWaitTimed( - SbConditionVariable* condition, - SbMutex* mutex, - int64_t timeout) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - - if (timeout < 0) { - timeout = 0; - } - -#if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - int64_t timeout_time_usec = starboard::CurrentMonotonicTime() + timeout; -#else // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - int64_t timeout_time_usec = starboard::CurrentPosixTime() + timeout; -#endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) - - // Detect overflow if timeout is near kSbInt64Max. Since timeout can't be - // negative at this point, if it goes negative after adding now, we know we've - // gone over. Especially posix now, which has a 400 year advantage over - // Chromium (Windows) now. - if (timeout_time_usec < 0) { - timeout_time_usec = kSbInt64Max; - } - - struct timespec timeout_ts; - timeout_ts.tv_sec = timeout_time_usec / 1'000'000; - timeout_ts.tv_nsec = (timeout_time_usec % 1'000'000) * 1000; - - if (!EnsureInitialized( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->initialized_state))) { - // The condition variable is set to SB_CONDITION_VARIABLE_INITIALIZER and - // is uninitialized, so call SbConditionVariableCreate() to initialize the - // condition variable. SbConditionVariableCreate() is responsible for - // marking the variable as initialized. - SbConditionVariableCreate(condition, mutex); - } - - int result = pthread_cond_timedwait( - &(SB_PTHREAD_INTERNAL_CONDITION(condition)->condition), - SB_PTHREAD_INTERNAL_MUTEX(mutex), &timeout_ts); - if (IsSuccess(result)) { - return kSbConditionVariableSignaled; - } - - if (result == ETIMEDOUT) { - return kSbConditionVariableTimedOut; - } - - return kSbConditionVariableFailed; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire.cc b/starboard/shared/pthread/mutex_acquire.cc deleted file mode 100644 index a9f4d26b7eed..000000000000 --- a/starboard/shared/pthread/mutex_acquire.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/experimental/concurrency_debug.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -SbMutexResult SbMutexAcquire(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - - if (!EnsureInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - *SB_PTHREAD_INTERNAL_MUTEX(mutex) = PTHREAD_MUTEX_INITIALIZER; - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - } - -#if SB_ENABLE_CONCURRENCY_DEBUG - starboard::experimental::ScopedMutexWaitTracker tracker(mutex); - if (tracker.acquired()) { - return kSbMutexAcquired; - } -#endif // SB_ENABLE_CONCURRENCY_DEBUG - int result = pthread_mutex_lock(SB_PTHREAD_INTERNAL_MUTEX(mutex)); - if (IsSuccess(result)) { - return kSbMutexAcquired; - } - - return kSbMutexBusy; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_acquire_try.cc b/starboard/shared/pthread/mutex_acquire_try.cc deleted file mode 100644 index 58fb709b5e3a..000000000000 --- a/starboard/shared/pthread/mutex_acquire_try.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - - if (!EnsureInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - *SB_PTHREAD_INTERNAL_MUTEX(mutex) = PTHREAD_MUTEX_INITIALIZER; - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - } - - int result = pthread_mutex_trylock(SB_PTHREAD_INTERNAL_MUTEX(mutex)); - if (IsSuccess(result)) { - return kSbMutexAcquired; - } - - return kSbMutexBusy; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_create.cc b/starboard/shared/pthread/mutex_create.cc deleted file mode 100644 index e24abce5dd2a..000000000000 --- a/starboard/shared/pthread/mutex_create.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::SetInitialized; - -bool SbMutexCreate(SbMutex* mutex) { - SB_COMPILE_ASSERT(sizeof(SbMutex) >= sizeof(SbMutexPrivate), - sb_mutex_private_larger_than_sb_mutex); - if (!mutex) { - return false; - } - - SetInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state)); - return IsSuccess(pthread_mutex_init(SB_PTHREAD_INTERNAL_MUTEX(mutex), NULL)); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_destroy.cc b/starboard/shared/pthread/mutex_destroy.cc deleted file mode 100644 index 754c52d14019..000000000000 --- a/starboard/shared/pthread/mutex_destroy.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/configuration.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbMutexDestroy(SbMutex* mutex) { - if (!mutex) { - return false; - } - - if (!IsInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - // If the mutex is not initialized there is nothing to destroy. - return true; - } - - // Both trying to recursively acquire a mutex that is locked by the calling - // thread, as well as deleting a locked mutex, result in undefined behavior. - return IsSuccess(pthread_mutex_destroy(SB_PTHREAD_INTERNAL_MUTEX(mutex))); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/mutex_release.cc b/starboard/shared/pthread/mutex_release.cc deleted file mode 100644 index 0dbe87f363ce..000000000000 --- a/starboard/shared/pthread/mutex_release.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::IsInitialized; - -bool SbMutexRelease(SbMutex* mutex) { - if (!mutex) { - return false; - } - - if (!IsInitialized(&(SB_INTERNAL_MUTEX(mutex)->initialized_state))) { - // If the mutex is not initialized there is nothing to release. - return true; - } - return IsSuccess(pthread_mutex_unlock(SB_PTHREAD_INTERNAL_MUTEX(mutex))); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/once.cc b/starboard/shared/pthread/once.cc deleted file mode 100644 index b0c757508c45..000000000000 --- a/starboard/shared/pthread/once.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/once.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/types_internal.h" -#include "starboard/shared/starboard/lazy_initialization_internal.h" - -using starboard::shared::starboard::EnsureInitialized; -using starboard::shared::starboard::SetInitialized; - -bool SbOnce(SbOnceControl* once_control, SbOnceInitRoutine init_routine) { - SB_COMPILE_ASSERT(sizeof(SbOnceControl) >= sizeof(SbOnceControlPrivate), - sb_once_control_private_larger_than_sb_once_control); - if (once_control == NULL) { - return false; - } - if (init_routine == NULL) { - return false; - } - if (!EnsureInitialized( - &(SB_INTERNAL_ONCE(once_control)->initialized_state))) { - *SB_PTHREAD_INTERNAL_ONCE(once_control) = PTHREAD_ONCE_INIT; - SetInitialized(&(SB_INTERNAL_ONCE(once_control)->initialized_state)); - } - - return pthread_once(SB_PTHREAD_INTERNAL_ONCE(once_control), init_routine) == - 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_create.cc b/starboard/shared/pthread/thread_create.cc deleted file mode 100644 index 41167eb00f54..000000000000 --- a/starboard/shared/pthread/thread_create.cc +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/thread_create_priority.h" -#include "starboard/shared/pthread/types_internal.h" - -namespace starboard { -namespace shared { -namespace pthread {} // namespace pthread -} // namespace shared -} // namespace starboard - -namespace { - -struct ThreadParams { - SbThreadAffinity affinity; - SbThreadEntryPoint entry_point; - char name[128] = {}; - void* context; - SbThreadPriority priority; -}; - -void* ThreadFunc(void* context) { - ThreadParams* thread_params = static_cast(context); - SbThreadEntryPoint entry_point = thread_params->entry_point; - void* real_context = thread_params->context; - SbThreadAffinity affinity = thread_params->affinity; - if (thread_params->name[0] != '\0') { - pthread_setname_np(pthread_self(), thread_params->name); - } - - starboard::shared::pthread::ThreadSetPriority(thread_params->priority); - - delete thread_params; - -#if defined(_GNU_SOURCE) // sched_setaffinity is a GNU extension - if (SbThreadIsValidAffinity(affinity)) { - cpu_set_t cpu_set; - CPU_ZERO(&cpu_set); - CPU_SET(affinity, &cpu_set); - sched_setaffinity(0, sizeof(cpu_set), &cpu_set); - } -#endif - - return entry_point(real_context); -} - -} // namespace - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - if (stack_size < 0 || !entry_point) { - return kSbThreadInvalid; - } - -#if defined(ADDRESS_SANITIZER) - // Set a big thread stack size when in ADDRESS_SANITIZER mode. - // This eliminates buffer overflows for deeply nested callstacks. - if (stack_size == 0) { - stack_size = 4096 * 1024; // 4MB - } -#endif - - pthread_attr_t attributes; - int result = pthread_attr_init(&attributes); - if (!IsSuccess(result)) { - return kSbThreadInvalid; - } - - pthread_attr_setdetachstate( - &attributes, - (joinable ? PTHREAD_CREATE_JOINABLE : PTHREAD_CREATE_DETACHED)); - - if (stack_size > 0) { - pthread_attr_setstacksize(&attributes, stack_size); - } - - ThreadParams* params = new ThreadParams(); - params->affinity = affinity; - params->entry_point = entry_point; - params->context = context; - - if (name) { - starboard::strlcpy(params->name, name, SB_ARRAY_SIZE_INT(params->name)); - } else { - params->name[0] = '\0'; - } - - params->priority = priority; - - SbThread thread = kSbThreadInvalid; - SB_COMPILE_ASSERT(sizeof(SbThread) >= sizeof(pthread_t), - pthread_t_larger_than_sb_thread); - result = pthread_create(SB_PTHREAD_INTERNAL_THREAD_PTR(thread), &attributes, - ThreadFunc, params); - - pthread_attr_destroy(&attributes); - if (IsSuccess(result)) { - return thread; - } - - return kSbThreadInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_create_local_key.cc b/starboard/shared/pthread/thread_create_local_key.cc deleted file mode 100644 index 59112c1310d0..000000000000 --- a/starboard/shared/pthread/thread_create_local_key.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) { - SbThreadLocalKey key = new SbThreadLocalKeyPrivate(); - if (!IsSuccess(pthread_key_create(&key->key, destructor))) { - delete key; - return kSbThreadLocalKeyInvalid; - } - return key; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_destroy_local_key.cc b/starboard/shared/pthread/thread_destroy_local_key.cc deleted file mode 100644 index 264bd10e2b4b..000000000000 --- a/starboard/shared/pthread/thread_destroy_local_key.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -void SbThreadDestroyLocalKey(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return; - } - - pthread_key_delete(key->key); - delete key; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_detach.cc b/starboard/shared/pthread/thread_detach.cc deleted file mode 100644 index 3a760d83727c..000000000000 --- a/starboard/shared/pthread/thread_detach.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -void SbThreadDetach(SbThread thread) { - if (!SbThreadIsValid(thread)) { - return; - } - - pthread_detach(SB_PTHREAD_INTERNAL_THREAD(thread)); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_get_current.cc b/starboard/shared/pthread/thread_get_current.cc deleted file mode 100644 index 62a5d98576ca..000000000000 --- a/starboard/shared/pthread/thread_get_current.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -SbThread SbThreadGetCurrent() { - return SB_THREAD(pthread_self()); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_get_local_value.cc b/starboard/shared/pthread/thread_get_local_value.cc deleted file mode 100644 index 21a79180dbc3..000000000000 --- a/starboard/shared/pthread/thread_get_local_value.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -void* SbThreadGetLocalValue(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return NULL; - } - - return pthread_getspecific(key->key); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_is_equal.cc b/starboard/shared/pthread/thread_is_equal.cc deleted file mode 100644 index 7131ef3cdfe8..000000000000 --- a/starboard/shared/pthread/thread_is_equal.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/types_internal.h" - -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { - return pthread_equal(SB_PTHREAD_INTERNAL_THREAD(thread1), - SB_PTHREAD_INTERNAL_THREAD(thread2)) != 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_join.cc b/starboard/shared/pthread/thread_join.cc deleted file mode 100644 index 3136701fdb68..000000000000 --- a/starboard/shared/pthread/thread_join.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/is_success.h" -#include "starboard/shared/pthread/types_internal.h" - -bool SbThreadJoin(SbThread thread, void** out_return) { - if (!SbThreadIsValid(thread)) { - return false; - } - - void* joined_return = NULL; - int result = pthread_join(SB_PTHREAD_INTERNAL_THREAD(thread), &joined_return); - if (!IsSuccess(result)) { - return false; - } - - if (out_return) { - *out_return = joined_return; - } - - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/pthread/thread_local_key_internal.h b/starboard/shared/pthread/thread_local_key_internal.h index adb74f3882ba..8a1073eb2ba8 100644 --- a/starboard/shared/pthread/thread_local_key_internal.h +++ b/starboard/shared/pthread/thread_local_key_internal.h @@ -15,18 +15,6 @@ #ifndef STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ #define STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ -#if SB_API_VERSION < 16 +#error This file is deprecated with SB_API_VERSION 16. -#include - -#include "starboard/shared/internal_only.h" -#include "starboard/shared/pthread/is_success.h" -#include "starboard/thread.h" - -struct SbThreadLocalKeyPrivate { - // The underlying thread-local variable handle. - pthread_key_t key; -}; - -#endif // SB_API_VERSION < 16 #endif // STARBOARD_SHARED_PTHREAD_THREAD_LOCAL_KEY_INTERNAL_H_ diff --git a/starboard/shared/pthread/thread_sampler_create.cc b/starboard/shared/pthread/thread_sampler_create.cc index 8968e224ef4f..7d930c28b94a 100644 --- a/starboard/shared/pthread/thread_sampler_create.cc +++ b/starboard/shared/pthread/thread_sampler_create.cc @@ -14,18 +14,9 @@ #include "starboard/shared/pthread/thread_sampler_internal.h" -#if SB_API_VERSION < 16 -SbThreadSampler SbThreadSamplerCreate(SbThread thread) { - if (!SbThreadIsValid(thread)) { - return kSbThreadSamplerInvalid; - } - return new SbThreadSamplerPrivate(thread); -} -#else SbThreadSampler SbThreadSamplerCreate(pthread_t thread) { if (thread == 0) { return kSbThreadSamplerInvalid; } return new SbThreadSamplerPrivate(thread); } -#endif diff --git a/starboard/shared/pthread/thread_sampler_internal.cc b/starboard/shared/pthread/thread_sampler_internal.cc index 744d5de264a6..282ae02dc2cc 100644 --- a/starboard/shared/pthread/thread_sampler_internal.cc +++ b/starboard/shared/pthread/thread_sampler_internal.cc @@ -130,11 +130,7 @@ void SignalHandler::HandleProfilerSignal(int signal, } // namespace -#if SB_API_VERSION < 16 -SbThreadSamplerPrivate::SbThreadSamplerPrivate(SbThread thread) -#else SbThreadSamplerPrivate::SbThreadSamplerPrivate(pthread_t thread) -#endif : thread_(thread) { SignalHandler::AddSampler(); } diff --git a/starboard/shared/pthread/thread_sampler_internal.h b/starboard/shared/pthread/thread_sampler_internal.h index a7b4c4304a39..11fddf3623c5 100644 --- a/starboard/shared/pthread/thread_sampler_internal.h +++ b/starboard/shared/pthread/thread_sampler_internal.h @@ -21,27 +21,15 @@ class SbThreadSamplerPrivate { public: -#if SB_API_VERSION < 16 - explicit SbThreadSamplerPrivate(SbThread thread); -#else explicit SbThreadSamplerPrivate(pthread_t thread); -#endif ~SbThreadSamplerPrivate(); SbThreadContext Freeze(); bool Thaw(); -#if SB_API_VERSION < 16 - SbThread thread() { return thread_; } -#else pthread_t thread() { return thread_; } -#endif private: -#if SB_API_VERSION < 16 - SbThread thread_; -#else pthread_t thread_; -#endif }; #endif // STARBOARD_SHARED_PTHREAD_THREAD_SAMPLER_INTERNAL_H_ diff --git a/starboard/shared/pthread/thread_set_local_value.cc b/starboard/shared/pthread/thread_set_local_value.cc deleted file mode 100644 index 1261d4c83c37..000000000000 --- a/starboard/shared/pthread/thread_set_local_value.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/pthread/thread_local_key_internal.h" - -bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value) { - if (!SbThreadIsValidLocalKey(key)) { - return false; - } - - if (IsSuccess(pthread_setspecific(key->key, value))) { - return true; - } - - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/directory_can_open.cc b/starboard/shared/starboard/directory_can_open.cc deleted file mode 100644 index 1c54230c910a..000000000000 --- a/starboard/shared/starboard/directory_can_open.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -#include "starboard/file.h" - -bool SbDirectoryCanOpen(const char* path) { - if (!path || !path[0]) { - return false; - } - - SbFileInfo info; - bool result = SbFileGetPathInfo(path, &info); - if (!result) { - return false; - } - - return info.is_directory; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/file_mode_string_to_flags.cc b/starboard/shared/starboard/file_mode_string_to_flags.cc deleted file mode 100644 index d6c217869a45..000000000000 --- a/starboard/shared/starboard/file_mode_string_to_flags.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/file.h" - -namespace { -bool IsUpdate(const char* mode) { - for (const char* m = mode; *m != '\0'; ++m) { - if (*m == '+') { - return true; - } - } - - return false; -} -} // namespace - -int SbFileModeStringToFlags(const char* mode) { - if (!mode) { - return 0; - } - - int length = static_cast(strlen(mode)); - if (length < 1) { - return 0; - } - - int flags = 0; - switch (mode[0]) { - case 'r': - if (IsUpdate(mode + 1)) { - flags |= kSbFileWrite; - } - flags |= kSbFileOpenOnly | kSbFileRead; - break; - case 'w': - if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; - } - flags |= kSbFileCreateAlways | kSbFileWrite; - break; - case 'a': - if (IsUpdate(mode + 1)) { - flags |= kSbFileRead; - } - flags |= kSbFileOpenAlways | kSbFileWrite; - break; - default: - SB_NOTREACHED(); - break; - } - return flags; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/starboard/file_storage/storage_delete_record.cc b/starboard/shared/starboard/file_storage/storage_delete_record.cc index 0d1bf129c858..0f8ab8ffc8ec 100644 --- a/starboard/shared/starboard/file_storage/storage_delete_record.cc +++ b/starboard/shared/starboard/file_storage/storage_delete_record.cc @@ -21,12 +21,7 @@ #include "starboard/configuration_constants.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -bool SbStorageDeleteRecord(SbUser user, const char* name) { -#else bool SbStorageDeleteRecord(const char* name) { -#endif // SB_API_VERSION < 16 std::vector path(kSbFileMaxPath); bool success = starboard::shared::starboard::GetStorageFilePath( name, path.data(), static_cast(path.size())); diff --git a/starboard/shared/starboard/file_storage/storage_open_record.cc b/starboard/shared/starboard/file_storage/storage_open_record.cc index eaa32c79790e..945ba2260e10 100644 --- a/starboard/shared/starboard/file_storage/storage_open_record.cc +++ b/starboard/shared/starboard/file_storage/storage_open_record.cc @@ -23,12 +23,7 @@ #include "starboard/configuration_constants.h" #include "starboard/shared/starboard/file_storage/storage_internal.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name) { -#else SbStorageRecord SbStorageOpenRecord(const char* name) { -#endif // SB_API_VERSION < 16 std::vector path(kSbFileMaxPath); bool success = starboard::shared::starboard::GetStorageFilePath( name, path.data(), static_cast(path.size())); diff --git a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc b/starboard/shared/starboard/media/media_get_buffer_storage_type.cc deleted file mode 100644 index 5cb8977c078b..000000000000 --- a/starboard/shared/starboard/media/media_get_buffer_storage_type.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" - -#if SB_API_VERSION < 16 -SbMediaBufferStorageType SbMediaGetBufferStorageType() { - return kSbMediaBufferStorageTypeMemory; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/media/media_util.cc b/starboard/shared/starboard/media/media_util.cc index e0541d47dc08..d0a5cdf2f7d1 100644 --- a/starboard/shared/starboard/media/media_util.cc +++ b/starboard/shared/starboard/media/media_util.cc @@ -133,16 +133,6 @@ AudioStreamInfo& AudioStreamInfo::operator=( void AudioStreamInfo::ConvertTo( SbMediaAudioStreamInfo* audio_stream_info) const { Assign(*this, audio_stream_info); - -#if SB_API_VERSION < 15 - SB_DCHECK(audio_stream_info); - audio_stream_info->format_tag = 0xff; - audio_stream_info->block_alignment = 4; - audio_stream_info->average_bytes_per_second = - audio_stream_info->samples_per_second * - audio_stream_info->number_of_channels * - audio_stream_info->bits_per_sample / 8; -#endif // SB_API_VERSION < 15 } void AudioStreamInfo::ConvertTo( diff --git a/starboard/shared/starboard/memory.cc b/starboard/shared/starboard/memory.cc deleted file mode 100644 index ccd1d97a80a9..000000000000 --- a/starboard/shared/starboard/memory.cc +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/memory.h" -#include "starboard/atomic.h" -#include "starboard/common/log.h" - -namespace { - -inline void* SbMemoryAllocateImpl(size_t size); -inline void* SbMemoryAllocateAlignedImpl(size_t alignment, size_t size); -inline void* SbMemoryReallocateImpl(void* memory, size_t size); - -} // namespace - -void* SbMemoryAllocate(size_t size) { - void* memory = SbMemoryAllocateImpl(size); - return memory; -} - -void* SbMemoryAllocateNoReport(size_t size) { - return SbMemoryAllocate(size); -} - -void* SbMemoryAllocateAligned(size_t alignment, size_t size) { - void* memory = SbMemoryAllocateAlignedImpl(alignment, size); - return memory; -} - -void* SbMemoryReallocate(void* memory, size_t size) { -#if !defined(COBALT_BUILD_TYPE_GOLD) - SB_CHECK((size != 0) || (memory == nullptr)) - << "Calling SbMemoryReallocate with a non-null pointer and size 0 is not " - "guaranteed to release the memory, and therefore may leak memory."; -#endif - void* new_memory = SbMemoryReallocateImpl(memory, size); - return new_memory; -} - -void SbMemoryDeallocate(void* memory) { - // Report must happen first or else a race condition allows the memory to - // be freed and then reported as allocated, before the allocation is removed. - SbMemoryFree(memory); -} - -void SbMemoryDeallocateNoReport(void* memory) { - SbMemoryDeallocate(memory); -} - -void SbMemoryDeallocateAligned(void* memory) { - // Report must happen first or else a race condition allows the memory to - // be freed and then reported as allocated, before the allocation is removed. - SbMemoryFreeAligned(memory); -} - -// Same as SbMemoryReallocateUnchecked, but will abort() in the case of an -// allocation failure -void* SbMemoryReallocateChecked(void* memory, size_t size) { - void* address = SbMemoryReallocateUnchecked(memory, size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -// Same as SbMemoryAllocateAlignedUnchecked, but will abort() in the case of an -// allocation failure -void* SbMemoryAllocateAlignedChecked(size_t alignment, size_t size) { - void* address = SbMemoryAllocateAlignedUnchecked(alignment, size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -void* SbMemoryAllocateChecked(size_t size) { - void* address = SbMemoryAllocateUnchecked(size); - SbAbortIfAllocationFailed(size, address); - return address; -} - -namespace { - -inline void* SbMemoryAllocateImpl(size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryAllocateChecked(size); -#else - return SbMemoryAllocateUnchecked(size); -#endif -} - -inline void* SbMemoryAllocateAlignedImpl(size_t alignment, size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryAllocateAlignedChecked(alignment, size); -#else - return SbMemoryAllocateAlignedUnchecked(alignment, size); -#endif -} - -inline void* SbMemoryReallocateImpl(void* memory, size_t size) { -#if SB_ABORT_ON_ALLOCATION_FAILURE - return SbMemoryReallocateChecked(memory, size); -#else - return SbMemoryReallocateUnchecked(memory, size); -#endif -} - -} // namespace - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/starboard/string_duplicate.cc b/starboard/shared/starboard/string_duplicate.cc deleted file mode 100644 index db66152ed262..000000000000 --- a/starboard/shared/starboard/string_duplicate.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -#include "starboard/common/log.h" -#include "starboard/memory.h" - -char* SbStringDuplicate(const char* source) { - size_t length = strlen(source); - char* result = static_cast(SbMemoryAllocate(length + 1)); - SB_DCHECK(length < kSbInt32Max); - int int_length = static_cast(length + 1); - starboard::strlcpy(result, source, int_length); - - return result; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_caption_settings.cc b/starboard/shared/stub/accessibility_get_caption_settings.cc deleted file mode 100644 index b0fc543a3e04..000000000000 --- a/starboard/shared/stub/accessibility_get_caption_settings.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/common/memory.h" - -bool SbAccessibilityGetCaptionSettings( - SbAccessibilityCaptionSettings* caption_settings) { - if (!caption_settings || - !starboard::common::MemoryIsZero( - caption_settings, sizeof(SbAccessibilityCaptionSettings))) { - return false; - } - - // Since kSbAccessibilityCaptionStateUnsupported == 0, there is no need to - // explicitly set states to kSbAccessibilityCaptionStateUnsupported. - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_display_settings.cc b/starboard/shared/stub/accessibility_get_display_settings.cc deleted file mode 100644 index 493666c1b576..000000000000 --- a/starboard/shared/stub/accessibility_get_display_settings.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" - -#include "starboard/common/memory.h" - -bool SbAccessibilityGetDisplaySettings( - SbAccessibilityDisplaySettings* out_setting) { - if (!out_setting || - !starboard::common::MemoryIsZero( - out_setting, sizeof(SbAccessibilityDisplaySettings))) { - return false; - } - out_setting->has_high_contrast_text_setting = false; - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc b/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc deleted file mode 100644 index 0ae831dbfc1a..000000000000 --- a/starboard/shared/stub/accessibility_get_text_to_speech_settings.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" - -#include "starboard/common/memory.h" - -bool SbAccessibilityGetTextToSpeechSettings( - SbAccessibilityTextToSpeechSettings* out_setting) { - if (!out_setting || - !starboard::common::MemoryIsZero( - out_setting, sizeof(SbAccessibilityTextToSpeechSettings))) { - return false; - } - out_setting->has_text_to_speech_setting = false; - return true; -} - -#endif diff --git a/starboard/shared/stub/accessibility_set_captions_enabled.cc b/starboard/shared/stub/accessibility_set_captions_enabled.cc deleted file mode 100644 index 458c43b50415..000000000000 --- a/starboard/shared/stub/accessibility_set_captions_enabled.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/accessibility.h" -#include "starboard/configuration.h" - -bool SbAccessibilitySetCaptionsEnabled(bool enabled) { - return false; -} - -#endif diff --git a/starboard/shared/stub/byte_swap.cc b/starboard/shared/stub/byte_swap.cc deleted file mode 100644 index a64b2020eb0e..000000000000 --- a/starboard/shared/stub/byte_swap.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -int16_t SbByteSwapS16(int16_t value) { - return 0; -} - -uint16_t SbByteSwapU16(uint16_t value) { - return 0; -} - -int32_t SbByteSwapS32(int32_t value) { - return 0; -} - -uint32_t SbByteSwapU32(uint32_t value) { - return 0; -} - -int64_t SbByteSwapS64(int64_t value) { - return 0; -} - -uint64_t SbByteSwapU64(uint64_t value) { - return 0; -} - -#endif diff --git a/starboard/shared/stub/condition_variable_broadcast.cc b/starboard/shared/stub/condition_variable_broadcast.cc deleted file mode 100644 index 056366ac914b..000000000000 --- a/starboard/shared/stub/condition_variable_broadcast.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableBroadcast(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_create.cc b/starboard/shared/stub/condition_variable_create.cc deleted file mode 100644 index 1589001f9a55..000000000000 --- a/starboard/shared/stub/condition_variable_create.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableCreate(SbConditionVariable* out_condition, - SbMutex* opt_mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_destroy.cc b/starboard/shared/stub/condition_variable_destroy.cc deleted file mode 100644 index 654d2b1c9318..000000000000 --- a/starboard/shared/stub/condition_variable_destroy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableDestroy(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_signal.cc b/starboard/shared/stub/condition_variable_signal.cc deleted file mode 100644 index 6f905ead1d47..000000000000 --- a/starboard/shared/stub/condition_variable_signal.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -bool SbConditionVariableSignal(SbConditionVariable* condition) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait.cc b/starboard/shared/stub/condition_variable_wait.cc deleted file mode 100644 index 8735a72337bb..000000000000 --- a/starboard/shared/stub/condition_variable_wait.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -SbConditionVariableResult SbConditionVariableWait( - SbConditionVariable* condition, - SbMutex* mutex) { - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/condition_variable_wait_timed.cc b/starboard/shared/stub/condition_variable_wait_timed.cc deleted file mode 100644 index 908759d0f98a..000000000000 --- a/starboard/shared/stub/condition_variable_wait_timed.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -SbConditionVariableResult SbConditionVariableWaitTimed( - SbConditionVariable* condition, - SbMutex* mutex, - int64_t timeout) { - return kSbConditionVariableFailed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_can_open.cc b/starboard/shared/stub/directory_can_open.cc deleted file mode 100644 index 8f69f9abb4f2..000000000000 --- a/starboard/shared/stub/directory_can_open.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -bool SbDirectoryCanOpen(const char* path) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_close.cc b/starboard/shared/stub/directory_close.cc deleted file mode 100644 index 894465617548..000000000000 --- a/starboard/shared/stub/directory_close.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -bool SbDirectoryClose(SbDirectory directory) { - return false; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/directory_create.cc b/starboard/shared/stub/directory_create.cc deleted file mode 100644 index f82885ca3b80..000000000000 --- a/starboard/shared/stub/directory_create.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -bool SbDirectoryCreate(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/directory_get_next.cc b/starboard/shared/stub/directory_get_next.cc deleted file mode 100644 index f7f81c652ba6..000000000000 --- a/starboard/shared/stub/directory_get_next.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - return false; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/directory_open.cc b/starboard/shared/stub/directory_open.cc deleted file mode 100644 index 19e1d6fc2af2..000000000000 --- a/starboard/shared/stub/directory_open.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - return kSbDirectoryInvalid; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_can_open.cc b/starboard/shared/stub/file_can_open.cc deleted file mode 100644 index 132438067b99..000000000000 --- a/starboard/shared/stub/file_can_open.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileCanOpen(const char* path, int flags) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_close.cc b/starboard/shared/stub/file_close.cc deleted file mode 100644 index 768d28e26435..000000000000 --- a/starboard/shared/stub/file_close.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileClose(SbFile file) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_delete.cc b/starboard/shared/stub/file_delete.cc deleted file mode 100644 index 298b5e0912bf..000000000000 --- a/starboard/shared/stub/file_delete.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileDelete(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_exists.cc b/starboard/shared/stub/file_exists.cc deleted file mode 100644 index 37ccdd18ab7c..000000000000 --- a/starboard/shared/stub/file_exists.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileExists(const char* path) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/file_flush.cc b/starboard/shared/stub/file_flush.cc deleted file mode 100644 index 48268327c115..000000000000 --- a/starboard/shared/stub/file_flush.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileFlush(SbFile file) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_get_info.cc b/starboard/shared/stub/file_get_info.cc deleted file mode 100644 index aa8d32f762f2..000000000000 --- a/starboard/shared/stub/file_get_info.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_get_path_info.cc b/starboard/shared/stub/file_get_path_info.cc deleted file mode 100644 index 6b441b45302e..000000000000 --- a/starboard/shared/stub/file_get_path_info.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/file_open.cc b/starboard/shared/stub/file_open.cc deleted file mode 100644 index 084fbd7eb37b..000000000000 --- a/starboard/shared/stub/file_open.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - return kSbFileInvalid; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_read.cc b/starboard/shared/stub/file_read.cc deleted file mode 100644 index 8db62d342148..000000000000 --- a/starboard/shared/stub/file_read.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int SbFileRead(SbFile file, char* data, int size) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_seek.cc b/starboard/shared/stub/file_seek.cc deleted file mode 100644 index 3655631fd497..000000000000 --- a/starboard/shared/stub/file_seek.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_truncate.cc b/starboard/shared/stub/file_truncate.cc deleted file mode 100644 index 21c63ca67f52..000000000000 --- a/starboard/shared/stub/file_truncate.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -bool SbFileTruncate(SbFile file, int64_t length) { - return false; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/file_write.cc b/starboard/shared/stub/file_write.cc deleted file mode 100644 index 35e1314a784c..000000000000 --- a/starboard/shared/stub/file_write.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - return 0; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/stub/image_decode.cc b/starboard/shared/stub/image_decode.cc deleted file mode 100644 index b5721162269b..000000000000 --- a/starboard/shared/stub/image_decode.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/image.h" - -SbDecodeTarget SbImageDecode(SbDecodeTargetGraphicsContextProvider* provider, - void* data, - int data_size, - const char* mime_type, - SbDecodeTargetFormat format) { - return kSbDecodeTargetInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/image_is_decode_supported.cc b/starboard/shared/stub/image_is_decode_supported.cc deleted file mode 100644 index 953169e6aeee..000000000000 --- a/starboard/shared/stub/image_is_decode_supported.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/image.h" - -bool SbImageIsDecodeSupported(const char* mime_type, - SbDecodeTargetFormat format) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/media_get_buffer_storage_type.cc b/starboard/shared/stub/media_get_buffer_storage_type.cc deleted file mode 100644 index 23db3566c2ea..000000000000 --- a/starboard/shared/stub/media_get_buffer_storage_type.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" - -#if SB_API_VERSION < 16 -SbMediaBufferStorageType SbMediaGetBufferStorageType() { - return static_cast(0); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire.cc b/starboard/shared/stub/mutex_acquire.cc deleted file mode 100644 index db64efd19d1c..000000000000 --- a/starboard/shared/stub/mutex_acquire.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -SbMutexResult SbMutexAcquire(SbMutex* mutex) { - return kSbMutexDestroyed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_acquire_try.cc b/starboard/shared/stub/mutex_acquire_try.cc deleted file mode 100644 index e59f2db4b581..000000000000 --- a/starboard/shared/stub/mutex_acquire_try.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { - return kSbMutexDestroyed; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_create.cc b/starboard/shared/stub/mutex_create.cc deleted file mode 100644 index 52876be4af47..000000000000 --- a/starboard/shared/stub/mutex_create.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexCreate(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_destroy.cc b/starboard/shared/stub/mutex_destroy.cc deleted file mode 100644 index e62414a53ec4..000000000000 --- a/starboard/shared/stub/mutex_destroy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexDestroy(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/mutex_release.cc b/starboard/shared/stub/mutex_release.cc deleted file mode 100644 index 21f81caf467a..000000000000 --- a/starboard/shared/stub/mutex_release.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -bool SbMutexRelease(SbMutex* mutex) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/once.cc b/starboard/shared/stub/once.cc deleted file mode 100644 index 570f6c4690d2..000000000000 --- a/starboard/shared/stub/once.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/once.h" - -bool SbOnce(SbOnceControl* once_control, SbOnceInitRoutine init_routine) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/storage_delete_record.cc b/starboard/shared/stub/storage_delete_record.cc index 3680cdd97128..f4bc24f007f7 100644 --- a/starboard/shared/stub/storage_delete_record.cc +++ b/starboard/shared/stub/storage_delete_record.cc @@ -14,10 +14,6 @@ #include "starboard/common/storage.h" -#if SB_API_VERSION < 16 -bool SbStorageDeleteRecord(SbUser user, const char* name) { -#else bool SbStorageDeleteRecord(const char* name) { -#endif return false; } diff --git a/starboard/shared/stub/storage_open_record.cc b/starboard/shared/stub/storage_open_record.cc index 25af8d1e2065..5ffbc0fca294 100644 --- a/starboard/shared/stub/storage_open_record.cc +++ b/starboard/shared/stub/storage_open_record.cc @@ -14,10 +14,6 @@ #include "starboard/common/storage.h" -#if SB_API_VERSION < 16 -SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name) { -#else SbStorageRecord SbStorageOpenRecord(const char* name) { -#endif return kSbStorageInvalidRecord; } diff --git a/starboard/shared/stub/string_compare_no_case.cc b/starboard/shared/stub/string_compare_no_case.cc deleted file mode 100644 index aa767bdb86be..000000000000 --- a/starboard/shared/stub/string_compare_no_case.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringCompareNoCase(const char* string1, const char* string2) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_compare_no_case_n.cc b/starboard/shared/stub/string_compare_no_case_n.cc deleted file mode 100644 index aa7ae6323c75..000000000000 --- a/starboard/shared/stub/string_compare_no_case_n.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringCompareNoCaseN(const char* string1, - const char* string2, - size_t count) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_duplicate.cc b/starboard/shared/stub/string_duplicate.cc deleted file mode 100644 index 1514acc6dc27..000000000000 --- a/starboard/shared/stub/string_duplicate.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 - -char* SbStringDuplicate(const char* source) { - return NULL; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/string_format.cc b/starboard/shared/stub/string_format.cc deleted file mode 100644 index 66a996088ceb..000000000000 --- a/starboard/shared/stub/string_format.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringFormat(char* out_buffer, - size_t buffer_size, - const char* format, - va_list arguments) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_format_wide.cc b/starboard/shared/stub/string_format_wide.cc deleted file mode 100644 index 4bcabdf50d06..000000000000 --- a/starboard/shared/stub/string_format_wide.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#if SB_API_VERSION < 16 -int SbStringFormatWide(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - va_list arguments) { - return 0; -} -#endif diff --git a/starboard/shared/stub/string_scan.cc b/starboard/shared/stub/string_scan.cc deleted file mode 100644 index 6646a905a8e7..000000000000 --- a/starboard/shared/stub/string_scan.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/string.h" - -int SbStringScan(const char* buffer, const char* pattern, va_list arguments) { - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_create.cc b/starboard/shared/stub/thread_create.cc deleted file mode 100644 index 5b93031f9d75..000000000000 --- a/starboard/shared/stub/thread_create.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - return kSbThreadInvalid; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_create_local_key.cc b/starboard/shared/stub/thread_create_local_key.cc deleted file mode 100644 index dd9324efa7e7..000000000000 --- a/starboard/shared/stub/thread_create_local_key.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) { - return kSbThreadLocalKeyInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_destroy_local_key.cc b/starboard/shared/stub/thread_destroy_local_key.cc deleted file mode 100644 index 055adc5a2aae..000000000000 --- a/starboard/shared/stub/thread_destroy_local_key.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadDestroyLocalKey(SbThreadLocalKey key) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_detach.cc b/starboard/shared/stub/thread_detach.cc deleted file mode 100644 index 381a25025f0a..000000000000 --- a/starboard/shared/stub/thread_detach.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/thread.h" - -void SbThreadDetach(SbThread thread) {} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_current.cc b/starboard/shared/stub/thread_get_current.cc deleted file mode 100644 index d6b495c38b9d..000000000000 --- a/starboard/shared/stub/thread_get_current.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -SbThread SbThreadGetCurrent() { - return kSbThreadInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_local_value.cc b/starboard/shared/stub/thread_get_local_value.cc deleted file mode 100644 index ac0e867197e9..000000000000 --- a/starboard/shared/stub/thread_get_local_value.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void* SbThreadGetLocalValue(SbThreadLocalKey key) { - return NULL; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_get_name.cc b/starboard/shared/stub/thread_get_name.cc deleted file mode 100644 index 6f9719219726..000000000000 --- a/starboard/shared/stub/thread_get_name.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadGetName(char* buffer, int buffer_size) {} - -#endif diff --git a/starboard/shared/stub/thread_is_equal.cc b/starboard/shared/stub/thread_is_equal.cc deleted file mode 100644 index d1cf10aacd03..000000000000 --- a/starboard/shared/stub/thread_is_equal.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_join.cc b/starboard/shared/stub/thread_join.cc deleted file mode 100644 index d19376e56d07..000000000000 --- a/starboard/shared/stub/thread_join.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadJoin(SbThread thread, void** out_return) { - return false; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_sampler_create.cc b/starboard/shared/stub/thread_sampler_create.cc index 9fbe64b5cd26..5131a4d48749 100644 --- a/starboard/shared/stub/thread_sampler_create.cc +++ b/starboard/shared/stub/thread_sampler_create.cc @@ -15,11 +15,7 @@ #include "starboard/common/log.h" #include "starboard/thread.h" -#if SB_API_VERSION < 16 -SbThreadSampler SbThreadSamplerCreate(SbThread thread) { -#else SbThreadSampler SbThreadSamplerCreate(pthread_t thread) { -#endif SB_NOTIMPLEMENTED() << "Profiling is not supported on this platform."; return kSbThreadSamplerInvalid; } diff --git a/starboard/shared/stub/thread_set_local_value.cc b/starboard/shared/stub/thread_set_local_value.cc deleted file mode 100644 index a716c543a81d..000000000000 --- a/starboard/shared/stub/thread_set_local_value.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/thread_set_name.cc b/starboard/shared/stub/thread_set_name.cc deleted file mode 100644 index dd5592db568b..000000000000 --- a/starboard/shared/stub/thread_set_name.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -void SbThreadSetName(const char* name) {} - -#endif diff --git a/starboard/shared/stub/time_get_monotonic_now.cc b/starboard/shared/stub/time_get_monotonic_now.cc deleted file mode 100644 index a012ce20ab38..000000000000 --- a/starboard/shared/stub/time_get_monotonic_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTimeMonotonic SbTimeGetMonotonicNow() { - return SbTimeMonotonic(); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_get_monotonic_thread_now.cc b/starboard/shared/stub/time_get_monotonic_thread_now.cc deleted file mode 100644 index edafecbdf13c..000000000000 --- a/starboard/shared/stub/time_get_monotonic_thread_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTimeMonotonic SbTimeGetMonotonicThreadNow() { - return SbTimeMonotonic(0); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_get_now.cc b/starboard/shared/stub/time_get_now.cc deleted file mode 100644 index 25362a35846b..000000000000 --- a/starboard/shared/stub/time_get_now.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -SbTime SbTimeGetNow() { - return SbTime(); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/time_is_time_thread_now_supported.cc b/starboard/shared/stub/time_is_time_thread_now_supported.cc deleted file mode 100644 index d60e58a4fadd..000000000000 --- a/starboard/shared/stub/time_is_time_thread_now_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -bool SbTimeIsTimeThreadNowSupported() { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/ui_nav_get_interface.cc b/starboard/shared/stub/ui_nav_get_interface.cc deleted file mode 100644 index 66e80ca257c6..000000000000 --- a/starboard/shared/stub/ui_nav_get_interface.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/ui_navigation.h" - -bool SbUiNavGetInterface(SbUiNavInterface* out_interface) { - return false; -} - -#endif // SB_API_VERSION diff --git a/starboard/shared/stub/user_get_current.cc b/starboard/shared/stub/user_get_current.cc deleted file mode 100644 index ead08b7d0bbd..000000000000 --- a/starboard/shared/stub/user_get_current.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -SbUser SbUserGetCurrent() { - return kSbUserInvalid; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/user_get_property.cc b/starboard/shared/stub/user_get_property.cc deleted file mode 100644 index cdb9b4e2f5dd..000000000000 --- a/starboard/shared/stub/user_get_property.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id) { - return 0; -} - -bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size) { - return false; -} - -#endif diff --git a/starboard/shared/stub/user_get_signed_in.cc b/starboard/shared/stub/user_get_signed_in.cc deleted file mode 100644 index 7fbfcc36ba50..000000000000 --- a/starboard/shared/stub/user_get_signed_in.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/user.h" - -int SbUserGetSignedIn(SbUser* out_users, int users_size) { - return 0; -} - -#endif diff --git a/starboard/shared/stub/window_blur_on_screen_keyboard.cc b/starboard/shared/stub/window_blur_on_screen_keyboard.cc deleted file mode 100644 index 389485ea8dd1..000000000000 --- a/starboard/shared/stub/window_blur_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowBlurOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_focus_on_screen_keyboard.cc b/starboard/shared/stub/window_focus_on_screen_keyboard.cc deleted file mode 100644 index 90d8e30e5a57..000000000000 --- a/starboard/shared/stub/window_focus_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowFocusOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc b/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc deleted file mode 100644 index 4f34c6b4eaef..000000000000 --- a/starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowGetOnScreenKeyboardBoundingRect(SbWindow window, - SbWindowRect* bounding_rect) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_hide_on_screen_keyboard.cc b/starboard/shared/stub/window_hide_on_screen_keyboard.cc deleted file mode 100644 index 22d982c454ac..000000000000 --- a/starboard/shared/stub/window_hide_on_screen_keyboard.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowHideOnScreenKeyboard(SbWindow window, int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc b/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc deleted file mode 100644 index 1578d07fff2d..000000000000 --- a/starboard/shared/stub/window_is_on_screen_keyboard_shown.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowIsOnScreenKeyboardShown(SbWindow window) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc b/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc deleted file mode 100644 index 007245bd06ab..000000000000 --- a/starboard/shared/stub/window_on_screen_keyboard_is_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowOnScreenKeyboardIsSupported() { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc b/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc deleted file mode 100644 index 6b4fefd5d4a0..000000000000 --- a/starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -bool SbWindowOnScreenKeyboardSuggestionsSupported(SbWindow window) { - return false; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc b/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc deleted file mode 100644 index 3a61e02db64c..000000000000 --- a/starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowSetOnScreenKeyboardKeepFocus(SbWindow window, bool keep_focus) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_show_on_screen_keyboard.cc b/starboard/shared/stub/window_show_on_screen_keyboard.cc deleted file mode 100644 index 7ffca5fa6e91..000000000000 --- a/starboard/shared/stub/window_show_on_screen_keyboard.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowShowOnScreenKeyboard(SbWindow window, - const char* input_text, - int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc b/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc deleted file mode 100644 index 3ad65ba87da7..000000000000 --- a/starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#if SB_API_VERSION < 16 - -void SbWindowUpdateOnScreenKeyboardSuggestions(SbWindow window, - const char* suggestions[], - int num_suggestions, - int ticket) {} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/uwp/analog_thumbstick_input.cc b/starboard/shared/uwp/analog_thumbstick_input.cc deleted file mode 100644 index 4a7f4e763212..000000000000 --- a/starboard/shared/uwp/analog_thumbstick_input.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2017 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "starboard/shared/uwp/analog_thumbstick_input.h" - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/types.h" - -#pragma comment(lib, "xinput9_1_0.lib") - -using Windows::Foundation::Collections::IVectorView; -using Windows::Gaming::Input::Gamepad; -using Windows::Gaming::Input::GamepadReading; -using Windows::Gaming::Input::RawGameController; - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -const int kMaxPlayerCounter = 4; -const float kDeadZoneThreshold = .24f; - -float ApplyLinearDeadZone(float value, float maxValue, float deadZoneSize) { - if (value < -deadZoneSize) { - // Increase negative values to remove the deadzone discontinuity. - value += deadZoneSize; - } else if (value > deadZoneSize) { - // Decrease positive values to remove the deadzone discontinuity. - value -= deadZoneSize; - } else { - // Values inside the deadzone come out zero. - return 0; - } - - // Scale into 0-1 range. - float scaledValue = value / (maxValue - deadZoneSize); - return std::max(-1.f, std::min(scaledValue, 1.f)); -} - -void ApplyStickDeadZone(float x, - float y, - float max_value, - float dead_zone_size, - float* result_x, - float* result_y) { - *result_x = ApplyLinearDeadZone(x, max_value, dead_zone_size); - *result_y = ApplyLinearDeadZone(y, max_value, dead_zone_size); -} - -ThumbSticks ReadThumbStick(Gamepad ^ controller) { - ThumbSticks output; - GamepadReading reading = controller->GetCurrentReading(); - - ApplyStickDeadZone(static_cast(reading.LeftThumbstickX), - static_cast(reading.LeftThumbstickY), 1.f, - kDeadZoneThreshold, &output.left_x, &output.left_y); - - ApplyStickDeadZone(static_cast(reading.RightThumbstickX), - static_cast(reading.RightThumbstickY), 1.f, - kDeadZoneThreshold, &output.right_x, &output.right_y); - return output; -} -} // namespace - -void GetGamepadThumbSticks(std::vector* destination) { - destination->erase(destination->begin(), destination->end()); - - // This profiled to an average time of 33us to execute. - IVectorView ^ gamepads = Gamepad::Gamepads; - - // This profiled to take on average 9us of time to read controller state. - const uint32_t n = gamepads->Size; - for (uint32_t i = 0; i < n; ++i) { - Gamepad ^ gamepad = gamepads->GetAt(i); - ThumbSticks thumb_stick = ReadThumbStick(gamepad); - destination->push_back(thumb_stick); - } -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/analog_thumbstick_input.h b/starboard/shared/uwp/analog_thumbstick_input.h deleted file mode 100644 index bfa5a39d218d..000000000000 --- a/starboard/shared/uwp/analog_thumbstick_input.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2017 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_H_ -#define STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_H_ - -#include - -#include "starboard/types.h" - -namespace starboard { -namespace shared { -namespace uwp { - -struct ThumbSticks { - float left_x = 0.0f; - float left_y = 0.0f; - float right_x = 0.0f; - float right_y = 0.0f; -}; - -// Reads all connected game pads and stores the joystick states in the -// destination vector. Note that the destination vector is unconditionally -// cleared before being populated. -void GetGamepadThumbSticks(std::vector* destination); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_H_ diff --git a/starboard/shared/uwp/analog_thumbstick_input_thread.cc b/starboard/shared/uwp/analog_thumbstick_input_thread.cc deleted file mode 100644 index e8eb3f159ce8..000000000000 --- a/starboard/shared/uwp/analog_thumbstick_input_thread.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2017 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "starboard/shared/uwp/analog_thumbstick_input_thread.h" - -#include - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/thread.h" -#include "starboard/shared/uwp/analog_thumbstick_input.h" -#include "starboard/thread.h" - -namespace starboard { -namespace shared { -namespace uwp { - -class AnalogThumbstickThread::Impl : public Thread { - public: - explicit Impl(Callback* cb) : Thread("AnalogGamepad"), callback_(cb) { - stick_is_centered_[kSbKeyGamepadLeftStickLeft] = true; - stick_is_centered_[kSbKeyGamepadRightStickLeft] = true; - stick_is_centered_[kSbKeyGamepadLeftStickUp] = true; - stick_is_centered_[kSbKeyGamepadRightStickUp] = true; - - Thread::Start(); - } - ~Impl() { Thread::Join(); } - - void Run() override { - while (!join_called()) { - Update(); - // 120hz to provide smooth 60fps playback. - usleep(1'000'000LL / kPollingFrequency); - } - } - - void Update() { - ThumbSticks thumb_state = GetCombinedThumbStickState(); - - FireEventIfNecessary(kSbKeyGamepadLeftStickLeft, thumb_state.left_x); - FireEventIfNecessary(kSbKeyGamepadLeftStickUp, thumb_state.left_y); - FireEventIfNecessary(kSbKeyGamepadRightStickLeft, thumb_state.right_x); - FireEventIfNecessary(kSbKeyGamepadRightStickUp, thumb_state.right_y); - } - - void FireEventIfNecessary(SbKey sb_key, float value) { - if (value == 0.0f) { - if (stick_is_centered_[sb_key]) { - // The previous stick input is in center position, so it is not - // necessary to inject another center input event. - return; - } - stick_is_centered_[sb_key] = true; - } else { - stick_is_centered_[sb_key] = false; - } - - SbInputVector input_vector = {0, 0}; - - switch (sb_key) { - case kSbKeyGamepadRightStickLeft: - case kSbKeyGamepadLeftStickLeft: { - input_vector.x = value; - break; - } - case kSbKeyGamepadRightStickUp: - case kSbKeyGamepadLeftStickUp: { - input_vector.y = -value; - break; - } - default: { - SB_NOTREACHED(); - break; - } - } - callback_->OnJoystickUpdate(sb_key, input_vector); - } - - ThumbSticks GetCombinedThumbStickState() { - ThumbSticks all_thumb_state; - GetGamepadThumbSticks(&thumb_sticks_); - - for (int i = 0; i < thumb_sticks_.size(); ++i) { - ThumbSticks thumb_state = thumb_sticks_[i]; - - all_thumb_state.left_x += thumb_state.left_x; - all_thumb_state.left_y += thumb_state.left_y; - all_thumb_state.right_x += thumb_state.right_x; - all_thumb_state.right_y += thumb_state.right_y; - } - - all_thumb_state.left_x = ClampToZeroOne(all_thumb_state.left_x); - all_thumb_state.left_y = ClampToZeroOne(all_thumb_state.left_y); - all_thumb_state.right_x = ClampToZeroOne(all_thumb_state.right_x); - all_thumb_state.right_y = ClampToZeroOne(all_thumb_state.right_y); - - return all_thumb_state; - } - - static float ClampToZeroOne(float in) { - return std::max(-1.0f, std::min(1.0f, in)); - } - Callback* callback_; - std::map stick_is_centered_; - std::vector thumb_sticks_; -}; - -AnalogThumbstickThread::AnalogThumbstickThread(Callback* cb) { - impl_.reset(new Impl(cb)); -} - -AnalogThumbstickThread::~AnalogThumbstickThread() { - impl_.reset(nullptr); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/analog_thumbstick_input_thread.h b/starboard/shared/uwp/analog_thumbstick_input_thread.h deleted file mode 100644 index 06700b2d1b07..000000000000 --- a/starboard/shared/uwp/analog_thumbstick_input_thread.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2017 The Cobalt Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_THREAD_H_ -#define STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_THREAD_H_ - -#include - -#include "starboard/configuration.h" -#include "starboard/input.h" - -namespace starboard { -namespace shared { -namespace uwp { - -// This class represents a thread that will poll all gamepads for -// the analog sticks. The sticks are summed together and then -// the callback will be invoked with the thumbstick values. -class AnalogThumbstickThread { - public: - enum { kPollingFrequency = 120 }; // Smooth playback for 60fps. - - class Callback { - public: - virtual ~Callback() {} - virtual void OnJoystickUpdate(SbKey key, SbInputVector position) = 0; - }; - - explicit AnalogThumbstickThread(Callback* cb); - ~AnalogThumbstickThread(); - - private: - AnalogThumbstickThread(const AnalogThumbstickThread&) = delete; - void operator=(const AnalogThumbstickThread&) = delete; - - class Impl; - std::unique_ptr impl_; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_ANALOG_THUMBSTICK_INPUT_THREAD_H_ diff --git a/starboard/shared/uwp/app_accessors.h b/starboard/shared/uwp/app_accessors.h deleted file mode 100644 index 77b5e6b44a56..000000000000 --- a/starboard/shared/uwp/app_accessors.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_APP_ACCESSORS_H_ -#define STARBOARD_SHARED_UWP_APP_ACCESSORS_H_ - -// A set of application and main-thread accessors -// so as to avoid including application_uwp.h - -#include -#include - -#include - -#include "starboard/key.h" - -namespace starboard { -namespace shared { -namespace uwp { - -// Returns the main window's CoreDispatcher. -Platform::Agile GetDispatcher(); - -// Returns the main window's SystemMediaTransportControls. -Platform::Agile -GetTransportControls(); - -// Asks the screen to remain active via -// Windows::System::DisplayRequest->RequestActive() -void DisplayRequestActive(); - -// Releases previous screen active request via -// Windows::System::DisplayRequest->RequestRelease() -void DisplayRequestRelease(); - -// Schedules a lambda to run on the main thread and returns immediately. -template -void RunInMainThreadAsync(const T& lambda) { - GetDispatcher()->RunAsync( - Windows::UI::Core::CoreDispatcherPriority::Normal, - ref new Windows::UI::Core::DispatchedHandler(lambda)); -} - -void InjectKeypress(SbKey key); - -} // namespace uwp -} // namespace shared -} // namespace starboard -#endif // STARBOARD_SHARED_UWP_APP_ACCESSORS_H_ diff --git a/starboard/shared/uwp/application_uwp.cc b/starboard/shared/uwp/application_uwp.cc deleted file mode 100644 index 472a03878e43..000000000000 --- a/starboard/shared/uwp/application_uwp.cc +++ /dev/null @@ -1,1373 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/application_uwp.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "starboard/common/device_type.h" -#include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/queue.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" -#include "starboard/common/system_property.h" -#include "starboard/common/thread.h" -#include "starboard/common/time.h" -#include "starboard/configuration_constants.h" -#include "starboard/event.h" -#include "starboard/input.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/starboard/audio_sink/audio_sink_internal.h" -#include "starboard/shared/starboard/media/key_system_supportability_cache.h" -#include "starboard/shared/starboard/media/mime_supportability_cache.h" -#include "starboard/shared/starboard/net_args.h" -#include "starboard/shared/starboard/net_log.h" -#include "starboard/shared/uwp/analog_thumbstick_input_thread.h" -#include "starboard/shared/uwp/app_accessors.h" -#include "starboard/shared/uwp/async_utils.h" -#include "starboard/shared/uwp/extended_resources_manager.h" -#include "starboard/shared/uwp/log_file_impl.h" -#include "starboard/shared/uwp/watchdog_log.h" -#include "starboard/shared/uwp/window_internal.h" -#include "starboard/shared/win32/thread_private.h" -#include "starboard/shared/win32/time_utils.h" -#include "starboard/shared/win32/video_decoder.h" -#include "starboard/shared/win32/wchar_utils.h" - -#include "starboard/system.h" - -namespace starboard { - -using Microsoft::WRL::ComPtr; -using shared::starboard::Application; -using shared::starboard::CommandLine; -using shared::starboard::kNetArgsCommandSwitchWait; -using shared::starboard::kNetLogCommandSwitchWait; -using shared::starboard::NetArgsWaitForPayload; -using shared::starboard::NetLogFlushThenClose; -using shared::starboard::NetLogWaitForClientConnected; -using shared::uwp::ApplicationUwp; -using shared::uwp::RunInMainThreadAsync; -using shared::uwp::WaitForResult; -using shared::win32::ConvertUsecToMillisRoundUp; -using shared::win32::platformStringToString; -using shared::win32::stringToPlatformString; -using shared::win32::wchar_tToUTF8; -using ::starboard::shared::starboard::media::KeySystemSupportabilityCache; -using ::starboard::shared::starboard::media::MimeSupportabilityCache; -using Windows::ApplicationModel::SuspendingDeferral; -using Windows::ApplicationModel::SuspendingEventArgs; -using Windows::ApplicationModel::Activation::ActivationKind; -using Windows::ApplicationModel::Activation::DialReceiverActivatedEventArgs; -using Windows::ApplicationModel::Activation::IActivatedEventArgs; -using Windows::ApplicationModel::Activation::IProtocolActivatedEventArgs; -using Windows::ApplicationModel::Core::CoreApplication; -using Windows::ApplicationModel::Core::CoreApplicationView; -using Windows::ApplicationModel::Core::IFrameworkView; -using Windows::ApplicationModel::Core::IFrameworkViewSource; -using Windows::ApplicationModel::ExtendedExecution::ExtendedExecutionReason; -using Windows::ApplicationModel::ExtendedExecution::ExtendedExecutionResult; -using Windows::ApplicationModel::ExtendedExecution:: - ExtendedExecutionRevokedEventArgs; -using Windows::ApplicationModel::ExtendedExecution::ExtendedExecutionSession; -using Windows::Devices::Enumeration::DeviceInformation; -using Windows::Devices::Enumeration::DeviceInformationUpdate; -using Windows::Devices::Enumeration::DeviceWatcher; -using Windows::Devices::Enumeration::DeviceWatcherStatus; -using Windows::Foundation::EventHandler; -using Windows::Foundation::IAsyncOperation; -using Windows::Foundation::TimeSpan; -using Windows::Foundation::TypedEventHandler; -using Windows::Foundation::Uri; -using Windows::Foundation::Collections::IVectorView; -using Windows::Foundation::Metadata::ApiInformation; -using Windows::Globalization::Calendar; -using Windows::Graphics::Display::AdvancedColorInfo; -using Windows::Graphics::Display::AdvancedColorKind; -using Windows::Graphics::Display::DisplayInformation; -using Windows::Graphics::Display::HdrMetadataFormat; -using Windows::Graphics::Display::Core::HdmiDisplayColorSpace; -using Windows::Graphics::Display::Core::HdmiDisplayHdr2086Metadata; -using Windows::Graphics::Display::Core::HdmiDisplayHdrOption; -using Windows::Graphics::Display::Core::HdmiDisplayInformation; -using Windows::Graphics::Display::Core::HdmiDisplayMode; -using Windows::Media::Protection::HdcpProtection; -using Windows::Media::Protection::HdcpSession; -using Windows::Media::Protection::HdcpSetProtectionResult; -using Windows::Security::Authentication::Web::Core::WebTokenRequestResult; -using Windows::Security::Authentication::Web::Core::WebTokenRequestStatus; -using Windows::Security::Credentials::WebAccountProvider; -using Windows::Storage::FileAttributes; -using Windows::Storage::KnownFolders; -using Windows::Storage::StorageFile; -using Windows::Storage::StorageFolder; -using Windows::System::UserAuthenticationStatus; -using Windows::System::Threading::ThreadPoolTimer; -using Windows::System::Threading::TimerElapsedHandler; -using Windows::UI::Core::CoreDispatcherPriority; -using Windows::UI::Core::CoreProcessEventsOption; -using Windows::UI::Core::CoreWindow; -using Windows::UI::Core::DispatchedHandler; -using Windows::UI::Core::KeyEventArgs; -using Windows::UI::ViewManagement::ApplicationView; -using Windows::UI::ViewManagement::ApplicationViewScaling; - -namespace { - -const Platform::String ^ kGenericPnpMonitorAqs = ref new Platform::String( - L"System.Devices.InterfaceClassGuid:=\"{e6f07b5f-ee97-4a90-b076-" - L"33f57bf4eaa7}\" AND " - L"System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#" - L"True"); - -const uint32_t kYuv420BitsPerPixelForHdr10Mode = 24; -const uint32_t kHdr4kRefreshRateMaximum = 60; -const uint32_t k4kResolutionWidth = 3840; -const uint32_t k4kResolutionHeight = 2160; - -// Per Microsoft, HdcpProtection::On means HDCP 1.x required. -const HdcpProtection kHDCPProtectionMode = HdcpProtection::On; - -const int kWinSockVersionMajor = 2; -const int kWinSockVersionMinor = 2; - -const char kDialParamPrefix[] = "cobalt-dial:?"; -const char kLogPathSwitch[] = "xb1_log_file"; -// A special log that the app will periodically write to. This allows -// tests to determine if the app is still alive. -const char kWatchDogLog[] = "xb1_watchdog_log"; -const char kStarboardArgumentsPath[] = "arguments\\starboard_arguments.txt"; -const int64_t kMaxArgumentFileSizeBytes = 4 * 1024 * 1024; - -int main_return_value = 0; - -// IDisplayRequest is both "non-agile" and apparently -// incompatible with Platform::Agile (it doesn't fully implement -// a thread marshaller). We must neither use ComPtr or Platform::Agile -// here. We manually create, access release on the main app thread only. -ABI::Windows::System::Display::IDisplayRequest* display_request = nullptr; - -// If an argv[0] is required, fill it in with the result of -// GetModuleFileName() -std::string GetArgvZero() { - const size_t kMaxModuleNameSize = kSbFileMaxName; - std::vector buffer(kMaxModuleNameSize); - DWORD result = GetModuleFileName(NULL, buffer.data(), buffer.size()); - std::string arg; - if (result == 0) { - arg = "unknown"; - } else { - arg = wchar_tToUTF8(buffer.data(), result).c_str(); - } - return arg; -} - -int MakeDeviceId() { - // TODO: Devices MIGHT have colliding hashcodes. Some other unique int - // ID generation tool would be better. - using Windows::Security::ExchangeActiveSyncProvisioning:: - EasClientDeviceInformation; - auto device_information = ref new EasClientDeviceInformation(); - Platform::String ^ device_id_string = device_information->Id.ToString(); - return device_id_string->GetHashCode(); -} - -#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - -void SplitArgumentsIntoVector(std::string* args, - std::vector* result) { - SB_DCHECK(args); - SB_DCHECK(result); - while (!args->empty()) { - size_t next = args->find(';'); - result->push_back(args->substr(0, next)); - if (next == std::string::npos) { - return; - } - *args = args->substr(next + 1); - } -} - -// Parses a starboard: URI scheme by splitting args at ';' boundaries. -std::vector ParseStarboardUri(const std::string& uri) { - std::vector result; - result.push_back(GetArgvZero()); - - size_t index = uri.find(':'); - if (index == std::string::npos) { - return result; - } - - std::string args = uri.substr(index + 1); - SplitArgumentsIntoVector(&args, &result); - - return result; -} - -void AddArgumentsFromFile(const char* path, std::vector* args) { - ScopedFile file(path, 0); - if (!file.IsValid()) { - SB_LOG(INFO) << path << " is not valid for arguments."; - return; - } - - int64_t file_size = file.GetSize(); - if (file_size > kMaxArgumentFileSizeBytes) { - SB_DLOG(ERROR) << "The arguments file is too big."; - return; - } - - if (file_size <= 0) { - SB_DLOG(INFO) << "Arguments file is empty."; - return; - } - - std::string argument_string(file_size, '\0'); - int return_value = file.ReadAll(&argument_string[0], file_size); - if (return_value < 0) { - SB_DLOG(ERROR) << "Error while reading arguments from file."; - return; - } - argument_string.resize(return_value); - - SplitArgumentsIntoVector(&argument_string, args); -} - -void TryAddCommandArgsFromStarboardFile(std::vector* args) { - std::vector content_directory(kSbFileMaxName); - content_directory[0] = '\0'; - - if (!SbSystemGetPath(kSbSystemPathContentDirectory, content_directory.data(), - content_directory.size())) { - return; - } - - std::string arguments_file_path(static_cast(content_directory.data())); - arguments_file_path += kSbFileSepString; - arguments_file_path += kStarboardArgumentsPath; - - AddArgumentsFromFile(arguments_file_path.c_str(), args); -} - -void AddCommandArgsFromNetArgs(int64_t timeout, - std::vector* args) { - // Detect if NetArgs is enabled for this run. If so then receive and - // then merge the arguments into this run. - SB_LOG(INFO) << "Waiting for net args..."; - std::vector net_args = NetArgsWaitForPayload(timeout); - if (!net_args.empty()) { - std::stringstream ss; - ss << "Found Net Args:\n"; - for (const std::string& s : net_args) { - ss << " " << s << "\n"; - } - SB_LOG(INFO) << ss.str(); - } - // Merge command arguments. - args->insert(args->end(), net_args.begin(), net_args.end()); -} - -#endif // defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - -std::unique_ptr MakeDeepLinkEvent( - const std::string& uri_string) { - SB_LOG(INFO) << "Navigate to: [" << uri_string << "]"; - const size_t kMaxDeepLinkSize = 128 * 1024; - const std::size_t uri_size = uri_string.size(); - if (uri_size > kMaxDeepLinkSize) { - SB_NOTREACHED() << "App launch data too big: " << uri_size; - return nullptr; - } - - const int kBufferSize = static_cast(uri_string.size()) + 1; - char* deep_link = new char[kBufferSize]; - SB_DCHECK(deep_link); - starboard::strlcpy(deep_link, uri_string.c_str(), kBufferSize); - - return std::unique_ptr( - new Application::Event(kSbEventTypeLink, deep_link, - Application::DeleteArrayDestructor)); -} - -// Returns if |full_string| ends with |substring|. -bool ends_with(const std::string& full_string, const std::string& substring) { - if (substring.length() > full_string.length()) { - return false; - } - return std::equal(substring.rbegin(), substring.rend(), full_string.rbegin()); -} - -std::string GetBinaryName() { - std::string full_binary_path = GetArgvZero(); - std::string::size_type index = full_binary_path.rfind(kSbFileSepChar); - if (index == std::string::npos) { - return full_binary_path; - } - - return full_binary_path.substr(index + 1); -} - -void OnDeviceAdded(DeviceWatcher ^, DeviceInformation ^) { - SB_LOG(INFO) << "DisplayStatusWatcher::OnDeviceAdded"; - // We need delay to give time for the display initializing after connect. - Sleep(ConvertUsecToMillisRoundUp(15'000)); - - MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities(); - - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeUnfreeze, NULL, NULL)); - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeReveal, NULL, NULL)); - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeFocus, NULL, NULL)); -} - -void OnDeviceRemoved(DeviceWatcher ^, DeviceInformationUpdate ^) { - // Without signing on OnDeviceRemoved, callback OnDeviceAdded doesn't work. - SB_LOG(INFO) << "DisplayStatusWatcher::OnDeviceRemoved"; - - MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities(); - - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeBlur, NULL, NULL)); - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeConceal, NULL, NULL)); - ApplicationUwp::Get()->Inject( - new ApplicationUwp::Event(kSbEventTypeFreeze, NULL, NULL)); -} - -} // namespace - -namespace shared { -namespace win32 { -// Called into drm_system_playready.cc -extern void DrmSystemOnUwpResume(); -} // namespace win32 -} // namespace shared - -ref class App sealed : public IFrameworkView { - public: - App(int64_t start_time) - : application_start_time_{start_time}, - previously_activated_(false), -#if SB_API_VERSION >= 15 - application_(SbEventHandle), -#endif // SB_API_VERSION >= 15 - is_online_(true) { - } - - // IFrameworkView methods. - virtual void Initialize(CoreApplicationView ^ application_view) { - // The following incantation creates a DisplayRequest and obtains - // its underlying COM interface. - ComPtr inspectable = reinterpret_cast( - ref new Windows::System::Display::DisplayRequest()); - ComPtr dr; - inspectable.As(&dr); - display_request = dr.Detach(); - - SbAudioSinkPrivate::Initialize(); - Windows::Networking::Connectivity::NetworkInformation:: - NetworkStatusChanged += ref new Windows::Networking::Connectivity:: - NetworkStatusChangedEventHandler(this, - &App::OnNetworkStatusChanged); - CoreApplication::Suspending += - ref new EventHandler(this, &App::OnSuspending); - CoreApplication::Resuming += - ref new EventHandler(this, &App::OnResuming); - application_view->Activated += - ref new TypedEventHandler( - this, &App::OnActivated); - - MimeSupportabilityCache::GetInstance()->SetCacheEnabled(true); - KeySystemSupportabilityCache::GetInstance()->SetCacheEnabled(true); - } - - virtual void SetWindow(CoreWindow ^ window) { - ApplicationUwp::Get()->SetCoreWindow(window); - window->KeyUp += ref new TypedEventHandler( - this, &App::OnKeyUp); - window->KeyDown += ref new TypedEventHandler( - this, &App::OnKeyDown); - } - - virtual void Load(Platform::String ^ entry_point) { - entry_point_ = wchar_tToUTF8(entry_point->Data()); - } - - virtual void Run() { -#if SB_API_VERSION >= 15 - main_return_value = - SbRunStarboardMain(static_cast(argv_.size()), - const_cast(argv_.data()), SbEventHandle); -#else - main_return_value = application_.Run(static_cast(argv_.size()), - const_cast(argv_.data())); -#endif // SB_API_VERSION >= 15 - } - virtual void Uninitialize() { - SbAudioSinkPrivate::TearDown(); - display_request->Release(); - display_request = nullptr; - } - - void CompleteSuspendDeferral() { - if (suspend_deferral_ != nullptr) { - // Completing the deferral results in the app being suspended by the OS. - SB_LOG(INFO) << "App is ready to be suspended."; - suspend_deferral_->Complete(); - suspend_deferral_ = nullptr; - } - } - - void ExtendedExecutionSessionRevoked(Object ^ sender, - ExtendedExecutionRevokedEventArgs ^ - args) { - CompleteSuspendDeferral(); - } - - void ForceQuit() { - SB_LOG(ERROR) << "Application is not safe to suspend, forcing exit."; - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeStop, NULL, NULL)); - auto extended_resources_manager = - shared::uwp::ExtendedResourcesManager::GetInstance(); - if (extended_resources_manager) { - extended_resources_manager->Quit(); - } - } - - void OnNetworkStatusChanged(Object ^ sender) { - auto connection_profile = Windows::Networking::Connectivity:: - NetworkInformation::GetInternetConnectionProfile(); - bool is_online = - connection_profile && - connection_profile->GetNetworkConnectivityLevel() != - Windows::Networking::Connectivity::NetworkConnectivityLevel::None; - - // Only inject event if the online status changed. - if (is_online != is_online_) { - auto* application = starboard::shared::starboard::Application::Get(); - - // Verify we have an application and dispatcher before injecting events. - if (application == nullptr) { - SB_LOG(ERROR) << "OnNetworkStatusChanged has no application."; - SB_DCHECK(false); - return; - } - if (starboard::shared::uwp::GetDispatcher().Get() == nullptr) { - SB_LOG(ERROR) << "OnNetworkStatusChanged has no dispatcher."; - SB_DCHECK(false); - return; - } - - if (is_online) { - application->InjectOsNetworkConnectedEvent(); - } else { - application->InjectOsNetworkDisconnectedEvent(); - } - is_online_ = is_online; - } - } - - void OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^ args) { - // Request deferral of the suspending operation. This ensures that the app - // does not immediately get suspended when this function returns. - suspend_deferral_ = args->SuspendingOperation->GetDeferral(); - - auto extended_resources_manager = - shared::uwp::ExtendedResourcesManager::GetInstance(); - bool is_safe_to_suspend = extended_resources_manager->IsSafeToSuspend(); - - // Request extended execution during which we will suspend the app and - // release extended resources. - auto session = ref new ExtendedExecutionSession(); - session->Reason = ExtendedExecutionReason::SavingData; - session->Description = "Suspending..."; - - // If the extended execution session gets revoked, we have to complete - // the deferral. - Windows::Foundation::EventRegistrationToken revoked_token = - session->Revoked += - ref new TypedEventHandler( - this, &App::ExtendedExecutionSessionRevoked); - Concurrency::create_task(session->RequestExtensionAsync()) - .then([this, is_safe_to_suspend, - extended_resources_manager](ExtendedExecutionResult result) { - // Suspend the app and release extended resources during the extended - // session. - - // Note if we dispatch "suspend" here before pause, application.cc - // will inject the "pause" which will cause us to go async which - // will cause us to not have completed the suspend operation before - // returning, which UWP requires. - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeBlur, NULL, NULL)); - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeConceal, NULL, NULL)); - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeFreeze, NULL, NULL)); - extended_resources_manager->ReleaseExtendedResources(); - if (!extended_resources_manager->IsSafeToSuspend()) { - ForceQuit(); - } - }) - .then([this, is_safe_to_suspend, session, revoked_token]() { - // The extended session has completed, we are ready to be suspended - // now. - session->Revoked -= revoked_token; - delete session; - - CompleteSuspendDeferral(); - }); - if (!is_safe_to_suspend) { - ForceQuit(); - } - } - - void OnResuming(Platform::Object ^ sender, Platform::Object ^ args) { - SB_LOG(INFO) << "Resuming application."; - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeUnfreeze, NULL, NULL)); - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeReveal, NULL, NULL)); - ApplicationUwp::Get()->DispatchAndDelete( - new ApplicationUwp::Event(kSbEventTypeFocus, NULL, NULL)); - shared::win32::DrmSystemOnUwpResume(); - shared::uwp::ExtendedResourcesManager::GetInstance() - ->AcquireExtendedResources(); - } - - void OnKeyUp(CoreWindow ^ sender, KeyEventArgs ^ args) { - ApplicationUwp::Get()->OnKeyEvent(sender, args, true); - } - - void OnKeyDown(CoreWindow ^ sender, KeyEventArgs ^ args) { - ApplicationUwp::Get()->OnKeyEvent(sender, args, false); - } - - void OnActivated(CoreApplicationView ^ application_view, - IActivatedEventArgs ^ args) { - SB_LOG(INFO) << "OnActivated"; - shared::uwp::ExtendedResourcesManager::GetInstance() - ->AcquireExtendedResources(); - - std::string start_url = entry_point_; - bool command_line_set = false; - - // Please see application lifecycle description: - // https://docs.microsoft.com/en-us/windows/uwp/launch-resume/app-lifecycle - // Note that this document was written for Xaml apps not core apps, - // so for us the precise API is a little different. - // The substance is that, while OnActivated is definitely called the - // first time the application is started, it may additionally called - // in other cases while the process is already running. Starboard - // applications cannot fully restart in a process lifecycle, - // so we interpret the first activation and the subsequent ones differently. - if (args->Kind == ActivationKind::Protocol) { - Uri ^ uri = dynamic_cast(args)->Uri; - -#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - // The starboard: scheme provides commandline arguments, but that's - // only allowed during a process's first activation. - std::string scheme = platformStringToString(uri->SchemeName); - if (!previously_activated_ && ends_with(scheme, "-starboard")) { - std::string uri_string = wchar_tToUTF8(uri->RawUri->Data()); - // args_ is a vector of std::string, but argv_ is a vector of - // char* into args_ so as to compose a char**. - args_ = ParseStarboardUri(uri_string); - for (const std::string& arg : args_) { - argv_.push_back(arg.c_str()); - } - - ApplicationUwp::Get()->SetCommandLine(static_cast(argv_.size()), - argv_.data()); - command_line_set = true; - } -#endif // defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - if (uri->SchemeName->Equals("youtube") || - uri->SchemeName->Equals("youtube-tv") || - uri->SchemeName->Equals("ms-xbl-07459769")) { - std::string uri_string = platformStringToString(uri->RawUri); - - // Strip the protocol from the uri. - size_t index = uri_string.find(':'); - if (index != std::string::npos) { - uri_string = uri_string.substr(index + 1); - } - - ProcessDeepLinkUri(&uri_string); - } - } else if (args->Kind == ActivationKind::DialReceiver) { - DialReceiverActivatedEventArgs ^ dial_args = - dynamic_cast(args); - SB_CHECK(dial_args); - Platform::String ^ arguments = dial_args->Arguments; - if (previously_activated_) { - std::string uri_string = - kDialParamPrefix + platformStringToString(arguments); - ProcessDeepLinkUri(&uri_string); - } else { - std::string activation_args = "--url="; - activation_args.append(start_url); - activation_args.append("?"); - activation_args.append(platformStringToString(arguments)); - SB_DLOG(INFO) << "Dial Activation url: " << activation_args; - args_.push_back(GetArgvZero()); - args_.push_back(activation_args); - // Set partition URL in case start_url is the main app first run - // special case. - std::string partition_arg = "--local_storage_partition_url="; - partition_arg.append(entry_point_); - args_.push_back(partition_arg); - for (const std::string& arg : args_) { - argv_.push_back(arg.c_str()); - } - ApplicationUwp::Get()->SetCommandLine(static_cast(argv_.size()), - argv_.data()); - command_line_set = true; - } - } - previous_activation_kind_ = args->Kind; - - if (!previously_activated_) { - if (!command_line_set) { -#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - TryAddCommandArgsFromStarboardFile(&args_); - CommandLine cmd_line(args_); - if (cmd_line.HasSwitch(kNetArgsCommandSwitchWait)) { - // Wait for net args is flaky and needs extended wait time on Xbox. - int64_t timeout_usec = 30'000'000; // 30 seconds - std::string val = cmd_line.GetSwitchValue(kNetArgsCommandSwitchWait); - if (!val.empty()) { - timeout_usec = atoi(val.c_str()); - } - AddCommandArgsFromNetArgs(timeout_usec, &args_); - } -#endif // defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - - if (!CommandLine(args_).HasSwitch("url")) { - args_.push_back(GetArgvZero()); - std::string start_url_arg = "--url="; - start_url_arg.append(start_url); - args_.push_back(start_url_arg); - std::string partition_arg = "--local_storage_partition_url="; - partition_arg.append(entry_point_); - args_.push_back(partition_arg); - } - - for (auto& arg : args_) { - argv_.push_back(arg.c_str()); - } - - ApplicationUwp::Get()->SetCommandLine(static_cast(argv_.size()), - argv_.data()); - } - - ApplicationUwp* application_uwp = ApplicationUwp::Get(); - const CommandLine* command_line = application_uwp->GetCommandLine(); - -#if defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - if (command_line->HasSwitch(kWatchDogLog)) { - // Launch a thread. - std::string switch_val = command_line->GetSwitchValue(kWatchDogLog); - auto uwp_dir = - Windows::Storage::ApplicationData::Current->LocalCacheFolder; - std::stringstream ss; - ss << platformStringToString(uwp_dir->Path) << "/" << switch_val; - shared::uwp::StartWatchdogLog(ss.str()); - } - - if (command_line->HasSwitch(kNetLogCommandSwitchWait)) { - int64_t timeout_usec = 1'000'000; // 1 second - std::string val = - command_line->GetSwitchValue(kNetLogCommandSwitchWait); - if (!val.empty()) { - timeout_usec = atoi(val.c_str()); - } - NetLogWaitForClientConnected(timeout_usec); - } - - if (command_line->HasSwitch(kLogPathSwitch)) { - std::stringstream ss; - ss << platformStringToString( - Windows::Storage::ApplicationData::Current->LocalCacheFolder->Path); - ss << "\\" << "" << command_line->GetSwitchValue(kLogPathSwitch); - std::string full_path_log_file = ss.str(); - shared::uwp::OpenLogFileWin32(full_path_log_file.c_str()); - } else { -#if !defined(COBALT_BUILD_TYPE_GOLD) - // Log to a file on the last removable device available (probably the - // most recently added removable device). - if (KnownFolders::RemovableDevices != nullptr) { - concurrency::create_task( - KnownFolders::RemovableDevices->GetFoldersAsync()) - .then( - [](concurrency::task ^> result) { - IVectorView ^ results; - try { - results = result.get(); - } catch (Platform::Exception ^) { - SB_LOG(ERROR) - << "Unable to open log file in RemovableDevices"; - return; - } - - if (results->Size == 0) { - return; - } - - StorageFolder ^ folder = results->GetAt(results->Size - 1); - Calendar ^ now = ref new Calendar(); - char filename[128]; - snprintf(filename, sizeof(filename), - "cobalt_log_%04d%02d%02d_%02d%02d%02d.txt", - now->Year, now->Month, now->Day, - now->Hour + now->FirstHourInThisPeriod, - now->Minute, now->Second); - shared::uwp::OpenLogFileUWP(folder, filename); - }); - } -#endif // !defined(COBALT_BUILD_TYPE_GOLD) - } -#endif // defined(ENABLE_DEBUG_COMMAND_LINE_SWITCHES) - SB_LOG(INFO) << "Starting " << GetBinaryName(); - - CoreWindow::GetForCurrentThread()->Activate(); - // Call DispatchStart async so the UWP system thinks we're activated. - // Some tools seem to want the application to be activated before - // interacting with them, some things are disallowed during activation - // (such as exiting), and DispatchStart (for example) runs - // automated tests synchronously. - RunInMainThreadAsync([this]() { - ApplicationUwp::Get()->DispatchStart(application_start_time_); - }); - } - previously_activated_ = true; - } - - private: - void ProcessDeepLinkUri(std::string* uri_string) { - SB_DCHECK(uri_string); - if (previously_activated_) { - std::unique_ptr event = - MakeDeepLinkEvent(*uri_string); - SB_DCHECK(event); - ApplicationUwp::Get()->Inject(event.release()); - } else { - ApplicationUwp::Get()->SetStartLink(uri_string->c_str()); - } - } - - std::string entry_point_; - bool is_online_; - bool previously_activated_; - // Only valid if previously_activated_ is true - ActivationKind previous_activation_kind_; - std::vector args_; - std::vector argv_; - - shared::uwp::ApplicationUwp application_; - SuspendingDeferral ^ suspend_deferral_ = nullptr; - int64_t application_start_time_; -}; - -ref class Direct3DApplicationSource sealed : IFrameworkViewSource { - public: - Direct3DApplicationSource(int64_t start_time) - : application_start_time_{start_time} {} - virtual IFrameworkView ^ CreateView() { - return ref new App(application_start_time_); - } private : int64_t application_start_time_; -}; - -namespace shared { -namespace uwp { - -void DisplayStatusWatcher::CreateWatcher() { - Platform::Collections::Vector ^ requestedProperties = - ref new Platform::Collections::Vector(); - requestedProperties->Append("System.Devices.InterfaceClassGuid"); - requestedProperties->Append("System.ItemNameDisplay"); - watcher_ = DeviceInformation::CreateWatcher( - const_cast(kGenericPnpMonitorAqs), - requestedProperties); - SB_CHECK(watcher_); - watcher_->Added += - ref new TypedEventHandler( - &OnDeviceAdded); - watcher_->Removed += - ref new TypedEventHandler( - &OnDeviceRemoved); - watcher_->Start(); -} - -bool DisplayStatusWatcher::IsWatcherStarted() { - SB_CHECK(watcher_); - DeviceWatcherStatus status = watcher_->Status; - return (status == DeviceWatcherStatus::Started) || - (status == DeviceWatcherStatus::EnumerationCompleted); -} - -void DisplayStatusWatcher::StopWatcher() { - SB_CHECK(watcher_); - if (IsWatcherStarted()) { - watcher_->Stop(); - } -} - -#if SB_API_VERSION >= 15 -ApplicationUwp::ApplicationUwp(SbEventHandleCallback sb_event_handle_callback) - : shared::starboard::Application(sb_event_handle_callback), - window_(kSbWindowInvalid), -#else -ApplicationUwp::ApplicationUwp() - : window_(kSbWindowInvalid), -#endif // SB_API_VERSION >= 15 - localized_strings_(SbSystemGetLocaleId()), - device_id_(MakeDeviceId()) { - SbWindowOptions options; - SbWindowSetDefaultOptions(&options); - window_size_ = options.size; - analog_thumbstick_thread_.reset(new AnalogThumbstickThread(this)); -} - -ApplicationUwp::~ApplicationUwp() { - SB_CHECK(watcher_); - { - ScopedLock lock(time_event_mutex_); - timer_event_map_.clear(); - } - watcher_->StopWatcher(); - analog_thumbstick_thread_.reset(nullptr); -} - -void ApplicationUwp::Initialize() {} - -void ApplicationUwp::Teardown() { - CloseWatchdogLog(); -} - -Application::Event* ApplicationUwp::GetNextEvent() { - SB_NOTREACHED(); - return nullptr; -} - -SbWindow ApplicationUwp::CreateWindowForUWP(const SbWindowOptions*) { - // TODO: Determine why SB_DCHECK(IsCurrentThread()) fails in nplb, fix it, - // and add back this check. - - if (SbWindowIsValid(window_)) { - return kSbWindowInvalid; - } - - if (!watcher_) { - watcher_ = ref new shared::uwp::DisplayStatusWatcher(); - watcher_->CreateWatcher(); - } - - window_size_ = GetPreferredWindowSize(); - - window_ = new SbWindowPrivate(window_size_.width, window_size_.height); - return window_; -} - -SbWindowSize ApplicationUwp::GetVisibleAreaSize() { - SbWindowSize size{}; - if (SbWindowGetSize(window_, &size)) { - return size; - } - return window_size_; -} - -SbWindowSize ApplicationUwp::GetPreferredWindowSize() { - bool scale_enabled = true; - if (ApiInformation::IsApiContractPresent( - "Windows.UI.ViewManagement.ViewManagementViewScalingContract", 1)) { - // Use unscaled layout where possible - scale_enabled = !ApplicationViewScaling::TrySetDisableLayoutScaling(true); - } - - auto app_view = ApplicationView::GetForCurrentView(); - bool is_fullscreen = app_view->IsFullScreenMode; - - if (!is_fullscreen && scale_enabled && - ApiInformation::IsApiContractPresent( - "Windows.Xbox.ApplicationResourcesContract", 1)) { - // Always use full screen mode for XBox - is_fullscreen = app_view->TryEnterFullScreenMode(); - } - - UpdateDisplayPreferredMode(); - int width = 0; - int height = 0; - auto display_mode = ApplicationUwp::Get()->GetPreferredModeHdr(); - if (!display_mode) { - display_mode = ApplicationUwp::Get()->GetPreferredModeHdmi(); - } - if (display_mode) { - width = display_mode->ResolutionWidthInRawPixels; - height = display_mode->ResolutionHeightInRawPixels; - } else { - auto bounds = app_view->VisibleBounds; - auto scaleFactor = - DisplayInformation::GetForCurrentView()->RawPixelsPerViewPixel; - width = bounds.Width * scaleFactor; - height = bounds.Height * scaleFactor; - } - SB_LOG(INFO) << "Preferred window size is " << width << " x " << height - << "\nScaling is " << (scale_enabled ? "enabled" : "disabled") - << "\nFull Screen mode is " << (is_fullscreen ? "ON" : "OFF"); - - return SbWindowSize{width, height}; -} - -bool ApplicationUwp::DestroyWindow(SbWindow window) { - // TODO: Determine why SB_DCHECK(IsCurrentThread()) fails in nplb, fix it, - // and add back this check. - - if (!SbWindowIsValid(window)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Invalid context."; - return false; - } - - auto app_view = ApplicationView::GetForCurrentView(); - if (app_view->IsFullScreenMode && - ApiInformation::IsApiContractPresent( - "Windows.Xbox.ApplicationResourcesContract", 1)) { - app_view->ExitFullScreenMode(); - } - - SB_DCHECK(window_ == window); - delete window; - window_ = kSbWindowInvalid; - - return true; -} - -void ApplicationUwp::UpdateDisplayPreferredMode() { - ScopedLock lock(preferred_display_mode_mutex_); - preferred_display_mode_hdmi_ = nullptr; - preferred_display_mode_hdr_ = nullptr; - if (!ApiInformation::IsTypePresent( - "Windows.Graphics.Display.Core.HdmiDisplayInformation")) { - return; - } - - auto hdmi_display_info = HdmiDisplayInformation::GetForCurrentView(); - if (!hdmi_display_info) { - return; - } - - preferred_display_mode_hdmi_ = hdmi_display_info->GetCurrentDisplayMode(); - for (auto mode : hdmi_display_info->GetSupportedDisplayModes()) { - // Check that resolution matches the preferred display mode. - if (mode->ResolutionWidthInRawPixels != - preferred_display_mode_hdmi_->ResolutionWidthInRawPixels || - mode->ResolutionHeightInRawPixels != - preferred_display_mode_hdmi_->ResolutionHeightInRawPixels) { - continue; - } - // Verify HDR metadata and transfer function are supported. - if (!mode->Is2086MetadataSupported || !mode->IsSmpte2084Supported) { - continue; - } - // Verify we have enough bits per pixel and the correct color space for HDR. - if (mode->BitsPerPixel < kYuv420BitsPerPixelForHdr10Mode || - mode->ColorSpace != HdmiDisplayColorSpace::BT2020) { - continue; - } - // We don't serve 4k HDR videos over 60fps, skipping display modes that will - // consume more power than needed. - if (mode->ResolutionWidthInRawPixels >= k4kResolutionWidth && - mode->ResolutionHeightInRawPixels >= k4kResolutionHeight && - mode->RefreshRate > kHdr4kRefreshRateMaximum) { - continue; - } - if (!preferred_display_mode_hdr_ || - preferred_display_mode_hdr_->RefreshRate < mode->RefreshRate) { - preferred_display_mode_hdr_ = mode; - } - } -} - -bool ApplicationUwp::DispatchNextEvent() { - core_window_->Activate(); - core_window_->Dispatcher->ProcessEvents( - CoreProcessEventsOption::ProcessUntilQuit); - return false; -} - -Windows::Media::Protection::HdcpSession ^ ApplicationUwp::GetHdcpSession() { - if (!hdcp_session_) { - hdcp_session_ = ref new HdcpSession(); - } - return hdcp_session_; -} - -void ApplicationUwp::ResetHdcpSession() { - // delete will call the destructor, but not free memory. - // The destructor is called explicitly so that HDCP session can be - // torn down immediately. - if (hdcp_session_) { - delete hdcp_session_; - hdcp_session_ = nullptr; - } -} - -void ApplicationUwp::Inject(Application::Event* event) { - RunInMainThreadAsync([this, event]() { - bool result = DispatchAndDelete(event); - if (!result) { - NetLogFlushThenClose(); - CoreApplication::Exit(); - } - }); -} - -void ApplicationUwp::InjectKeypress(SbKey key) { - if (!SbWindowIsValid(window_)) { - return; - } - std::unique_ptr press_data(new SbInputData()); - std::unique_ptr unpress_data(new SbInputData()); - - memset(press_data.get(), 0, sizeof(*press_data)); - press_data->window = window_; - press_data->device_type = kSbInputDeviceTypeKeyboard; - press_data->device_id = device_id(); - press_data->key = key; - press_data->type = kSbInputEventTypePress; - - *unpress_data = *press_data; - unpress_data->type = kSbInputEventTypeUnpress; - - Inject(new Event(kSbEventTypeInput, press_data.release(), - &Application::DeleteDestructor)); - Inject(new Event(kSbEventTypeInput, unpress_data.release(), - &Application::DeleteDestructor)); -} - -void ApplicationUwp::InjectTimedEvent(Application::TimedEvent* timed_event) { - int64_t delay_usec = timed_event->target_time - CurrentMonotonicTime(); - if (delay_usec < 0) { - delay_usec = 0; - } - - // TimeSpan ticks are, like FILETIME, 100ns - const int64_t kTicksPerUsec = 10; - - TimeSpan timespan; - timespan.Duration = delay_usec * kTicksPerUsec; - - ScopedLock lock(time_event_mutex_); - ThreadPoolTimer ^ timer = ThreadPoolTimer::CreateTimer( - ref new TimerElapsedHandler([this, timed_event](ThreadPoolTimer ^ timer) { - RunInMainThreadAsync([this, timed_event]() { - // Even if the event is canceled, the callback can still fire. - // Thus, the existence of event in timer_event_map_ is used - // as a source of truth. - std::size_t number_erased = 0; - { - ScopedLock lock(time_event_mutex_); - number_erased = timer_event_map_.erase(timed_event->id); - } - if (number_erased > 0) { - timed_event->callback(timed_event->context); - } - }); - }), - timespan); - timer_event_map_.emplace(timed_event->id, timer); -} - -void ApplicationUwp::CancelTimedEvent(SbEventId event_id) { - ScopedLock lock(time_event_mutex_); - auto it = timer_event_map_.find(event_id); - if (it == timer_event_map_.end()) { - return; - } - it->second->Cancel(); - timer_event_map_.erase(it); -} - -Application::TimedEvent* ApplicationUwp::GetNextDueTimedEvent() { - SB_NOTIMPLEMENTED(); - return nullptr; -} - -int64_t ApplicationUwp::GetNextTimedEventTargetTime() { - SB_NOTIMPLEMENTED(); - return 0; -} - -void ApplicationUwp::OnJoystickUpdate(SbKey key, SbInputVector input_vector) { - if (!SbWindowIsValid(window_)) { - return; - } - std::unique_ptr data(new SbInputData()); - memset(data.get(), 0, sizeof(*data)); - data->window = window_; - data->type = kSbInputEventTypeMove; - data->device_type = kSbInputDeviceTypeGamepad; - data->device_id = device_id(); - data->key = key; - data->character = 0; - - data->key_modifiers = kSbKeyModifiersNone; - data->position = input_vector; - - SbKeyLocation key_location = kSbKeyLocationUnspecified; - switch (key) { - case kSbKeyGamepadLeftStickLeft: - case kSbKeyGamepadLeftStickUp: { - key_location = kSbKeyLocationLeft; - break; - } - case kSbKeyGamepadRightStickLeft: - case kSbKeyGamepadRightStickUp: { - key_location = kSbKeyLocationRight; - break; - } - default: { - SB_NOTREACHED(); - break; - } - } - - data->key_location = key_location; - Inject(new Event(kSbEventTypeInput, data.release(), - &Application::DeleteDestructor)); -} - -Platform::String ^ - ApplicationUwp::GetString(const char* id, const char* fallback) const { - return stringToPlatformString(localized_strings_.GetString(id, fallback)); -} - -bool ApplicationUwp::IsHdcpOn() { - ScopedLock lock(hdcp_session_mutex_); - - return GetHdcpSession()->IsEffectiveProtectionAtLeast(kHDCPProtectionMode); -} - -bool ApplicationUwp::TurnOnHdcp() { - HdcpSetProtectionResult protection_result; - { - ScopedLock lock(hdcp_session_mutex_); - - protection_result = WaitForResult( - GetHdcpSession()->SetDesiredMinProtectionAsync(kHDCPProtectionMode)); - } - - if (IsHdcpOn()) { - return true; - } - - // If the operation did not have intended result, log something. - switch (protection_result) { - case HdcpSetProtectionResult::Success: - SB_LOG(INFO) << "Successfully set HDCP."; - break; - case HdcpSetProtectionResult::NotSupported: - SB_LOG(INFO) << "HDCP is not supported."; - break; - case HdcpSetProtectionResult::TimedOut: - SB_LOG(INFO) << "Setting HDCP timed out."; - break; - case HdcpSetProtectionResult::UnknownFailure: - SB_LOG(INFO) << "Unknown failure returned while setting HDCP."; - break; - } - - return false; -} - -bool ApplicationUwp::TurnOffHdcp() { - { - ScopedLock lock(hdcp_session_mutex_); - ResetHdcpSession(); - } - bool success = !IsHdcpOn(); - return success; -} - -// TODO: Consolidate this function with TurnOfHdcp() and TurnOffHdcp(). -bool ApplicationUwp::SetOutputProtection(bool should_enable_dhcp) { - bool is_hdcp_on = IsHdcpOn(); - - if (is_hdcp_on == should_enable_dhcp) { - return true; - } - - SB_LOG(INFO) << "Attempting to " - << (should_enable_dhcp ? "enable" : "disable") - << " output protection. Current status: " - << (is_hdcp_on ? "enabled" : "disabled"); - int64_t tick = CurrentMonotonicTime(); - - bool hdcp_success = false; - if (should_enable_dhcp) { - hdcp_success = TurnOnHdcp(); - } else { - hdcp_success = TurnOffHdcp(); - } - - is_hdcp_on = (hdcp_success ? should_enable_dhcp : !should_enable_dhcp); - - int64_t tock = CurrentMonotonicTime(); - SB_LOG(INFO) << "Output protection is " - << (is_hdcp_on ? "enabled" : "disabled") - << ". Toggling HDCP took " << (tock - tick) / 1000 - << " milliseconds."; - return hdcp_success; -} - -Platform::Agile GetDispatcher() { - return ApplicationUwp::Get()->GetDispatcher(); -} - -Platform::Agile -GetTransportControls() { - return ApplicationUwp::Get()->GetTransportControls(); -} - -void DisplayRequestActive() { - RunInMainThreadAsync([]() { - if (display_request != nullptr) { - display_request->RequestActive(); - } - }); -} - -void DisplayRequestRelease() { - RunInMainThreadAsync([]() { - if (display_request != nullptr) { - display_request->RequestRelease(); - } - }); -} - -void InjectKeypress(SbKey key) { - ApplicationUwp::Get()->InjectKeypress(key); -} - -namespace { - -// Calls CoreApplication::Run() on a new thread to free up the main thread. -// This allows all extended resources related operations to be run on the main -// thread. -class CoreApplicationThread : public ::starboard::Thread { - public: - explicit CoreApplicationThread(int64_t start_time) - : application_start_time_{start_time}, Thread("core_app") {} - void Run() override { - CoreApplication::Run( - ref new Direct3DApplicationSource(application_start_time_)); - ExtendedResourcesManager::GetInstance()->Quit(); - } - - private: - int64_t application_start_time_; -}; - -} // namespace - -int InternalMain() { - volatile auto start_time = CurrentMonotonicTime(); - if (!IsDebuggerPresent()) { - // By default, a Windows application will display a dialog box - // when it crashes. This is extremely undesirable when run offline. - // The following configures messages to be print to the console instead. - _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); - } - - WSAData wsaData; - int init_result = WSAStartup( - MAKEWORD(kWinSockVersionMajor, kWinSockVersionMajor), &wsaData); - - SB_CHECK(init_result == 0); - // WSAStartup returns the highest version that is supported up to the version - // we request. - SB_CHECK(LOBYTE(wsaData.wVersion) == kWinSockVersionMajor && - HIBYTE(wsaData.wVersion) == kWinSockVersionMinor); - - HRESULT hr = MFStartup(MF_VERSION); - SB_DCHECK(SUCCEEDED(hr)); - -#if defined(COBALT_BUILD_TYPE_GOLD) - // Early exit for gold builds on desktop as a security measure. -#if SB_API_VERSION < 15 - if (SbSystemGetDeviceType() == kSbSystemDeviceTypeDesktopPC) { - return main_return_value; - } -#else - if (GetSystemPropertyString(kSbSystemPropertyDeviceType) == - kSystemDeviceTypeDesktopPC) { - return main_return_value; - } -#endif -#endif // defined(COBALT_BUILD_TYPE_GOLD) - - shared::win32::RegisterMainThread(); - - ExtendedResourcesManager extended_resources_manager; - CoreApplicationThread thread(start_time); - - thread.Start(); - extended_resources_manager.Run(); - - NetLogFlushThenClose(); - CoreApplication::Exit(); - - MFShutdown(); - WSACleanup(); - - return main_return_value; -} - -#if SB_API_VERSION >= 15 -extern "C" int SbRunStarboardMain(int argc, - char** argv, - SbEventHandleCallback callback) { - return ApplicationUwp::Get()->Run(argc, argv); -} -#endif // SB_API_VERSION >= 15 - -} // namespace uwp -} // namespace shared -} // namespace starboard - -[Platform::MTAThread] int main(Platform::Array ^ args) { - return starboard::shared::uwp::InternalMain(); -} diff --git a/starboard/shared/uwp/application_uwp.h b/starboard/shared/uwp/application_uwp.h deleted file mode 100644 index 745b84e8dd81..000000000000 --- a/starboard/shared/uwp/application_uwp.h +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_APPLICATION_UWP_H_ -#define STARBOARD_SHARED_UWP_APPLICATION_UWP_H_ - -#include -#include - -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/configuration.h" -#include "starboard/input.h" -#include "starboard/key.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/starboard/command_line.h" -#include "starboard/shared/starboard/localized_strings.h" -#include "starboard/shared/uwp/analog_thumbstick_input_thread.h" -#include "starboard/types.h" -#include "starboard/window.h" - -namespace starboard { -namespace shared { -namespace uwp { - -private -ref class DisplayStatusWatcher sealed { - public: - void CreateWatcher(); - bool IsWatcherStarted(); - void StopWatcher(); - - private: - Windows::Devices::Enumeration::DeviceWatcher ^ watcher_; -}; - -class ApplicationUwp : public shared::starboard::Application, - private AnalogThumbstickThread::Callback { - public: - const float kDefaultScreenRefreshRate = 60.f; - -#if SB_API_VERSION >= 15 - explicit ApplicationUwp(SbEventHandleCallback sb_event_handle_callback); -#else - ApplicationUwp(); -#endif - ~ApplicationUwp() override; - - static ApplicationUwp* Get() { - return static_cast(shared::starboard::Application::Get()); - } - - SbWindow CreateWindowForUWP(const SbWindowOptions* options); - - // Returns window size if the window_ has been instantiated, otherwise returns - // theoretical maximum visible size, i.e. screen size for active display. - SbWindowSize GetVisibleAreaSize(); - - bool DestroyWindow(SbWindow window); - - void DispatchStart(int64_t timestamp) { - shared::starboard::Application::DispatchStart(timestamp); - } - - // public for IFrameworkView subclass - void SetCommandLine(int argc, const char** argv) { - shared::starboard::Application::SetCommandLine(argc, argv); - } - - // public for IFrameworkView subclass - bool DispatchAndDelete(Application::Event* event) { - return shared::starboard::Application::DispatchAndDelete(event); - } - - Platform::Agile GetCoreWindow() const { - return core_window_; - } - - Platform::Agile GetDispatcher() const { - return dispatcher_; - } - - Platform::Agile - GetTransportControls() const { - return transport_controls_; - } - - // public for IFrameworkView subclass - void SetCoreWindow(Windows::UI::Core::CoreWindow ^ window) { - core_window_ = window; - - dispatcher_ = window->Dispatcher; - transport_controls_ = - Windows::Media::SystemMediaTransportControls::GetForCurrentView(); - } - - void OnKeyEvent(Windows::UI::Core::CoreWindow ^ sender, - Windows::UI::Core::KeyEventArgs ^ args, - bool up); - - void Inject(Event* event) override; - - void InjectKeypress(SbKey key); - - void SetStartLink(const char* link) { - shared::starboard::Application::SetStartLink(link); - } - - Platform::String ^ GetString(const char* id, const char* fallback) const; - - void UpdateDisplayPreferredMode(); - - bool IsHdrSupported() { - ScopedLock lock(preferred_display_mode_mutex_); - return preferred_display_mode_hdr_ != nullptr; - } - - float GetRefreshRate() { - ScopedLock lock(preferred_display_mode_mutex_); - if (preferred_display_mode_hdr_ != nullptr) { - return preferred_display_mode_hdr_->RefreshRate; - } - if (preferred_display_mode_hdmi_ != nullptr) { - return preferred_display_mode_hdmi_->RefreshRate; - } - // Sometimes it happens that functions are requesting refresh rate earlier - // than Application is fully initialized and preferred_display_modes are - // nullptr, for such cases we return default most common for typical - // monitors refresh rate. - return kDefaultScreenRefreshRate; - } - - // clang-format off - Windows::Graphics::Display::Core::HdmiDisplayMode ^ - GetPreferredModeHdr() { - ScopedLock lock(preferred_display_mode_mutex_); - return preferred_display_mode_hdr_; - } - - Windows::Graphics::Display::Core::HdmiDisplayMode - ^ - GetPreferredModeHdmi() { - ScopedLock lock(preferred_display_mode_mutex_); - return preferred_display_mode_hdmi_; - } - // clang-format on - - bool IsHdcpOn(); - // Returns true on success. - bool TurnOnHdcp(); - // Returns true on success. - bool TurnOffHdcp(); - - bool SetOutputProtection(bool should_enable_dhcp); - - private: - // --- Application overrides --- - bool IsStartImmediate() override { return false; } - void Initialize() override; - void Teardown() override; - Event* GetNextEvent() override; - bool DispatchNextEvent() override; - void InjectTimedEvent(TimedEvent* timed_event) override; - void CancelTimedEvent(SbEventId event_id) override; - TimedEvent* GetNextDueTimedEvent() override; - int64_t GetNextTimedEventTargetTime() override; - - int device_id() const { return device_id_; } - void OnJoystickUpdate(SbKey key, SbInputVector value) override; - - // Calculates the preferred size of main application window depending on - // platform API available and the mode used to launch application. Used by - // CreateWindowForUWP and GetVisibleAreaSize if the window_ is not yet - // instantiated. - SbWindowSize GetPreferredWindowSize(); - - // These two functions should only be called while holding - // |hdcp_session_mutex_|. - Windows::Media::Protection::HdcpSession ^ GetHdcpSession(); - void ResetHdcpSession(); - - // TODO: Check if |window_| requires mutex or that it is safely accessed - // The single open window, if any. - SbWindow window_; - SbWindowSize window_size_; - Platform::Agile core_window_; - - Platform::Agile dispatcher_; - Platform::Agile - transport_controls_; - - shared::starboard::LocalizedStrings localized_strings_; - - Mutex time_event_mutex_; - // |timer_event_map_| is locked by |mutex_|. - std::unordered_map - timer_event_map_; - - int device_id_; - - // |hdcp_session_| is locked by |hdcp_session_mutex_|. - Mutex hdcp_session_mutex_; - Windows::Media::Protection::HdcpSession ^ hdcp_session_; - - std::unique_ptr analog_thumbstick_thread_; - Windows::ApplicationModel::SuspendingDeferral ^ suspend_deferral_ = nullptr; - - Mutex preferred_display_mode_mutex_; - Windows::Graphics::Display::Core::HdmiDisplayMode ^ - preferred_display_mode_hdr_ = nullptr; - Windows::Graphics::Display::Core::HdmiDisplayMode ^ - preferred_display_mode_hdmi_ = nullptr; - DisplayStatusWatcher ^ watcher_ = nullptr; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_APPLICATION_UWP_H_ diff --git a/starboard/shared/uwp/application_uwp_key_event.cc b/starboard/shared/uwp/application_uwp_key_event.cc deleted file mode 100644 index 8d5c504c99f5..000000000000 --- a/starboard/shared/uwp/application_uwp_key_event.cc +++ /dev/null @@ -1,478 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/application_uwp.h" - -#include "starboard/event.h" -#include "starboard/input.h" -#include "starboard/key.h" - -using Windows::System::VirtualKey; -using Windows::UI::Core::CoreVirtualKeyStates; -using Windows::UI::Core::CoreWindow; -using Windows::UI::Core::KeyEventArgs; - -namespace { - -SbKey VirtualKeyToSbKey(VirtualKey key) { -// Disable warning for Invalid valid values from switch of enum. -#pragma warning(push) -#pragma warning(disable : 4063) - switch (key) { - case VirtualKey::None: - case VirtualKey::NavigationView: - case VirtualKey::NavigationMenu: - case VirtualKey::NavigationUp: - case VirtualKey::NavigationDown: - case VirtualKey::NavigationLeft: - case VirtualKey::NavigationRight: - case VirtualKey::NavigationAccept: - case VirtualKey::NavigationCancel: - return kSbKeyUnknown; - case VirtualKey::Cancel: - return kSbKeyCancel; - case VirtualKey::Back: - return kSbKeyBack; - case VirtualKey::Tab: - return kSbKeyTab; - case VirtualKey::Clear: - return kSbKeyClear; - case VirtualKey::Enter: - return kSbKeyReturn; - case VirtualKey::Shift: - return kSbKeyShift; - case VirtualKey::Control: - return kSbKeyControl; - case VirtualKey::Menu: - return kSbKeyMenu; - case VirtualKey::Pause: - return kSbKeyPause; - case VirtualKey::CapitalLock: - return kSbKeyCapital; - // Hangul and Kana have the same VirtualKey constant - case VirtualKey::Kana: - return kSbKeyKana; - case VirtualKey::Junja: - return kSbKeyJunja; - case VirtualKey::Final: - return kSbKeyFinal; - // Hanja and Kanji have the same VirtualKey constant - case VirtualKey::Hanja: - return kSbKeyHanja; - case VirtualKey::Escape: - return kSbKeyEscape; - case VirtualKey::Convert: - return kSbKeyConvert; - case VirtualKey::NonConvert: - return kSbKeyNonconvert; - case VirtualKey::Accept: - return kSbKeyAccept; - case VirtualKey::ModeChange: - return kSbKeyModechange; - case VirtualKey::Space: - return kSbKeySpace; - case VirtualKey::PageUp: - return kSbKeyPrior; - case VirtualKey::PageDown: - return kSbKeyNext; - case VirtualKey::End: - return kSbKeyEnd; - case VirtualKey::Home: - return kSbKeyHome; - case VirtualKey::Left: - return kSbKeyLeft; - case VirtualKey::Up: - return kSbKeyUp; - case VirtualKey::Right: - return kSbKeyRight; - case VirtualKey::Down: - return kSbKeyDown; - case VirtualKey::Select: - return kSbKeySelect; - case VirtualKey::Print: - return kSbKeyPrint; - case VirtualKey::Execute: - return kSbKeyExecute; - case VirtualKey::Snapshot: - return kSbKeySnapshot; - case VirtualKey::Insert: - return kSbKeyInsert; - case VirtualKey::Delete: - return kSbKeyDelete; - case VirtualKey::Number0: - return kSbKey0; - case VirtualKey::Number1: - return kSbKey1; - case VirtualKey::Number2: - return kSbKey2; - case VirtualKey::Number3: - return kSbKey3; - case VirtualKey::Number4: - return kSbKey4; - case VirtualKey::Number5: - return kSbKey5; - case VirtualKey::Number6: - return kSbKey6; - case VirtualKey::Number7: - return kSbKey7; - case VirtualKey::Number8: - return kSbKey8; - case VirtualKey::Number9: - return kSbKey9; - case VirtualKey::A: - return kSbKeyA; - case VirtualKey::B: - return kSbKeyB; - case VirtualKey::C: - return kSbKeyC; - case VirtualKey::D: - return kSbKeyD; - case VirtualKey::E: - return kSbKeyE; - case VirtualKey::F: - return kSbKeyF; - case VirtualKey::G: - return kSbKeyG; - case VirtualKey::H: - return kSbKeyH; - case VirtualKey::I: - return kSbKeyI; - case VirtualKey::J: - return kSbKeyJ; - case VirtualKey::K: - return kSbKeyK; - case VirtualKey::L: - return kSbKeyL; - case VirtualKey::M: - return kSbKeyM; - case VirtualKey::N: - return kSbKeyN; - case VirtualKey::O: - return kSbKeyO; - case VirtualKey::P: - return kSbKeyP; - case VirtualKey::Q: - return kSbKeyQ; - case VirtualKey::R: - return kSbKeyR; - case VirtualKey::S: - return kSbKeyS; - case VirtualKey::T: - return kSbKeyT; - case VirtualKey::U: - return kSbKeyU; - case VirtualKey::V: - return kSbKeyV; - case VirtualKey::W: - return kSbKeyW; - case VirtualKey::X: - return kSbKeyX; - case VirtualKey::Y: - return kSbKeyY; - case VirtualKey::Z: - return kSbKeyZ; - case VirtualKey::LeftWindows: - return kSbKeyLwin; - case VirtualKey::RightWindows: - return kSbKeyRwin; - case VirtualKey::Application: - return kSbKeyApps; - case VirtualKey::Sleep: - return kSbKeySleep; - case VirtualKey::NumberPad0: - return kSbKeyNumpad0; - case VirtualKey::NumberPad1: - return kSbKeyNumpad1; - case VirtualKey::NumberPad2: - return kSbKeyNumpad2; - case VirtualKey::NumberPad3: - return kSbKeyNumpad3; - case VirtualKey::NumberPad4: - return kSbKeyNumpad4; - case VirtualKey::NumberPad5: - return kSbKeyNumpad5; - case VirtualKey::NumberPad6: - return kSbKeyNumpad6; - case VirtualKey::NumberPad7: - return kSbKeyNumpad7; - case VirtualKey::NumberPad8: - return kSbKeyNumpad8; - case VirtualKey::NumberPad9: - return kSbKeyNumpad9; - case VirtualKey::Multiply: - return kSbKeyMultiply; - case VirtualKey::Add: - return kSbKeyAdd; - case VirtualKey::Separator: - return kSbKeySeparator; - case VirtualKey::Subtract: - return kSbKeySubtract; - case VirtualKey::Decimal: - return kSbKeyDecimal; - case VirtualKey::Divide: - return kSbKeyDivide; - case VirtualKey::F1: - return kSbKeyF1; - case VirtualKey::F2: - return kSbKeyF2; - case VirtualKey::F3: - return kSbKeyF3; - case VirtualKey::F4: - return kSbKeyF4; - case VirtualKey::F5: - return kSbKeyF5; - case VirtualKey::F6: - return kSbKeyF6; - case VirtualKey::F7: - return kSbKeyF7; - case VirtualKey::F8: - return kSbKeyF8; - case VirtualKey::F9: - return kSbKeyF9; - case VirtualKey::F10: - return kSbKeyF10; - case VirtualKey::F11: - return kSbKeyF11; - case VirtualKey::F12: - return kSbKeyF12; - case VirtualKey::F13: - return kSbKeyF13; - case VirtualKey::F14: - return kSbKeyF14; - case VirtualKey::F15: - return kSbKeyF15; - case VirtualKey::F16: - return kSbKeyF16; - case VirtualKey::F17: - return kSbKeyF17; - case VirtualKey::F18: - return kSbKeyF18; - case VirtualKey::F19: - return kSbKeyF19; - case VirtualKey::F20: - return kSbKeyF20; - case VirtualKey::F21: - return kSbKeyF21; - case VirtualKey::F22: - return kSbKeyF22; - case VirtualKey::F23: - return kSbKeyF23; - case VirtualKey::F24: - return kSbKeyF24; - // SbKeys were originally modeled after the windows virtual key mappings - // [1]. UWP VirtualKey uses a very similar mapping, but the UWP enum does - // not contain all of the Virtual-Key Codes. [1] - // https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx - case 0xBA: - return kSbKeyOem1; // Used for ";:" key with US keyboards. - case 0xBB: - return kSbKeyOemPlus; - case 0xBC: - return kSbKeyOemComma; - case 0xBD: - return kSbKeyOemMinus; - case 0xBE: - return kSbKeyOemPeriod; - case 0xBF: - return kSbKeyOem2; // Used for "/?" key with US keyboards. - case 0xC0: - return kSbKeyOem3; // Used for "~" with US keyboards. - case 0xDB: - return kSbKeyOem4; // Used for "[{" with US keyboards. - case 0xDC: - return kSbKeyOem5; // Used for "\|" with US keyboards. - case 0xDD: - return kSbKeyOem6; // Used for "]}" with US keyboards. - case 0xDE: - return kSbKeyOem7; // Used for quotes with US keyboards. - case 0xDF: - return kSbKeyOem8; // Used for misc. chars with US keyboards. - case 0xE2: - return kSbKeyOem102; // Used for "/" or angle bracket keys. - case 0xAD: - return kSbKeyVolumeMute; - case 0xAE: - return kSbKeyVolumeDown; - case 0xAF: - return kSbKeyVolumeUp; - case VirtualKey::NumberKeyLock: - return kSbKeyNumlock; - case VirtualKey::Scroll: - return kSbKeyScroll; - case VirtualKey::LeftShift: - return kSbKeyLshift; - case VirtualKey::RightShift: - return kSbKeyRshift; - case VirtualKey::LeftControl: - return kSbKeyLcontrol; - case VirtualKey::RightControl: - return kSbKeyRcontrol; - case VirtualKey::LeftMenu: - return kSbKeyLmenu; - case VirtualKey::RightMenu: - return kSbKeyRmenu; - case VirtualKey::GoBack: - return kSbKeyBrowserBack; - case VirtualKey::GoForward: - return kSbKeyBrowserForward; - case VirtualKey::Refresh: - return kSbKeyBrowserRefresh; - case VirtualKey::Stop: - return kSbKeyBrowserStop; - case VirtualKey::Search: - return kSbKeyBrowserSearch; - case VirtualKey::Favorites: - return kSbKeyBrowserFavorites; - case VirtualKey::GoHome: - return kSbKeyBrowserHome; - case VirtualKey::LeftButton: - return kSbKeyMouse1; - case VirtualKey::RightButton: - return kSbKeyMouse2; - case VirtualKey::MiddleButton: - return kSbKeyMouse3; - case VirtualKey::XButton1: - return kSbKeyMouse4; - case VirtualKey::XButton2: - return kSbKeyMouse5; - case VirtualKey::GamepadA: - return kSbKeyGamepad1; - case VirtualKey::GamepadB: - return kSbKeyGamepad2; - case VirtualKey::GamepadX: - return kSbKeyGamepad3; - case VirtualKey::GamepadY: - return kSbKeyGamepad4; - case VirtualKey::GamepadRightShoulder: - return kSbKeyGamepadRightBumper; - case VirtualKey::GamepadLeftShoulder: - return kSbKeyGamepadLeftBumper; - case VirtualKey::GamepadLeftTrigger: - return kSbKeyGamepadLeftTrigger; - case VirtualKey::GamepadRightTrigger: - return kSbKeyGamepadRightTrigger; - case VirtualKey::GamepadDPadUp: - return kSbKeyGamepadDPadUp; - case VirtualKey::GamepadDPadDown: - return kSbKeyGamepadDPadDown; - case VirtualKey::GamepadDPadLeft: - return kSbKeyGamepadDPadLeft; - case VirtualKey::GamepadDPadRight: - return kSbKeyGamepadDPadRight; - case VirtualKey::GamepadMenu: - return kSbKeyGamepad6; - case VirtualKey::GamepadView: - return kSbKeyGamepad5; - case VirtualKey::GamepadLeftThumbstickButton: - return kSbKeyGamepadLeftStick; - case VirtualKey::GamepadRightThumbstickButton: - return kSbKeyGamepadRightStick; - case VirtualKey::GamepadLeftThumbstickUp: - return kSbKeyGamepadLeftStickUp; - case VirtualKey::GamepadLeftThumbstickDown: - return kSbKeyGamepadLeftStickDown; - case VirtualKey::GamepadLeftThumbstickRight: - return kSbKeyGamepadLeftStickRight; - case VirtualKey::GamepadLeftThumbstickLeft: - return kSbKeyGamepadLeftStickLeft; - case VirtualKey::GamepadRightThumbstickUp: - return kSbKeyGamepadRightStickUp; - case VirtualKey::GamepadRightThumbstickDown: - return kSbKeyGamepadRightStickDown; - case VirtualKey::GamepadRightThumbstickRight: - return kSbKeyGamepadRightStickRight; - case VirtualKey::GamepadRightThumbstickLeft: - return kSbKeyGamepadRightStickLeft; - default: - return kSbKeyUnknown; - } -#pragma warning(pop) // Warning 4093 (Invalid valid values from switch of enum) -} - -// Returns true if a given VirtualKey is currently being held down. -bool IsDown(CoreWindow ^ sender, VirtualKey key) { - return ((sender->GetKeyState(key) & CoreVirtualKeyStates::Down) == - CoreVirtualKeyStates::Down); -} - -} // namespace - -namespace starboard { -namespace shared { -namespace uwp { - -void ApplicationUwp::OnKeyEvent(CoreWindow ^ sender, - KeyEventArgs ^ args, - bool up) { - args->Handled = true; - SbInputData* data = new SbInputData(); - memset(data, 0, sizeof(*data)); - - data->window = window_; - data->device_type = kSbInputDeviceTypeKeyboard; - data->device_id = device_id(); - data->key = VirtualKeyToSbKey(args->VirtualKey); - - if (up) { - data->type = kSbInputEventTypeUnpress; - } else { - data->type = kSbInputEventTypePress; - } - - // Build up key_modifiers - if (IsDown(sender, VirtualKey::Menu) || - IsDown(sender, VirtualKey::LeftMenu) || - IsDown(sender, VirtualKey::RightMenu)) { - data->key_modifiers |= kSbKeyModifiersAlt; - } - if (IsDown(sender, VirtualKey::Control) || - IsDown(sender, VirtualKey::LeftControl) || - IsDown(sender, VirtualKey::RightControl)) { - data->key_modifiers |= kSbKeyModifiersCtrl; - } - if (IsDown(sender, VirtualKey::LeftWindows) || - IsDown(sender, VirtualKey::RightWindows)) { - data->key_modifiers |= kSbKeyModifiersMeta; - } - if (IsDown(sender, VirtualKey::Shift) || - IsDown(sender, VirtualKey::LeftShift) || - IsDown(sender, VirtualKey::RightShift)) { - data->key_modifiers |= kSbKeyModifiersShift; - } - - // Set key_location - switch (args->VirtualKey) { - case VirtualKey::LeftMenu: - case VirtualKey::LeftControl: - case VirtualKey::LeftWindows: - case VirtualKey::LeftShift: - data->key_location = kSbKeyLocationLeft; - break; - case VirtualKey::RightMenu: - case VirtualKey::RightControl: - case VirtualKey::RightWindows: - case VirtualKey::RightShift: - data->key_location = kSbKeyLocationRight; - break; - default: - break; - } - - DispatchAndDelete(new Event(kSbEventTypeInput, data, - &Application::DeleteDestructor)); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/async_utils.h b/starboard/shared/uwp/async_utils.h deleted file mode 100644 index 510f9b47d650..000000000000 --- a/starboard/shared/uwp/async_utils.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_ASYNC_UTILS_H_ -#define STARBOARD_SHARED_UWP_ASYNC_UTILS_H_ - -#include - -#include - -#include "starboard/common/log.h" - -using Windows::Foundation::IAsyncAction; -using Windows::Foundation::IAsyncOperation; - -namespace starboard { -namespace shared { -namespace uwp { - -template -TResult WaitForResult(IAsyncOperation ^ operation) { - using concurrency::task_continuation_context; - HANDLE event = CreateEvent(nullptr, TRUE, FALSE, nullptr); - concurrency::create_task(operation, - task_continuation_context::use_arbitrary()) - .then( - [&event](TResult result) { - BOOL success = SetEvent(event); - SB_DCHECK(success); - }, - task_continuation_context::use_arbitrary()); - DWORD return_value = WaitForSingleObject(event, INFINITE); - SB_DCHECK(return_value == WAIT_OBJECT_0); - CloseHandle(event); - return operation->GetResults(); -} - -inline void WaitForComplete(IAsyncAction ^ action) { - using concurrency::task_continuation_context; - HANDLE event = CreateEvent(nullptr, TRUE, FALSE, nullptr); - concurrency::create_task(action, task_continuation_context::use_arbitrary()) - .then( - [&event](void) { - BOOL success = SetEvent(event); - SB_DCHECK(success); - }, - task_continuation_context::use_arbitrary()); - DWORD return_value = WaitForSingleObject(event, INFINITE); - SB_DCHECK(return_value == WAIT_OBJECT_0); - CloseHandle(event); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_ASYNC_UTILS_H_ diff --git a/starboard/shared/uwp/audio_renderer_passthrough.cc b/starboard/shared/uwp/audio_renderer_passthrough.cc deleted file mode 100644 index 34a769f266e7..000000000000 --- a/starboard/shared/uwp/audio_renderer_passthrough.cc +++ /dev/null @@ -1,360 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/audio_renderer_passthrough.h" - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" - -namespace starboard { -namespace shared { -namespace uwp { - -namespace { - -int CodecToIecSampleRate(SbMediaAudioCodec codec) { - switch (codec) { - case kSbMediaAudioCodecAc3: - return 48000; - case kSbMediaAudioCodecEac3: - return 192000; - default: - SB_NOTREACHED(); - return 0; - } -} - -} // namespace - -AudioRendererPassthrough::AudioRendererPassthrough( - std::unique_ptr audio_decoder, - const AudioStreamInfo& audio_stream_info) - : channels_(audio_stream_info.number_of_channels), - codec_(audio_stream_info.codec), - iec_sample_rate_(CodecToIecSampleRate(audio_stream_info.codec)), - decoder_(std::move(audio_decoder)), - sink_(new WASAPIAudioSink), - process_audio_buffers_job_( - std::bind(&AudioRendererPassthrough::ProcessAudioBuffers, this)) { - SB_DCHECK(codec_ == kSbMediaAudioCodecAc3 || - codec_ == kSbMediaAudioCodecEac3); - SB_DCHECK(decoder_); - QueryPerformanceFrequency(&performance_frequency_); - SB_DCHECK(performance_frequency_.QuadPart > 0); - SB_LOG(INFO) << "Creating AudioRendererPassthrough with " << channels_ - << " channels."; -} - -AudioRendererPassthrough::~AudioRendererPassthrough() { - SB_DCHECK(BelongsToCurrentThread()); - SB_LOG(INFO) << "Destroying AudioRendererPassthrough with " << channels_ - << " channels."; -} - -void AudioRendererPassthrough::Initialize(const ErrorCB& error_cb, - const PrerolledCB& prerolled_cb, - const EndedCB& ended_cb) { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(error_cb); - SB_DCHECK(prerolled_cb); - SB_DCHECK(ended_cb); - SB_DCHECK(!error_cb_); - SB_DCHECK(!prerolled_cb_); - SB_DCHECK(!ended_cb_); - - error_cb_ = error_cb; - prerolled_cb_ = prerolled_cb; - ended_cb_ = ended_cb; - - decoder_->Initialize( - std::bind(&AudioRendererPassthrough::OnDecoderOutput, this), error_cb); - - if (!sink_->Initialize(channels_, iec_sample_rate_, codec_)) { - error_cb_(kSbPlayerErrorDecode, "failed to start audio sink"); - } -} - -void AudioRendererPassthrough::WriteSamples(const InputBuffers& input_buffers) { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(input_buffers.size() == 1); - SB_DCHECK(input_buffers[0]); - SB_DCHECK(can_accept_more_data_.load()); - - if (end_of_stream_written_.load()) { - SB_LOG(ERROR) << "Appending audio sample at " - << input_buffers[0]->timestamp() << " after EOS reached."; - return; - } - - can_accept_more_data_.store(false); - decoder_->Decode( - input_buffers, - std::bind(&AudioRendererPassthrough::OnDecoderConsumed, this)); -} - -void AudioRendererPassthrough::WriteEndOfStream() { - SB_DCHECK(BelongsToCurrentThread()); - - if (end_of_stream_written_.load()) { - SB_LOG(ERROR) << "Try to write EOS after EOS is reached"; - return; - } - - end_of_stream_written_.store(true); - decoder_->WriteEndOfStream(); -} - -void AudioRendererPassthrough::SetVolume(double volume) { - SB_DCHECK(BelongsToCurrentThread()); - sink_->SetVolume(volume); -} - -bool AudioRendererPassthrough::IsEndOfStreamWritten() const { - SB_DCHECK(BelongsToCurrentThread()); - - return end_of_stream_written_.load(); -} - -bool AudioRendererPassthrough::IsEndOfStreamPlayed() const { - SB_DCHECK(BelongsToCurrentThread()); - - return end_of_stream_played_.load(); -} - -bool AudioRendererPassthrough::CanAcceptMoreData() const { - SB_DCHECK(BelongsToCurrentThread()); - - return !end_of_stream_written_.load() && - pending_inputs_.size() < kMaxDecodedAudios && - can_accept_more_data_.load(); -} - -void AudioRendererPassthrough::Play() { - SB_DCHECK(BelongsToCurrentThread()); - ScopedLock lock(mutex_); - paused_ = false; - sink_->Play(); -} - -void AudioRendererPassthrough::Pause() { - SB_DCHECK(BelongsToCurrentThread()); - ScopedLock lock(mutex_); - paused_ = true; - sink_->Pause(); -} - -void AudioRendererPassthrough::SetPlaybackRate(double playback_rate) { - SB_DCHECK(BelongsToCurrentThread()); - - if (playback_rate > 0.0 && playback_rate != 1.0) { - std::string error_message = ::starboard::FormatString( - "Playback rate %f is not supported", playback_rate); - error_cb_(kSbPlayerErrorDecode, error_message); - return; - } - - ScopedLock lock(mutex_); - playback_rate_ = playback_rate; - sink_->SetPlaybackRate(playback_rate); -} - -void AudioRendererPassthrough::Seek(int64_t seek_to_time) { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(seek_to_time >= 0); - { - ScopedLock lock(mutex_); - seeking_to_time_ = std::max(seek_to_time, 0); - seeking_ = true; - } - - total_frames_sent_to_sink_ = 0; - can_accept_more_data_.store(true); - process_audio_buffers_job_token_.ResetToInvalid(); - total_buffers_sent_to_sink_ = 0; - end_of_stream_written_.store(false); - end_of_stream_played_.store(false); - pending_inputs_ = std::queue>(); - sink_->Reset(); - decoder_->Reset(); - - CancelPendingJobs(); -} - -int64_t AudioRendererPassthrough::GetCurrentMediaTime(bool* is_playing, - bool* is_eos_played, - bool* is_underflow, - double* playback_rate) { - SB_DCHECK(is_playing); - SB_DCHECK(is_eos_played); - SB_DCHECK(is_underflow); - SB_DCHECK(playback_rate); - - ScopedLock lock(mutex_); - *is_playing = !paused_ && !seeking_; - *is_eos_played = end_of_stream_played_.load(); - *is_underflow = false; // TODO: Support underflow - *playback_rate = playback_rate_; - - if (seeking_) { - return seeking_to_time_; - } - - uint64_t sink_playback_time_updated_at; - int64_t sink_playback_time = static_cast( - sink_->GetCurrentPlaybackTime(&sink_playback_time_updated_at)); - if (sink_playback_time <= 0) { - if (sink_playback_time < 0) { - error_cb_(kSbPlayerErrorDecode, - "Error obtaining playback time from WASAPI sink"); - } - return seeking_to_time_; - } - - int64_t media_time = seeking_to_time_ + sink_playback_time; - if (!sink_->playing()) { - return media_time; - } - - return media_time + - CalculateElapsedPlaybackTime(sink_playback_time_updated_at); -} - -void AudioRendererPassthrough::OnDecoderConsumed() { - SB_DCHECK(BelongsToCurrentThread()); - can_accept_more_data_.store(true); -} - -void AudioRendererPassthrough::OnDecoderOutput() { - SB_DCHECK(BelongsToCurrentThread()); - int samples_per_second = 0; - scoped_refptr decoded_audio = - decoder_->Read(&samples_per_second); - SB_DCHECK(decoded_audio); - pending_inputs_.push(decoded_audio); - - if (process_audio_buffers_job_token_.is_valid()) { - RemoveJobByToken(process_audio_buffers_job_token_); - process_audio_buffers_job_token_.ResetToInvalid(); - } - ProcessAudioBuffers(); -} - -void AudioRendererPassthrough::ProcessAudioBuffers() { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(!pending_inputs_.empty()); - - process_audio_buffers_job_token_.ResetToInvalid(); - int64_t process_audio_buffers_job_delay_usec = 5'000; // 5ms - - scoped_refptr decoded_audio = pending_inputs_.front(); - SB_DCHECK(decoded_audio); - - if (decoded_audio->is_end_of_stream()) { - SB_DCHECK(end_of_stream_written_.load()); - ScopedLock lock(mutex_); - if (seeking_) { - seeking_ = false; - Schedule(prerolled_cb_); - } - pending_inputs_.pop(); - SB_DCHECK(pending_inputs_.empty()); - } else { - ScopedLock lock(mutex_); - while (seeking_ && decoded_audio && - CalculateLastOutputTime(decoded_audio) < seeking_to_time_) { - pending_inputs_.pop(); - decoded_audio = pending_inputs_.empty() ? scoped_refptr() - : pending_inputs_.front(); - } - - if (decoded_audio && TryToWriteAudioBufferToSink(decoded_audio)) { - pending_inputs_.pop(); - process_audio_buffers_job_delay_usec = 0; - if (seeking_ && total_buffers_sent_to_sink_ >= kNumPrerollDecodedAudios) { - seeking_ = false; - Schedule(prerolled_cb_); - } - } - } - - if (!pending_inputs_.empty()) { - process_audio_buffers_job_token_ = Schedule( - process_audio_buffers_job_, process_audio_buffers_job_delay_usec); - return; - } - - if (end_of_stream_written_.load() && !end_of_stream_played_.load()) { - TryToEndStream(); - } -} - -bool AudioRendererPassthrough::TryToWriteAudioBufferToSink( - scoped_refptr decoded_audio) { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(decoded_audio); - - bool buffer_written = sink_->WriteBuffer(decoded_audio); - if (buffer_written && !decoded_audio->is_end_of_stream()) { - total_frames_sent_to_sink_ += decoded_audio->frames(); - total_buffers_sent_to_sink_++; - } - return buffer_written; -} - -void AudioRendererPassthrough::TryToEndStream() { - bool is_playing, is_eos_played, is_underflow; - double playback_rate; - int64_t total_frames_played_by_sink = - GetCurrentMediaTime(&is_playing, &is_eos_played, &is_underflow, - &playback_rate) * - iec_sample_rate_ / 1'000'000; - // Wait for the audio sink to output the remaining frames before calling - // Pause(). - if (total_frames_played_by_sink >= total_frames_sent_to_sink_) { - sink_->Pause(); - end_of_stream_played_.store(true); - ended_cb_(); - return; - } - Schedule(std::bind(&AudioRendererPassthrough::TryToEndStream, this), 5'000); -} - -int64_t AudioRendererPassthrough::CalculateElapsedPlaybackTime( - uint64_t update_time) { - LARGE_INTEGER current_time; - QueryPerformanceCounter(¤t_time); - // Convert current performance counter timestamp to units of 100 nanoseconds. - // https://docs.microsoft.com/en-us/windows/win32/api/audioclient/nf-audioclient-iaudioclock-getposition#remarks - uint64_t current_time_converted = - static_cast(current_time.QuadPart) * - (10000000.0 / static_cast(performance_frequency_.QuadPart)); - SB_DCHECK(current_time_converted >= update_time); - - // Convert elapsed time to microseconds. - return ((current_time_converted - update_time) * 100) / 1000; -} - -int64_t AudioRendererPassthrough::CalculateLastOutputTime( - scoped_refptr& decoded_audio) { - return decoded_audio->timestamp() + - (decoded_audio->frames() / iec_sample_rate_ * 1'000'000); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/audio_renderer_passthrough.h b/starboard/shared/uwp/audio_renderer_passthrough.h deleted file mode 100644 index d3c39f9fe4e3..000000000000 --- a/starboard/shared/uwp/audio_renderer_passthrough.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_AUDIO_RENDERER_PASSTHROUGH_H_ -#define STARBOARD_SHARED_UWP_AUDIO_RENDERER_PASSTHROUGH_H_ - -#include -#include -#include - -#include "starboard/atomic.h" -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/media.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/decoded_audio_internal.h" -#include "starboard/shared/starboard/player/filter/audio_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/audio_renderer_internal.h" -#include "starboard/shared/starboard/player/filter/media_time_provider.h" -#include "starboard/shared/starboard/player/input_buffer_internal.h" -#include "starboard/shared/starboard/player/job_queue.h" -#include "starboard/shared/uwp/wasapi_audio_sink.h" -#include "starboard/types.h" - -namespace starboard { -namespace shared { -namespace uwp { - -using ::starboard::shared::starboard::player::DecodedAudio; -using ::starboard::shared::starboard::player::JobQueue; -using ::starboard::shared::starboard::player::filter::AudioDecoder; -using ::starboard::shared::starboard::player::filter::AudioRenderer; -using ::starboard::shared::starboard::player::filter::MediaTimeProvider; - -class AudioRendererPassthrough : public AudioRenderer, - public MediaTimeProvider, - private JobQueue::JobOwner { - public: - typedef starboard::media::AudioStreamInfo AudioStreamInfo; - - AudioRendererPassthrough(std::unique_ptr audio_decoder, - const AudioStreamInfo& audio_stream_info); - ~AudioRendererPassthrough() override; - - void Initialize(const ErrorCB& error_cb, - const PrerolledCB& prerolled_cb, - const EndedCB& ended_cb) override; - void WriteSamples(const InputBuffers& input_buffers) override; - void WriteEndOfStream() override; - - void SetVolume(double volume) override; - - bool IsEndOfStreamWritten() const override; - bool IsEndOfStreamPlayed() const override; - bool CanAcceptMoreData() const override; - - // MediaTimeProvider methods - void Play() override; - void Pause() override; - void SetPlaybackRate(double playback_rate) override; - void Seek(int64_t seek_to_time) override; - int64_t GetCurrentMediaTime(bool* is_playing, - bool* is_eos_played, - bool* is_underflow, - double* playback_rate) override; - - private: - void OnDecoderConsumed(); - void OnDecoderOutput(); - - void ProcessAudioBuffers(); - bool TryToWriteAudioBufferToSink(scoped_refptr decoded_audio); - - // After end of stream is written, stop the audio sink after it finishes audio - // output. - void TryToEndStream(); - - // Calculates the playback time elapsed (microseconds) since the last time the - // timestamp was queried using WASAPIAudioSink::GetCurrentPlaybackTime(). - int64_t CalculateElapsedPlaybackTime(uint64_t update_time); - // Calculates the final output timestamp (microseconds) of a DecodedAudio. - int64_t CalculateLastOutputTime(scoped_refptr& decoded_audio); - - const int kMaxDecodedAudios = 16; - // About 250 ms of (E)AC3 audio. - const int kNumPrerollDecodedAudios = 8; - - ErrorCB error_cb_; - PrerolledCB prerolled_cb_; - EndedCB ended_cb_; - - Mutex mutex_; - bool paused_ = true; - bool seeking_ = false; - double playback_rate_ = 1.0; - int64_t seeking_to_time_ = 0; - - std::atomic_bool end_of_stream_written_{false}; - std::atomic_bool end_of_stream_played_{false}; - // Use DecodedAudio to store decrypted and formatted encoded audio data. - std::queue> pending_inputs_; - - std::atomic_bool can_accept_more_data_{false}; - - JobQueue::JobToken process_audio_buffers_job_token_; - std::function process_audio_buffers_job_; - - int64_t total_frames_sent_to_sink_ = 0; - int total_buffers_sent_to_sink_ = 0; - - const int channels_; - const SbMediaAudioCodec codec_ = kSbMediaAudioCodecNone; - std::unique_ptr decoder_; - std::unique_ptr sink_; - - // |iec_sample_rate_| is the sample rate of the stream when stored in an IEC - // 61937 format. This may be different from the decoded sample rate. - const int iec_sample_rate_; - - // Used to calculate the media time in GetCurrentMediaTime(). - LARGE_INTEGER performance_frequency_; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_AUDIO_RENDERER_PASSTHROUGH_H_ diff --git a/starboard/shared/uwp/decoder_utils.cc b/starboard/shared/uwp/decoder_utils.cc deleted file mode 100644 index 2bc9723f2679..000000000000 --- a/starboard/shared/uwp/decoder_utils.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/decoder_utils.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/async_utils.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" -#include "third_party/angle/include/GLES2/gl2.h" - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -using ::starboard::shared::uwp::ApplicationUwp; -using ::starboard::shared::uwp::WaitForResult; -using Windows::Graphics::Display::Core::HdmiDisplayHdr2086Metadata; -using Windows::Graphics::Display::Core::HdmiDisplayHdrOption; -using Windows::Graphics::Display::Core::HdmiDisplayInformation; -using Windows::Graphics::Display::Core::HdmiDisplayMode; - -constexpr uint16_t Scale(float value, float factor) { - return static_cast(value * factor); -} - -template -EglFunctionType GetEglProcAddr(const char* name) { - EglFunctionType egl_function = - reinterpret_cast(eglGetProcAddress(name)); - SB_DCHECK(egl_function != nullptr); - return egl_function; -} - -} // namespace - -Microsoft::WRL::ComPtr GetDirectX11Device(void* display) { - static PFNEGLQUERYDISPLAYATTRIBEXTPROC s_egl_query_display_attrib_ext = - GetEglProcAddr( - "eglQueryDisplayAttribEXT"); - - static PFNEGLQUERYDEVICEATTRIBEXTPROC s_egl_query_device_attrib_ext = - GetEglProcAddr("eglQueryDeviceAttribEXT"); - - intptr_t egl_device = 0; - s_egl_query_display_attrib_ext(display, EGL_DEVICE_EXT, &egl_device); - SB_DCHECK(egl_device != 0); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - intptr_t device = 0; - s_egl_query_device_attrib_ext(reinterpret_cast(egl_device), - EGL_D3D11_DEVICE_ANGLE, &device); - SB_DCHECK(device != 0); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - return reinterpret_cast(device); -} - -void UpdateHdrColorMetadataToCurrentDisplay( - const SbMediaColorMetadata& color_metadata) { - const SbMediaMasteringMetadata& md = color_metadata.mastering_metadata; - HdmiDisplayHdr2086Metadata hdr2086_metadata{ - Scale(md.primary_r_chromaticity_x, 50000.), - Scale(md.primary_r_chromaticity_y, 50000.), - Scale(md.primary_g_chromaticity_x, 50000.), - Scale(md.primary_g_chromaticity_y, 50000.), - Scale(md.primary_b_chromaticity_x, 50000.), - Scale(md.primary_b_chromaticity_y, 50000.), - Scale(md.white_point_chromaticity_x, 50000.), - Scale(md.white_point_chromaticity_y, 50000.), - Scale(md.luminance_max, 10000.), - Scale(md.luminance_min, 10000.), - Scale(color_metadata.max_cll, 10000.), - Scale(color_metadata.max_fall, 10000.)}; - auto hdmi_info = HdmiDisplayInformation::GetForCurrentView(); - HdmiDisplayMode ^ mode = ApplicationUwp::Get()->GetPreferredModeHdr(); - bool result = WaitForResult(hdmi_info->RequestSetCurrentDisplayModeAsync( - mode, HdmiDisplayHdrOption::Eotf2084, hdr2086_metadata)); - SB_CHECK(result); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/decoder_utils.h b/starboard/shared/uwp/decoder_utils.h deleted file mode 100644 index cf0b9e6284b7..000000000000 --- a/starboard/shared/uwp/decoder_utils.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_DECODER_UTILS_H_ -#define STARBOARD_SHARED_UWP_DECODER_UTILS_H_ - -#include -#include - -#include - -#include "starboard/media.h" - -namespace starboard { -namespace shared { -namespace uwp { - -Microsoft::WRL::ComPtr GetDirectX11Device(void* display); - -// This is a utility function for finding entries with the method timestamp() -// in containers. Useful in decoders for getting data from buffers keeped in -// input queues; -template -const auto FindByTimestamp(const Container& container, int64_t timestamp) { - return std::find_if(container.begin(), container.end(), - [=](const typename Container::value_type& value) { - return value->timestamp() == timestamp; - }); -} - -// This is a utility function for removing entries with the method timestamp() -// from containers. Useful in decoders for cleaning up input and output queues -// from expired buffers. -template -void RemoveByTimestamp(Container* container, int64_t timestamp) { - auto to_remove = - std::find_if(container->begin(), container->end(), - [=](const typename Container::value_type& value) { - return value->timestamp() == timestamp; - }); - if (to_remove != container->end()) { - container->erase(to_remove); - } -} - -void UpdateHdrColorMetadataToCurrentDisplay( - const SbMediaColorMetadata& color_metadata); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_DECODER_UTILS_H_ diff --git a/starboard/shared/uwp/extended_resources_manager.cc b/starboard/shared/uwp/extended_resources_manager.cc deleted file mode 100644 index 4930030e4fc4..000000000000 --- a/starboard/shared/uwp/extended_resources_manager.cc +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/extended_resources_manager.h" - -#include - -#include "starboard/common/condition_variable.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/starboard/media/mime_supportability_cache.h" -#include "starboard/shared/uwp/xb1_get_type.h" -#include "starboard/shared/win32/video_decoder.h" -#include "starboard/thread.h" -#include "starboard/xb1/shared/internal_shims.h" -#if defined(INTERNAL_BUILD) -#include "internal/starboard/xb1/dav1d_video_decoder.h" -#include "internal/starboard/xb1/vpx_video_decoder.h" -#include "third_party/internal/libvpx_xb1/libvpx/d3dx12.h" -#endif // defined(INTERNAL_BUILD) - -namespace starboard { -namespace shared { -namespace uwp { - -namespace { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::starboard::media::MimeSupportabilityCache; -using Windows::Foundation::Metadata::ApiInformation; -#if defined(INTERNAL_BUILD) -using ::starboard::xb1::shared::Dav1dVideoDecoder; -using ::starboard::xb1::shared::GpuVideoDecoderBase; -using ::starboard::xb1::shared::VpxVideoDecoder; -#endif // defined(INTERNAL_BUILD) - -const int64_t kReleaseTimeoutUsec = 1'000'000; - -// kFrameBuffersPoolMemorySize is the size of gpu memory heap for common use -// by vpx & av1 sw decoders. -// This value must be greater then max(av1_min_value, vpx_min_value), where -// av1_min_value & vpx_min_value are minimal required memory size for sw av1 & -// vpx decoders. -// -// Vpx sw decoder needs 13 internal frame buffers for work and at least -// 8 buffers for preroll. -// The size of fb is 13762560 for 4K SDR and 12976128 for 2K HDR -// So, vpx decoder needs minimum 13762560 * (13 + preroll_size) = 289013760 -// bytes. -// -// Av1 sw decoder needs 13 internal buffers and 8 buffers for preroll. -// The size of fb is 5996544 for 2K SDR and 11993088 for 2K HDR -// av1 decoder needs minimum 11993088 * (13 + preroll_size) = 251854848 bytes. -// -// So, the value 289013760 is minimal for reliable decoders working. -// -// To make playback more smooth it is better to increase the output queue size -// up to 30-50 frames, but it should not exceed memory budgetd. -// Compromise value was found out experimentally. -// In XBOX ONE S/Base 400 Mb leaves enough memory for stable working of the rest -// system. Just in case to be more sure we reduce this value down to 380 Mb. In -// Sereies devices (if to use gpu based decoders) the max available frame size -// size is 4K instead of 2K. On the other hand the memory budget is greater than -// for Base/S. So we can use more memory for output queue. -const uint64_t kFrameBuffersPoolMemorySizeForXB1 = 380 * 1024 * 1024; -// +8 extra frames 4K HDR DXGI_FORMAT_R10G10B10A2_UNORM -const uint64_t kFrameBuffersPoolMemorySizeForXBSeries = - kFrameBuffersPoolMemorySizeForXB1 + 8 * 16588800; - -bool IsExtendedResourceModeRequired() { - if (!::starboard::xb1::shared::CanAcquire()) { - return false; - } - // erm is required for all xbox types except kXboxOneX; - bool is_erm_required = ::starboard::shared::uwp::GetXboxType() != - ::starboard::shared::uwp::kXboxOneX; - return is_erm_required; -} - -} // namespace - -// static -ExtendedResourcesManager* ExtendedResourcesManager::s_instance_; - -ExtendedResourcesManager::ExtendedResourcesManager() - : acquisition_condition_(mutex_) { - SB_DCHECK(!s_instance_); - s_instance_ = this; -} - -ExtendedResourcesManager::~ExtendedResourcesManager() { - SB_DCHECK(s_instance_ == this); - s_instance_ = NULL; -} - -// static -ExtendedResourcesManager* ExtendedResourcesManager::GetInstance() { - return s_instance_; -} - -void ExtendedResourcesManager::Run() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - if (!IsExtendedResourceModeRequired()) { - // Running a simplified loop that only cares about the kQuit event. - while (event_queue_.Get() != kQuit) { - } - return; - } - - bool retrying_acquire = false; - // Delay before retry acquiring to avoid pinning a core. - constexpr int64_t kRetryDelayUsec = 1'000'000 / 10; - for (;;) { - switch (retrying_acquire ? event_queue_.GetTimed(kRetryDelayUsec) - : event_queue_.Get()) { - case kTimeout: - SB_DCHECK(retrying_acquire); - // Fall through to acquire extended resources. - case kAcquireExtendedResources: - retrying_acquire = !AcquireExtendedResourcesInternal(); - if (!retrying_acquire) { - retrying_acquire = !StartCompileShaders(); - } - break; - case kCompileShaders: - CompileShadersAsynchronously(); - break; - case kReleaseExtendedResources: - retrying_acquire = false; - ReleaseExtendedResourcesInternal(); - break; - case kQuit: - retrying_acquire = false; - ReleaseExtendedResourcesInternal(); - return; - } - } -} - -void ExtendedResourcesManager::AcquireExtendedResources() { - // This is expected to be called from another thread only. - SB_DCHECK(!thread_checker_.CalledOnValidThread()); - event_queue_.Put(kAcquireExtendedResources); -} - -void ExtendedResourcesManager::ReleaseExtendedResources() { - // This is expected to be called from another thread only. If called from the - // worker thread, it can deadlock on the mutex below. - SB_DCHECK(!thread_checker_.CalledOnValidThread()); - event_queue_.Put(kReleaseExtendedResources); - - // Skip any pending extended resources acquisitions. - pending_extended_resources_release_.store(true); - { - // Wait until we successfully release the extended resources or timeout. - ScopedLock scoped_lock(mutex_); - while (is_extended_resources_acquired_.load()) { - acquisition_condition_.Wait(); - } - } -} - -void ExtendedResourcesManager::Quit() { - SB_DCHECK(!thread_checker_.CalledOnValidThread()); - event_queue_.Put(kQuit); - pending_extended_resources_release_.store(true); -} - -void ExtendedResourcesManager::ReleaseBuffersHeap() { - d3d12FrameBuffersHeap_.Reset(); -} - -bool ExtendedResourcesManager::GetD3D12Objects( - Microsoft::WRL::ComPtr* device, - Microsoft::WRL::ComPtr* buffer_heap, - void** command_queue) { - if (HasNonrecoverableFailure()) { - SB_LOG(WARNING) << "The D3D12 device has encountered a nonrecoverable " - "failure."; - return false; - } - - device->Reset(); - *command_queue = nullptr; - - ScopedTryLock scoped_lock(mutex_); - if (!scoped_lock.is_locked()) { - SB_LOG(INFO) << "GetD3D12Objects() failed" - << " because lock cannot be acquired."; - return false; - } - if (!is_extended_resources_acquired_.load()) { - SB_LOG(INFO) << "GetD3D12Objects() failed" - << " because extended resources mode is not acquired."; - return false; - } - if (!GetD3D12ObjectsInternal()) { - SB_LOG(INFO) << "GetD3D12Objects() failed" - << " because d3d12 objects can not be created."; - return false; - } - -#if defined(INTERNAL_BUILD) - // Verify that we can allocate one MB without getting an error. This should - // detect a DXGI_ERROR_DEVICE_REMOVED failure mode. - ComPtr res; - D3D12_HEAP_PROPERTIES prop = CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_DEFAULT); - D3D12_RESOURCE_DESC desc = CD3DX12_RESOURCE_DESC::Buffer(1024 * 1024); - HRESULT result = d3d12device_->CreateCommittedResource( - &prop, D3D12_HEAP_FLAG_NONE, &desc, D3D12_RESOURCE_STATE_COMMON, nullptr, - IID_PPV_ARGS(&res)); - if (result != S_OK) { - SB_LOG(WARNING) << "The D3D12 device is not in a good state, can not use " - "GPU based decoders."; - OnNonrecoverableFailure(); - return false; - } -#endif // defined(INTERNAL_BUILD) - - *device = d3d12device_; - *command_queue = d3d12queue_.Get(); - *buffer_heap = d3d12FrameBuffersHeap_.Get(); - return true; -} - -bool ExtendedResourcesManager::GetD3D12ObjectsInternal() { - if (!d3d12device_) { - UINT dxgiFactoryFlags = 0; -#if defined(_DEBUG) - { - // This can help to debug DX issues. If something goes wrong in DX, - // Debug Layer outputs detailed log - ComPtr debugController; - HRESULT hr = D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)); - if (SUCCEEDED(hr)) { - debugController->EnableDebugLayer(); - } - } -#endif - - if (FAILED(D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, - IID_PPV_ARGS(&d3d12device_)))) { - // GPU based vp9 decoding will be temporarily disabled. - SB_LOG(WARNING) << "Failed to create d3d12 device."; - return false; - } - SB_DCHECK(d3d12device_); - } - - if (!d3d12queue_) { - D3D12_COMMAND_QUEUE_DESC desc = {}; - desc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; - desc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; - if (FAILED(d3d12device_->CreateCommandQueue(&desc, - IID_PPV_ARGS(&d3d12queue_)))) { - SB_LOG(WARNING) << "Failed to create d3d12 command queue."; - return false; - } - SB_DCHECK(d3d12queue_); - } - if (!d3d12FrameBuffersHeap_) { - const bool isSeries = ::starboard::shared::uwp::GetXboxType() == - ::starboard::shared::uwp::kXboxSeriesS || - ::starboard::shared::uwp::GetXboxType() == - ::starboard::shared::uwp::kXboxSeriesX; - D3D12_HEAP_DESC heap_desc; - heap_desc.SizeInBytes = isSeries ? kFrameBuffersPoolMemorySizeForXBSeries - : kFrameBuffersPoolMemorySizeForXB1; - heap_desc.Properties.Type = D3D12_HEAP_TYPE_DEFAULT; - heap_desc.Properties.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; - heap_desc.Properties.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; - heap_desc.Properties.CreationNodeMask = 0; - heap_desc.Properties.VisibleNodeMask = 0; - heap_desc.Alignment = D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT; - heap_desc.Flags = D3D12_HEAP_FLAG_NONE; - - if (FAILED(d3d12device_->CreateHeap( - &heap_desc, IID_PPV_ARGS(&d3d12FrameBuffersHeap_)))) { - SB_LOG(WARNING) << "Failed to create d3d12 buffer."; - return false; - } - SB_DCHECK(d3d12FrameBuffersHeap_); - } - - return d3d12device_ && d3d12queue_ && d3d12FrameBuffersHeap_; -} - -bool ExtendedResourcesManager::AcquireExtendedResourcesInternal() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - ScopedLock scoped_lock(mutex_); - - if (HasNonrecoverableFailure()) { - SB_LOG(WARNING) - << "Encountered a nonrecoverable failure, ignoring acquire."; - return false; - } - - if (is_extended_resources_acquired_.load()) { - SB_LOG(INFO) << "Skip acquiring extended resources, already acquired."; - } else { - if (pending_extended_resources_release_.load()) { - SB_LOG(INFO) << "AcquireExtendedResourcesInternal() interrupted" - " by pending extended resources release."; - return false; - } - auto extended_resources_mode_enable_task = - concurrency::create_task(::starboard::xb1::shared::Acquire()); - - Semaphore semaphore; - extended_resources_mode_enable_task.then( - [this, &semaphore](concurrency::task task) { - try { - if (task.get()) { - is_extended_resources_acquired_.store(true); - acquisition_condition_.Signal(); - SB_LOG(INFO) << "Successfully acquired extended resources."; - } else { - // TODO: Investigate if vp9 playback should be disabled. - SB_LOG(INFO) << "Failed to acquire extended resources."; - } - } catch (const std::exception& e) { - SB_LOG(ERROR) << "Exception on acquiring extended resources: " - << e.what(); - } catch (...) { - SB_LOG(ERROR) << "Exception on acquiring extended resources."; - } - semaphore.Put(); - }); - if (semaphore.TakeWait(10'000'000)) { - acquisition_condition_.Signal(); - // If extended resource acquisition was not successful after the wait - // time, signal a nonrecoverable failure, unless a release of - // extended resources has since been requested. - if (!is_extended_resources_acquired_.load() && - !pending_extended_resources_release_.load()) { - SB_LOG(WARNING) << "Extended resource mode acquisition timed out"; - OnNonrecoverableFailure(); - } - } - } - - if (!is_extended_resources_acquired_.load()) { - SB_LOG(INFO) << "AcquireExtendedResourcesInternal() failed."; - return false; - } - return is_extended_resources_acquired_.load(); -} - -bool ExtendedResourcesManager::StartCompileShaders() { - { - ScopedLock scoped_lock(mutex_); - if (HasNonrecoverableFailure()) { - SB_LOG(WARNING) - << "Encountered a nonrecoverable failure, ignoring shader compile."; - return false; - } - if (pending_extended_resources_release_.load()) { - SB_LOG(INFO) << "StartCompileShaders() interrupted" - " by pending extended resources release."; - return false; - } - if (!is_extended_resources_acquired_.load()) { - SB_LOG(INFO) << "StartCompileShaders() failed" - " because extended resources are not acquired."; - return false; - } - if (!GetD3D12ObjectsInternal()) { - SB_LOG(INFO) << "StartCompileShaders() failed" - << " because d3d12 objects can not be created."; - return false; - } - } - // Everything is ready to give a command for shaders compilation. - // Note: once we returned "true" execution will not go here anymore to queue - // an event to compile shaders again. - event_queue_.Put(kCompileShaders); - return true; -} - -void ExtendedResourcesManager::CompileShadersAsynchronously() { - // Shaders compilation may take several seconds that is why it is good to run - // it asynchronously. We may not wait until its compilation is completed and - // synchronize decoding with it. If real playback will start earlier than this - // compilation completed then the decoder will compile shaders before playback - // and they will be placed in cache as binaries for further reusing. - Concurrency::create_task([this] { - ScopedLock scoped_lock(mutex_); -#if defined(INTERNAL_BUILD) - if (!is_av1_shader_compiled_) { - SB_LOG(INFO) << "Start to compile AV1 decoder shaders."; - if (HasNonrecoverableFailure()) { - SB_LOG(WARNING) << "Encountered a nonrecoverable failure, ignoring " - "shader compile."; - return; - } - if (Dav1dVideoDecoder::CompileShaders(d3d12device_)) { - is_av1_shader_compiled_ = true; - SB_LOG(INFO) << "Gpu based AV1 decoder finished compiling its shaders."; - } else { - SB_LOG(WARNING) - << "Failed to compile AV1 decoder shaders, next attempt " - "will happen right on the AV1 decoder instantiation."; - } - } else { - SB_LOG(INFO) << "AV1 decoder shaders are already compiled."; - } - if (!is_vp9_shader_compiled_) { - SB_LOG(INFO) << "Start to compile VP9 decoder shaders."; - if (HasNonrecoverableFailure()) { - SB_LOG(WARNING) << "Encountered a nonrecoverable failure, ignoring " - "shader compile."; - return; - } - if (VpxVideoDecoder::CompileShaders(d3d12device_, d3d12FrameBuffersHeap_, - d3d12queue_.Get())) { - is_vp9_shader_compiled_ = true; - SB_LOG(INFO) << "Gpu based VP9 decoder finished compiling its shaders."; - } else { - // This warning means that not all the shaders has been compiled - // successfully, It will try to compile the shaders again, right before - // the start of playback, in function |VideoDecoder::InitializeCodec()|. - SB_LOG(WARNING) - << "Failed to compile VP9 decoder shaders, next attempt " - "will happen right on the VP9 decoder instantiation."; - } - } else { - SB_LOG(INFO) << "VP9 decoder shaders are already compiled."; - } -#endif // defined(INTERNAL_BUILD) - - if (is_av1_shader_compiled_ && is_vp9_shader_compiled_) { - MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities(); - } - }); -} - -void ExtendedResourcesManager::ReleaseExtendedResourcesInternal() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - ScopedLock scoped_lock(mutex_); - if (!is_extended_resources_acquired_.load()) { - SB_LOG(INFO) << "Extended resources hasn't been acquired," - << " no need to release."; - return; - } - - try { - // Wait until all commands on the queue has been finished. - if (d3d12device_ && d3d12queue_) { - ComPtr fence; - HRESULT hr = d3d12device_->CreateFence(0, D3D12_FENCE_FLAG_NONE, - IID_PPV_ARGS(&fence)); - if (SUCCEEDED(hr)) { - HANDLE event = CreateEvent(nullptr, false, false, nullptr); - SB_DCHECK(event); - - // If createEvent() succeeds, we can use it to wait for the command - // queue to complete. - if (event) { - fence->SetEventOnCompletion(1, event); - d3d12queue_->Signal(fence.Get(), 1); - - DWORD result = - WaitForSingleObject(event, 1000); // Wait at most one second - CloseHandle(event); - if (result == WAIT_TIMEOUT) { - SB_LOG(WARNING) << "Fence event completion timeout."; - OnNonrecoverableFailure(); - } - } else { - SB_LOG(INFO) << "CreateEvent() failed with " << GetLastError(); - } - } else { - SB_LOG(INFO) << "CreateFence() failed with " << hr; - } -#if defined(INTERNAL_BUILD) - // Clear frame buffers used for rendering queue - GpuVideoDecoderBase::ClearFrameBuffersPool(); -#endif // #if defined(INTERNAL_BUILD) - } - - if (d3d12queue_) { -#if !defined(COBALT_BUILD_TYPE_GOLD) - d3d12queue_->AddRef(); - ULONG reference_count = d3d12queue_->Release(); - SB_LOG(INFO) << "Reference count of |d3d12queue_| is " << reference_count; -#endif - } - - if (d3d12FrameBuffersHeap_) { -#if !defined(COBALT_BUILD_TYPE_GOLD) - d3d12FrameBuffersHeap_->AddRef(); - ULONG reference_count = d3d12FrameBuffersHeap_->Release(); - SB_LOG(INFO) << "Reference count of |d3d12FrameBuffersHeap_| is " - << reference_count; -#endif - d3d12FrameBuffersHeap_.Reset(); - } - - if (d3d12device_) { -#if !defined(COBALT_BUILD_TYPE_GOLD) - d3d12device_->AddRef(); - ULONG reference_count = d3d12device_->Release(); - SB_LOG(INFO) << "Reference count of |d3d12device_| is " - << reference_count; -#endif - d3d12device_.Reset(); - } - - } catch (const std::exception& e) { - SB_LOG(ERROR) << "Exception on releasing extended resources: " << e.what(); - OnNonrecoverableFailure(); - } catch (...) { - SB_LOG(ERROR) << "Exception on releasing extended resources."; - OnNonrecoverableFailure(); - } - - auto extended_resources_mode_disable_task = - concurrency::create_task([] { ::starboard::xb1::shared::Release(); }); - - Semaphore semaphore; - extended_resources_mode_disable_task.then( - [this, &semaphore](concurrency::task task) { - try { - acquisition_condition_.Signal(); - // ReleaseExtendedResources has no return value but a call to get() - // will bubble up any exceptions thrown during the task. - task.get(); - SB_LOG(INFO) << "Released extended resources."; - } catch (const std::exception& e) { - SB_LOG(ERROR) << "Exception on releasing extended resources: " - << e.what(); - OnNonrecoverableFailure(); - } catch (...) { - SB_LOG(ERROR) << "Exception on releasing extended resources."; - OnNonrecoverableFailure(); - } - is_extended_resources_acquired_.store(false); - pending_extended_resources_release_.store(false); - semaphore.Put(); - }); - if (!semaphore.TakeWait(kReleaseTimeoutUsec)) { - acquisition_condition_.Signal(); - // If extended resources are still acquired or the release is still pending - // after the wait time, signal a nonrecoverable failure. - if (is_extended_resources_acquired_.load() || - pending_extended_resources_release_.load()) { - SB_LOG(WARNING) << "Extended resource mode release timed out"; - OnNonrecoverableFailure(); - } - is_extended_resources_acquired_.store(false); - pending_extended_resources_release_.store(false); - } - // After extendedResources release the codecs supportability changes. - // So mime supportability cache must be reset. - MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities(); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/extended_resources_manager.h b/starboard/shared/uwp/extended_resources_manager.h deleted file mode 100644 index b00c9525c893..000000000000 --- a/starboard/shared/uwp/extended_resources_manager.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_EXTENDED_RESOURCES_MANAGER_H_ -#define STARBOARD_SHARED_UWP_EXTENDED_RESOURCES_MANAGER_H_ - -#include -#include - -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/queue.h" -#include "starboard/configuration.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/starboard/thread_checker.h" - -namespace starboard { -namespace shared { -namespace uwp { - -// TODO: Refactor this class using CoreDispatcher. - -// Manages the acquiring and releasing of extended resources, and related -// objects like the d3d12 device and command queue. -class ExtendedResourcesManager { - public: - ExtendedResourcesManager(); - ~ExtendedResourcesManager(); - - static ExtendedResourcesManager* GetInstance(); - void Run(); - - void AcquireExtendedResources(); - void ReleaseExtendedResources(); - void Quit(); - void ReleaseBuffersHeap(); - - // Returns true when the d3d12 device, buffer heap - // and command queue can be used. - bool GetD3D12Objects(Microsoft::WRL::ComPtr* device, - Microsoft::WRL::ComPtr* buffer_heap, - void** command_queue); - - bool IsGpuDecoderReady() const { - return is_av1_shader_compiled_ && is_vp9_shader_compiled_; - } - - // This is called when it is found that the D3D12 driver is in an - // error state that can not be recovered from. - void OnNonrecoverableFailure() { is_nonrecoverable_failure_ = true; } - bool HasNonrecoverableFailure() { return is_nonrecoverable_failure_; } - - // Returns false if the application should exit instead of suspend. - bool IsSafeToSuspend() { return !is_nonrecoverable_failure_; } - - private: - enum Event { - kTimeout, // Returned by Queue::Poll() when there is no pending event. - kAcquireExtendedResources, - kCompileShaders, - kReleaseExtendedResources, - kQuit - }; - - bool GetD3D12ObjectsInternal(); - bool AcquireExtendedResourcesInternal(); - bool StartCompileShaders(); - void CompileShadersAsynchronously(); - void ReleaseExtendedResourcesInternal(); - - static ExtendedResourcesManager* s_instance_; - - shared::starboard::ThreadChecker thread_checker_; - Mutex mutex_; - std::atomic_bool is_extended_resources_acquired_{false}; - - std::atomic_bool is_av1_shader_compiled_ = {false}; - std::atomic_bool is_vp9_shader_compiled_ = {false}; - - bool is_nonrecoverable_failure_ = false; - Queue event_queue_; - Microsoft::WRL::ComPtr d3d12device_; - Microsoft::WRL::ComPtr d3d12queue_; - // heap for frame buffers (for the decoder and output queue) memory allocation - Microsoft::WRL::ComPtr d3d12FrameBuffersHeap_; - - // This is set to true when a release of extended resources is requested. - // Anything delaying the release should be expedited when this is set. - std::atomic_bool pending_extended_resources_release_{false}; - - // This condition variable is used to synchronize changes to - // is_extended_resources_acquired_. - ConditionVariable acquisition_condition_; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_EXTENDED_RESOURCES_MANAGER_H_ diff --git a/starboard/shared/uwp/get_home_directory.cc b/starboard/shared/uwp/get_home_directory.cc deleted file mode 100644 index 4fecc9a922ff..000000000000 --- a/starboard/shared/uwp/get_home_directory.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/starboard/get_home_directory.h" -#include "starboard/shared/win32/wchar_utils.h" -#include "starboard/system.h" - -using Windows::Storage::ApplicationData; - -namespace sbwin32 = starboard::shared::win32; - -namespace starboard { -namespace shared { -namespace starboard { - -bool GetHomeDirectory(char* out_path, int path_size) { - std::string home_directory = sbwin32::platformStringToString( - ApplicationData::Current->LocalFolder->Path); - return ::starboard::strlcpy(out_path, home_directory.c_str(), path_size); -} - -} // namespace starboard -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/keys.cc b/starboard/shared/uwp/keys.cc deleted file mode 100644 index 9da9f5242092..000000000000 --- a/starboard/shared/uwp/keys.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/keys.h" - -namespace starboard { -namespace shared { -namespace uwp { - -const char* SpeechApiKey() { - return ""; -} - -} // namespace uwp. -} // namespace shared. -} // namespace starboard. diff --git a/starboard/shared/uwp/keys.h b/starboard/shared/uwp/keys.h deleted file mode 100644 index 44dad32fe69e..000000000000 --- a/starboard/shared/uwp/keys.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_KEYS_H_ -#define STARBOARD_SHARED_UWP_KEYS_H_ - -namespace starboard { -namespace shared { -namespace uwp { - -const char* SpeechApiKey(); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_KEYS_H_ diff --git a/starboard/shared/uwp/log_file_impl.cc b/starboard/shared/uwp/log_file_impl.cc deleted file mode 100644 index e96b2f4ae643..000000000000 --- a/starboard/shared/uwp/log_file_impl.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/log_file_impl.h" - -#include - -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/common/string.h" -#include "starboard/shared/uwp/log_writer_uwp.h" -#include "starboard/shared/uwp/log_writer_win32.h" - -using Windows::Storage::StorageFolder; - -namespace starboard { -namespace shared { -namespace uwp { - -namespace { - -class LogFileImpl { - public: - static LogFileImpl* GetInstance(); - - void OpenUWP(StorageFolder ^ folder, const char* filename) { - ScopedLock lock(mutex_); - impl_.reset(); - impl_ = CreateLogWriterUWP(folder, filename); - } - - void OpenWin32(const char* path) { - ScopedLock lock(mutex_); - impl_.reset(); - impl_ = CreateLogWriterWin32(path); - } - - void Close() { - ScopedLock lock(mutex_); - impl_.reset(); - } - - void Write(const char* text, int text_length) { - ScopedLock lock(mutex_); - if (impl_) { - impl_->Write(text, text_length); - } - } - - private: - LogFileImpl() {} - starboard::Mutex mutex_; - std::unique_ptr impl_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(LogFileImpl, LogFileImpl::GetInstance); - -} // namespace - -void CloseLogFile() { - LogFileImpl::GetInstance()->Close(); -} - -void OpenLogFileUWP(StorageFolder ^ folder, const char* filename) { - LogFileImpl::GetInstance()->OpenUWP(folder, filename); -} - -void OpenLogFileWin32(const char* path) { - LogFileImpl::GetInstance()->OpenWin32(path); -} - -void WriteToLogFile(const char* text, int text_length) { - if (text_length <= 0) { - return; - } - LogFileImpl::GetInstance()->Write(text, text_length); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/log_file_impl.h b/starboard/shared/uwp/log_file_impl.h deleted file mode 100644 index 4157cfbce289..000000000000 --- a/starboard/shared/uwp/log_file_impl.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This header provides a mechanism for multiple Android logging -// formats to share a single log file handle. - -#ifndef STARBOARD_SHARED_UWP_LOG_FILE_IMPL_H_ -#define STARBOARD_SHARED_UWP_LOG_FILE_IMPL_H_ - -namespace starboard { -namespace shared { -namespace uwp { - -void OpenLogFileUWP(Windows::Storage::StorageFolder ^ folder, - const char* filename); - -void OpenLogFileWin32(const char* path); - -void CloseLogFile(); -void WriteToLogFile(const char* text, int text_length); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_LOG_FILE_IMPL_H_ diff --git a/starboard/shared/uwp/log_raw.cc b/starboard/shared/uwp/log_raw.cc deleted file mode 100644 index 77f8ca848529..000000000000 --- a/starboard/shared/uwp/log_raw.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -#include -#include - -#include "starboard/common/string.h" -#include "starboard/shared/starboard/net_log.h" -#include "starboard/shared/uwp/log_file_impl.h" - -namespace sbuwp = starboard::shared::uwp; - -namespace { - -void OutputToDebugConsole(const char* message) { - // OutputDebugStringA may stall for multiple seconds if the output string is - // too long. Split |message| into shorter strings for output. - char buffer[512]; - for (;;) { - errno_t result = strncpy_s(buffer, message, _TRUNCATE); - if (result == 0) { - OutputDebugStringA(buffer); - break; - } else if (result == STRUNCATE) { - OutputDebugStringA(buffer); - message += sizeof(buffer) - 1; - } else { - break; - } - } -} - -} // namespace. - -void SbLogRaw(const char* message) { - fprintf(stderr, "%s", message); - sbuwp::WriteToLogFile(message, static_cast(strlen(message))); - OutputToDebugConsole(message); - starboard::shared::starboard::NetLogWrite(message); -} diff --git a/starboard/shared/uwp/log_raw_format.cc b/starboard/shared/uwp/log_raw_format.cc deleted file mode 100644 index c0d117a1c4b0..000000000000 --- a/starboard/shared/uwp/log_raw_format.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -#include - -void SbLogRawFormat(const char* format, va_list arguments) { - char log_buffer[16 * 1024]; - vsnprintf_s(log_buffer, _TRUNCATE, format, arguments); - SbLogRaw(log_buffer); -} diff --git a/starboard/shared/uwp/log_writer_interface.h b/starboard/shared/uwp/log_writer_interface.h deleted file mode 100644 index 826f9b8e56f7..000000000000 --- a/starboard/shared/uwp/log_writer_interface.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_LOG_WRITER_INTERFACE_H_ -#define STARBOARD_SHARED_UWP_LOG_WRITER_INTERFACE_H_ - -namespace starboard { -namespace shared { -namespace uwp { - -class ILogWriter { - public: - ILogWriter() {} - virtual ~ILogWriter() {} - virtual void Write(const char* content, int size) = 0; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_LOG_WRITER_INTERFACE_H_ diff --git a/starboard/shared/uwp/log_writer_uwp.cc b/starboard/shared/uwp/log_writer_uwp.cc deleted file mode 100644 index c88bcf637636..000000000000 --- a/starboard/shared/uwp/log_writer_uwp.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/log_writer_uwp.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" -#include "starboard/shared/win32/wchar_utils.h" - -using Windows::Foundation::AsyncOperationCompletedHandler; -using Windows::Foundation::AsyncStatus; -using Windows::Foundation::IAsyncOperation; -using Windows::Storage::FileAccessMode; -using Windows::Storage::StorageFile; -using Windows::Storage::StorageFolder; -using Windows::Storage::Streams::DataWriter; -using Windows::Storage::Streams::IOutputStream; -using Windows::Storage::Streams::IRandomAccessStream; - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -class SharedMutex { - public: - SharedMutex() : sema_(1) {} - void Acquire() { sema_.Take(); } - void Release() { sema_.Put(); } - bool AcquireTry() { return sema_.TakeTry(); } - - private: - Semaphore sema_; -}; - -class LogWriterUWP : public ILogWriter { - public: - LogWriterUWP(StorageFolder ^ folder, const char* filename) { - OpenLogFile(folder, filename); - } - - ~LogWriterUWP() { CloseLogFile(); } - - void Write(const char* content, int size) override { - WriteToLogFile(content, size); - } - - private: - // SbMutex is not reentrant, so factor out close log file functionality for - // use by other functions. - void CloseLogFile_Locked() { log_writer_ = nullptr; } - - void CloseLogFile() { - log_mutex_.Acquire(); - CloseLogFile_Locked(); - log_mutex_.Release(); - } - - void OpenLogFile(StorageFolder ^ folder, const char* filename) { - std::wstring wfilename = win32::CStringToWString(filename); - - log_mutex_.Acquire(); - CloseLogFile_Locked(); - - // Manually set the completion callback function instead of using - // concurrency::create_task() since those tasks may not execute before the - // UI thread wants the log_mutex_ to output another log. - auto task = folder->CreateFileAsync( - ref new Platform::String(wfilename.c_str()), - Windows::Storage::CreationCollisionOption::ReplaceExisting); - task->Completed = ref new AsyncOperationCompletedHandler( - [folder, this](IAsyncOperation ^ op, AsyncStatus) { - if (op->Status != AsyncStatus::Completed) { - this->log_mutex_.Release(); - SB_LOG(ERROR) << "Unable to open log file in folder " - << win32::platformStringToString(folder->Name); - return; - } - - try { - auto task = op->GetResults()->OpenAsync(FileAccessMode::ReadWrite); - task->Completed = - ref new AsyncOperationCompletedHandler( - [this](IAsyncOperation ^ op, - AsyncStatus) { - this->log_writer_ = ref new DataWriter( - op->GetResults()->GetOutputStreamAt(0)); - this->log_mutex_.Release(); - }); - } catch (Platform::Exception ^) { - this->log_mutex_.Release(); - SB_LOG(ERROR) << "Unable to open log file in folder " - << win32::platformStringToString(folder->Name); - } - }); - } - - void WriteToLogFile(const char* text, int text_length) { - if (text_length <= 0) { - return; - } - log_mutex_.Acquire(); - if (log_writer_) { - log_writer_->WriteBytes(ref new Platform::Array( - (unsigned char*)text, text_length)); - - // Manually set the completion callback function instead of using - // concurrency::create_task() since those tasks may not execute before the - // UI thread wants the log_mutex_ to output another log. - auto task = log_writer_->StoreAsync(); - task->Completed = ref new AsyncOperationCompletedHandler( - [this](IAsyncOperation ^, AsyncStatus) { - auto task = this->log_writer_->FlushAsync(); - task->Completed = ref new AsyncOperationCompletedHandler( - [this](IAsyncOperation ^, AsyncStatus) { - this->log_mutex_.Release(); - }); - }); - } else { - log_mutex_.Release(); - } - } - SharedMutex log_mutex_; - // The Windows Storage API must be used in order to access files in - // privileged areas (e.g. KnownFolders::RemovableDevices). The win32 - // file API used by SbFile returns access denied errors in these situations. - DataWriter ^ log_writer_ = nullptr; -}; -} // namespace. - -std::unique_ptr CreateLogWriterUWP(Windows::Storage::StorageFolder ^ - folder, - const char* filename) { - std::unique_ptr output(new LogWriterUWP(folder, filename)); - return output; -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/log_writer_uwp.h b/starboard/shared/uwp/log_writer_uwp.h deleted file mode 100644 index 7b04b8316951..000000000000 --- a/starboard/shared/uwp/log_writer_uwp.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_LOG_WRITER_UWP_H_ -#define STARBOARD_SHARED_UWP_LOG_WRITER_UWP_H_ - -#include - -#include - -#include "starboard/shared/uwp/log_writer_interface.h" - -namespace starboard { -namespace shared { -namespace uwp { - -std::unique_ptr CreateLogWriterUWP(Windows::Storage::StorageFolder ^ - folder, - const char* filename); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_LOG_WRITER_UWP_H_ diff --git a/starboard/shared/uwp/log_writer_win32.cc b/starboard/shared/uwp/log_writer_win32.cc deleted file mode 100644 index 7d6f5a8bdf6e..000000000000 --- a/starboard/shared/uwp/log_writer_win32.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/log_writer_win32.h" - -#include - -#include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" - -using starboard::ScopedFile; - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -class LogWriterWin32 : public ILogWriter { - public: - explicit LogWriterWin32(const std::string& file_path) { - file_.reset( - new ScopedFile(file_path.c_str(), O_CREAT | O_TRUNC | O_WRONLY)); - if (!file_->IsValid()) { - SB_LOG(ERROR) << "Could not create watchdog file " << file_path; - file_.reset(); - } - } - - ~LogWriterWin32() { FlushToDisk(); } - - void Write(const char* content, int size) override { - starboard::ScopedLock lock(mutex_); - if (IsValid_Locked()) { - file_->Write(content, size); - } - return; - } - - private: - bool IsValid_Locked() const { return file_ && file_->IsValid(); } - - void FlushToDisk() { - starboard::ScopedLock lock(mutex_); - if (IsValid_Locked()) { - file_->Flush(); - } - } - std::string file_path_; - starboard::Mutex mutex_; - std::unique_ptr file_; -}; - -} // namespace. - -std::unique_ptr CreateLogWriterWin32(const char* path) { - std::unique_ptr output(new LogWriterWin32(path)); - return output; -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/log_writer_win32.h b/starboard/shared/uwp/log_writer_win32.h deleted file mode 100644 index ed4103a2694b..000000000000 --- a/starboard/shared/uwp/log_writer_win32.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_LOG_WRITER_WIN32_H_ -#define STARBOARD_SHARED_UWP_LOG_WRITER_WIN32_H_ - -#include - -#include "starboard/shared/uwp/log_writer_interface.h" - -namespace starboard { -namespace shared { -namespace uwp { - -std::unique_ptr CreateLogWriterWin32(const char* path); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_LOG_WRITER_WIN32_H_ diff --git a/starboard/shared/uwp/media_get_audio_configuration.cc b/starboard/shared/uwp/media_get_audio_configuration.cc deleted file mode 100644 index 96ed6ff9d653..000000000000 --- a/starboard/shared/uwp/media_get_audio_configuration.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" -#include "starboard/shared/uwp/wasapi_audio.h" - -using starboard::shared::uwp::WASAPIAudioDevice; - -bool SbMediaGetAudioConfiguration( - int output_index, - SbMediaAudioConfiguration* out_configuration) { - if (output_index != 0 || out_configuration == NULL) { - return false; - } - - out_configuration->connector = kSbMediaAudioConnectorUnknown; - out_configuration->latency = 0; - out_configuration->coding_type = kSbMediaAudioCodingTypePcm; - - int channels = - WASAPIAudioDevice::GetCachedNumChannelsOfDefaultAudioRenderer(); - - if (channels < 2) { - out_configuration->number_of_channels = 2; - } else { - out_configuration->number_of_channels = channels; - } - - return true; -} diff --git a/starboard/shared/uwp/media_is_audio_supported.cc b/starboard/shared/uwp/media_is_audio_supported.cc deleted file mode 100644 index 78bc3c2dce07..000000000000 --- a/starboard/shared/uwp/media_is_audio_supported.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/media/media_support_internal.h" - -#include "starboard/configuration.h" -#include "starboard/configuration_constants.h" -#include "starboard/media.h" -#include "starboard/shared/uwp/wasapi_audio.h" - -using ::starboard::shared::starboard::media::MimeType; -using ::starboard::shared::uwp::WASAPIAudioDevice; - -bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec, - const MimeType* mime_type, - int64_t bitrate) { - if (audio_codec != kSbMediaAudioCodecAac && - audio_codec != kSbMediaAudioCodecOpus && - audio_codec != kSbMediaAudioCodecAc3 && - audio_codec != kSbMediaAudioCodecEac3) { - return false; - } - - if (audio_codec == kSbMediaAudioCodecAc3 || - audio_codec == kSbMediaAudioCodecEac3) { - if (!(WASAPIAudioDevice::GetPassthroughSupportOfDefaultAudioRenderer( - audio_codec))) { - return false; - } - } - - int64_t local_bitrate = - WASAPIAudioDevice::GetCachedBitrateOfDefaultAudioRenderer(); - - if (local_bitrate <= 0) { - local_bitrate = kSbMediaMaxAudioBitrateInBitsPerSecond; - } - - // Here we say : "The app cannot play any encoded audio whose encoded bitrate - // exceeds the output bitrate" - return bitrate <= local_bitrate; -} diff --git a/starboard/shared/uwp/media_is_video_supported.cc b/starboard/shared/uwp/media_is_video_supported.cc deleted file mode 100644 index 59ce59f6e9a7..000000000000 --- a/starboard/shared/uwp/media_is_video_supported.cc +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/media/media_support_internal.h" - -#include "starboard/memory.h" -#include "starboard/shared/starboard/media/video_capabilities.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/extended_resources_manager.h" -#include "starboard/shared/uwp/xb1_get_type.h" -#include "starboard/shared/win32/video_decoder.h" -#include "starboard/window.h" - -using ::starboard::shared::starboard::media::MimeType; - -namespace { -using ::starboard::shared::uwp::ApplicationUwp; -using ::starboard::shared::uwp::ExtendedResourcesManager; - -class XboxVideoCapabilities { - public: - XboxVideoCapabilities() { - bool limit_to_2k = false; - SbWindowSize window_size = ApplicationUwp::Get()->GetVisibleAreaSize(); - if (window_size.width <= 1920 || window_size.height <= 1080) { - limit_to_2k = true; - } - -#ifdef ENABLE_H264_4K_SUPPORT - // Documentation claims the following resolution constraints for H264 - // decoder: - // (https://docs.microsoft.com/en-us/windows/win32/medfound/h-264-video-decoder) - // - minimum Resolution 48*48 pixels - // - maximum Resolution 4096*2304 pixels - // For Windows 8 and higher the maximum guaranteed resolution for DXVA - // acceleration is 1920*1088 pixels. - // At higher resolutions, decoding is done with DXVA, if it is supported by - // the underlying hardware, otherwise, decoding is done with software. - // Therefore platforms must explicitly opt-in to support 4k H264. - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecH264, 4096, 2304, 60); -#else // ENABLE_H264_4K_SUPPORT - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecH264, 1920, 1088, 60); -#endif // ENABLE_H264_4K_SUPPORT - - switch (starboard::shared::uwp::GetXboxType()) { - case starboard::shared::uwp::kXboxOneBase: - // Horizontal video resolutions - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 2560, 1440, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 1920, 1080, - 60); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2560, 1440, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1920, 1080, - 60); - // Vertical video resolutions - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 1440, 2560, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 1080, 1920, - 60); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1440, 2560, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1080, 1920, - 60); - break; - case starboard::shared::uwp::kXboxOneS: - if (!limit_to_2k) { - // Horizontal video resolution - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 3840, - 2160, 30); - // Vertical video resolution - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 2160, - 3840, 30); - } - // Horizontal video resolutions - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 2560, 1440, - 60); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 2560, 1440, - 60); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2560, 1440, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1920, 1080, - 60); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2560, 1440, - 30); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 1920, 1080, - 60); - // Vertical video resolutions - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 1440, 2560, - 60); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 1440, 2560, - 60); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1440, 2560, - 30); - gpu_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 1080, 1920, - 60); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 1440, 2560, - 30); - gpu_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 1080, 1920, - 60); - break; - case starboard::shared::uwp::kXboxOneX: - // Horizontal video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 2560, 1440, - 60); - // Vertical video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 2160, 3840, - 30); - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 2160, 3840, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 2160, 3840, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 1440, 2560, - 60); - break; - case starboard::shared::uwp::kXboxSeriesS: - // Horizontal video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 60); - // Vertical video resolutions - // Microsoft Vp9 MFT component is limited by 3840x2160 resolution - // so vertical video resolutions is the same as horizontal - - // Horizontal video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 30); - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2560, 1440, - 60); - // Vertical video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 30); - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 60); - break; - case starboard::shared::uwp::kXboxSeriesX: - // Horizontal video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecVp9, 3840, 2160, - 60); - // Vertical video resolutions vor vp9 is the same as horizontal - - // Horizontal video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 30); - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 3840, 2160, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2560, 1440, - 60); - // Vertical video resolutions - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 30); - hw_decoder_capabilities_.AddSdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 60); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 2160, 3840, - 30); - hw_decoder_capabilities_.AddHdrRule(kSbMediaVideoCodecAv1, 1440, 2560, - 60); - break; - default: - // If you appeared here you likely added new XBox model name but not - // specified corresponded case here to add rule for SDR and HDR - // supported resolution/framerate. - SB_NOTREACHED(); - } - } - - bool IsSupported(SbMediaVideoCodec codec, - int bit_depth, - SbMediaPrimaryId primary_id, - SbMediaTransferId transfer_id, - SbMediaMatrixId matrix_id, - int width, - int height, - int fps) const { - bool is_supported = hw_decoder_capabilities_.IsSupported( - codec, transfer_id, width, height, fps); - - if (ExtendedResourcesManager::GetInstance()->IsGpuDecoderReady() && - !is_supported) { - is_supported = gpu_decoder_capabilities_.IsSupported(codec, transfer_id, - width, height, fps); - } - - if (starboard::shared::starboard::media::IsSDRVideo( - bit_depth, primary_id, transfer_id, matrix_id)) { - return is_supported; - } - - is_supported &= ApplicationUwp::Get()->IsHdrSupported(); - is_supported &= bit_depth == 10; - is_supported &= primary_id == kSbMediaPrimaryIdBt2020; - is_supported &= transfer_id == kSbMediaTransferIdSmpteSt2084; - // According to https://support.google.com/youtube/answer/7126552 - // upload requirements the color matrix should be Rec.2020 - // non-constant luminance. - is_supported &= matrix_id == kSbMediaMatrixIdBt2020NonconstantLuminance; - return is_supported; - } - - private: - // We use gpu accelerated software decoder on kXboxOneBase and kXboxOneS. The - // software decoder initialization takes some time at app launch, and will be - // only available after initialization. So, we use |gpu_decoder_capabilities_| - // and ExtendedResourcesManager::IsGpuDecoderReady() to determine the device - // capabilities with software decoder. |hw_decoder_capabilities_| is - // determined by the device type and would not change at all. - starboard::shared::starboard::media::VideoCapabilities - hw_decoder_capabilities_; - starboard::shared::starboard::media::VideoCapabilities - gpu_decoder_capabilities_; -}; - -} // namespace - -bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec, - const MimeType* mime_type, - int profile, - int level, - int bit_depth, - SbMediaPrimaryId primary_id, - SbMediaTransferId transfer_id, - SbMediaMatrixId matrix_id, - int frame_width, - int frame_height, - int64_t bitrate, - int fps, - bool decode_to_texture_required) { - if (bitrate > kSbMediaMaxVideoBitrateInBitsPerSecond) { - return false; - } - - // To avoid massive dropping frames, only support video's fps - // that is at most 20% higher than the refresh rate of display - // in HDR mode. - if (1.2 * ApplicationUwp::Get()->GetRefreshRate() < fps) { - return false; - } - - static const XboxVideoCapabilities xbox_video_capabilities; - return xbox_video_capabilities.IsSupported(video_codec, bit_depth, primary_id, - transfer_id, matrix_id, - frame_width, frame_height, fps); -} diff --git a/starboard/shared/uwp/microphone_impl.cc b/starboard/shared/uwp/microphone_impl.cc deleted file mode 100644 index 5721f011c126..000000000000 --- a/starboard/shared/uwp/microphone_impl.cc +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/microphone/microphone_internal.h" - -// Windows headers. -#include -#include -#include - -// C++ headers. -#include -#include -#include -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" -#include "starboard/common/thread.h" -#include "starboard/common/time.h" -#include "starboard/shared/uwp/app_accessors.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/async_utils.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wchar_utils.h" - -using concurrency::task_continuation_context; -using Microsoft::WRL::ComPtr; -using starboard::Mutex; -using starboard::ScopedLock; -using starboard::Semaphore; -using starboard::shared::uwp::ApplicationUwp; -using starboard::shared::win32::platformStringToString; -using Windows::Devices::Enumeration::DeviceInformation; -using Windows::Devices::Enumeration::DeviceInformationCollection; -using Windows::Foundation::EventRegistrationToken; -using Windows::Foundation::IMemoryBufferByteAccess; -using Windows::Foundation::IMemoryBufferReference; -using Windows::Foundation::TypedEventHandler; -using Windows::Foundation::Uri; -using Windows::Media::AudioBuffer; -using Windows::Media::AudioBufferAccessMode; -using Windows::Media::AudioFrame; -using Windows::Media::Audio::AudioDeviceInputNode; -using Windows::Media::Audio::AudioDeviceNodeCreationStatus; -using Windows::Media::Audio::AudioFrameOutputNode; -using Windows::Media::Audio::AudioGraph; -using Windows::Media::Audio::AudioGraphCreationStatus; -using Windows::Media::Audio::AudioGraphSettings; -using Windows::Media::Audio::CreateAudioDeviceInputNodeResult; -using Windows::Media::Audio::CreateAudioGraphResult; -using Windows::Media::Audio::QuantumSizeSelectionMode; -using Windows::Media::Capture::MediaCategory; -using Windows::Media::Devices::MediaDevice; -using Windows::Media::MediaProperties::AudioEncodingProperties; -using Windows::Media::Render::AudioRenderCategory; -using Windows::System::Launcher; - -namespace { - -// It appears that cobalt will only request 16khz. -const int kMinSampleRate = 16000; -const int kMaxSampleRate = 44100; -const int kNumChannels = 1; -const int kOutputBytesPerSample = sizeof(int16_t); -const int kMinReadSizeBytes = 4096; -const int kMicGain = 1; - -// Controls the amount of time that a microphone will record muted audio -// before it signals a read error. Without this trigger, the app -// will continuously wait for audio data. This happens with the Kinect -// device, which when disconnected will still record 0-value samples. -const int64_t kTimeMutedThresholdUsec = 3'000'000; // 3 seconds. - -// Maps [-1.0f, 1.0f] -> [-32768, 32767] -// Values outside of [-1.0f, 1.0] are clamped. -int16_t To16BitPcm(float val) { - static const float kMaxFloatValue = std::numeric_limits::max(); - static const float kLowFloatValue = std::numeric_limits::lowest(); - if (val == 0.0f) { - return 0; - } else if (val > 0.0f) { - if (val > 1.0f) { - val = 1.0; - } - return static_cast(val * kMaxFloatValue); - } else { - if (val < -1.0f) { - val = -1.0; - } - return static_cast(-1.0f * val * kLowFloatValue); - } -} - -const char* ToString(AudioDeviceNodeCreationStatus status) { - switch (status) { - case AudioDeviceNodeCreationStatus::AccessDenied: - return "AccessDenied"; - case AudioDeviceNodeCreationStatus::DeviceNotAvailable: - return "DeviceNotAvailable"; - case AudioDeviceNodeCreationStatus::FormatNotSupported: - return "FormatNotSupported"; - case AudioDeviceNodeCreationStatus::Success: - return "Success"; - case AudioDeviceNodeCreationStatus::UnknownFailure: - return "UnknownFailure"; - } - return "Unknown"; -} - -bool IsUiThread() { - auto dispatcher = starboard::shared::uwp::GetDispatcher(); - // Is UI thread. - return dispatcher->HasThreadAccess; -} - -void LaunchMicrophonePermissionsAppAsync() { - // Schedule a task to run on the main thread which will launch a URI to - // request microphone permissions. - auto main_thread_task = - []() { - auto uri = ref new Uri("ms-settings:privacy-microphone"); - - concurrency::create_task(Launcher::LaunchUriAsync(uri)) - .then([](concurrency::task previous_task) { - try { - bool launched_ok = !!previous_task.get(); - SB_LOG_IF(ERROR, !launched_ok); - } catch (Platform::Exception ^ e) { - HRESULT hr = e->HResult; - std::string msg = platformStringToString(e->Message); - SB_LOG(ERROR) - << "Exception while launching permissions app, HRESULT: " - << hr << ", msg: " << msg; - } - }); - }; - starboard::shared::uwp::RunInMainThreadAsync(main_thread_task); -} - -std::vector GetAllMicrophoneDevices() { - std::vector output; - Platform::String ^ audio_str = MediaDevice::GetAudioCaptureSelector(); - DeviceInformationCollection ^ all_devices = - starboard::shared::uwp::WaitForResult( - DeviceInformation::FindAllAsync(audio_str)); - for (DeviceInformation ^ dev_info : all_devices) { - output.push_back(dev_info); - } - - return output; -} - -AudioGraph ^ - CreateAudioGraph(AudioRenderCategory category, - QuantumSizeSelectionMode selection_mode) { - AudioGraphSettings ^ settings = ref new AudioGraphSettings(category); - settings->QuantumSizeSelectionMode = selection_mode; - CreateAudioGraphResult ^ result = starboard::shared::uwp::WaitForResult( - AudioGraph::CreateAsync(settings)); - SB_DCHECK(result->Status == AudioGraphCreationStatus::Success); - AudioGraph ^ graph = result->Graph; - return graph; - } std:: - vector GenerateAudioInputNodes( - const std::vector& microphone_devices, - AudioEncodingProperties ^ encoding_properties, - AudioGraph ^ graph) { - std::vector output; - - int64_t start_time = starboard::CurrentMonotonicTime(); - - bool had_permissions_error = false; - for (DeviceInformation ^ mic : microphone_devices) { - auto create_microphone_input_task = graph->CreateDeviceInputNodeAsync( - MediaCategory::Speech, encoding_properties, mic); - CreateAudioDeviceInputNodeResult ^ deviceInputNodeResult = - starboard::shared::uwp::WaitForResult(create_microphone_input_task); - - auto status = deviceInputNodeResult->Status; - AudioDeviceInputNode ^ input_node = deviceInputNodeResult->DeviceInputNode; - - if (status != AudioDeviceNodeCreationStatus::Success) { - SB_LOG(INFO) << "Failed to create microphone with device name \"" - << platformStringToString(mic->Name) << "\" because " - << ToString(status); - if (status == AudioDeviceNodeCreationStatus::AccessDenied) { - // The user hasn't given cobalt access to the microphone because they - // declined access to the microphone now or previously. - had_permissions_error = true; - } - continue; - } - SB_LOG(INFO) << "Created a microphone with device \"" - << platformStringToString(mic->Name) << "\""; - input_node->ConsumeInput = true; - input_node->OutgoingGain = kMicGain; - output.push_back(input_node); - } - - int64_t delta_time = starboard::CurrentMonotonicTime() - start_time; - const bool had_ui_interaction = delta_time > 250'000; - - // We only care to retry permissions if there were - // 1. No microphones that could be opened. - // 2. There are 1 or more microphones that had errors. - // 3. There was no UI interaction, which is detected if the audio - // node creation completed really quickly. A quick action suggests - // that there was no user interaction and therefore we are in a - // permissions "cooldown" period. These typically last for 30 minutes - // and the work around requires an explicit permissions request. - const bool do_launch_microphone_permissions_app = - output.empty() && had_permissions_error && !had_ui_interaction; - - if (do_launch_microphone_permissions_app) { - LaunchMicrophonePermissionsAppAsync(); - } - return output; -} - -// Reinterprets underlying buffer type to match destination vector. -void ExtractRawAudioData(AudioFrameOutputNode ^ node, - std::vector* destination) { - AudioFrame ^ audio_frame = node->GetFrame(); - AudioBuffer ^ audio_buffer = - audio_frame->LockBuffer(AudioBufferAccessMode::Read); - IMemoryBufferReference ^ memory_buffer_reference = - audio_buffer->CreateReference(); - - ComPtr memory_byte_access; - HRESULT hr = reinterpret_cast(memory_buffer_reference) - ->QueryInterface(IID_PPV_ARGS(&memory_byte_access)); - CheckResult(hr); - - BYTE* data = nullptr; - UINT32 capacity = 0; - hr = memory_byte_access->GetBuffer(&data, &capacity); - CheckResult(hr); - - // Audio data is float data, so the buffer must be a multiple of 4. - SB_DCHECK(capacity % sizeof(float) == 0); - - if (capacity > 0) { - float* typed_data = reinterpret_cast(data); - const size_t typed_data_size = capacity / sizeof(float); - destination->insert(destination->end(), typed_data, - typed_data + typed_data_size); - } -} - -// Timer useful for detecting that the microphone has been muted for a certain -// amount of time. -class MutedTrigger { - public: - void SignalMuted() { - if (state_ == kIsMuted) { - return; - } - state_ = kIsMuted; - time_start_ = starboard::CurrentMonotonicTime(); - } - - void SignalSound() { state_ = kFoundSound; } - - bool IsMuted(int64_t duration_threshold) const { - if (state_ != kIsMuted) { - return false; - } - int64_t duration = starboard::CurrentMonotonicTime() - time_start_; - return duration > duration_threshold; - } - - private: - enum State { kInitialized, kIsMuted, kFoundSound }; - State state_ = kInitialized; - int64_t time_start_ = 0; -}; - -// MicrophoneProcessor encapsulates Microsoft's audio api. All available -// microphones are queried and instantiated. This class will mix the audio -// together into one signed 16-bit pcm stream. -// -// When the microphone is created it will find all available microphones and -// immediately start recording. A callback will be created which will process -// audio data when new samples are available. The Microphone will stop -// recording when Close() is called. -class MicrophoneProcessor : public starboard::Thread { - public: - // This will try and create a microphone. This will fail (return null) if - // there are not available microphones. - static std::unique_ptr TryCreateAndStartRecording( - size_t max_num_samples, - int sample_rate) { - std::unique_ptr output; - - std::vector microphone_devices = - GetAllMicrophoneDevices(); - if (microphone_devices.empty()) { // Unexpected condition. - return output; - } - - output.reset(new MicrophoneProcessor(max_num_samples, sample_rate, - microphone_devices)); - - if (output->input_nodes_.empty()) { - output.reset(nullptr); - } - return output; - } - - virtual ~MicrophoneProcessor() { - Thread::Join(); - audio_graph_->Stop(); - } - - // Returns the number of elements that have been written, or -1 if there - // was a read error. - int Read(int16_t* out_audio_data, size_t out_audio_count) { - ScopedLock lock(mutex_); - if (muted_timer_.IsMuted(kTimeMutedThresholdUsec)) { - return -1; - } - - out_audio_count = std::min(out_audio_count, pcm_audio_data_.size()); - using iter = std::vector::iterator; - iter it_begin = pcm_audio_data_.begin(); - iter it_end = pcm_audio_data_.begin() + out_audio_count; - std::copy(it_begin, it_end, out_audio_data); - pcm_audio_data_.erase(it_begin, it_end); - return static_cast(out_audio_count); - } - - private: - explicit MicrophoneProcessor( - size_t max_num_samples, - int sample_rate, - const std::vector& microphone_devices) - : Thread("MicrophoneProc"), max_num_samples_(max_num_samples) { - audio_graph_ = CreateAudioGraph(AudioRenderCategory::Speech, - QuantumSizeSelectionMode::SystemDefault); - wave_encoder_ = - AudioEncodingProperties::CreatePcm(sample_rate, kNumChannels, - 16); // 4-byte float. - SB_DCHECK(audio_graph_); - input_nodes_ = GenerateAudioInputNodes(microphone_devices, wave_encoder_, - audio_graph_); - for (AudioDeviceInputNode ^ input_node : input_nodes_) { - AudioFrameOutputNode ^ audio_frame_node = - audio_graph_->CreateFrameOutputNode(wave_encoder_); - audio_frame_node->ConsumeInput = true; - input_node->AddOutgoingConnection(audio_frame_node); - audio_channel_.emplace_back(new std::vector()); - audio_frame_nodes_.push_back(audio_frame_node); - } - // Update the audio data whenever a new audio sample has been finished. - audio_graph_->Start(); - Thread::Start(); - } - - void Run() override { - while (!join_called()) { - SleepMilliseconds(1); - Process(); - } - } - - void Process() { - ScopedLock lock(mutex_); - if (audio_frame_nodes_.empty()) { - return; - } - for (size_t i = 0; i < audio_frame_nodes_.size(); ++i) { - ExtractRawAudioData(audio_frame_nodes_[i], audio_channel_[i].get()); - } - - size_t num_elements = max_num_samples_; - for (const auto& audio_datum : audio_channel_) { - num_elements = std::min(audio_datum->size(), num_elements); - } - if (num_elements == 0) { - return; - } - - bool is_muted = true; - // Mix all available audio channels together and convert to output buffer - // format. Detect if audio is muted. - for (int i = 0; i < num_elements; ++i) { - float mixed_sample = 0.0f; - for (const auto& audio_datum : audio_channel_) { - float sample = (*audio_datum)[i]; - if (sample != 0.0) { - is_muted = false; - } - mixed_sample += sample; - } - pcm_audio_data_.push_back(To16BitPcm(mixed_sample)); - } - - // Trim values from finished pcm_data if the buffer has exceeded it's - // allowed size. - if (pcm_audio_data_.size() > max_num_samples_) { - size_t num_delete = pcm_audio_data_.size() - max_num_samples_; - pcm_audio_data_.erase(pcm_audio_data_.begin(), - pcm_audio_data_.begin() + num_delete); - } - - if (is_muted) { - muted_timer_.SignalMuted(); - } else { - muted_timer_.SignalSound(); - } - // Trim values from source channels that were just transferred to - // pcm_audio_data. - for (const auto& audio_datum : audio_channel_) { - audio_datum->erase(audio_datum->begin(), - audio_datum->begin() + num_elements); - } - } - - AudioGraph ^ audio_graph_ = nullptr; - AudioEncodingProperties ^ wave_encoder_; - std::vector input_nodes_; - std::vector audio_frame_nodes_; - std::vector>> audio_channel_; - std::vector pcm_audio_data_; - size_t max_num_samples_ = 0; - MutedTrigger muted_timer_; - Mutex mutex_; -}; - -// Implements the SbMicrophonePrivate interface. -class MicrophoneImpl : public SbMicrophonePrivate { - public: - MicrophoneImpl(int sample_rate, int buffer_size_bytes) - : buffer_size_bytes_(buffer_size_bytes), sample_rate_(sample_rate) {} - - ~MicrophoneImpl() { Close(); } - - bool Open() override { - if (!microphone_) { - if (IsUiThread()) { - SB_LOG(INFO) << "Could not open microphone from UI thread."; - return false; - } - microphone_ = MicrophoneProcessor::TryCreateAndStartRecording( - buffer_size_bytes_ / kOutputBytesPerSample, sample_rate_); - } - return microphone_ != nullptr; - } - - bool Close() override { - microphone_.reset(nullptr); - return true; - } - - int Read(void* out_audio_data, int audio_data_size) override { - if (!microphone_) { - return -1; - } - int16_t* pcm_buffer = reinterpret_cast(out_audio_data); - size_t pcm_buffer_count = audio_data_size / kOutputBytesPerSample; - int n_samples = microphone_->Read(pcm_buffer, pcm_buffer_count); - if (n_samples < 0) { - return -1; // Is error. - } else { - return n_samples * kOutputBytesPerSample; - } - } - - private: - const int buffer_size_bytes_; - const int sample_rate_; - std::unique_ptr microphone_; -}; - -// Singleton access is required by the microphone interface as specified by -// nplb. -const SbMicrophoneId kSingletonId = reinterpret_cast(0x1); -std::atomic s_singleton_pointer{nullptr}; - -} // namespace. - -int SbMicrophonePrivate::GetAvailableMicrophones( - SbMicrophoneInfo* out_info_array, - int info_array_size) { - std::vector mic_devices = GetAllMicrophoneDevices(); - if (mic_devices.empty()) { - return 0; - } - if (out_info_array && (info_array_size >= 1)) { - SbMicrophoneInfo info; - memset(&info, 0, sizeof(info)); - info.id = kSingletonId; - info.type = kSBMicrophoneAnalogHeadset; - info.max_sample_rate_hz = kMaxSampleRate; - info.min_read_size = kMinReadSizeBytes; - - std::stringstream all_mic_names; - for (size_t i = 0; i < mic_devices.size(); ++i) { - DeviceInformation ^ mic_dev = mic_devices[i]; - if (i > 0) { - all_mic_names << ", "; - } - all_mic_names << "[" << platformStringToString(mic_dev->Name) << "]"; - } - starboard::strlcpy(info.label, all_mic_names.str().c_str(), - SB_ARRAY_SIZE(info.label)); - out_info_array[0] = info; - } - return 1; -} - -bool SbMicrophonePrivate::IsMicrophoneSampleRateSupported( - SbMicrophoneId id, - int sample_rate_in_hz) { - if (!SbMicrophoneIdIsValid(id)) { - return false; - } - return (kMinSampleRate <= sample_rate_in_hz) && - (sample_rate_in_hz <= kMaxSampleRate); -} - -SbMicrophone SbMicrophonePrivate::CreateMicrophone(SbMicrophoneId id, - int sample_rate_in_hz, - int buffer_size_bytes) { - if (!SbMicrophoneIdIsValid(id)) { - return kSbMicrophoneInvalid; - } - if (sample_rate_in_hz < kMinSampleRate) { - return kSbMicrophoneInvalid; - } - if (sample_rate_in_hz > kMaxSampleRate) { - return kSbMicrophoneInvalid; - } - if (buffer_size_bytes <= 0) { - return kSbMicrophoneInvalid; - } - // Required to conform to nplb test. - if (buffer_size_bytes >= (std::numeric_limits::max() - 1)) { - return kSbMicrophoneInvalid; - } - // Id will either by 1 or 0. At this time there is only one microphone. - SB_DCHECK(id == kSingletonId); - if (s_singleton_pointer.load()) { - return kSbMicrophoneInvalid; - } - MicrophoneImpl* new_microphone = - new MicrophoneImpl(sample_rate_in_hz, buffer_size_bytes); - - s_singleton_pointer.store(new_microphone); - return new_microphone; -} - -void SbMicrophonePrivate::DestroyMicrophone(SbMicrophone microphone) { - SB_DCHECK(microphone == s_singleton_pointer.load()); - s_singleton_pointer.store(nullptr); - delete microphone; -} diff --git a/starboard/shared/uwp/player_components_factory.cc b/starboard/shared/uwp/player_components_factory.cc deleted file mode 100644 index 4ead7137e009..000000000000 --- a/starboard/shared/uwp/player_components_factory.cc +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/player/filter/player_components.h" - -#include - -#include - -#include "starboard/common/device_type.h" -#include "starboard/common/log.h" -#include "starboard/common/ref_counted.h" -#include "starboard/common/system_property.h" -#include "starboard/shared/opus/opus_audio_decoder.h" -#include "starboard/shared/starboard/media/media_support_internal.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/audio_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h" -#include "starboard/shared/starboard/player/filter/audio_renderer_sink_impl.h" -#include "starboard/shared/starboard/player/filter/media_time_provider_impl.h" -#include "starboard/shared/starboard/player/filter/video_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/video_render_algorithm.h" -#include "starboard/shared/starboard/player/filter/video_render_algorithm_impl.h" -#include "starboard/shared/starboard/player/filter/video_renderer_internal_impl.h" -#include "starboard/shared/starboard/player/filter/video_renderer_sink.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/audio_renderer_passthrough.h" -#include "starboard/shared/uwp/extended_resources_manager.h" -#include "starboard/shared/win32/audio_decoder.h" -#include "starboard/xb1/shared/video_decoder_uwp.h" - -#if defined(INTERNAL_BUILD) -#include "internal/starboard/xb1/dav1d_video_decoder.h" -#include "internal/starboard/xb1/vpx_video_decoder.h" -#endif // defined(INTERNAL_BUILD) - -namespace starboard { -namespace shared { -namespace starboard { -namespace player { -namespace filter { - -namespace { - -using ::starboard::shared::uwp::AudioRendererPassthrough; - -double GetRefreshRate() { - return static_cast(uwp::ApplicationUwp::Get()->GetRefreshRate()); -} - -bool IsHdrVideo(const media::VideoStreamInfo& video_stream_info) { - const auto& mime = video_stream_info.mime; - const auto& primaries = video_stream_info.color_metadata.primaries; - return mime.find("codecs=\"vp9.2") != mime.npos || - mime.find("codecs=\"vp09.02") != mime.npos || - primaries == kSbMediaPrimaryIdBt2020; -} - -class PlayerComponentsPassthrough - : public ::starboard::shared::starboard::player::filter::PlayerComponents { - public: - PlayerComponentsPassthrough( - std::unique_ptr audio_renderer, - std::unique_ptr video_renderer) - : audio_renderer_(std::move(audio_renderer)), - video_renderer_(std::move(video_renderer)) {} - - private: - // PlayerComponents methods - MediaTimeProvider* GetMediaTimeProvider() override { - return audio_renderer_.get(); - } - AudioRenderer* GetAudioRenderer() override { return audio_renderer_.get(); } - VideoRenderer* GetVideoRenderer() override { return video_renderer_.get(); } - - std::unique_ptr audio_renderer_; - std::unique_ptr video_renderer_; -}; - -class PlayerComponentsFactory : public PlayerComponents::Factory { - using AudioRendererPassthrough = - ::starboard::shared::uwp::AudioRendererPassthrough; - std::unique_ptr CreateComponents( - const CreationParameters& creation_parameters, - std::string* error_message) override { - SB_DCHECK(creation_parameters.audio_codec() != kSbMediaAudioCodecNone || - creation_parameters.video_codec() != kSbMediaVideoCodecNone); - SB_DCHECK(error_message); - - if (creation_parameters.audio_codec() != kSbMediaAudioCodecAc3 && - creation_parameters.audio_codec() != kSbMediaAudioCodecEac3) { - SB_LOG(INFO) << "Creating non pass-through components."; - return PlayerComponents::Factory::CreateComponents(creation_parameters, - error_message); - } - - SB_LOG(INFO) << "Creating pass-through components."; - - std::unique_ptr audio_decoder; - std::unique_ptr audio_renderer; - std::unique_ptr audio_renderer_sink; - std::unique_ptr video_decoder; - std::unique_ptr video_render_algorithm; - scoped_refptr video_renderer_sink; - std::unique_ptr video_renderer; - - if (!CreateSubComponents(creation_parameters, &audio_decoder, - &audio_renderer_sink, &video_decoder, - &video_render_algorithm, &video_renderer_sink, - error_message)) { - return std::unique_ptr(); - } - audio_renderer = - std::unique_ptr(new AudioRendererPassthrough( - std::move(audio_decoder), creation_parameters.audio_stream_info())); - if (creation_parameters.video_codec() != kSbMediaVideoCodecNone) { - SB_DCHECK(video_decoder); - SB_DCHECK(video_render_algorithm); - - MediaTimeProvider* media_time_provider = audio_renderer.get(); - video_renderer.reset(new VideoRendererImpl( - std::move(video_decoder), media_time_provider, - std::move(video_render_algorithm), video_renderer_sink)); - } - - return std::unique_ptr(new PlayerComponentsPassthrough( - std::move(audio_renderer), std::move(video_renderer))); - } - - bool CreateSubComponents( - const CreationParameters& creation_parameters, - std::unique_ptr* audio_decoder, - std::unique_ptr* audio_renderer_sink, - std::unique_ptr* video_decoder, - std::unique_ptr* video_render_algorithm, - scoped_refptr* video_renderer_sink, - std::string* error_message) override { - SB_DCHECK(error_message); - - if (creation_parameters.audio_codec() != kSbMediaAudioCodecNone) { - SB_DCHECK(audio_decoder); - SB_DCHECK(audio_renderer_sink); - - auto decoder_creator = [](const media::AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system) { - using AacAudioDecoder = ::starboard::shared::win32::AudioDecoder; - using OpusAudioDecoder = ::starboard::shared::opus::OpusAudioDecoder; - - if (audio_stream_info.codec == kSbMediaAudioCodecAac) { - return std::unique_ptr( - new AacAudioDecoder(audio_stream_info, drm_system)); - } else if (audio_stream_info.codec == kSbMediaAudioCodecOpus) { - std::unique_ptr audio_decoder_impl( - new OpusAudioDecoder(audio_stream_info)); - if (audio_decoder_impl->is_valid()) { - return std::unique_ptr(std::move(audio_decoder_impl)); - } - } else { - SB_NOTREACHED(); - } - return std::unique_ptr(); - }; - - auto audio_codec = creation_parameters.audio_stream_info().codec; - if (audio_codec != kSbMediaAudioCodecAc3 && - audio_codec != kSbMediaAudioCodecEac3) { - audio_decoder->reset(new AdaptiveAudioDecoder( - creation_parameters.audio_stream_info(), - creation_parameters.drm_system(), decoder_creator)); - } else { - // Use win32::AudioDecoder to decrypt and reformat the bitstream for the - // passthrough AudioRenderer. - audio_decoder->reset(new ::starboard::shared::win32::AudioDecoder( - creation_parameters.audio_stream_info(), - creation_parameters.drm_system())); - } - audio_renderer_sink->reset(new AudioRendererSinkImpl); - } - - const auto video_codec = creation_parameters.video_codec(); - if (video_codec == kSbMediaVideoCodecNone) { - return true; - } - - using MftVideoDecoder = ::starboard::xb1::shared::VideoDecoderUwp; - using ExtendedResourcesManager = shared::uwp::ExtendedResourcesManager; - - const auto output_mode = creation_parameters.output_mode(); - const auto is_hdr_video = - IsHdrVideo(creation_parameters.video_stream_info()); - - if (video_codec == kSbMediaVideoCodecH264 || - (video_codec == kSbMediaVideoCodecVp9 && - MftVideoDecoder::IsHardwareVp9DecoderSupported()) || - (video_codec == kSbMediaVideoCodecAv1 && - MftVideoDecoder::IsHardwareAv1DecoderSupported())) { - video_render_algorithm->reset( - new VideoRenderAlgorithmImpl(std::bind(GetRefreshRate))); - // The memory heap for gpu decoders isn't used by hw decoders. - // Release it. - ExtendedResourcesManager::GetInstance()->ReleaseBuffersHeap(); - video_decoder->reset(new MftVideoDecoder( - video_codec, output_mode, - creation_parameters.decode_target_graphics_context_provider(), - creation_parameters.drm_system())); - return true; - } - -#if !SB_HAS(GPU_DECODERS_ON_DESKTOP) -#if SB_API_VERSION < 15 - if (SbSystemGetDeviceType() == kSbSystemDeviceTypeDesktopPC) { - SB_LOG(WARNING) << "GPU decoder disabled on Desktop."; - return false; - } -#else - if (GetSystemPropertyString(kSbSystemPropertyDeviceType) == - kSystemDeviceTypeDesktopPC) { - SB_LOG(WARNING) << "GPU decoder disabled on Desktop."; - return false; - } -#endif -#endif // !SB_HAS(GPU_DECODERS_ON_DESKTOP) - if (video_codec != kSbMediaVideoCodecVp9 && - video_codec != kSbMediaVideoCodecAv1) { - return false; - } - SB_DCHECK(output_mode == kSbPlayerOutputModeDecodeToTexture); - - Microsoft::WRL::ComPtr d3d12device; - Microsoft::WRL::ComPtr d3d12buffer_heap; - void* d3d12queue = nullptr; - if (!uwp::ExtendedResourcesManager::GetInstance()->GetD3D12Objects( - &d3d12device, &d3d12buffer_heap, &d3d12queue)) { - // Somehow extended resources get lost. Returns directly to trigger an - // error to the player. - *error_message = - "Failed to obtain D3D12Device and/or D3D12queue required for " - "instantiating GPU based decoders."; - SB_LOG(ERROR) << *error_message; - return false; - } - SB_DCHECK(d3d12device); - SB_DCHECK(d3d12buffer_heap); - SB_DCHECK(d3d12queue); - -#if defined(INTERNAL_BUILD) - using GpuVp9VideoDecoder = ::starboard::xb1::shared::VpxVideoDecoder; - using GpuAv1VideoDecoder = ::starboard::xb1::shared::Dav1dVideoDecoder; - - if (video_codec == kSbMediaVideoCodecVp9) { - video_decoder->reset(new GpuVp9VideoDecoder( - creation_parameters.decode_target_graphics_context_provider(), - creation_parameters.video_stream_info(), is_hdr_video, d3d12device, - d3d12buffer_heap, d3d12queue)); - } - - if (video_codec == kSbMediaVideoCodecAv1) { - video_decoder->reset(new GpuAv1VideoDecoder( - creation_parameters.decode_target_graphics_context_provider(), - creation_parameters.video_stream_info(), is_hdr_video, d3d12device, - d3d12buffer_heap, d3d12queue)); - } -#endif // defined(INTERNAL_BUILD) - - if (video_decoder) { - video_render_algorithm->reset( - new VideoRenderAlgorithmImpl(std::bind(GetRefreshRate))); - return true; - } - - *error_message = FormatString( - "Unsupported video codec %d or insufficient resources to its creation.", - video_codec); - SB_LOG(ERROR) << *error_message; - return false; - } -}; - -} // namespace - -// static -std::unique_ptr PlayerComponents::Factory::Create() { - return std::unique_ptr( - new PlayerComponentsFactory); -} - -// static -bool PlayerComponents::Factory::OutputModeSupported( - SbPlayerOutputMode output_mode, - SbMediaVideoCodec codec, - SbDrmSystem drm_system) { - return output_mode == kSbPlayerOutputModeDecodeToTexture; -} - -} // namespace filter -} // namespace player -} // namespace starboard -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/system_get_property.cc b/starboard/shared/uwp/system_get_property.cc deleted file mode 100644 index 53baad1ed69f..000000000000 --- a/starboard/shared/uwp/system_get_property.cc +++ /dev/null @@ -1,350 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include -#include -#include - -#include "starboard/common/device_type.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/memory.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/keys.h" -#include "starboard/shared/win32/wchar_utils.h" -#include "starboard/system.h" -#include "starboard/xb1/shared/internal_shims.h" -#include "starboard/xb1/system_properties.h" - -using starboard::shared::win32::platformStringToString; -using Windows::Security::ExchangeActiveSyncProvisioning:: - EasClientDeviceInformation; -using Windows::System::Profile::AnalyticsInfo; -using Windows::System::Profile::AnalyticsVersionInfo; -using Windows::System::UserProfile::AdvertisingManager; - -namespace { - -#define arraysize(array) (sizeof(array) / sizeof(*array)) - -struct UwpDevice { - const char* deviceForm; - const char* chipsetModel; - const char* model; - const char* year; -} UwpDevices; - -// Array of model name and year for known UWP devices. -struct UwpDevice kDevices[] = { - {"Xbox One", "XboxOne", "XboxOne", "2013"}, - {"Xbox One S", "XboxOne", "XboxOne S", "2016"}, - {"Xbox One X", "XboxOne", "XboxOne X", "2017"}, - {"Xbox One X DevKit", "XboxOne", "XboxOne X", "2017"}, - {"Xbox Series X", "XboxScarlett", "XboxScarlett Series X", "2020"}, - {"Xbox Series X Devkit", "XboxScarlett", "XboxScarlett Series X", "2020"}, - {"Xbox Series S", "XboxScarlett", "XboxScarlett Series S", "2020"}, -}; - -const char kSystemIntegrator[] = "YouTube"; -const char kXboxDeviceFormField[] = "Xbox"; - -// Year for unknown Uwp devices. This assumes that they will be as -// capable as the most recent known device. -const char kUnknownModelYear[] = "2020"; - -// Chipset for unidentified device forms. -const char kUnknownChipset[] = "UwpUnknown"; - -bool CopyStringAndTestIfSuccess(char* out_value, - int value_length, - const char* from_value) { - if (strlen(from_value) + 1 > value_length) - return false; - starboard::strlcpy(out_value, from_value, value_length); - return true; -} - -bool CopyStringAndTestIfSuccess(char* out_value, - int value_length, - const wchar_t* from_value) { - char* from_value_str = new char[value_length]; - int len = wcstombs(from_value_str, from_value, value_length); - bool result = len < 0 ? false - : CopyStringAndTestIfSuccess(out_value, value_length, - from_value_str); - delete from_value_str; - return result; -} - -const std::size_t kOsVersionSize = 128; - -struct WindowsVersion { - uint16_t major_version; - uint16_t minor_version; - uint16_t build_version; - uint16_t revision; -}; - -bool GetWindowsVersion(WindowsVersion* version) { - SB_DCHECK(version); - AnalyticsVersionInfo ^ version_info = AnalyticsInfo::VersionInfo; - std::string device_family_version = - platformStringToString(version_info->DeviceFamilyVersion); - if (device_family_version.empty()) { - return false; - } - uint64_t version_info_all = - strtoull(device_family_version.c_str(), nullptr, 10); - if (version_info_all == 0) { - return false; - } - version->major_version = (version_info_all >> 48) & 0xFFFF; - version->minor_version = (version_info_all >> 32) & 0xFFFF; - version->build_version = (version_info_all >> 16) & 0xFFFF; - version->revision = version_info_all & 0xFFFF; - return true; -} - -std::string GetDeviceForm() { - Platform::String ^ device_form = AnalyticsInfo::DeviceForm; - return platformStringToString(device_form); -} - -bool GetBrandName(char* out_value, int value_length) { - EasClientDeviceInformation ^ current_device_info = - ref new EasClientDeviceInformation(); - std::string brand_name = - platformStringToString(current_device_info->SystemManufacturer); - if (brand_name.empty()) { - return false; - } - return CopyStringAndTestIfSuccess(out_value, value_length, - brand_name.c_str()); -} - -bool GetChipsetModelNumber(char* out_value, int value_length) { - std::string deviceForm = GetDeviceForm(); - // If the device form is a known device, return the chipset model from the - // table. - for (size_t i = 0; i < arraysize(kDevices); i++) { - const UwpDevice* device = kDevices + i; - if (deviceForm == device->deviceForm) { - return CopyStringAndTestIfSuccess(out_value, value_length, - device->chipsetModel); - } - } - - // The device form is not a known value, return unknown chipset. - return CopyStringAndTestIfSuccess(out_value, value_length, kUnknownChipset); -} - -bool GetFirmwareVersion(char* out_value, int value_length) { - WindowsVersion version = {0}; - if (!GetWindowsVersion(&version)) { - return false; - } - // The caller expects that the the output string will only be written if - // when true is returned. Therefore we have to buffer the string in case - // there is a false condition, such as small memory input size to hold - // the output parameter. - std::vector out_path_copy(kSbFileMaxPath + 1, 0); - int len = std::min(kSbFileMaxPath, value_length); - int return_value = - snprintf(out_path_copy.data(), len, "%u.%u.%u.%u", version.major_version, - version.minor_version, version.build_version, version.revision); - - const bool ok = ((return_value > 0) && (return_value < value_length)); - if (ok) { - starboard::strlcpy(out_value, out_path_copy.data(), len); - } - return ok; -} - -bool GetFriendlyName(char* out_value, int value_length) { - EasClientDeviceInformation ^ current_device_info = - ref new EasClientDeviceInformation(); - std::string friendly_name = - platformStringToString(current_device_info->FriendlyName); - if (friendly_name.empty()) { - return false; - } - return CopyStringAndTestIfSuccess(out_value, value_length, - friendly_name.c_str()); -} - -bool GetModelYear(char* out_value, int value_length) { - std::string deviceForm = GetDeviceForm(); - for (size_t i = 0; i < arraysize(kDevices); i++) { - const UwpDevice* device = kDevices + i; - if (deviceForm == device->deviceForm) { - return CopyStringAndTestIfSuccess(out_value, value_length, device->year); - } - } - - return CopyStringAndTestIfSuccess(out_value, value_length, kUnknownModelYear); -} - -bool GetModelName(char* out_value, int value_length) { - std::string deviceForm = GetDeviceForm(); - for (size_t i = 0; i < arraysize(kDevices); i++) { - const UwpDevice* device = kDevices + i; - if (deviceForm == device->deviceForm) { - return CopyStringAndTestIfSuccess(out_value, value_length, device->model); - } - } - - // The device form is not a known value, return the device form verbatim. - return CopyStringAndTestIfSuccess(out_value, value_length, - deviceForm.c_str()); -} - -bool GetPlatformName(char* out_value, int value_length) { - EasClientDeviceInformation ^ current_device_info = - ref new EasClientDeviceInformation(); - std::string operating_system = - platformStringToString(current_device_info->OperatingSystem); - - AnalyticsVersionInfo ^ version_info = AnalyticsInfo::VersionInfo; - std::string os_name_and_version = - platformStringToString(current_device_info->OperatingSystem); - if (os_name_and_version.empty()) { - return false; - } - - WindowsVersion os_version; - if (!GetWindowsVersion(&os_version)) { - return false; - } - - os_name_and_version += " "; - char os_version_buffer[kOsVersionSize]; - os_version_buffer[0] = '\0'; - - int return_value = - snprintf(os_version_buffer, value_length, "%u.%u", - os_version.major_version, os_version.minor_version); - if ((return_value < 0) || (return_value >= value_length)) { - return false; - } - - os_name_and_version.append(os_version_buffer); - - return CopyStringAndTestIfSuccess(out_value, value_length, - os_name_and_version.c_str()); -} - -bool GetAppXVersion(char* out_value, int value_length) { - Windows::ApplicationModel::PackageVersion version = - Windows::ApplicationModel::Package::Current->Id->Version; - std::stringstream version_string; - version_string << version.Major << '.' << version.Minor << '.' - << version.Build << '.' << version.Revision; - return CopyStringAndTestIfSuccess(out_value, value_length, - version_string.str().c_str()); -} - -std::string GetAdvertisingId() { - Platform::String ^ advertising_id = AdvertisingManager::AdvertisingId; - return platformStringToString(advertising_id); -} - -bool GetDeviceType(char* out_value, int value_length) { - AnalyticsVersionInfo ^ version_info = AnalyticsInfo::VersionInfo; - std::string family = starboard::shared::win32::platformStringToString( - version_info->DeviceFamily); - std::string device_type; - if (family.compare("Windows.Desktop") == 0) { - return CopyStringAndTestIfSuccess(out_value, value_length, - starboard::kSystemDeviceTypeDesktopPC); - } - if (family.compare("Windows.Xbox") == 0) { - return CopyStringAndTestIfSuccess(out_value, value_length, - starboard::kSystemDeviceTypeGameConsole); - } - SB_NOTREACHED(); - return CopyStringAndTestIfSuccess(out_value, value_length, - starboard::kSystemDeviceTypeUnknown); -} - -} // namespace - -bool SbSystemGetProperty(SbSystemPropertyId property_id, - char* out_value, - int value_length) { - if (!out_value || !value_length) { - return false; - } - - using starboard::shared::uwp::SpeechApiKey; - - switch (property_id) { - case kSbSystemPropertyCertificationScope: { - Platform::String ^ scope = starboard::xb1::shared::GetCertScope(); - if (scope->IsEmpty()) { - if (kCertificationScope[0] == '\0') - return false; - return CopyStringAndTestIfSuccess(out_value, value_length, - kCertificationScope); - } - bool result = - CopyStringAndTestIfSuccess(out_value, value_length, scope->Data()); - return result; - } - case kSbSystemPropertyChipsetModelNumber: - return GetChipsetModelNumber(out_value, value_length); - case kSbSystemPropertyFirmwareVersion: - return GetFirmwareVersion(out_value, value_length); - case kSbSystemPropertyFriendlyName: - return GetFriendlyName(out_value, value_length); - case kSbSystemPropertyBrandName: - return GetBrandName(out_value, value_length); - case kSbSystemPropertyModelName: - return GetModelName(out_value, value_length); - case kSbSystemPropertyModelYear: - return GetModelYear(out_value, value_length); - case kSbSystemPropertySystemIntegratorName: - return CopyStringAndTestIfSuccess(out_value, value_length, - kSystemIntegrator); - case kSbSystemPropertyPlatformName: - return GetPlatformName(out_value, value_length); - case kSbSystemPropertySpeechApiKey: - CopyStringAndTestIfSuccess(out_value, value_length, SpeechApiKey()); - return true; - case kSbSystemPropertyUserAgentAuxField: - return GetAppXVersion(out_value, value_length); - case kSbSystemPropertyAdvertisingId: { - std::string advertising_id = GetAdvertisingId(); - return CopyStringAndTestIfSuccess(out_value, value_length, - advertising_id.c_str()); - } - case kSbSystemPropertyLimitAdTracking: { - std::string advertising_id = GetAdvertisingId(); - // If we get an empty ID, that means the user disabled it. - return CopyStringAndTestIfSuccess(out_value, value_length, - advertising_id.empty() ? "1" : "0"); - } -#if SB_API_VERSION >= 15 - case kSbSystemPropertyDeviceType: - return GetDeviceType(out_value, value_length); -#endif - default: - SB_DLOG(WARNING) << __FUNCTION__ - << ": Unrecognized property: " << property_id; - break; - } - return false; -} diff --git a/starboard/shared/uwp/system_get_property_test.cc b/starboard/shared/uwp/system_get_property_test.cc deleted file mode 100644 index eefe2f5e4179..000000000000 --- a/starboard/shared/uwp/system_get_property_test.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/system_property.h" -#include "starboard/system.h" - -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -using starboard::kSystemPropertyMaxLength; -using testing::MatchesRegex; - -TEST(SbSystemGetPropertyTest, UserAgentAuxField) { - char out_value[kSystemPropertyMaxLength]; - bool result = SbSystemGetProperty(kSbSystemPropertyUserAgentAuxField, - out_value, kSystemPropertyMaxLength); - EXPECT_TRUE(result); - // Assert that the output value matches 4 numbers separated by periods. - EXPECT_THAT(out_value, MatchesRegex("\\d+\\.\\d+\\.\\d+\\.\\d+")); -} diff --git a/starboard/shared/uwp/system_get_total_cpu_memory.cc b/starboard/shared/uwp/system_get_total_cpu_memory.cc deleted file mode 100644 index 537658e6925e..000000000000 --- a/starboard/shared/uwp/system_get_total_cpu_memory.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -using Windows::System::MemoryManager; - -int64_t SbSystemGetTotalCPUMemory() { - return static_cast(MemoryManager::AppMemoryUsageLimit); -} diff --git a/starboard/shared/uwp/system_get_used_cpu_memory.cc b/starboard/shared/uwp/system_get_used_cpu_memory.cc deleted file mode 100644 index f326ecbc94bf..000000000000 --- a/starboard/shared/uwp/system_get_used_cpu_memory.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -using Windows::System::MemoryManager; - -int64_t SbSystemGetUsedCPUMemory() { - return static_cast(MemoryManager::AppMemoryUsage); -} diff --git a/starboard/shared/uwp/system_platform_error_internal.cc b/starboard/shared/uwp/system_platform_error_internal.cc deleted file mode 100644 index eb862243bf2f..000000000000 --- a/starboard/shared/uwp/system_platform_error_internal.cc +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/system_platform_error_internal.h" - -using Windows::Foundation::AsyncOperationCompletedHandler; -using Windows::Foundation::AsyncStatus; -using Windows::Foundation::IAsyncOperation; -using Windows::UI::Popups::IUICommand; -using Windows::UI::Popups::MessageDialog; -using Windows::UI::Popups::UICommand; -using Windows::UI::Popups::UICommandInvokedHandler; - -SbAtomic32 SbSystemPlatformErrorPrivate::s_error_count = 0; - -SbSystemPlatformErrorPrivate::SbSystemPlatformErrorPrivate( - ApplicationUwp* app, - SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data) - : callback_(callback), user_data_(user_data) { - SB_DCHECK(type == kSbSystemPlatformErrorTypeConnectionError); - - // Only one error dialog can be displayed at a time. - if (SbAtomicAcquire_CompareAndSwap(&s_error_count, 0, 1) != 0) { - return; - } - - MessageDialog ^ dialog = ref new MessageDialog(app->GetString( - "UNABLE_TO_CONTACT_YOUTUBE_1", "Sorry, could not connect to YouTube.")); - dialog->Commands->Append( - MakeUICommand(app, "OFFLINE_MESSAGE_TRY_AGAIN", "Try again", - kSbSystemPlatformErrorResponsePositive)); - dialog->Commands->Append(MakeUICommand(app, "EXIT_BUTTON", "Exit", - kSbSystemPlatformErrorResponseCancel)); - dialog->DefaultCommandIndex = 0; - dialog->CancelCommandIndex = 1; - - try { - dialog_operation_ = dialog->ShowAsync(); - dialog_operation_->Completed = - ref new AsyncOperationCompletedHandler( - [this](IAsyncOperation ^, AsyncStatus) { - SB_DCHECK(SbAtomicAcquire_Load(&s_error_count) > 0); - SbAtomicBarrier_Increment(&s_error_count, -1); - delete this; - }); - } catch (Platform::Exception ^) { - SB_LOG(ERROR) << "Unable to raise SbSystemPlatformError"; - SbAtomicBarrier_Increment(&s_error_count, -1); - } -} - -bool SbSystemPlatformErrorPrivate::IsValid() const { - return dialog_operation_.Get() != nullptr; -} - -void SbSystemPlatformErrorPrivate::ClearAndDelete() { - if (IsValid()) { - dialog_operation_->Cancel(); - } - delete this; -} - -IUICommand ^ SbSystemPlatformErrorPrivate::MakeUICommand( - ApplicationUwp* app, - const char* id, - const char* fallback, - SbSystemPlatformErrorResponse response) { - Platform::String ^ label = app->GetString(id, fallback); - return ref new UICommand(label, ref new UICommandInvokedHandler( - [this, response](IUICommand ^ command) { - callback_(response, user_data_); - })); -} diff --git a/starboard/shared/uwp/system_platform_error_internal.h b/starboard/shared/uwp/system_platform_error_internal.h deleted file mode 100644 index 959aab32c3e1..000000000000 --- a/starboard/shared/uwp/system_platform_error_internal.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_SYSTEM_PLATFORM_ERROR_INTERNAL_H_ -#define STARBOARD_SHARED_UWP_SYSTEM_PLATFORM_ERROR_INTERNAL_H_ - -#include "starboard/atomic.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/system.h" - -// Note that this is a "struct" and not a "class" because -// that's how it's defined in starboard/system.h -struct SbSystemPlatformErrorPrivate { - typedef starboard::shared::uwp::ApplicationUwp ApplicationUwp; - - SbSystemPlatformErrorPrivate(const SbSystemPlatformErrorPrivate&) = delete; - SbSystemPlatformErrorPrivate& operator=(const SbSystemPlatformErrorPrivate&) = - delete; - - SbSystemPlatformErrorPrivate(ApplicationUwp* app, - SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data); - bool IsValid() const; - void ClearAndDelete(); - - private: - typedef Windows::UI::Popups::IUICommand IUICommand; - typedef Windows::Foundation::IAsyncOperation DialogOperation; - - IUICommand ^ MakeUICommand(ApplicationUwp* app, - const char* id, - const char* fallback, - SbSystemPlatformErrorResponse response); - - SbSystemPlatformErrorCallback callback_; - void* user_data_; - Platform::Agile dialog_operation_; - - static SbAtomic32 s_error_count; -}; - -#endif // STARBOARD_SHARED_UWP_SYSTEM_PLATFORM_ERROR_INTERNAL_H_ diff --git a/starboard/shared/uwp/system_raise_platform_error.cc b/starboard/shared/uwp/system_raise_platform_error.cc deleted file mode 100644 index b223b835c250..000000000000 --- a/starboard/shared/uwp/system_raise_platform_error.cc +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/system_platform_error_internal.h" - -using starboard::shared::uwp::ApplicationUwp; - -bool SbSystemRaisePlatformError(SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data) { - ApplicationUwp* app = ApplicationUwp::Get(); - if (!app) { - return false; - } - - // Note that SbSystemPlatformErrorPrivate deletes itself on - // completion. - SbSystemPlatformErrorPrivate* handle = - new SbSystemPlatformErrorPrivate(app, type, callback, user_data); - if (!handle->IsValid()) { - handle->ClearAndDelete(); - } - return true; -} diff --git a/starboard/shared/uwp/time_zone_get_name.cc b/starboard/shared/uwp/time_zone_get_name.cc deleted file mode 100644 index d2abda29df16..000000000000 --- a/starboard/shared/uwp/time_zone_get_name.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/time_zone.h" - -#include -#include - -#include "starboard/common/once.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { -class TimeZoneString { - public: - static TimeZoneString* Get(); - const char* value() const { return value_.c_str(); } - - private: - TimeZoneString() { - Windows::Globalization::Calendar ^ calendar = - ref new Windows::Globalization::Calendar(); - Platform::String ^ time_zone = calendar->GetTimeZone(); - value_ = starboard::shared::win32::platformStringToString(time_zone); - } - std::string value_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(TimeZoneString, TimeZoneString::Get); -} // namespace. - -const char* SbTimeZoneGetName() { - const char* output = TimeZoneString::Get()->value(); - return output; -} diff --git a/starboard/shared/uwp/wasapi_audio.cc b/starboard/shared/uwp/wasapi_audio.cc deleted file mode 100644 index 679aacc4a47c..000000000000 --- a/starboard/shared/uwp/wasapi_audio.cc +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/wasapi_audio.h" - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/shared/starboard/media/mime_supportability_cache.h" -#include "starboard/shared/win32/wasapi_include.h" - -namespace starboard { -namespace shared { -namespace uwp { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::starboard::media::MimeSupportabilityCache; -using Windows::Foundation::TypedEventHandler; -using Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs; -using Windows::Media::Devices::MediaDevice; - -namespace { - -const int kWaitForActivateTimeout = 500; // 0.5 sec - -void SetPassthroughWaveformat(WAVEFORMATEXTENSIBLE* wfext, - SbMediaAudioCodec audio_codec) { - SB_DCHECK(audio_codec == kSbMediaAudioCodecAc3 || - audio_codec == kSbMediaAudioCodecEac3); - - wfext->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wfext->Format.nChannels = kIec60958Channels; - wfext->Format.wBitsPerSample = kIec60958BitsPerSample; - wfext->Format.nSamplesPerSec = audio_codec == kSbMediaAudioCodecAc3 - ? kAc3SamplesPerSecond - : kEac3SamplesPerSecond; - wfext->Format.nBlockAlign = kIec60958BlockAlign; - wfext->Format.nAvgBytesPerSec = - wfext->Format.nSamplesPerSec * wfext->Format.nBlockAlign; - wfext->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - wfext->Samples.wValidBitsPerSample = wfext->Format.wBitsPerSample; - wfext->dwChannelMask = KSAUDIO_SPEAKER_DIRECTOUT; - wfext->SubFormat = audio_codec == kSbMediaAudioCodecAc3 - ? MFAudioFormat_Dolby_AC3_SPDIF - : KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS; -} - -class DefaultAudioRenderParams { - public: - DefaultAudioRenderParams() { - device_changed_token_ = MediaDevice::DefaultAudioRenderDeviceChanged += - ref new TypedEventHandler( - [this](Platform::Object ^ sender, - DefaultAudioRenderDeviceChangedEventArgs ^ args) { - OnDefaultAudioRenderDeviceChanged(sender, args); - }); - } - - ~DefaultAudioRenderParams() { - MediaDevice::DefaultAudioRenderDeviceChanged -= device_changed_token_; - } - - int GetBitrate() { - ScopedLock lock(mutex_); - RefreshCachedParamsIfNeeded_Locked(); - return cached_bitrate_; - } - - int GetNumChannels() { - ScopedLock lock(mutex_); - RefreshCachedParamsIfNeeded_Locked(); - return cached_channels_; - } - - bool GetPassthroughCodecSupport(SbMediaAudioCodec audio_codec) { - SB_DCHECK(audio_codec == kSbMediaAudioCodecAc3 || - audio_codec == kSbMediaAudioCodecEac3); - ScopedLock lock(mutex_); - RefreshCachedParamsIfNeeded_Locked(); - return audio_codec == kSbMediaAudioCodecAc3 ? supports_ac3_passthrough_ - : supports_eac3_passthrough_; - } - - private: - std::atomic_bool is_dirty_{true}; - Mutex mutex_; - int cached_bitrate_ = 0; - int cached_channels_ = 0; - bool supports_ac3_passthrough_ = false; - bool supports_eac3_passthrough_ = false; - Windows::Foundation::EventRegistrationToken device_changed_token_{}; - - void OnDefaultAudioRenderDeviceChanged( - Platform::Object ^ sender, - Windows::Media::Devices::DefaultAudioRenderDeviceChangedEventArgs ^ - event_args) { - is_dirty_.store(true); - MimeSupportabilityCache::GetInstance()->ClearCachedMimeSupportabilities(); - } - - void RefreshCachedParamsIfNeeded_Locked() { - if (is_dirty_.load()) { - Microsoft::WRL::ComPtr audio_device = - Microsoft::WRL::Make(); - cached_bitrate_ = audio_device->GetBitrate(); - cached_channels_ = audio_device->GetNumChannels(); - supports_ac3_passthrough_ = - audio_device->GetPassthroughCodecSupport(kSbMediaAudioCodecAc3); - supports_eac3_passthrough_ = - audio_device->GetPassthroughCodecSupport(kSbMediaAudioCodecEac3); - // when a timeout occurres before WASAPIAudioDevice::ActivateCompleted() - // has been called the cached values are not set with correct values. We - // need to initializa again for getting correct values nex time. - if (cached_bitrate_ != kInitialValue && cached_channels_ != kInitialValue) - is_dirty_.store(false); - } - } -}; - -SB_ONCE_INITIALIZE_FUNCTION(DefaultAudioRenderParams, - GetDefaultAudioRenderParams); - -} // namespace - -// static -int WASAPIAudioDevice::GetCachedBitrateOfDefaultAudioRenderer() { - return GetDefaultAudioRenderParams()->GetBitrate(); -} - -// static -int WASAPIAudioDevice::GetCachedNumChannelsOfDefaultAudioRenderer() { - return GetDefaultAudioRenderParams()->GetNumChannels(); -} - -// static -bool WASAPIAudioDevice::GetPassthroughSupportOfDefaultAudioRenderer( - SbMediaAudioCodec audio_codec) { - return GetDefaultAudioRenderParams()->GetPassthroughCodecSupport(audio_codec); -} - -WASAPIAudioDevice::WASAPIAudioDevice() { - InitializeAudioDevice(); -} - -WASAPIAudioDevice::~WASAPIAudioDevice() { - CloseHandle(activate_completed_); -} - -void WASAPIAudioDevice::InitializeAudioDevice() { - ComPtr async_operation; - - // Default Audio Device Renderer - Platform::String ^ deviceIdString = MediaDevice::GetDefaultAudioRenderId( - Windows::Media::Devices::AudioDeviceRole::Default); - - if (FAILED(ActivateAudioInterfaceAsync(deviceIdString->Data(), - __uuidof(IAudioClient3), nullptr, this, - &async_operation))) { - return; - } - WaitForSingleObject(activate_completed_, kWaitForActivateTimeout); -} - -HRESULT WASAPIAudioDevice::ActivateCompleted( - IActivateAudioInterfaceAsyncOperation* operation) { - HRESULT hr = S_OK; - HRESULT hr_activate = S_OK; - ComPtr audio_interface; - - // Check for a successful activation result - hr = operation->GetActivateResult(&hr_activate, &audio_interface); - - if (SUCCEEDED(hr) && SUCCEEDED(hr_activate)) { - // Get the pointer for the Audio Client. - hr = audio_interface->QueryInterface(IID_PPV_ARGS(&audio_client_)); - SB_DCHECK(audio_client_); - if (SUCCEEDED(hr)) { - AudioClientProperties audio_props = {0}; - audio_props.cbSize = sizeof(AudioClientProperties); - audio_props.bIsOffload = false; - audio_props.eCategory = AudioCategory_Media; - - hr = audio_client_->SetClientProperties(&audio_props); - if (SUCCEEDED(hr)) { - WAVEFORMATEX* format; - hr = audio_client_->GetMixFormat(&format); - SB_DCHECK(format); - if (SUCCEEDED(hr)) { - bitrate_ = format->nSamplesPerSec * format->wBitsPerSample; - channels_ = format->nChannels; - CoTaskMemFree(format); - - if (channels_ > 2) { - WAVEFORMATEXTENSIBLE passthrough_format; - SetPassthroughWaveformat(&passthrough_format, - kSbMediaAudioCodecAc3); - hr = audio_client_->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, - &passthrough_format.Format, - nullptr); - supports_ac3_passthrough_ = hr == S_OK; - SetPassthroughWaveformat(&passthrough_format, - kSbMediaAudioCodecEac3); - hr = audio_client_->IsFormatSupported(AUDCLNT_SHAREMODE_EXCLUSIVE, - &passthrough_format.Format, - nullptr); - supports_eac3_passthrough_ = hr == S_OK; - } - } // audio_client_->GetMixFormat - } // audio_client_->SetClientProperties - } // audio_interface->QueryInterface - } - - audio_client_ = nullptr; - SetEvent(activate_completed_); - - // Need to return S_OK - return S_OK; -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/wasapi_audio.h b/starboard/shared/uwp/wasapi_audio.h deleted file mode 100644 index 086da46b4333..000000000000 --- a/starboard/shared/uwp/wasapi_audio.h +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_WASAPI_AUDIO_H_ -#define STARBOARD_SHARED_UWP_WASAPI_AUDIO_H_ - -#include -#include -#include - -#include "starboard/media.h" - -constexpr int kInitialValue = -1; - -namespace starboard { -namespace shared { -namespace uwp { - -class WASAPIAudioDevice - : public Microsoft::WRL::RuntimeClass< - Microsoft::WRL::RuntimeClassFlags, - Microsoft::WRL::FtmBase, - IActivateAudioInterfaceCompletionHandler> { - public: - // For accessing values of the bitrate and the number of channels of the - // default audio render device it is necessary to instantiate - // WASAPIAudioDevice and call its methods GetNumChannels() and GetBitrate(). - // The default audio render device may be changed by system or user but - // WASAPIAudioDevice does not care about it and for accessing actual values of - // the bitrate and the number of channels it is necessary to create the new - // instance of WASAPIAudioDevice every time before calling to GetNumChannels() - // and GetBitrate(). - // Generally WASAPIAudioDevice initialization makes some work which may take - // a while. If some code frequently instantiates WASAPIAudioDevice to get the - // bitrate and the number of channels, it may take some significant period of - // time which will cause a long delay for the caller. - // Due to this for accessing actual values of the bitrate and the number of - // channels, instead of calling GetNumChannels() and GetBitrate() please - // consider using static functions GetCachedBitrateOfDefaultAudioRenderer() - // and GetCachedNumChannelsOfDefaultAudioRenderer() which are accessing the - // cached values of the bitrate and the number of channels of the default - // audio render device. Their implementations handle the system event - // DefaultAudioRenderDeviceChanged which notifies when the default audio - // device is changed. - static int GetCachedBitrateOfDefaultAudioRenderer(); - static int GetCachedNumChannelsOfDefaultAudioRenderer(); - static bool GetPassthroughSupportOfDefaultAudioRenderer( - SbMediaAudioCodec audio_codec); - - WASAPIAudioDevice(); - virtual ~WASAPIAudioDevice(); - - int GetNumChannels() const { return channels_; } - int GetBitrate() const { return bitrate_; } - bool GetPassthroughCodecSupport(SbMediaAudioCodec audio_codec) const { - if (audio_codec == kSbMediaAudioCodecAc3) { - return supports_ac3_passthrough_; - } else if (audio_codec == kSbMediaAudioCodecEac3) { - return supports_eac3_passthrough_; - } - return false; - } - - private: - friend class WASAPIAudioDeviceTest; - STDMETHOD(ActivateCompleted)(IActivateAudioInterfaceAsyncOperation*); - void InitializeAudioDevice(); - - HANDLE activate_completed_ = CreateEvent(nullptr, TRUE, FALSE, nullptr); - Microsoft::WRL::ComPtr audio_client_ = nullptr; - int bitrate_ = kInitialValue; - int channels_ = kInitialValue; - bool supports_ac3_passthrough_ = false; - bool supports_eac3_passthrough_ = false; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_WASAPI_AUDIO_H_ diff --git a/starboard/shared/uwp/wasapi_audio_sink.cc b/starboard/shared/uwp/wasapi_audio_sink.cc deleted file mode 100644 index 4a6a6b0900e2..000000000000 --- a/starboard/shared/uwp/wasapi_audio_sink.cc +++ /dev/null @@ -1,305 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/wasapi_audio_sink.h" - -#include - -#include - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -#define CHECK_HRESULT_OK(hr) \ - do { \ - SB_DCHECK(hr == S_OK) << "WASAPI audio sink error, error code: " \ - << std::hex << hr; \ - } while (false) - -void SetPassthroughWaveFormat(WAVEFORMATEXTENSIBLE* wfext, - SbMediaAudioCodec audio_codec, - int channels, - int sample_rate) { - SB_DCHECK(audio_codec == kSbMediaAudioCodecAc3 || - audio_codec == kSbMediaAudioCodecEac3); - - wfext->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wfext->Format.nChannels = kIec60958Channels; - wfext->Format.wBitsPerSample = kIec60958BitsPerSample; - wfext->Format.nSamplesPerSec = sample_rate; - wfext->Format.nBlockAlign = kIec60958BlockAlign; - wfext->Format.nAvgBytesPerSec = - wfext->Format.nSamplesPerSec * wfext->Format.nBlockAlign; - wfext->Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - wfext->Samples.wValidBitsPerSample = wfext->Format.wBitsPerSample; - wfext->dwChannelMask = KSAUDIO_SPEAKER_DIRECTOUT; - wfext->SubFormat = audio_codec == kSbMediaAudioCodecAc3 - ? MFAudioFormat_Dolby_AC3_SPDIF - : KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS; -} - -} // namespace - -WASAPIAudioSink::WASAPIAudioSink() - : thread_checker_(starboard::ThreadChecker::kSetThreadIdOnFirstCheck) { - Microsoft::WRL::ComPtr device_enumerator; - HRESULT hr = CoCreateInstance( - CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, - reinterpret_cast(device_enumerator.GetAddressOf())); - CHECK_HRESULT_OK(hr); - hr = device_enumerator->GetDefaultAudioEndpoint(eRender, eConsole, - device_.GetAddressOf()); - CHECK_HRESULT_OK(hr); -} - -bool WASAPIAudioSink::Initialize(int channels, - int sample_rate, - SbMediaAudioCodec audio_codec) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(audio_codec == kSbMediaAudioCodecAc3 || - audio_codec == kSbMediaAudioCodecEac3); - - HRESULT hr; - WAVEFORMATEXTENSIBLE wave_format; - SetPassthroughWaveFormat(&wave_format, audio_codec, channels, sample_rate); - - hr = - device_->Activate(__uuidof(IAudioClient3), CLSCTX_ALL, NULL, - reinterpret_cast(audio_client_.GetAddressOf())); - if (hr != S_OK) { - SB_LOG(ERROR) << "Failed to activate audio client, error code: " << std::hex - << hr; - return false; - } - - // 300 milliseconds, as REFERENCE_TIME is in units of 100 nanoseconds. - REFERENCE_TIME buffer_duration = 300 * 10000; - hr = - audio_client_->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE, 0, buffer_duration, - buffer_duration, &wave_format.Format, NULL); - - if (hr != S_OK) { - SB_LOG(ERROR) << "Failed to initialize audio client, error code: " - << std::hex << hr; - return false; - } - - hr = audio_client_->GetService( - IID_ISimpleAudioVolume, - reinterpret_cast(audio_volume_.GetAddressOf())); - if (hr != S_OK) { - SB_LOG(ERROR) << "Failed to initialize volume handler, error code: " - << std::hex << hr; - return false; - } - - hr = audio_client_->GetService( - IID_IAudioRenderClient, - reinterpret_cast(render_client_.GetAddressOf())); - if (hr != S_OK) { - SB_LOG(ERROR) << "Failed to initialize render client, error code: " - << std::hex << hr; - return false; - } - - hr = audio_client_->GetService( - IID_IAudioClock, reinterpret_cast(audio_clock_.GetAddressOf())); - if (hr != S_OK) { - SB_LOG(ERROR) << "Failed to initialize audio clock, error code: " - << std::hex << hr; - return false; - } - audio_clock_->GetFrequency(&audio_clock_frequency_); - SB_DCHECK(audio_clock_frequency_ > 0); - - audio_client_->GetBufferSize(&client_buffer_size_in_frames_); - - frames_per_audio_buffer_ = audio_codec == kSbMediaAudioCodecAc3 - ? kAc3BufferSizeInFrames - : kEac3BufferSizeInFrames; - - SB_DCHECK(client_buffer_size_in_frames_ >= frames_per_audio_buffer_); - - return true; -} - -bool WASAPIAudioSink::WriteBuffer(scoped_refptr decoded_audio) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(decoded_audio->size_in_bytes() == kAc3BufferSize || - decoded_audio->size_in_bytes() == kEac3BufferSize); - SB_DCHECK(decoded_audio); - - if (!job_thread_) { - job_thread_.reset(new JobThread("wasapi_audio_sink")); - } - - ScopedLock lock(output_frames_mutex_); - bool queued_decoded_audio = false; - if (pending_decoded_audios_.size() < kMaxDecodedAudios) { - pending_decoded_audios_.push(std::move(decoded_audio)); - queued_decoded_audio = true; - } - - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::OutputFrames, this)); - - return queued_decoded_audio; -} - -void WASAPIAudioSink::Reset() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - job_thread_.reset(); - was_playing_ = false; - ScopedLock decoded_audios_lock(output_frames_mutex_); - pending_decoded_audios_ = std::queue>(); - audio_client_->Stop(); - ScopedLock audio_clock_lock(audio_clock_mutex_); - audio_client_->Reset(); -} - -void WASAPIAudioSink::Pause() { - paused_.store(true); - if (job_thread_) { - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::UpdatePlaybackState, this)); - } -} -void WASAPIAudioSink::Play() { - paused_.store(false); - if (job_thread_) { - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::UpdatePlaybackState, this)); - } -} - -void WASAPIAudioSink::SetVolume(double volume) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - if (volume > 1.0 || volume < 0.0) { - SB_LOG(WARNING) << "volume " << volume << " is not between 0.0 and 1.0"; - volume = volume > 1.0 ? 1.0 : 0.0; - } - volume_.store(volume); - if (job_thread_) { - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::UpdatePlaybackState, this)); - } -} - -void WASAPIAudioSink::SetPlaybackRate(double playback_rate) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - SB_DCHECK(playback_rate == 0.0 || playback_rate == 1.0) - << "Playback rate " << playback_rate - << " is unsupported by WASAPIAudioSink."; - playback_rate_.store(playback_rate); - if (job_thread_) { - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::UpdatePlaybackState, this)); - } -} - -double WASAPIAudioSink::GetCurrentPlaybackTime(uint64_t* updated_at) { - SB_DCHECK(audio_clock_); - - ScopedLock lock(audio_clock_mutex_); - uint64_t pos; - HRESULT hr = audio_clock_->GetPosition(&pos, updated_at); - if (hr != S_OK) { - SB_LOG(INFO) << "WASAPI audio clock error, error code: " << std::hex << hr; - return -1; - } - - return (static_cast(pos) / - static_cast(audio_clock_frequency_)) * - 1'000'000; -} - -void WASAPIAudioSink::OutputFrames() { - SB_DCHECK(job_thread_->job_queue()->BelongsToCurrentThread()); - - ScopedLock lock(output_frames_mutex_); - - if (pending_decoded_audios_.empty()) { - return; - } - - int frames_copied = 0; - uint32_t frames_in_client_buffer = 0; - int64_t output_frames_job_delay_usec = 5'000; // 5ms - HRESULT hr = audio_client_->GetCurrentPadding(&frames_in_client_buffer); - CHECK_HRESULT_OK(hr); - int frames_available = static_cast(client_buffer_size_in_frames_) - - static_cast(frames_in_client_buffer); - if (frames_available >= frames_per_audio_buffer_) { - BYTE* client_buffer = nullptr; - hr = render_client_->GetBuffer(frames_available, &client_buffer); - CHECK_HRESULT_OK(hr); - - int client_buffer_offset = 0; - while (frames_available >= frames_per_audio_buffer_ && - !pending_decoded_audios_.empty()) { - scoped_refptr decoded_audio = - pending_decoded_audios_.front(); - SB_DCHECK(decoded_audio); - memcpy(client_buffer + client_buffer_offset, - reinterpret_cast(decoded_audio->data()), - decoded_audio->size_in_bytes()); - frames_copied += frames_per_audio_buffer_; - client_buffer_offset += decoded_audio->size_in_bytes(); - pending_decoded_audios_.pop(); - frames_available -= frames_per_audio_buffer_; - } - - hr = render_client_->ReleaseBuffer(frames_copied, 0 /* dwFlags */); - CHECK_HRESULT_OK(hr); - output_frames_job_delay_usec = 0; - } - - if (!pending_decoded_audios_.empty()) { - job_thread_->job_queue()->Schedule( - std::bind(&WASAPIAudioSink::OutputFrames, this), - output_frames_job_delay_usec); - } -} - -void WASAPIAudioSink::UpdatePlaybackState() { - SB_DCHECK(job_thread_->job_queue()->BelongsToCurrentThread()); - - bool is_playing = playing(); - HRESULT hr; - if (is_playing != was_playing_) { - if (is_playing) { - hr = audio_client_->Start(); - CHECK_HRESULT_OK(hr); - } else { - hr = audio_client_->Stop(); - CHECK_HRESULT_OK(hr); - } - was_playing_ = is_playing; - } - double volume = volume_.load(); - if (current_volume_ != volume) { - hr = audio_volume_->SetMasterVolume(volume, NULL); - CHECK_HRESULT_OK(hr); - current_volume_ = volume; - } -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/wasapi_audio_sink.h b/starboard/shared/uwp/wasapi_audio_sink.h deleted file mode 100644 index c846f3476deb..000000000000 --- a/starboard/shared/uwp/wasapi_audio_sink.h +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_WASAPI_AUDIO_SINK_H_ -#define STARBOARD_SHARED_UWP_WASAPI_AUDIO_SINK_H_ - -#include -#include -#include - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/starboard/player/decoded_audio_internal.h" -#include "starboard/shared/starboard/player/job_thread.h" -#include "starboard/shared/starboard/thread_checker.h" -#include "starboard/shared/win32/wasapi_include.h" - -namespace starboard { -namespace shared { -namespace uwp { - -typedef enum __MIDL___MIDL_itf_mmdeviceapi_0000_0000_0001 { - eRender = 0, - eCapture, - eAll, - EDataFlow_enum_count -} EDataFlow; - -typedef enum __MIDL___MIDL_itf_mmdeviceapi_0000_0000_0002 { - eConsole = 0, - eMultimedia, - eCommunications, - ERole_enum_count -} ERole; - -MIDL_INTERFACE("D666063F-1587-4E43-81F1-B948E807363F") -IMMDevice : public IUnknown { - public: - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE Activate( - /* [annotation][in] */ - _In_ REFIID iid, - /* [annotation][in] */ - _In_ DWORD dwClsCtx, - /* [annotation][unique][in] */ - _In_opt_ PROPVARIANT * pActivationParams, - /* [annotation][iid_is][out] */ - _Out_ void** ppInterface) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE OpenPropertyStore( - /* [annotation][in] */ - _In_ DWORD stgmAccess, - /* [annotation][out] */ - _Out_ IPropertyStore * *ppProperties) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetId( - /* [annotation][out] */ - _Outptr_ LPWSTR * ppstrId) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetState( - /* [annotation][out] */ - _Out_ DWORD * pdwState) = 0; -}; - -MIDL_INTERFACE("A95664D2-9614-4F35-A746-DE8DB63617E6") -IMMDeviceEnumerator : public IUnknown { - public: - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE EnumAudioEndpoints( - /* [annotation][in] */ - _In_ EDataFlow dataFlow, - /* [annotation][in] */ - _In_ DWORD dwStateMask, - /* [annotation][out] */ - _Out_ IMMDeviceCollection * *ppDevices) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE - GetDefaultAudioEndpoint( - /* [annotation][in] */ - _In_ EDataFlow dataFlow, - /* [annotation][in] */ - _In_ ERole role, - /* [annotation][out] */ - _Out_ IMMDevice * *ppEndpoint) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE GetDevice( - /* [annotation][in] */ - _In_ LPCWSTR pwstrId, - /* [annotation][out] */ - _Out_ IMMDevice * *ppDevice) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE - RegisterEndpointNotificationCallback( - /* [annotation][in] */ - _In_ IMMNotificationClient * pClient) = 0; - - virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE - UnregisterEndpointNotificationCallback( - /* [annotation][in] */ - _In_ IMMNotificationClient * pClient) = 0; -}; - -const IID IID_IAudioClock = __uuidof(IAudioClock); -const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient); -const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator); -const IID IID_ISimpleAudioVolume = __uuidof(ISimpleAudioVolume); -class DECLSPEC_UUID("BCDE0395-E52F-467C-8E3D-C4579291692E") MMDeviceEnumerator; -const CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator); - -using ::starboard::shared::starboard::player::DecodedAudio; -using ::starboard::shared::starboard::player::JobQueue; -using ::starboard::shared::starboard::player::JobThread; - -class WASAPIAudioSink { - public: - WASAPIAudioSink(); - ~WASAPIAudioSink() {} - - bool Initialize(int channels, int sample_rate, SbMediaAudioCodec audio_codec); - - bool WriteBuffer(scoped_refptr decoded_audio); - - void Reset(); - void Pause(); - void Play(); - void SetVolume(double volume); - void SetPlaybackRate(double playback_rate); - // GetCurrentPlaybackTime() can be called from any thread. - double GetCurrentPlaybackTime(uint64_t* updated_at); - - bool playing() { return !paused_.load() && playback_rate_.load() > 0.0; } - - private: - void OutputFrames(); - void UpdatePlaybackState(); - - const int kMaxDecodedAudios = 16; - - // The size of one (E)AC3 sync frame in IEC 61937 frames. - const int kAc3BufferSizeInFrames = 1536; - const int kEac3BufferSizeInFrames = 6144; - - std::atomic_bool paused_{false}; - std::atomic playback_rate_{0.0}; - std::atomic volume_{0.0}; - double current_volume_ = 0.0; - bool was_playing_ = false; - - Microsoft::WRL::ComPtr device_; - Microsoft::WRL::ComPtr audio_client_; - Microsoft::WRL::ComPtr render_client_; - Microsoft::WRL::ComPtr audio_volume_; - - Mutex audio_clock_mutex_; - Microsoft::WRL::ComPtr audio_clock_; - uint64_t audio_clock_frequency_; - - uint32_t client_buffer_size_in_frames_ = 0; - int frames_per_audio_buffer_; - - Mutex output_frames_mutex_; - std::queue> pending_decoded_audios_; - - std::unique_ptr job_thread_; - - starboard::ThreadChecker thread_checker_; -}; - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_WASAPI_AUDIO_SINK_H_ diff --git a/starboard/shared/uwp/wasapi_audio_test.cc b/starboard/shared/uwp/wasapi_audio_test.cc deleted file mode 100644 index c7bf406aa371..000000000000 --- a/starboard/shared/uwp/wasapi_audio_test.cc +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/wasapi_audio.h" - -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace starboard { -namespace shared { -namespace uwp { - -using ::testing::_; -using ::testing::Return; -using ::testing::SetArgPointee; - -class IAudioClientMock : public IAudioClient2 { - public: - MOCK_METHOD1(SetClientProperties, - HRESULT(const AudioClientProperties* props)); - MOCK_METHOD1(GetMixFormat, HRESULT(WAVEFORMATEX** format)); - MOCK_METHOD2(QueryInterface, HRESULT(const IID& riid, void** obj)); - MOCK_METHOD0(AddRef, ULONG()); - MOCK_METHOD0(Release, ULONG()); - MOCK_METHOD6(Initialize, - HRESULT(AUDCLNT_SHAREMODE s, - DWORD d, - REFERENCE_TIME t1, - REFERENCE_TIME t2, - const WAVEFORMATEX* w, - LPCGUID id)); - MOCK_METHOD1(GetBufferSize, HRESULT(UINT32* n)); - MOCK_METHOD1(GetStreamLatency, HRESULT(REFERENCE_TIME* t)); - MOCK_METHOD1(GetCurrentPadding, HRESULT(UINT32* n)); - MOCK_METHOD3(IsFormatSupported, - HRESULT(AUDCLNT_SHAREMODE, const WAVEFORMATEX*, WAVEFORMATEX**)); - MOCK_METHOD2(GetDevicePeriod, HRESULT(REFERENCE_TIME*, REFERENCE_TIME*)); - MOCK_METHOD0(Start, HRESULT()); - MOCK_METHOD0(Stop, HRESULT()); - MOCK_METHOD0(Reset, HRESULT()); - MOCK_METHOD1(SetEventHandle, HRESULT(HANDLE h)); - MOCK_METHOD2(GetService, HRESULT(const IID& riid, void** obj)); - MOCK_METHOD2(IsOffloadCapable, HRESULT(AUDIO_STREAM_CATEGORY asc, BOOL* b)); - MOCK_METHOD4(GetBufferSizeLimits, - HRESULT(const WAVEFORMATEX* w, - BOOL b, - REFERENCE_TIME* t1, - REFERENCE_TIME* t2)); -}; - -class IUnknownMock : public IUnknown { - public: - MOCK_METHOD2(QueryInterface, HRESULT(const IID& riid, void** obj)); - MOCK_METHOD0(AddRef, ULONG()); - MOCK_METHOD0(Release, ULONG()); -}; - -class AsyncOperationMock : public IActivateAudioInterfaceAsyncOperation { - public: - MOCK_METHOD2(GetActivateResult, - HRESULT(HRESULT* activateResult, IUnknown** activatedInterface)); - MOCK_METHOD2(QueryInterface, HRESULT(const IID& riid, void** obj)); - MOCK_METHOD0(AddRef, ULONG()); - MOCK_METHOD0(Release, ULONG()); -}; - -class WASAPIAudioDeviceTest : public testing::Test { - protected: - void InitAudioDevice() { - audio_device_->bitrate_ = -1; - audio_device_->channels_ = -1; - audio_device_->audio_client_ = nullptr; - audio_device_->activate_completed_ = - CreateEvent(nullptr, TRUE, FALSE, nullptr); - } - - virtual void SetUp() { - audio_device_ = Microsoft::WRL::Make(); - InitAudioDevice(); - } - - void CallActivateCompleted() { - audio_device_->ActivateCompleted(&async_operation_); - } - - bool IsInitializedAndNotChanged() { - CallActivateCompleted(); - - bool res = (audio_device_->GetBitrate() == -1); - res &= (audio_device_->GetNumChannels() == -1); - - return res; - } - - WAVEFORMATEX* CreateWAVEFORMATEX(int test_channels, - int test_samples_per_sec, - int test_bits_per_sample) { - WAVEFORMATEX* format = - reinterpret_cast(CoTaskMemAlloc(sizeof(WAVEFORMATEX))); - EXPECT_NE(nullptr, format); - - format->nChannels = test_channels; - format->nSamplesPerSec = test_samples_per_sec; - format->wBitsPerSample = test_bits_per_sample; - return format; - } - - AsyncOperationMock async_operation_; - IAudioClientMock client_; - IUnknownMock audio_interface_; - Microsoft::WRL::ComPtr audio_device_; -}; - -// GetActivateResult returns not S_OK, activateResult (first argument) is set to -// S_OK, activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, GetActivateResultFailsReturnValue) { - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), Return(E_FAIL))); - - EXPECT_TRUE(IsInitializedAndNotChanged()); -} - -// GetActivateResult returns S_OK, activateResult (first argument) is not S_OK, -// activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, GetActivateResultFailsFirstArg) { - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(E_ACCESSDENIED), Return(S_OK))); - - EXPECT_TRUE(IsInitializedAndNotChanged()); -} - -// QueryInterface of audio_interface_ returns not S_OK as returned value, -// activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, QueryInterfaceIsNotSupported) { - EXPECT_CALL(audio_interface_, QueryInterface(_, _)) - .WillRepeatedly(Return(E_NOINTERFACE)); - - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), - SetArgPointee<1>(&audio_interface_), Return(S_OK))); - - EXPECT_TRUE(IsInitializedAndNotChanged()); -} - -// QueryInterface of audio_interface_ returns null pointer to interface object, -// activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, QueryInterfaceReturnsNullObj) { - IAudioClientMock* p_client = nullptr; - - // If ppvObject of audio_interface_ is NULL, QueryInterface returns E_POINTER - EXPECT_CALL(audio_interface_, QueryInterface(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<1>(p_client), Return(E_POINTER))); - - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), - SetArgPointee<1>(&audio_interface_), Return(S_OK))); - - EXPECT_TRUE(IsInitializedAndNotChanged()); -} - -// SetClientProperties of audio_client_ returns not S_OK, -// activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, SetClientPropertiesFails) { - EXPECT_CALL(client_, SetClientProperties(_)).WillRepeatedly(Return(E_FAIL)); - - EXPECT_CALL(audio_interface_, QueryInterface(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<1>(&client_), Return(S_OK))); - - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), - SetArgPointee<1>(&audio_interface_), Return(S_OK))); - - EXPECT_TRUE(IsInitializedAndNotChanged()); -} - -// GetMixFormat of audio_client_ returns not S_OK, -// activation fails, both GetNumChannels and GetBitrate should return -1 -TEST_F(WASAPIAudioDeviceTest, GetMixFormatFails) { - EXPECT_CALL(client_, SetClientProperties(_)).WillRepeatedly(Return(S_OK)); - EXPECT_CALL(client_, GetMixFormat(_)) - .WillOnce(Return(E_POINTER)) - .RetiresOnSaturation(); - EXPECT_CALL(client_, GetMixFormat(_)) - .WillOnce(Return(E_OUTOFMEMORY)) - .RetiresOnSaturation(); - EXPECT_CALL(client_, GetMixFormat(_)) - .WillOnce(Return(AUDCLNT_E_SERVICE_NOT_RUNNING)) - .RetiresOnSaturation(); - EXPECT_CALL(client_, GetMixFormat(_)) - .WillOnce(Return(AUDCLNT_E_DEVICE_INVALIDATED)) - .RetiresOnSaturation(); - - EXPECT_CALL(audio_interface_, QueryInterface(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<1>(&client_), Return(S_OK))); - - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), - SetArgPointee<1>(&audio_interface_), Return(S_OK))); - - for (int i = 0; i < 4; i++) { - InitAudioDevice(); - EXPECT_TRUE(IsInitializedAndNotChanged()); - } -} - -// GetMixFormat of audio_client_ returns S_OK and sets some values, -// activation is OK, to check GetNumChannels and GetBitrate returns -// some numbers -TEST_F(WASAPIAudioDeviceTest, CheckValuesReturned) { - EXPECT_CALL(client_, SetClientProperties(_)).WillRepeatedly(Return(S_OK)); - - EXPECT_CALL(audio_interface_, QueryInterface(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<1>(&client_), Return(S_OK))); - - EXPECT_CALL(async_operation_, GetActivateResult(_, _)) - .WillRepeatedly(DoAll(SetArgPointee<0>(S_OK), - SetArgPointee<1>(&audio_interface_), Return(S_OK))); - - int test_channels_arr[] = {2, 6}; - int test_samples_per_sec_arr[] = {44100, 48000, 96000}; - int test_bits_per_sample_arr[] = {16, 24}; - - for (int test_channels : test_channels_arr) { - for (int test_samples_per_sec : test_samples_per_sec_arr) { - for (int test_bits_per_sample : test_bits_per_sample_arr) { - EXPECT_CALL(client_, GetMixFormat(_)) - .WillRepeatedly(DoAll( - SetArgPointee<0>(CreateWAVEFORMATEX( - test_channels, test_samples_per_sec, test_bits_per_sample)), - Return(S_OK))); - - InitAudioDevice(); - CallActivateCompleted(); - EXPECT_EQ(audio_device_->GetNumChannels(), test_channels); - EXPECT_EQ(audio_device_->GetBitrate(), - (test_samples_per_sec * test_bits_per_sample)); - } // for k - } // for j - } // for i -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/watchdog_log.cc b/starboard/shared/uwp/watchdog_log.cc deleted file mode 100644 index 5b6f745f5076..000000000000 --- a/starboard/shared/uwp/watchdog_log.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/watchdog_log.h" - -#include -#include - -#include -#include - -#include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/string.h" -#include "starboard/common/thread.h" -#include "starboard/file.h" - -namespace starboard { -namespace shared { -namespace uwp { -namespace { - -// The WatchDogThread will print out "alive: \n" periodically to a -// file. On destruction WatchDogThread will write out "done\n". -// This allows a test runner to accurately determine whether this process -// is still alive, finished, or crashed. -class WatchDogThread : public Thread { - public: - explicit WatchDogThread(const std::string& file_path) - : Thread("WatchDogLog"), file_path_(file_path) { - Start(); - } - - ~WatchDogThread() { Join(); } - - void Run() override { - static const int64_t kSleepTime = 250'000; // 250ms - int counter = 0; - int file_handle = open(file_path_.c_str(), O_CREAT | O_TRUNC | O_WRONLY, - S_IRUSR | S_IWUSR); - if (!IsValid(file_handle)) { - SB_LOG(ERROR) << "Could not create watchdog file " << file_path_; - return; - } - while (!WaitForJoin(kSleepTime)) { - std::stringstream ss; - ss << "alive: " << counter++ << "\n"; - std::string str = ss.str(); - int result = - write(file_handle, str.c_str(), static_cast(str.size())); - RecordFileWriteStat(result); - fsync(file_handle); - } - const char kDone[] = "done\n"; - int result = write(file_handle, kDone, static_cast(strlen(kDone))); - RecordFileWriteStat(result); - fsync(file_handle); - usleep(50'000); - bool closed = !close(file_handle); - SB_LOG_IF(ERROR, closed) << "Could not close file " << file_path_; - } - - private: - std::string file_path_; -}; -std::unique_ptr s_watchdog_singleton_; -} // namespace. - -void StartWatchdogLog(const std::string& path) { - if (s_watchdog_singleton_.get()) { - SB_LOG(ERROR) << "WatchDogThread exists, aborting."; - return; - } - s_watchdog_singleton_.reset(new WatchDogThread(path)); -} - -void CloseWatchdogLog() { - s_watchdog_singleton_.reset(nullptr); -} - -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/watchdog_log.h b/starboard/shared/uwp/watchdog_log.h deleted file mode 100644 index da0ffad5063b..000000000000 --- a/starboard/shared/uwp/watchdog_log.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_WATCHDOG_LOG_H_ -#define STARBOARD_SHARED_UWP_WATCHDOG_LOG_H_ - -#include - -namespace starboard { -namespace shared { -namespace uwp { - -// Starts a watch dog log file. This file has "alive" printed -// to it periodically and "done" when it finishes. Useful for -// tests to determine when the process exits. Only one watchdog -// log can be active in the process. -void StartWatchdogLog(const std::string& path); -void CloseWatchdogLog(); - -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_WATCHDOG_LOG_H_ diff --git a/starboard/shared/uwp/window_create.cc b/starboard/shared/uwp/window_create.cc deleted file mode 100644 index 620699252d01..000000000000 --- a/starboard/shared/uwp/window_create.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#include "starboard/shared/uwp/application_uwp.h" - -SbWindow SbWindowCreate(const SbWindowOptions* options) { - SbWindowOptions default_options; - if (options == nullptr) { - SbWindowSetDefaultOptions(&default_options); - options = &default_options; - } - return starboard::shared::uwp::ApplicationUwp::Get()->CreateWindowForUWP( - options); -} diff --git a/starboard/shared/uwp/window_destroy.cc b/starboard/shared/uwp/window_destroy.cc deleted file mode 100644 index 87341a02ab82..000000000000 --- a/starboard/shared/uwp/window_destroy.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#include "starboard/shared/uwp/application_uwp.h" - -bool SbWindowDestroy(SbWindow window) { - return starboard::shared::uwp::ApplicationUwp::Get()->DestroyWindow(window); -} diff --git a/starboard/shared/uwp/window_get_diagonal_size_in_inches.cc b/starboard/shared/uwp/window_get_diagonal_size_in_inches.cc deleted file mode 100644 index e9982bbb026f..000000000000 --- a/starboard/shared/uwp/window_get_diagonal_size_in_inches.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include "starboard/window.h" - -using Windows::Graphics::Display::DisplayInformation; - -float SbWindowGetDiagonalSizeInInches(SbWindow window) { - DisplayInformation ^ displayInfo = DisplayInformation::GetForCurrentView(); - Platform::IBox ^ diagonalSize = displayInfo->DiagonalSizeInInches; - if (!SbWindowIsValid(window) || diagonalSize == nullptr) { - // 0 is a signal meaning that the platform doesn't know the diagonal screen - // length. - return 0.f; - } else { - return diagonalSize->Value; - } -} diff --git a/starboard/shared/uwp/window_get_platform_handle.cc b/starboard/shared/uwp/window_get_platform_handle.cc deleted file mode 100644 index 77227a61db2c..000000000000 --- a/starboard/shared/uwp/window_get_platform_handle.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "starboard/shared/uwp/window_internal.h" -#include "starboard/window.h" - -void* SbWindowGetPlatformHandle(SbWindow window) { - if (!SbWindowIsValid(window)) { - return NULL; - } - - return reinterpret_cast(window->egl_native_window()); -} diff --git a/starboard/shared/uwp/window_get_size.cc b/starboard/shared/uwp/window_get_size.cc deleted file mode 100644 index 2a868ea5588f..000000000000 --- a/starboard/shared/uwp/window_get_size.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#include "starboard/common/log.h" -#include "starboard/shared/uwp/window_internal.h" - -bool SbWindowGetSize(SbWindow window, SbWindowSize* size) { - if (!SbWindowIsValid(window)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Invalid window."; - return false; - } - - size->width = window->width; - size->height = window->height; - // The video resolution is the same as the graphics resolution. - size->video_pixel_ratio = 1.0f; - return true; -} diff --git a/starboard/shared/uwp/window_internal.cc b/starboard/shared/uwp/window_internal.cc deleted file mode 100644 index b184af4b0b09..000000000000 --- a/starboard/shared/uwp/window_internal.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/window_internal.h" -#include "third_party/angle/include/angle_windowsstore.h" - -using Windows::UI::Core::CoreWindow; - -SbWindowPrivate::SbWindowPrivate(int width, int height) - : width(width), height(height) { - angle_property_set = ref new Windows::Foundation::Collections::PropertySet(); - angle_property_set->Insert( - ref new Platform::String(EGLNativeWindowTypeProperty), - starboard::shared::uwp::ApplicationUwp::Get()->GetCoreWindow().Get()); - angle_property_set->Insert( - ref new Platform::String(EGLRenderSurfaceSizeProperty), - Windows::Foundation::PropertyValue::CreateSize( - Windows::Foundation::Size(width, height))); -} - -SbWindowPrivate::~SbWindowPrivate() {} diff --git a/starboard/shared/uwp/window_internal.h b/starboard/shared/uwp/window_internal.h deleted file mode 100644 index 46a8a7d1468d..000000000000 --- a/starboard/shared/uwp/window_internal.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_WINDOW_INTERNAL_H_ -#define STARBOARD_SHARED_UWP_WINDOW_INTERNAL_H_ - -#include - -#include "starboard/atomic.h" -#include "starboard/window.h" - -struct SbWindowPrivate { - SbWindowPrivate(int width, int height); - ~SbWindowPrivate(); - - EGLNativeWindowType egl_native_window() const { - return reinterpret_cast(angle_property_set); - } - - // The width of this window. - int width; - - // The height of this window. - int height; - - private: - Windows::Foundation::Collections::PropertySet ^ angle_property_set; -}; - -#endif // STARBOARD_SHARED_UWP_WINDOW_INTERNAL_H_ diff --git a/starboard/shared/uwp/window_set_default_options.cc b/starboard/shared/uwp/window_set_default_options.cc deleted file mode 100644 index 1c9f584c65e6..000000000000 --- a/starboard/shared/uwp/window_set_default_options.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" -#include "starboard/window.h" - -void SbWindowSetDefaultOptions(SbWindowOptions* options) { - memset(options, 0, sizeof(*options)); - options->size.width = 1920; - options->size.height = 1080; -} diff --git a/starboard/shared/uwp/xb1_get_type.cc b/starboard/shared/uwp/xb1_get_type.cc deleted file mode 100644 index c3e4b2644e54..000000000000 --- a/starboard/shared/uwp/xb1_get_type.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "starboard/shared/uwp/xb1_get_type.h" - -#include - -#include "starboard/system.h" - -namespace starboard { -namespace shared { -namespace uwp { -XboxType GetXboxType() { - // The value kXboxUndefined means that the model name needs to be clarified at - // the first time and cached for further calls. - static XboxType xbox_type = kXboxUndefined; - constexpr size_t kNameLength = 1024; - char name[kNameLength] = {}; - - if (xbox_type == kXboxUndefined) { - // Provide a base functionality even for unknown models. - xbox_type = kXboxOneBase; - - // Detect from system properties which model runs the application. - if (SbSystemGetProperty(kSbSystemPropertyModelName, name, kNameLength)) { - const std::string friendly_name(name); - if (friendly_name == "XboxOne S") { - xbox_type = kXboxOneS; - } else if (friendly_name == "XboxOne X") { - xbox_type = kXboxOneX; - } else if (friendly_name == "XboxScarlett Series S") { - xbox_type = kXboxSeriesS; - } else if (friendly_name == "XboxScarlett Series X") { - xbox_type = kXboxSeriesX; - } - } - } - return xbox_type; -} -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/xb1_get_type.h b/starboard/shared/uwp/xb1_get_type.h deleted file mode 100644 index f943fc1f4b36..000000000000 --- a/starboard/shared/uwp/xb1_get_type.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_XB1_GET_TYPE_H_ -#define STARBOARD_SHARED_UWP_XB1_GET_TYPE_H_ - -namespace starboard { -namespace shared { -namespace uwp { - -enum XboxType { - kXboxUndefined, - kXboxOneBase, - kXboxOneS, - kXboxOneX, - kXboxSeriesS, - kXboxSeriesX, -}; - -XboxType GetXboxType(); -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_XB1_GET_TYPE_H_ diff --git a/starboard/shared/uwp/xb1_media_session_client.cc b/starboard/shared/uwp/xb1_media_session_client.cc deleted file mode 100644 index ba0e4d7bb230..000000000000 --- a/starboard/shared/uwp/xb1_media_session_client.cc +++ /dev/null @@ -1,243 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/uwp/xb1_media_session_client.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/common/semaphore.h" -#include "starboard/key.h" -#include "starboard/shared/uwp/app_accessors.h" - -using starboard::shared::uwp::DisplayRequestActive; -using starboard::shared::uwp::DisplayRequestRelease; -using starboard::shared::uwp::GetTransportControls; -using starboard::shared::uwp::InjectKeypress; -using Windows::Foundation::TypedEventHandler; -using Windows::Media::MediaPlaybackStatus; -using Windows::Media::SystemMediaTransportControls; -using Windows::Media::SystemMediaTransportControlsButton; -using Windows::Media::SystemMediaTransportControlsButtonPressedEventArgs; -using Windows::Media::Playback::MediaPlayer; -using Windows::UI::Core::CoreDispatcherPriority; -using Windows::UI::Core::DispatchedHandler; - -namespace { - -MediaPlaybackStatus MediaSessionPlaybackStateToMediaPlaybackState( - CobaltExtensionMediaSessionPlaybackState playback_state) { - switch (playback_state) { - case kCobaltExtensionMediaSessionNone: - return MediaPlaybackStatus::Stopped; - case kCobaltExtensionMediaSessionPaused: - return MediaPlaybackStatus::Paused; - case kCobaltExtensionMediaSessionPlaying: - return MediaPlaybackStatus::Playing; - default: - SB_NOTREACHED() << "Invalid playback_state " << playback_state; - } - return MediaPlaybackStatus::Closed; -} - -pthread_once_t once_flag = PTHREAD_ONCE_INIT; -pthread_mutex_t mutex; - -// Callbacks to the last MediaSessionClient to become active, or null. -// In practice, only one MediaSessionClient will become active at a time. -// Protected by "mutex" -CobaltExtensionMediaSessionUpdatePlatformPlaybackStateCallback - g_update_platform_playback_state_callback; -void* g_callback_context; - -bool button_press_callback_registered = false; -bool active = false; -bool media_playing = false; - -void OnceInit() { - pthread_mutex_init(&mutex, nullptr); -} - -void InitButtonCallbackOnce() { - if (button_press_callback_registered) { - return; - } - button_press_callback_registered = true; - Platform::Agile transport_controls = - GetTransportControls(); - - transport_controls->ButtonPressed += ref new TypedEventHandler< - SystemMediaTransportControls ^, - SystemMediaTransportControlsButtonPressedEventArgs ^>( - [](SystemMediaTransportControls ^ controls, - SystemMediaTransportControlsButtonPressedEventArgs ^ args) { - SbKey key_code; - switch (args->Button) { - case SystemMediaTransportControlsButton::ChannelDown: - key_code = kSbKeyChannelDown; - break; - case SystemMediaTransportControlsButton::ChannelUp: - key_code = kSbKeyChannelUp; - break; - case SystemMediaTransportControlsButton::Next: - key_code = kSbKeyMediaNextTrack; - break; - case SystemMediaTransportControlsButton::Pause: - case SystemMediaTransportControlsButton::Play: - key_code = kSbKeyMediaPlayPause; - break; - case SystemMediaTransportControlsButton::Previous: - key_code = kSbKeyMediaPrevTrack; - break; - case SystemMediaTransportControlsButton::Stop: - key_code = kSbKeyMediaStop; - break; - case SystemMediaTransportControlsButton::FastForward: - key_code = kSbKeyMediaFastForward; - break; - case SystemMediaTransportControlsButton::Rewind: - key_code = kSbKeyMediaRewind; - break; - default: - key_code = kSbKeyUnknown; - break; - } - if (key_code != kSbKeyUnknown) { - InjectKeypress(key_code); - } - }); -} - -void OnMediaSessionStateChanged( - const CobaltExtensionMediaSessionState session_state) { - const CobaltExtensionMediaSessionPlaybackState playback_state = - session_state.actual_playback_state; - - pthread_once(&once_flag, OnceInit); - pthread_mutex_lock(&mutex); - - InitButtonCallbackOnce(); - Platform::Agile transport_controls = - GetTransportControls(); - - pthread_mutex_unlock(&mutex); - - const bool sessionActive = kCobaltExtensionMediaSessionNone == playback_state; - - bool now_active = false; - bool now_media_playing = false; - - switch (playback_state) { - case kCobaltExtensionMediaSessionPlaying: - now_active = true; - now_media_playing = true; - break; - case kCobaltExtensionMediaSessionPaused: - now_active = true; - now_media_playing = false; - break; - case kCobaltExtensionMediaSessionNone: - now_active = false; - now_media_playing = false; - break; - default: - SB_NOTREACHED() << "Unknown state reached " << playback_state; - } - if (now_media_playing && !media_playing) { - DisplayRequestActive(); - } else if (!now_media_playing && media_playing) { - DisplayRequestRelease(); - } - - transport_controls->IsEnabled = now_active; - - active = now_active; - media_playing = now_media_playing; - - transport_controls->IsChannelDownEnabled = now_active; - transport_controls->IsChannelUpEnabled = now_active; - transport_controls->IsFastForwardEnabled = now_active; - transport_controls->IsNextEnabled = now_active; - transport_controls->IsPauseEnabled = now_active; - transport_controls->IsPlayEnabled = now_active; - transport_controls->IsPreviousEnabled = now_active; - transport_controls->IsRecordEnabled = now_active; - transport_controls->IsRewindEnabled = now_active; - transport_controls->IsStopEnabled = now_active; - - if (!active) { - return; - } - - transport_controls->PlaybackStatus = - MediaSessionPlaybackStateToMediaPlaybackState(playback_state); -} - -void RegisterMediaSessionCallbacks( - void* callback_context, - CobaltExtensionMediaSessionInvokeActionCallback invoke_action_callback, - CobaltExtensionMediaSessionUpdatePlatformPlaybackStateCallback - update_platform_playback_state_callback) { - pthread_once(&once_flag, OnceInit); - pthread_mutex_lock(&mutex); - - g_callback_context = callback_context; - g_update_platform_playback_state_callback = - update_platform_playback_state_callback; - - pthread_mutex_unlock(&mutex); -} - -void DestroyMediaSessionClientCallback() { - pthread_once(&once_flag, OnceInit); - pthread_mutex_lock(&mutex); - - g_callback_context = NULL; - g_update_platform_playback_state_callback = NULL; - - pthread_mutex_unlock(&mutex); -} - -void UpdateActiveSessionPlatformPlaybackState( - CobaltExtensionMediaSessionPlaybackState state) { - pthread_once(&once_flag, OnceInit); - pthread_mutex_lock(&mutex); - - if (g_update_platform_playback_state_callback != NULL && - g_callback_context != NULL) { - g_update_platform_playback_state_callback(state, g_callback_context); - } - - pthread_mutex_unlock(&mutex); -} -} // namespace - -namespace starboard { -namespace shared { -namespace uwp { - -const CobaltExtensionMediaSessionApi kMediaSessionApi = { - kCobaltExtensionMediaSessionName, - 1, - &OnMediaSessionStateChanged, - &RegisterMediaSessionCallbacks, - &DestroyMediaSessionClientCallback, - &UpdateActiveSessionPlatformPlaybackState}; - -const void* GetMediaSessionApi() { - return &kMediaSessionApi; -} -} // namespace uwp -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/uwp/xb1_media_session_client.h b/starboard/shared/uwp/xb1_media_session_client.h deleted file mode 100644 index c7660dffb5ab..000000000000 --- a/starboard/shared/uwp/xb1_media_session_client.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_UWP_XB1_MEDIA_SESSION_CLIENT_H_ -#define STARBOARD_SHARED_UWP_XB1_MEDIA_SESSION_CLIENT_H_ - -#include -#include - -#include "starboard/common/once.h" -#include "starboard/extension/media_session.h" - -namespace starboard { -namespace shared { -namespace uwp { - -const void* GetMediaSessionApi(); -} // namespace uwp -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_UWP_XB1_MEDIA_SESSION_CLIENT_H_ diff --git a/starboard/shared/win32/__init__.py b/starboard/shared/win32/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/starboard/shared/win32/adapter_utils.cc b/starboard/shared/win32/adapter_utils.cc deleted file mode 100644 index 6b8ea240acab..000000000000 --- a/starboard/shared/win32/adapter_utils.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/adapter_utils.h" - -#include - -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/common/socket.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace { -const ULONG kDefaultAdapterInfoBufferSizeInBytes = 16 * 1024; -} // namespace - -namespace starboard { -namespace shared { -namespace win32 { - -bool GetAdapters(const SbSocketAddressType address_type, - std::unique_ptr* adapter_info) { - SB_DCHECK(adapter_info); - - ULONG family = 0; - int address_length_bytes = 0; - - switch (address_type) { - case kSbSocketAddressTypeIpv4: - family = AF_INET; - address_length_bytes = kAddressLengthIpv4; - break; - case kSbSocketAddressTypeIpv6: - family = AF_INET6; - address_length_bytes = kAddressLengthIpv6; - break; - default: - SB_NOTREACHED() << "Invalid address type: " << address_type; - return false; - } - - ULONG adapter_addresses_number_bytes = kDefaultAdapterInfoBufferSizeInBytes; - - for (int try_count = 0; try_count != 2; ++try_count) { - // Using auto for return value here, since different versions of windows use - // slightly different datatypes. These differences do not matter to us, but - // the compiler might warn on them. - adapter_info->reset(new char[adapter_addresses_number_bytes]); - PIP_ADAPTER_ADDRESSES adapter_addresses = - reinterpret_cast(adapter_info->get()); - - // Note: If |GetAdapterAddresses| deems that buffer supplied is not enough, - // it will return the recommended number of bytes in - // |adapter_addresses_number_bytes|. - auto retval = GetAdaptersAddresses( - family, GAA_FLAG_SKIP_FRIENDLY_NAME | GAA_FLAG_SKIP_DNS_SERVER, nullptr, - adapter_addresses, &adapter_addresses_number_bytes); - - if (retval == ERROR_SUCCESS) { - return true; - } - if (retval != ERROR_BUFFER_OVERFLOW) { - // Only retry with more memory if the error says so. - break; - } - SB_LOG(ERROR) << "GetAdapterAddresses() failed with error code " << retval; - } - return false; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/adapter_utils.h b/starboard/shared/win32/adapter_utils.h deleted file mode 100644 index 831fb86cfceb..000000000000 --- a/starboard/shared/win32/adapter_utils.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_ADAPTER_UTILS_H_ -#define STARBOARD_SHARED_WIN32_ADAPTER_UTILS_H_ - -#include - -#include -#include - -#include - -#include "starboard/common/socket.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// Returns all of the results for wi32's -bool GetAdapters(const SbSocketAddressType address_type, - std::unique_ptr* adapter_info); - -// Returns true if a IP_ADAPTER_ADDRESSES IfType is a -// non-loopback Ethernet interface. -inline bool IsIfTypeEthernet(DWORD iftype) { - switch (iftype) { - case IF_TYPE_ETHERNET_CSMACD: - case IF_TYPE_IEEE80211: - return true; - case IF_TYPE_SOFTWARE_LOOPBACK: - default: - return false; - } -} - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_ADAPTER_UTILS_H_ diff --git a/starboard/shared/win32/application_win32.cc b/starboard/shared/win32/application_win32.cc deleted file mode 100644 index 0e337f06d48b..000000000000 --- a/starboard/shared/win32/application_win32.cc +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/application_win32.h" - -#include // NOLINT(build/include_order) -#include // NOLINT(build/include_order) - -#include -#include - -#include "starboard/input.h" -#include "starboard/key.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/win32/dialog.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/minidump.h" -#include "starboard/shared/win32/thread_private.h" -#include "starboard/shared/win32/wchar_utils.h" -#include "starboard/shared/win32/window_internal.h" -#include "starboard/system.h" - -using starboard::shared::starboard::Application; -using starboard::shared::starboard::CommandLine; -using starboard::shared::win32::ApplicationWin32; -using starboard::shared::win32::CStringToWString; -using starboard::shared::win32::DebugLogWinError; - -namespace { - -static const int kSbMouseDeviceId = 1; - -static const TCHAR kWindowClassName[] = L"window_class_name"; -const char kMiniDumpFilePath[] = "mini_dump_file_path"; - -LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM w_param, LPARAM l_param) { - return ApplicationWin32::Get()->WindowProcess(hWnd, msg, w_param, l_param); -} - -bool RegisterWindowClass() { - WNDCLASSEX window_class; - window_class.cbSize = sizeof(WNDCLASSEX); - // https://msdn.microsoft.com/en-us/library/windows/desktop/ff729176(v=vs.85).aspx - window_class.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; - window_class.lpfnWndProc = WndProc; - window_class.cbClsExtra = 0; - window_class.cbWndExtra = 0; - window_class.hInstance = GetModuleHandle(nullptr); - // TODO: Add YouTube icon. - window_class.hIcon = LoadIcon(window_class.hInstance, IDI_APPLICATION); - window_class.hIconSm = LoadIcon(window_class.hInstance, IDI_APPLICATION); - window_class.hCursor = LoadCursor(NULL, IDC_ARROW); - window_class.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - window_class.lpszMenuName = NULL; - window_class.lpszClassName = kWindowClassName; - - if (!::RegisterClassEx(&window_class)) { - SB_LOG(ERROR) << "Failed to register window"; - DebugLogWinError(); - return false; - } - return true; -} - -// Create a Windows window. -HWND CreateWindowInstance(const SbWindowOptions& options) { - DWORD dwStyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_CLIPSIBLINGS | - WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; - if (options.windowed) { - dwStyle |= WS_MAXIMIZE; - } - const std::wstring wide_window_name = CStringToWString(options.name); - const HWND window = CreateWindow( - kWindowClassName, wide_window_name.c_str(), dwStyle, CW_USEDEFAULT, - CW_USEDEFAULT, options.size.width, options.size.height, nullptr, nullptr, - GetModuleHandle(nullptr), nullptr); - SetForegroundWindow(window); - if (window == nullptr) { - SB_LOG(ERROR) << "Failed to create window."; - DebugLogWinError(); - } - - return window; -} - -void AttachMiniDumpHandler(const CommandLine& cmd_line) { - std::string file_path; - if (cmd_line.HasSwitch(kMiniDumpFilePath)) { - // If there is a mini dump file path then use that. - file_path = cmd_line.GetSwitchValue(kMiniDumpFilePath); - } else { - // Otherwise use the file path and append ".dmp" to it. - const auto& args = cmd_line.argv(); - if (!args.empty()) { - file_path = args[0]; - file_path.append(".dmp"); - } - } - - if (!file_path.empty()) { - starboard::shared::win32::InitMiniDumpHandler(file_path.c_str()); - } -} - -} // namespace - -namespace starboard { -namespace shared { -namespace win32 { - -#if SB_API_VERSION >= 15 -ApplicationWin32::ApplicationWin32( - SbEventHandleCallback sb_event_handle_callback) - : localized_strings_(SbSystemGetLocaleId()), - QueueApplication(sb_event_handle_callback) {} -#else -ApplicationWin32::ApplicationWin32() - : localized_strings_(SbSystemGetLocaleId()) {} -#endif // SB_API_VERSION >= 15 -ApplicationWin32::~ApplicationWin32() {} - -SbWindow ApplicationWin32::CreateWindowForWin32( - const SbWindowOptions* options) { - if (SbWindowIsValid(window_.get())) { - SB_LOG(WARNING) << "Returning existing window instance."; - return window_.get(); - } - - RegisterWindowClass(); - HWND window; - if (options) { - window = CreateWindowInstance(*options); - window_.reset(new SbWindowPrivate(options, window)); - } else { - SbWindowOptions default_options; - SbWindowSetDefaultOptions(&default_options); - window = CreateWindowInstance(default_options); - window_.reset(new SbWindowPrivate(&default_options, window)); - } - ShowWindow(window, SW_SHOW); - UpdateWindow(window); - return window_.get(); -} - -bool ApplicationWin32::DestroyWindow(SbWindow window) { - if (!SbWindowIsValid(window) || window != window_.get()) { - return false; - } - - HWND window_handle = window_->GetWindowHandle(); - window_.reset(); - - if (!::DestroyWindow(window_handle)) { - SB_LOG(WARNING) << "Unable to destroy window"; - } - - if (!::UnregisterClass(kWindowClassName, NULL)) { - SB_LOG(ERROR) << "Failed to unregister window class."; - DebugLogWinError(); - } - - return true; -} - -bool ApplicationWin32::OnSbSystemRaisePlatformError( - SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data) { - // This was never being deleted, but it should be. - if (type != kSbSystemPlatformErrorTypeConnectionError) - SB_NOTREACHED(); - - ApplicationWin32* app = ApplicationWin32::Get(); - const bool created_dialog = ShowOkCancelDialog( - app->GetCoreWindow()->GetWindowHandle(), - "", // No title. - app->GetLocalizedString("UNABLE_TO_CONTACT_YOUTUBE_1", - "Sorry, could not connect to YouTube."), - app->GetLocalizedString("RETRY_BUTTON", "Retry"), - [this, callback, user_data]() { - callback(kSbSystemPlatformErrorResponsePositive, user_data); - }, - app->GetLocalizedString("EXIT_BUTTON", "Exit"), - [this, callback, user_data]() { - callback(kSbSystemPlatformErrorResponseNegative, user_data); - }); - SB_DCHECK(!created_dialog); - if (!created_dialog) { - SB_LOG(ERROR) << "Failed to create dialog!"; - } - return true; -} - -Application::Event* ApplicationWin32::WaitForSystemEventWithTimeout( - int64_t time) { - ProcessNextSystemMessage(); - if (pending_event_) { - Event* out = pending_event_; - pending_event_ = nullptr; - return out; - } - - ScopedLock lock(stop_waiting_for_system_events_mutex_); - if (time <= CurrentMonotonicTime() || stop_waiting_for_system_events_) { - stop_waiting_for_system_events_ = false; - return nullptr; - } - - return WaitForSystemEventWithTimeout(time); -} - -LRESULT ApplicationWin32::WindowProcess(HWND hWnd, - UINT msg, - WPARAM w_param, - LPARAM l_param) { - switch (msg) { - // Input message handling. - case WM_MBUTTONDOWN: - case WM_LBUTTONDOWN: - case WM_RBUTTONDOWN: - case WM_MBUTTONUP: - case WM_LBUTTONUP: - case WM_RBUTTONUP: - case WM_MOUSEMOVE: - case WM_MOUSEWHEEL: - pending_event_ = - ProcessWinMouseEvent(GetCoreWindow(), msg, w_param, l_param); - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - case WM_KEYUP: - case WM_SYSKEYUP: - pending_event_ = - ProcessWinKeyEvent(GetCoreWindow(), msg, w_param, l_param); - break; - case WM_DESTROY: - if (window_.get()) { - // Freeze the application first so we can do some cleanup before the - // window is destroyed (e.g. stopping rasterization). - InjectAndProcess(kSbEventTypeFreeze, /* checkSystemEvents */ false); - PostQuitMessage(0); - } - break; - default: - return DefWindowProcW(hWnd, msg, w_param, l_param); - } - return 0; -} - -int ApplicationWin32::Run(int argc, char** argv) { - CommandLine cmd_line(argc, argv); - AttachMiniDumpHandler(cmd_line); - int return_val = Application::Run(argc, argv); - return return_val; -} - -void ApplicationWin32::ProcessNextSystemMessage() { - MSG msg; - BOOL peek_message_return = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); - if (peek_message_return == 0) { // 0 indicates no messages available. - return; - } - - if (!DialogHandleMessage(&msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - if (msg.message == WM_QUIT) { - SB_LOG(INFO) << "Received Quit message; stopping application"; - SbSystemRequestStop(msg.wParam); - } -} - -Application::Event* ApplicationWin32::ProcessWinMouseEvent(SbWindow window, - UINT msg, - WPARAM w_param, - LPARAM l_param) { - SbInputData* data = new SbInputData(); - memset(data, 0, sizeof(*data)); - - data->window = window; - data->device_type = kSbInputDeviceTypeMouse; - data->device_id = kSbMouseDeviceId; - switch (msg) { - case WM_LBUTTONDOWN: - data->key = kSbKeyMouse1; - data->type = kSbInputEventTypePress; - break; - case WM_RBUTTONDOWN: - data->key = kSbKeyMouse2; - data->type = kSbInputEventTypePress; - break; - case WM_MBUTTONDOWN: - data->key = kSbKeyMouse3; - data->type = kSbInputEventTypePress; - break; - case WM_LBUTTONUP: - data->key = kSbKeyMouse1; - data->type = kSbInputEventTypeUnpress; - break; - case WM_RBUTTONUP: - data->key = kSbKeyMouse2; - data->type = kSbInputEventTypeUnpress; - break; - case WM_MBUTTONUP: - data->key = kSbKeyMouse3; - data->type = kSbInputEventTypeUnpress; - break; - case WM_MOUSEMOVE: - data->type = kSbInputEventTypeMove; - break; - case WM_MOUSEWHEEL: { - data->type = kSbInputEventTypeWheel; - int wheel_delta = GET_WHEEL_DELTA_WPARAM(w_param); - // Per MSFT, standard mouse wheel increments are multiples of 120. For - // smooth scrolling, this may be less. - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms645617(v=vs.85).aspx - data->delta.y = wheel_delta / 120.0f; - } break; - default: - SB_LOG(WARNING) << "Received unrecognized MSG code " << msg; - return nullptr; - } - - data->pressure = NAN; - data->size = {NAN, NAN}; - data->tilt = {NAN, NAN}; - data->position.x = GET_X_LPARAM(l_param); - data->position.y = GET_Y_LPARAM(l_param); - - return new Application::Event(kSbEventTypeInput, data, - &Application::DeleteDestructor); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/application_win32.h b/starboard/shared/win32/application_win32.h deleted file mode 100644 index 52955d044c71..000000000000 --- a/starboard/shared/win32/application_win32.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_APPLICATION_WIN32_H_ -#define STARBOARD_SHARED_WIN32_APPLICATION_WIN32_H_ - -// Windows headers. -#include - -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/time.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/starboard/localized_strings.h" -#include "starboard/shared/starboard/queue_application.h" -#include "starboard/shared/win32/window_internal.h" -#include "starboard/system.h" -#include "starboard/window.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class ApplicationWin32 : public starboard::QueueApplication { - public: -#if SB_API_VERSION >= 15 - explicit ApplicationWin32(SbEventHandleCallback sb_event_handle_callback); -#else - ApplicationWin32(); -#endif // SB_API_VERSION >= 15 - ~ApplicationWin32() override; - - static ApplicationWin32* Get() { - return static_cast( - ::starboard::shared::starboard::Application::Get()); - } - - SbWindow CreateWindowForWin32(const SbWindowOptions* options); - - bool DestroyWindow(SbWindow window); - - void DispatchStart(int64_t timestamp) { - shared::starboard::Application::DispatchStart(timestamp); - } - - SbWindow GetCoreWindow() { - return SbWindowIsValid(window_.get()) ? window_.get() : kSbWindowInvalid; - } - - bool OnSbSystemRaisePlatformError(SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data); - - std::string GetLocalizedString(const char* id, const char* fallback) const { - return localized_strings_.GetString(id, fallback); - } - - // Returns true if it is valid to poll/query for system events. - bool MayHaveSystemEvents() override { return true; } - - // Waits for an event until the timeout |time| runs out (in microseconds). If - // an event occurs in this time, it is returned, otherwise NULL is returned. - // If |time| is zero or negative, then this should function effectively like a - // no-wait poll. - Event* WaitForSystemEventWithTimeout(int64_t time) override; - - // Wakes up any thread waiting within a call to - // WaitForSystemEventWithTimeout(). - void WakeSystemEventWait() override { - ScopedLock lock(stop_waiting_for_system_events_mutex_); - stop_waiting_for_system_events_ = true; - } - - LRESULT WindowProcess(HWND hWnd, UINT msg, WPARAM w_param, LPARAM l_param); - VOID TimedEventCallback(PVOID lp, BOOLEAN timer_or_wait_fired); - - // Non-virtual override. Calls into super class Run(). - int Run(int argc, char** argv); - - private: - // --- Application overrides --- - bool IsStartImmediate() override { return true; } - void Initialize() override {} - void Teardown() override {} - - void ProcessNextSystemMessage(); - int64_t GetNextTimedEventTargetTime() override { - return CurrentMonotonicTime(); - } - - // Processes window key events, returning a corresponding Event instance. - // This transfers ownership of the returned Event. - Event* ProcessWinKeyEvent(SbWindow window, - UINT msg, - WPARAM w_param, - LPARAM l_param); - - // Processes window mouse events, returning a corresponding Event instance. - // This transfers ownership of the returned Event. The Event may be nullptr. - Event* ProcessWinMouseEvent(SbWindow window, - UINT msg, - WPARAM w_param, - LPARAM l_param); - - Event* pending_event_ = nullptr; - - // The single open window, if any. - std::unique_ptr window_; - - starboard::LocalizedStrings localized_strings_; - - Mutex stop_waiting_for_system_events_mutex_; - bool stop_waiting_for_system_events_; - - // The current depressed SbKeyModifiers - if there are any. - unsigned int current_key_modifiers_ = 0; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_APPLICATION_WIN32_H_ diff --git a/starboard/shared/win32/application_win32_key_event.cc b/starboard/shared/win32/application_win32_key_event.cc deleted file mode 100644 index 600a2e3bcbb9..000000000000 --- a/starboard/shared/win32/application_win32_key_event.cc +++ /dev/null @@ -1,390 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/application_win32.h" - -#include - -#include "starboard/event.h" -#include "starboard/input.h" -#include "starboard/key.h" -#include "starboard/shared/starboard/application.h" - -using starboard::shared::starboard::Application; - -namespace { - -const int kSbKeyboardDeviceId = 1; - -SbKey VirtualKeyCodeToSbKey(WPARAM virtual_key_code) { - // Keyboard code reference: - // https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx - switch (virtual_key_code) { - case VK_CANCEL: - return kSbKeyCancel; - case VK_BACK: - return kSbKeyBack; - case VK_TAB: - return kSbKeyTab; - case VK_CLEAR: - return kSbKeyClear; - case VK_RETURN: - return kSbKeyReturn; - case VK_SHIFT: - return kSbKeyShift; - case VK_CONTROL: - return kSbKeyControl; - case VK_MENU: - return kSbKeyMenu; - case VK_PAUSE: - return kSbKeyPause; - case VK_CAPITAL: - return kSbKeyCapital; - // Hangul and Kana have the same VirtualKey constant - case VK_KANA: - return kSbKeyKana; - case VK_JUNJA: - return kSbKeyJunja; - case VK_FINAL: - return kSbKeyFinal; - // Hanja and Kanji have the same VirtualKey constant - case VK_HANJA: - return kSbKeyHanja; - case VK_ESCAPE: - return kSbKeyEscape; - case VK_CONVERT: - return kSbKeyConvert; - case VK_NONCONVERT: - return kSbKeyNonconvert; - case VK_ACCEPT: - return kSbKeyAccept; - case VK_MODECHANGE: - return kSbKeyModechange; - case VK_SPACE: - return kSbKeySpace; - case VK_PRIOR: - return kSbKeyPrior; - case VK_NEXT: - return kSbKeyNext; - case VK_END: - return kSbKeyEnd; - case VK_HOME: - return kSbKeyHome; - case VK_LEFT: - return kSbKeyLeft; - case VK_UP: - return kSbKeyUp; - case VK_RIGHT: - return kSbKeyRight; - case VK_DOWN: - return kSbKeyDown; - case VK_SELECT: - return kSbKeySelect; - case VK_PRINT: - return kSbKeyPrint; - case VK_EXECUTE: - return kSbKeyExecute; - case VK_SNAPSHOT: - return kSbKeySnapshot; - case VK_INSERT: - return kSbKeyInsert; - case VK_DELETE: - return kSbKeyDelete; - case VK_OEM_PERIOD: - return kSbKeyOemPeriod; - case 0x30: - return kSbKey0; - case 0x31: - return kSbKey1; - case 0x32: - return kSbKey2; - case 0x33: - return kSbKey3; - case 0x34: - return kSbKey4; - case 0x35: - return kSbKey5; - case 0x36: - return kSbKey6; - case 0x37: - return kSbKey7; - case 0x38: - return kSbKey8; - case 0x39: - return kSbKey9; - case 0x41: - return kSbKeyA; - case 0x42: - return kSbKeyB; - case 0x43: - return kSbKeyC; - case 0x44: - return kSbKeyD; - case 0x45: - return kSbKeyE; - case 0x46: - return kSbKeyF; - case 0x47: - return kSbKeyG; - case 0x48: - return kSbKeyH; - case 0x49: - return kSbKeyI; - case 0x4A: - return kSbKeyJ; - case 0x4B: - return kSbKeyK; - case 0x4C: - return kSbKeyL; - case 0x4D: - return kSbKeyM; - case 0x4E: - return kSbKeyN; - case 0x4F: - return kSbKeyO; - case 0x50: - return kSbKeyP; - case 0x51: - return kSbKeyQ; - case 0x52: - return kSbKeyR; - case 0x53: - return kSbKeyS; - case 0x54: - return kSbKeyT; - case 0x55: - return kSbKeyU; - case 0x56: - return kSbKeyV; - case 0x57: - return kSbKeyW; - case 0x58: - return kSbKeyX; - case 0x59: - return kSbKeyY; - case 0x5A: - return kSbKeyZ; - case VK_LWIN: - return kSbKeyLwin; - case VK_RWIN: - return kSbKeyRwin; - case VK_APPS: - return kSbKeyApps; - case VK_SLEEP: - return kSbKeySleep; - case VK_NUMPAD0: - return kSbKeyNumpad0; - case VK_NUMPAD1: - return kSbKeyNumpad1; - case VK_NUMPAD2: - return kSbKeyNumpad2; - case VK_NUMPAD3: - return kSbKeyNumpad3; - case VK_NUMPAD4: - return kSbKeyNumpad4; - case VK_NUMPAD5: - return kSbKeyNumpad5; - case VK_NUMPAD6: - return kSbKeyNumpad6; - case VK_NUMPAD7: - return kSbKeyNumpad7; - case VK_NUMPAD8: - return kSbKeyNumpad8; - case VK_NUMPAD9: - return kSbKeyNumpad9; - case VK_MULTIPLY: - return kSbKeyMultiply; - case VK_ADD: - return kSbKeyAdd; - case VK_SEPARATOR: - return kSbKeySeparator; - case VK_SUBTRACT: - return kSbKeySubtract; - case VK_DECIMAL: - return kSbKeyDecimal; - case VK_DIVIDE: - return kSbKeyDivide; - case VK_F1: - return kSbKeyF1; - case VK_F2: - return kSbKeyF2; - case VK_F3: - return kSbKeyF3; - case VK_F4: - return kSbKeyF4; - case VK_F5: - return kSbKeyF5; - case VK_F6: - return kSbKeyF6; - case VK_F7: - return kSbKeyF7; - case VK_F8: - return kSbKeyF8; - case VK_F9: - return kSbKeyF9; - case VK_F10: - return kSbKeyF10; - case VK_F11: - return kSbKeyF11; - case VK_F12: - return kSbKeyF12; - case VK_F13: - return kSbKeyF13; - case VK_F14: - return kSbKeyF14; - case VK_F15: - return kSbKeyF15; - case VK_F16: - return kSbKeyF16; - case VK_F17: - return kSbKeyF17; - case VK_F18: - return kSbKeyF18; - case VK_F19: - return kSbKeyF19; - case VK_F20: - return kSbKeyF20; - case VK_F21: - return kSbKeyF21; - case VK_F22: - return kSbKeyF22; - case VK_F23: - return kSbKeyF23; - case VK_F24: - return kSbKeyF24; - case VK_NUMLOCK: - return kSbKeyNumlock; - case VK_SCROLL: - return kSbKeyScroll; - case VK_LSHIFT: - return kSbKeyLshift; - case VK_RSHIFT: - return kSbKeyRshift; - case VK_LCONTROL: - return kSbKeyLcontrol; - case VK_RCONTROL: - return kSbKeyRcontrol; - case VK_LMENU: - return kSbKeyLmenu; - case VK_RMENU: - return kSbKeyRmenu; - case VK_BROWSER_BACK: - return kSbKeyBrowserBack; - case VK_BROWSER_FORWARD: - return kSbKeyBrowserForward; - case VK_BROWSER_REFRESH: - return kSbKeyBrowserRefresh; - case VK_BROWSER_STOP: - return kSbKeyBrowserStop; - case VK_BROWSER_SEARCH: - return kSbKeyBrowserSearch; - case VK_BROWSER_FAVORITES: - return kSbKeyBrowserFavorites; - case VK_BROWSER_HOME: - return kSbKeyBrowserHome; - case VK_LBUTTON: - return kSbKeyMouse1; - case VK_RBUTTON: - return kSbKeyMouse2; - case VK_MBUTTON: - return kSbKeyMouse3; - case VK_XBUTTON1: - return kSbKeyMouse4; - case VK_XBUTTON2: - return kSbKeyMouse5; - case VK_VOLUME_MUTE: - return kSbKeyVolumeMute; - case VK_VOLUME_DOWN: - return kSbKeyVolumeDown; - case VK_VOLUME_UP: - return kSbKeyVolumeUp; - default: - SB_LOG(WARNING) << "Unrecognized key hit."; - return kSbKeyUnknown; - } -} - -} // namespace - -namespace starboard { -namespace shared { -namespace win32 { - -// TODO: Plug into XInput APIs for Xbox controller input? -Application::Event* ApplicationWin32::ProcessWinKeyEvent(SbWindow window, - UINT msg, - WPARAM w_param, - LPARAM l_param) { - SbInputData* data = new SbInputData(); - memset(data, 0, sizeof(*data)); - - data->window = window; - data->device_type = kSbInputDeviceTypeKeyboard; - // TODO: Do some more intelligent handling logic here to determine - // a unique device ID. - data->device_id = kSbKeyboardDeviceId; - data->key = VirtualKeyCodeToSbKey(w_param); - - const bool was_down = ((l_param & (1 << 30)) != 0); - const bool up = msg != WM_KEYDOWN && msg != WM_SYSKEYDOWN; - - data->type = up ? kSbInputEventTypeUnpress : kSbInputEventTypePress; - - SbKeyModifiers current_modifier = kSbKeyModifiersNone; - if (data->key == kSbKeyShift || data->key == kSbKeyRshift || - data->key == kSbKeyLshift) { - current_modifier = kSbKeyModifiersShift; - } else if (data->key == kSbKeyMenu || data->key == kSbKeyRmenu || - data->key == kSbKeyLmenu) { - current_modifier = kSbKeyModifiersAlt; - } else if (data->key == kSbKeyControl || data->key == kSbKeyRcontrol || - data->key == kSbKeyLcontrol) { - current_modifier = kSbKeyModifiersCtrl; - } else if (data->key == kSbKeyRwin || data->key == kSbKeyLwin) { - current_modifier = kSbKeyModifiersMeta; - } - - // Either add or remove the current modifier key being pressed or released. - // This noops for kSbKeyModifiersNone. - if (up) { - current_key_modifiers_ &= ~current_modifier; - } else { - current_key_modifiers_ |= current_modifier; - } - data->key_modifiers = current_key_modifiers_; - - switch (data->key) { - case kSbKeyLshift: - case kSbKeyLmenu: - case kSbKeyLcontrol: - case kSbKeyLwin: - data->key_location = kSbKeyLocationLeft; - break; - case kSbKeyRshift: - case kSbKeyRmenu: - case kSbKeyRcontrol: - case kSbKeyRwin: - data->key_location = kSbKeyLocationRight; - break; - default: - break; - } - - return new Application::Event(kSbEventTypeInput, data, - &Application::DeleteDestructor); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/atomic_public.h b/starboard/shared/win32/atomic_public.h deleted file mode 100644 index 1b9d4295221b..000000000000 --- a/starboard/shared/win32/atomic_public.h +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_ATOMIC_PUBLIC_H_ -#define STARBOARD_SHARED_WIN32_ATOMIC_PUBLIC_H_ - -#include "starboard/atomic.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Declarations for Windows Intrinsic Functions -// Defined here to avoid including Windows headers -// See https://msdn.microsoft.com/en-us/library/w5405h95.aspx - -long _InterlockedCompareExchange( // NOLINT(runtime/int) - long volatile* Destination, // NOLINT(runtime/int) - long Exchange, // NOLINT(runtime/int) - long Comparand); // NOLINT(runtime/int) -#pragma intrinsic(_InterlockedCompareExchange) - -__int64 _InterlockedCompareExchange64(__int64 volatile* Destination, - __int64 Exchange, - __int64 Comparand); -#pragma intrinsic(_InterlockedCompareExchange64) - -char _InterlockedCompareExchange8(char volatile* Destination, - char Exchange, - char Comparand); -#pragma intrinsic(_InterlockedCompareExchange8) - -long _InterlockedExchange(long volatile* Target, // NOLINT(runtime/int) - long Value); // NOLINT(runtime/int) -#pragma intrinsic(_InterlockedExchange) - -__int64 _InterlockedExchange64(__int64 volatile* Target, __int64 Value); -#pragma intrinsic(_InterlockedExchange64) - -long _InterlockedExchangeAdd(long volatile* Addend, // NOLINT(runtime/int) - long Value); // NOLINT(runtime/int) -#pragma intrinsic(_InterlockedExchangeAdd) - -__int64 _InterlockedExchangeAdd64(__int64 volatile* Addend, __int64 Value); -#pragma intrinsic(_InterlockedExchangeAdd64) - -void _ReadWriteBarrier(void); -#pragma intrinsic(_ReadWriteBarrier) - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicNoBarrier_CompareAndSwap(volatile SbAtomic32* ptr, - SbAtomic32 old_value, - SbAtomic32 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange( - (volatile long*)ptr, // NOLINT(runtime/int) - (long)new_value, // NOLINT(runtime/int) - (long)old_value); // NOLINT(runtime/int) -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicNoBarrier_Exchange(volatile SbAtomic32* ptr, SbAtomic32 new_value) { - // Note this does a full memory barrier - return _InterlockedExchange((volatile long*)ptr, // NOLINT(runtime/int) - (long)new_value); // NOLINT(runtime/int) -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicNoBarrier_Increment(volatile SbAtomic32* ptr, SbAtomic32 increment) { - return SbAtomicBarrier_Increment(ptr, increment); -} - -SB_C_FORCE_INLINE SbAtomic32 SbAtomicBarrier_Increment(volatile SbAtomic32* ptr, - SbAtomic32 increment) { - // Note InterlockedExchangeAdd does a full memory barrier - return increment + - _InterlockedExchangeAdd((volatile long*)ptr, // NOLINT(runtime/int) - (long)increment); // NOLINT(runtime/int) -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicAcquire_CompareAndSwap(volatile SbAtomic32* ptr, - SbAtomic32 old_value, - SbAtomic32 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange( - (volatile long*)ptr, // NOLINT(runtime/int) - (long)new_value, // NOLINT(runtime/int) - (long)old_value); // NOLINT(runtime/int) -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicRelease_CompareAndSwap(volatile SbAtomic32* ptr, - SbAtomic32 old_value, - SbAtomic32 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange( - (volatile long*)ptr, // NOLINT(runtime/int) - (long)new_value, // NOLINT(runtime/int) - (long)old_value); // NOLINT(runtime/int) -} - -// NOTE: https://msdn.microsoft.com/en-us/library/f20w0x5e.aspx -// states _ReadWriteBarrier() is deprecated and -// recommends "atomic_thread_fence", which is C++11 and violates -// Starboard's "C-only header" policy -SB_C_FORCE_INLINE void SbAtomicMemoryBarrier() { - _ReadWriteBarrier(); -} - -SB_C_FORCE_INLINE void SbAtomicNoBarrier_Store(volatile SbAtomic32* ptr, - SbAtomic32 value) { - *ptr = value; -} - -SB_C_FORCE_INLINE void SbAtomicAcquire_Store(volatile SbAtomic32* ptr, - SbAtomic32 value) { - *ptr = value; - SbAtomicMemoryBarrier(); -} - -SB_C_FORCE_INLINE void SbAtomicRelease_Store(volatile SbAtomic32* ptr, - SbAtomic32 value) { - SbAtomicMemoryBarrier(); - *ptr = value; -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicNoBarrier_Load(volatile const SbAtomic32* ptr) { - return *ptr; -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicAcquire_Load(volatile const SbAtomic32* ptr) { - SbAtomic32 value = *ptr; - SbAtomicMemoryBarrier(); - return value; -} - -SB_C_FORCE_INLINE SbAtomic32 -SbAtomicRelease_Load(volatile const SbAtomic32* ptr) { - SbAtomicMemoryBarrier(); - return *ptr; -} - -SB_C_FORCE_INLINE SbAtomic8 -SbAtomicRelease_CompareAndSwap8(volatile SbAtomic8* ptr, - SbAtomic8 old_value, - SbAtomic8 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange8((volatile char*)ptr, new_value, - old_value); -} - -SB_C_FORCE_INLINE void SbAtomicNoBarrier_Store8(volatile SbAtomic8* ptr, - SbAtomic8 value) { - *ptr = value; -} - -SB_C_FORCE_INLINE SbAtomic8 -SbAtomicNoBarrier_Load8(volatile const SbAtomic8* ptr) { - return *ptr; -} - -// 64-bit atomic operations (only available on 64-bit processors). -#if SB_HAS(64_BIT_ATOMICS) -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicNoBarrier_CompareAndSwap64(volatile SbAtomic64* ptr, - SbAtomic64 old_value, - SbAtomic64 new_value) { - return _InterlockedCompareExchange64(ptr, new_value, old_value); -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicNoBarrier_Exchange64(volatile SbAtomic64* ptr, SbAtomic64 new_value) { - return _InterlockedExchange64(ptr, new_value); -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicNoBarrier_Increment64(volatile SbAtomic64* ptr, SbAtomic64 increment) { - return increment + _InterlockedExchangeAdd64(ptr, increment); -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicBarrier_Increment64(volatile SbAtomic64* ptr, SbAtomic64 increment) { - // Note this does a full memory barrier - return increment + _InterlockedExchangeAdd64(ptr, increment); -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicAcquire_CompareAndSwap64(volatile SbAtomic64* ptr, - SbAtomic64 old_value, - SbAtomic64 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange64(ptr, new_value, old_value); -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicRelease_CompareAndSwap64(volatile SbAtomic64* ptr, - SbAtomic64 old_value, - SbAtomic64 new_value) { - // Note this does a full memory barrier - return _InterlockedCompareExchange64(ptr, new_value, old_value); -} - -SB_C_FORCE_INLINE void SbAtomicNoBarrier_Store64(volatile SbAtomic64* ptr, - SbAtomic64 value) { - *ptr = value; -} - -SB_C_FORCE_INLINE void SbAtomicAcquire_Store64(volatile SbAtomic64* ptr, - SbAtomic64 value) { - *ptr = value; - SbAtomicMemoryBarrier(); -} - -SB_C_FORCE_INLINE void SbAtomicRelease_Store64(volatile SbAtomic64* ptr, - SbAtomic64 value) { - SbAtomicMemoryBarrier(); - *ptr = value; -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicNoBarrier_Load64(volatile const SbAtomic64* ptr) { - return *ptr; -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicAcquire_Load64(volatile const SbAtomic64* ptr) { - SbAtomic64 value = *ptr; - SbAtomicMemoryBarrier(); - return value; -} - -SB_C_FORCE_INLINE SbAtomic64 -SbAtomicRelease_Load64(volatile const SbAtomic64* ptr) { - SbAtomicMemoryBarrier(); - return *ptr; -} -#endif // SB_HAS(64_BIT_ATOMICS) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // STARBOARD_SHARED_WIN32_ATOMIC_PUBLIC_H_ diff --git a/starboard/shared/win32/atomic_queue.h b/starboard/shared/win32/atomic_queue.h deleted file mode 100644 index cd224871afab..000000000000 --- a/starboard/shared/win32/atomic_queue.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_ATOMIC_QUEUE_H_ -#define STARBOARD_SHARED_WIN32_ATOMIC_QUEUE_H_ - -#include - -#include "starboard/common/mutex.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// A simple thread-safe producer / consumer queue. Elements are added via -// PopBack() and removed via PopFront(). -template -class AtomicQueue { - public: - size_t PushBack(Data data_ptr) { - ScopedLock lock(mutex_); - data_queue_.push_back(data_ptr); - return data_queue_.size(); - } - - Data PopFront() { - ScopedLock lock(mutex_); - if (data_queue_.empty()) { - Data empty = Data(); - return empty; - } - Data data_ptr = data_queue_.front(); - data_queue_.pop_front(); - return data_ptr; - } - - bool IsEmpty() const { - ScopedLock lock(mutex_); - return data_queue_.empty(); - } - - size_t Size() const { - ScopedLock lock(mutex_); - return data_queue_.size(); - } - - void Clear() { - ScopedLock lock(mutex_); - std::deque empty; - data_queue_.swap(empty); - } - - private: - using Mutex = ::starboard::Mutex; - using ScopedLock = ::starboard::ScopedLock; - std::deque data_queue_; - ::starboard::Mutex mutex_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_ATOMIC_QUEUE_H_ diff --git a/starboard/shared/win32/audio_decoder.cc b/starboard/shared/win32/audio_decoder.cc deleted file mode 100644 index 94453c561933..000000000000 --- a/starboard/shared/win32/audio_decoder.cc +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/audio_decoder.h" - -#include "starboard/atomic.h" -#include "starboard/audio_sink.h" -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/media_common.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class AudioDecoder::CallbackScheduler : private JobOwner { - public: - CallbackScheduler() : callback_signaled_(false) {} - - void SetCallbackOnce(ConsumedCB cb) { - SB_DCHECK(cb); - ::starboard::ScopedLock lock(mutex_); - if (!cb_) { - cb_ = cb; - } - } - - void ScheduleCallbackIfNecessary() { - ::starboard::ScopedLock lock(mutex_); - if (!cb_ || callback_signaled_) { - return; - } - callback_signaled_ = true; - JobOwner::Schedule(cb_); - } - - void OnCallbackSignaled() { - ::starboard::ScopedLock lock(mutex_); - callback_signaled_ = false; - } - - ConsumedCB cb_; - ::starboard::Mutex mutex_; - bool callback_signaled_; -}; - -AudioDecoder::AudioDecoder(const AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system) - : audio_stream_info_(audio_stream_info), - drm_system_(drm_system), - sample_type_((audio_stream_info.codec == kSbMediaAudioCodecAc3 || - audio_stream_info.codec == kSbMediaAudioCodecEac3) - ? kSbMediaAudioSampleTypeInt16Deprecated - : kSbMediaAudioSampleTypeFloat32), - stream_ended_(false) { - SB_DCHECK(audio_stream_info.codec == kSbMediaAudioCodecAac || - audio_stream_info.codec == kSbMediaAudioCodecAc3 || - audio_stream_info.codec == kSbMediaAudioCodecEac3); -} - -AudioDecoder::~AudioDecoder() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - decoder_thread_.reset(nullptr); - decoder_impl_.reset(nullptr); - callback_scheduler_.reset(nullptr); -} - -void AudioDecoder::Initialize(const OutputCB& output_cb, - const ErrorCB& error_cb) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - SB_DCHECK(output_cb); - SB_DCHECK(!output_cb_); - output_cb_ = output_cb; - decoder_impl_ = AbstractWin32AudioDecoder::Create( - kSbMediaAudioFrameStorageTypeInterleaved, sample_type_, - audio_stream_info_, drm_system_); - decoder_thread_.reset(new AudioDecoderThread(decoder_impl_.get(), this)); - callback_scheduler_.reset(new CallbackScheduler()); -} - -void AudioDecoder::Decode(const InputBuffers& input_buffers, - const ConsumedCB& consumed_cb) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(input_buffers.size() == 1); - SB_DCHECK(input_buffers[0]); - - callback_scheduler_->SetCallbackOnce(consumed_cb); - callback_scheduler_->OnCallbackSignaled(); - const bool can_take_more_data = decoder_thread_->QueueInput(input_buffers[0]); - if (can_take_more_data) { - callback_scheduler_->ScheduleCallbackIfNecessary(); - } - - if (stream_ended_) { - SB_LOG(ERROR) << "Decode() is called after WriteEndOfStream() is called."; - return; - } -} - -void AudioDecoder::WriteEndOfStream() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - ::starboard::ScopedLock lock(mutex_); - stream_ended_ = true; - decoder_thread_->QueueEndOfStream(); -} - -scoped_refptr AudioDecoder::Read( - int* samples_per_second) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - DecodedAudioPtr data = decoded_data_.PopFront(); - SB_DCHECK(data); - *samples_per_second = decoder_impl_->GetSamplesPerSecond(); - return data; -} - -void AudioDecoder::Reset() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - decoder_thread_.reset(nullptr); - decoder_impl_->Reset(); - - decoded_data_.Clear(); - stream_ended_ = false; - callback_scheduler_.reset(new CallbackScheduler()); - CancelPendingJobs(); - - decoder_thread_.reset(new AudioDecoderThread(decoder_impl_.get(), this)); -} - -void AudioDecoder::OnAudioDecoded(DecodedAudioPtr data) { - decoded_data_.PushBack(data); - if (output_cb_) { - Schedule(output_cb_); - } - callback_scheduler_->ScheduleCallbackIfNecessary(); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/audio_decoder.h b/starboard/shared/win32/audio_decoder.h deleted file mode 100644 index a52fec5ca6eb..000000000000 --- a/starboard/shared/win32/audio_decoder.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_AUDIO_DECODER_H_ -#define STARBOARD_SHARED_WIN32_AUDIO_DECODER_H_ - -#include - -#include "starboard/common/ref_counted.h" -#include "starboard/configuration.h" -#include "starboard/drm.h" -#include "starboard/media.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/decoded_audio_internal.h" -#include "starboard/shared/starboard/player/filter/audio_decoder_internal.h" -#include "starboard/shared/starboard/player/job_queue.h" -#include "starboard/shared/starboard/thread_checker.h" -#include "starboard/shared/win32/atomic_queue.h" -#include "starboard/shared/win32/audio_decoder_thread.h" -#include "starboard/shared/win32/media_common.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class AudioDecoder - : public ::starboard::shared::starboard::player::filter::AudioDecoder, - private ::starboard::shared::starboard::player::JobQueue::JobOwner, - private AudioDecodedCallback { - public: - typedef starboard::media::AudioStreamInfo AudioStreamInfo; - - AudioDecoder(const AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system); - ~AudioDecoder() override; - - void Initialize(const OutputCB& output_cb, const ErrorCB& error_cb) override; - void Decode(const InputBuffers& input_buffers, - const ConsumedCB& consumed_cb) override; - void WriteEndOfStream() override; - scoped_refptr Read(int* samples_per_second) override; - void Reset() override; - void OnAudioDecoded(DecodedAudioPtr data) override; - - private: - class CallbackScheduler; - - ::starboard::shared::starboard::ThreadChecker thread_checker_; - - const AudioStreamInfo audio_stream_info_; - SbDrmSystem const drm_system_; - const SbMediaAudioSampleType sample_type_; - bool stream_ended_; - - AtomicQueue decoded_data_; - std::unique_ptr callback_scheduler_; - std::unique_ptr decoder_impl_; - std::unique_ptr decoder_thread_; - OutputCB output_cb_; - - Mutex mutex_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_AUDIO_DECODER_H_ diff --git a/starboard/shared/win32/audio_decoder_thread.cc b/starboard/shared/win32/audio_decoder_thread.cc deleted file mode 100644 index 15e77d620bd0..000000000000 --- a/starboard/shared/win32/audio_decoder_thread.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/audio_decoder_thread.h" - -#include -#include - -namespace starboard { -namespace shared { -namespace win32 { -namespace { - -// Size of the queue for audio units. -const size_t kMaxProcessingElements = 64; - -size_t WriteAsMuchAsPossible( - std::deque >* data_queue, - AbstractWin32AudioDecoder* audio_decoder) { - const size_t original_size = data_queue->size(); - while (!data_queue->empty()) { - scoped_refptr buff = data_queue->front(); - data_queue->pop_front(); - - if (buff) { - if (!audio_decoder->TryWrite(buff)) { - data_queue->push_front(buff); - break; - } - } else { - audio_decoder->WriteEndOfStream(); - } - } - return original_size - data_queue->size(); -} - -std::vector ReadAllDecodedAudioSamples( - AbstractWin32AudioDecoder* audio_decoder) { - std::vector decoded_audio_out; - while (DecodedAudioPtr decoded_datum = audio_decoder->ProcessAndRead()) { - decoded_audio_out.push_back(decoded_datum); - } - return decoded_audio_out; -} - -} // namespace. - -AudioDecoderThread::AudioDecoderThread(AbstractWin32AudioDecoder* decoder_impl, - AudioDecodedCallback* callback) - : Thread("AudioDecoderThd"), - win32_audio_decoder_(decoder_impl), - callback_(callback) { - Start(); -} - -AudioDecoderThread::~AudioDecoderThread() { - Join(); -} - -bool AudioDecoderThread::QueueInput(const scoped_refptr& buffer) { - { - ::starboard::ScopedLock lock(input_buffer_queue_mutex_); - input_buffer_queue_.push_back(buffer); - } - - // increment() returns the previous value. - size_t element_count = processing_elements_++ + 1; - semaphore_.Put(); - return element_count < kMaxProcessingElements; -} - -void AudioDecoderThread::QueueEndOfStream() { - scoped_refptr empty; - QueueInput(empty); -} - -void AudioDecoderThread::Run() { - std::deque > local_queue; - - while (!join_called()) { - if (local_queue.empty()) { - TransferPendingInputTo(&local_queue); - } - bool work_done = false; - size_t number_written = - WriteAsMuchAsPossible(&local_queue, win32_audio_decoder_); - if (number_written > 0) { - processing_elements_.fetch_sub(static_cast(number_written)); - work_done = true; - } - - std::vector decoded_audio = - ReadAllDecodedAudioSamples(win32_audio_decoder_); - - if (!decoded_audio.empty()) { - work_done = true; - for (auto it = decoded_audio.begin(); it != decoded_audio.end(); ++it) { - callback_->OnAudioDecoded(*it); - } - } - - if (!work_done) { - semaphore_.TakeWait(1000); - } - } -} - -void AudioDecoderThread::TransferPendingInputTo( - std::deque >* destination) { - ::starboard::ScopedLock lock(input_buffer_queue_mutex_); - while (!input_buffer_queue_.empty()) { - destination->push_back(input_buffer_queue_.front()); - input_buffer_queue_.pop_front(); - } -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/audio_decoder_thread.h b/starboard/shared/win32/audio_decoder_thread.h deleted file mode 100644 index 3ede570fb25e..000000000000 --- a/starboard/shared/win32/audio_decoder_thread.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_AUDIO_DECODER_THREAD_H_ -#define STARBOARD_SHARED_WIN32_AUDIO_DECODER_THREAD_H_ - -#include -#include -#include - -#include "starboard/common/ref_counted.h" -#include "starboard/common/semaphore.h" -#include "starboard/common/thread.h" -#include "starboard/media.h" -#include "starboard/shared/starboard/player/decoded_audio_internal.h" -#include "starboard/shared/starboard/player/filter/audio_decoder_internal.h" -#include "starboard/shared/win32/media_common.h" -#include "starboard/shared/win32/win32_audio_decoder.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class AudioDecodedCallback { - public: - virtual ~AudioDecodedCallback() {} - virtual void OnAudioDecoded(DecodedAudioPtr data) = 0; -}; - -// This decoder thread simplifies decoding media. Data is pushed in via -// QueueInput() and QueueEndOfStream() and output data is pushed via -// the AudioDecodedCallback. -class AudioDecoderThread : private Thread { - public: - AudioDecoderThread(AbstractWin32AudioDecoder* decoder_impl, - AudioDecodedCallback* callback); - ~AudioDecoderThread() override; - - // Returns true if more input can be pushed to this thread. - bool QueueInput(const scoped_refptr& buffer); - void QueueEndOfStream(); - - private: - void Run() override; - void TransferPendingInputTo( - std::deque >* destination); - AbstractWin32AudioDecoder* win32_audio_decoder_; - AudioDecodedCallback* callback_; - - std::deque > input_buffer_queue_; - ::starboard::Mutex input_buffer_queue_mutex_; - std::atomic processing_elements_{0}; - Semaphore semaphore_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_AUDIO_DECODER_THREAD_H_ diff --git a/starboard/shared/win32/audio_sink.cc b/starboard/shared/win32/audio_sink.cc deleted file mode 100644 index e3b7909ef4f3..000000000000 --- a/starboard/shared/win32/audio_sink.cc +++ /dev/null @@ -1,613 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include - -#include -#include -#include - -#include "starboard/atomic.h" -#include "starboard/common/condition_variable.h" -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/time.h" -#include "starboard/configuration.h" -#include "starboard/shared/starboard/audio_sink/audio_sink_internal.h" -#include "starboard/shared/starboard/player/job_thread.h" -#include "starboard/shared/starboard/thread_checker.h" -#include "starboard/thread.h" - -namespace starboard { -namespace shared { -namespace win32 { -namespace { - -using Microsoft::WRL::ComPtr; - -const int kMaxBuffersSubmittedPerLoop = 2; - -// Fails an SB_DCHECK if an HRESULT is not S_OK -void CHECK_HRESULT_OK(HRESULT hr) { - SB_DCHECK(SUCCEEDED(hr)) << std::hex << hr; -} - -WORD SampleTypeToFormatTag(SbMediaAudioSampleType type) { - switch (type) { - case kSbMediaAudioSampleTypeInt16Deprecated: - return WAVE_FORMAT_PCM; - case kSbMediaAudioSampleTypeFloat32: - return WAVE_FORMAT_IEEE_FLOAT; - default: - SB_NOTREACHED(); - return 0; - } -} - -WORD SampleTypeToBitsPerSample(SbMediaAudioSampleType type) { - switch (type) { - case kSbMediaAudioSampleTypeInt16Deprecated: - return 16; - case kSbMediaAudioSampleTypeFloat32: - return 32; - default: - SB_NOTREACHED(); - return 0; - } -} - -class XAudioAudioSinkType; - -class XAudioAudioSink : public SbAudioSinkPrivate { - public: - XAudioAudioSink(XAudioAudioSinkType* type, - IXAudio2SourceVoice* source_voice, - const WAVEFORMATEX& wfx, - SbAudioSinkFrameBuffers frame_buffers, - int frame_buffers_size_in_frames, - SbAudioSinkUpdateSourceStatusFunc update_source_status_func, - ConsumeFramesFunc consume_frames_func, - void* context); - ~XAudioAudioSink() override{}; - - void SetSourceVoice(IXAudio2SourceVoice* source_voice) { - source_voice_ = source_voice; - samples_played_ = 0; - submitted_frames_ = 0; - if (source_voice_) { - CHECK_HRESULT_OK(source_voice_->Start(0)); - SbAtomicRelease_Store(&stop_callbacks_, 0); - } - } - - bool IsType(Type* type) override; - void SetPlaybackRate(double playback_rate) override { - SB_DCHECK(playback_rate >= 0.0); - if (playback_rate != 0.0 && playback_rate != 1.0) { - SB_NOTIMPLEMENTED() << "TODO: Only playback rates of 0.0 and 1.0 are " - "currently supported."; - playback_rate = (playback_rate > 0.0) ? 1.0 : 0.0; - } - ScopedLock lock(mutex_); - playback_rate_ = playback_rate; - } - void SetVolume(double volume) override { - ScopedLock lock(mutex_); - volume_ = volume; - } - void Process(); - - void StopCallbacks() { - SbAtomicBarrier_Increment(&stop_callbacks_, 1); - // Make sure that any call to Process() returns so we know that - // no future callbacks will be invoked. - process_mutex_.Acquire(); - process_mutex_.Release(); - - // This must happen on a non-XAudio callback thread. - if (source_voice_) { - source_voice_->DestroyVoice(); - } - } - const WAVEFORMATEX& GetWaveFormatEx() const { return wfx_; } - - private: - bool AreCallbacksStopped() const { - return SbAtomicAcquire_Load(&stop_callbacks_) != 0; - } - void SubmitSourceBuffer(int offset_in_frames, int count_frames); - - // If true, this instance's source_voice_ has been destroyed and - // future Process() calls should return immediately. - SbAtomic32 stop_callbacks_; - - XAudioAudioSinkType* const type_; - const SbAudioSinkUpdateSourceStatusFunc update_source_status_func_; - const ConsumeFramesFunc consume_frames_func_; - void* const context_; - - SbAudioSinkFrameBuffers frame_buffers_; - const int frame_buffers_size_in_frames_; - const WAVEFORMATEX wfx_; - - // Note: despite some documentation to the contrary, it appears - // that IXAudio2SourceVoice cannot be a ComPtr. - IXAudio2SourceVoice* source_voice_; - - // |process_mutex_| is held during Process. Others may rapidly - // acquire/release to ensure they wait until the current Process() ends. - Mutex process_mutex_; - // |mutex_| protects |playback_rate_| and |volume_|. - Mutex mutex_; - double playback_rate_; - double volume_; - // The following variables are only used inside Process(). To keep it in the - // class simply to allow them to be kept between Process() calls. - int submitted_frames_; - int samples_played_; - int queued_buffers_; - bool was_playing_; - double current_volume_; -}; - -class XAudioAudioSinkType : public SbAudioSinkPrivate::Type, - private IXAudio2EngineCallback { - public: - XAudioAudioSinkType(); - - ComPtr XAudioCreate(); - - SbAudioSink Create( - int channels, - int sampling_frequency_hz, - SbMediaAudioSampleType audio_sample_type, - SbMediaAudioFrameStorageType audio_frame_storage_type, - SbAudioSinkFrameBuffers frame_buffers, - int frame_buffers_size_in_frames, - SbAudioSinkUpdateSourceStatusFunc update_source_status_func, - SbAudioSinkPrivate::ConsumeFramesFunc consume_frames_func, - SbAudioSinkPrivate::ErrorFunc error_func, - void* context); - - bool IsValid(SbAudioSink audio_sink) override { - return audio_sink != kSbAudioSinkInvalid && audio_sink->IsType(this); - } - - void Destroy(SbAudioSink audio_sink) override; - - private: - void RestartAudioDevice(); - void TryAcquireSinkVoices(); - // IXAudio2EngineCallback methods - // This function will be called periodically with an interval of ~10ms. - void OnProcessingPassStart() override; - void OnProcessingPassEnd() override {} - void OnCriticalError(HRESULT hr) { - SB_LOG(INFO) << "OnCriticalError() called with code " << hr; - - SB_DCHECK(thread_checker_.CalledOnValidThread()); - // The thread id of callbacks will be changed after OnCriticalError() call. - thread_checker_.Detach(); - - if (sink_shutdown_in_progress_) { - return; - } - sink_shutdown_in_progress_ = true; - - x_audio2_->UnregisterForCallbacks(this); - - for (XAudioAudioSink* sink : audio_sinks_on_xaudio_callbacks_) { - sink->StopCallbacks(); - } - - restart_audio_thread_.job_queue()->Schedule( - std::bind(&XAudioAudioSinkType::RestartAudioDevice, this)); - } - - void ProcessSinksToAdd() { - if (!audio_sinks_to_add_.empty()) { - audio_sinks_on_xaudio_callbacks_.insert( - audio_sinks_on_xaudio_callbacks_.end(), audio_sinks_to_add_.begin(), - audio_sinks_to_add_.end()); - audio_sinks_to_add_.clear(); - } - } - - void ProcessSinksToDelete() { - if (!audio_sinks_to_delete_.empty()) { - for (auto sink : audio_sinks_to_delete_) { - audio_sinks_on_xaudio_callbacks_.erase( - std::find(audio_sinks_on_xaudio_callbacks_.begin(), - audio_sinks_on_xaudio_callbacks_.end(), sink)); - delete sink; - } - audio_sinks_to_delete_.clear(); - } - } - - ComPtr x_audio2_; - Mutex x_audio2_mutex_; - IXAudio2MasteringVoice* mastering_voice_ = nullptr; - - // This mutex protects |audio_sinks_to_add_| and |audio_sinks_to_delete_|. - Mutex mutex_; - std::list audio_sinks_to_add_; - std::list audio_sinks_to_delete_; - - // This must only be accessed from the OnProcessingPassStart callback - std::list audio_sinks_on_xaudio_callbacks_; - starboard::ThreadChecker thread_checker_; - - starboard::player::JobThread restart_audio_thread_; - std::list audio_sinks_to_restart_; - bool sink_shutdown_in_progress_; -}; - -XAudioAudioSink::XAudioAudioSink( - XAudioAudioSinkType* type, - IXAudio2SourceVoice* source_voice, - const WAVEFORMATEX& wfx, - SbAudioSinkFrameBuffers frame_buffers, - int frame_buffers_size_in_frames, - SbAudioSinkUpdateSourceStatusFunc update_source_status_func, - ConsumeFramesFunc consume_frames_func, - void* context) - : stop_callbacks_(0), - type_(type), - source_voice_(source_voice), - update_source_status_func_(update_source_status_func), - consume_frames_func_(consume_frames_func), - context_(context), - frame_buffers_(frame_buffers), - frame_buffers_size_in_frames_(frame_buffers_size_in_frames), - wfx_(wfx), - playback_rate_(1.0), - volume_(1.0), - submitted_frames_(0), - samples_played_(0), - queued_buffers_(0), - was_playing_(false), - current_volume_(1.0) { - CHECK_HRESULT_OK(source_voice_->Stop(0)); -} - -bool XAudioAudioSink::IsType(Type* type) { - return type_ == type; -} - -void XAudioAudioSink::Process() { - ScopedLock process_lock(process_mutex_); - if (AreCallbacksStopped()) { - // We must not continue in this case, since |source_voice_| has been - // destroyed. - return; - } - int frames_in_buffer, offset_in_frames; - bool is_playing, is_eos_reached; - bool is_playback_rate_zero = false; - bool should_set_volume = false; - - // This function is run on the XAudio thread and shouldn't be blocked. - if (mutex_.AcquireTry()) { - is_playback_rate_zero = playback_rate_ == 0.0; - should_set_volume = current_volume_ != volume_; - current_volume_ = volume_; - mutex_.Release(); - } - - if (should_set_volume) { - CHECK_HRESULT_OK(source_voice_->SetVolume(current_volume_)); - } - - update_source_status_func_(&frames_in_buffer, &offset_in_frames, &is_playing, - &is_eos_reached, context_); - if (is_playback_rate_zero) { - is_playing = false; - } - - if (is_playing != was_playing_) { - if (is_playing) { - CHECK_HRESULT_OK(source_voice_->Start(0)); - } else { - CHECK_HRESULT_OK(source_voice_->Stop(0)); - } - } - was_playing_ = is_playing; - - // TODO: make sure that frames_in_buffer is large enough - // that it exceeds the voice state pool interval - if (!is_playing || frames_in_buffer == 0 || is_playback_rate_zero) { - return; - } - int unsubmitted_frames = frames_in_buffer - submitted_frames_; - int unsubmitted_start = - (offset_in_frames + submitted_frames_) % frame_buffers_size_in_frames_; - if (unsubmitted_frames == 0 || queued_buffers_ + kMaxBuffersSubmittedPerLoop > - XAUDIO2_MAX_QUEUED_BUFFERS) { - // submit nothing - } else if (unsubmitted_start + unsubmitted_frames <= - frame_buffers_size_in_frames_) { - SubmitSourceBuffer(unsubmitted_start, unsubmitted_frames); - } else { - int count_tail_frames = frame_buffers_size_in_frames_ - unsubmitted_start; - // Note since we can submit up to two source buffers at a time, - // kMaxBuffersSubmittedPerLoop = 2. - SubmitSourceBuffer(unsubmitted_start, count_tail_frames); - SubmitSourceBuffer(0, unsubmitted_frames - count_tail_frames); - } - submitted_frames_ = frames_in_buffer; - - XAUDIO2_VOICE_STATE voice_state; - source_voice_->GetState(&voice_state); - - int64_t consumed_frames = voice_state.SamplesPlayed - samples_played_; - SB_DCHECK(consumed_frames >= 0); - SB_DCHECK(consumed_frames <= std::numeric_limits::max()); - int consumed_frames_int = static_cast(consumed_frames); - - consume_frames_func_(consumed_frames_int, CurrentMonotonicTime(), context_); - submitted_frames_ -= consumed_frames_int; - samples_played_ = voice_state.SamplesPlayed; - queued_buffers_ = voice_state.BuffersQueued; -} - -void XAudioAudioSink::SubmitSourceBuffer(int offset_in_frames, - int count_frames) { - XAUDIO2_BUFFER audio_buffer_info; - - audio_buffer_info.Flags = 0; - audio_buffer_info.AudioBytes = wfx_.nChannels * - frame_buffers_size_in_frames_ * - (wfx_.wBitsPerSample / 8); - audio_buffer_info.pAudioData = static_cast(frame_buffers_[0]); - audio_buffer_info.PlayBegin = offset_in_frames; - audio_buffer_info.PlayLength = count_frames; - audio_buffer_info.LoopBegin = 0; - audio_buffer_info.LoopLength = 0; - audio_buffer_info.LoopCount = 0; - audio_buffer_info.pContext = nullptr; - CHECK_HRESULT_OK(source_voice_->SubmitSourceBuffer(&audio_buffer_info)); -} - -XAudioAudioSinkType::XAudioAudioSinkType() - : restart_audio_thread_("RestartAudioDevice"), - sink_shutdown_in_progress_(false), - thread_checker_(starboard::ThreadChecker::kSetThreadIdOnFirstCheck) { - x_audio2_ = XAudioCreate(); - HRESULT hr = x_audio2_->CreateMasteringVoice(&mastering_voice_); - SB_LOG_IF(WARNING, FAILED(hr)) << "Audio failed to CreateMasteringVoice(), " - "sound will be disabled."; -} - -ComPtr XAudioAudioSinkType::XAudioCreate() { - ComPtr x_audio2; - HRESULT hr = XAudio2Create(&x_audio2, 0, XAUDIO2_DEFAULT_PROCESSOR); - if (FAILED(hr)) { - return nullptr; - } - -#if !defined(COBALT_BUILD_TYPE_GOLD) - XAUDIO2_DEBUG_CONFIGURATION debug_config = {}; - debug_config.TraceMask = XAUDIO2_LOG_ERRORS | XAUDIO2_LOG_WARNINGS | - XAUDIO2_LOG_INFO | XAUDIO2_LOG_DETAIL | - XAUDIO2_LOG_TIMING | XAUDIO2_LOG_LOCKS; - debug_config.LogThreadID = TRUE; - debug_config.LogFileline = TRUE; - debug_config.LogFunctionName = TRUE; - debug_config.LogTiming = TRUE; - x_audio2->SetDebugConfiguration(&debug_config, NULL); -#endif // !defined(COBALT_BUILD_TYPE_GOLD) - - x_audio2->RegisterForCallbacks(this); - return x_audio2; -} - -SbAudioSink XAudioAudioSinkType::Create( - int channels, - int sampling_frequency_hz, - SbMediaAudioSampleType audio_sample_type, - SbMediaAudioFrameStorageType audio_frame_storage_type, - SbAudioSinkFrameBuffers frame_buffers, - int frame_buffers_size_in_frames, - SbAudioSinkUpdateSourceStatusFunc update_source_status_func, - SbAudioSinkPrivate::ConsumeFramesFunc consume_frames_func, - SbAudioSinkPrivate::ErrorFunc error_func, - void* context) { - SB_DCHECK(audio_frame_storage_type == - kSbMediaAudioFrameStorageTypeInterleaved); - - WAVEFORMATEX wfx; - wfx.wFormatTag = SampleTypeToFormatTag(audio_sample_type); - wfx.nChannels = static_cast(channels); - wfx.nSamplesPerSec = sampling_frequency_hz; - wfx.nAvgBytesPerSec = channels * - SampleTypeToBitsPerSample(audio_sample_type) * - sampling_frequency_hz / 8; - wfx.wBitsPerSample = SampleTypeToBitsPerSample(audio_sample_type); - wfx.nBlockAlign = static_cast((channels * wfx.wBitsPerSample) / 8); - wfx.cbSize = 0; - - IXAudio2SourceVoice* source_voice = nullptr; - HRESULT hr = E_FAIL; - { - ScopedLock lock(x_audio2_mutex_); - if (!x_audio2_) { - x_audio2_ = XAudioCreate(); - if (!x_audio2_) { - SB_DLOG(WARNING) << "Audio failed to XAudioCreate(), " - "sound will be disabled."; - return nullptr; - } - hr = x_audio2_->CreateMasteringVoice(&mastering_voice_); - if (FAILED(hr)) { - SB_DLOG(WARNING) << "Audio failed to CreateMasteringVoice(), " - "sound will be disabled."; - return nullptr; - } - } - hr = x_audio2_->CreateSourceVoice(&source_voice, &wfx, - XAUDIO2_VOICE_NOPITCH, 1.f); - } - if (FAILED(hr)) { - SB_DLOG(WARNING) << "Could not create source voice, error code: " << hr; - return nullptr; - } - - XAudioAudioSink* audio_sink = new XAudioAudioSink( - this, source_voice, wfx, frame_buffers, frame_buffers_size_in_frames, - update_source_status_func, consume_frames_func, context); - - ScopedLock lock(mutex_); - audio_sinks_to_add_.push_back(audio_sink); - return audio_sink; -} - -void XAudioAudioSinkType::Destroy(SbAudioSink audio_sink) { - if (audio_sink == kSbAudioSinkInvalid) { - return; - } - if (!IsValid(audio_sink)) { - SB_LOG(WARNING) << "audio_sink is invalid."; - return; - } - // Previous versions of this code waited for the next OnProcessingPassStart() - // call to occur before returning. However, various circumstances could - // cause that never to happen, especially during UWP suspend. - // Instead, we return immediately, ensuring no SbAudioSink callbacks occur - // and postpone the delete itself until the next OnProcessingPassStart() - static_cast(audio_sink)->StopCallbacks(); - - ScopedLock lock(mutex_); - auto it = std::find(audio_sinks_to_restart_.begin(), - audio_sinks_to_restart_.end(), audio_sink); - if (it == audio_sinks_to_restart_.end()) { - audio_sinks_to_delete_.push_back(audio_sink); - } else { - audio_sinks_to_restart_.erase(it); - delete audio_sink; - } -} - -void XAudioAudioSinkType::RestartAudioDevice() { - { - ScopedLock lock(mutex_); - audio_sinks_to_restart_.insert(audio_sinks_to_restart_.end(), - audio_sinks_on_xaudio_callbacks_.begin(), - audio_sinks_on_xaudio_callbacks_.end()); - audio_sinks_on_xaudio_callbacks_.clear(); - audio_sinks_to_restart_.insert(audio_sinks_to_restart_.end(), - audio_sinks_to_add_.begin(), - audio_sinks_to_add_.end()); - audio_sinks_to_add_.clear(); - - ProcessSinksToDelete(); - for (auto sink : audio_sinks_to_restart_) { - sink->SetSourceVoice(nullptr); - } - } - if (mastering_voice_) { - mastering_voice_->DestroyVoice(); - mastering_voice_ = nullptr; - } - { - ScopedLock lock(x_audio2_mutex_); - x_audio2_.Reset(); - } - sink_shutdown_in_progress_ = false; - - TryAcquireSinkVoices(); -} - -void XAudioAudioSinkType::TryAcquireSinkVoices() { - HRESULT hr = E_FAIL; - ScopedLock x_audio2_mutex_lock(x_audio2_mutex_); - if (!x_audio2_) { - hr = XAudio2Create(&x_audio2_, 0, XAUDIO2_DEFAULT_PROCESSOR); - if (FAILED(hr)) { - restart_audio_thread_.job_queue()->Schedule( - std::bind(&XAudioAudioSinkType::TryAcquireSinkVoices, this)); - return; - } - x_audio2_->RegisterForCallbacks(this); - } - - if (!mastering_voice_) { - hr = x_audio2_->CreateMasteringVoice(&mastering_voice_); - if (FAILED(hr)) { - restart_audio_thread_.job_queue()->Schedule( - std::bind(&XAudioAudioSinkType::TryAcquireSinkVoices, this)); - return; - } - } - - std::list audio_sinks_failed; - ScopedLock mutex_lock(mutex_); - for (auto sink : audio_sinks_to_restart_) { - IXAudio2SourceVoice* source_voice = nullptr; - hr = x_audio2_->CreateSourceVoice(&source_voice, &sink->GetWaveFormatEx(), - XAUDIO2_VOICE_NOPITCH, 1.f); - if (FAILED(hr)) { - audio_sinks_failed.push_back(sink); - continue; - } - sink->SetSourceVoice(source_voice); - audio_sinks_to_add_.push_back(sink); - } - audio_sinks_to_restart_ = audio_sinks_failed; - if (audio_sinks_to_restart_.empty()) { - return; - } - restart_audio_thread_.job_queue()->Schedule( - std::bind(&XAudioAudioSinkType::TryAcquireSinkVoices, this)); -} - -void XAudioAudioSinkType::OnProcessingPassStart() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - if (mutex_.AcquireTry()) { - ProcessSinksToAdd(); - ProcessSinksToDelete(); - mutex_.Release(); - } - - for (XAudioAudioSink* sink : audio_sinks_on_xaudio_callbacks_) { - sink->Process(); - } -} - -} // namespace -} // namespace win32 -} // namespace shared -} // namespace starboard - -namespace { -SbAudioSinkPrivate::Type* audio_sink_; -} // namespace - -// static -void SbAudioSinkPrivate::PlatformInitialize() { - SB_DCHECK(!audio_sink_); - audio_sink_ = new starboard::shared::win32::XAudioAudioSinkType(); - SetPrimaryType(audio_sink_); - EnableFallbackToStub(); -} - -// static -void SbAudioSinkPrivate::PlatformTearDown() { - SB_DCHECK(audio_sink_ == GetPrimaryType()); - SetPrimaryType(nullptr); - delete audio_sink_; - audio_sink_ = nullptr; -} diff --git a/starboard/shared/win32/audio_sink_get_max_channels.cc b/starboard/shared/win32/audio_sink_get_max_channels.cc deleted file mode 100644 index 979f62f8147a..000000000000 --- a/starboard/shared/win32/audio_sink_get_max_channels.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/audio_sink.h" - -int SbAudioSinkGetMaxChannels() { - return 6; -} diff --git a/starboard/shared/win32/audio_sink_get_nearest_supported_sample_frequency.cc b/starboard/shared/win32/audio_sink_get_nearest_supported_sample_frequency.cc deleted file mode 100644 index 4e0c5ecdb86e..000000000000 --- a/starboard/shared/win32/audio_sink_get_nearest_supported_sample_frequency.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/audio_sink.h" - -#include "starboard/common/log.h" - -int SbAudioSinkGetNearestSupportedSampleFrequency(int sampling_frequency_hz) { - if (sampling_frequency_hz <= 0) { - SB_LOG(ERROR) << "Invalid audio sampling frequency " - << sampling_frequency_hz; - return 1; - } - return sampling_frequency_hz; -} diff --git a/starboard/shared/win32/audio_sink_is_audio_frame_storage_type_supported.cc b/starboard/shared/win32/audio_sink_is_audio_frame_storage_type_supported.cc deleted file mode 100644 index 55af5b9ec0d6..000000000000 --- a/starboard/shared/win32/audio_sink_is_audio_frame_storage_type_supported.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/audio_sink.h" - -#include "starboard/common/log.h" - -bool SbAudioSinkIsAudioFrameStorageTypeSupported( - SbMediaAudioFrameStorageType audio_frame_storage_type) { - switch (audio_frame_storage_type) { - case kSbMediaAudioFrameStorageTypeInterleaved: - return true; - case kSbMediaAudioFrameStorageTypePlanar: - return false; - default: - SB_NOTREACHED(); - return false; - } -} diff --git a/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc b/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc deleted file mode 100644 index 7ea8f1ed5149..000000000000 --- a/starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/audio_sink.h" - -#include "starboard/common/log.h" - -bool SbAudioSinkIsAudioSampleTypeSupported( - SbMediaAudioSampleType audio_sample_type) { - switch (audio_sample_type) { - case kSbMediaAudioSampleTypeInt16Deprecated: - return true; - case kSbMediaAudioSampleTypeFloat32: - return true; - default: - return false; - } -} diff --git a/starboard/shared/win32/audio_transform.cc b/starboard/shared/win32/audio_transform.cc deleted file mode 100644 index 67b832d5d50a..000000000000 --- a/starboard/shared/win32/audio_transform.cc +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/audio_transform.h" - -#include - -#include - -#include "starboard/memory.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/media_common.h" -#include "starboard/shared/win32/media_foundation_utils.h" -#include "starboard/shared/win32/wasapi_include.h" - -namespace starboard { -namespace shared { -namespace win32 { - -using Microsoft::WRL::ComPtr; -using starboard::media::AudioStreamInfo; - -namespace { - -GUID ConvertToWin32AudioCodec(SbMediaAudioCodec codec) { - switch (codec) { - case kSbMediaAudioCodecNone: { - return MFAudioFormat_PCM; - } - case kSbMediaAudioCodecAac: { - return MFAudioFormat_AAC; - } - case kSbMediaAudioCodecOpus: { - return MFAudioFormat_Opus; - } - case kSbMediaAudioCodecAc3: { - return MFAudioFormat_Dolby_AC3; - } - case kSbMediaAudioCodecEac3: { - return MFAudioFormat_Dolby_DDPlus; - } - default: { - SB_NOTIMPLEMENTED(); - return MFAudioFormat_PCM; - } - } -} - -GUID ConvertToWin32TransformType(SbMediaAudioCodec codec) { - switch (codec) { - case kSbMediaAudioCodecAac: { - return CLSID_MSAACDecMFT; - } - case kSbMediaAudioCodecAc3: - case kSbMediaAudioCodecEac3: { - return CLSID_MSDDPlusDecMFT; - } - default: { - SB_NOTIMPLEMENTED(); - return MFAudioFormat_Float; - } - } -} - -GUID ConvertToWin32OutputFormat(SbMediaAudioCodec codec) { - switch (codec) { - case kSbMediaAudioCodecAac: - case kSbMediaAudioCodecOpus: - case kSbMediaAudioCodecNone: { - return MFAudioFormat_Float; - } - case kSbMediaAudioCodecAc3: { - return MFAudioFormat_Dolby_AC3_SPDIF; - } - case kSbMediaAudioCodecEac3: { - return KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS; - } - default: { - SB_NOTIMPLEMENTED(); - return MFAudioFormat_Float; - } - } -} - -class WinAudioFormat { - public: - explicit WinAudioFormat(const AudioStreamInfo& audio_stream_info) { - if (audio_stream_info.codec == kSbMediaAudioCodecAac) { - CreateAacAudioFormat(audio_stream_info); - } else { - SB_DCHECK(audio_stream_info.codec == kSbMediaAudioCodecAc3 || - audio_stream_info.codec == kSbMediaAudioCodecEac3); - CreateAc3AudioFormat(audio_stream_info); - } - } - - void CreateAacAudioFormat(const AudioStreamInfo& audio_stream_info) { - // The HEAACWAVEFORMAT structure has many specializations with varying data - // appended at the end. - // The "-1" is used to account for pbAudioSpecificConfig[1] at the end of - // HEAACWAVEFORMAT. - format_buffer_.resize(sizeof(HEAACWAVEFORMAT) + - audio_stream_info.audio_specific_config.size() - 1); - HEAACWAVEFORMAT* wave_format = - reinterpret_cast(format_buffer_.data()); - - wave_format->wfInfo.wfx.nAvgBytesPerSec = 0; - wave_format->wfInfo.wfx.nBlockAlign = 4; - wave_format->wfInfo.wfx.nChannels = audio_stream_info.number_of_channels; - wave_format->wfInfo.wfx.nSamplesPerSec = - audio_stream_info.samples_per_second; - wave_format->wfInfo.wfx.wBitsPerSample = audio_stream_info.bits_per_sample; - wave_format->wfInfo.wfx.wFormatTag = WAVE_FORMAT_MPEG_HEAAC; - // The "-1" is used to account for pbAudioSpecificConfig[1] at the end of - // HEAACWAVEFORMAT. - wave_format->wfInfo.wfx.cbSize = - static_cast(sizeof(HEAACWAVEFORMAT) - sizeof(WAVEFORMATEX) + - audio_stream_info.audio_specific_config.size() - 1); - - wave_format->wfInfo.wPayloadType = 0; // RAW - wave_format->wfInfo.wAudioProfileLevelIndication = 0xfe; // Unknown Profile - wave_format->wfInfo.wStructType = 0; // AudioSpecificConfig() - - if (!audio_stream_info.audio_specific_config.empty()) { - memcpy(wave_format->pbAudioSpecificConfig, - audio_stream_info.audio_specific_config.data(), - audio_stream_info.audio_specific_config.size()); - } - } - - void CreateAc3AudioFormat(const AudioStreamInfo& audio_stream_info) { - format_buffer_.resize(sizeof(WAVEFORMATEXTENSIBLE)); - WAVEFORMATEXTENSIBLE* wave_format = - reinterpret_cast(format_buffer_.data()); - - wave_format->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - wave_format->Format.nChannels = audio_stream_info.number_of_channels; - wave_format->Format.wBitsPerSample = audio_stream_info.bits_per_sample; - wave_format->Format.nSamplesPerSec = audio_stream_info.samples_per_second; - wave_format->Format.nBlockAlign = 4; - wave_format->Format.nAvgBytesPerSec = 0; - wave_format->Format.cbSize = - sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - wave_format->Samples.wValidBitsPerSample = - wave_format->Format.wBitsPerSample; - wave_format->dwChannelMask = audio_stream_info.number_of_channels > 2 - ? KSAUDIO_SPEAKER_5POINT1 - : KSAUDIO_SPEAKER_STEREO; - wave_format->SubFormat = ConvertToWin32AudioCodec(audio_stream_info.codec); - } - - WAVEFORMATEX* WaveFormatData() { - return reinterpret_cast(format_buffer_.data()); - } - UINT32 Size() const { return static_cast(format_buffer_.size()); } - - private: - std::vector format_buffer_; -}; - -} // namespace. - -std::unique_ptr CreateAudioTransform( - const AudioStreamInfo& audio_stream_info) { - SB_DCHECK(audio_stream_info.codec == kSbMediaAudioCodecAac || - audio_stream_info.codec == kSbMediaAudioCodecAc3 || - audio_stream_info.codec == kSbMediaAudioCodecEac3); - ComPtr transform; - HRESULT hr = CreateDecoderTransform( - ConvertToWin32TransformType(audio_stream_info.codec), &transform); - - CheckResult(hr); - - ComPtr input_type; - hr = MFCreateMediaType(&input_type); - CheckResult(hr); - - WinAudioFormat audio_fmt(audio_stream_info); - hr = MFInitMediaTypeFromWaveFormatEx( - input_type.Get(), audio_fmt.WaveFormatData(), audio_fmt.Size()); - CheckResult(hr); - - GUID win32_audio_type = ConvertToWin32AudioCodec(audio_stream_info.codec); - - std::vector> available_types = - GetAllInputMediaTypes(MediaTransform::kStreamId, transform.Get()); - - available_types = FilterMediaBySubType(available_types, win32_audio_type); - SB_DCHECK(available_types.size()); - - ComPtr selected = available_types[0]; - CopyProperties(input_type.Get(), selected.Get()); - - std::unique_ptr output(new MediaTransform(transform)); - output->SetInputType(selected); - output->SetOutputTypeBySubType( - ConvertToWin32OutputFormat(audio_stream_info.codec)); - - return output; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/audio_transform.h b/starboard/shared/win32/audio_transform.h deleted file mode 100644 index 0e30134de89f..000000000000 --- a/starboard/shared/win32/audio_transform.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_AUDIO_TRANSFORM_H_ -#define STARBOARD_SHARED_WIN32_AUDIO_TRANSFORM_H_ - -#include - -#include "starboard/media.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/win32/media_transform.h" - -namespace starboard { -namespace shared { -namespace win32 { - -std::unique_ptr CreateAudioTransform( - const starboard::media::AudioStreamInfo& audio_stream_info); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_AUDIO_TRANSFORM_H_ diff --git a/starboard/shared/win32/auto_event_handle.h b/starboard/shared/win32/auto_event_handle.h deleted file mode 100644 index b971d8782628..000000000000 --- a/starboard/shared/win32/auto_event_handle.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_AUTO_EVENT_HANDLE_H_ -#define STARBOARD_SHARED_WIN32_AUTO_EVENT_HANDLE_H_ - -#include - -namespace starboard { -namespace shared { -namespace win32 { - -class AutoEventHandle { - public: - explicit AutoEventHandle(WSAEVENT event) : event_(event) {} - - ~AutoEventHandle() { CleanupExistingEvent(); } - - void Reset(WSAEVENT new_event) { - CleanupExistingEvent(); - event_ = new_event; - } - - bool IsValid() const { return event_ != WSA_INVALID_EVENT; } - - WSAEVENT GetEvent() { return event_; } - - private: - AutoEventHandle(const AutoEventHandle&) = delete; - AutoEventHandle& operator=(const AutoEventHandle&) = delete; - - void CleanupExistingEvent() { - if (IsValid()) { - WSACloseEvent(event_); - event_ = WSA_INVALID_EVENT; - } - } - - WSAEVENT event_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_AUTO_EVENT_HANDLE_H_ diff --git a/starboard/shared/win32/byte_swap.cc b/starboard/shared/win32/byte_swap.cc deleted file mode 100644 index 649ab6f73add..000000000000 --- a/starboard/shared/win32/byte_swap.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#if SB_API_VERSION < 16 - -#include "starboard/byte_swap.h" - -#include - -int16_t SbByteSwapS16(int16_t value) { - return _byteswap_ushort(value); -} - -uint16_t SbByteSwapU16(uint16_t value) { - return _byteswap_ushort(value); -} - -int32_t SbByteSwapS32(int32_t value) { - return _byteswap_ulong(value); -} - -uint32_t SbByteSwapU32(uint32_t value) { - return _byteswap_ulong(value); -} - -int64_t SbByteSwapS64(int64_t value) { - return _byteswap_uint64(value); -} - -uint64_t SbByteSwapU64(uint64_t value) { - return _byteswap_uint64(value); -} - -#endif diff --git a/starboard/shared/win32/condition_variable_broadcast.cc b/starboard/shared/win32/condition_variable_broadcast.cc deleted file mode 100644 index 54afbd843ad7..000000000000 --- a/starboard/shared/win32/condition_variable_broadcast.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -bool SbConditionVariableBroadcast(SbConditionVariable* condition) { - if (!condition) { - return false; - } - WakeAllConditionVariable(SB_WIN32_INTERNAL_CONDITION(condition)); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_create.cc b/starboard/shared/win32/condition_variable_create.cc deleted file mode 100644 index 8346a9cb1b41..000000000000 --- a/starboard/shared/win32/condition_variable_create.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/types_internal.h" - -bool SbConditionVariableCreate(SbConditionVariable* out_condition, - SbMutex* opt_mutex) { - SB_COMPILE_ASSERT(sizeof(SbConditionVariable) >= sizeof(CONDITION_VARIABLE), - condition_variable_larger_than_sb_condition_variable); - if (!out_condition) { - return false; - } - InitializeConditionVariable(SB_WIN32_INTERNAL_CONDITION(out_condition)); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_destroy.cc b/starboard/shared/win32/condition_variable_destroy.cc deleted file mode 100644 index a48c40fb4568..000000000000 --- a/starboard/shared/win32/condition_variable_destroy.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -bool SbConditionVariableDestroy(SbConditionVariable* condition) { - if (!condition) { - return false; - } - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_signal.cc b/starboard/shared/win32/condition_variable_signal.cc deleted file mode 100644 index ac38573e5232..000000000000 --- a/starboard/shared/win32/condition_variable_signal.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -bool SbConditionVariableSignal(SbConditionVariable* condition) { - if (!condition) { - return false; - } - WakeConditionVariable(SB_WIN32_INTERNAL_CONDITION(condition)); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_wait.cc b/starboard/shared/win32/condition_variable_wait.cc deleted file mode 100644 index 5360e7ec243c..000000000000 --- a/starboard/shared/win32/condition_variable_wait.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -SbConditionVariableResult SbConditionVariableWait( - SbConditionVariable* condition, - SbMutex* mutex) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - bool result = - SleepConditionVariableSRW(SB_WIN32_INTERNAL_CONDITION(condition), - SB_WIN32_INTERNAL_MUTEX(mutex), INFINITE, 0); - - return result ? kSbConditionVariableSignaled : kSbConditionVariableFailed; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/condition_variable_wait_timed.cc b/starboard/shared/win32/condition_variable_wait_timed.cc deleted file mode 100644 index 2a448466affb..000000000000 --- a/starboard/shared/win32/condition_variable_wait_timed.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/condition_variable.h" - -#include - -#include "starboard/shared/win32/time_utils.h" -#include "starboard/shared/win32/types_internal.h" - -using starboard::shared::win32::ConvertUsecToMillisRoundUp; - -SbConditionVariableResult SbConditionVariableWaitTimed( - SbConditionVariable* condition, - SbMutex* mutex, - int64_t timeout) { - if (!condition || !mutex) { - return kSbConditionVariableFailed; - } - - if (timeout < 0) { - timeout = 0; - } - bool result = SleepConditionVariableSRW( - SB_WIN32_INTERNAL_CONDITION(condition), SB_WIN32_INTERNAL_MUTEX(mutex), - ConvertUsecToMillisRoundUp(timeout), 0); - - if (timeout == 0) { - // Per documentation, "If the |timeout_duration| value is less than - // or equal to zero, the function returns as quickly as possible with a - // kSbConditionVariableTimedOut result." - return kSbConditionVariableTimedOut; - } - - if (result) { - return kSbConditionVariableSignaled; - } - - if (GetLastError() == ERROR_TIMEOUT) { - return kSbConditionVariableTimedOut; - } - return kSbConditionVariableFailed; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/configuration.cc b/starboard/shared/win32/configuration.cc deleted file mode 100644 index d1b93a53023d..000000000000 --- a/starboard/shared/win32/configuration.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/configuration.h" - -#include "starboard/common/configuration_defaults.h" -#include "starboard/extension/configuration.h" - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -const char* CobaltFallbackSplashScreenUrl() { - return "file:///internal/cobalt/browser/splash_screen/" - "youtube_splash_screen.html"; -} - -const char* CobaltRasterizerType() { - // Use a hardware rasterizer and graphical setup. - return "hardware"; -} - -const CobaltExtensionConfigurationApi kConfigurationApi = { - kCobaltExtensionConfigurationName, - 3, - &common::CobaltUserOnExitStrategyDefault, - &common::CobaltRenderDirtyRegionOnlyDefault, - &common::CobaltEglSwapIntervalDefault, - &CobaltFallbackSplashScreenUrl, - &common::CobaltEnableQuicDefault, - &common::CobaltSkiaCacheSizeInBytesDefault, - &common::CobaltOffscreenTargetCacheSizeInBytesDefault, - &common::CobaltEncodedImageCacheSizeInBytesDefault, - &common::CobaltImageCacheSizeInBytesDefault, - &common::CobaltLocalTypefaceCacheSizeInBytesDefault, - &common::CobaltRemoteTypefaceCacheSizeInBytesDefault, - &common::CobaltMeshCacheSizeInBytesDefault, - &common::CobaltSoftwareSurfaceCacheSizeInBytesDefault, - &common::CobaltImageCacheCapacityMultiplierWhenPlayingVideoDefault, - &common::CobaltSkiaGlyphAtlasWidthDefault, - &common::CobaltSkiaGlyphAtlasHeightDefault, - &common::CobaltJsGarbageCollectionThresholdInBytesDefault, - &common::CobaltReduceCpuMemoryByDefault, - &common::CobaltReduceGpuMemoryByDefault, - &common::CobaltGcZealDefault, - &CobaltRasterizerType, - &common::CobaltEnableJitDefault, - &common::CobaltFallbackSplashScreenTopicsDefault, - &common::CobaltCanStoreCompiledJavascriptDefault, -}; - -} // namespace - -const void* GetConfigurationApi() { - return &kConfigurationApi; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/configuration.h b/starboard/shared/win32/configuration.h deleted file mode 100644 index 390b35e4f71f..000000000000 --- a/starboard/shared/win32/configuration.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_CONFIGURATION_H_ -#define STARBOARD_SHARED_WIN32_CONFIGURATION_H_ - -namespace starboard { -namespace shared { -namespace win32 { - -const void* GetConfigurationApi(); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_CONFIGURATION_H_ diff --git a/starboard/shared/win32/decode_target_internal.cc b/starboard/shared/win32/decode_target_internal.cc deleted file mode 100644 index 88e7046a7410..000000000000 --- a/starboard/shared/win32/decode_target_internal.cc +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/decode_target_internal.h" - -#include "starboard/common/log.h" -#include "starboard/common/memory.h" -#include "starboard/configuration.h" - -SbDecodeTargetPrivate::SbDecodeTargetPrivate() : refcount(1) { - memset(&info, 0, sizeof(info)); -} - -void SbDecodeTargetPrivate::AddRef() { - SbAtomicBarrier_Increment(&refcount, 1); -} - -void SbDecodeTargetPrivate::Release() { - int new_count = SbAtomicBarrier_Increment(&refcount, -1); - SB_DCHECK(new_count >= 0); - if (new_count == 0) { - delete this; - } -} - -void SbDecodeTargetRelease(SbDecodeTarget decode_target) { - if (SbDecodeTargetIsValid(decode_target)) { - decode_target->Release(); - } -} - -SbDecodeTargetFormat SbDecodeTargetGetFormat(SbDecodeTarget decode_target) { - // Note that kSbDecodeTargetFormat2PlaneYUVNV12 represents DXGI_FORMAT_NV12. - // kSbDecodeTargetFormat1PlaneRGBA represents DXGI_FORMAT_R10G10B10A2_UNORM. - SB_DCHECK(kSbDecodeTargetFormat2PlaneYUVNV12 == decode_target->info.format || - kSbDecodeTargetFormat1PlaneRGBA == decode_target->info.format); - return decode_target->info.format; -} - -bool SbDecodeTargetGetInfo(SbDecodeTarget decode_target, - SbDecodeTargetInfo* out_info) { - if (!out_info || - !starboard::common::MemoryIsZero(out_info, sizeof(*out_info))) { - SB_DCHECK(false) << "out_info must be zeroed out."; - return false; - } - memcpy(out_info, &decode_target->info, sizeof(*out_info)); - return true; -} diff --git a/starboard/shared/win32/decode_target_internal.h b/starboard/shared/win32/decode_target_internal.h deleted file mode 100644 index 0f1e077c8bf7..000000000000 --- a/starboard/shared/win32/decode_target_internal.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DECODE_TARGET_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_DECODE_TARGET_INTERNAL_H_ - -#include "starboard/atomic.h" -#include "starboard/decode_target.h" - -struct SbDecodeTargetPrivate { - SbAtomic32 refcount; - - // Publicly accessible information about the decode target. - SbDecodeTargetInfo info; - - SbDecodeTargetPrivate(); - virtual ~SbDecodeTargetPrivate() {} - - void AddRef(); - void Release(); -}; - -#endif // STARBOARD_SHARED_WIN32_DECODE_TARGET_INTERNAL_H_ diff --git a/starboard/shared/win32/decrypting_decoder.cc b/starboard/shared/win32/decrypting_decoder.cc deleted file mode 100644 index 5488e744cd6f..000000000000 --- a/starboard/shared/win32/decrypting_decoder.cc +++ /dev/null @@ -1,366 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/decrypting_decoder.h" - -#include - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/memory.h" -#include "starboard/common/ref_counted.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/media_foundation_utils.h" - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -ComPtr CreateSample(const void* data, - int size, - int64_t win32_timestamp) { - ComPtr buffer; - HRESULT hr = MFCreateMemoryBuffer(size, &buffer); - CheckResult(hr); - - BYTE* buffer_ptr; - hr = buffer->Lock(&buffer_ptr, 0, 0); - CheckResult(hr); - - memcpy(buffer_ptr, data, size); - - hr = buffer->Unlock(); - CheckResult(hr); - - hr = buffer->SetCurrentLength(size); - CheckResult(hr); - - ComPtr input; - hr = MFCreateSample(&input); - CheckResult(hr); - - hr = input->AddBuffer(buffer.Get()); - CheckResult(hr); - - // sample time is in 100 nanoseconds. - input->SetSampleTime(win32_timestamp); - return input; -} - -void AttachDrmDataToSample(ComPtr sample, - int sample_size, - const uint8_t* key_id, - int key_id_size, - const uint8_t* iv, - int iv_size, - const SbDrmSubSampleMapping* subsample_mapping, - int subsample_count) { - if (iv_size == 16 && ::starboard::common::MemoryIsZero(iv + 8, 8)) { - // For iv that is 16 bytes long but the the last 8 bytes is 0, we treat - // it as an 8 bytes iv. - iv_size = 8; - } - sample->SetBlob(MFSampleExtension_Encryption_SampleID, - reinterpret_cast(iv), - static_cast(iv_size)); - SB_DCHECK(key_id_size == sizeof(GUID)); - GUID guid = *reinterpret_cast(key_id); - - guid.Data1 = _byteswap_ulong(guid.Data1); - guid.Data2 = _byteswap_ushort(guid.Data2); - guid.Data3 = _byteswap_ushort(guid.Data3); - - sample->SetGUID(MFSampleExtension_Content_KeyID, guid); - - SB_DCHECK(sizeof(DWORD) * 2 == sizeof(SbDrmSubSampleMapping)); - - SbDrmSubSampleMapping default_subsample = {0, sample_size}; - if (subsample_count == 0) { - subsample_mapping = &default_subsample; - subsample_count = 1; - } - sample->SetBlob( - MFSampleExtension_Encryption_SubSampleMappingSplit, - reinterpret_cast(subsample_mapping), - static_cast(subsample_count * sizeof(SbDrmSubSampleMapping))); -} - -} // namespace - -DecryptingDecoder::DecryptingDecoder(const std::string& type, - std::unique_ptr decoder, - SbDrmSystem drm_system) - : type_(type), decoder_(std::move(decoder)) { - SB_DCHECK(decoder_.get()); - drm_system_ = static_cast(drm_system); -} - -DecryptingDecoder::~DecryptingDecoder() { - Reset(); -} - -bool DecryptingDecoder::TryWriteInputBuffer( - const scoped_refptr& input_buffer, - int bytes_to_skip_in_sample) { - SB_DCHECK(input_buffer); - SB_DCHECK(bytes_to_skip_in_sample >= 0); - - ComPtr input_sample; - - const SbDrmSampleInfo* drm_info = input_buffer->drm_info(); - const uint8_t* key_id = NULL; - int key_id_size = 0; - bool encrypted = false; - - if (drm_info != NULL && drm_info->identifier_size == 16 && - (drm_info->initialization_vector_size == 8 || - drm_info->initialization_vector_size == 16)) { - key_id = drm_info->identifier; - key_id_size = drm_info->identifier_size; - encrypted = true; - } - - if (input_buffer == last_input_buffer_) { - SB_DCHECK(last_input_sample_); - input_sample = last_input_sample_; - } else { - if (input_buffer->size() < bytes_to_skip_in_sample) { - SB_NOTREACHED(); - return false; - } - - const void* data = input_buffer->data() + bytes_to_skip_in_sample; - int size = input_buffer->size() - bytes_to_skip_in_sample; - - std::int64_t win32_timestamp = - ConvertUsecToWin32Time(input_buffer->timestamp()); - const uint8_t* iv = NULL; - int iv_size = 0; - const SbDrmSubSampleMapping* subsample_mapping = NULL; - int subsample_count = 0; - - if (drm_info != NULL && drm_info->initialization_vector_size != 0) { - if (bytes_to_skip_in_sample != 0) { - if (drm_info->subsample_count != 0 && drm_info->subsample_count != 1) { - return false; - } - if (drm_info->subsample_count == 1) { - if (drm_info->subsample_mapping[0].clear_byte_count != - bytes_to_skip_in_sample) { - return false; - } - } - } else { - subsample_mapping = drm_info->subsample_mapping; - subsample_count = drm_info->subsample_count; - } - - iv = drm_info->initialization_vector; - iv_size = drm_info->initialization_vector_size; - } - - // MFSampleExtension_CleanPoint is a key-frame for the video + audio. It is - // not set here because the win32 system is smart enough to figure this out. - // It will probably be totally ok to not set this at all. Resolution: If - // there are problems with win32 video decoding, come back to this and see - // if setting this will fix it. THis will be used if - // SbMediaVideoSampleInfo::is_key_frame is true inside of the this function - // (which will receive an InputBuffer). - input_sample = CreateSample(data, size, win32_timestamp); - - if (encrypted) { - AttachDrmDataToSample(input_sample, size, key_id, key_id_size, iv, - iv_size, subsample_mapping, subsample_count); - } - last_input_buffer_ = input_buffer; - last_input_sample_ = input_sample; - } - - if (encrypted) { - if (!decryptor_) { - if (decoder_->draining()) { - return false; - } - if (!decoder_->drained()) { - decoder_->Drain(); - return false; - } - decoder_->ResetFromDrained(); - scoped_refptr license = - drm_system_->GetLicense(key_id, key_id_size); - if (license && license->usable()) { - decryptor_.reset(new MediaTransform(license->decryptor())); - bool success = ActivateDecryptor(); - if (!success) { - decryptor_.reset(); - return false; - } - } - } - if (!decryptor_) { - SB_NOTREACHED(); - return false; - } - } - - if (encrypted) { - return decryptor_->TryWrite(input_sample); - } - return decoder_->TryWrite(input_sample); -} - -bool DecryptingDecoder::ProcessAndRead(ComPtr* output, - ComPtr* new_type, - bool* has_error) { - bool did_something = false; - - *output = decoder_->TryRead(new_type); - did_something |= *output != NULL; - *has_error = decoder_->HasError(); - - if (decryptor_) { - if (!pending_decryptor_output_) { - ComPtr ignored_type; - pending_decryptor_output_ = decryptor_->TryRead(&ignored_type); - did_something |= pending_decryptor_output_ != NULL; - } - - if (pending_decryptor_output_) { - if (decoder_->TryWrite(pending_decryptor_output_)) { - pending_decryptor_output_.Reset(); - did_something = true; - } - } - - if (decryptor_->drained() && !decoder_->draining() && - !decoder_->drained()) { - decoder_->Drain(); - did_something = true; - } - } - - return did_something; -} - -void DecryptingDecoder::Drain() { - if (decryptor_) { - decryptor_->Drain(); - } else { - decoder_->Drain(); - } -} - -bool DecryptingDecoder::ActivateDecryptor() { - SB_DCHECK(decryptor_); - - ComPtr decoder_output_type = decoder_->GetCurrentOutputType(); - decryptor_->SetInputType(decoder_->GetCurrentInputType()); - - GUID original_sub_type; - decoder_output_type->GetGUID(MF_MT_SUBTYPE, &original_sub_type); - - // Ensure that the decryptor and the decoder agrees on the protection of - // samples transferred between them. - ComPtr decryption_sample_protection = - decryptor_->GetSampleProtection(); - SB_DCHECK(decryption_sample_protection); - - DWORD decryption_protection_version; - HRESULT hr = decryption_sample_protection->GetOutputProtectionVersion( - &decryption_protection_version); - CheckResult(hr); - - ComPtr decoder_sample_protection = - decoder_->GetSampleProtection(); - SB_DCHECK(decoder_sample_protection); - - DWORD decoder_protection_version; - hr = decoder_sample_protection->GetInputProtectionVersion( - &decoder_protection_version); - CheckResult(hr); - - DWORD protection_version = - std::min(decoder_protection_version, decryption_protection_version); - if (protection_version < SAMPLE_PROTECTION_VERSION_RC4) { - SB_NOTREACHED(); - return true; - } - - BYTE* cert_data = NULL; - DWORD cert_data_size = 0; - - hr = decoder_sample_protection->GetProtectionCertificate( - protection_version, &cert_data, &cert_data_size); - CheckResult(hr); - - BYTE* crypt_seed = NULL; - DWORD crypt_seed_size = 0; - hr = decryption_sample_protection->InitOutputProtection( - protection_version, 0, cert_data, cert_data_size, &crypt_seed, - &crypt_seed_size); - if (FAILED(hr)) { - // This can happen if we call InitOutputProtection while processing - // a UWP resume event or shortly after. - return false; - } - CheckResult(hr); - - hr = decoder_sample_protection->InitInputProtection( - protection_version, 0, crypt_seed, crypt_seed_size); - CheckResult(hr); - - CoTaskMemFree(cert_data); - CoTaskMemFree(crypt_seed); - - // Ensure that the input type of the decoder is the output type of the - // decryptor. - ComPtr decoder_input_type; - std::vector> decryptor_output_types = - decryptor_->GetAvailableOutputTypes(); - SB_DCHECK(!decryptor_output_types.empty()); - - decryptor_->SetOutputType(decryptor_output_types[0]); - decoder_->SetInputType(decryptor_output_types[0]); - - std::vector> decoder_output_types = - decoder_->GetAvailableOutputTypes(); - for (auto output_type : decoder_output_types) { - GUID sub_type; - output_type->GetGUID(MF_MT_SUBTYPE, &sub_type); - if (IsEqualGUID(sub_type, original_sub_type)) { - decoder_->SetOutputType(output_type); - return true; - } - } - return true; -} - -void DecryptingDecoder::Reset() { - if (decryptor_) { - decryptor_->Reset(); - } - decoder_->Reset(); - - last_input_buffer_ = nullptr; - last_input_sample_ = nullptr; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/decrypting_decoder.h b/starboard/shared/win32/decrypting_decoder.h deleted file mode 100644 index 472318e152c9..000000000000 --- a/starboard/shared/win32/decrypting_decoder.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DECRYPTING_DECODER_H_ -#define STARBOARD_SHARED_WIN32_DECRYPTING_DECODER_H_ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "starboard/common/ref_counted.h" -#include "starboard/drm.h" -#include "starboard/media.h" -#include "starboard/shared/win32/drm_system_playready.h" -#include "starboard/shared/win32/media_common.h" -#include "starboard/shared/win32/media_transform.h" -#include "starboard/types.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// This class maintains a MediaTransform based decoding stream. When the -// stream is encrypted, it also contains a MediaTransform based decryptor and -// manages the interaction between the decryptor and the decoder. -class DecryptingDecoder { - public: - DecryptingDecoder(const std::string& type, - std::unique_ptr decoder, - SbDrmSystem drm_system); - ~DecryptingDecoder(); - - MediaTransform* GetDecoder() { return decoder_.get(); } - - bool TryWriteInputBuffer(const scoped_refptr& input_buffer, - int bytes_to_skip_in_sample); - - // Return true if there is any internal actions succeeded, this implies that - // the caller can call this function again to process further. - // |output| contains the decrypted and decoded output if there is any. - // |new_type| contains the new output type in case the output type of the - // decoding stream is changed. - bool ProcessAndRead(ComPtr* output, - ComPtr* new_type, - bool* has_error); - void Drain(); - void Reset(); - - private: - bool ActivateDecryptor(); - - // TODO: Clarify the thread pattern of this class. - const std::string type_; // For debugging purpose. - DrmSystemPlayready* drm_system_; - - std::unique_ptr decryptor_; - std::unique_ptr decoder_; - - scoped_refptr last_input_buffer_; - ComPtr last_input_sample_; - - ComPtr pending_decryptor_output_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_DECRYPTING_DECODER_H_ diff --git a/starboard/shared/win32/dialog.cc b/starboard/shared/win32/dialog.cc deleted file mode 100644 index 878430779d2c..000000000000 --- a/starboard/shared/win32/dialog.cc +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/dialog.h" - -#include -#include -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wchar_utils.h" - -typedef std::function DialogCallback; - -using starboard::shared::win32::CStringToWString; -using starboard::shared::win32::DebugLogWinError; - -namespace { -HWND g_current_dialog_handle = nullptr; -DialogCallback g_ok_callback; -DialogCallback g_cancel_callback; -} // namespace - -// Wraps the win32 Dialog interface for building Dialogs at runtime. -// https://blogs.msdn.microsoft.com/oldnewthing/20050429-00/?p=35743 -class DialogTemplateBuilder { - public: - LPCDLGTEMPLATE BuildTemplate() { return (LPCDLGTEMPLATE)&v[0]; } - void AlignToDword() { - if (v.size() % 4) - Write(NULL, 4 - (v.size() % 4)); - } - void Write(LPCVOID pvWrite, DWORD cbWrite) { - v.insert(v.end(), cbWrite, 0); - if (pvWrite) - CopyMemory(&v[v.size() - cbWrite], pvWrite, cbWrite); - } - template - void Write(T t) { - Write(&t, sizeof(T)); - } - void WriteString(LPCWSTR psz) { - Write(psz, (lstrlenW(psz) + 1) * sizeof(WCHAR)); - } - - private: - std::vector v; -}; - -INT_PTR CALLBACK DialogProcedureCallback(HWND dialog_handle, - UINT message, - WPARAM w_param, - LPARAM l_param) { - SB_CHECK(!g_current_dialog_handle || dialog_handle == g_current_dialog_handle) - << "Received callback on non-active dialog! Only one dialog at a time is " - "supported."; - switch (message) { - case WM_INITDIALOG: - return TRUE; - case WM_COMMAND: - auto command_id = GET_WM_COMMAND_ID(w_param, l_param); - if (command_id == IDCANCEL) { - g_cancel_callback(); - } else if (command_id == IDOK) { - g_ok_callback(); - } else { - return FALSE; - } - EndDialog(dialog_handle, 0); - g_current_dialog_handle = nullptr; - return TRUE; - } - return FALSE; -} - -namespace starboard { -namespace shared { -namespace win32 { - -bool ShowOkCancelDialog(HWND hwnd, - const std::string& title, - const std::string& message, - const std::string& ok_message, - DialogCallback ok_callback, - const std::string& cancel_message, - DialogCallback cancel_callback) { - if (g_current_dialog_handle != nullptr) { - SB_LOG(WARNING) << "Already showing a dialog; cancelling existing and " - "replacing with new dialog"; - CancelDialog(); - } - g_ok_callback = ok_callback; - g_cancel_callback = cancel_callback; - // Get the device context (DC) and from the system so we can scale our fonts - // correctly. - HDC hdc = GetDC(NULL); - SB_CHECK(hdc); - NONCLIENTMETRICSW ncm = {sizeof(ncm)}; - bool retrieved_system_params = - SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); - - if (!retrieved_system_params) { - DebugLogWinError(); - ReleaseDC(NULL, hdc); - return false; - } - DialogTemplateBuilder dialog_template; - const int help_id = 0; - const int extended_style = 0; - - const int window_width = 200; - const int window_height = 80; - const int window_x = 32; - const int window_y = 32; - - const int edge_padding = 7; - - const int button_height = 14; - const int button_width = 50; - const int button_y = window_height - button_height - edge_padding; - const int left_button_x = window_width / 2 - button_width - edge_padding / 2; - const int right_button_x = window_width / 2 + edge_padding / 2; - const int text_width = window_width - edge_padding * 2; - const int text_height = window_width - edge_padding * 3 - button_height; - const int extra_data = 0; - - // Create a dialog template. - // The following MSDN blogposts explains how this is all laid out: - // https://blogs.msdn.microsoft.com/oldnewthing/20040623-00/?p=38753 - // https://blogs.msdn.microsoft.com/oldnewthing/20050429-00/?p=35743 - // More official documentation: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644996(v=vs.85).aspx#modeless_box - dialog_template.Write(1); // dialog version - dialog_template.Write(0xFFFF); // extended dialog template - dialog_template.Write(help_id); - dialog_template.Write(extended_style); - dialog_template.Write(WS_CAPTION | WS_SYSMENU | DS_SETFONT | - DS_MODALFRAME); - dialog_template.Write(3); // number of controls - dialog_template.Write(window_x); - dialog_template.Write(window_y); - dialog_template.Write(window_width); - dialog_template.Write(window_height); - dialog_template.WriteString(L""); // no menu - dialog_template.WriteString(L""); // default dialog class - // Title. - dialog_template.WriteString( - (LPCWSTR)starboard::shared::win32::CStringToWString(title.c_str()) - .c_str()); - - // See following for info on how the font styling is calculated: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ff684173(v=vs.85).aspx - if (ncm.lfMessageFont.lfHeight < 0) { - ncm.lfMessageFont.lfHeight = - -MulDiv(ncm.lfMessageFont.lfHeight, 72, GetDeviceCaps(hdc, LOGPIXELSY)); - } - dialog_template.Write((WORD)ncm.lfMessageFont.lfHeight); - dialog_template.Write((WORD)ncm.lfMessageFont.lfWeight); - dialog_template.Write(ncm.lfMessageFont.lfItalic); - dialog_template.Write(ncm.lfMessageFont.lfCharSet); - dialog_template.WriteString(ncm.lfMessageFont.lfFaceName); - - // Message text. - dialog_template.AlignToDword(); - dialog_template.Write(help_id); - dialog_template.Write(extended_style); - dialog_template.Write(WS_CHILD | WS_VISIBLE); - dialog_template.Write(edge_padding); - dialog_template.Write(edge_padding); - dialog_template.Write(text_width); - dialog_template.Write(text_height); - dialog_template.Write((DWORD)-1); - dialog_template.Write(0x0082FFFF); - dialog_template.WriteString( - (LPCWSTR)starboard::shared::win32::CStringToWString(message.c_str()) - .c_str()); - dialog_template.Write(extra_data); - - // Cancel button. - dialog_template.AlignToDword(); - dialog_template.Write(help_id); - dialog_template.Write(extended_style); - dialog_template.Write(WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | - BS_DEFPUSHBUTTON); - dialog_template.Write(left_button_x); - dialog_template.Write(button_y); - dialog_template.Write(button_width); - dialog_template.Write(button_height); - dialog_template.Write(IDCANCEL); - dialog_template.Write(0x0080FFFF); - dialog_template.WriteString( - (LPCWSTR)starboard::shared::win32::CStringToWString( - cancel_message.c_str()) - .c_str()); - dialog_template.Write(extra_data); - - // Ok button. - dialog_template.AlignToDword(); - dialog_template.Write(help_id); - dialog_template.Write(extended_style); - dialog_template.Write(WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | - BS_DEFPUSHBUTTON); // style - dialog_template.Write(right_button_x); - dialog_template.Write(button_y); - dialog_template.Write(button_width); - dialog_template.Write(button_height); - dialog_template.Write(IDOK); - dialog_template.Write(0x0080FFFF); - dialog_template.WriteString( - (LPCWSTR)starboard::shared::win32::CStringToWString(ok_message.c_str()) - .c_str()); - dialog_template.Write(extra_data); - - ReleaseDC(NULL, hdc); - // Template is ready - go display it. - g_current_dialog_handle = CreateDialogIndirect( - GetModuleHandle(nullptr), dialog_template.BuildTemplate(), hwnd, - DialogProcedureCallback); - ShowWindow(g_current_dialog_handle, SW_SHOW); - return g_current_dialog_handle != nullptr; -} - -bool DialogHandleMessage(MSG* msg) { - return IsWindow(g_current_dialog_handle) && - IsDialogMessage(g_current_dialog_handle, msg); -} - -void CancelDialog() { - if (g_current_dialog_handle != nullptr) { - EndDialog(g_current_dialog_handle, 0); - g_current_dialog_handle = nullptr; - } -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/dialog.h b/starboard/shared/win32/dialog.h deleted file mode 100644 index cbff87e4869c..000000000000 --- a/starboard/shared/win32/dialog.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DIALOG_H_ -#define STARBOARD_SHARED_WIN32_DIALOG_H_ - -#include - -#include -#include - -namespace starboard { -namespace shared { -namespace win32 { - -typedef std::function DialogCallback; - -// Shows a modeless OK/Cancel-style dialog. Only one dialog may be shown at a -// time. -bool ShowOkCancelDialog(HWND hwnd, - const std::string& title, - const std::string& message, - const std::string& ok_message, - DialogCallback ok_callback, - const std::string& cancel_message, - DialogCallback cancel_callback); - -// Cancels the current dialog that is showing, if there is one. -void CancelDialog(); - -bool DialogHandleMessage(MSG* msg); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_DIALOG_H_ diff --git a/starboard/shared/win32/directory_can_open.cc b/starboard/shared/win32/directory_can_open.cc deleted file mode 100644 index 10707ad80947..000000000000 --- a/starboard/shared/win32/directory_can_open.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -bool SbDirectoryCanOpen(const char* path) { - using starboard::shared::win32::IsAbsolutePath; - using starboard::shared::win32::IsValidHandle; - using starboard::shared::win32::NormalizeWin32Path; - using starboard::shared::win32::TrimExtraFileSeparators; - - if ((path == nullptr) || (path[0] == '\0')) { - return false; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - TrimExtraFileSeparators(&path_wstring); - - if (!IsAbsolutePath(path_wstring)) { - return false; - } - - WIN32_FIND_DATA find_data = {0}; - - HANDLE search_handle = FindFirstFileExW( - path_wstring.c_str(), FindExInfoStandard, &find_data, - FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE); - if (!IsValidHandle(search_handle)) { - return false; - } - - FindClose(search_handle); - - return find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/directory_close.cc b/starboard/shared/win32/directory_close.cc deleted file mode 100644 index d5b7b692ad0c..000000000000 --- a/starboard/shared/win32/directory_close.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/shared/win32/directory_internal.h" - -bool SbDirectoryClose(SbDirectory directory) { - if (!SbDirectoryIsValid(directory)) { - return false; - } - - bool success = CloseHandle(directory->directory_handle); - - delete directory; - - return success; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/directory_create.cc b/starboard/shared/win32/directory_create.cc deleted file mode 100644 index 66f6e7ec0232..000000000000 --- a/starboard/shared/win32/directory_create.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/directory.h" - -#include -#include - -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -using starboard::shared::win32::DirectoryExists; -using starboard::shared::win32::DirectoryExistsOrCreated; -using starboard::shared::win32::IsAbsolutePath; -using starboard::shared::win32::NormalizeWin32Path; -using starboard::shared::win32::TrimExtraFileSeparators; - -bool SbDirectoryCreate(const char* path) { - if ((path == nullptr) || (path[0] == '\0')) { - return false; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - TrimExtraFileSeparators(&path_wstring); - - if (!IsAbsolutePath(path_wstring)) { - return false; - } - - return DirectoryExistsOrCreated(path_wstring); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/directory_get_next.cc b/starboard/shared/win32/directory_get_next.cc deleted file mode 100644 index e35ce0c9b0a5..000000000000 --- a/starboard/shared/win32/directory_get_next.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#if SB_API_VERSION < 17 -#include "starboard/directory.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { -// One of the entries of FILE_ID_BOTH_DIR_INFO is a file path, so make the -// buffer at-least one path big. -const std::size_t kDirectoryInfoBufferSize = - kSbFileMaxPath + sizeof(FILE_ID_BOTH_DIR_INFO); - -std::deque GetDirectoryEntries(HANDLE directory_handle) { - // According to - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa364226(v=vs.85).aspx, - // FILE_ID_BOTH_DIR_INFO must be aligned on a DWORDLONG boundary. - alignas(sizeof(DWORDLONG)) std::vector directory_info_buffer( - kDirectoryInfoBufferSize); - - std::deque entries; - BOOL directory_info_success = GetFileInformationByHandleEx( - directory_handle, FileIdBothDirectoryInfo, directory_info_buffer.data(), - static_cast(directory_info_buffer.size())); - - if (!directory_info_success) { - return entries; - } - - const char* directory_info_pointer = directory_info_buffer.data(); - DWORD next_entry_offset = 0; - - do { - auto directory_info = - reinterpret_cast(directory_info_pointer); - - // FileName is in Unicode, so divide by 2 to get the real length. - DWORD number_characters_in_filename = directory_info->FileNameLength / 2; - std::string ascii_path = starboard::shared::win32::wchar_tToUTF8( - directory_info->FileName, number_characters_in_filename); - SB_DCHECK(ascii_path.size() == number_characters_in_filename); - bool is_dotted_directory = - !ascii_path.compare(".") || !ascii_path.compare(".."); - if (!is_dotted_directory) { - entries.emplace_back(std::move(ascii_path)); - } - next_entry_offset = directory_info->NextEntryOffset; - directory_info_pointer += next_entry_offset; - } while (next_entry_offset != 0); - - return entries; -} - -} // namespace - -bool SbDirectoryGetNext(SbDirectory directory, - char* out_entry, - size_t out_entry_size) { - if (!SbDirectoryIsValid(directory) || out_entry == nullptr || - out_entry_size < kSbFileMaxName) { - return false; - } - - auto& next_directory_entries = directory->next_directory_entries; - if (next_directory_entries.empty()) { - next_directory_entries = GetDirectoryEntries(directory->directory_handle); - } - - if (next_directory_entries.empty()) { - return false; - } - - bool success = true; - if (starboard::strlcpy(out_entry, next_directory_entries.rbegin()->c_str(), - static_cast(out_entry_size)) >= out_entry_size) { - success = false; - } - directory->next_directory_entries.pop_back(); - return success; -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/directory_internal.cc b/starboard/shared/win32/directory_internal.cc deleted file mode 100644 index 0e665db38c1b..000000000000 --- a/starboard/shared/win32/directory_internal.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/directory_internal.h" - -#include "starboard/directory.h" - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/configuration_constants.h" -#include "starboard/memory.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/win32/file_internal.h" - -namespace starboard { -namespace shared { -namespace win32 { - -bool HasValidHandle(SbDirectory directory) { - if (!SbDirectoryIsValid(directory)) { - return false; - } - return directory->HasValidHandle(); -} - -// This function strips trailing file separators from a directory name. -// For example if the directory name was "C:\\Temp\\\\\\", it would -// strip them, so that the directory name is now to be "C:\\temp". -void TrimExtraFileSeparators(std::wstring* dirname_pointer) { - SB_DCHECK(dirname_pointer); - std::wstring& dirname = *dirname_pointer; - auto new_end = std::find_if_not( - dirname.rbegin(), dirname.rend(), - [](wchar_t c) { return c == kSbFileSepChar || c == kSbFileAltSepChar; }); - dirname.erase(new_end.base(), dirname.end()); -} - -bool IsAbsolutePath(const std::wstring& path) { - std::vector full_path(kSbFileMaxPath); - DWORD full_path_size = - GetFullPathNameW(path.c_str(), static_cast(full_path.size()), - full_path.data(), NULL); - if (full_path_size == 0) { - return false; - } - - int path_size = static_cast(path.size()); - return CompareStringEx(LOCALE_NAME_USER_DEFAULT, NORM_IGNORECASE, - path.c_str(), path_size, full_path.data(), - full_path_size, NULL, NULL, 0) == CSTR_EQUAL; -} - -bool DirectoryExists(const std::wstring& dir_path) { - if (dir_path.empty()) { - return false; - } - std::wstring norm_dir_path = NormalizeWin32Path(dir_path); - WIN32_FILE_ATTRIBUTE_DATA attribute_data = {0}; - if (!GetFileAttributesExW(norm_dir_path.c_str(), GetFileExInfoStandard, - &attribute_data)) { - // If this is system folder GetFileAttributesExW returns FALSE - // but the folder exists - return GetLastError() == ERROR_ACCESS_DENIED; - } - return (attribute_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); -} - -bool CreateDirectoryHierarchy(const std::wstring& wfull_path) { - if (DirectoryExistsOrCreated(wfull_path)) { - return true; - } - const wchar_t kPathSeparators[] = {static_cast(kSbFileSepChar), - static_cast(kSbFileAltSepChar)}; - size_t path_end = 0; - do { - path_end = wfull_path.find_first_of(kPathSeparators, path_end, - SB_ARRAY_SIZE(kPathSeparators)); - if (path_end == std::wstring::npos) { - path_end = wfull_path.size(); - } - std::wstring temp_path = wfull_path.substr(0, path_end); - DirectoryExistsOrCreated(temp_path); - } while (path_end < wfull_path.size()); - - return DirectoryExistsOrCreated(wfull_path); -} - -bool DirectoryExistsOrCreated(const std::wstring& wpath) { - return DirectoryExists(wpath) || CreateDirectoryW(wpath.c_str(), NULL); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/directory_internal.h b/starboard/shared/win32/directory_internal.h deleted file mode 100644 index 4fce048fdb24..000000000000 --- a/starboard/shared/win32/directory_internal.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DIRECTORY_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_DIRECTORY_INTERNAL_H_ - -#include "starboard/directory.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/win32/file_internal.h" - -#pragma warning(push) - -// SbFilePrivate is defined as a struct, but for windows implementation -// enough functionality has been added so that it warrants being a class -// per Google's C++ style guide. This mismatch causes the Microsoft's compiler -// to generate a warning. -#pragma warning(disable : 4099) - -class SbDirectoryPrivate { - public: - explicit SbDirectoryPrivate(HANDLE handle) : directory_handle(handle) {} - - bool HasValidHandle() const { - return starboard::shared::win32::IsValidHandle(directory_handle); - } - - HANDLE directory_handle; - std::deque next_directory_entries; - - // SbDirectoryPrivate is neither copyable nor movable. - SbDirectoryPrivate(const SbDirectoryPrivate&) = delete; - SbDirectoryPrivate& operator=(const SbDirectoryPrivate&) = delete; -}; -#pragma warning(pop) - -namespace starboard { -namespace shared { -namespace win32 { - -bool HasValidHandle(SbDirectory directory); - -// This function strips trailing file separators from a directory name. -// For example if the directory name was "C:\\Temp\\\\\\", it would -// strip them, so that the directory name is now to be "C:\\temp". -void TrimExtraFileSeparators(std::wstring* dirname_pointer); - -bool IsAbsolutePath(const std::wstring& path); - -bool DirectoryExists(const std::wstring& dir_path); - -// Directory hierarchy is created from tip down to root. This is necessary -// because UWP has issues with bottom up directory creation due to permissions. -bool CreateDirectoryHierarchy(const std::wstring& wfull_path); - -bool DirectoryExistsOrCreated(const std::wstring& wpath); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_DIRECTORY_INTERNAL_H_ diff --git a/starboard/shared/win32/directory_open.cc b/starboard/shared/win32/directory_open.cc deleted file mode 100644 index 8fccfee9dc02..000000000000 --- a/starboard/shared/win32/directory_open.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/directory.h" - -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -SbDirectory SbDirectoryOpen(const char* path, SbFileError* out_error) { - using starboard::shared::win32::CStringToWString; - using starboard::shared::win32::NormalizeWin32Path; - - if ((path == nullptr) || (path[0] == '\0')) { - if (out_error) { - *out_error = kSbFileErrorNotFound; - } - return kSbDirectoryInvalid; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - - if (!starboard::shared::win32::IsAbsolutePath(path_wstring)) { - if (out_error) { - *out_error = kSbFileErrorNotFound; - } - return kSbDirectoryInvalid; - } - - HANDLE directory_handle = starboard::shared::win32::OpenFileOrDirectory( - path, kSbFileOpenOnly | kSbFileRead, nullptr, out_error); - - if (!starboard::shared::win32::IsValidHandle(directory_handle)) { - return kSbDirectoryInvalid; - } - - FILE_BASIC_INFO basic_info = {0}; - BOOL basic_info_success = GetFileInformationByHandleEx( - directory_handle, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)); - - if (!basic_info_success || - !(basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - CloseHandle(directory_handle); - if (out_error) { - *out_error = kSbFileErrorNotADirectory; - } - return kSbDirectoryInvalid; - } - - return new SbDirectoryPrivate(directory_handle); -} -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/drm_create_system.cc b/starboard/shared/win32/drm_create_system.cc deleted file mode 100644 index db73316430d5..000000000000 --- a/starboard/shared/win32/drm_create_system.cc +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/drm.h" - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/win32/drm_system_playready.h" - -SbDrmSystem SbDrmCreateSystem( - const char* key_system, - void* context, - SbDrmSessionUpdateRequestFunc update_request_callback, - SbDrmSessionUpdatedFunc session_updated_callback, - SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, - SbDrmServerCertificateUpdatedFunc server_certificate_updated_callback, - SbDrmSessionClosedFunc session_closed_callback) { - using ::starboard::shared::win32::DrmSystemPlayready; - - if (!update_request_callback || !session_updated_callback || - !key_statuses_changed_callback || !server_certificate_updated_callback || - !session_closed_callback) { - SB_DLOG(WARNING) << "Callback functions not set on key system: " - << key_system; - return kSbDrmSystemInvalid; - } - - if (DrmSystemPlayready::IsKeySystemSupported(key_system)) { - return new DrmSystemPlayready( - context, []() { return false; }, // Output protection not supported - update_request_callback, session_updated_callback, - key_statuses_changed_callback, session_closed_callback); - } - - SB_DLOG(WARNING) << "Invalid key system " << key_system; - return kSbDrmSystemInvalid; -} diff --git a/starboard/shared/win32/drm_system_playready.cc b/starboard/shared/win32/drm_system_playready.cc deleted file mode 100644 index 844283d22745..000000000000 --- a/starboard/shared/win32/drm_system_playready.cc +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/drm_system_playready.h" - -#include -#include -#include -#include - -#include "starboard/common/instance_counter.h" -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/common/string.h" -#include "starboard/configuration.h" -#include "starboard/memory.h" -#include "starboard/shared/starboard/media/mime_type.h" - -namespace { - -const char kPlayReadyKeySystem[] = "com.youtube.playready"; -const bool kLogPlayreadyChallengeResponse = false; - -DECLARE_INSTANCE_COUNTER(DrmSystemPlayready); - -std::string GetHexRepresentation(const void* data, size_t size) { - const char kHex[] = "0123456789ABCDEF"; - - std::stringstream representation; - std::stringstream ascii; - const uint8_t* binary = static_cast(data); - bool new_line = true; - for (size_t i = 0; i < size; ++i) { - if (new_line) { - new_line = false; - } else { - representation << ' '; - } - ascii << (std::isprint(binary[i]) ? static_cast(binary[i]) : '?'); - representation << kHex[binary[i] / 16] << kHex[binary[i] % 16]; - if (i % 16 == 15 && i != size - 1) { - representation << " (" << ascii.str() << ')' << std::endl; - std::stringstream empty; - ascii.swap(empty); // Clear the ascii stream - new_line = true; - } - } - - if (!ascii.str().empty()) { - representation << '(' << ascii.str() << ')' << std::endl; - } - - return representation.str(); -} - -template -std::string GetHexRepresentation(const T& value) { - return GetHexRepresentation(&value, sizeof(T)); -} - -class ActiveDrmSystems { - public: - ::starboard::Mutex mutex_; - std::vector active_systems_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(ActiveDrmSystems, GetActiveDrmSystems); - -} // namespace - -namespace starboard { -namespace shared { -namespace win32 { - -void DrmSystemOnUwpResume() { - ::starboard::ScopedLock lock(GetActiveDrmSystems()->mutex_); - for (DrmSystemPlayready* item : GetActiveDrmSystems()->active_systems_) { - item->OnUwpResume(); - } -} - -DrmSystemPlayready::DrmSystemPlayready( - void* context, - EnableOutputProtectionFunc enable_output_protection_func, - SbDrmSessionUpdateRequestFunc session_update_request_callback, - SbDrmSessionUpdatedFunc session_updated_callback, - SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, - SbDrmSessionClosedFunc session_closed_callback) - : context_(context), - enable_output_protection_func_(enable_output_protection_func), - session_update_request_callback_(session_update_request_callback), - session_updated_callback_(session_updated_callback), - key_statuses_changed_callback_(key_statuses_changed_callback), - session_closed_callback_(session_closed_callback) { - SB_DCHECK(enable_output_protection_func); - SB_DCHECK(session_update_request_callback); - SB_DCHECK(session_updated_callback); - SB_DCHECK(key_statuses_changed_callback); - SB_DCHECK(session_closed_callback); - - ON_INSTANCE_CREATED(DrmSystemPlayready); - - ScopedLock lock(GetActiveDrmSystems()->mutex_); - GetActiveDrmSystems()->active_systems_.push_back(this); -} - -DrmSystemPlayready::~DrmSystemPlayready() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - ON_INSTANCE_RELEASED(DrmSystemPlayready); - - ScopedLock lock(GetActiveDrmSystems()->mutex_); - auto& active_systems = GetActiveDrmSystems()->active_systems_; - active_systems.erase( - std::remove(active_systems.begin(), active_systems.end(), this)); -} - -bool DrmSystemPlayready::IsKeySystemSupported(const char* key_system) { - SB_DCHECK(key_system); - - // It is possible that the |key_system| comes with extra attributes, like - // `com.youtube.playready; encryptionscheme="cenc"`. We prepend "key_system/" - // to it, so it can be parsed by MimeType. - starboard::media::MimeType mime_type(std::string("key_system/") + key_system); - - if (!mime_type.is_valid()) { - return false; - } - SB_DCHECK(mime_type.type() == "key_system"); - if (mime_type.subtype() != kPlayReadyKeySystem) { - return false; - } - - for (int i = 0; i < mime_type.GetParamCount(); ++i) { - if (mime_type.GetParamName(i) == "encryptionscheme") { - auto value = mime_type.GetParamStringValue(i); - if (value != "cenc") { - return false; - } - } - } - - return true; -} - -void DrmSystemPlayready::GenerateSessionUpdateRequest( - int ticket, - const char* type, - const void* initialization_data, - int initialization_data_size) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - if (strcmp("cenc", type) != 0) { - SB_NOTREACHED() << "Invalid initialization data type " << type; - return; - } - - std::string session_id = GenerateAndAdvanceSessionId(); - scoped_refptr license = - License::Create(initialization_data, initialization_data_size); - const std::string& challenge = license->license_challenge(); - if (challenge.empty()) { - // Signal an error with |session_id| as NULL. - SB_LOG(ERROR) << "Failed to generate license challenge"; - session_update_request_callback_( - this, context_, ticket, kSbDrmStatusUnknownError, - kSbDrmSessionRequestTypeLicenseRequest, NULL, NULL, 0, NULL, 0, NULL); - return; - } - - SB_LOG(INFO) << "Send challenge for key id " - << GetHexRepresentation(license->key_id()) << " in session " - << session_id; - SB_LOG_IF(INFO, kLogPlayreadyChallengeResponse) - << GetHexRepresentation(challenge.data(), challenge.size()); - - session_update_request_callback_( - this, context_, ticket, kSbDrmStatusSuccess, - kSbDrmSessionRequestTypeLicenseRequest, NULL, session_id.c_str(), - static_cast(session_id.size()), challenge.c_str(), - static_cast(challenge.size()), NULL); - pending_requests_[session_id] = license; -} - -void DrmSystemPlayready::UpdateSession(int ticket, - const void* key, - int key_size, - const void* session_id, - int session_id_size) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - std::string session_id_copy(static_cast(session_id), - session_id_size); - auto iter = pending_requests_.find(session_id_copy); - SB_DCHECK(iter != pending_requests_.end()); - if (iter == pending_requests_.end()) { - SB_NOTREACHED() << "Invalid session id " << session_id_copy; - return; - } - - scoped_refptr license = iter->second; - - SB_LOG(INFO) << "Adding playready response for key id " - << GetHexRepresentation(license->key_id()); - SB_LOG_IF(INFO, kLogPlayreadyChallengeResponse) - << GetHexRepresentation(key, key_size); - - license->UpdateLicense(key, key_size); - - if (license->usable()) { - SB_LOG(INFO) << "Successfully add key for key id " - << GetHexRepresentation(license->key_id()) << " in session " - << session_id_copy; - { - ScopedLock lock(mutex_); - successful_requests_[iter->first] = - LicenseInfo(kSbDrmKeyStatusUsable, license); - } - session_updated_callback_(this, context_, ticket, kSbDrmStatusSuccess, NULL, - session_id, session_id_size); - - { - ScopedLock lock(mutex_); - ReportKeyStatusChanged_Locked(session_id_copy); - } - pending_requests_.erase(iter); - } else { - SB_LOG(INFO) << "Failed to add key for session " << session_id_copy; - // Don't report it as a failure as otherwise the JS player is going to - // terminate the video. - session_updated_callback_(this, context_, ticket, kSbDrmStatusSuccess, NULL, - session_id, session_id_size); - // When UpdateLicense() fails, the |license| must have generated a new - // challenge internally. Send this challenge again. - const std::string& challenge = license->license_challenge(); - if (challenge.empty()) { - SB_NOTREACHED(); - return; - } - - SB_LOG(INFO) << "Send challenge again for key id " - << GetHexRepresentation(license->key_id()) << " in session " - << session_id; - SB_LOG_IF(INFO, kLogPlayreadyChallengeResponse) - << GetHexRepresentation(challenge.data(), challenge.size()); - - // We have to use |kSbDrmTicketInvalid| as the license challenge is not a - // result of GenerateSessionUpdateRequest(). - session_update_request_callback_( - this, context_, kSbDrmTicketInvalid, kSbDrmStatusSuccess, - kSbDrmSessionRequestTypeLicenseRequest, NULL, session_id, - session_id_size, challenge.c_str(), static_cast(challenge.size()), - NULL); - } -} - -void DrmSystemPlayready::CloseSession(const void* session_id, - int session_id_size) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - key_statuses_changed_callback_(this, context_, session_id, session_id_size, 0, - nullptr, nullptr); - - std::string session_id_copy(static_cast(session_id), - session_id_size); - pending_requests_.erase(session_id_copy); - - ScopedLock lock(mutex_); - successful_requests_.erase(session_id_copy); -} - -SbDrmSystemPrivate::DecryptStatus DrmSystemPlayready::Decrypt( - InputBuffer* buffer) { - const SbDrmSampleInfo* drm_info = buffer->drm_info(); - - if (drm_info == NULL || drm_info->initialization_vector_size == 0) { - return kSuccess; - } - - GUID key_id; - if (drm_info->identifier_size != sizeof(key_id)) { - return kRetry; - } - key_id = *reinterpret_cast(drm_info->identifier); - - ScopedLock lock(mutex_); - for (auto& item : successful_requests_) { - if (item.second.license_->key_id() == key_id) { - if (buffer->sample_type() == kSbMediaTypeAudio) { - return kSuccess; - } - - if (item.second.license_->IsHDCPRequired()) { - if (!enable_output_protection_func_()) { - SB_LOG(INFO) << "HDCP required but not available"; - item.second.status_ = kSbDrmKeyStatusRestricted; - ReportKeyStatusChanged_Locked(item.first); - return kRetry; - } - } - - return kSuccess; - } - } - - return kRetry; -} - -void DrmSystemPlayready::ReportKeyStatusChanged_Locked( - const std::string& session_id) { - // mutex_ must be held by caller - ::starboard::ScopedTryLock lock_should_fail(mutex_); - SB_DCHECK(!lock_should_fail.is_locked()); - - LicenseInfo& item = successful_requests_[session_id]; - - GUID key_id = item.license_->key_id(); - SbDrmKeyId drm_key_id; - SB_DCHECK(sizeof(drm_key_id.identifier) >= sizeof(key_id)); - memcpy(&(drm_key_id.identifier), &key_id, sizeof(key_id)); - drm_key_id.identifier_size = sizeof(key_id); - - key_statuses_changed_callback_(this, context_, session_id.data(), - static_cast(session_id.size()), 1, - &drm_key_id, &(item.status_)); -} - -scoped_refptr DrmSystemPlayready::GetLicense( - const uint8_t* key_id, - int key_id_size) { - GUID key_id_copy; - if (key_id_size != sizeof(key_id_copy)) { - return NULL; - } - key_id_copy = *reinterpret_cast(key_id); - - ScopedLock lock(mutex_); - - for (auto& item : successful_requests_) { - if (item.second.license_->key_id() == key_id_copy) { - return item.second.license_; - } - } - - return NULL; -} - -void DrmSystemPlayready::OnUwpResume() { - for (auto& item : successful_requests_) { - session_closed_callback_(this, context_, item.first.data(), - static_cast(item.first.size())); - } -} - -std::string DrmSystemPlayready::GenerateAndAdvanceSessionId() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - std::stringstream ss; - ss << current_session_id_; - ++current_session_id_; - return ss.str(); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/drm_system_playready.h b/starboard/shared/win32/drm_system_playready.h deleted file mode 100644 index cda8653f757b..000000000000 --- a/starboard/shared/win32/drm_system_playready.h +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DRM_SYSTEM_PLAYREADY_H_ -#define STARBOARD_SHARED_WIN32_DRM_SYSTEM_PLAYREADY_H_ - -#include -#include -#include -#include - -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/shared/starboard/drm/drm_system_internal.h" -#include "starboard/shared/starboard/thread_checker.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// Adapts PlayReady decryption module to Starboard's |SbDrmSystem|. -class DrmSystemPlayready : public SbDrmSystemPrivate { - public: - typedef std::function EnableOutputProtectionFunc; - - class License : public RefCountedThreadSafe { - public: - static scoped_refptr Create(const void* initialization_data, - int initialization_data_size); - - virtual ~License() {} - - virtual GUID key_id() const = 0; - virtual bool usable() const = 0; - virtual std::string license_challenge() const = 0; - virtual Microsoft::WRL::ComPtr decryptor() = 0; - virtual void UpdateLicense(const void* license, int license_size) = 0; - virtual bool IsHDCPRequired() = 0; - }; - - DrmSystemPlayready( - void* context, - EnableOutputProtectionFunc enable_output_protection_func, - SbDrmSessionUpdateRequestFunc session_update_request_callback, - SbDrmSessionUpdatedFunc session_updated_callback, - SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback, - SbDrmSessionClosedFunc session_closed_callback); - ~DrmSystemPlayready() override; - - static bool IsKeySystemSupported(const char* key_system); - - // From |SbDrmSystemPrivate|. - void GenerateSessionUpdateRequest(int ticket, - const char* type, - const void* initialization_data, - int initialization_data_size) override; - - void UpdateSession(int ticket, - const void* key, - int key_size, - const void* session_id, - int session_id_size) override; - - void CloseSession(const void* session_id, int session_id_size) override; - - DecryptStatus Decrypt(InputBuffer* buffer) override; - - // Used by audio and video decoders to retrieve the decryptors. - scoped_refptr GetLicense(const uint8_t* key_id, int key_id_size); - - void OnUwpResume(); - - bool IsServerCertificateUpdatable() override { return false; } - void UpdateServerCertificate(int ticket, - const void* certificate, - int certificate_size) override {} - - const void* GetMetrics(int* size) override { return NULL; } - - private: - std::string GenerateAndAdvanceSessionId(); - // Note: requires mutex_ to be held - void ReportKeyStatusChanged_Locked(const std::string& session_id); - - ::starboard::shared::starboard::ThreadChecker thread_checker_; - - void* context_; - const EnableOutputProtectionFunc enable_output_protection_func_; - const SbDrmSessionUpdateRequestFunc session_update_request_callback_; - const SbDrmSessionUpdatedFunc session_updated_callback_; - const SbDrmSessionKeyStatusesChangedFunc key_statuses_changed_callback_; - const SbDrmSessionClosedFunc session_closed_callback_; - int current_session_id_ = 1; - - std::map > pending_requests_; - - // |successful_requests_| can be accessed from more than one thread. Guard - // it by a mutex. - Mutex mutex_; - - struct LicenseInfo { - LicenseInfo(SbDrmKeyStatus status, const scoped_refptr& license) - : status_(status), license_(license) {} - LicenseInfo() : status_(kSbDrmKeyStatusError) {} - - SbDrmKeyStatus status_; - scoped_refptr license_; - }; - - std::map successful_requests_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_DRM_SYSTEM_PLAYREADY_H_ diff --git a/starboard/shared/win32/dx_context_video_decoder.cc b/starboard/shared/win32/dx_context_video_decoder.cc deleted file mode 100644 index b576659c87bb..000000000000 --- a/starboard/shared/win32/dx_context_video_decoder.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/dx_context_video_decoder.h" - -#include -#include -#include - -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" - -#include "starboard/common/log.h" - -namespace starboard { -namespace shared { -namespace win32 { - -HardwareDecoderContext GetDirectXForHardwareDecoding() { - HRESULT result = S_OK; - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - PFNEGLQUERYDISPLAYATTRIBEXTPROC query_display; - - query_display = reinterpret_cast( - eglGetProcAddress("eglQueryDisplayAttribEXT")); - SB_DCHECK(query_display != nullptr); - - PFNEGLQUERYDEVICEATTRIBEXTPROC query_device; - query_device = reinterpret_cast( - eglGetProcAddress("eglQueryDeviceAttribEXT")); - SB_DCHECK(query_device != nullptr); - - intptr_t egl_device = 0; - query_display(display, EGL_DEVICE_EXT, &egl_device); - SB_DCHECK(egl_device != 0); - - intptr_t device = 0; - query_device(reinterpret_cast(egl_device), - EGL_D3D11_DEVICE_ANGLE, &device); - - Microsoft::WRL::ComPtr output_dx_device = - reinterpret_cast(device); - Microsoft::WRL::ComPtr dxgi_device_mgr; - - UINT token = 0; - result = MFCreateDXGIDeviceManager(&token, &dxgi_device_mgr); - SB_DCHECK(result == S_OK); - SB_DCHECK(dxgi_device_mgr); - - result = dxgi_device_mgr->ResetDevice(output_dx_device.Get(), token); - SB_DCHECK(SUCCEEDED(result)); - - HardwareDecoderContext output = {output_dx_device, dxgi_device_mgr}; - return output; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/dx_context_video_decoder.h b/starboard/shared/win32/dx_context_video_decoder.h deleted file mode 100644 index ece217275057..000000000000 --- a/starboard/shared/win32/dx_context_video_decoder.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_DX_CONTEXT_VIDEO_DECODER_H_ -#define STARBOARD_SHARED_WIN32_DX_CONTEXT_VIDEO_DECODER_H_ - -#include // For ComPtr. - -struct ID3D11Device; -struct ID3D11DeviceContext; -struct IMFDXGIDeviceManager; - -namespace starboard { -namespace shared { -namespace win32 { - -struct HardwareDecoderContext { - Microsoft::WRL::ComPtr dx_device_out; - Microsoft::WRL::ComPtr dxgi_device_manager_out; -}; - -HardwareDecoderContext GetDirectXForHardwareDecoding(); - -} // namespace win32 -} // namespace shared -} // namespace starboard -#endif // STARBOARD_SHARED_WIN32_DX_CONTEXT_VIDEO_DECODER_H_ diff --git a/starboard/shared/win32/environment.cc b/starboard/shared/win32/environment.cc deleted file mode 100644 index bba9b00f2c6e..000000000000 --- a/starboard/shared/win32/environment.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "starboard/shared/environment.h" - -namespace starboard { - -std::string GetEnvironment(std::string name) { - std::wstring w_name(name.begin(), name.end()); - DWORD len = GetEnvironmentVariable(w_name.c_str(), nullptr, 0); - if (len == 0) - return ""; - std::wstring w_environment_string(len, 0); - GetEnvironmentVariable(w_name.c_str(), &w_environment_string[0], len); - std::string environment_string(w_environment_string.begin(), - w_environment_string.end()); - return environment_string; -} - -} // namespace starboard diff --git a/starboard/shared/win32/error_utils.cc b/starboard/shared/win32/error_utils.cc deleted file mode 100644 index a14304ba9308..000000000000 --- a/starboard/shared/win32/error_utils.cc +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#include "starboard/shared/win32/error_utils.h" - -#include -#include -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace starboard { -namespace shared { -namespace win32 { -namespace { - -std::string GetFormatHresultMessage(HRESULT hr) { - std::stringstream ss; - LPWSTR error_message; - int message_size = FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, // Unused with FORMAT_MESSAGE_FROM_SYSTEM. - hr, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&error_message, - 0, // Minimum size for output buffer. - nullptr); - SB_DCHECK(message_size); - ss << wchar_tToUTF8(error_message); - LocalFree(error_message); - return ss.str(); -} - -#define MAKE_HR_PAIR(X) std::pair(X, #X) -const std::pair kHresultValueStrings[] = { - MAKE_HR_PAIR(S_OK), - MAKE_HR_PAIR(MF_E_PLATFORM_NOT_INITIALIZED), - MAKE_HR_PAIR(MF_E_BUFFERTOOSMALL), - MAKE_HR_PAIR(MF_E_INVALIDREQUEST), - MAKE_HR_PAIR(MF_E_INVALIDSTREAMNUMBER), - MAKE_HR_PAIR(MF_E_INVALIDMEDIATYPE), - MAKE_HR_PAIR(MF_E_NOTACCEPTING), - MAKE_HR_PAIR(MF_E_NOT_INITIALIZED), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_REPRESENTATION), - MAKE_HR_PAIR(MF_E_NO_MORE_TYPES), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_SERVICE), - MAKE_HR_PAIR(MF_E_UNEXPECTED), - MAKE_HR_PAIR(MF_E_INVALIDNAME), - MAKE_HR_PAIR(MF_E_INVALIDTYPE), - MAKE_HR_PAIR(MF_E_INVALID_FILE_FORMAT), - MAKE_HR_PAIR(MF_E_INVALIDINDEX), - MAKE_HR_PAIR(MF_E_INVALID_TIMESTAMP), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_SCHEME), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_BYTESTREAM_TYPE), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_TIME_FORMAT), - MAKE_HR_PAIR(MF_E_NO_SAMPLE_TIMESTAMP), - MAKE_HR_PAIR(MF_E_NO_SAMPLE_DURATION), - MAKE_HR_PAIR(MF_E_INVALID_STREAM_DATA), - MAKE_HR_PAIR(MF_E_RT_UNAVAILABLE), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_RATE), - MAKE_HR_PAIR(MF_E_THINNING_UNSUPPORTED), - MAKE_HR_PAIR(MF_E_REVERSE_UNSUPPORTED), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_RATE_TRANSITION), - MAKE_HR_PAIR(MF_E_RATE_CHANGE_PREEMPTED), - MAKE_HR_PAIR(MF_E_NOT_FOUND), - MAKE_HR_PAIR(MF_E_NOT_AVAILABLE), - MAKE_HR_PAIR(MF_E_NO_CLOCK), - MAKE_HR_PAIR(MF_S_MULTIPLE_BEGIN), - MAKE_HR_PAIR(MF_E_MULTIPLE_BEGIN), - MAKE_HR_PAIR(MF_E_MULTIPLE_SUBSCRIBERS), - MAKE_HR_PAIR(MF_E_TIMER_ORPHANED), - MAKE_HR_PAIR(MF_E_STATE_TRANSITION_PENDING), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_STATE_TRANSITION), - MAKE_HR_PAIR(MF_E_UNRECOVERABLE_ERROR_OCCURRED), - MAKE_HR_PAIR(MF_E_SAMPLE_HAS_TOO_MANY_BUFFERS), - MAKE_HR_PAIR(MF_E_SAMPLE_NOT_WRITABLE), - MAKE_HR_PAIR(MF_E_INVALID_KEY), - MAKE_HR_PAIR(MF_E_BAD_STARTUP_VERSION), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_CAPTION), - MAKE_HR_PAIR(MF_E_INVALID_POSITION), - MAKE_HR_PAIR(MF_E_ATTRIBUTENOTFOUND), - MAKE_HR_PAIR(MF_E_PROPERTY_TYPE_NOT_ALLOWED), - MAKE_HR_PAIR(MF_E_TOPO_INVALID_OPTIONAL_NODE), - MAKE_HR_PAIR(MF_E_TOPO_CANNOT_FIND_DECRYPTOR), - MAKE_HR_PAIR(MF_E_TOPO_CODEC_NOT_FOUND), - MAKE_HR_PAIR(MF_E_TOPO_CANNOT_CONNECT), - MAKE_HR_PAIR(MF_E_TOPO_UNSUPPORTED), - MAKE_HR_PAIR(MF_E_TOPO_INVALID_TIME_ATTRIBUTES), - MAKE_HR_PAIR(MF_E_TOPO_LOOPS_IN_TOPOLOGY), - MAKE_HR_PAIR(MF_E_TOPO_MISSING_PRESENTATION_DESCRIPTOR), - MAKE_HR_PAIR(MF_E_TOPO_MISSING_STREAM_DESCRIPTOR), - MAKE_HR_PAIR(MF_E_TOPO_STREAM_DESCRIPTOR_NOT_SELECTED), - MAKE_HR_PAIR(MF_E_TOPO_MISSING_SOURCE), - MAKE_HR_PAIR(MF_E_TOPO_SINK_ACTIVATES_UNSUPPORTED), - MAKE_HR_PAIR(MF_E_TRANSFORM_TYPE_NOT_SET), - MAKE_HR_PAIR(MF_E_TRANSFORM_STREAM_CHANGE), - MAKE_HR_PAIR(MF_E_TRANSFORM_INPUT_REMAINING), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROFILE_MISSING), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROFILE_INVALID_OR_CORRUPT), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROFILE_TRUNCATED), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_PID_NOT_RECOGNIZED), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_VARIANT_TYPE_WRONG), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_NOT_WRITEABLE), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_ARRAY_VALUE_WRONG_NUM_DIM), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_VALUE_SIZE_WRONG), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_VALUE_OUT_OF_RANGE), - MAKE_HR_PAIR(MF_E_TRANSFORM_PROPERTY_VALUE_INCOMPATIBLE), - MAKE_HR_PAIR(MF_E_TRANSFORM_NOT_POSSIBLE_FOR_CURRENT_OUTPUT_MEDIATYPE), - MAKE_HR_PAIR(MF_E_TRANSFORM_NOT_POSSIBLE_FOR_CURRENT_INPUT_MEDIATYPE), - MAKE_HR_PAIR(MF_E_TRANSFORM_NOT_POSSIBLE_FOR_CURRENT_MEDIATYPE_COMBINATION), - MAKE_HR_PAIR( - MF_E_TRANSFORM_CONFLICTS_WITH_OTHER_CURRENTLY_ENABLED_FEATURES), - MAKE_HR_PAIR(MF_E_TRANSFORM_NEED_MORE_INPUT), - MAKE_HR_PAIR(MF_E_TRANSFORM_NOT_POSSIBLE_FOR_CURRENT_SPKR_CONFIG), - MAKE_HR_PAIR(MF_E_TRANSFORM_CANNOT_CHANGE_MEDIATYPE_WHILE_PROCESSING), - MAKE_HR_PAIR(MF_S_TRANSFORM_DO_NOT_PROPAGATE_EVENT), - MAKE_HR_PAIR(MF_E_UNSUPPORTED_D3D_TYPE), - MAKE_HR_PAIR(MF_E_TRANSFORM_ASYNC_LOCKED), - MAKE_HR_PAIR(MF_E_TRANSFORM_CANNOT_INITIALIZE_ACM_DRIVER), -}; -#undef MAKE_HR_PAIR - -bool FindHResultEnumString(HRESULT hr, std::string* output) { - const size_t n = sizeof(kHresultValueStrings) / sizeof(*kHresultValueStrings); - - for (auto i = 0; i < n; ++i) { - const auto& elems = kHresultValueStrings[i]; - if (hr == elems.first) { - *output = elems.second; - return true; - } - } - return false; -} - -} // namespace - -std::ostream& operator<<(std::ostream& os, const Win32ErrorCode& error_code) { - LPWSTR error_message; - int message_size = FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_IGNORE_INSERTS, - nullptr, // Unused with FORMAT_MESSAGE_FROM_SYSTEM. - error_code.GetHRESULT(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&error_message, - 0, // Minimum size for output buffer. - nullptr); - SB_DCHECK(message_size); - os << wchar_tToUTF8(error_message); - LocalFree(error_message); - - return os; -} - -void DebugLogWinError() { -#if defined(_DEBUG) - DWORD error_code = GetLastError(); - if (!error_code) - return; - - SB_LOG(ERROR) << Win32ErrorCode(error_code); -#endif // defined(_DEBUG) -} - -std::string HResultToString(HRESULT hr) { - std::string enum_str; - bool has_enum_str = FindHResultEnumString(hr, &enum_str); - std::string error_message = GetFormatHresultMessage(hr); - - std::stringstream ss; - if (has_enum_str) { - ss << enum_str << ": "; - } - - ss << "\"" << error_message << "\""; - return ss.str(); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/error_utils.h b/starboard/shared/win32/error_utils.h deleted file mode 100644 index 31a2f9ab5605..000000000000 --- a/starboard/shared/win32/error_utils.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Not breaking these functions up because however one is implemented, the -// others should be implemented similarly. - -#ifndef STARBOARD_SHARED_WIN32_ERROR_UTILS_H_ -#define STARBOARD_SHARED_WIN32_ERROR_UTILS_H_ - -#include - -#include -#include - -#include "starboard/common/log.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class Win32ErrorCode { - public: - explicit Win32ErrorCode(DWORD error_code) : error_code_(error_code) {} - - HRESULT GetHRESULT() const { return HRESULT_FROM_WIN32(error_code_); } - - private: - DWORD error_code_; -}; - -std::ostream& operator<<(std::ostream& os, const Win32ErrorCode& error_code); - -// Checks for system errors and logs a human-readable error if GetLastError() -// returns an error code. Noops on non-debug builds. -void DebugLogWinError(); - -std::string HResultToString(HRESULT hr); - -// The following macro evaluates statement in every build config, and checks the -// result in debug & devel builds only. -#define CheckResult(statement) \ - do { \ - auto check_result_hr = (statement); \ - SB_DCHECK(SUCCEEDED(check_result_hr)) \ - << "HRESULT was " << std::hex << check_result_hr \ - << " which translates to\n---> \"" \ - << ::starboard::shared::win32::HResultToString(check_result_hr) \ - << "\""; \ - } while (0) - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_ERROR_UTILS_H_ diff --git a/starboard/shared/win32/file_atomic_replace.cc b/starboard/shared/win32/file_atomic_replace.cc deleted file mode 100644 index 6b7dddcacfe1..000000000000 --- a/starboard/shared/win32/file_atomic_replace.cc +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/file.h" - -#include - -#include - -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/starboard/file_atomic_replace_write_file.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { - -const char kTempFileSuffix[] = ".temp"; - -} // namespace - -bool SbFileAtomicReplace(const char* path, - const char* data, - int64_t data_size) { - if ((data_size < 0) || ((data_size > 0) && !data)) { - return false; - } - - std::vector temp_path(kSbFileMaxPath + 1, 0); - - starboard::strlcpy(temp_path.data(), path, kSbFileMaxPath); - starboard::strlcat(temp_path.data(), kTempFileSuffix, kSbFileMaxPath); - - if (!::starboard::shared::starboard::SbFileAtomicReplaceWriteFile( - temp_path.data(), data, data_size)) { - return false; - } - - std::wstring path_wstring = starboard::shared::win32::NormalizeWin32Path( - starboard::shared::win32::CStringToWString(path)); - std::wstring temp_path_wstring = starboard::shared::win32::NormalizeWin32Path( - starboard::shared::win32::CStringToWString(temp_path.data())); - - // Try a simple move first. It will only succeed when |to_path| doesn't - // already exist. - if (MoveFileEx(temp_path_wstring.c_str(), path_wstring.c_str(), 0)) { - return true; - } - - // Try the full-blown replace if the move fails, as ReplaceFile will only - // succeed when |to_path| does exist. - if (ReplaceFile(path_wstring.c_str(), temp_path_wstring.c_str(), NULL, 0, - NULL, NULL)) { - return true; - } - return false; -} diff --git a/starboard/shared/win32/file_can_open.cc b/starboard/shared/win32/file_can_open.cc deleted file mode 100644 index 7744b103eec5..000000000000 --- a/starboard/shared/win32/file_can_open.cc +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -bool SbFileCanOpen(const char* path, int flags) { - if ((path == nullptr) || (path[0] == '\0')) { - return false; - } - - bool can_read = flags & kSbFileRead; - bool can_write = flags & kSbFileWrite; - if (!can_read && !can_write) { - return false; - } - - std::wstring path_wstring = starboard::shared::win32::CStringToWString(path); - WIN32_FIND_DATA find_data = {0}; - - HANDLE search_handle = FindFirstFileExW( - path_wstring.c_str(), FindExInfoStandard, &find_data, - FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE); - if (!starboard::shared::win32::IsValidHandle(search_handle)) { - return false; - } - - bool can_open = true; - - if (((find_data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) && can_write) || - !starboard::shared::win32::PathEndsWith(path_wstring, - find_data.cFileName)) { - can_open = false; - } - - FindClose(search_handle); - - return can_open; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_close.cc b/starboard/shared/win32/file_close.cc deleted file mode 100644 index fa47181459dc..000000000000 --- a/starboard/shared/win32/file_close.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/file_internal.h" - -using starboard::shared::win32::DebugLogWinError; - -bool SbFileClose(SbFile file) { - if (!SbFileIsValid(file)) { - return false; - } - - bool success = CloseHandle(file->file_handle); - - if (!success) { - DebugLogWinError(); - } - - delete file; - - return success; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_delete.cc b/starboard/shared/win32/file_delete.cc deleted file mode 100644 index d20cd80ed217..000000000000 --- a/starboard/shared/win32/file_delete.cc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -bool SbFileDelete(const char* path) { - using starboard::shared::win32::CStringToWString; - using starboard::shared::win32::NormalizeWin32Path; - - if ((path == nullptr) || *path == '\0') { - return false; - } - struct stat info; - if (stat(path, &info) != 0) { - return true; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - - // Remove file or empty directory. - return DeleteFileW(path_wstring.c_str()) || - RemoveDirectoryW(path_wstring.c_str()); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_exists.cc b/starboard/shared/win32/file_exists.cc deleted file mode 100644 index 70093daf6e29..000000000000 --- a/starboard/shared/win32/file_exists.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -#include - -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -bool SbFileExists(const char* path) { - using starboard::shared::win32::CStringToWString; - using starboard::shared::win32::IsValidHandle; - using starboard::shared::win32::NormalizeWin32Path; - using starboard::shared::win32::PathEndsWith; - - if ((path == nullptr) || (path[0] == '\0')) { - return false; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - // Win32 does not like a trailing "\\" on the path names for directories, - // so it's needs to be chopped off. - if (!path_wstring.empty() && (path_wstring.back() == '\\')) { - path_wstring.pop_back(); - } - - WIN32_FIND_DATA find_data = {0}; - - HANDLE search_handle = FindFirstFileExW( - path_wstring.c_str(), FindExInfoStandard, &find_data, - FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE); - - if (!IsValidHandle(search_handle)) { - return false; - } - - FindClose(search_handle); - - return PathEndsWith(path_wstring, find_data.cFileName); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/file_flush.cc b/starboard/shared/win32/file_flush.cc deleted file mode 100644 index ad566da0cc73..000000000000 --- a/starboard/shared/win32/file_flush.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" - -bool SbFileFlush(SbFile file) { - if (!starboard::shared::win32::HasValidHandle(file)) { - return false; - } - - return FlushFileBuffers(file->file_handle); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_get_info.cc b/starboard/shared/win32/file_get_info.cc deleted file mode 100644 index f4176e5b014f..000000000000 --- a/starboard/shared/win32/file_get_info.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/time_utils.h" - -bool SbFileGetInfo(SbFile file, SbFileInfo* out_info) { - if (!starboard::shared::win32::HasValidHandle(file) || !out_info) { - return false; - } - - FILE_BASIC_INFO basic_info = {0}; - BOOL basic_info_success = GetFileInformationByHandleEx( - file->file_handle, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)); - if (!basic_info_success) { - return false; - } - - FILE_STANDARD_INFO standard_info = {0}; - BOOL standard_info_success = - GetFileInformationByHandleEx(file->file_handle, FileStandardInfo, - &standard_info, sizeof(FILE_STANDARD_INFO)); - if (!standard_info_success) { - return false; - } - - out_info->size = standard_info.EndOfFile.QuadPart; - SB_DCHECK(out_info->size >= 0); - - using starboard::shared::win32::ConvertFileTimeTicksToUsec; - - out_info->creation_time = ConvertFileTimeTicksToUsec(basic_info.CreationTime); - out_info->last_accessed = - ConvertFileTimeTicksToUsec(basic_info.LastAccessTime); - out_info->last_modified = - ConvertFileTimeTicksToUsec(basic_info.LastWriteTime); - - out_info->is_symbolic_link = false; - out_info->is_directory = standard_info.Directory; - - return true; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_get_path_info.cc b/starboard/shared/win32/file_get_path_info.cc deleted file mode 100644 index 606af69ddd23..000000000000 --- a/starboard/shared/win32/file_get_path_info.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/file.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/time_utils.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { - -bool IsDriveLetter(wchar_t drive_letter) { - if (L'A' <= drive_letter && drive_letter <= 'Z') { - return true; - } - - if (L'a' <= drive_letter && drive_letter <= 'z') { - return true; - } - return false; -} - -bool IsRootDirectory(std::wstring wpath) { - if (wpath.length() > 3) { - return false; - } - - // Strip optional trailing slash. - if (wpath.length() == 3) { - if (wpath.back() != L'\\') { - return false; - } - wpath.pop_back(); - } - - if (wpath.length() == 2) { - if (IsDriveLetter(wpath[0]) && wpath[1] == ':') { - return true; - } - } - return false; -} - -} // namespace - -bool SbFileGetPathInfo(const char* path, SbFileInfo* out_info) { - using starboard::shared::win32::CStringToWString; - using starboard::shared::win32::NormalizeWin32Path; - - if (!path || path[0] == '\0' || !out_info) { - return false; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - - // GetFileAttributesExW(...) does not handle root directories - // we we have to handle it here. - if (IsRootDirectory(path_wstring)) { - out_info->is_directory = true; - out_info->last_modified = 0; - out_info->last_accessed = 0; - out_info->creation_time = 0; - return true; - } - - WIN32_FILE_ATTRIBUTE_DATA attribute_data = {0}; - if (!GetFileAttributesExW(path_wstring.c_str(), GetFileExInfoStandard, - &attribute_data)) { - return false; - } - - out_info->size = static_cast(attribute_data.nFileSizeHigh) << 32 | - attribute_data.nFileSizeLow; - SB_DCHECK(out_info->size >= 0); - - using starboard::shared::win32::ConvertFileTimeToUsec; - - out_info->creation_time = - ConvertFileTimeToUsec(attribute_data.ftCreationTime); - out_info->last_accessed = - ConvertFileTimeToUsec(attribute_data.ftLastAccessTime); - out_info->last_modified = - ConvertFileTimeToUsec(attribute_data.ftLastWriteTime); - - out_info->is_symbolic_link = false; - out_info->is_directory = - (attribute_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); - - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/file_internal.cc b/starboard/shared/win32/file_internal.cc deleted file mode 100644 index 0d4bea24d703..000000000000 --- a/starboard/shared/win32/file_internal.cc +++ /dev/null @@ -1,192 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/file_internal.h" - -#include -#include -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wchar_utils.h" - -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) - -namespace sbwin32 = starboard::shared::win32; - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { -const char kUnixSep[] = "/"; -const char kWin32Sep[] = "\\"; -const wchar_t kUnixSepW[] = L"/"; -const wchar_t kWin32SepW[] = L"\\"; - -bool IsPathNormalized(const std::string& string) { - return string.find(kUnixSep) == std::string::npos; -} - -bool IsPathNormalized(const std::wstring& string) { - return string.find(kUnixSepW) == std::wstring::npos; -} - -std::string NormalizePathSeparator(std::string str) { - size_t start_pos = 0; - while ((start_pos = str.find(kUnixSep, start_pos)) != std::string::npos) { - str.replace(start_pos, sizeof(kUnixSep) - 1, kWin32Sep); - start_pos += sizeof(kWin32Sep) - 1; - } - return str; -} - -std::wstring NormalizePathSeparator(std::wstring str) { - size_t start_pos = 0; - while ((start_pos = str.find(kUnixSepW, start_pos)) != std::wstring::npos) { - str.replace(start_pos, sizeof(kUnixSepW) / 2 - 1, kWin32SepW); - start_pos += sizeof(kWin32SepW) / 2 - 1; - } - return str; -} - -bool StringCanNarrow(const std::wstring& str) { - for (wchar_t value : str) { - char narrow_val = static_cast(value); - if (value != narrow_val) { - return false; - } - } - return true; -} - -} // namespace - -std::wstring NormalizeWin32Path(std::string str) { - return NormalizeWin32Path(CStringToWString(str.c_str())); -} - -std::wstring NormalizeWin32Path(std::wstring str) { - return NormalizePathSeparator(str); -} - -HANDLE OpenFileOrDirectory(const char* path, int flags) { - // Note that FILE_SHARE_DELETE allows a file to be deleted while there - // are other handles open for read/write. This is necessary for the - // Async file tests which, due to system timing, will sometimes have - // outstanding handles open and fail to delete, failing the test. - const DWORD share_mode = - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; - - DWORD desired_access = 0; - if ((flags & O_ACCMODE) == O_RDONLY) { - desired_access |= GENERIC_READ; - } else if ((flags & O_ACCMODE) == O_WRONLY) { - desired_access |= GENERIC_WRITE; - flags &= ~O_WRONLY; - } else if ((flags & O_ACCMODE) == O_RDWR) { - desired_access |= GENERIC_READ | GENERIC_WRITE; - flags &= ~O_RDWR; - } else { - // Applications shall specify exactly one of the first three file access - // modes. - errno = EINVAL; - return INVALID_HANDLE_VALUE; - } - - DWORD creation_disposition = 0; - if (!flags) { - creation_disposition = OPEN_EXISTING; - } - - if (flags & O_CREAT && flags & O_EXCL) { - SB_DCHECK(!creation_disposition); - creation_disposition = CREATE_NEW; - flags &= ~(O_CREAT | O_EXCL); - } - - if (flags & O_CREAT && flags & O_TRUNC) { - SB_DCHECK(!creation_disposition); - creation_disposition = CREATE_ALWAYS; - flags &= ~(O_CREAT | O_TRUNC); - } - - if (flags & O_TRUNC) { - SB_DCHECK(!creation_disposition); - SB_DCHECK((flags & O_WRONLY) || (flags & O_RDWR)); - creation_disposition = TRUNCATE_EXISTING; - flags &= ~O_TRUNC; - } - - if (flags & O_CREAT) { - SB_DCHECK(!creation_disposition); - creation_disposition = OPEN_ALWAYS; - flags &= ~O_CREAT; - } - - // SbFileOpen does not support any other combination of flags. - if (flags || !creation_disposition) { - errno = ENOTSUP; - return INVALID_HANDLE_VALUE; - } - - SB_DCHECK(desired_access != 0) << "Invalid permission flag."; - - std::wstring path_wstring = NormalizeWin32Path(path); - CREATEFILE2_EXTENDED_PARAMETERS create_ex_params = {0}; - // Enabling |FILE_FLAG_BACKUP_SEMANTICS| allows us to figure out if the path - // is a directory. - create_ex_params.dwFileFlags = FILE_FLAG_BACKUP_SEMANTICS; - create_ex_params.dwFileFlags |= FILE_FLAG_POSIX_SEMANTICS; - create_ex_params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; - create_ex_params.dwSecurityQosFlags = SECURITY_ANONYMOUS; - create_ex_params.dwSize = sizeof(CREATEFILE2_EXTENDED_PARAMETERS); - - HANDLE file_handle = - CreateFile2(path_wstring.c_str(), desired_access, share_mode, - creation_disposition, &create_ex_params); - - const DWORD last_error = GetLastError(); - - if (!starboard::shared::win32::IsValidHandle(file_handle)) { - switch (last_error) { - case ERROR_ACCESS_DENIED: - errno = EACCES; - break; - case ERROR_FILE_EXISTS: { - if (creation_disposition == CREATE_NEW) { - errno = EEXIST; - } else { - errno = EPERM; - } - break; - } - case ERROR_FILE_NOT_FOUND: - errno = ENOENT; - break; - default: - errno = EPERM; - } - } - - return file_handle; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/file_internal.h b/starboard/shared/win32/file_internal.h deleted file mode 100644 index 5cecb3b0d874..000000000000 --- a/starboard/shared/win32/file_internal.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_FILE_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_FILE_INTERNAL_H_ - -#include - -#include // This file included for std::wcslen. -#include - -#include "starboard/file.h" -#include "starboard/shared/internal_only.h" - -namespace starboard { -namespace shared { -namespace win32 { - -inline bool IsValidHandle(HANDLE handle) { - return handle != INVALID_HANDLE_VALUE; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#pragma warning(push) - -// SbFilePrivate is defined as a struct, but for windows implementation -// enough functionality has been added so that it warrants being a class -// per Google's C++ style guide. This mismatch causes the Microsoft's compiler -// to generate a warning. -#pragma warning(disable : 4099) - -#pragma warning(pop) - -namespace starboard { -namespace shared { -namespace win32 { - -inline bool PathEndsWith(const std::wstring& path, const wchar_t* filename) { - size_t filename_length = std::wcslen(filename); - if (filename_length > path.size()) { - return false; - } - - size_t path_offset = path.size() - filename_length; - - return _wcsicmp(path.c_str() + path_offset, filename) == 0; -} - -// Path's from cobalt use "/" as a path separator. This function will -// replace all of the "/" with "\". -std::wstring NormalizeWin32Path(std::string str); -std::wstring NormalizeWin32Path(std::wstring str); - -HANDLE OpenFileOrDirectory(const char* path, int flags); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_FILE_INTERNAL_H_ diff --git a/starboard/shared/win32/file_open.cc b/starboard/shared/win32/file_open.cc deleted file mode 100644 index d632c234a363..000000000000 --- a/starboard/shared/win32/file_open.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include "starboard/shared/win32/file_internal.h" - -SbFile SbFileOpen(const char* path, - int flags, - bool* out_created, - SbFileError* out_error) { - if ((path == nullptr) || (path[0] == '\0')) { - if (out_created) { - *out_created = false; - } - if (out_error) { - *out_error = kSbFileErrorNotAFile; - } - return kSbFileInvalid; - } - - HANDLE file_handle = starboard::shared::win32::OpenFileOrDirectory( - path, flags, out_created, out_error); - - if (!starboard::shared::win32::IsValidHandle(file_handle)) { - return kSbFileInvalid; - } - - return new SbFilePrivate(file_handle); -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_read.cc b/starboard/shared/win32/file_read.cc deleted file mode 100644 index f8415ae71765..000000000000 --- a/starboard/shared/win32/file_read.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" - -int SbFileRead(SbFile file, char* data, int size) { - SB_DCHECK((size == 0) || (data != nullptr)); - - if (!starboard::shared::win32::HasValidHandle(file)) { - return -1; - } - - if (size < 0) { - SB_NOTREACHED(); - return -1; - } else if (size == 0) { - return 0; - } - - DWORD number_bytes_read = 0; - BOOL success = - ReadFile(file->file_handle, data, size, &number_bytes_read, nullptr); - - // Since we are only doing synchronous IO, success == FALSE implies that - // something is wrong. - if (!success) { - return -1; - } - - return number_bytes_read; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_seek.cc b/starboard/shared/win32/file_seek.cc deleted file mode 100644 index 117df70b36a7..000000000000 --- a/starboard/shared/win32/file_seek.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/shared/win32/file_internal.h" - -int64_t SbFileSeek(SbFile file, SbFileWhence whence, int64_t offset) { - if (!starboard::shared::win32::HasValidHandle(file)) { - return -1; - } - - LARGE_INTEGER new_file_pointer = {0}; - LARGE_INTEGER offset_argument = {0}; - offset_argument.QuadPart = offset; - BOOL success = - SetFilePointerEx(file->file_handle, offset_argument, &new_file_pointer, - static_cast(whence)); - - if (!success) { - return -1; - } - - return new_file_pointer.QuadPart; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_truncate.cc b/starboard/shared/win32/file_truncate.cc deleted file mode 100644 index 21fef69fa87e..000000000000 --- a/starboard/shared/win32/file_truncate.cc +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" - -namespace { -static const char k4KZeroPage[4 * 1024] = {0}; - -bool WriteZerosToFile(HANDLE file_handle, - LARGE_INTEGER begin, - LARGE_INTEGER end) { - SB_DCHECK(starboard::shared::win32::IsValidHandle(file_handle)); - int64_t bytes_left_to_write = end.QuadPart - begin.QuadPart; - if (bytes_left_to_write <= 0) { - return true; - } - - // Set the file pointer to |begin|. - if (!SetFilePointerEx(file_handle, begin, NULL, FILE_BEGIN)) { - return false; - } - - // Write from zeros from |begin| to |end|. - while (bytes_left_to_write > 0) { - int64_t bytes_to_write = - std::min(SB_ARRAY_SIZE(k4KZeroPage), bytes_left_to_write); - SB_DCHECK(bytes_to_write <= kSbInt32Max); - - DWORD bytes_written = 0; - if (!WriteFile(file_handle, k4KZeroPage, static_cast(bytes_to_write), - &bytes_written, NULL)) { - return false; - } - - bytes_left_to_write -= bytes_written; - } - - return true; -} - -} // namespace - -bool SbFileTruncate(SbFile file, int64_t length) { - if (!starboard::shared::win32::HasValidHandle(file) || length < 0) { - return false; - } - - HANDLE file_handle = file->file_handle; - - // Get current position. - LARGE_INTEGER current_position = {0}; - BOOL success = - SetFilePointerEx(file_handle, {0}, ¤t_position, FILE_CURRENT); - - if (!success) { - return false; - } - - bool return_value = false; - do { - LARGE_INTEGER old_eof = {0}; - if (!SetFilePointerEx(file_handle, {0}, &old_eof, FILE_END)) { - break; - } - - LARGE_INTEGER new_eof = {0}; - new_eof.QuadPart = length; - if (!SetFilePointerEx(file_handle, new_eof, NULL, FILE_BEGIN)) { - break; - } - - if (!SetEndOfFile(file_handle)) { - break; - } - - WriteZerosToFile(file_handle, old_eof, new_eof); - return_value = true; - } while (0); - - // Set the file pointer position back where it was. - SetFilePointerEx(file_handle, current_position, NULL, FILE_BEGIN); - - return return_value; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/file_write.cc b/starboard/shared/win32/file_write.cc deleted file mode 100644 index b95460c8b0f6..000000000000 --- a/starboard/shared/win32/file_write.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 17 - -#include "starboard/file.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/file_internal.h" - -int SbFileWrite(SbFile file, const char* data, int size) { - // TODO: Support asynchronous IO, if necessary. - SB_DCHECK((size == 0) || (data != nullptr)); - if (!SbFileIsValid(file)) { - return -1; - } - if (size < 0) { - SB_NOTREACHED(); - return -1; - } else if (size == 0) { - return 0; - } - - DWORD bytes_written = 0; - bool success = WriteFile(file->file_handle, data, size, &bytes_written, NULL); - if (!success) { - return -1; - } - - return bytes_written; -} - -#endif // SB_API_VERSION < 17 diff --git a/starboard/shared/win32/get_home_directory.cc b/starboard/shared/win32/get_home_directory.cc deleted file mode 100644 index 64ecc941a3f4..000000000000 --- a/starboard/shared/win32/get_home_directory.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include - -// Windows defines GetCommandLine as a macro to GetCommandLineW which -// breaks our Application::GetCommandLine call below; thus we undefine -// it after including our Windows headers. -#undef GetCommandLine - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/starboard/application.h" -#include "starboard/shared/starboard/command_line.h" -#include "starboard/shared/starboard/get_home_directory.h" -#include "starboard/shared/win32/application_win32.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wchar_utils.h" -#include "starboard/system.h" - -namespace sbwin32 = starboard::shared::win32; - -using starboard::shared::starboard::CommandLine; - -namespace starboard { -namespace shared { -namespace starboard { - -bool GetHomeDirectory(char* out_path, int path_size) { - PWSTR local_app_data_path = nullptr; - - if (S_OK == SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, - &local_app_data_path)) { - TCHAR wide_path[MAX_PATH]; - wcscpy(wide_path, local_app_data_path); - CoTaskMemFree(local_app_data_path); - // Instead of using the raw local AppData directory, we create a program - // app directory if it doesn't exist already. - TCHAR program_name[MAX_PATH]; - DWORD program_name_length = GetModuleFileName(NULL, program_name, MAX_PATH); - if (program_name_length == 0) { - SB_LOG(ERROR) << "GetModuleFileName failed"; - sbwin32::DebugLogWinError(); - return false; - } - PathStripPath(program_name); - PathAppend(wide_path, program_name); - if (!PathFileExists(wide_path)) { - SECURITY_ATTRIBUTES security_attributes = {sizeof(SECURITY_ATTRIBUTES), - NULL, TRUE}; - const BOOL created_directory = - CreateDirectory(wide_path, &security_attributes); - if (!created_directory) { - SB_LOG(ERROR) << "Failed to create home directory"; - sbwin32::DebugLogWinError(); - return false; - } - } - - const size_t actual_path_length = wcslen(wide_path); - if (path_size < actual_path_length) { - SB_LOG(ERROR) << "Home directory length exceeds max path size"; - return false; - } - std::wcstombs(out_path, wide_path, actual_path_length + 1); - return true; - } - SB_LOG(ERROR) << "Unable to open local AppData as home directory."; - sbwin32::DebugLogWinError(); - return false; -} - -} // namespace starboard -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/graphics.cc b/starboard/shared/win32/graphics.cc deleted file mode 100644 index d620908b9e2b..000000000000 --- a/starboard/shared/win32/graphics.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/graphics.h" - -#include "starboard/extension/graphics.h" - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -float GetMaximumFrameIntervalInMilliseconds() { - // Allow the rasterizer to delay rendering indefinitely if nothing has - // changed. - return -1.0f; -} - -float GetMinimumFrameIntervalInMilliseconds() { - // Frame presentation is blocked on vsync, so the render thread will also - // block on vsync. However, use a non-zero minimum frame time to avoid - // possible busy-loops on unrendered submissions. - return 1.0f; -} - -const CobaltExtensionGraphicsApi kGraphicsApi = { - kCobaltExtensionGraphicsName, - 2, - &GetMaximumFrameIntervalInMilliseconds, - &GetMinimumFrameIntervalInMilliseconds, -}; - -} // namespace - -const void* GetGraphicsApi() { - return &kGraphicsApi; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/graphics.h b/starboard/shared/win32/graphics.h deleted file mode 100644 index 555a24a93a98..000000000000 --- a/starboard/shared/win32/graphics.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_GRAPHICS_H_ -#define STARBOARD_SHARED_WIN32_GRAPHICS_H_ - -namespace starboard { -namespace shared { -namespace win32 { - -const void* GetGraphicsApi(); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_GRAPHICS_H_ diff --git a/starboard/shared/win32/gyp_configuration.py b/starboard/shared/win32/gyp_configuration.py deleted file mode 100644 index 7893875dc62d..000000000000 --- a/starboard/shared/win32/gyp_configuration.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2016 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard win32 shared platform configuration for gyp_cobalt.""" - -from starboard.build import platform_configuration - -MSVS_VERSION = 2017 - - -class Win32SharedConfiguration(platform_configuration.PlatformConfiguration): - """Starboard Microsoft Windows platform configuration.""" - pass diff --git a/starboard/shared/win32/hardware_decode_target_internal.cc b/starboard/shared/win32/hardware_decode_target_internal.cc deleted file mode 100644 index d494dfd13718..000000000000 --- a/starboard/shared/win32/hardware_decode_target_internal.cc +++ /dev/null @@ -1,385 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/hardware_decode_target_internal.h" - -#include "starboard/common/log.h" -#include "starboard/configuration.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/error_utils.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" -#include "third_party/angle/include/GLES2/gl2.h" -#include "third_party/angle/include/GLES2/gl2ext.h" - -namespace { - -using Microsoft::WRL::ComPtr; - -// {3C3A43AB-C69B-46C9-AA8D-B0CFFCD4596D} -const GUID kCobaltNv12BindChroma = { - 0x3c3a43ab, - 0xc69b, - 0x46c9, - {0xaa, 0x8d, 0xb0, 0xcf, 0xfc, 0xd4, 0x59, 0x6d}}; - -ComPtr AllocateTexture(const ComPtr& d3d_device, - SbDecodeTargetFormat format, - int width, - int height, - HRESULT* h_result) { - ComPtr texture; - D3D11_TEXTURE2D_DESC texture_desc = {}; - texture_desc.Width = width; - texture_desc.Height = height; - texture_desc.MipLevels = 1; - texture_desc.ArraySize = 1; - switch (format) { - case kSbDecodeTargetFormat2PlaneYUVNV12: - texture_desc.Format = DXGI_FORMAT_NV12; - break; - case kSbDecodeTargetFormat1PlaneRGBA: - texture_desc.Format = DXGI_FORMAT_R10G10B10A2_UNORM; - break; - default: - SB_NOTREACHED(); - } - - texture_desc.SampleDesc.Count = 1; - texture_desc.SampleDesc.Quality = 0; - texture_desc.Usage = D3D11_USAGE_DEFAULT; - texture_desc.BindFlags = - D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; - *h_result = d3d_device->CreateTexture2D(&texture_desc, nullptr, - texture.GetAddressOf()); - return texture; -} - -void UpdateTexture( - const ComPtr& texture, - const ComPtr& video_device, - const ComPtr& video_context, - const ComPtr& video_enumerator, - const ComPtr& video_processor, - const ComPtr& video_sample, - const RECT& video_area) { - ComPtr media_buffer; - CheckResult(video_sample->GetBufferByIndex(0, media_buffer.GetAddressOf())); - - ComPtr dxgi_buffer; - CheckResult(media_buffer.As(&dxgi_buffer)); - - ComPtr input_texture; - CheckResult(dxgi_buffer->GetResource(IID_PPV_ARGS(&input_texture))); - - // The VideoProcessor needs to know what subset of the decoded - // frame contains active pixels that should be displayed to the user. - video_context->VideoProcessorSetStreamSourceRect(video_processor.Get(), 0, - TRUE, &video_area); - - D3D11_VIDEO_PROCESSOR_INPUT_VIEW_DESC input_desc = {}; - input_desc.ViewDimension = D3D11_VPIV_DIMENSION_TEXTURE2D; - input_desc.Texture2D.MipSlice = 0; - dxgi_buffer->GetSubresourceIndex(&input_desc.Texture2D.ArraySlice); - - ComPtr input_view; - CheckResult(video_device->CreateVideoProcessorInputView( - input_texture.Get(), video_enumerator.Get(), &input_desc, - input_view.GetAddressOf())); - - D3D11_VIDEO_PROCESSOR_OUTPUT_VIEW_DESC output_desc = {}; - output_desc.ViewDimension = D3D11_VPOV_DIMENSION_TEXTURE2D; - output_desc.Texture2D.MipSlice = 0; - - ComPtr output_view; - CheckResult(video_device->CreateVideoProcessorOutputView( - texture.Get(), video_enumerator.Get(), &output_desc, - output_view.GetAddressOf())); - - // We have a single video stream, which is enabled for display. - D3D11_VIDEO_PROCESSOR_STREAM stream_info = {}; - stream_info.Enable = TRUE; - stream_info.pInputSurface = input_view.Get(); - CheckResult(video_context->VideoProcessorBlt( - video_processor.Get(), output_view.Get(), 0, 1, &stream_info)); -} - -} // namespace - -HardwareDecodeTargetPrivate::HardwareDecodeTargetPrivate( - const ComPtr& d3d_device, - const ComPtr& video_device, - const ComPtr& video_context, - const ComPtr& video_enumerator, - const ComPtr& video_processor, - const ComPtr& video_sample, - const RECT& video_area, - bool texture_RGBA) - : texture_RGBA_(texture_RGBA) { - memset(&info, 0, sizeof(info)); - info.is_opaque = true; - info.width = video_area.right; - info.height = video_area.bottom; - - if (texture_RGBA_) { - info.format = kSbDecodeTargetFormat1PlaneRGBA; - } else { - info.format = kSbDecodeTargetFormat2PlaneYUVNV12; - } - - d3d_texture = AllocateTexture(d3d_device, info.format, info.width, - info.height, &create_texture_2d_h_result); - if (d3d_texture) { - if (video_sample) { - UpdateTexture(d3d_texture, video_device, video_context, video_enumerator, - video_processor, video_sample, video_area); - } - - if (texture_RGBA_) { - InitTextureRGBA(); - } else { - InitTextureYUV(); - } - } -} - -void HardwareDecodeTargetPrivate::InitTextureYUV() { - SbDecodeTargetInfoPlane* planeY = &(info.planes[kSbDecodeTargetPlaneY]); - SbDecodeTargetInfoPlane* planeUV = &(info.planes[kSbDecodeTargetPlaneUV]); - - planeY->width = info.width; - planeY->height = info.height; - planeY->content_region.left = 0; - planeY->content_region.top = info.height; - planeY->content_region.right = info.width; - planeY->content_region.bottom = 0; - - planeUV->width = info.width / 2; - planeUV->height = info.height / 2; - planeUV->content_region.left = planeY->content_region.left / 2; - planeUV->content_region.top = planeY->content_region.top / 2; - planeUV->content_region.right = planeY->content_region.right / 2; - planeUV->content_region.bottom = planeY->content_region.bottom / 2; - - EGLint luma_texture_attributes[] = {EGL_WIDTH, - static_cast(info.width), - EGL_HEIGHT, - static_cast(info.height), - EGL_TEXTURE_TARGET, - EGL_TEXTURE_2D, - EGL_TEXTURE_FORMAT, - EGL_TEXTURE_RGBA, - EGL_NONE}; - - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - - EGLConfig config; - EGLint attribute_list[] = {EGL_SURFACE_TYPE, // this must be first - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_RED_SIZE, - 8, - EGL_GREEN_SIZE, - 8, - EGL_BLUE_SIZE, - 8, - EGL_ALPHA_SIZE, - 8, - EGL_BIND_TO_TEXTURE_RGBA, - EGL_TRUE, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, - EGL_NONE}; - - EGLint num_configs; - bool ok = eglChooseConfig(display, attribute_list, &config, 1, &num_configs); - SB_DCHECK(ok); - SB_DCHECK(num_configs == 1); - - GLuint gl_textures[2] = {0}; - glGenTextures(2, gl_textures); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - // This tells ANGLE that the texture it creates should draw - // the luma channel on R8. - HRESULT hr = d3d_texture->SetPrivateData(kCobaltNv12BindChroma, 0, nullptr); - SB_DCHECK(SUCCEEDED(hr)); - - surface[0] = eglCreatePbufferFromClientBuffer(display, EGL_D3D_TEXTURE_ANGLE, - d3d_texture.Get(), config, - luma_texture_attributes); - - SB_DCHECK(surface[0] != EGL_NO_SURFACE); - - glBindTexture(GL_TEXTURE_2D, gl_textures[0]); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - ok = eglBindTexImage(display, surface[0], EGL_BACK_BUFFER); - SB_DCHECK(ok); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - planeY->texture = gl_textures[0]; - planeY->gl_texture_target = GL_TEXTURE_2D; - planeY->gl_texture_format = GL_RED_EXT; - - // This tells ANGLE that the texture it creates should draw - // the chroma channel on R8G8. - bool bind_chroma = true; - hr = d3d_texture->SetPrivateData(kCobaltNv12BindChroma, 1, &bind_chroma); - SB_DCHECK(SUCCEEDED(hr)); - - EGLint chroma_texture_attributes[] = {EGL_WIDTH, - static_cast(info.width) / 2, - EGL_HEIGHT, - static_cast(info.height) / 2, - EGL_TEXTURE_TARGET, - EGL_TEXTURE_2D, - EGL_TEXTURE_FORMAT, - EGL_TEXTURE_RGBA, - EGL_NONE}; - surface[1] = eglCreatePbufferFromClientBuffer(display, EGL_D3D_TEXTURE_ANGLE, - d3d_texture.Get(), config, - chroma_texture_attributes); - - SB_DCHECK(surface[1] != EGL_NO_SURFACE); - - glBindTexture(GL_TEXTURE_2D, gl_textures[1]); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - ok = eglBindTexImage(display, surface[1], EGL_BACK_BUFFER); - SB_DCHECK(ok); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - planeUV->texture = gl_textures[1]; - planeUV->gl_texture_target = GL_TEXTURE_2D; - planeUV->gl_texture_format = GL_RG_EXT; -} - -void HardwareDecodeTargetPrivate::InitTextureRGBA() { - SbDecodeTargetInfoPlane* planeRGBA = &(info.planes[kSbDecodeTargetPlaneRGBA]); - - planeRGBA->width = info.width; - planeRGBA->height = info.height; - planeRGBA->content_region.left = 0; - planeRGBA->content_region.top = info.height; - planeRGBA->content_region.right = info.width; - planeRGBA->content_region.bottom = 0; - - EGLint RGBA_texture_attributes[] = {EGL_WIDTH, - static_cast(info.width), - EGL_HEIGHT, - static_cast(info.height), - EGL_TEXTURE_TARGET, - EGL_TEXTURE_2D, - EGL_TEXTURE_FORMAT, - EGL_TEXTURE_RGBA, - EGL_NONE}; - - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - - EGLConfig config; - EGLint attribute_list[] = {EGL_SURFACE_TYPE, // this must be first - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_RED_SIZE, - 10, - EGL_GREEN_SIZE, - 10, - EGL_BLUE_SIZE, - 10, - EGL_ALPHA_SIZE, - 2, - EGL_BIND_TO_TEXTURE_RGBA, - EGL_TRUE, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, - EGL_NONE}; - - EGLint num_configs; - bool ok = eglChooseConfig(display, attribute_list, &config, 1, &num_configs); - SB_DCHECK(ok); - SB_DCHECK(num_configs == 1); - - GLuint gl_textures[2] = {0}; - glGenTextures(2, gl_textures); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - surface[0] = eglCreatePbufferFromClientBuffer(display, EGL_D3D_TEXTURE_ANGLE, - d3d_texture.Get(), config, - RGBA_texture_attributes); - - SB_DCHECK(surface[0] != EGL_NO_SURFACE); - - glBindTexture(GL_TEXTURE_2D, gl_textures[0]); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - ok = eglBindTexImage(display, surface[0], EGL_BACK_BUFFER); - SB_DCHECK(ok); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - planeRGBA->texture = gl_textures[0]; - planeRGBA->gl_texture_target = GL_TEXTURE_2D; - planeRGBA->gl_texture_format = GL_RED_EXT; -} - -HardwareDecodeTargetPrivate::~HardwareDecodeTargetPrivate() { - if (!texture_RGBA_) { - glDeleteTextures(1, &(info.planes[kSbDecodeTargetPlaneY].texture)); - glDeleteTextures(1, &(info.planes[kSbDecodeTargetPlaneUV].texture)); - } - - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - - eglReleaseTexImage(display, surface[0], EGL_BACK_BUFFER); - eglDestroySurface(display, surface[0]); - - if (!texture_RGBA_) { - eglReleaseTexImage(display, surface[1], EGL_BACK_BUFFER); - eglDestroySurface(display, surface[1]); - } -} - -bool HardwareDecodeTargetPrivate::Update( - const ComPtr& d3d_device, - const ComPtr& video_device, - const ComPtr& video_context, - const ComPtr& video_enumerator, - const ComPtr& video_processor, - const ComPtr& video_sample, - const RECT& video_area, - bool texture_RGBA) { - // Only allow updating if this is the only reference. Otherwise the update - // may change something that's currently being used. - if (SbAtomicAcquire_Load(&refcount) > 1) { - return false; - } - - // The decode target info must be compatible. The resolution should match - // exactly, otherwise the shader may sample invalid texels along the - // texture border. - if ((texture_RGBA ^ (info.format != kSbDecodeTargetFormat2PlaneYUVNV12)) || - (texture_RGBA ^ (info.format == kSbDecodeTargetFormat1PlaneRGBA)) || - info.is_opaque != true || info.width != video_area.right || - info.height != video_area.bottom) { - return false; - } - - UpdateTexture(d3d_texture, video_device, video_context, video_enumerator, - video_processor, video_sample, video_area); - return true; -} diff --git a/starboard/shared/win32/hardware_decode_target_internal.h b/starboard/shared/win32/hardware_decode_target_internal.h deleted file mode 100644 index a73b298ce447..000000000000 --- a/starboard/shared/win32/hardware_decode_target_internal.h +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_HARDWARE_DECODE_TARGET_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_HARDWARE_DECODE_TARGET_INTERNAL_H_ - -#include -#include -#include - -#include "starboard/atomic.h" -#include "starboard/decode_target.h" -#include "starboard/shared/win32/decode_target_internal.h" - -struct HardwareDecodeTargetPrivate : public SbDecodeTargetPrivate { - template - using ComPtr = ::Microsoft::WRL::ComPtr; - - // Return value of CreateTexture2D. Stored here to report exact error codes to - // the video decoder when the call fails (b/257541360). - HRESULT create_texture_2d_h_result; - - ComPtr d3d_texture; - bool texture_RGBA_; - - // EGLSurface is defined as void* in "third_party/angle/include/EGL/egl.h". - // Use void* directly here to avoid `egl.h` being included broadly. - void* surface[2]; - - HardwareDecodeTargetPrivate( - const ComPtr& d3d_device, - const ComPtr& video_device, - const ComPtr& video_context, - const ComPtr& video_enumerator, - const ComPtr& video_processor, - const ComPtr& video_sample, - const RECT& video_area, - bool texture_RGBA); - ~HardwareDecodeTargetPrivate() override; - - // Update the existing texture with the given video_sample's data. - // If the current object is not compatible with the new video_sample, then - // this will return false, and the caller should just create a new - // decode target for the sample. - bool Update(const ComPtr& d3d_device, - const ComPtr& video_device, - const ComPtr& video_context, - const ComPtr& video_enumerator, - const ComPtr& video_processor, - const ComPtr& video_sample, - const RECT& video_area, - bool texture_RGBA); - void InitTextureRGBA(); - void InitTextureYUV(); -}; - -#endif // STARBOARD_SHARED_WIN32_HARDWARE_DECODE_TARGET_INTERNAL_H_ diff --git a/starboard/shared/win32/log.cc b/starboard/shared/win32/log.cc deleted file mode 100644 index 51eb1d1275a8..000000000000 --- a/starboard/shared/win32/log.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -void SbLog(SbLogPriority priority, const char* message) { - SbLogRaw(message); -} diff --git a/starboard/shared/win32/log_file_impl.cc b/starboard/shared/win32/log_file_impl.cc deleted file mode 100644 index 6932dec04f6d..000000000000 --- a/starboard/shared/win32/log_file_impl.cc +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/log_file_impl.h" - -#include -#include -#include - -#include -#include - -#include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/file.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/file_internal.h" - -namespace { - -pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; -int log_file = -1; - -// SbMutex is not reentrant, so factor out close log file functionality for use -// by other functions. -void CloseLogFileWithoutLock() { - if (starboard::IsValid(log_file)) { - fsync(log_file); - close(log_file); - log_file = -1; - } -} - -} // namespace - -namespace starboard { -namespace shared { -namespace win32 { - -void CloseLogFile() { - pthread_mutex_lock(&log_mutex); - CloseLogFileWithoutLock(); - pthread_mutex_unlock(&log_mutex); -} - -void OpenLogInCacheDirectory(const char* log_file_name, int creation_flags) { - SB_DCHECK((creation_flags & O_CREAT) || - ((creation_flags & O_CREAT) && (creation_flags & O_TRUNC))); - SB_DCHECK(strlen(log_file_name) != 0); - SB_DCHECK(strchr(log_file_name, kSbFileSepChar) == nullptr); - std::vector out_path(kSbFileMaxPath + 1); - out_path[0] = '\0'; - - const int path_size = static_cast(out_path.size()); - if (!SbSystemGetPath(kSbSystemPathCacheDirectory, out_path.data(), - path_size)) { - return; - } - - if (starboard::strlcat(out_path.data(), kSbFileSepString, path_size) >= - path_size) { - return; - } - if (starboard::strlcat(out_path.data(), log_file_name, path_size) >= - path_size) { - return; - } - - OpenLogFile(out_path.data(), creation_flags); -} - -void OpenLogFile(const char* path, const int creation_flags) { - SB_DCHECK(creation_flags & O_CREAT); - SB_DLOG(INFO) << "Logging to [" << path << "]"; - - int flags = creation_flags | O_WRONLY; - - pthread_mutex_lock(&log_mutex); - CloseLogFileWithoutLock(); - if ((path != nullptr) && (path[0] != '\0')) { - log_file = open(path, flags, S_IRUSR | S_IWUSR); - SB_DCHECK(starboard::IsValid(log_file)); - } - - pthread_mutex_unlock(&log_mutex); -} - -void WriteToLogFile(const char* text, const int text_length) { - if (text_length <= 0) { - return; - } - pthread_mutex_lock(&log_mutex); - if (!starboard::IsValid(log_file)) { - pthread_mutex_unlock(&log_mutex); - return; - } - - int bytes_written = starboard::WriteAll(log_file, text, text_length); - RecordFileWriteStat(bytes_written); - SB_DCHECK(text_length == bytes_written); - - fsync(log_file); - pthread_mutex_unlock(&log_mutex); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/log_file_impl.h b/starboard/shared/win32/log_file_impl.h deleted file mode 100644 index cfa17a5e6ee0..000000000000 --- a/starboard/shared/win32/log_file_impl.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This header provides a mechanism for multiple Android logging -// formats to share a single log file handle. - -#ifndef STARBOARD_SHARED_WIN32_LOG_FILE_IMPL_H_ -#define STARBOARD_SHARED_WIN32_LOG_FILE_IMPL_H_ - -#include "starboard/common/mutex.h" -#include "starboard/file.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// Closes the log file. -void CloseLogFile(); - -// Opens a file in |kSbSystemPathCacheDirectory| directory. -// |log_file_name|: C-style string of a filename -// |creation_flags|: Must be kSbFileCreateAlways (which will truncate the file) -// |kSbFileOpenAlways|, which can be used to append to the file. -void OpenLogInCacheDirectory(const char* log_file_name, int creation_flags); - -// Opens a file at |log_file_path| with |creation_flags|. -// |log_file_name|: C-style string of a filename -// |creation_flags|: Must be kSbFileCreateAlways (which will truncate the file) -// |kSbFileOpenAlways|, which can be used to append to the file. -void OpenLogFile(const char* log_file_path, int creation_flags); - -// Writes |text_length| bytes starting from |text| to the current log file. -void WriteToLogFile(const char* text, const int text_length); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_LOG_FILE_IMPL_H_ diff --git a/starboard/shared/win32/log_flush.cc b/starboard/shared/win32/log_flush.cc deleted file mode 100644 index 5c5a5b9a6e3c..000000000000 --- a/starboard/shared/win32/log_flush.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -#include - -void SbLogFlush() { - fflush(stderr); -} diff --git a/starboard/shared/win32/log_format.cc b/starboard/shared/win32/log_format.cc deleted file mode 100644 index c65266abd23c..000000000000 --- a/starboard/shared/win32/log_format.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -void SbLogFormat(const char* format, va_list arguments) { - SbLogRawFormat(format, arguments); -} diff --git a/starboard/shared/win32/log_raw.cc b/starboard/shared/win32/log_raw.cc deleted file mode 100644 index dd9dcd707bd9..000000000000 --- a/starboard/shared/win32/log_raw.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -#include -#include - -#include "starboard/common/string.h" -#include "starboard/shared/starboard/net_log.h" -#include "starboard/shared/win32/log_file_impl.h" - -namespace sbwin32 = starboard::shared::win32; - -void SbLogRaw(const char* message) { - fprintf(stderr, "%s", message); - OutputDebugStringA(message); - sbwin32::WriteToLogFile(message, static_cast(strlen(message))); - - starboard::shared::starboard::NetLogWrite(message); -} diff --git a/starboard/shared/win32/log_raw_dump_stack.cc b/starboard/shared/win32/log_raw_dump_stack.cc deleted file mode 100644 index 180a29b14e1b..000000000000 --- a/starboard/shared/win32/log_raw_dump_stack.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -void SbLogRawDumpStack(int frames_to_skip) { - SbLogRaw("TODO stack dump not implemented\n"); -} diff --git a/starboard/shared/win32/log_raw_format.cc b/starboard/shared/win32/log_raw_format.cc deleted file mode 100644 index 4eda23c70869..000000000000 --- a/starboard/shared/win32/log_raw_format.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" - -#include -#include - -#include "starboard/shared/win32/log_file_impl.h" - -static const int kMaxLogLineChars = 16 * 1024; - -namespace sbwin32 = starboard::shared::win32; - -void SbLogRawFormat(const char* format, va_list arguments) { - char log_buffer[kMaxLogLineChars] = {0}; - int result = vsprintf_s(log_buffer, kMaxLogLineChars - 1, format, arguments); - if (result > 0) { - SbLogRaw(log_buffer); - } else { - SbLogRaw("[log line too long]"); - } -} diff --git a/starboard/shared/win32/media_common.cc b/starboard/shared/win32/media_common.cc deleted file mode 100644 index 4fa378dbde20..000000000000 --- a/starboard/shared/win32/media_common.cc +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/media_common.h" - -#include -#include -#include -#include -#include -#include -#include // For ComPtr. - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/common/string.h" -#include "starboard/configuration.h" -#include "starboard/media.h" -#include "starboard/shared/starboard/player/filter/player_components.h" -#include "starboard/shared/starboard/player/input_buffer_internal.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// Converts microseconds to 10Mhz (100ns time). -int64_t ConvertUsecToWin32Time(int64_t input) { - int64_t out = input; - out *= 10; - return out; -} - -// Convert the other way around. -int64_t ConvertWin32TimeToUsec(int64_t input) { - int64_t out = input; - out /= 10; - return out; -} - -std::vector> GetAllOutputMediaTypes( - int stream_id, - IMFTransform* decoder) { - std::vector> output; - for (int index = 0;; ++index) { - ComPtr media_type; - HRESULT hr = decoder->GetOutputAvailableType(stream_id, index, &media_type); - if (SUCCEEDED(hr)) { - output.push_back(media_type); - } else { - SB_DCHECK(hr == MF_E_NO_MORE_TYPES); - break; - } - } - return output; -} - -std::vector> GetAllInputMediaTypes( - int stream_id, - IMFTransform* transform) { - std::vector> input_types; - - for (DWORD i = 0;; ++i) { - ComPtr curr_type; - HRESULT hr = transform->GetInputAvailableType(stream_id, i, - curr_type.GetAddressOf()); - if (FAILED(hr)) { - break; - } - input_types.push_back(curr_type); - } - return input_types; -} - -std::vector> FilterMediaBySubType( - const std::vector>& input, - GUID sub_type_filter) { - std::vector> output; - for (auto it = input.begin(); it != input.end(); ++it) { - ComPtr media_type = *it; - GUID media_sub_type = {0}; - media_type->GetGUID(MF_MT_SUBTYPE, &media_sub_type); - if (IsEqualGUID(media_sub_type, sub_type_filter)) { - output.push_back(media_type); - } - } - return output; -} - -HRESULT CreateAV1Decoder(const IID& iid, void** object) { - MFT_REGISTER_TYPE_INFO type_info = {MFMediaType_Video, MFVideoFormat_AV1}; - MFT_REGISTER_TYPE_INFO output_info = {MFMediaType_Video, MFVideoFormat_NV12}; - - IMFActivate** acts; - UINT32 acts_num = 0; - HRESULT hr = ::MFTEnumEx(MFT_CATEGORY_VIDEO_DECODER, - MFT_ENUM_FLAG_SYNCMFT | MFT_ENUM_FLAG_LOCALMFT | - MFT_ENUM_FLAG_UNTRUSTED_STOREMFT, - &type_info, &output_info, &acts, &acts_num); - if (FAILED(hr)) - return hr; - - if (acts_num < 1) - return E_FAIL; - - hr = acts[0]->ActivateObject(iid, object); - for (UINT32 i = 0; i < acts_num; ++i) - acts[i]->Release(); - CoTaskMemFree(acts); - return hr; -} - -HRESULT CreateDecoderTransform(const GUID& decoder_guid, - ComPtr* transform) { - if (decoder_guid == MFVideoFormat_AV1) { - return CreateAV1Decoder(IID_PPV_ARGS(transform->GetAddressOf())); - } - return CoCreateInstance(decoder_guid, NULL, CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(transform->GetAddressOf())); -} - -bool IsHardwareAv1DecoderSupported() { - static bool av1_decoder_supported = false; - static bool av1_support_checked = false; - if (!av1_support_checked) { - MFT_REGISTER_TYPE_INFO type_info = {MFMediaType_Video, MFVideoFormat_AV1}; - MFT_REGISTER_TYPE_INFO output_info = {MFMediaType_Video, - MFVideoFormat_NV12}; - - IMFActivate** acts; - UINT32 acts_num = 0; - HRESULT hr = ::MFTEnumEx(MFT_CATEGORY_VIDEO_DECODER, - MFT_ENUM_FLAG_SYNCMFT | MFT_ENUM_FLAG_LOCALMFT | - MFT_ENUM_FLAG_UNTRUSTED_STOREMFT, - &type_info, &output_info, &acts, &acts_num); - for (UINT32 i = 0; i < acts_num; ++i) - acts[i]->Release(); - av1_decoder_supported = SUCCEEDED(hr) && acts_num >= 1; - av1_support_checked = true; - } - return av1_decoder_supported; -} -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/media_common.h b/starboard/shared/win32/media_common.h deleted file mode 100644 index b689f87d4a32..000000000000 --- a/starboard/shared/win32/media_common.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_MEDIA_COMMON_H_ -#define STARBOARD_SHARED_WIN32_MEDIA_COMMON_H_ - -#include -#include -#include -#include -#include -#include -#include -#include // For ComPtr. -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/common/string.h" -#include "starboard/configuration.h" -#include "starboard/media.h" -#include "starboard/shared/starboard/player/filter/player_components.h" -#include "starboard/shared/starboard/player/filter/video_frame_internal.h" -#include "starboard/shared/starboard/player/input_buffer_internal.h" - -namespace starboard { -namespace shared { -namespace win32 { - -using DecodedAudio = ::starboard::shared::starboard::player::DecodedAudio; -using DecodedAudioPtr = ::starboard::scoped_refptr; -using InputBuffer = ::starboard::shared::starboard::player::InputBuffer; -using PlayerComponents = - ::starboard::shared::starboard::player::filter::PlayerComponents; -using Status = - ::starboard::shared::starboard::player::filter::VideoDecoder::Status; -using VideoFrame = ::starboard::shared::starboard::player::filter::VideoFrame; -using VideoFramePtr = ::starboard::scoped_refptr; -using Microsoft::WRL::ComPtr; - -// Converts microseconds to 10Mhz (100ns time). -int64_t ConvertUsecToWin32Time(int64_t input); - -// Convert the other way around. -int64_t ConvertWin32TimeToUsec(int64_t input); - -std::vector> GetAllOutputMediaTypes(int stream_id, - IMFTransform* decoder); -std::vector> GetAllInputMediaTypes( - int stream_id, - IMFTransform* transform); - -std::vector> FilterMediaBySubType( - const std::vector>& input, - GUID sub_type_filter); - -HRESULT CreateDecoderTransform(const GUID& decoder_guid, - ComPtr* transform); - -bool IsHardwareAv1DecoderSupported(); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_MEDIA_COMMON_H_ diff --git a/starboard/shared/win32/media_foundation_utils.cc b/starboard/shared/win32/media_foundation_utils.cc deleted file mode 100644 index f07ed62b3a7d..000000000000 --- a/starboard/shared/win32/media_foundation_utils.cc +++ /dev/null @@ -1,273 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/media_foundation_utils.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/error_utils.h" - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -#define MAKE_GUID_PAIR(X) std::pair(X, #X) - -const std::pair kMfMtAudio[] = { - MAKE_GUID_PAIR(MF_MT_AAC_PAYLOAD_TYPE), - MAKE_GUID_PAIR(MF_MT_AUDIO_AVG_BYTES_PER_SECOND), - MAKE_GUID_PAIR(MF_MT_AUDIO_BITS_PER_SAMPLE), - MAKE_GUID_PAIR(MF_MT_AUDIO_BLOCK_ALIGNMENT), - MAKE_GUID_PAIR(MF_MT_AUDIO_CHANNEL_MASK), - MAKE_GUID_PAIR(MF_MT_AUDIO_FLOAT_SAMPLES_PER_SECOND), - MAKE_GUID_PAIR(MF_MT_AUDIO_NUM_CHANNELS), - MAKE_GUID_PAIR(MF_MT_AUDIO_SAMPLES_PER_BLOCK), - MAKE_GUID_PAIR(MF_MT_AUDIO_SAMPLES_PER_SECOND), - MAKE_GUID_PAIR(MF_MT_AUDIO_NUM_CHANNELS), - MAKE_GUID_PAIR(MF_MT_MAJOR_TYPE), - MAKE_GUID_PAIR(MF_MT_AUDIO_PREFER_WAVEFORMATEX), - MAKE_GUID_PAIR(MF_MT_USER_DATA), - MAKE_GUID_PAIR(MF_MT_SUBTYPE), - MAKE_GUID_PAIR(MFAudioFormat_AAC), - MAKE_GUID_PAIR(MFAudioFormat_ADTS), - MAKE_GUID_PAIR(MFAudioFormat_ALAC), - MAKE_GUID_PAIR(MFAudioFormat_AMR_NB), - MAKE_GUID_PAIR(MFAudioFormat_AMR_WB), - MAKE_GUID_PAIR(MFAudioFormat_AMR_WP), - MAKE_GUID_PAIR(MFAudioFormat_Dolby_AC3), - MAKE_GUID_PAIR(MFAudioFormat_Dolby_AC3_SPDIF), - MAKE_GUID_PAIR(MFAudioFormat_Dolby_DDPlus), - MAKE_GUID_PAIR(MFAudioFormat_DRM), - MAKE_GUID_PAIR(MFAudioFormat_DTS), - MAKE_GUID_PAIR(MFAudioFormat_FLAC), - MAKE_GUID_PAIR(MFAudioFormat_Float), - MAKE_GUID_PAIR(MFAudioFormat_Float_SpatialObjects), - MAKE_GUID_PAIR(MFAudioFormat_MP3), - MAKE_GUID_PAIR(MFAudioFormat_MPEG), - MAKE_GUID_PAIR(MFAudioFormat_MSP1), - MAKE_GUID_PAIR(MFAudioFormat_Opus), - MAKE_GUID_PAIR(MFAudioFormat_PCM), - MAKE_GUID_PAIR(MFAudioFormat_WMASPDIF), - MAKE_GUID_PAIR(MFAudioFormat_WMAudio_Lossless), - MAKE_GUID_PAIR(MFAudioFormat_WMAudioV8), - MAKE_GUID_PAIR(MFAudioFormat_WMAudioV9), - MAKE_GUID_PAIR(MFAudioFormat_WMAudioV9), - MAKE_GUID_PAIR(MFMediaType_Audio), -}; -#undef MAKE_GUID_PAIR - -std::string GuidToFallbackString(GUID guid) { - std::stringstream ss; - wchar_t* guid_str = nullptr; - StringFromCLSID(guid, &guid_str); - ss << guid_str; - CoTaskMemFree(guid_str); - return ss.str(); -} - -std::string MfGuidToString(GUID guid) { - const size_t n = sizeof(kMfMtAudio) / sizeof(*kMfMtAudio); - for (auto i = 0; i < n; ++i) { - const auto& elems = kMfMtAudio[i]; - if (guid == elems.first) { - return elems.second; - } - } - return GuidToFallbackString(guid); -} - -std::string ImfAttributesToString(IMFAttributes* type) { - std::stringstream ss; - UINT32 n = 0; - HRESULT hr = type->GetCount(&n); - CheckResult(hr); - for (UINT32 i = 0; i < n; ++i) { - GUID key; - PROPVARIANT val; - type->GetItemByIndex(i, &key, &val); - PropVariantClear(&val); - - MF_ATTRIBUTE_TYPE attrib_type; - hr = type->GetItemType(key, &attrib_type); - CheckResult(hr); - - std::string key_str = MfGuidToString(key); - ss << key_str << ": "; - - switch (attrib_type) { - case MF_ATTRIBUTE_GUID: { - GUID value_guid; - hr = type->GetGUID(key, &value_guid); - ss << MfGuidToString(value_guid) << "\n"; - break; - } - - case MF_ATTRIBUTE_DOUBLE: { - double value = 0; - hr = type->GetDouble(key, &value); - ss << value << "\n"; - break; - } - - case MF_ATTRIBUTE_BLOB: { - // Skip. - ss << "" - << "\n"; - break; - } - - case MF_ATTRIBUTE_UINT32: { - UINT32 int_val = 0; - hr = type->GetUINT32(key, &int_val); - ss << int_val << "\n"; - break; - } - - case MF_ATTRIBUTE_UINT64: { - UINT64 int_val = 0; - hr = type->GetUINT64(key, &int_val); - ss << int_val << "\n"; - break; - } - - case MF_ATTRIBUTE_STRING: { - UINT32 length = 0; - hr = type->GetStringLength(key, &length); - CheckResult(hr); - ++length; // For trailing 0. - std::vector buffer(length); - hr = type->GetString(key, buffer.data(), length, NULL); - CheckResult(hr); - ss << buffer.data() << "\n"; - break; - } - - case MF_ATTRIBUTE_IUNKNOWN: { - SB_NOTIMPLEMENTED(); - break; - } - } - } - ss << "\n"; - return ss.str(); -} - -} // namespace. - -void CopyProperties(IMFMediaType* source, IMFMediaType* destination) { - UINT32 attribute_count = 0; - HRESULT hr = source->GetCount(&attribute_count); - CheckResult(hr); - for (UINT32 i = 0; i < attribute_count; ++i) { - GUID key; - PROPVARIANT variant; - hr = source->GetItemByIndex(i, &key, &variant); - CheckResult(hr); - PropVariantClear(&variant); - - MF_ATTRIBUTE_TYPE attrib_type; - hr = source->GetItemType(key, &attrib_type); - CheckResult(hr); - - switch (attrib_type) { - case MF_ATTRIBUTE_GUID: { - GUID value_guid; - hr = source->GetGUID(key, &value_guid); - CheckResult(hr); - hr = destination->SetGUID(key, value_guid); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_DOUBLE: { - double value = 0; - hr = source->GetDouble(key, &value); - CheckResult(hr); - hr = destination->SetDouble(key, value); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_BLOB: { - UINT32 blob_size = 0; - hr = source->GetBlobSize(key, &blob_size); - CheckResult(hr); - std::vector blob(blob_size); - hr = source->GetBlob(key, blob.data(), blob_size, &blob_size); - CheckResult(hr); - hr = destination->SetBlob(key, blob.data(), blob_size); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_UINT32: { - UINT32 int_val = 0; - hr = source->GetUINT32(key, &int_val); - CheckResult(hr); - hr = destination->SetUINT32(key, int_val); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_UINT64: { - UINT64 int_val = 0; - hr = source->GetUINT64(key, &int_val); - CheckResult(hr); - hr = destination->SetUINT64(key, int_val); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_STRING: { - UINT32 length = 0; - hr = source->GetStringLength(key, &length); - CheckResult(hr); - ++length; // For trailing 0. - std::vector buffer(length); - hr = source->GetString(key, buffer.data(), length, NULL); - CheckResult(hr); - hr = destination->SetString(key, buffer.data()); - CheckResult(hr); - break; - } - - case MF_ATTRIBUTE_IUNKNOWN: { - SB_NOTIMPLEMENTED(); - break; - } - } - } -} - -std::ostream& operator<<(std::ostream& os, const IMFMediaType& media_type) { - const IMFAttributes* attribs = &media_type; // Upcast. - std::string output_str = - ImfAttributesToString(const_cast(attribs)); - os << output_str; - return os; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/media_foundation_utils.h b/starboard/shared/win32/media_foundation_utils.h deleted file mode 100644 index 6d96080a72e7..000000000000 --- a/starboard/shared/win32/media_foundation_utils.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -#include - -#ifndef STARBOARD_SHARED_WIN32_MEDIA_FOUNDATION_UTILS_H_ -#define STARBOARD_SHARED_WIN32_MEDIA_FOUNDATION_UTILS_H_ - -namespace starboard { -namespace shared { -namespace win32 { - -std::ostream& operator<<(std::ostream& os, const IMFMediaType& media_type); - -std::string ToString(IMFAttributes* type); - -void CopyProperties(IMFMediaType* source, IMFMediaType* destination); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_MEDIA_FOUNDATION_UTILS_H_ diff --git a/starboard/shared/win32/media_get_max_buffer_capacity.cc b/starboard/shared/win32/media_get_max_buffer_capacity.cc deleted file mode 100644 index 591923d0adb5..000000000000 --- a/starboard/shared/win32/media_get_max_buffer_capacity.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/media.h" - -int SbMediaGetMaxBufferCapacity(SbMediaVideoCodec codec, - int resolution_width, - int resolution_height, - int bits_per_pixel) { - // TODO: refine this to a more reasonable value, taking into account - // resolution. On most platforms this is 36 * 1024 * 1024 for 1080p, and - // 65 * 1024 * 1024 for 4k. - return 500 * 1024 * 1024; -} diff --git a/starboard/shared/win32/media_is_audio_supported.cc b/starboard/shared/win32/media_is_audio_supported.cc deleted file mode 100644 index f838ac3eb988..000000000000 --- a/starboard/shared/win32/media_is_audio_supported.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/media/media_support_internal.h" - -#include "starboard/configuration.h" -#include "starboard/configuration_constants.h" -#include "starboard/media.h" - -using ::starboard::shared::starboard::media::MimeType; - -bool SbMediaIsAudioSupported(SbMediaAudioCodec audio_codec, - const MimeType* mime_type, - int64_t bitrate) { - if (audio_codec != kSbMediaAudioCodecAac && - audio_codec != kSbMediaAudioCodecOpus) { - return false; - } - return bitrate <= kSbMediaMaxAudioBitrateInBitsPerSecond; -} diff --git a/starboard/shared/win32/media_is_supported.cc b/starboard/shared/win32/media_is_supported.cc deleted file mode 100644 index b7180b5fbc6e..000000000000 --- a/starboard/shared/win32/media_is_supported.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/media/media_support_internal.h" - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/media.h" -#include "starboard/shared/win32/drm_system_playready.h" - -bool SbMediaIsSupported(SbMediaVideoCodec video_codec, - SbMediaAudioCodec audio_codec, - const char* key_system) { - using ::starboard::shared::win32::DrmSystemPlayready; - - return DrmSystemPlayready::IsKeySystemSupported(key_system); -} diff --git a/starboard/shared/win32/media_is_video_supported.cc b/starboard/shared/win32/media_is_video_supported.cc deleted file mode 100644 index 28aaa229a19e..000000000000 --- a/starboard/shared/win32/media_is_video_supported.cc +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/media/media_support_internal.h" - -#include -#include -#include -#include - -#include "starboard/configuration_constants.h" -#include "starboard/shared/starboard/media/media_util.h" - -using ::starboard::shared::starboard::media::MimeType; - -namespace { - -// Cache the VP9 support status since the check may be expensive. -enum Vp9Support { kVp9SupportUnknown, kVp9SupportYes, kVp9SupportNo }; -Vp9Support s_vp9_support = kVp9SupportUnknown; - -// Check for VP9 support. Since this is used by a starboard function, it -// cannot depend on other modules (e.g. ANGLE). -bool IsVp9Supported() { - if (!kSbHasMediaWebmVp9Support) { - return false; - } - - if (s_vp9_support == kVp9SupportUnknown) { - // Try initializing the VP9 decoder to determine if it is supported. - HRESULT hr; - - Microsoft::WRL::ComPtr d3d_device; - hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, - nullptr, 0, D3D11_SDK_VERSION, - d3d_device.GetAddressOf(), nullptr, nullptr); - - UINT reset_token = 0; - Microsoft::WRL::ComPtr device_manager; - if (SUCCEEDED(hr)) { - hr = MFCreateDXGIDeviceManager(&reset_token, - device_manager.GetAddressOf()); - } - if (SUCCEEDED(hr)) { - hr = device_manager->ResetDevice(d3d_device.Get(), reset_token); - } - - Microsoft::WRL::ComPtr transform; - if (SUCCEEDED(hr)) { - hr = CoCreateInstance(CLSID_MSVPxDecoder, nullptr, CLSCTX_INPROC_SERVER, - IID_PPV_ARGS(transform.GetAddressOf())); - } - - if (SUCCEEDED(hr)) { - hr = transform->ProcessMessage(MFT_MESSAGE_SET_D3D_MANAGER, - ULONG_PTR(device_manager.Get())); - } - - s_vp9_support = SUCCEEDED(hr) ? kVp9SupportYes : kVp9SupportNo; - } - return s_vp9_support == kVp9SupportYes; -} - -} // namespace - -bool SbMediaIsVideoSupported(SbMediaVideoCodec video_codec, - const MimeType* mime_type, - int profile, - int level, - int bit_depth, - SbMediaPrimaryId primary_id, - SbMediaTransferId transfer_id, - SbMediaMatrixId matrix_id, - int frame_width, - int frame_height, - int64_t bitrate, - int fps, - bool decode_to_texture_required) { - // Win32 platforms use decode-to-texture by default so there is no special - // constraints if decode-to-texture support is specifically required. - - int max_width = 1920; - int max_height = 1080; - - if (video_codec == kSbMediaVideoCodecVp9) { -// Vp9 supports 8k only in whitelisted platforms, up to 4k in the others. -#ifdef ENABLE_VP9_8K_SUPPORT - max_width = 7680; - max_height = 4320; -#else // ENABLE_VP9_8K_SUPPORT - max_width = 3840; - max_height = 2160; -#endif // ENABLE_VP9_8K_SUPPORT - } else if (video_codec == kSbMediaVideoCodecH264) { -// Not all devices can support 4k H264; some (e.g. xb1) may crash in -// the decoder if provided too high of a resolution. Therefore -// platforms must explicitly opt-in to support 4k H264. -#ifdef ENABLE_H264_4K_SUPPORT - max_width = 3840; - max_height = 2160; -#endif // ENABLE_H264_4K_SUPPORT - } - - if (frame_width > max_width || frame_height > max_height) { - return false; - } - - // Is bitrate in range? - if (bitrate > kSbMediaMaxVideoBitrateInBitsPerSecond) { - return false; - } - if (fps > 60) { - return false; - } - using ::starboard::shared::starboard::media::IsSDRVideo; - if (!IsSDRVideo(bit_depth, primary_id, transfer_id, matrix_id)) { - return false; - } - if (video_codec == kSbMediaVideoCodecH264) { - return true; - } - if (video_codec == kSbMediaVideoCodecVp9) { - return IsVp9Supported(); - } - return false; -} diff --git a/starboard/shared/win32/media_transform.cc b/starboard/shared/win32/media_transform.cc deleted file mode 100644 index 499454d2c95e..000000000000 --- a/starboard/shared/win32/media_transform.cc +++ /dev/null @@ -1,384 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/media_transform.h" - -#include "starboard/common/log.h" -#include "starboard/shared/win32/audio_transform.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/media_common.h" -#include "starboard/shared/win32/media_foundation_utils.h" - -namespace starboard { -namespace shared { -namespace win32 { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::starboard::ThreadChecker; - -namespace { - -template -void ReleaseIfNotNull(T** ptr) { - if (*ptr) { - (*ptr)->Release(); - *ptr = NULL; - } -} - -} // namespace - -MediaTransform::MediaTransform(CLSID clsid) - : thread_checker_(ThreadChecker::kSetThreadIdOnFirstCheck), - state_(kCanAcceptInput), - stream_begun_(false), - discontinuity_(true), - throttle_inputs_(false) { - transform_ = nullptr; - HRESULT hr = CreateDecoderTransform(clsid, &transform_); - if (FAILED(hr) || !transform_) { - transform_ = nullptr; - state_ = kDrained; - } -} - -MediaTransform::MediaTransform( - const Microsoft::WRL::ComPtr& transform) - : transform_(transform), - thread_checker_(ThreadChecker::kSetThreadIdOnFirstCheck), - state_(kCanAcceptInput), - stream_begun_(false), - discontinuity_(true), - throttle_inputs_(false) { - SB_DCHECK(transform_); -} - -bool MediaTransform::TryWrite(const ComPtr& input) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - if (state_ != kCanAcceptInput || !transform_) { - return false; - } - - if (!stream_begun_) { - SendMessage(MFT_MESSAGE_NOTIFY_BEGIN_STREAMING); - SendMessage(MFT_MESSAGE_NOTIFY_START_OF_STREAM); - stream_begun_ = true; - } - - HRESULT hr = transform_->ProcessInput(kStreamId, input.Get(), 0); - - if (SUCCEEDED(hr)) { - // Some transforms do not return MF_E_NOTACCEPTING. To avoid flooding - // these transforms, input is only allowed when ProcessOutput returns - // MF_E_TRANSFORM_NEED_MORE_INPUT. - if (throttle_inputs_) { - state_ = kCanProvideOutput; - } - return true; - } - if (hr == MF_E_NOTACCEPTING) { - state_ = kCanProvideOutput; - return false; - } - SB_NOTREACHED() << "Unexpected return value " << hr; - return false; -} - -ComPtr MediaTransform::TryRead(ComPtr* new_type) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(new_type); - - if (state_ == kDrained || !transform_ || state_ == kInvalidInput) { - return NULL; - } - - ComPtr sample; - HRESULT hr = ProcessOutput(&sample); - - if (hr == MF_E_TRANSFORM_STREAM_CHANGE) { - hr = transform_->GetOutputAvailableType(kStreamId, - 0, // TypeIndex - new_type->GetAddressOf()); - CheckResult(hr); - SetOutputType(*new_type); - - hr = ProcessOutput(&sample); - } - - if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { - if (state_ == kCanProvideOutput) { - state_ = kCanAcceptInput; - } - if (state_ == kDraining) { - state_ = kDrained; - } - return NULL; - } - - if (FAILED(hr)) { - // Sometimes the decryptor refuse to emit output after shutting down. - if (hr == MF_E_INVALIDREQUEST && state_ == kDraining) { - state_ = kDrained; - } else { - state_ = kInvalidInput; - } - return NULL; - } - - SB_DCHECK(sample); - - if (discontinuity_) { - sample->SetUINT32(MFSampleExtension_Discontinuity, TRUE); - discontinuity_ = false; - } - - return sample; -} - -void MediaTransform::Drain() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(state_ != kDraining && state_ != kDrained); - - if (state_ == kDraining || state_ == kDrained) { - return; - } - - if (!stream_begun_) { - state_ = kDrained; - return; - } - - // The VP9 codec may crash when MFT_MESSAGE_NOTIFY_END_OF_STREAM is processed - // at the same time an IMFSample is released. Per documentation, the client - // is not required to send this message for IMFTransforms. Avoid the possible - // race condition by not sending this message. - // SendMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM); - SendMessage(MFT_MESSAGE_COMMAND_DRAIN); - state_ = kDraining; -} - -bool MediaTransform::draining() const { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - return state_ == kDraining; -} - -bool MediaTransform::drained() const { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - return state_ == kDrained; -} - -bool MediaTransform::HasError() const { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - return state_ == kInvalidInput; -} - -bool MediaTransform::HasValidTransform() const { - return transform_ ? true : false; -} - -void MediaTransform::ResetFromDrained() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(drained()); - - state_ = kCanAcceptInput; - stream_begun_ = false; - discontinuity_ = true; -} - -ComPtr MediaTransform::GetCurrentInputType() { - ComPtr type; - SB_DCHECK(transform_); - HRESULT hr = transform_->GetInputCurrentType(kStreamId, type.GetAddressOf()); - CheckResult(hr); - return type; -} - -void MediaTransform::SetInputType(const ComPtr& input_type) { - SB_DCHECK(transform_); - HRESULT hr = transform_->SetInputType(0, input_type.Get(), 0); - CheckResult(hr); -} - -std::vector> MediaTransform::GetAvailableInputTypes() { - SB_DCHECK(transform_); - return GetAllInputMediaTypes(kStreamId, transform_.Get()); -} - -ComPtr MediaTransform::GetCurrentOutputType() { - ComPtr type; - SB_DCHECK(transform_); - HRESULT hr = transform_->GetOutputCurrentType(kStreamId, type.GetAddressOf()); - CheckResult(hr); - return type; -} - -void MediaTransform::SetOutputType(const ComPtr& output_type) { - SB_DCHECK(transform_); - HRESULT hr = transform_->SetOutputType(0, output_type.Get(), 0); - CheckResult(hr); -} - -std::vector> MediaTransform::GetAvailableOutputTypes() { - std::vector> output_types; - SB_DCHECK(transform_); - - for (DWORD i = 0;; ++i) { - ComPtr curr_type; - HRESULT hr = transform_->GetOutputAvailableType(kStreamId, i, - curr_type.GetAddressOf()); - if (FAILED(hr)) { - break; - } - output_types.push_back(curr_type); - } - - return output_types; -} - -void MediaTransform::SetOutputTypeBySubType(GUID subtype) { - SB_DCHECK(transform_); - for (int index = 0;; ++index) { - ComPtr media_type; - HRESULT hr = - transform_->GetOutputAvailableType(kStreamId, index, &media_type); - if (SUCCEEDED(hr)) { - GUID media_sub_type = {}; - media_type->GetGUID(MF_MT_SUBTYPE, &media_sub_type); - if (media_sub_type == subtype) { - SetOutputType(media_type); - return; - } - } else { - SB_DCHECK(hr == MF_E_NO_MORE_TYPES); - break; - } - } - SB_NOTREACHED(); -} - -ComPtr MediaTransform::GetAttributes() { - SB_DCHECK(transform_); - ComPtr attributes; - HRESULT hr = transform_->GetAttributes(attributes.GetAddressOf()); - CheckResult(hr); - return attributes; -} - -ComPtr MediaTransform::GetOutputStreamAttributes() { - SB_DCHECK(transform_); - ComPtr attributes; - HRESULT hr = - transform_->GetOutputStreamAttributes(0, attributes.GetAddressOf()); - CheckResult(hr); - return attributes; -} - -ComPtr MediaTransform::GetSampleProtection() { - SB_DCHECK(transform_); - ComPtr sample_protection; - HRESULT hr = transform_.As(&sample_protection); - CheckResult(hr); - return sample_protection; -} - -void MediaTransform::GetStreamCount(DWORD* input_stream_count, - DWORD* output_stream_count) { - SB_DCHECK(transform_); - SB_DCHECK(input_stream_count); - SB_DCHECK(output_stream_count); - HRESULT hr = - transform_->GetStreamCount(input_stream_count, output_stream_count); - CheckResult(hr); -} - -HRESULT MediaTransform::SendMessage(MFT_MESSAGE_TYPE msg, - ULONG_PTR data /*= 0*/) { - SB_DCHECK(transform_); - return transform_->ProcessMessage(msg, data); -} - -void MediaTransform::Reset() { - if (stream_begun_) { - SendMessage(MFT_MESSAGE_COMMAND_FLUSH); - } - state_ = kCanAcceptInput; - discontinuity_ = true; - thread_checker_.Detach(); -} - -void MediaTransform::PrepareOutputDataBuffer( - MFT_OUTPUT_DATA_BUFFER* output_data_buffer) { - SB_DCHECK(transform_); - output_data_buffer->dwStreamID = kStreamId; - output_data_buffer->pSample = NULL; - output_data_buffer->dwStatus = 0; - output_data_buffer->pEvents = NULL; - - MFT_OUTPUT_STREAM_INFO output_stream_info; - HRESULT hr = transform_->GetOutputStreamInfo(kStreamId, &output_stream_info); - CheckResult(hr); - - static const DWORD kFlagAutoAllocateMemory = - MFT_OUTPUT_STREAM_PROVIDES_SAMPLES | - MFT_OUTPUT_STREAM_CAN_PROVIDE_SAMPLES; - if ((output_stream_info.dwFlags & kFlagAutoAllocateMemory) != 0) { - // Try to let the IMFTransform allocate the memory if possible. - return; - } - - ComPtr sample; - hr = MFCreateSample(&sample); - CheckResult(hr); - - ComPtr buffer; - hr = MFCreateAlignedMemoryBuffer(output_stream_info.cbSize, - output_stream_info.cbAlignment, &buffer); - CheckResult(hr); - - hr = sample->AddBuffer(buffer.Get()); - CheckResult(hr); - - output_data_buffer->pSample = sample.Detach(); -} - -HRESULT MediaTransform::ProcessOutput(ComPtr* sample) { - SB_DCHECK(sample); - SB_DCHECK(transform_); - - MFT_OUTPUT_DATA_BUFFER output_data_buffer; - PrepareOutputDataBuffer(&output_data_buffer); - - const DWORD kFlags = 0; - const DWORD kNumberOfBuffers = 1; - DWORD status = 0; - HRESULT hr = transform_->ProcessOutput(kFlags, kNumberOfBuffers, - &output_data_buffer, &status); - - SB_DCHECK(!output_data_buffer.pEvents); - - *sample = output_data_buffer.pSample; - ReleaseIfNotNull(&output_data_buffer.pEvents); - ReleaseIfNotNull(&output_data_buffer.pSample); - - if (output_data_buffer.dwStatus == MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE) { - hr = MF_E_TRANSFORM_NEED_MORE_INPUT; - } - - return hr; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/media_transform.h b/starboard/shared/win32/media_transform.h deleted file mode 100644 index ecc9abd81e47..000000000000 --- a/starboard/shared/win32/media_transform.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_MEDIA_TRANSFORM_H_ -#define STARBOARD_SHARED_WIN32_MEDIA_TRANSFORM_H_ - -#include -#include -#include -#include - -#include - -#include "starboard/media.h" -#include "starboard/shared/starboard/thread_checker.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// Wrapper class for IMFTransform with the following functionalities: -// 1. State management: -// It supports a one way life cycle from "kCanAcceptInput/kCanProvideOutput" -// to "kDraining" then to "kDrained". -// 2. Manages states like input/output types, various attributes, and sample -// protection, etc. -// 3. Send message to the underlying transform. -// This simplifies the implementation of higher level decoder mechanism that -// may deal with two IMFTransforms: one decoder and one decryptor. -class MediaTransform { - public: - enum { kStreamId = 0 }; - explicit MediaTransform(CLSID clsid); - explicit MediaTransform( - const Microsoft::WRL::ComPtr& transform); - - // By default, the input throttle is disabled, and inputs can be written to - // the transform until rejected; i.e. the transform is kept full of inputs. - // However, some transforms may never report that they are full, so enabling - // the input throttle will allow inputs only when the transform reports that - // it needs more input. - void EnableInputThrottle(bool enable) { throttle_inputs_ = enable; } - - bool TryWrite(const Microsoft::WRL::ComPtr& input); - Microsoft::WRL::ComPtr TryRead( - Microsoft::WRL::ComPtr* new_type); - void Drain(); - bool draining() const; - bool drained() const; - bool HasError() const; - // Once the transform is drained, this function can be called to allow the - // transform to accept new input as a newly created transform. This allows - // the reuse of existing transform without re-negotiating all types and - // attributes. - void ResetFromDrained(); - - bool HasValidTransform() const; - - Microsoft::WRL::ComPtr GetCurrentInputType(); - void SetInputType(const Microsoft::WRL::ComPtr& type); - std::vector> GetAvailableInputTypes(); - - Microsoft::WRL::ComPtr GetCurrentOutputType(); - void SetOutputType(const Microsoft::WRL::ComPtr& type); - std::vector> GetAvailableOutputTypes(); - void SetOutputTypeBySubType(GUID subtype); - - Microsoft::WRL::ComPtr GetAttributes(); - Microsoft::WRL::ComPtr GetOutputStreamAttributes(); - - Microsoft::WRL::ComPtr GetSampleProtection(); - void GetStreamCount(DWORD* input_streamcount, DWORD* output_stream_count); - - HRESULT SendMessage(MFT_MESSAGE_TYPE msg, ULONG_PTR data = 0); - - // Reset the media transform to its original state. - void Reset(); - - private: - enum State { - kCanAcceptInput, - kCanProvideOutput, - kDraining, - kDrained, - kInvalidInput - }; - - void PrepareOutputDataBuffer(MFT_OUTPUT_DATA_BUFFER* output_data_buffer); - HRESULT ProcessOutput(Microsoft::WRL::ComPtr* sample); - - Microsoft::WRL::ComPtr transform_; - - ::starboard::shared::starboard::ThreadChecker thread_checker_; - State state_; - bool stream_begun_; - bool discontinuity_; - bool throttle_inputs_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_MEDIA_TRANSFORM_H_ diff --git a/starboard/shared/win32/memory_allocate_aligned_unchecked.cc b/starboard/shared/win32/memory_allocate_aligned_unchecked.cc deleted file mode 100644 index 57e2494812de..000000000000 --- a/starboard/shared/win32/memory_allocate_aligned_unchecked.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" - -#include - -#if SB_API_VERSION < 16 -void* SbMemoryAllocateAlignedUnchecked(size_t alignment, size_t size) { - return _aligned_malloc(size, alignment); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_allocate_unchecked.cc b/starboard/shared/win32/memory_allocate_unchecked.cc deleted file mode 100644 index 833045957703..000000000000 --- a/starboard/shared/win32/memory_allocate_unchecked.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" - -#include - -void* SbMemoryAllocateUnchecked(size_t size) { - return HeapAlloc(GetProcessHeap(), 0, size); -} diff --git a/starboard/shared/win32/memory_flush.cc b/starboard/shared/win32/memory_flush.cc deleted file mode 100644 index 7beacede7acc..000000000000 --- a/starboard/shared/win32/memory_flush.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/common/log.h" -#include "starboard/memory.h" - -#include // NOLINT(build/include_order) - -#if !SB_CAN(MAP_EXECUTABLE_MEMORY) -#error \ - "You shouldn't implement SbMemoryFlush unless you can map " \ - "memory pages as executable" -#endif - -void SbMemoryFlush(void* virtual_address, int64_t size_bytes) { - SB_NOTIMPLEMENTED(); - // TODO: Enable the following implementation when xb1 can compile it. - // FlushInstructionCache(GetCurrentProcess(), virtual_address, size_bytes); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_free.cc b/starboard/shared/win32/memory_free.cc deleted file mode 100644 index 4eb2535ba106..000000000000 --- a/starboard/shared/win32/memory_free.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" - -#include - -void SbMemoryFree(void* memory) { - HeapFree(GetProcessHeap(), 0, memory); -} diff --git a/starboard/shared/win32/memory_free_aligned.cc b/starboard/shared/win32/memory_free_aligned.cc deleted file mode 100644 index 93c140c810d1..000000000000 --- a/starboard/shared/win32/memory_free_aligned.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" - -#include - -#if SB_API_VERSION < 16 -void SbMemoryFreeAligned(void* memory) { - _aligned_free(memory); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_map.cc b/starboard/shared/win32/memory_map.cc deleted file mode 100644 index 3d4279a2a1d8..000000000000 --- a/starboard/shared/win32/memory_map.cc +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -#include - -#include "starboard/common/log.h" - -void* SbMemoryMap(int64_t size_bytes, int flags, const char* name) { - if (size_bytes == 0) { - return SB_MEMORY_MAP_FAILED; - } - ULONG protect = PAGE_NOACCESS; - // |flags| is a bitmask of SbMemoryMapFlags, but |protect| is not a bitmask. - switch (flags) { - case kSbMemoryMapProtectReserved: { - protect = PAGE_NOACCESS; - break; - } - case kSbMemoryMapProtectRead: - protect = PAGE_READONLY; - break; - case kSbMemoryMapProtectWrite: - // Windows does not provide write only mode privileges - // are escalated to read/write. - case kSbMemoryMapProtectReadWrite: - protect = PAGE_READWRITE; - break; - default: - SB_NOTIMPLEMENTED() << "memory flag " << flags << " not supported."; - return SB_MEMORY_MAP_FAILED; - } - - void* memory = VirtualAllocFromApp( - NULL, size_bytes, - (flags == kSbMemoryMapProtectReserved) ? MEM_RESERVE : MEM_COMMIT, - protect); - return memory; -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_protect.cc b/starboard/shared/win32/memory_protect.cc deleted file mode 100644 index 7f73cca1c302..000000000000 --- a/starboard/shared/win32/memory_protect.cc +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -#include - -bool SbMemoryProtect(void* virtual_address, int64_t size_bytes, int flags) { - ULONG new_protection = 0; - - switch (flags) { - case kSbMemoryMapProtectReserved: - // After this call, the address will be in reserved state. - return VirtualFree(virtual_address, size_bytes, MEM_DECOMMIT); - case kSbMemoryMapProtectRead: - new_protection = PAGE_READONLY; - break; - - // Windows does not provide write only mode privileges - // are escalated to read/write. - case kSbMemoryMapProtectWrite: - case kSbMemoryMapProtectReadWrite: - new_protection = PAGE_READWRITE; - break; - -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - case kSbMemoryMapProtectExec: - new_protection = PAGE_EXECUTE; - break; - case kSbMemoryMapProtectRead | kSbMemoryMapProtectExec: - new_protection = PAGE_EXECUTE_READ; - break; -#endif - - // No other protections are supported, see - // https://msdn.microsoft.com/en-us/library/windows/desktop/mt169846. - default: - return false; - } - - ULONG old_protection; - // Changing protection from No-Access to others needs the memory to be - // committed first. Commit committed pages will not reset them to zero. - VirtualAllocFromApp(virtual_address, size_bytes, MEM_COMMIT, PAGE_READONLY); - return VirtualProtectFromApp(virtual_address, size_bytes, new_protection, - &old_protection) != 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_reallocate_unchecked.cc b/starboard/shared/win32/memory_reallocate_unchecked.cc deleted file mode 100644 index 306c3b3a7c65..000000000000 --- a/starboard/shared/win32/memory_reallocate_unchecked.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" - -#if SB_API_VERSION < 16 -#include - -void* SbMemoryReallocateUnchecked(void* memory, size_t size) { - if (memory == NULL) { - return SbMemoryAllocateUnchecked(size); - } - return HeapReAlloc(GetProcessHeap(), 0, memory, size); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/memory_unmap.cc b/starboard/shared/win32/memory_unmap.cc deleted file mode 100644 index 8b563555ed44..000000000000 --- a/starboard/shared/win32/memory_unmap.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -#include - -bool SbMemoryUnmap(void* virtual_address, int64_t size_bytes) { - // Note that SbMemoryUnmap documentation says that "This function can - // unmap multiple contiguous regions that were mapped with separate calls - // to SbMemoryMap()". Because of that, we cannot use MEM_FREE here. - return VirtualFree(virtual_address, size_bytes, MEM_DECOMMIT); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mini_dump_printer.py b/starboard/shared/win32/mini_dump_printer.py deleted file mode 100644 index 749709251f6b..000000000000 --- a/starboard/shared/win32/mini_dump_printer.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Module for mini dump analysis and printing""" - -from __future__ import print_function - -import os -import subprocess -import sys - -# This cdb tool is part of Microsoft's debugging toolset, it will allow mini -# dump analysis and printing. -_DEFAULT_TOOL_PATH = ('C:/Program Files (x86)/Windows Kits/10/Debuggers/x64' - '/cdb.exe') - - -def PrintMiniDump(mini_dump_path, - out_stream=sys.stdout, - tool_path=_DEFAULT_TOOL_PATH): - out_stream.write('\n*** Found crash dump! ***\nMinDumpPath:' + - mini_dump_path + '\n') - - tool_path = os.path.abspath(tool_path) - if not os.path.isfile(tool_path): - out_stream.write('Could not perform crash analysis because ' + tool_path\ - + ' does not exist.\n') - return - - dump_log = mini_dump_path + '.log' - cmd = (f'"{tool_path}" -z "{mini_dump_path}" -c "!analyze -v;q" > ' - f'{dump_log}') - - try: - out_stream.write('Running command:\n' + cmd + '\n') - subprocess.check_output(cmd, shell=True, universal_newlines=True) - - if not os.path.exists(dump_log): - out_stream.write('Error - mini dump log ' + dump_log\ - + ' was not found.\n') - return - with open(dump_log, encoding='utf-8') as f: - out_stream.write(f.read() + '\n') - out_stream.write('*** Finished printing minidump ' + mini_dump_path + - ' ***\n' + 'For more information, use VisualStudio ' + - 'to load the minidump.\n') - os.remove(dump_log) - except Exception as e: # pylint: disable=broad-except - out_stream.write('Error: ' + str(e)) diff --git a/starboard/shared/win32/minidump.cc b/starboard/shared/win32/minidump.cc deleted file mode 100644 index b236269dcdd0..000000000000 --- a/starboard/shared/win32/minidump.cc +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/minidump.h" - -// clang-format off -#include // Has to go first. -// clang-format on -#include -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/shared/win32/file_internal.h" - -using starboard::Mutex; -using starboard::ScopedLock; -using starboard::shared::win32::NormalizeWin32Path; - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -class DumpHandler { - public: - static DumpHandler* Instance(); - - void Init(std::string file_path) { - ScopedLock lock(mutex_); - if (initialized_) { - return; - } - file_path_ = file_path; - // After this call, unhandled exceptions will use the exception handler - // when an error occurs but only if the debugger is not attached. - SetUnhandledExceptionFilter(UnhandledExceptionHandler); - - std::stringstream ss; - ss << "\n****MiniDumpHandler activated***\nIf a crash happens then an " - << "attempt to write a MiniDump file to: " << file_path << "\n\n"; - SbLogRaw(ss.str().c_str()); - - initialized_ = true; - } - - private: - static LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* pep) { - DumpHandler::Instance()->DumpStack(pep); - return EXCEPTION_EXECUTE_HANDLER; - } - DumpHandler() {} - - void DumpStack(EXCEPTION_POINTERS* pep) { - ScopedLock lock(mutex_); - if (file_path_.empty()) { - SbLogRaw("Could not write minidump because the dump path is missing."); - return; - } - - HANDLE file_handle = - OpenFileOrDirectory(file_path_.c_str(), O_CREAT | O_TRUNC | O_WRONLY); - - const bool file_ok = - (file_handle != NULL) && (file_handle != INVALID_HANDLE_VALUE); - - if (!file_ok) { - std::stringstream ss; - ss << "CreateFile failed. Error: " << GetLastError() << "\n"; - SbLogRaw(ss.str().c_str()); - return; - } - - // Create the minidump. - MINIDUMP_EXCEPTION_INFORMATION mdei; - mdei.ThreadId = GetCurrentThreadId(); - mdei.ExceptionPointers = pep; - mdei.ClientPointers = TRUE; - MINIDUMP_TYPE mdt = static_cast( - MiniDumpWithFullMemory | MiniDumpWithFullMemoryInfo | - MiniDumpWithHandleData | MiniDumpWithThreadInfo | - MiniDumpWithUnloadedModules); - - BOOL rv = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), - file_handle, mdt, (pep != 0) ? &mdei : 0, 0, 0); - std::stringstream ss; - if (!rv) { - ss << "Minidump write failed. Error: " << GetLastError() << "\n"; - } else { - ss << "Minidump " << file_path_ << "created.\n"; - } - // Lower level logging than SbLogRaw(). - SbLogRaw(ss.str().c_str()); - CloseHandle(file_handle); - } - - std::string file_path_; - starboard::Mutex mutex_; - bool initialized_ = false; -}; - -SB_ONCE_INITIALIZE_FUNCTION(DumpHandler, DumpHandler::Instance); - -} // namespace - -void InitMiniDumpHandler(const char* file_path) { -#ifndef COBALT_BUILD_TYPE_GOLD - DumpHandler::Instance()->Init(file_path); -#endif -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/minidump.h b/starboard/shared/win32/minidump.h deleted file mode 100644 index 0f0137b0237d..000000000000 --- a/starboard/shared/win32/minidump.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_MINIDUMP_H_ -#define STARBOARD_SHARED_WIN32_MINIDUMP_H_ - -namespace starboard { -namespace shared { -namespace win32 { - -// After this call, any crashes will cause a mini dump file to be written -// to the file path. Note that the dump file will only be written if the -// process is not running in a debugger (e.g. inside of Visual Studio). -// -// Example 1: -// InitMiniDumpHandler("cobalt.exe.dmp"); // Relative path to current working -// // directory -// Example 2: -// InitMiniDumpHandler("C:\\...\\cobalt.exe.dmp") // Absolute path. -void InitMiniDumpHandler(const char* file_path); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_MINIDUMP_H_ diff --git a/starboard/shared/win32/mutex_acquire.cc b/starboard/shared/win32/mutex_acquire.cc deleted file mode 100644 index 7c4bab841b86..000000000000 --- a/starboard/shared/win32/mutex_acquire.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -SbMutexResult SbMutexAcquire(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - AcquireSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); - return kSbMutexAcquired; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_acquire_try.cc b/starboard/shared/win32/mutex_acquire_try.cc deleted file mode 100644 index bc78ddaeab92..000000000000 --- a/starboard/shared/win32/mutex_acquire_try.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -SbMutexResult SbMutexAcquireTry(SbMutex* mutex) { - if (!mutex) { - return kSbMutexDestroyed; - } - bool result = TryAcquireSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); - return result ? kSbMutexAcquired : kSbMutexBusy; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_create.cc b/starboard/shared/win32/mutex_create.cc deleted file mode 100644 index de9039c22dae..000000000000 --- a/starboard/shared/win32/mutex_create.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/types_internal.h" - -bool SbMutexCreate(SbMutex* mutex) { - SB_COMPILE_ASSERT(sizeof(SbMutex) >= sizeof(SRWLOCK), - srwlock_larger_than_sb_mutex); - if (!mutex) { - return false; - } - InitializeSRWLock(SB_WIN32_INTERNAL_MUTEX(mutex)); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_destroy.cc b/starboard/shared/win32/mutex_destroy.cc deleted file mode 100644 index d8745b771993..000000000000 --- a/starboard/shared/win32/mutex_destroy.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/configuration.h" - -bool SbMutexDestroy(SbMutex* mutex) { - if (!mutex) { - return false; - } - // On Windows a SRWLOCK is used in place of the heavier mutex. These locks - // cannot be acquired recursively, and the behavior when this is attempted is - // not clear in the documentation. A Microsoft DevBlog seems to suggest this - // is undefined behavior: - // - // It’s a programming error. It is your responsibility as a programmer not - // to call Acquire­SRW­Lock­Shared or Acquire­SRW­Lock­Exclusive from a - // thread that has already acquired the lock. Failing to comply with this - // rule will result in undefined behavior. - // - // https://devblogs.microsoft.com/oldnewthing/20160819-00/?p=94125 - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/mutex_release.cc b/starboard/shared/win32/mutex_release.cc deleted file mode 100644 index a1d3839baea2..000000000000 --- a/starboard/shared/win32/mutex_release.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/mutex.h" - -#include - -#include "starboard/shared/win32/types_internal.h" - -bool SbMutexRelease(SbMutex* mutex) { - if (!mutex) { - return false; - } - ReleaseSRWLockExclusive(SB_WIN32_INTERNAL_MUTEX(mutex)); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/once.cc b/starboard/shared/win32/once.cc deleted file mode 100644 index 05df1dca3706..000000000000 --- a/starboard/shared/win32/once.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/common/once.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/types_internal.h" - -namespace { -BOOL CALLBACK OnceTrampoline(PINIT_ONCE once_control, - void* parameter, - void** context) { - static_cast(parameter)(); - return true; -} - -} // namespace - -bool SbOnce(SbOnceControl* once_control, SbOnceInitRoutine init_routine) { - SB_COMPILE_ASSERT(sizeof(SbOnceControl) >= sizeof(INIT_ONCE), - init_once_larger_than_sb_once_control); - if (!once_control || !init_routine) { - return false; - } - return InitOnceExecuteOnce(SB_WIN32_INTERNAL_ONCE(once_control), - OnceTrampoline, init_routine, NULL); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/player_components_factory.cc b/starboard/shared/win32/player_components_factory.cc deleted file mode 100644 index 601679181169..000000000000 --- a/starboard/shared/win32/player_components_factory.cc +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/starboard/player/filter/player_components.h" - -#include "starboard/common/log.h" -#include "starboard/common/ref_counted.h" -#include "starboard/shared/opus/opus_audio_decoder.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/filter/adaptive_audio_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/audio_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/audio_renderer_sink_impl.h" -#include "starboard/shared/starboard/player/filter/video_decoder_internal.h" -#include "starboard/shared/starboard/player/filter/video_render_algorithm.h" -#include "starboard/shared/starboard/player/filter/video_render_algorithm_impl.h" -#include "starboard/shared/starboard/player/filter/video_renderer_sink.h" -#include "starboard/shared/win32/audio_decoder.h" -#include "starboard/shared/win32/video_decoder.h" - -namespace starboard { -namespace shared { -namespace starboard { -namespace player { -namespace filter { - -namespace { - -class PlayerComponentsFactory : public PlayerComponents::Factory { - bool CreateSubComponents( - const CreationParameters& creation_parameters, - std::unique_ptr* audio_decoder, - std::unique_ptr* audio_renderer_sink, - std::unique_ptr* video_decoder, - std::unique_ptr* video_render_algorithm, - scoped_refptr* video_renderer_sink, - std::string* error_message) override { - SB_DCHECK(error_message); - - if (creation_parameters.audio_codec() != kSbMediaAudioCodecNone) { - SB_DCHECK(audio_decoder); - SB_DCHECK(audio_renderer_sink); - - auto decoder_creator = [](const media::AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system) { - using AacAudioDecoderImpl = ::starboard::shared::win32::AudioDecoder; - using OpusAudioDecoderImpl = - ::starboard::shared::opus::OpusAudioDecoder; - - if (audio_stream_info.codec == kSbMediaAudioCodecAac) { - return std::unique_ptr( - new AacAudioDecoderImpl(audio_stream_info, drm_system)); - } else if (audio_stream_info.codec == kSbMediaAudioCodecOpus) { - return std::unique_ptr( - new OpusAudioDecoderImpl(audio_stream_info)); - } else { - SB_NOTREACHED(); - } - return std::unique_ptr(); - }; - - audio_decoder->reset(new AdaptiveAudioDecoder( - creation_parameters.audio_stream_info(), - creation_parameters.drm_system(), decoder_creator)); - audio_renderer_sink->reset(new AudioRendererSinkImpl); - } - - if (creation_parameters.video_codec() != kSbMediaVideoCodecNone) { - using VideoDecoderImpl = ::starboard::shared::win32::VideoDecoder; - - SB_DCHECK(video_decoder); - SB_DCHECK(video_render_algorithm); - SB_DCHECK(video_renderer_sink); - - std::unique_ptr video_decoder_impl(new VideoDecoderImpl( - creation_parameters.video_codec(), creation_parameters.output_mode(), - creation_parameters.decode_target_graphics_context_provider(), - creation_parameters.drm_system())); - *video_renderer_sink = NULL; - video_decoder->reset(video_decoder_impl.release()); - video_render_algorithm->reset(new VideoRenderAlgorithmImpl); - } - - return true; - } -}; - -} // namespace - -// static -std::unique_ptr PlayerComponents::Factory::Create() { - return std::unique_ptr( - new PlayerComponentsFactory); -} - -// static -bool PlayerComponents::Factory::OutputModeSupported( - SbPlayerOutputMode output_mode, - SbMediaVideoCodec codec, - SbDrmSystem drm_system) { - return output_mode == kSbPlayerOutputModeDecodeToTexture; -} - -} // namespace filter -} // namespace player -} // namespace starboard -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/playready_license.cc b/starboard/shared/win32/playready_license.cc deleted file mode 100644 index 421df2ad6dbe..000000000000 --- a/starboard/shared/win32/playready_license.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/drm_system_playready.h" - -#include "starboard/configuration.h" - -namespace starboard { -namespace shared { -namespace win32 { - -scoped_refptr DrmSystemPlayready::License::Create( - const void* initialization_data, - int initialization_data_size) { - return NULL; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/posix_emu/dirent.cc b/starboard/shared/win32/posix_emu/dirent.cc deleted file mode 100644 index e2531a8017e2..000000000000 --- a/starboard/shared/win32/posix_emu/dirent.cc +++ /dev/null @@ -1,241 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" -#include "starboard/types.h" - -struct CriticalSection { - CriticalSection() { InitializeCriticalSection(&critical_section_); } - CRITICAL_SECTION critical_section_; -}; - -static int gen_fd() { - static int fd = 100; - fd++; - if (fd == 0x7FFFFFFF) { - fd = 100; - } - return fd; -} - -static std::map>* directory_map = nullptr; -static CriticalSection g_critical_section; - -static int handle_db_put(std::deque next_directory_entry) { - EnterCriticalSection(&g_critical_section.critical_section_); - if (directory_map == nullptr) { - directory_map = new std::map>(); - } - - int fd = gen_fd(); - // Go through the map and make sure there isn't duplicated index - // already. - while (directory_map->find(fd) != directory_map->end()) { - fd = gen_fd(); - } - - directory_map->insert({fd, next_directory_entry}); - - LeaveCriticalSection(&g_critical_section.critical_section_); - return fd; -} - -static std::deque handle_db_get(int fd, bool erase) { - std::deque empty_deque; - if (fd < 0) { - return empty_deque; - } - EnterCriticalSection(&g_critical_section.critical_section_); - if (directory_map == nullptr) { - LeaveCriticalSection(&g_critical_section.critical_section_); - return empty_deque; - } - - auto itr = directory_map->find(fd); - if (itr == directory_map->end()) { - LeaveCriticalSection(&g_critical_section.critical_section_); - return empty_deque; - } - - std::deque next_directory_entry = itr->second; - if (erase) { - directory_map->erase(itr); - } - LeaveCriticalSection(&g_critical_section.critical_section_); - return next_directory_entry; -} - -static void handle_db_replace(int fd, - std::deque next_directory_entry) { - EnterCriticalSection(&g_critical_section.critical_section_); - if (directory_map == nullptr) { - directory_map = new std::map>(); - } - auto itr = directory_map->find(fd); - if (itr == directory_map->end()) { - directory_map->insert({fd, next_directory_entry}); - } else { - directory_map->erase(itr); - directory_map->insert({fd, next_directory_entry}); - } - LeaveCriticalSection(&g_critical_section.critical_section_); -} - -const std::size_t kDirectoryInfoBufferSize = - kSbFileMaxPath + sizeof(FILE_ID_BOTH_DIR_INFO); - -std::deque GetDirectoryEntries(HANDLE directory_handle) { - // According to - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa364226(v=vs.85).aspx, - // FILE_ID_BOTH_DIR_INFO must be aligned on a DWORDLONG boundary. - alignas(sizeof(DWORDLONG)) std::vector directory_info_buffer( - kDirectoryInfoBufferSize); - - std::deque entries; - BOOL directory_info_success = GetFileInformationByHandleEx( - directory_handle, FileIdBothDirectoryInfo, directory_info_buffer.data(), - static_cast(directory_info_buffer.size())); - - if (!directory_info_success) { - return entries; - } - - const char* directory_info_pointer = directory_info_buffer.data(); - DWORD next_entry_offset = 0; - - do { - auto directory_info = - reinterpret_cast(directory_info_pointer); - - // FileName is in Unicode, so divide by 2 to get the real length. - DWORD number_characters_in_filename = directory_info->FileNameLength / 2; - std::string ascii_path = starboard::shared::win32::wchar_tToUTF8( - directory_info->FileName, number_characters_in_filename); - SB_DCHECK(ascii_path.size() == number_characters_in_filename); - bool is_dotted_directory = - !ascii_path.compare(".") || !ascii_path.compare(".."); - if (!is_dotted_directory) { - entries.emplace_back(std::move(ascii_path)); - } - next_entry_offset = directory_info->NextEntryOffset; - directory_info_pointer += next_entry_offset; - } while (next_entry_offset != 0); - - return entries; -} - -extern "C" { - -DIR* opendir(const char* path) { - using starboard::shared::win32::CStringToWString; - using starboard::shared::win32::NormalizeWin32Path; - - if ((path == nullptr) || (path[0] == '\0')) { - errno = ENOENT; - return nullptr; - } - - std::wstring path_wstring = NormalizeWin32Path(path); - - if (!starboard::shared::win32::IsAbsolutePath(path_wstring)) { - errno = EBADF; - return nullptr; - } - - HANDLE directory_handle = - starboard::shared::win32::OpenFileOrDirectory(path, O_RDONLY); - - if (!starboard::shared::win32::IsValidHandle(directory_handle)) { - errno = EBADF; - return nullptr; - } - - FILE_BASIC_INFO basic_info = {0}; - BOOL basic_info_success = GetFileInformationByHandleEx( - directory_handle, FileBasicInfo, &basic_info, sizeof(FILE_BASIC_INFO)); - - if (!basic_info_success || - !(basic_info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { - CloseHandle(directory_handle); - errno = ENOTDIR; - return nullptr; - } - - DIR* dir = reinterpret_cast(calloc(1, sizeof(DIR))); - dir->handle = directory_handle; - dir->fd = handle_db_put(std::deque()); - return dir; -} - -int closedir(DIR* dir) { - if (!dir) { - errno = EBADF; - return -1; - } - bool success = CloseHandle(dir->handle); - handle_db_get(dir->fd, true); - free(dir); - if (!success) { - errno = EBADF; - return -1; - } - return 0; -} - -int readdir_r(DIR* __restrict dir, - struct dirent* __restrict dirent_buf, - struct dirent** __restrict dirent) { - if (!dir || !dirent_buf || !dirent) { - if (dirent) { - *dirent = nullptr; - } - return EBADF; - } - - auto next_directory_entries = handle_db_get(dir->fd, false); - if (next_directory_entries.empty()) { - next_directory_entries = GetDirectoryEntries(dir->handle); - } - - if (next_directory_entries.empty()) { - *dirent = nullptr; - return ENOENT; - } - - if (starboard::strlcpy(dirent_buf->d_name, - next_directory_entries.rbegin()->c_str(), - kSbFileMaxName) >= kSbFileMaxName) { - *dirent = nullptr; - return ENOENT; - } - - *dirent = dirent_buf; - next_directory_entries.pop_back(); - handle_db_replace(dir->fd, next_directory_entries); - - return 0; -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/ifaddrs.cc b/starboard/shared/win32/posix_emu/ifaddrs.cc deleted file mode 100644 index b0ceb387352c..000000000000 --- a/starboard/shared/win32/posix_emu/ifaddrs.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include - -void freeifaddrs(struct ifaddrs* ifa) { - struct ifaddrs* ptr = ifa; - struct ifaddrs* last_ptr = ifa; - while (ptr != nullptr) { - if (ptr->ifa_addr != nullptr) { - delete ptr->ifa_addr; - ptr->ifa_addr = nullptr; - } - ptr = ptr->ifa_next; - delete last_ptr; - last_ptr = ptr; - } -} - -int getifaddrs(struct ifaddrs** ifap) { - char ac[80]; - struct ifaddrs* ifaddr_ptr = nullptr; - struct ifaddrs* last_ifaddr_ptr = nullptr; - - if (gethostname(ac, sizeof(ac)) == SOCKET_ERROR) { - return -1; - } - - struct hostent* phe = gethostbyname(ac); - if (phe == 0) { - return -1; - } - - for (int i = 0; phe->h_addr_list[i] != 0; ++i) { - ifaddr_ptr = new struct ifaddrs; - memset(ifaddr_ptr, 0, sizeof(struct ifaddrs)); - if (i == 0) { - *ifap = ifaddr_ptr; - } - if (last_ifaddr_ptr != nullptr) { - last_ifaddr_ptr->ifa_next = ifaddr_ptr; - } - last_ifaddr_ptr = ifaddr_ptr; - - ifaddr_ptr->ifa_addr = new struct sockaddr; - struct sockaddr_in in_addr = {0}; - memcpy(&in_addr.sin_addr, phe->h_addr_list[i], sizeof(in_addr.sin_addr)); - in_addr.sin_family = AF_INET; - memcpy(ifaddr_ptr->ifa_addr, &in_addr, sizeof(sockaddr)); - - ifaddr_ptr->ifa_next = nullptr; - } - - return 0; -} diff --git a/starboard/shared/win32/posix_emu/include/arpa/inet.h b/starboard/shared/win32/posix_emu/include/arpa/inet.h deleted file mode 100644 index 7409ce676e52..000000000000 --- a/starboard/shared/win32/posix_emu/include/arpa/inet.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_ARPA_INET_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_ARPA_INET_H_ - -#include -#include -#include -#include - -#include "starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h" - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_ARPA_INET_H_ diff --git a/starboard/shared/win32/posix_emu/include/dirent.h b/starboard/shared/win32/posix_emu/include/dirent.h deleted file mode 100644 index 1286844c5819..000000000000 --- a/starboard/shared/win32/posix_emu/include/dirent.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_DIRENT_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_DIRENT_H_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -struct __dirstream { - int tell; - int fd; - int buf_pos; - int buf_end; - volatile int lock[1]; - HANDLE handle; - char buf[2048]; -}; - -struct dirent { - int d_ino; - int d_off; - int d_reclen; - unsigned char d_type; - char d_name[256]; -}; - -typedef struct __dirstream DIR; - -DIR* opendir(const char* path); - -int closedir(DIR* dir); - -int readdir_r(DIR* __restrict dir, - struct dirent* __restrict dirent_buf, - struct dirent** __restrict dirent); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_DIRENT_H_ diff --git a/starboard/shared/win32/posix_emu/include/fcntl.h b/starboard/shared/win32/posix_emu/include/fcntl.h deleted file mode 100644 index a86989dfa0e5..000000000000 --- a/starboard/shared/win32/posix_emu/include/fcntl.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_FCNTL_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_FCNTL_H_ - -#include <../ucrt/fcntl.h> // The Visual Studio version of this same file -#include <../ucrt/sys/stat.h> -#include // Needed for `open`, which is in fcntl.h on POSIX - -#undef open - -#define F_GETFL 3 /* get file->f_flags */ -#define F_SETFL 4 /* set file->f_flags */ - -#ifndef O_NONBLOCK -#define O_NONBLOCK 00004000 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -int sb_fcntl(int fd, int cmd, ... /*arg*/); -#define fcntl sb_fcntl - -int sb_open(const char* path, int oflag, ...); -#define open sb_open - -#ifdef __cplusplus -} -#endif -typedef int mode_t; - -// For the POSIX modes that do not have a Windows equivalent, the modes -// defined here use the POSIX values left shifted 16 bits. -// Passing these into Windows file I/O functions has no effect. - -static const mode_t S_ISUID = 0x40000000; -static const mode_t S_ISGID = 0x20000000; -static const mode_t S_ISVTX = 0x10000000; -static const mode_t S_IRWXU = 0x07000000; -static const mode_t S_IRUSR = _S_IREAD; // read by user -static const mode_t S_IWUSR = _S_IWRITE; // write by user -static const mode_t S_IXUSR = 0x01000000; -static const mode_t S_IRGRP = 0x00400000; -static const mode_t S_IWGRP = 0x00200000; -static const mode_t S_IXGRP = 0x00100000; -static const mode_t S_IRWXO = 0x00070000; -static const mode_t S_IROTH = 0x00040000; -static const mode_t S_IWOTH = 0x00020000; -static const mode_t S_IXOTH = 0x00010000; - -static const mode_t MS_MODE_MASK = 0x0000ffff; - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_FCNTL_H_ diff --git a/starboard/shared/win32/posix_emu/include/ifaddrs.h b/starboard/shared/win32/posix_emu/include/ifaddrs.h deleted file mode 100644 index e986db151119..000000000000 --- a/starboard/shared/win32/posix_emu/include/ifaddrs.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_IFADDRS_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_IFADDRS_H_ - -struct ifaddrs { - struct ifaddrs* ifa_next; /* Next item in list */ - char* ifa_name; /* Name of interface */ - unsigned int ifa_flags; /* Flags from SIOCGIFFLAGS */ - struct sockaddr* ifa_addr; /* Address of interface */ - struct sockaddr* ifa_netmask; /* Netmask of interface */ - union { - struct sockaddr* ifu_broadaddr; - /* Broadcast address of interface */ - struct sockaddr* ifu_dstaddr; - /* Point-to-point destination address */ - } ifa_ifu; -#define ifa_broadaddr ifa_ifu.ifu_broadaddr -#define ifa_dstaddr ifa_ifu.ifu_dstaddr - void* ifa_data; /* Address-specific data */ -}; - -int getifaddrs(struct ifaddrs** ifap); -void freeifaddrs(struct ifaddrs* ifa); - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_IFADDRS_H_ diff --git a/starboard/shared/win32/posix_emu/include/malloc.h b/starboard/shared/win32/posix_emu/include/malloc.h deleted file mode 100644 index a04d0861e61c..000000000000 --- a/starboard/shared/win32/posix_emu/include/malloc.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_MALLOC_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_MALLOC_H_ - -#include <../ucrt/malloc.h> // The Visual Studio version of this same file - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html -// NOTE: Also declared in stdlib.h and implementation in stdlib.cc. -void sb_free(void* ptr); -#undef free -#define free sb_free - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_MALLOC_H_ diff --git a/starboard/shared/win32/posix_emu/include/netdb.h b/starboard/shared/win32/posix_emu/include/netdb.h deleted file mode 100644 index d7389ed044ec..000000000000 --- a/starboard/shared/win32/posix_emu/include/netdb.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETDB_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETDB_H_ - -#include - -#include "starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h" - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETDB_H_ diff --git a/starboard/shared/win32/posix_emu/include/netinet/in.h b/starboard/shared/win32/posix_emu/include/netinet/in.h deleted file mode 100644 index 77c73bb8f954..000000000000 --- a/starboard/shared/win32/posix_emu/include/netinet/in.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_IN_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_IN_H_ - -#include -#include - -#include "starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h" - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_IN_H_ diff --git a/starboard/shared/win32/posix_emu/include/netinet/tcp.h b/starboard/shared/win32/posix_emu/include/netinet/tcp.h deleted file mode 100644 index 96944e25ed7a..000000000000 --- a/starboard/shared/win32/posix_emu/include/netinet/tcp.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_TCP_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_TCP_H_ - -#include - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_NETINET_TCP_H_ diff --git a/starboard/shared/win32/posix_emu/include/pthread.h b/starboard/shared/win32/posix_emu/include/pthread.h deleted file mode 100644 index 91b3131573cc..000000000000 --- a/starboard/shared/win32/posix_emu/include/pthread.h +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_PTHREAD_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_PTHREAD_H_ - -#include -#include - -#ifdef __cplusplus -#define _INITIALIZER \ - {} -#else -#define _INITIALIZER {0} -#endif - -#define PTHREAD_MUTEX_INITIALIZER _INITIALIZER -#define PTHREAD_COND_INITIALIZER _INITIALIZER -#define PTHREAD_ONCE_INIT _INITIALIZER - -#define PTHREAD_CREATE_JOINABLE 0 -#define PTHREAD_CREATE_DETACHED 1 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef union pthread_cond_t { - uint8_t buffer[8]; - void* ptr; -} pthread_cond_t; - -typedef union pthread_mutex_t { - uint8_t buffer[8]; - void* ptr; -} pthread_mutex_t; - -typedef union pthread_once_t { - uint8_t buffer[8]; - void* ptr; -} pthread_once_t; - -typedef unsigned int pthread_mutexattr_t; -typedef uintptr_t pthread_key_t; -typedef unsigned int pthread_condattr_t; -typedef uintptr_t pthread_t; -typedef uintptr_t pthread_attr_t; - -int pthread_mutex_destroy(pthread_mutex_t* mutex); -int pthread_mutex_init(pthread_mutex_t* mutex, - const pthread_mutexattr_t* mutex_attr); -int pthread_mutex_lock(pthread_mutex_t* mutex); -int pthread_mutex_unlock(pthread_mutex_t* mutex); -int pthread_mutex_trylock(pthread_mutex_t* mutex); - -int pthread_key_create(pthread_key_t* key, void (*dtor)(void*)); -int pthread_key_delete(pthread_key_t key); -void* pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, const void* value); - -int pthread_cond_broadcast(pthread_cond_t* cond); -int pthread_cond_destroy(pthread_cond_t* cond); -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr); -int pthread_cond_signal(pthread_cond_t* cond); -int pthread_cond_timedwait(pthread_cond_t* cond, - pthread_mutex_t* mutex, - const struct timespec* t); -int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex); -int pthread_condattr_destroy(pthread_condattr_t* attr); -int pthread_condattr_getclock(const pthread_condattr_t* attr, - clockid_t* clock_id); -int pthread_condattr_init(pthread_condattr_t* attr); -int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock_id); - -int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)); - -int pthread_create(pthread_t* thread, - const pthread_attr_t* attr, - void* (*start_routine)(void*), - void* arg); -int pthread_join(pthread_t thread, void** value_ptr); -int pthread_detach(pthread_t thread); -pthread_t pthread_self(); -int pthread_equal(pthread_t t1, pthread_t t2); - -int pthread_setname_np(pthread_t thread, const char* name); -int pthread_getname_np(pthread_t thread, char* name, size_t len); - -int pthread_attr_init(pthread_attr_t* attr); -int pthread_attr_destroy(pthread_attr_t* attr); - -int pthread_attr_getstacksize(const pthread_attr_t* attr, size_t* stack_size); -int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size); - -int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state); -int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state); - -#ifdef __cplusplus -} -#endif - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_PTHREAD_H_ diff --git a/starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h b/starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h deleted file mode 100644 index 41f8d891eb03..000000000000 --- a/starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// NOLINT(build/header_guard) - -// This file should only be included in other include files within posix_emu, -// after including any MSVC headers that may define macros that collide with -// Cobalt code. When undefining a macro here, provide a comment of which -// specific Windows header file defined it for future reference. -#undef NO_ERROR // winerror.h; b/302733082#comment15 -#undef CreateDirectory // fileapi.h -#undef DeleteFile // fileapi.h -#undef GetCurrentTime // winbase.h; b/324981660 -#undef PostMessage // winuser.h -#undef ReplaceFile // winbase.h diff --git a/starboard/shared/win32/posix_emu/include/sched.h b/starboard/shared/win32/posix_emu/include/sched.h deleted file mode 100644 index 2cce95db9d0e..000000000000 --- a/starboard/shared/win32/posix_emu/include/sched.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SCHED_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SCHED_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int sched_yield(); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SCHED_H_ diff --git a/starboard/shared/win32/posix_emu/include/stdlib.h b/starboard/shared/win32/posix_emu/include/stdlib.h deleted file mode 100644 index f2cfb52cb293..000000000000 --- a/starboard/shared/win32/posix_emu/include/stdlib.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STDLIB_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STDLIB_H_ - -#include <../ucrt/stdlib.h> // The Visual Studio version of this same file - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html -int posix_memalign(void** res, size_t alignment, size_t size); - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html -void sb_free(void* ptr); -#undef free -#define free sb_free - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STDLIB_H_ diff --git a/starboard/shared/win32/posix_emu/include/string.h b/starboard/shared/win32/posix_emu/include/string.h deleted file mode 100644 index 366ffed858e9..000000000000 --- a/starboard/shared/win32/posix_emu/include/string.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRING_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRING_H_ - -#include <../ucrt/string.h> // The Visual Studio version of this same file -#undef strdup // Remove the MSVC one since we're defining our own -#include // For historical reasons, glibc included these too - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/009604599/functions/strdup.html -char* strdup(const char* s1); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRING_H_ diff --git a/starboard/shared/win32/posix_emu/include/strings.h b/starboard/shared/win32/posix_emu/include/strings.h deleted file mode 100644 index afd0499b4c64..000000000000 --- a/starboard/shared/win32/posix_emu/include/strings.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRINGS_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRINGS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcasecmp.html -int strcasecmp(const char* s1, const char* s2); - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncasecmp.html -int strncasecmp(const char* s1, const char* s2, size_t n); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_STRINGS_H_ diff --git a/starboard/shared/win32/posix_emu/include/sys/mman.h b/starboard/shared/win32/posix_emu/include/sys/mman.h deleted file mode 100644 index c226390abaa9..000000000000 --- a/starboard/shared/win32/posix_emu/include/sys/mman.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_MMAN_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_MMAN_H_ - -#include - -#define PROT_NONE 0 -#define PROT_READ 1 -#define PROT_WRITE 2 -#define PROT_EXEC 4 - -#define MAP_PRIVATE 0x02 -#define MAP_ANON 0x20 - -#define MAP_FAILED ((void*)-1) - -#ifdef __cplusplus -extern "C" { -#endif - -void* mmap(void*, size_t, int, int, int, off_t); -int munmap(void*, size_t); -int mprotect(void*, size_t, int); -int msync(void*, size_t, int); - -#ifdef __cplusplus -} -#endif - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_MMAN_H_ diff --git a/starboard/shared/win32/posix_emu/include/sys/socket.h b/starboard/shared/win32/posix_emu/include/sys/socket.h deleted file mode 100644 index f92181e0aaa8..000000000000 --- a/starboard/shared/win32/posix_emu/include/sys/socket.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_SOCKET_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_SOCKET_H_ - -#include -#include -#include - -#include "starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h" - -#ifdef __cplusplus -extern "C" { -#endif - -int sb_socket(int domain, int type, int protocol); -#define socket sb_socket - -int sb_bind(int socket, const struct sockaddr* address, socklen_t address_len); -#define bind sb_bind - -int sb_listen(int socket, int backlog); -#define listen sb_listen - -int sb_accept(int socket, sockaddr* addr, int* addrlen); -#define accept sb_accept - -int sb_connect(int socket, const sockaddr* name, int namelen); -#define connect sb_connect - -int sb_send(int sockfd, const void* buf, size_t len, int flags); -#define send sb_send - -int sb_recv(int sockfd, void* buf, size_t len, int flags); -#define recv sb_recv - -int sb_sendto(int sockfd, - const void* buf, - size_t len, - int flags, - const struct sockaddr* dest_addr, - socklen_t dest_len); -#define sendto sb_sendto - -int sb_recvfrom(int sockfd, - void* buf, - size_t len, - int flags, - struct sockaddr* address, - socklen_t* address_len); -#define recvfrom sb_recvfrom - -int sb_setsockopt(int socket, - int level, - int option_name, - const void* option_value, - int option_len); -#define setsockopt sb_setsockopt - -int sb_getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen); -#define getsockname sb_getsockname - -int posix_socket_get_fd_from_handle(SOCKET socket); -SOCKET posix_socket_get_handle_from_fd(int socket); - -#ifdef __cplusplus -} -#endif -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_SOCKET_H_ diff --git a/starboard/shared/win32/posix_emu/include/sys/stat.h b/starboard/shared/win32/posix_emu/include/sys/stat.h deleted file mode 100644 index 1b40a221ea54..000000000000 --- a/starboard/shared/win32/posix_emu/include/sys/stat.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_STAT_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_STAT_H_ - -#include <../ucrt/sys/stat.h> - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define S_ISLNK(mode) 0 // Windows doesn't support symbolic links -#define S_ISDIR(mode) (((mode) & _S_IFMT) == (_S_IFDIR)) -#define S_ISREG(mode) (((mode) & _S_IFMT) == (_S_IFREG)) - -typedef int mode_t; - -// Implementation in socket.cc -int sb_fstat(int fd, struct stat* buffer); -#define fstat sb_fstat - -int sb_mkdir(const char* path, mode_t mode); -#undef mkdir -#define mkdir sb_mkdir - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_STAT_H_ diff --git a/starboard/shared/win32/posix_emu/include/sys/time.h b/starboard/shared/win32/posix_emu/include/sys/time.h deleted file mode 100644 index cab4d1c95858..000000000000 --- a/starboard/shared/win32/posix_emu/include/sys/time.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_TIME_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_TIME_H_ - -#include // For struct timeval - -#include "starboard/shared/win32/posix_emu/include/remove_problematic_windows_macros.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html -// https://learn.microsoft.com/en-us/windows/win32/api/winsock2/ns-winsock2-timeval -typedef long suseconds_t; // NOLINT(runtime/int) - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html -int gettimeofday(struct timeval* tp, void* tzp); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_SYS_TIME_H_ diff --git a/starboard/shared/win32/posix_emu/include/time.h b/starboard/shared/win32/posix_emu/include/time.h deleted file mode 100644 index 0288032bd851..000000000000 --- a/starboard/shared/win32/posix_emu/include/time.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_TIME_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_TIME_H_ - -// struct timespec is defined in the system time.h -#include <../ucrt/time.h> // The Visual Studio version of this same file - -// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html -typedef int clockid_t; -#define CLOCK_REALTIME 0 -#define CLOCK_MONOTONIC 1 -#define CLOCK_PROCESS_CPUTIME_ID 2 -#define CLOCK_THREAD_CPUTIME_ID 3 - -#ifdef __cplusplus -extern "C" { -#endif - -// https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html -int clock_gettime(clockid_t clock_id, struct timespec* tp); - -// https://pubs.opengroup.org/onlinepubs/000095399/functions/gmtime_r.html -struct tm* gmtime_r(const time_t* timer, struct tm* result); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_TIME_H_ diff --git a/starboard/shared/win32/posix_emu/include/unistd.h b/starboard/shared/win32/posix_emu/include/unistd.h deleted file mode 100644 index 9b6a8b58b5a3..000000000000 --- a/starboard/shared/win32/posix_emu/include/unistd.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_UNISTD_H_ -#define STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_UNISTD_H_ - -#include -#include - -#undef close - -#ifdef __cplusplus -extern "C" { -#endif - -int sb_close(int fd); -#define close sb_close - -// The implementation of the following functions are located in socket.cc. - -int fsync(int fd); - -int ftruncate(int fd, int64_t length); - -long lseek(int fd, long offset, int origin); // NOLINT - -int read(int fd, void* buffer, unsigned int buffer_size); - -int write(int fd, const void* buffer, unsigned int count); - -int usleep(unsigned int useconds); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // STARBOARD_SHARED_WIN32_POSIX_EMU_INCLUDE_UNISTD_H_ diff --git a/starboard/shared/win32/posix_emu/mman.cc b/starboard/shared/win32/posix_emu/mman.cc deleted file mode 100644 index a74dfb6bbece..000000000000 --- a/starboard/shared/win32/posix_emu/mman.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -#include "starboard/configuration.h" - -extern "C" { - -void* mmap(void* addr, size_t len, int prot, int flags, int fd, off_t off) { - if (addr != NULL) { - return MAP_FAILED; - } - if (fd != -1) { - return MAP_FAILED; - } - if (len == 0) { - return MAP_FAILED; - } - - ULONG allocation_type = MEM_RESERVE; - ULONG protect = PAGE_NOACCESS; - - if (prot & PROT_READ) { - protect = PAGE_READONLY; - allocation_type = MEM_COMMIT; - } - if (prot & PROT_WRITE) { - // Windows does not provide write only mode privileges - // are escalated to read/write. - protect = PAGE_READWRITE; - allocation_type = MEM_COMMIT; - } - - void* p = VirtualAllocFromApp(NULL, len, allocation_type, protect); - if (!p) { - return MAP_FAILED; - } - return p; -} - -int munmap(void* addr, size_t len) { - if (VirtualFree(addr, len, MEM_DECOMMIT)) { - return 0; - } - return -1; -} - -int msync(void* addr, size_t len, int flags) { - // TODO: Enable the following implementation when xb1 can compile it. - // FlushInstructionCache(GetCurrentProcess(), virtual_address, size_bytes); - return 0; -} - -int mprotect(void* addr, size_t len, int prot) { - ULONG new_protection = 0; - - if (prot == PROT_NONE) { - // After this call, the address will be in reserved state. - if (VirtualFree(addr, len, MEM_DECOMMIT)) { - return 0; - } - return -1; - } - - if (prot == PROT_READ) { - new_protection = PAGE_READONLY; - } else if (prot | PROT_WRITE) { - // Windows does not provide write only mode privileges - // are escalated to read/write. - new_protection = PAGE_READWRITE; - } - - if (prot == PROT_EXEC) { - new_protection = PAGE_EXECUTE; - } else if (prot == (PROT_READ | PROT_EXEC)) { - new_protection = PAGE_EXECUTE_READ; - } - - ULONG old_protection; - // Changing protection from No-Access to others needs the memory to be - // committed first. Commit committed pages will not reset them to zero. - VirtualAllocFromApp(addr, len, MEM_COMMIT, PAGE_READONLY); - bool res = VirtualProtectFromApp(addr, len, new_protection, &old_protection); - if (res) { - return 0; - } - return -1; -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/pthread.cc b/starboard/shared/win32/posix_emu/pthread.cc deleted file mode 100644 index 5d8574f19234..000000000000 --- a/starboard/shared/win32/posix_emu/pthread.cc +++ /dev/null @@ -1,412 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/common/time.h" -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" -#include "starboard/shared/win32/wchar_utils.h" - -using starboard::shared::win32::CStringToWString; -using starboard::shared::win32::GetCurrentSbThreadPrivate; -using starboard::shared::win32::GetThreadSubsystemSingleton; -using starboard::shared::win32::SbThreadPrivate; -using starboard::shared::win32::ThreadCreateInfo; -using starboard::shared::win32::ThreadSetLocalValue; -using starboard::shared::win32::ThreadSubsystemSingleton; -using starboard::shared::win32::TlsInternalFree; -using starboard::shared::win32::TlsInternalGetValue; -using starboard::shared::win32::TlsInternalSetValue; - -void CallThreadLocalDestructorsMultipleTimes(); -void ResetWinError(); -int RunThreadLocalDestructors(ThreadSubsystemSingleton* singleton); -int CountTlsObjectsRemaining(ThreadSubsystemSingleton* singleton); - -typedef struct pthread_attr_impl_t { - size_t stack_size; - int detach_state; -} pthread_attr_impl_t; - -extern "C" { - -int pthread_mutex_destroy(pthread_mutex_t* mutex) { - return 0; -} - -int pthread_mutex_init(pthread_mutex_t* mutex, - const pthread_mutexattr_t* mutex_attr) { - static_assert(sizeof(SRWLOCK) == sizeof(mutex->buffer)); - if (!mutex) { - return EINVAL; - } - InitializeSRWLock(reinterpret_cast(mutex->buffer)); - return 0; -} - -int pthread_mutex_lock(pthread_mutex_t* mutex) { - if (!mutex) { - return EINVAL; - } - AcquireSRWLockExclusive(reinterpret_cast(mutex->buffer)); - return 0; -} - -int pthread_mutex_unlock(pthread_mutex_t* mutex) { - if (!mutex) { - return EINVAL; - } - ReleaseSRWLockExclusive(reinterpret_cast(mutex->buffer)); - return 0; -} - -int pthread_mutex_trylock(pthread_mutex_t* mutex) { - if (!mutex) { - return EINVAL; - } - bool result = - TryAcquireSRWLockExclusive(reinterpret_cast(mutex->buffer)); - return result ? 0 : EBUSY; -} - -int pthread_cond_broadcast(pthread_cond_t* cond) { - if (!cond) { - return -1; - } - WakeAllConditionVariable(reinterpret_cast(cond->buffer)); - return 0; -} - -int pthread_cond_destroy(pthread_cond_t* cond) { - return 0; -} - -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) { - static_assert(sizeof(CONDITION_VARIABLE) == sizeof(cond->buffer)); - if (!cond) { - return -1; - } - InitializeConditionVariable( - reinterpret_cast(cond->buffer)); - return 0; -} - -int pthread_cond_signal(pthread_cond_t* cond) { - if (!cond) { - return -1; - } - WakeConditionVariable(reinterpret_cast(cond->buffer)); - return -0; -} - -int pthread_cond_timedwait(pthread_cond_t* cond, - pthread_mutex_t* mutex, - const struct timespec* t) { - // take the current time as soon as possible to - // try to improve the accuracy of the timeout duration. - int64_t now_ms = starboard::CurrentPosixTime() / 1000; - - if (!cond || !mutex) { - return -1; - } - - int64_t timeout_duration_ms = t->tv_sec * 1000 + t->tv_nsec / 1000000; - timeout_duration_ms -= now_ms; - if (timeout_duration_ms < 0) { - timeout_duration_ms = 0; - } - - bool result = SleepConditionVariableSRW( - reinterpret_cast(cond->buffer), - reinterpret_cast(mutex->buffer), timeout_duration_ms, 0); - - if (result) { - return 0; - } - - if (GetLastError() == ERROR_TIMEOUT) { - return ETIMEDOUT; - } - return -1; -} - -int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) { - if (!cond || !mutex) { - return -1; - } - - if (SleepConditionVariableSRW( - reinterpret_cast(cond->buffer), - reinterpret_cast(mutex->buffer), INFINITE, 0)) { - return 0; - } - return -1; -} - -int pthread_condattr_destroy(pthread_condattr_t* attr) { - SB_DCHECK(false) << "pthread_condattr_destroy not supported on win32"; - return -1; -} - -int pthread_condattr_getclock(const pthread_condattr_t* attr, - clockid_t* clock_id) { - SB_DCHECK(false) << "pthread_condattr_getclock not supported on win32"; - return -1; -} - -int pthread_condattr_init(pthread_condattr_t* attr) { - SB_DCHECK(false) << "pthread_condattr_init not supported on win32"; - return -1; -} - -int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock_id) { - SB_DCHECK(false) << "pthread_condattr_setclock not supported on win32"; - return -1; -} - -static BOOL CALLBACK OnceTrampoline(PINIT_ONCE once_control, - void* parameter, - void** context) { - static_cast(parameter)(); - return true; -} - -int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)) { - static_assert(sizeof(INIT_ONCE) == sizeof(once_control->buffer)); - if (!once_control || !init_routine) { - return -1; - } - return InitOnceExecuteOnce(reinterpret_cast(once_control->buffer), - OnceTrampoline, init_routine, NULL) - ? 0 - : -1; -} - -static unsigned ThreadTrampoline(void* thread_create_info_context) { - std::unique_ptr info( - static_cast(thread_create_info_context)); - - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - ThreadSetLocalValue(singleton->thread_private_key_, &info->thread_private_); - pthread_setname_np(pthread_self(), info->name_.c_str()); - - void* result = info->entry_point_(info->user_context_); - - CallThreadLocalDestructorsMultipleTimes(); - - pthread_mutex_lock(&info->thread_private_.mutex_); - info->thread_private_.result_ = result; - info->thread_private_.result_is_valid_ = true; - pthread_cond_signal(&info->thread_private_.condition_); - while (info->thread_private_.wait_for_join_) { - pthread_cond_wait(&info->thread_private_.condition_, - &info->thread_private_.mutex_); - } - pthread_mutex_unlock(&info->thread_private_.mutex_); - - return 0; -} - -int pthread_create(pthread_t* thread, - const pthread_attr_t* attr, - void* (*start_routine)(void*), - void* arg) { - if (start_routine == NULL) { - return -1; - } - ThreadCreateInfo* info = new ThreadCreateInfo(); - - info->entry_point_ = start_routine; - info->user_context_ = arg; - - info->thread_private_.wait_for_join_ = true; - if (attr != nullptr) { - if (reinterpret_cast(*attr)->detach_state == - PTHREAD_CREATE_DETACHED) { - info->thread_private_.wait_for_join_ = false; - } - } - - // Create the thread suspended, and then resume once ThreadCreateInfo::handle_ - // has been set, so that it's always valid in the ThreadCreateInfo - // destructor. - - unsigned int stack_size = 0; - if (attr != nullptr) { - stack_size = reinterpret_cast(*attr)->stack_size; - } - uintptr_t handle = _beginthreadex(NULL, stack_size, ThreadTrampoline, info, - CREATE_SUSPENDED, NULL); - SB_DCHECK(handle); - info->thread_private_.handle_ = reinterpret_cast(handle); - ResetWinError(); - - ResumeThread(info->thread_private_.handle_); - - *thread = reinterpret_cast(&info->thread_private_); - return 0; -} - -int pthread_join(pthread_t thread, void** value_ptr) { - if (thread == NULL) { - return -1; - } - - SbThreadPrivate* thread_private = reinterpret_cast(thread); - - pthread_mutex_lock(&thread_private->mutex_); - if (!thread_private->wait_for_join_) { - // Thread has already been detached. - pthread_mutex_unlock(&thread_private->mutex_); - return -1; - } - while (!thread_private->result_is_valid_) { - pthread_cond_wait(&thread_private->condition_, &thread_private->mutex_); - } - thread_private->wait_for_join_ = false; - pthread_cond_signal(&thread_private->condition_); - if (value_ptr != NULL) { - *value_ptr = thread_private->result_; - } - pthread_mutex_unlock(&thread_private->mutex_); - return 0; -} - -int pthread_detach(pthread_t thread) { - if (thread == NULL) { - return -1; - } - SbThreadPrivate* thread_private = reinterpret_cast(thread); - - pthread_mutex_lock(&thread_private->mutex_); - thread_private->wait_for_join_ = false; - pthread_cond_signal(&thread_private->condition_); - pthread_mutex_unlock(&thread_private->mutex_); - return 0; -} - -pthread_t pthread_self() { - return reinterpret_cast(GetCurrentSbThreadPrivate()); -} - -int pthread_equal(pthread_t t1, pthread_t t2) { - return t1 == t2; -} - -int pthread_key_create(pthread_key_t* key, void (*dtor)(void*)) { - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - *key = reinterpret_cast( - SbThreadCreateLocalKeyInternal(dtor, singleton)); - return 0; -} - -int pthread_key_delete(pthread_key_t key) { - if (!key) { - return -1; - } - // To match pthreads, the thread local pointer for the key is set to null - // so that a supplied destructor doesn't run. - ThreadSetLocalValue(reinterpret_cast(key), nullptr); - DWORD tls_index = reinterpret_cast(key)->tls_index; - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - - pthread_mutex_lock(&singleton->mutex_); - singleton->thread_local_keys_.erase(tls_index); - pthread_mutex_unlock(&singleton->mutex_); - - TlsInternalFree(tls_index); - free(reinterpret_cast(key)); - return 0; -} - -void* pthread_getspecific(pthread_key_t key) { - if (!key) { - return NULL; - } - DWORD tls_index = reinterpret_cast(key)->tls_index; - return TlsInternalGetValue(tls_index); -} - -int pthread_setspecific(pthread_key_t key, const void* value) { - if (!key) { - return -1; - } - DWORD tls_index = reinterpret_cast(key)->tls_index; - return TlsInternalSetValue(tls_index, const_cast(value)) ? 0 : -1; -} - -int pthread_setname_np(pthread_t thread, const char* name) { - SbThreadPrivate* thread_private = reinterpret_cast(thread); - std::wstring wname = CStringToWString(name); - - HRESULT hr = SetThreadDescription(thread_private->handle_, wname.c_str()); - if (FAILED(hr)) { - return -1; - } - // We store the thread name in our own TLS context as well as telling - // the OS because it's much easier to retrieve from our own TLS context. - thread_private->name_ = name; - - return 0; -} - -int pthread_getname_np(pthread_t thread, char* name, size_t len) { - SbThreadPrivate* thread_private = reinterpret_cast(thread); - starboard::strlcpy(name, thread_private->name_.c_str(), len); - return 0; -} - -int pthread_attr_init(pthread_attr_t* attr) { - *attr = - reinterpret_cast(calloc(sizeof(pthread_attr_impl_t), 1)); - if (*attr) { - return 0; - } - return -1; -} - -int pthread_attr_destroy(pthread_attr_t* attr) { - free(reinterpret_cast(*attr)); - return 0; -} - -int pthread_attr_getstacksize(const pthread_attr_t* attr, size_t* stack_size) { - *stack_size = reinterpret_cast(*attr)->stack_size; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size) { - reinterpret_cast(*attr)->stack_size = stack_size; - return 0; -} - -int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state) { - *detach_state = reinterpret_cast(*attr)->detach_state; - return 0; -} - -int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state) { - reinterpret_cast(*attr)->detach_state = detach_state; - return 0; -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/sched.cc b/starboard/shared/win32/posix_emu/sched.cc deleted file mode 100644 index 067fd3359d65..000000000000 --- a/starboard/shared/win32/posix_emu/sched.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -extern "C" { - -int sched_yield() { - Sleep(0); - return 0; -} -} diff --git a/starboard/shared/win32/posix_emu/socket.cc b/starboard/shared/win32/posix_emu/socket.cc deleted file mode 100644 index c8a8dba2ed81..000000000000 --- a/starboard/shared/win32/posix_emu/socket.cc +++ /dev/null @@ -1,547 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// We specifically do not include since the define causes a loop - -#include -#include // Needed for file-specific `_close`. -#include -#include // Our version that declares generic `close`. -#include -#undef NO_ERROR // http://b/302733082#comment15 -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/types.h" - -#undef open -#undef close - -static int gen_fd() { - static int fd = 100; - fd++; - if (fd == 0x7FFFFFFF) { - fd = 100; - } - return fd; -} - -struct FileOrSocket { - bool is_file; - int file; - SOCKET socket; -}; - -struct CriticalSection { - CriticalSection() { InitializeCriticalSection(&critical_section_); } - CRITICAL_SECTION critical_section_; -}; - -static std::map* g_map_addr = nullptr; -static CriticalSection g_critical_section; - -int handle_db_put(FileOrSocket handle) { - EnterCriticalSection(&g_critical_section.critical_section_); - if (g_map_addr == nullptr) { - g_map_addr = new std::map(); - } - - int fd = gen_fd(); - // Go through the map and make sure there isn't duplicated index - // already. - while (g_map_addr->find(fd) != g_map_addr->end()) { - fd = gen_fd(); - } - g_map_addr->insert({fd, handle}); - - LeaveCriticalSection(&g_critical_section.critical_section_); - return fd; -} - -static FileOrSocket handle_db_get(int fd, bool erase) { - FileOrSocket invalid_handle = {/*is_file=*/false, -1, INVALID_SOCKET}; - if (fd < 0) { - _set_errno(EBADF); - return invalid_handle; - } - EnterCriticalSection(&g_critical_section.critical_section_); - if (g_map_addr == nullptr) { - g_map_addr = new std::map(); - _set_errno(EBADF); - return invalid_handle; - } - - auto itr = g_map_addr->find(fd); - if (itr == g_map_addr->end()) { - _set_errno(EBADF); - return invalid_handle; - } - - FileOrSocket handle = itr->second; - if (erase) { - g_map_addr->erase(fd); - } - LeaveCriticalSection(&g_critical_section.critical_section_); - return handle; -} - -static int handle_db_get_fd(SOCKET handle) { - int fd = -1; - if (handle == INVALID_SOCKET) { - return fd; - } - - EnterCriticalSection(&g_critical_section.critical_section_); - for (auto i : *g_map_addr) { - if (i.second.is_file == false && i.second.socket == handle) { - fd = i.first; - break; - } - } - LeaveCriticalSection(&g_critical_section.critical_section_); - return fd; -} - -// WSAGetLastError should be called immediately to retrieve the extended error -// code for the failing function call. -// https://learn.microsoft.com/en-us/windows/win32/winsock/error-codes-errno-h-errno-and-wsagetlasterror-2 -static void set_errno() { - int winsockError = WSAGetLastError(); - int sockError = 0; - - // The error codes returned by Windows Sockets are similar to UNIX socket - // error code constants, but the constants are all prefixed with WSA. So in - // Winsock applications the WSAEWOULDBLOCK error code would be returned, while - // in UNIX applications the EWOULDBLOCK error code would be returned. The - // errno values in a WIN32 are a subset of the values for errno in UNIX - // systems. - switch (winsockError) { - case WSAEINTR: // Interrupted function call - sockError = EINTR; - break; - case WSAEBADF: // WSAEBADF - sockError = EBADF; - break; - case WSAEACCES: // WSAEACCES - sockError = EACCES; - break; - case WSAEFAULT: // Bad address - sockError = EFAULT; - break; - case WSAEINVAL: // Invalid argument - sockError = EINVAL; - break; - case WSAEMFILE: // Too many open files - sockError = EMFILE; - break; - case WSAEWOULDBLOCK: // Operation would block - sockError = EWOULDBLOCK; - break; - case WSAEINPROGRESS: // Operation now in progress - sockError = EINPROGRESS; - break; - case WSAEALREADY: // Operation already in progress - sockError = EALREADY; - break; - case WSAENOTSOCK: // Socket operation on non-socket - sockError = ENOTSOCK; - break; - case WSAEDESTADDRREQ: // Destination address required - sockError = EDESTADDRREQ; - break; - case WSAEMSGSIZE: // Message too long - sockError = EMSGSIZE; - break; - case WSAEPROTOTYPE: // Protocol wrong type for socket - sockError = EPROTOTYPE; - break; - case WSAENOPROTOOPT: // Bad protocol option - sockError = ENOPROTOOPT; - break; - case WSAEPROTONOSUPPORT: // Protocol not supported - sockError = EPROTONOSUPPORT; - break; - case WSAEOPNOTSUPP: // Operation not supported - sockError = EOPNOTSUPP; - break; - case WSAEAFNOSUPPORT: // Address family not supported by protocol family - sockError = EAFNOSUPPORT; - break; - case WSAEADDRINUSE: // Address already in use - sockError = EADDRINUSE; - break; - case WSAEADDRNOTAVAIL: // Cannot assign requested address - sockError = EADDRNOTAVAIL; - break; - case WSAENETDOWN: // Network is down - sockError = ENETDOWN; - break; - case WSAENETUNREACH: // Network is unreachable - sockError = ENETUNREACH; - break; - case WSAENETRESET: // Network dropped connection on reset - sockError = ENETRESET; - break; - case WSAECONNABORTED: // Software caused connection abort - sockError = ECONNABORTED; - break; - case WSAECONNRESET: // Connection reset by peer - sockError = ECONNRESET; - break; - case WSAENOBUFS: // No buffer space available - sockError = ENOBUFS; - break; - case WSAEISCONN: // Socket is already connected - sockError = EISCONN; - break; - case WSAENOTCONN: // Socket is not connected - sockError = ENOTCONN; - break; - case WSAETIMEDOUT: // Connection timed out - sockError = ETIMEDOUT; - break; - case WSAECONNREFUSED: // Connection refused - sockError = ECONNREFUSED; - break; - case WSAELOOP: // WSAELOOP - sockError = ELOOP; - break; - case WSAENAMETOOLONG: // WSAENAMETOOLONG - sockError = ENAMETOOLONG; - break; - case WSAEHOSTUNREACH: // No route to host - sockError = EHOSTUNREACH; - break; - case WSAENOTEMPTY: // WSAENOTEMPTY - sockError = ENOTEMPTY; - break; - case WSAHOST_NOT_FOUND: // Host not found - sockError = HOST_NOT_FOUND; - break; - case WSATRY_AGAIN: // Non-authoritative host not found - sockError = TRY_AGAIN; - break; - case WSANO_RECOVERY: // This is a non-recoverable error - sockError = NO_RECOVERY; - break; - case WSANO_DATA: // Valid name, no data record of requested type - sockError = NO_DATA; - break; - default: - SB_DLOG(WARNING) << "Unknown socket error."; - break; - } - - _set_errno(sockError); - SB_DLOG(INFO) << "Encounter socket error: " << strerror(sockError); -} - -/////////////////////////////////////////////////////////////////////////////// -// Implementations below exposed externally in pure C for emulation. -/////////////////////////////////////////////////////////////////////////////// - -extern "C" { - -int sb_socket(int domain, int type, int protocol) { - // Sockets on Windows do not use *nix-style file descriptors - // socket() returns a handle to a kernel object instead - SOCKET socket_handle = socket(domain, type, protocol); - if (socket_handle == INVALID_SOCKET) { - set_errno(); - return -1; - } - - FileOrSocket handle = {/*is_file=*/false, -1, socket_handle}; - - return handle_db_put(handle); -} - -int sb_open(const char* path, int oflag, ...) { - va_list args; - va_start(args, oflag); - int fd; - mode_t mode; - // Open in binary mode because read() stops at the first 0x1A value. - oflag |= O_BINARY; - if (oflag & O_CREAT) { - mode = va_arg(args, mode_t); - fd = _open(path, oflag, mode & MS_MODE_MASK); - } else { - fd = _open(path, oflag); - } - va_end(args); - - if (fd < 0) { - return fd; - } - - FileOrSocket handle = {/*is_file=*/true, fd, INVALID_SOCKET}; - return handle_db_put(handle); -} - -int sb_close(int fd) { - FileOrSocket handle = handle_db_get(fd, true); - - if (!handle.is_file && handle.socket == INVALID_SOCKET) { - return -1; - } else if (!handle.is_file) { - int result = closesocket(handle.socket); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; - } - - // This is then a file handle, so use Windows `_close` API. - return _close(handle.file); -} - -int fsync(int fd) { - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - return _commit(handle.file); -} - -int ftruncate(int fd, int64_t length) { - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - return _chsize(handle.file, length); -} - -long lseek(int fd, long offset, int origin) { // NOLINT - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - return _lseek(handle.file, offset, origin); -} - -int sb_fstat(int fd, struct stat* buffer) { - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - - return _fstat(handle.file, (struct _stat*)buffer); -} - -int read(int fd, void* buffer, unsigned int buffer_size) { - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - return _read(handle.file, buffer, buffer_size); -} - -int write(int fd, const void* buffer, unsigned int count) { - FileOrSocket handle = handle_db_get(fd, false); - if (!handle.is_file) { - return -1; - } - return _write(handle.file, buffer, count); -} - -int sb_bind(int socket, const struct sockaddr* address, socklen_t address_len) { - SOCKET socket_handle = handle_db_get(socket, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = bind(socket_handle, address, address_len); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_listen(int socket, int backlog) { - SOCKET socket_handle = handle_db_get(socket, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = listen(socket_handle, backlog); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_accept(int socket, sockaddr* addr, int* addrlen) { - SOCKET socket_handle = handle_db_get(socket, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - SOCKET accept_handle = accept(socket_handle, addr, addrlen); - if (accept_handle == INVALID_SOCKET) { - set_errno(); - return -1; - } - - FileOrSocket handle = {/*is_file=*/false, -1, accept_handle}; - return handle_db_put(handle); -} - -int sb_connect(int socket, const sockaddr* name, int namelen) { - SOCKET socket_handle = handle_db_get(socket, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = connect(socket_handle, name, namelen); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_send(int sockfd, const void* buf, size_t len, int flags) { - SOCKET socket_handle = handle_db_get(sockfd, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = - send(socket_handle, reinterpret_cast(buf), len, flags); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_recv(int sockfd, void* buf, size_t len, int flags) { - SOCKET socket_handle = handle_db_get(sockfd, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = recv(socket_handle, reinterpret_cast(buf), len, flags); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_sendto(int sockfd, - const void* buf, - size_t len, - int flags, - const struct sockaddr* dest_addr, - socklen_t dest_len) { - SOCKET socket_handle = handle_db_get(sockfd, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = sendto(socket_handle, reinterpret_cast(buf), len, - flags, dest_addr, dest_len); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_recvfrom(int sockfd, - void* buf, - size_t len, - int flags, - struct sockaddr* address, - socklen_t* address_len) { - SOCKET socket_handle = handle_db_get(sockfd, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - int result = recvfrom(socket_handle, reinterpret_cast(buf), len, flags, - address, address_len); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_setsockopt(int socket, - int level, - int option_name, - const void* option_value, - int option_len) { - FileOrSocket handle = handle_db_get(socket, false); - - if (handle.is_file || handle.socket == INVALID_SOCKET) { - return -1; - } - - int result = - setsockopt(handle.socket, level, option_name, - reinterpret_cast(option_value), option_len); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int sb_fcntl(int fd, int cmd, ... /*arg*/) { - SOCKET socket_handle = handle_db_get(fd, false).socket; - if (socket_handle == INVALID_SOCKET) { - return -1; - } - - if (cmd == F_SETFL) { - va_list ap; - int arg; - va_start(ap, cmd); - arg = va_arg(ap, int); - va_end(ap); - if ((arg & O_NONBLOCK) == O_NONBLOCK) { - int opt = 1; - ioctlsocket(socket_handle, FIONBIO, reinterpret_cast(&opt)); - } - } - return 0; -} - -int sb_getsockname(int sockfd, struct sockaddr* addr, socklen_t* addrlen) { - FileOrSocket handle = handle_db_get(sockfd, false); - - if (handle.is_file || handle.socket == INVALID_SOCKET) { - return -1; - } - - int result = getsockname(handle.socket, addr, addrlen); - if (result == SOCKET_ERROR) { - set_errno(); - } - return result; -} - -int posix_socket_get_fd_from_handle(SOCKET socket) { - return handle_db_get_fd(socket); -} - -SOCKET posix_socket_get_handle_from_fd(int socket) { - FileOrSocket handle = handle_db_get(socket, false); - if (handle.is_file || handle.socket == INVALID_SOCKET) { - return INVALID_SOCKET; - } - return handle.socket; -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/stat.cc b/starboard/shared/win32/posix_emu/stat.cc deleted file mode 100644 index 1868dd5af487..000000000000 --- a/starboard/shared/win32/posix_emu/stat.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -extern "C" { - -int sb_mkdir(const char* path, mode_t mode) { - return _mkdir(path); -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/stdlib.cc b/starboard/shared/win32/posix_emu/stdlib.cc deleted file mode 100644 index 8aa2b906f7d2..000000000000 --- a/starboard/shared/win32/posix_emu/stdlib.cc +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include - -// Undef alias to `free` and pull in the system-level header so we can use it -#undef free -#include <../ucrt/malloc.h> - -// clang-format off -// The windows.h must be included before the synchapi.h -#include // NOLINT -#include // NOLINT -// clang-format on - -#include - -static void* take_or_store_impl(bool take, void* p) { - // Make sure the set is allocated and stays allocated for all global calls. - static std::set* s_addr = new std::set(); - if (take) { - bool found = (s_addr->find(p) != s_addr->end()); - - // remove the address - s_addr->erase(p); - - if (found) { - return p; - } else { - return nullptr; - } - } else { - // Store the address - s_addr->insert(p); - return p; - } -} - -struct CriticalSection { - CriticalSection() { InitializeCriticalSection(&critical_section_); } - - CRITICAL_SECTION critical_section_; -}; - -static void* take_or_store(bool take, void* p) { - static CriticalSection s_critical_section; - - EnterCriticalSection(&s_critical_section.critical_section_); - void* res = take_or_store_impl(take, p); - LeaveCriticalSection(&s_critical_section.critical_section_); - return res; -} - -static void store_aligned_pointer(void* p) { - take_or_store(false /* take */, p); -} - -static void* take_aligned_pointer(void* p) { - return take_or_store(true /* take */, p); -} - -/////////////////////////////////////////////////////////////////////////////// -// Implementations below exposed externally in pure C for emulation. -/////////////////////////////////////////////////////////////////////////////// - -extern "C" { - -int posix_memalign(void** res, size_t alignment, size_t size) { - *res = _aligned_malloc(size, alignment); - store_aligned_pointer(*res); - if (*res != nullptr) { - return 0; - } - return ENOMEM; -} - -void sb_free(void* p) { - if (!p) { - return; - } - void* res = take_aligned_pointer(p); - if (res == p) { - _aligned_free(p); - } else { - free(p); // This is using the system-level implementation. - } -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/string.cc b/starboard/shared/win32/posix_emu/string.cc deleted file mode 100644 index bab3dae030bb..000000000000 --- a/starboard/shared/win32/posix_emu/string.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -extern "C" { - -char* strdup(const char* s1) { - return _strdup(s1); -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/strings.cc b/starboard/shared/win32/posix_emu/strings.cc deleted file mode 100644 index 7986abcb7e60..000000000000 --- a/starboard/shared/win32/posix_emu/strings.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include // For _stricmp, _strnicmp -#include - -extern "C" { - -int strcasecmp(const char* s1, const char* s2) { - return _stricmp(s1, s2); -} - -int strncasecmp(const char* s1, const char* s2, size_t n) { - return _strnicmp(s1, s2, n); -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/time.cc b/starboard/shared/win32/posix_emu/time.cc deleted file mode 100644 index 2a0f26112ed5..000000000000 --- a/starboard/shared/win32/posix_emu/time.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/types.h" - -extern "C" { - -int gettimeofday(struct timeval* tp, void* tzp) { - if (tp == NULL) { - return -1; - } - - SYSTEMTIME system_time; - GetSystemTime(&system_time); - - // Represents number of 100-nanosecond intervals since January 1, 1601 (UTC). - FILETIME file_time; - SystemTimeToFileTime(&system_time, &file_time); - - ULARGE_INTEGER large_int; - large_int.LowPart = file_time.dwLowDateTime; - large_int.HighPart = file_time.dwHighDateTime; - // Divide by 10 to get microseconds from 100-nanosecond intervals. - uint64_t windows_time_micros = large_int.QuadPart / 10; - // Remove number of microseconds since Jan 1, 1601 (UTC) until Jan 1, 1970. - uint64_t posix_time_micros = windows_time_micros - 11644473600000000ULL; - - tp->tv_sec = static_cast(posix_time_micros / 1000000); - tp->tv_usec = static_cast(system_time.wMilliseconds) * 1000; - return 0; -} - -int clock_gettime(clockid_t clock_id, struct timespec* tp) { - // There are only Windows implementations for realtime and monotonic clocks. - // If CLOCK_PROCESS_CPUTIME_ID or CLOCK_THREAD_CPUTIME_ID are passed in, - // this will return -1. Code that tries to use one of those should either - // be able to detect and handle the -1 return value or be guarded with - // #if SB_HAS(TIME_THREAD_NOW). - SB_DCHECK((clock_id == CLOCK_REALTIME) || (clock_id == CLOCK_MONOTONIC) || - (clock_id == CLOCK_PROCESS_CPUTIME_ID) || - (clock_id == CLOCK_THREAD_CPUTIME_ID)); - - if (tp == NULL) { - return -1; - } - - if (clock_id == CLOCK_REALTIME) { - struct timeval tv; - if (gettimeofday(&tv, NULL) != 0) { - return -1; - } - tp->tv_sec = tv.tv_sec; - tp->tv_nsec = static_cast(tv.tv_usec) * 1000; // NOLINT(runtime/int) - return 0; - } else if (clock_id == CLOCK_MONOTONIC) { - LARGE_INTEGER counts; - bool success; - - success = QueryPerformanceCounter(&counts); - - // "On systems that run Windows XP or later, - // the function will always succeed and will thus never return zero." - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx - SB_DCHECK(success); - - LARGE_INTEGER countsPerSecond; - success = QueryPerformanceFrequency(&countsPerSecond); - // "On systems that run Windows XP or later, - // the function will always succeed and will thus never return zero." - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx - SB_DCHECK(success); - - // An observed value of countsPerSecond on a desktop x86 machine is - // ~2.5e6. With this frequency, it will take ~37500 days to exceed - // 2^53, which is the mantissa precision of a double. - // Hence, we can safely convert to a double here without losing precision. - double result = static_cast(counts.QuadPart); - result *= (1000.0 * 1000.0) / countsPerSecond.QuadPart; - int64_t microseconds = static_cast(result); - tp->tv_sec = microseconds / 1000000; - tp->tv_nsec = (microseconds % 1000000) * 1000; - return 0; - } - return -1; -} - -struct tm* gmtime_r(const time_t* timer, struct tm* result) { - if (gmtime_s(result, timer) != 0) { - return NULL; - } - return result; -} - -} // extern "C" diff --git a/starboard/shared/win32/posix_emu/usleep.cc b/starboard/shared/win32/posix_emu/usleep.cc deleted file mode 100644 index f0ca4c100750..000000000000 --- a/starboard/shared/win32/posix_emu/usleep.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include - -#include "starboard/shared/win32/time_utils.h" - -using starboard::shared::win32::ConvertUsecToMillisRoundUp; - -extern "C" { - -int usleep(unsigned int useconds) { - Sleep(ConvertUsecToMillisRoundUp(useconds)); - return 0; -} -} diff --git a/starboard/shared/win32/set_non_blocking_internal.cc b/starboard/shared/win32/set_non_blocking_internal.cc deleted file mode 100644 index 8abeb3af8821..000000000000 --- a/starboard/shared/win32/set_non_blocking_internal.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/set_non_blocking_internal.h" - -#include - -namespace starboard { -namespace shared { -namespace win32 { - -bool SetNonBlocking(SOCKET socket_handle) { - u_long kOne = 1; - bool success = (ioctlsocket(socket_handle, FIONBIO, &kOne) == 0); - return success; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/set_non_blocking_internal.h b/starboard/shared/win32/set_non_blocking_internal.h deleted file mode 100644 index fc369f77a939..000000000000 --- a/starboard/shared/win32/set_non_blocking_internal.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_SET_NON_BLOCKING_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_SET_NON_BLOCKING_INTERNAL_H_ - -#include "starboard/shared/internal_only.h" - -#include - -namespace starboard { -namespace shared { -namespace win32 { - -// Makes the socket file descriptor non-blocking. -bool SetNonBlocking(SOCKET socket_handle); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_SET_NON_BLOCKING_INTERNAL_H_ diff --git a/starboard/shared/win32/socket_accept.cc b/starboard/shared/win32/socket_accept.cc deleted file mode 100644 index b8ca76bd2b13..000000000000 --- a/starboard/shared/win32/socket_accept.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/set_non_blocking_internal.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -SbSocket SbSocketAccept(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return kSbSocketInvalid; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - - SOCKET socket_handle = accept(socket->socket_handle, nullptr, nullptr); - if (socket_handle == INVALID_SOCKET) { - socket->error = sbwin32::TranslateSocketErrorStatus(WSAGetLastError()); - return kSbSocketInvalid; - } - - // All Starboard sockets are non-blocking, so let's ensure it. - if (!sbwin32::SetNonBlocking(socket_handle)) { - // Something went wrong, we'll clean up and return failure. - socket->error = sbwin32::TranslateSocketErrorStatus(WSAGetLastError()); - closesocket(socket_handle); - return kSbSocketInvalid; - } - - socket->error = kSbSocketOk; - - // Adopt the newly accepted socket. - return new SbSocketPrivate(socket->address_type, socket->protocol, - socket_handle, - SbSocketPrivate::BindTarget::kAccepted); -} diff --git a/starboard/shared/win32/socket_bind.cc b/starboard/shared/win32/socket_bind.cc deleted file mode 100644 index 56fd97b4d872..000000000000 --- a/starboard/shared/win32/socket_bind.cc +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/common/memory.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -namespace { - -bool IsIpv6InaddrAny(const SbSocketAddress* local_address) { - return starboard::common::MemoryIsZero(local_address->address, - sbwin32::kAddressLengthIpv6); -} -bool IsIpv4InaddrAny(const SbSocketAddress* local_address) { - return starboard::common::MemoryIsZero(local_address->address, - sbwin32::kAddressLengthIpv4); -} - -} // namespace - -SbSocketError SbSocketBind(SbSocket socket, - const SbSocketAddress* local_address) { - if (!SbSocketIsValid(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Invalid socket"; - return kSbSocketErrorFailed; - } - - sbwin32::SockAddr sock_addr; - if (!sock_addr.FromSbSocketAddress(local_address)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Invalid address"; - return (socket->error = sbwin32::TranslateSocketErrorStatus(EINVAL)); - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - if (local_address->type != socket->address_type) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Incompatible addresses: " - << "socket type = " << socket->address_type - << ", argument type = " << local_address->type; - return (socket->error = sbwin32::TranslateSocketErrorStatus(EAFNOSUPPORT)); - } - - switch (local_address->type) { - case kSbSocketAddressTypeIpv6: - if (!IsIpv6InaddrAny(local_address)) { - socket->bound_to = SbSocketPrivate::BindTarget::kOther; - break; - } - - socket->bound_to = SbSocketPrivate::BindTarget::kAny; - - // When binding to the IPV6 any address, ensure that the IPV6_V6ONLY flag - // is off to allow incoming IPV4 connections on the same socket. - // See https://www.ietf.org/rfc/rfc3493.txt for details. - if (!sbwin32::SetBooleanSocketOption(socket, IPPROTO_IPV6, IPV6_V6ONLY, - "IPV6_V6ONLY", false)) { - // Silently ignore errors, assume the default behavior is as expected. - socket->error = kSbSocketOk; - } - - break; - case kSbSocketAddressTypeIpv4: - socket->bound_to = IsIpv4InaddrAny(local_address) - ? SbSocketPrivate::BindTarget::kAny - : SbSocketPrivate::BindTarget::kOther; - break; - } - - int result = - bind(socket->socket_handle, sock_addr.sockaddr(), sock_addr.length); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << __FUNCTION__ - << ": Bind failed. last_error=" << last_error; - return (socket->error = sbwin32::TranslateSocketErrorStatus(last_error)); - } - - return (socket->error = kSbSocketOk); -} diff --git a/starboard/shared/win32/socket_clear_last_error.cc b/starboard/shared/win32/socket_clear_last_error.cc deleted file mode 100644 index 06f4a7deaed8..000000000000 --- a/starboard/shared/win32/socket_clear_last_error.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include "starboard/shared/win32/socket_internal.h" - -bool SbSocketClearLastError(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return false; - } - - socket->error = kSbSocketOk; - return true; -} diff --git a/starboard/shared/win32/socket_connect.cc b/starboard/shared/win32/socket_connect.cc deleted file mode 100644 index a618efc134e0..000000000000 --- a/starboard/shared/win32/socket_connect.cc +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -SbSocketError SbSocketConnect(SbSocket socket, const SbSocketAddress* address) { - if (!SbSocketIsValid(socket)) { - return kSbSocketErrorFailed; - } - - sbwin32::SockAddr sock_addr; - if (!sock_addr.FromSbSocketAddress(address)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Invalid address"; - return (socket->error = kSbSocketErrorFailed); - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - if (address->type != socket->address_type) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Incompatible addresses: " - << "socket type = " << socket->address_type - << ", argument type = " << address->type; - return (socket->error = kSbSocketErrorFailed); - } - - int result = - connect(socket->socket_handle, sock_addr.sockaddr(), sock_addr.length); - - if (result != SOCKET_ERROR) { - socket->bound_to = SbSocketPrivate::BindTarget::kAny; - return (socket->error = kSbSocketOk); - } - - const int last_error = WSAGetLastError(); - if (last_error == WSAEWOULDBLOCK) { - socket->bound_to = SbSocketPrivate::BindTarget::kAny; - return (socket->error = kSbSocketPending); - } - - SB_DLOG(ERROR) << __FUNCTION__ << ": connect failed: " << last_error; - return (socket->error = kSbSocketErrorFailed); -} diff --git a/starboard/shared/win32/socket_create.cc b/starboard/shared/win32/socket_create.cc deleted file mode 100644 index 65c1786cf089..000000000000 --- a/starboard/shared/win32/socket_create.cc +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -// WinSock includes need to be in particular order -// clang-format off -#include -#include -// clang-format on - -#include "starboard/common/log.h" -#include "starboard/shared/win32/set_non_blocking_internal.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -SbSocket SbSocketCreate(SbSocketAddressType address_type, - SbSocketProtocol protocol) { - int socket_domain; - switch (address_type) { - case kSbSocketAddressTypeIpv4: - socket_domain = AF_INET; - break; - case kSbSocketAddressTypeIpv6: - socket_domain = AF_INET6; - break; - default: - SB_NOTREACHED(); - return kSbSocketInvalid; - } - - int socket_type; - int socket_protocol; - switch (protocol) { - case kSbSocketProtocolTcp: - socket_type = SOCK_STREAM; - socket_protocol = IPPROTO_TCP; - break; - case kSbSocketProtocolUdp: - socket_type = SOCK_DGRAM; - socket_protocol = IPPROTO_UDP; - break; - default: - SB_NOTREACHED(); - return kSbSocketInvalid; - } - - // WSASocket with dwFlags=0, instead of socket() creates sockets that do not - // support overlapped IO. - SOCKET socket_handle = - WSASocketW(socket_domain, socket_type, socket_protocol, nullptr, 0, 0); - if (socket_handle == INVALID_SOCKET) { - return kSbSocketInvalid; - } - - // From - // https://msdn.microsoft.com/en-us/library/windows/desktop/cc136103(v=vs.85).aspx: - // "When the TargetOsVersion member is set to a value for Windows Vista or - // later, reductions to the TCP receive buffer size on this socket using the - // SO_RCVBUF socket option are allowed even after a TCP connection has been - // establishment." - // "When the TargetOsVersion member is set to a value for Windows Vista or - // later, receive window auto-tuning is enabled and the TCP window scale - // factor is reduced to 2 from the default value of 8." - - // The main impetus for this change: - - // "The WsaBehaviorAutoTuning option is needed on Windows Vista for some - // Internet gateway devices and firewalls that do not correctly support data - // flows for TCP connections that use the WSopt extension and a windows scale - // factor. On Windows Vista, a receiver by default negotiates a window scale - // factor of 8 for a maximum true window size of 16,776,960 bytes. When data - // begins to flow on a fast link, Windows initially starts with a 64 Kilobyte - // true window size by setting the Window field of the TCP header to 256 and - // setting the window scale factor to 8 in the TCP options (256*2^8=64KB). - // Some Internet gateway devices and firewalls ignore the window scale factor - // and only look at the advertised Window field in the TCP header specified as - // 256, and drop incoming packets for the connection that contain more than - // 256 bytes of TCP data. To support TCP receive window scaling, a gateway - // device or firewall must monitor the TCP handshake and track the negotiated - // window scale factor as part of the TCP connection data. Also some - // applications and TCP stack implementations on other platforms ignore the - // TCP WSopt extension and the window scaling factor. So the remote host - // sending the data may send data at the rate advertised in the Window field - // of the TCP header (256 bytes). This can result in data being received very - // slowly by the receiver." - - if (protocol == kSbSocketProtocolTcp) { - WSA_COMPATIBILITY_MODE compatibility_mode = {WsaBehaviorAll, NTDDI_VISTA}; - - DWORD kZero = 0; - int return_value = WSAIoctl( - socket_handle, SIO_SET_COMPATIBILITY_MODE, &compatibility_mode, - sizeof(WSA_COMPATIBILITY_MODE), nullptr, 0, &kZero, nullptr, nullptr); - if (return_value == SOCKET_ERROR) { - closesocket(socket_handle); - return kSbSocketInvalid; - } - } - - // All Starboard sockets are non-blocking, so let's ensure it. - if (!sbwin32::SetNonBlocking(socket_handle)) { - // Something went wrong, we'll clean up and return failure. - closesocket(socket_handle); - return kSbSocketInvalid; - } - - return new SbSocketPrivate(address_type, protocol, socket_handle, - SbSocketPrivate::BindTarget::kUnbound); -} diff --git a/starboard/shared/win32/socket_destroy.cc b/starboard/shared/win32/socket_destroy.cc deleted file mode 100644 index 14da41ebc89e..000000000000 --- a/starboard/shared/win32/socket_destroy.cc +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" -#include "starboard/socket_waiter.h" - -bool SbSocketDestroy(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - - if (socket->waiter != nullptr) { - bool result = SbSocketWaiterRemove(socket->waiter, socket); - SB_DCHECK(result); - } - - bool result = closesocket(socket->socket_handle) != SOCKET_ERROR; - - delete socket; - return result; -} diff --git a/starboard/shared/win32/socket_free_resolution.cc b/starboard/shared/win32/socket_free_resolution.cc deleted file mode 100644 index 834e472d0845..000000000000 --- a/starboard/shared/win32/socket_free_resolution.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include "starboard/common/log.h" - -void SbSocketFreeResolution(SbSocketResolution* resolution) { - if (!resolution) { - return; - } - - if (resolution->addresses) { - delete[] resolution->addresses; - } - - delete resolution; -} diff --git a/starboard/shared/win32/socket_get_interface_address.cc b/starboard/shared/win32/socket_get_interface_address.cc deleted file mode 100644 index c88f6feebd5b..000000000000 --- a/starboard/shared/win32/socket_get_interface_address.cc +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include -#include - -#include -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/adapter_utils.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -namespace { -const ULONG kDefaultAdapterInfoBufferSizeInBytes = 16 * 1024; - -bool IsAnyAddress(const SbSocketAddress& address) { - switch (address.type) { - case kSbSocketAddressTypeIpv4: - return (address.address[0] == 0 && address.address[1] == 0 && - address.address[2] == 0 && address.address[3] == 0); - case kSbSocketAddressTypeIpv6: { - bool found_nonzero = false; - for (std::size_t i = 0; i != sbwin32::kAddressLengthIpv6; ++i) { - found_nonzero |= (address.address[i] != 0); - } - return !found_nonzero; - } - default: - SB_NOTREACHED() << "Invalid address type " << address.type; - break; - } - - return false; -} - -void GenerateNetMaskFromPrefixLength(UINT8 prefix_length, - UINT32* const address_begin, - UINT32* const address_end) { - SB_DCHECK(address_end >= address_begin); - SB_DCHECK((reinterpret_cast(address_end) - - reinterpret_cast(address_begin)) % - 4 == - 0); - UINT8 ones_left = prefix_length; - const int kBitsInOneDWORD = sizeof(UINT32) * 8; - for (UINT32* iterator = address_begin; iterator != address_end; ++iterator) { - UINT8 ones_in_this_dword = std::min(kBitsInOneDWORD, ones_left); - UINT64 mask_value = - kSbUInt64Max - ((1ULL << (kBitsInOneDWORD - ones_in_this_dword)) - 1); - *iterator = _byteswap_ulong(static_cast(mask_value & kSbUInt64Max)); - ones_left -= ones_in_this_dword; - } -} - -bool PopulateInterfaceAddress(const IP_ADAPTER_UNICAST_ADDRESS& unicast_address, - SbSocketAddress* out_interface_ip) { - if (!out_interface_ip) { - return true; - } - - const SOCKET_ADDRESS& address = unicast_address.Address; - sbwin32::SockAddr addr; - return addr.FromSockaddr(address.lpSockaddr) && - addr.ToSbSocketAddress(out_interface_ip); -} - -bool PopulateNetmask(const IP_ADAPTER_UNICAST_ADDRESS& unicast_address, - SbSocketAddress* out_netmask) { - if (!out_netmask) { - return true; - } - - const SOCKET_ADDRESS& address = unicast_address.Address; - if (address.lpSockaddr == nullptr) { - return false; - } - const ADDRESS_FAMILY& family = address.lpSockaddr->sa_family; - - switch (family) { - case AF_INET: - out_netmask->type = kSbSocketAddressTypeIpv4; - break; - case AF_INET6: - out_netmask->type = kSbSocketAddressTypeIpv6; - break; - default: - SB_NOTREACHED() << "Invalid family " << family; - return false; - } - - UINT32* const begin_netmask = - reinterpret_cast(&(out_netmask->address[0])); - UINT32* const end_netmask = - begin_netmask + SB_ARRAY_SIZE(out_netmask->address) / sizeof(UINT32); - - GenerateNetMaskFromPrefixLength(unicast_address.OnLinkPrefixLength, - begin_netmask, end_netmask); - return true; -} - -bool GetNetmaskForInterfaceAddress(const SbSocketAddress& interface_address, - SbSocketAddress* out_netmask) { - std::unique_ptr adapter_info_memory_block; - if (!sbwin32::GetAdapters(interface_address.type, - &adapter_info_memory_block)) { - return false; - } - const void* const interface_address_buffer = - reinterpret_cast(interface_address.address); - for (PIP_ADAPTER_ADDRESSES adapter = reinterpret_cast( - adapter_info_memory_block.get()); - adapter != nullptr; adapter = adapter->Next) { - if ((adapter->OperStatus != IfOperStatusUp) || - !sbwin32::IsIfTypeEthernet(adapter->IfType)) { - continue; - } - - for (PIP_ADAPTER_UNICAST_ADDRESS unicast_address = - adapter->FirstUnicastAddress; - unicast_address != nullptr; unicast_address = unicast_address->Next) { - sbwin32::SockAddr addr; - if (!addr.FromSockaddr(unicast_address->Address.lpSockaddr)) { - continue; - } - - const void* unicast_address_buffer = nullptr; - int bytes_to_check = 0; - - switch (interface_address.type) { - case kSbSocketAddressTypeIpv4: - unicast_address_buffer = - reinterpret_cast(&(addr.sockaddr_in()->sin_addr)); - bytes_to_check = sbwin32::kAddressLengthIpv4; - break; - case kSbSocketAddressTypeIpv6: - unicast_address_buffer = - reinterpret_cast(&(addr.sockaddr_in6()->sin6_addr)); - bytes_to_check = sbwin32::kAddressLengthIpv6; - break; - default: - SB_DLOG(ERROR) << "Invalid interface address type " - << interface_address.type; - return false; - } - - if (memcmp(unicast_address_buffer, interface_address_buffer, - bytes_to_check) != 0) { - continue; - } - - if (PopulateNetmask(*unicast_address, out_netmask)) { - return true; - } - } - } - - return false; -} - -bool IsUniqueLocalAddress(const unsigned char ip[16]) { - // Unique Local Addresses are in fd08::/8. - return ip[0] == 0xfd && ip[1] == 0x08; -} - -bool FindInterfaceIP(const SbSocketAddressType address_type, - SbSocketAddress* out_interface_ip, - SbSocketAddress* out_netmask) { - if (out_interface_ip == nullptr) { - SB_NOTREACHED() << "out_interface_ip must be specified"; - return false; - } - - std::unique_ptr adapter_info_memory_block; - if (!sbwin32::GetAdapters(address_type, &adapter_info_memory_block)) { - return false; - } - - for (PIP_ADAPTER_ADDRESSES adapter = reinterpret_cast( - adapter_info_memory_block.get()); - adapter != nullptr; adapter = adapter->Next) { - if ((adapter->OperStatus != IfOperStatusUp) || - !sbwin32::IsIfTypeEthernet(adapter->IfType)) { - continue; - } - - for (PIP_ADAPTER_UNICAST_ADDRESS unicast_address = - adapter->FirstUnicastAddress; - unicast_address != nullptr; unicast_address = unicast_address->Next) { - if (unicast_address->Flags & (IP_ADAPTER_ADDRESS_TRANSIENT)) { - continue; - } - if (!(unicast_address->Flags & IP_ADAPTER_ADDRESS_DNS_ELIGIBLE)) { - continue; - } - - // TODO: For IPv6, Prioritize interface with highest scope. - // Skip ULAs for now. - if (address_type == kSbSocketAddressTypeIpv6) { - // Documentation on MSDN states: - // "The SOCKADDR structure pointed to by the lpSockaddr member varies - // depending on the protocol or address family selected. For example, - // the sockaddr_in6 structure is used for an IPv6 socket address - // while the sockaddr_in4 structure is used for an IPv4 socket address." - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms740507(v=vs.85).aspx - - sockaddr_in6* addr = reinterpret_cast( - unicast_address->Address.lpSockaddr); - SB_DCHECK(addr->sin6_family == AF_INET6); - if (IsUniqueLocalAddress(addr->sin6_addr.u.Byte)) { - continue; - } - } - - if (!PopulateInterfaceAddress(*unicast_address, out_interface_ip)) { - continue; - } - if (!PopulateNetmask(*unicast_address, out_netmask)) { - continue; - } - - return true; - } - } - return false; -} - -bool FindSourceAddressForDestination(const SbSocketAddress& destination, - SbSocketAddress* out_source_address) { - SbSocket socket = SbSocketCreate(destination.type, kSbSocketProtocolUdp); - if (!SbSocketIsValid(socket)) { - return false; - } - - SbSocketError connect_retval = SbSocketConnect(socket, &destination); - if (connect_retval != kSbSocketOk) { - bool socket_destroyed = SbSocketDestroy(socket); - SB_DCHECK(socket_destroyed); - return false; - } - - bool success = SbSocketGetLocalAddress(socket, out_source_address); - bool socket_destroyed = SbSocketDestroy(socket); - SB_DCHECK(socket_destroyed); - return success; -} - -} // namespace - -bool SbSocketGetInterfaceAddress(const SbSocketAddress* const destination, - SbSocketAddress* out_source_address, - SbSocketAddress* out_netmask) { - if (!out_source_address) { - return false; - } - - if (destination == nullptr) { - // Return either a v4 or a v6 address. Per spec. - return (FindInterfaceIP(kSbSocketAddressTypeIpv4, out_source_address, - out_netmask) || - FindInterfaceIP(kSbSocketAddressTypeIpv6, out_source_address, - out_netmask)); - } else if (IsAnyAddress(*destination)) { - return FindInterfaceIP(destination->type, out_source_address, out_netmask); - } - - return (FindSourceAddressForDestination(*destination, out_source_address) && - GetNetmaskForInterfaceAddress(*out_source_address, out_netmask)); -} diff --git a/starboard/shared/win32/socket_get_last_error.cc b/starboard/shared/win32/socket_get_last_error.cc deleted file mode 100644 index cdfa21d3f9ea..000000000000 --- a/starboard/shared/win32/socket_get_last_error.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include "starboard/shared/win32/socket_internal.h" - -SbSocketError SbSocketGetLastError(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return kSbSocketErrorFailed; - } - - return socket->error; -} diff --git a/starboard/shared/win32/socket_get_local_address.cc b/starboard/shared/win32/socket_get_local_address.cc deleted file mode 100644 index 5b900f683013..000000000000 --- a/starboard/shared/win32/socket_get_local_address.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketGetLocalAddress(SbSocket socket, SbSocketAddress* out_address) { - if (!SbSocketIsValid(socket)) { - return false; - } - - // winsock2 considers calling getsockname() on unbound sockets to be an error. - // Therefore, SbSocketListen() will call SbSocketBind(). - if (socket->bound_to == SbSocketPrivate::BindTarget::kUnbound) { - out_address->type = socket->address_type; - switch (socket->address_type) { - case kSbSocketAddressTypeIpv4: - memset(out_address->address, 0, sbwin32::kAddressLengthIpv4); - out_address->port = 0; - return true; - case kSbSocketAddressTypeIpv6: - memset(out_address->address, 0, sbwin32::kAddressLengthIpv6); - out_address->port = 0; - return true; - default: - SB_NOTREACHED() << "Invalid address type: " << socket->address_type; - return false; - } - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - sbwin32::SockAddr sock_addr; - int result = getsockname(socket->socket_handle, sock_addr.sockaddr(), - &sock_addr.length); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_LOG(ERROR) << "getsockname() failed with last_error = " << last_error; - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return false; - } - if (!sock_addr.ToSbSocketAddress(out_address)) { - socket->error = kSbSocketErrorFailed; - return false; - } - - socket->error = kSbSocketOk; - return true; -} diff --git a/starboard/shared/win32/socket_internal.cc b/starboard/shared/win32/socket_internal.cc deleted file mode 100644 index 3e718d3c94a7..000000000000 --- a/starboard/shared/win32/socket_internal.cc +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/socket_internal.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/memory.h" - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { -const socklen_t kAddressStructLengthIpv4 = - static_cast(sizeof(struct sockaddr_in)); -const socklen_t kAddressStructLengthIpv6 = - static_cast(sizeof(struct sockaddr_in6)); -} // namespace - -SbSocketError TranslateSocketErrorStatus(int error) { - switch (error) { - case 0: - return kSbSocketOk; - - // Microsoft Winsock error codes: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx - case WSAEINPROGRESS: - case WSAEWOULDBLOCK: - return kSbSocketPending; - case WSAECONNRESET: - case WSAENETRESET: - case WSAECONNABORTED: - return kSbSocketErrorConnectionReset; - - // Microsoft System Error codes: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx - case ERROR_BROKEN_PIPE: - return kSbSocketErrorConnectionReset; - } - - // Here's where we would be more nuanced if we need to be. - return kSbSocketErrorFailed; -} - -bool SetBooleanSocketOption(SbSocket socket, - int level, - int option_code, - const char* option_name, - bool value) { - if (!SbSocketIsValid(socket)) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - const int on = value ? 1 : 0; - int result = setsockopt(socket->socket_handle, level, option_code, - reinterpret_cast(&on), sizeof(on)); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Failed to set " << option_name << " on socket " - << socket->socket_handle << ", last_error = " << last_error; - socket->error = TranslateSocketErrorStatus(last_error); - return false; - } - - socket->error = kSbSocketOk; - return true; -} - -bool SetIntegerSocketOption(SbSocket socket, - int level, - int option_code, - const char* option_name, - int value) { - if (!SbSocketIsValid(socket)) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - int result = setsockopt(socket->socket_handle, level, option_code, - reinterpret_cast(&value), sizeof(value)); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Failed to set " << option_name << " on socket " - << socket->socket_handle << ", last_error = " << last_error; - socket->error = TranslateSocketErrorStatus(last_error); - return false; - } - - socket->error = kSbSocketOk; - return true; -} - -bool SockAddr::FromSbSocketAddress(const SbSocketAddress* address) { - if (!address) { - return false; - } - - length = sizeof(storage_); - switch (address->type) { - case kSbSocketAddressTypeIpv4: { - struct sockaddr_in* addr = sockaddr_in(); - length = kAddressStructLengthIpv4; - memset(addr, 0, length); - addr->sin_family = AF_INET; - addr->sin_port = htons(static_cast(address->port)); - memcpy(&addr->sin_addr, address->address, kAddressLengthIpv4); - break; - } - case kSbSocketAddressTypeIpv6: { - struct sockaddr_in6* addr6 = sockaddr_in6(); - length = kAddressStructLengthIpv6; - memset(addr6, 0, length); - addr6->sin6_family = AF_INET6; - addr6->sin6_port = htons(static_cast(address->port)); - memcpy(&addr6->sin6_addr, address->address, kAddressLengthIpv6); - break; - } - default: - SB_NOTREACHED() << "Unrecognized address type: " << address->type; - return false; - } - - return true; -} - -bool SockAddr::ToSbSocketAddress(SbSocketAddress* out_address) const { - if (!out_address) { - return false; - } - - // Check that we have been properly initialized. - SB_DCHECK(length == kAddressStructLengthIpv4 || - length == kAddressStructLengthIpv6); - - if (family() == AF_INET) { - const struct sockaddr_in* addr = sockaddr_in(); - if (length < kAddressStructLengthIpv4) { - SB_NOTREACHED() << "Insufficient INET size: " << length; - return false; - } - - memcpy(out_address->address, &addr->sin_addr, kAddressLengthIpv4); - out_address->port = ntohs(addr->sin_port); - out_address->type = kSbSocketAddressTypeIpv4; - return true; - } - - if (family() == AF_INET6) { - const struct sockaddr_in6* addr6 = sockaddr_in6(); - if (length < kAddressStructLengthIpv6) { - SB_NOTREACHED() << "Insufficient INET6 size: " << length; - return false; - } - - memcpy(out_address->address, &addr6->sin6_addr, kAddressLengthIpv6); - out_address->port = ntohs(addr6->sin6_port); - out_address->type = kSbSocketAddressTypeIpv6; - return true; - } - - SB_NOTREACHED() << "Unrecognized address family: " << family(); - return false; -} - -bool SockAddr::FromSockaddr(const struct sockaddr* sock_addr) { - if (!sock_addr) { - return false; - } - - int family = sock_addr->sa_family; - if (family == AF_INET) { - const struct sockaddr_in* addr = - reinterpret_cast(sock_addr); - *sockaddr_in() = *addr; - length = static_cast(sizeof(*addr)); - return true; - } else if (family == AF_INET6) { - const struct sockaddr_in6* addr = - reinterpret_cast(sock_addr); - *sockaddr_in6() = *addr; - length = static_cast(sizeof(*addr)); - return true; - } - - SB_DLOG(WARNING) << "Unrecognized address family: " << family; - return false; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/socket_internal.h b/starboard/shared/win32/socket_internal.h deleted file mode 100644 index b437feadf94c..000000000000 --- a/starboard/shared/win32/socket_internal.h +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_SOCKET_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_SOCKET_INTERNAL_H_ - -#include -#include -#include - -#include "starboard/common/socket.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/win32/auto_event_handle.h" -#include "starboard/socket_waiter.h" -#include "starboard/types.h" - -namespace sbwin32 = starboard::shared::win32; - -struct SbSocketPrivate { - enum struct BindTarget { - kUnbound = 0, - kAny = 1, - kOther = 2, - kAccepted = 3, - }; - - SbSocketPrivate(SbSocketAddressType address_type, - SbSocketProtocol protocol, - SOCKET handle, - BindTarget bound_to) - : address_type(address_type), - protocol(protocol), - socket_handle(handle), - socket_event(WSA_INVALID_EVENT), - error(kSbSocketOk), - waiter(kSbSocketWaiterInvalid), - bound_to(bound_to) {} - ~SbSocketPrivate() {} - - // The address domain of this socket, IPv4 or IPv6. - SbSocketAddressType address_type; - - // The protocol of this socket, UDP or TCP. - SbSocketProtocol protocol; - - // The handle for this socket. - SOCKET socket_handle; - - // The event related to the socket_handle. Used for SbSocketWaiter. - sbwin32::AutoEventHandle socket_event; - - // Set to true between when socket is shown as writable via WSAEventSelect/ - // WSAWaitForMultipleEvents and when writing to the socket returns - // fails with WSAEWOULDBLOCK. - // - // Used to work around the fact that WSAEventSelect for FD_WRITE is - // edge-triggered, unlike other events. - // - // See MSDN documentation for WSAEventSelect FD_WRITE for more info. - std::atomic_bool writable{false}; - - // The last error that occurred on this socket, or kSbSocketOk. - SbSocketError error; - - // The waiter this socket is registered with, or kSbSocketWaiterInvalid. - SbSocketWaiter waiter; - - BindTarget bound_to; -}; - -namespace starboard { -namespace shared { -namespace win32 { - -const socklen_t kAddressLengthIpv4 = 4; -const socklen_t kAddressLengthIpv6 = 16; - -// Translates an last_error from a socket call into an SbSocketError. -SbSocketError TranslateSocketErrorStatus(int error); - -// Sets a boolean socket option, doing all appropriate checks. -bool SetBooleanSocketOption(SbSocket socket, - int level, - int option_code, - const char* option_name, - bool value); - -// Sets an integer socket option, doing all appropriate checks. -bool SetIntegerSocketOption(SbSocket socket, - int level, - int option_code, - const char* option_name, - int value); - -// A helper class for converting back and forth from sockaddrs, ugh. -class SockAddr { - public: - SockAddr() : length(sizeof(storage_)) {} - ~SockAddr() {} - - // Initializes this SockAddr with the given SbSocketAddress, overwriting - // anything any address previously held. - bool FromSbSocketAddress(const SbSocketAddress* address); - - // Initializes the given SbSocketAddress with this SockAddr, which must have - // been previously initialized. - bool ToSbSocketAddress(SbSocketAddress* out_address) const; - - // Initializes this SockAddr with |sock_addr|, assuming it is appropriately - // sized for its type. - bool FromSockaddr(const struct sockaddr* sock_addr); - - // The sockaddr family. We only support INET and INET6. - u_short family() const { return sockaddr()->sa_family; } - - struct sockaddr* sockaddr() { - return reinterpret_cast(&storage_); - } - - const struct sockaddr* sockaddr() const { - return reinterpret_cast(&storage_); - } - - struct sockaddr_in* sockaddr_in() { - return reinterpret_cast(&storage_); - } - - const struct sockaddr_in* sockaddr_in() const { - return reinterpret_cast(&storage_); - } - - struct sockaddr_in6* sockaddr_in6() { - return reinterpret_cast(&storage_); - } - - const struct sockaddr_in6* sockaddr_in6() const { - return reinterpret_cast(&storage_); - } - - // Public on purpose, because it will be handy to be passed directly by - // reference into other functions. - socklen_t length; - - private: - sockaddr_storage storage_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_SOCKET_INTERNAL_H_ diff --git a/starboard/shared/win32/socket_is_connected.cc b/starboard/shared/win32/socket_is_connected.cc deleted file mode 100644 index 23ec5ac0c793..000000000000 --- a/starboard/shared/win32/socket_is_connected.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -bool SbSocketIsConnected(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - - // To tell if it is really connected, we peek a byte from the stream. We - // should get a byte back, or an EAGAIN/EWOULDBLOCK telling us the socket is - // waiting for data. - char c; - const int result = recv(socket->socket_handle, &c, 1, MSG_PEEK); - if (result == 0) { - // If the connection is closed, the return value is 0. - return false; - } - - const int last_error = WSAGetLastError(); - return (result > 0 || last_error == WSAEWOULDBLOCK); -} diff --git a/starboard/shared/win32/socket_is_connected_and_idle.cc b/starboard/shared/win32/socket_is_connected_and_idle.cc deleted file mode 100644 index 5a748976dede..000000000000 --- a/starboard/shared/win32/socket_is_connected_and_idle.cc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -bool SbSocketIsConnectedAndIdle(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - - // To tell if it is really connected and idle, we peek a byte from the - // stream. We should get an EAGAIN/EWOULDBLOCK telling us the socket is - // waiting for data. - char c; - int rv = recv(socket->socket_handle, &c, 1, MSG_PEEK); - if (rv != SOCKET_ERROR) { - // Either not connected, or not idle. - return false; - } - - return (WSAGetLastError() == WSAEWOULDBLOCK); -} diff --git a/starboard/shared/win32/socket_join_multicast_group.cc b/starboard/shared/win32/socket_join_multicast_group.cc deleted file mode 100644 index 0fabee06f1f7..000000000000 --- a/starboard/shared/win32/socket_join_multicast_group.cc +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketJoinMulticastGroup(SbSocket socket, - const SbSocketAddress* address) { - if (!SbSocketIsValid(socket)) { - return false; - } - - if (!address) { - return false; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - ip_mreq imreq = {0}; - IN_ADDR addr = *reinterpret_cast(address->address); - imreq.imr_multiaddr.s_addr = addr.S_un.S_addr; - imreq.imr_interface.s_addr = INADDR_ANY; - - int result = setsockopt(socket->socket_handle, IPPROTO_IP, IP_ADD_MEMBERSHIP, - reinterpret_cast(&imreq), sizeof(imreq)); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Failed to IP_ADD_MEMBERSHIP on socket " - << socket->socket_handle << ", last_error = " << last_error; - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return false; - } - - socket->error = kSbSocketOk; - return true; -} diff --git a/starboard/shared/win32/socket_listen.cc b/starboard/shared/win32/socket_listen.cc deleted file mode 100644 index 0fbdda77c24a..000000000000 --- a/starboard/shared/win32/socket_listen.cc +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -SbSocketError SbSocketListen(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - return kSbSocketErrorFailed; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - - // Under winsock, a socket must be bound before we can listen on it. - if (socket->bound_to == SbSocketPrivate::BindTarget::kUnbound) { - // By listening on ::, we can accept both IPv4 and IPv6 connections. - SbSocketAddress any_address = {0}; - any_address.type = socket->address_type; - if (SbSocketBind(socket, &any_address) != kSbSocketOk) { - SB_DLOG(ERROR) << "Unable to bind a socket during SbListen."; - return (socket->error = kSbSocketErrorFailed); - } - - socket->bound_to = SbSocketPrivate::BindTarget::kAny; - } - - // We set the backlog to SOMAXCONN to ensure that it is above 1, and high - // enough that all tests are able to pass. Some tests will fail if backlog==1 - // because they expect to be able to successfully initiate multiple connects - // at once, and then after all connects have been initiated to subsequently - // initiate corresponding accepts. - int result = listen(socket->socket_handle, SOMAXCONN); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_LOG(ERROR) << "listen() failed with last_error = " << last_error; - return (socket->error = sbwin32::TranslateSocketErrorStatus(last_error)); - } - - return (socket->error = kSbSocketOk); -} diff --git a/starboard/shared/win32/socket_receive_from.cc b/starboard/shared/win32/socket_receive_from.cc deleted file mode 100644 index 2788266e3faf..000000000000 --- a/starboard/shared/win32/socket_receive_from.cc +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -namespace { - -bool IsReportableErrno(int code) { - return (code != WSAEWOULDBLOCK && code != WSAECONNRESET); -} - -} // namespace - -int SbSocketReceiveFrom(SbSocket socket, - char* out_data, - int data_size, - SbSocketAddress* out_source) { - const int kRecvFlags = 0; - - if (!SbSocketIsValid(socket)) { - return -1; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - if (socket->protocol == kSbSocketProtocolTcp) { - if (out_source) { - sbwin32::SockAddr sock_addr; - int result = getpeername(socket->socket_handle, sock_addr.sockaddr(), - &sock_addr.length); - if (result == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << __FUNCTION__ - << ": getpeername failed, last_error = " << last_error; - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return -1; - } - - if (!sock_addr.ToSbSocketAddress(out_source)) { - SB_DLOG(FATAL) << __FUNCTION__ << ": Bad TCP source address."; - socket->error = kSbSocketErrorFailed; - return -1; - } - } - - int bytes_read = - recv(socket->socket_handle, out_data, data_size, kRecvFlags); - if (bytes_read >= 0) { - socket->error = kSbSocketOk; - return static_cast(bytes_read); - } - - int last_error = WSAGetLastError(); - if (IsReportableErrno(last_error) && - socket->error != sbwin32::TranslateSocketErrorStatus(last_error)) { - SB_DLOG(ERROR) << "recv failed, last_error = " << last_error; - } - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return -1; - } else if (socket->protocol == kSbSocketProtocolUdp) { - sbwin32::SockAddr sock_addr; - ssize_t bytes_read = - recvfrom(socket->socket_handle, out_data, data_size, kRecvFlags, - sock_addr.sockaddr(), &sock_addr.length); - - if (bytes_read >= 0) { - if (out_source) { - if (!sock_addr.ToSbSocketAddress(out_source)) { - SB_DLOG(FATAL) << __FUNCTION__ << ": Bad UDP source address."; - socket->error = kSbSocketErrorFailed; - return -1; - } - } - - socket->error = kSbSocketOk; - return static_cast(bytes_read); - } - - int last_error = WSAGetLastError(); - if (last_error != WSAEWOULDBLOCK && - socket->error != sbwin32::TranslateSocketErrorStatus(last_error)) { - SB_DLOG(ERROR) << "recvfrom failed, last_error = " << last_error; - } - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return -1; - } - - SB_NOTREACHED() << "Unrecognized protocol: " << socket->protocol; - return -1; -} diff --git a/starboard/shared/win32/socket_resolve.cc b/starboard/shared/win32/socket_resolve.cc deleted file mode 100644 index 2074e6d6e04c..000000000000 --- a/starboard/shared/win32/socket_resolve.cc +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -SbSocketResolution* SbSocketResolve(const char* hostname, int filters) { - struct addrinfo* ai = nullptr; - struct addrinfo hints = {0}; - - if (filters & kSbSocketResolveFilterIpv4) { - if (filters & kSbSocketResolveFilterIpv6) { - hints.ai_family = AF_UNSPEC; - } else { - hints.ai_family = AF_INET; - } - } else if (filters & kSbSocketResolveFilterIpv6) { - hints.ai_family = AF_INET6; - } else { - hints.ai_family = AF_UNSPEC; - } - - hints.ai_flags = AI_ADDRCONFIG; - hints.ai_socktype = SOCK_STREAM; - - // Actually make the call to get the data. - int err = getaddrinfo(hostname, nullptr, &hints, &ai); - if (err != 0 || ai == nullptr) { - SB_DLOG(ERROR) << "getaddrinfo failed. last_error: " << WSAGetLastError(); - return nullptr; - } - - int address_count = 0; - for (const auto* i = ai; i != nullptr; i = i->ai_next) { - ++address_count; - } - - SbSocketResolution* result = new SbSocketResolution(); - - // Translate all the sockaddrs. - std::vector sock_addrs; - sock_addrs.resize(address_count); - - std::vector parsed; - parsed.resize(address_count); - - int index = 0; - int skip = 0; - for (const auto* i = ai; i != nullptr; i = i->ai_next, ++index) { - // Skip over any addresses we can't parse. - parsed[index] = sock_addrs[index].FromSockaddr(i->ai_addr); - if (!parsed[index]) { - ++skip; - } - } - - result->address_count = address_count - skip; - result->addresses = new SbSocketAddress[result->address_count]; - - int result_index = 0; - for (int i = 0; i < address_count; ++i) { - if (parsed[i] && - sock_addrs[i].ToSbSocketAddress(&result->addresses[result_index])) { - ++result_index; - } - } - - freeaddrinfo(ai); - return result; -} diff --git a/starboard/shared/win32/socket_send_to.cc b/starboard/shared/win32/socket_send_to.cc deleted file mode 100644 index b7ac3dce8701..000000000000 --- a/starboard/shared/win32/socket_send_to.cc +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -namespace { -std::string CreateErrorString(const SbSocketAddress* addr, int error) { - std::stringstream out; - if (addr) { - out << "Sendto failed while sending to port " << addr->port - << ". Last Error: 0x" << std::hex << error; - } else { - out << "Sendto failed because of error: 0x" << std::hex << error; - } - return out.str(); -} -} // namespace - -int SbSocketSendTo(SbSocket socket, - const char* data, - int data_size, - const SbSocketAddress* destination) { - const int kSendFlags = 0; - if (!SbSocketIsValid(socket)) { - return -1; - } - - SB_DCHECK(socket->socket_handle != INVALID_SOCKET); - if (socket->protocol == kSbSocketProtocolTcp) { - if (destination) { - SB_DLOG(FATAL) << "Destination passed to TCP send."; - socket->error = kSbSocketErrorFailed; - return -1; - } - - int bytes_written = - send(socket->socket_handle, data, data_size, kSendFlags); - if (bytes_written >= 0) { - socket->error = kSbSocketOk; - return static_cast(bytes_written); - } - - int last_error = WSAGetLastError(); - - if ((last_error == WSAEWOULDBLOCK) || (last_error == WSAECONNABORTED)) { - socket->writable.store(false); - } else { - SB_DLOG(ERROR) << CreateErrorString(destination, last_error); - } - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return -1; - } else if (socket->protocol == kSbSocketProtocolUdp) { - if (!destination) { - SB_DLOG(FATAL) << "No destination passed to UDP send."; - socket->error = kSbSocketErrorFailed; - return -1; - } - - sbwin32::SockAddr sock_addr; - const sockaddr* sockaddr = nullptr; - socklen_t sockaddr_length = 0; - if (destination) { - if (!sock_addr.FromSbSocketAddress(destination)) { - SB_DLOG(FATAL) << "Invalid destination passed to UDP send."; - socket->error = kSbSocketErrorFailed; - return -1; - } - sockaddr = sock_addr.sockaddr(); - sockaddr_length = sock_addr.length; - } - - int bytes_written = sendto(socket->socket_handle, data, data_size, - kSendFlags, sockaddr, sockaddr_length); - if (bytes_written >= 0) { - socket->error = kSbSocketOk; - return static_cast(bytes_written); - } - - int last_error = WSAGetLastError(); - - if (last_error != WSAEWOULDBLOCK) { - SB_DLOG(ERROR) << CreateErrorString(destination, last_error); - } - socket->error = sbwin32::TranslateSocketErrorStatus(last_error); - return -1; - } - - SB_NOTREACHED() << "Unrecognized protocol: " << socket->protocol; - return -1; -} diff --git a/starboard/shared/win32/socket_set_broadcast.cc b/starboard/shared/win32/socket_set_broadcast.cc deleted file mode 100644 index af86362e7c1c..000000000000 --- a/starboard/shared/win32/socket_set_broadcast.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetBroadcast(SbSocket socket, bool value) { - return sbwin32::SetBooleanSocketOption(socket, SOL_SOCKET, SO_BROADCAST, - "SO_BROADCAST", value); -} diff --git a/starboard/shared/win32/socket_set_receive_buffer_size.cc b/starboard/shared/win32/socket_set_receive_buffer_size.cc deleted file mode 100644 index f9571be47137..000000000000 --- a/starboard/shared/win32/socket_set_receive_buffer_size.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetReceiveBufferSize(SbSocket socket, int32_t size) { - return sbwin32::SetIntegerSocketOption(socket, SOL_SOCKET, SO_RCVBUF, - "SO_RCVBUF", size); -} diff --git a/starboard/shared/win32/socket_set_reuse_address.cc b/starboard/shared/win32/socket_set_reuse_address.cc deleted file mode 100644 index b240402d4749..000000000000 --- a/starboard/shared/win32/socket_set_reuse_address.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetReuseAddress(SbSocket socket, bool value) { - return sbwin32::SetBooleanSocketOption(socket, SOL_SOCKET, SO_REUSEADDR, - "SO_REUSEADDR", value); -} diff --git a/starboard/shared/win32/socket_set_send_buffer_size.cc b/starboard/shared/win32/socket_set_send_buffer_size.cc deleted file mode 100644 index ca02d0111f62..000000000000 --- a/starboard/shared/win32/socket_set_send_buffer_size.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetSendBufferSize(SbSocket socket, int32_t size) { - return sbwin32::SetIntegerSocketOption(socket, SOL_SOCKET, SO_SNDBUF, - "SO_SNDBUF", size); -} diff --git a/starboard/shared/win32/socket_set_tcp_keep_alive.cc b/starboard/shared/win32/socket_set_tcp_keep_alive.cc deleted file mode 100644 index ba88a1905822..000000000000 --- a/starboard/shared/win32/socket_set_tcp_keep_alive.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetTcpKeepAlive(SbSocket socket, bool value, int64_t period) { - bool result = sbwin32::SetBooleanSocketOption( - socket, SOL_SOCKET, SO_KEEPALIVE, "SO_KEEPALIVE", value); - return result; -} diff --git a/starboard/shared/win32/socket_set_tcp_no_delay.cc b/starboard/shared/win32/socket_set_tcp_no_delay.cc deleted file mode 100644 index f6c340879803..000000000000 --- a/starboard/shared/win32/socket_set_tcp_no_delay.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include - -#include "starboard/shared/win32/socket_internal.h" - -namespace sbwin32 = starboard::shared::win32; - -bool SbSocketSetTcpNoDelay(SbSocket socket, bool value) { - return sbwin32::SetBooleanSocketOption(socket, IPPROTO_TCP, TCP_NODELAY, - "TCP_NODELAY", value); -} diff --git a/starboard/shared/win32/socket_set_tcp_window_scaling.cc b/starboard/shared/win32/socket_set_tcp_window_scaling.cc deleted file mode 100644 index 091af3cc51e9..000000000000 --- a/starboard/shared/win32/socket_set_tcp_window_scaling.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/socket.h" - -#include -#include - -// Note that windows.h and winsock2.h must be included before these. -#include -#include - -#include "starboard/shared/win32/socket_internal.h" - -bool SbSocketSetTcpWindowScaling(SbSocket socket, bool enable_window_scaling) { - // From - // https://msdn.microsoft.com/en-us/library/windows/desktop/cc136103(v=vs.85).aspx: - // "When the TargetOsVersion member is set to a value for Windows Vista or - // later, receive window auto-tuning is enabled and the TCP window scale - // factor is reduced to 2 from the default value of 8." - - if (socket == kSbSocketInvalid) - return false; - - const ULONG target_os_version = - enable_window_scaling ? NTDDI_VISTA : NTDDI_WS03; - WSA_COMPATIBILITY_MODE compatibility_mode = {WsaBehaviorAutoTuning, - target_os_version}; - - DWORD kZero = 0; - int return_value = WSAIoctl( - socket->socket_handle, SIO_SET_COMPATIBILITY_MODE, &compatibility_mode, - sizeof(WSA_COMPATIBILITY_MODE), nullptr, 0, &kZero, nullptr, nullptr); - - return return_value != SOCKET_ERROR; -} diff --git a/starboard/shared/win32/socket_waiter_add.cc b/starboard/shared/win32/socket_waiter_add.cc deleted file mode 100644 index d16114a3993d..000000000000 --- a/starboard/shared/win32/socket_waiter_add.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/common/log.h" -#include "starboard/shared/win32/socket_waiter_internal.h" - -#if SB_API_VERSION >= 16 -bool SbPosixSocketWaiterAdd(SbSocketWaiter waiter, - int socket, - void* context, - SbPosixSocketWaiterCallback callback, - int interests, - bool persistent) { - if (!SbSocketWaiterIsValid(waiter)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Waiter (" << waiter << ") is invalid."; - return false; - } - - if (socket < 0) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (!callback) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No callback provided."; - return false; - } - - if (!interests) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No interests provided."; - return false; - } - - return waiter->Add(socket, waiter, context, callback, interests, persistent); -} -#endif // SB_API_VERSION >= 16 - -bool SbSocketWaiterAdd(SbSocketWaiter waiter, - SbSocket socket, - void* context, - SbSocketWaiterCallback callback, - int interests, - bool persistent) { - if (!SbSocketWaiterIsValid(waiter)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Waiter (" << waiter << ") is invalid."; - return false; - } - - if (!SbSocketIsValid(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (!callback) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No callback provided."; - return false; - } - - if (!interests) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No interests provided."; - return false; - } - - return waiter->Add(socket, context, callback, interests, persistent); -} diff --git a/starboard/shared/win32/socket_waiter_create.cc b/starboard/shared/win32/socket_waiter_create.cc deleted file mode 100644 index 0b032f2d1cb8..000000000000 --- a/starboard/shared/win32/socket_waiter_create.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -SbSocketWaiter SbSocketWaiterCreate() { - return new SbSocketWaiterPrivate(); -} diff --git a/starboard/shared/win32/socket_waiter_destroy.cc b/starboard/shared/win32/socket_waiter_destroy.cc deleted file mode 100644 index 22bab6003ef1..000000000000 --- a/starboard/shared/win32/socket_waiter_destroy.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -bool SbSocketWaiterDestroy(SbSocketWaiter waiter) { - if (!SbSocketWaiterIsValid(waiter)) { - return false; - } - delete waiter; - return true; -} diff --git a/starboard/shared/win32/socket_waiter_internal.cc b/starboard/shared/win32/socket_waiter_internal.cc deleted file mode 100644 index 7162e358efa8..000000000000 --- a/starboard/shared/win32/socket_waiter_internal.cc +++ /dev/null @@ -1,759 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#undef socket - -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/optional.h" -#include "starboard/common/time.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/socket_internal.h" -#include "starboard/shared/win32/socket_waiter_internal.h" -#include "starboard/shared/win32/thread_private.h" -#include "starboard/shared/win32/time_utils.h" -#include "starboard/thread.h" - -namespace sbwin32 = starboard::shared::win32; - -namespace { - -// This is a helper function that takes data from |network_events|, and then -// adds the bitwise ORs |interest_to_add| onto |interest_out|. -// For more information, please see -// https://msdn.microsoft.com/en-us/library/windows/desktop/ms741572(v=vs.85).aspx. -void TranslateNetworkBitIntoInterests(const WSANETWORKEVENTS& network_events, - int bit_to_check, - SbSocketWaiterInterest interest_to_add, - SbSocketWaiterInterest* interests_out) { - SB_DCHECK(interests_out); - - static_assert( - sizeof(SbSocketWaiterInterest) == sizeof(int), - "Assuming size of enum is size of int, due to the bitfield logic below."); - - if (network_events.lNetworkEvents & (1 << bit_to_check)) { - *(reinterpret_cast(interests_out)) |= - static_cast(interest_to_add); - const int error_code = network_events.iErrorCode[bit_to_check]; - if (error_code != 0) { - SB_DLOG(ERROR) << "Error on network event " << bit_to_check << " " - << sbwin32::Win32ErrorCode(error_code); - } - } -} - -SbSocketWaiterInterest DiscoverNetworkEventInterests(SOCKET socket_handle) { - // Please take note that WSAEnumNetworkEvents below only works with - // WSAEventSelect. - SbSocketWaiterInterest interests = kSbSocketWaiterInterestNone; - WSANETWORKEVENTS network_events = {0}; - int return_code = - WSAEnumNetworkEvents(socket_handle, nullptr, &network_events); - if (return_code == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "WSAEnumNetworkEvents failed with last_error = " - << sbwin32::Win32ErrorCode(last_error); - return interests; - } - - // Translate information from WSAEnumNetworkEvents to interests: - // From the MSDN documentation: - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms741572(v=vs.85).aspx - // The lNetworkEvents member of the WSANETWORKEVENTS structure indicates which - // of the FD_XXX network events have occurred. The iErrorCode array is used to - // contain any associated error codes with the array index corresponding to - // the position of event bits in lNetworkEvents. Identifiers such as - // FD_READ_BIT and FD_WRITE_BIT can be used to index the iErrorCode array. - // Note that only those elements of the iErrorCode array are set that - // correspond to the bits set in lNetworkEvents parameter - TranslateNetworkBitIntoInterests(network_events, FD_READ_BIT, - kSbSocketWaiterInterestRead, &interests); - TranslateNetworkBitIntoInterests(network_events, FD_ACCEPT_BIT, - kSbSocketWaiterInterestRead, &interests); - TranslateNetworkBitIntoInterests(network_events, FD_CLOSE_BIT, - kSbSocketWaiterInterestRead, &interests); - - TranslateNetworkBitIntoInterests(network_events, FD_CONNECT_BIT, - kSbSocketWaiterInterestWrite, &interests); - TranslateNetworkBitIntoInterests(network_events, FD_WRITE_BIT, - kSbSocketWaiterInterestWrite, &interests); - - return interests; -} - -// The function erases the |index|th element from the collection by swapping -// it with the last element. This operation leaves all the other elements in -// place, which is useful for some operations. -template -void EraseIndexFromVector(T* collection_pointer, std::size_t index) { - SB_DCHECK(collection_pointer); - T& collection = *collection_pointer; - const std::size_t current_size = collection.size(); - if (current_size <= 1) { - collection.clear(); - return; - } - const std::size_t new_size = collection.size() - 1; - std::swap(collection[index], collection[new_size]); - collection.resize(new_size); -} - -SbSocketWaiterInterest CombineInterests(SbSocketWaiterInterest a, - SbSocketWaiterInterest b) { - int a_int = static_cast(a); - int b_int = static_cast(b); - return static_cast(a_int | b_int); -} - -} // namespace - -SbSocketWaiterPrivate::SbSocketWaiterPrivate() - : thread_(pthread_self()), - wakeup_event_token_(-1), - wakeup_event_(CreateEvent(nullptr, false, false, nullptr)) { - { - starboard::ScopedLock lock(unhandled_wakeup_count_mutex_); - unhandled_wakeup_count_ = 0; - } - if (wakeup_event_.IsValid() == false) { - SB_DLOG(ERROR) << "Could not create wakeup event: " - << starboard::shared::win32::Win32ErrorCode(GetLastError()); - return; - } - wakeup_event_token_ = - waitees_.AddSocketEventAndWaitee(wakeup_event_.GetEvent(), nullptr); -} - -SbSocketWaiterPrivate::~SbSocketWaiterPrivate() { - for (auto& it : waitees_.GetWaitees()) { - if (it) { - if (it->use_posix_socket == 1) { -#if SB_API_VERSION >= 16 - SB_DCHECK(CheckSocketWaiterIsThis(it->posix_socket, it->waiter)); -#endif - } else { - SB_DCHECK(CheckSocketWaiterIsThis(it->socket)); - } - } - } -} - -#if SB_API_VERSION >= 16 -bool SbSocketWaiterPrivate::Add(int socket, - SbSocketWaiter waiter, - void* context, - SbPosixSocketWaiterCallback callback, - int interests, - bool persistent) { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - if (socket < 0) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (!interests) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No interests provided."; - return false; - } - - // The policy is not to add a socket to a waiter if it is registered with - // another waiter. - - // TODO: Since integer based socket fd doesn't have waiter information, - // need to find a way to keep track whether this socket has been - // registered with a waiter already. - // At this moment, at least we can test if this specific socket - // is already registered to this incoming waiter. - if (waiter->CheckSocketRegistered(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket already has this waiter (" - << this << ")."; - return false; - } - - int network_event_interests = 0; - if (interests & kSbSocketWaiterInterestRead) { - network_event_interests |= FD_READ | FD_ACCEPT | FD_CLOSE; - } - - if (interests & kSbSocketWaiterInterestWrite) { - network_event_interests |= FD_CONNECT | FD_WRITE; - } - - const BOOL manual_reset = !persistent; - - // Without SbSocket->socket_event, we need a standalone socket_event and store - // it inside the waitee. - sbwin32::AutoEventHandle* socket_event_ptr = - new sbwin32::AutoEventHandle(WSA_INVALID_EVENT); - - socket_event_ptr->Reset(CreateEvent(nullptr, manual_reset, false, nullptr)); - if (socket_event_ptr->GetEvent() == WSA_INVALID_EVENT) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Error calling WSACreateEvent() last_error = " - << sbwin32::Win32ErrorCode(last_error); - return false; - } - - // Note that WSAEnumNetworkEvents used elsewhere only works with - // WSAEventSelect. - // Please consider that before changing this code. - int return_value = - WSAEventSelect(posix_socket_get_handle_from_fd(socket), - socket_event_ptr->GetEvent(), network_event_interests); - - if (return_value == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Error calling WSAEventSelect() last_error = " - << sbwin32::Win32ErrorCode(last_error); - return false; - } - - if (waitees_.GetHandleArraySize() >= MAXIMUM_WAIT_OBJECTS) { - SB_DLOG(ERROR) << "Reached maxed number of socket events (" - << MAXIMUM_WAIT_OBJECTS << ")"; - return false; - } - - std::unique_ptr waitee(new Waitee(this, socket, socket_event_ptr, - context, callback, interests, - persistent)); - - waitees_.AddSocketEventAndWaitee(socket_event_ptr->GetEvent(), - std::move(waitee)); - waiter = this; - - return true; -} - -bool SbSocketWaiterPrivate::Remove(int socket, SbSocketWaiter waiter) { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - if (!CheckSocketWaiterIsThis(socket, waiter)) { - return false; - } - - waiter = kSbSocketWaiterInvalid; - - Waitee* waitee_ptr = waitees_.GetWaitee(socket); - if (waitee_ptr != nullptr && waitee_ptr->socket_event_ptr != nullptr) { - delete waitee_ptr->socket_event_ptr; - waitee_ptr->socket_event_ptr = nullptr; - } - - return waitees_.RemoveSocket(socket); -} - -#endif // SB_API_VERSION >= 16 - -bool SbSocketWaiterPrivate::Add(SbSocket socket, - void* context, - SbSocketWaiterCallback callback, - int interests, - bool persistent) { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - if (!SbSocketIsValid(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (!interests) { - SB_DLOG(ERROR) << __FUNCTION__ << ": No interests provided."; - return false; - } - - // The policy is not to add a socket to a waiter if it is registered with - // another waiter. - - // TODO: If anyone were to want to add a socket to a different waiter, - // it would probably be another thread, so doing this check without locking is - // probably wrong. But, it is also a pain, and, at this precise moment, socket - // access is all going to come from one I/O thread anyway, and there will only - // be one waiter. - if (SbSocketWaiterIsValid(socket->waiter)) { - if (socket->waiter == this) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket already has this waiter (" - << this << ")."; - } else { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket already has waiter (" - << socket->waiter << ", this=" << this << ")."; - } - return false; - } - - int network_event_interests = 0; - if (interests & kSbSocketWaiterInterestRead) { - network_event_interests |= FD_READ | FD_ACCEPT | FD_CLOSE; - } - - if (interests & kSbSocketWaiterInterestWrite) { - network_event_interests |= FD_CONNECT | FD_WRITE; - } - - const BOOL manual_reset = !persistent; - - SB_DCHECK(!socket->socket_event.IsValid()); - - socket->socket_event.Reset( - CreateEvent(nullptr, manual_reset, false, nullptr)); - if (socket->socket_event.GetEvent() == WSA_INVALID_EVENT) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Error calling WSACreateEvent() last_error = " - << sbwin32::Win32ErrorCode(last_error); - return false; - } - - // Note that WSAEnumNetworkEvents used elsewhere only works with - // WSAEventSelect. - // Please consider that before changing this code. - int return_value = - WSAEventSelect(socket->socket_handle, socket->socket_event.GetEvent(), - network_event_interests); - - if (return_value == SOCKET_ERROR) { - int last_error = WSAGetLastError(); - SB_DLOG(ERROR) << "Error calling WSAEventSelect() last_error = " - << sbwin32::Win32ErrorCode(last_error); - return false; - } - - if (waitees_.GetHandleArraySize() >= MAXIMUM_WAIT_OBJECTS) { - SB_DLOG(ERROR) << "Reached maxed number of socket events (" - << MAXIMUM_WAIT_OBJECTS << ")"; - return false; - } - - std::unique_ptr waitee( - new Waitee(this, socket, context, callback, interests, persistent)); - waitees_.AddSocketEventAndWaitee(socket->socket_event.GetEvent(), - std::move(waitee)); - socket->waiter = this; - - return true; -} - -bool SbSocketWaiterPrivate::Remove(SbSocket socket) { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - if (!CheckSocketWaiterIsThis(socket)) { - return false; - } - - socket->waiter = kSbSocketWaiterInvalid; - - socket->socket_event.Reset(nullptr); - return waitees_.RemoveSocket(socket); -} - -void SbSocketWaiterPrivate::HandleWakeUpRead() { - SB_LOG(INFO) << "HandleWakeUpRead incrementing counter.."; - starboard::ScopedLock lock(unhandled_wakeup_count_mutex_); - ++unhandled_wakeup_count_; -} - -void SbSocketWaiterPrivate::SignalWakeupEvent() { - SB_DCHECK(wakeup_event_.IsValid()); - WSASetEvent(wakeup_event_.GetEvent()); -} - -void SbSocketWaiterPrivate::ResetWakeupEvent() { - SB_DCHECK(wakeup_event_.IsValid()); - WSAResetEvent(wakeup_event_.GetEvent()); -} - -#if SB_API_VERSION >= 16 -bool SbSocketWaiterPrivate::CheckSocketWaiterIsThis(int socket, - SbSocketWaiter waiter) { - if (socket < 0) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (waiter != this) { - return false; - } - - return true; -} - -bool SbSocketWaiterPrivate::CheckSocketRegistered(int socket) { - if (socket < 0) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (waitees_.GetIndex(socket) == starboard::nullopt) { - return false; - } - - return true; -} - -#endif // SB_API_VERSION >= 16 - -bool SbSocketWaiterPrivate::CheckSocketWaiterIsThis(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - - if (socket->waiter != this) { - return false; - } - - return true; -} - -bool SbSocketWaiterPrivate::CheckSocketRegistered(SbSocket socket) { - if (!SbSocketIsValid(socket)) { - SB_DLOG(ERROR) << __FUNCTION__ << ": Socket (" << socket << ") is invalid."; - return false; - } - if (waitees_.GetIndex(socket) == starboard::nullopt) { - return false; - } - - return true; -} - -void SbSocketWaiterPrivate::Wait() { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - // We basically wait for the largest amount of time to achieve an indefinite - // block. - WaitTimed(kSbInt64Max); -} - -SbSocketWaiterResult SbSocketWaiterPrivate::WaitTimed(int64_t duration_usec) { - SB_DCHECK(pthread_equal(pthread_self(), thread_)); - - const int64_t start_time = starboard::CurrentMonotonicTime(); - int64_t duration_left = duration_usec; - - while (true) { - // |waitees_| could have been modified in the last loop iteration, so - // re-read it. - const DWORD number_events = - static_cast(waitees_.GetHandleArraySize()); - - const DWORD millis = sbwin32::ConvertUsecToMillisRoundUp(duration_left); - - { - starboard::ScopedLock lock(unhandled_wakeup_count_mutex_); - if (unhandled_wakeup_count_ > 0) { - --unhandled_wakeup_count_; - // The signaling thread also set the event, so reset it. - ResetWakeupEvent(); - return kSbSocketWaiterResultWokenUp; - } - } - - // Check existing waitees to find out which type of socket is used - // This check applies to SB16 and above only because of the POSIX APIs. - int use_posix_socket = 0; -#if SB_API_VERSION >= 16 - for (auto& it : waitees_.GetWaitees()) { - if (!it) { - continue; - } - if (it->use_posix_socket == 1) { - use_posix_socket = 1; - break; - } - } -#endif // SB_API_VERSION >= 16 - - // There should always be a wakeup event. - SB_DCHECK(number_events > 0); - bool has_writable; - int posix_maybe_writable_socket = -1; - SbSocket maybe_writable_socket = kSbSocketInvalid; - - if (use_posix_socket == 1) { -#if SB_API_VERSION >= 16 - has_writable = (posix_maybe_writable_socket != -1); -#endif - } else { - for (auto& it : waitees_.GetWaitees()) { - if (!it) { - continue; - } - if ((it->interests & kSbSocketWaiterInterestWrite) == 0) { - continue; - } - if (it->socket->writable.load()) { - maybe_writable_socket = it->socket; - break; - } - } - - has_writable = (maybe_writable_socket != kSbSocketInvalid); - } - - DWORD return_value = - WSAWaitForMultipleEvents(number_events, waitees_.GetHandleArray(), - false, has_writable ? 0 : millis, false); - - if (has_writable || ((return_value >= WSA_WAIT_EVENT_0) && - (return_value < (WSA_WAIT_EVENT_0 + number_events)))) { - int64_t socket_index; - if (has_writable) { - if (use_posix_socket == 1) { - socket_index = waitees_.GetIndex(posix_maybe_writable_socket).value(); - } else { - socket_index = waitees_.GetIndex(maybe_writable_socket).value(); - } - } else { - socket_index = static_cast(return_value) - - static_cast(WSA_WAIT_EVENT_0); - } - SB_DCHECK(socket_index >= 0); - if (socket_index < 0) { - SB_NOTREACHED() << "Bad socket_index. " << socket_index; - return kSbSocketWaiterResultTimedOut; - } - - // Make sure wakeup_event_token_ is initialized. - SB_DCHECK(wakeup_event_token_ >= 0); - - if (socket_index == wakeup_event_token_) { - starboard::ScopedLock lock(unhandled_wakeup_count_mutex_); - SB_DCHECK(unhandled_wakeup_count_ > 0); - - --unhandled_wakeup_count_; - // This was a dummy event. We were woken up. - // Note that we do not need to reset the event here, - // since it was created using an auto-reset flag. - return kSbSocketWaiterResultWokenUp; - } else { - Waitee* waitee = waitees_.GetWaiteeByIndex(socket_index); - - // Remove the non-persistent waitee before calling the callback, so - // that we can add another waitee in the callback if we need to. This - // is also why we copy all the fields we need out of waitee. - if (use_posix_socket == 1) { -#if SB_API_VERSION >= 16 - const int posix_socket = waitee->posix_socket; - const SbPosixSocketWaiterCallback posix_callback = - waitee->posix_callback; - - void* context = waitee->context; - - // Note: this should also go before Remove(). - SbSocketWaiterInterest interests = DiscoverNetworkEventInterests( - posix_socket_get_handle_from_fd(posix_socket)); - - // TODO: implement "writable" - if (!waitee->persistent) { - Remove(waitee->posix_socket, waitee->waiter); - } - posix_callback(this, posix_socket, context, interests); -#endif - } else { - const SbSocket socket = waitee->socket; - const SbSocketWaiterCallback callback = waitee->callback; - - void* context = waitee->context; - - // Note: this should also go before Remove(). - SbSocketWaiterInterest interests = - DiscoverNetworkEventInterests(socket->socket_handle); - - if ((waitee->interests & kSbSocketWaiterInterestWrite) && - socket->writable.load()) { - interests = - CombineInterests(interests, kSbSocketWaiterInterestWrite); - } else if (interests & kSbSocketWaiterInterestWrite) { - socket->writable.store(true); - } - - if (!waitee->persistent) { - Remove(waitee->socket); - } - callback(this, socket, context, interests); - } - } - } else if (return_value == WSA_WAIT_FAILED) { - SB_DLOG(ERROR) << "Wait failed -- " - << sbwin32::Win32ErrorCode(WSAGetLastError()); - return kSbSocketWaiterResultInvalid; - } else if (return_value == WSA_WAIT_TIMEOUT) { - // Do nothing, check time ourselves. - } else { - SB_NOTREACHED() << "Unhandled case: " << return_value; - return kSbSocketWaiterResultInvalid; - } - - const int64_t time_elapsed = - static_cast(starboard::CurrentMonotonicTime()) - - static_cast(start_time); - duration_left -= time_elapsed; - if (duration_left < 0) { - return kSbSocketWaiterResultTimedOut; - } - } - - SB_NOTREACHED() << "Invalid state reached"; - return kSbSocketWaiterResultInvalid; -} - -void SbSocketWaiterPrivate::WakeUp() { - // Increasing unhandled_wakeup_count_mutex_ and calling SignalWakeupEvent - // atomically helps add additional guarantees of when the waiter can be - // woken up. While we can code around this easily, having a stronger - // coupling enables us to add DCHECKs for |unhandled_wakeup_count_| in other - // parts of the code. - starboard::ScopedLock lock(unhandled_wakeup_count_mutex_); - ++unhandled_wakeup_count_; - SignalWakeupEvent(); -} - -#if SB_API_VERSION >= 16 -SbSocketWaiterPrivate::Waitee* SbSocketWaiterPrivate::WaiteeRegistry::GetWaitee( - int socket) { - starboard::optional token = GetIndex(socket); - if (!token) { - return nullptr; - } - return waitees_[token.value()].get(); -} - -starboard::optional SbSocketWaiterPrivate::WaiteeRegistry::GetIndex( - int socket) { - auto iterator = posix_socket_to_index_map_.find(socket); - if (iterator == posix_socket_to_index_map_.end()) { - return starboard::nullopt; - } - - return iterator->second; -} - -bool SbSocketWaiterPrivate::WaiteeRegistry::RemoveSocket(int socket) { - auto iterator = posix_socket_to_index_map_.find(socket); - if (iterator == posix_socket_to_index_map_.end()) { - return false; - } - - const std::size_t current_size = socket_events_.size(); - SB_DCHECK(current_size == waitees_.size()); - - const std::size_t socket_index = iterator->second; - int socket_to_swap = waitees_[current_size - 1]->posix_socket; - // Since |EraseIndexFromVector| will swap the last socket and the socket - // at current index, |socket_to_index_| will need to be updated. - posix_socket_to_index_map_[socket_to_swap] = socket_index; - - // Note that |EraseIndexFromVector| only touches the last element and the - // element to remove. - EraseIndexFromVector(&socket_events_, socket_index); - EraseIndexFromVector(&waitees_, socket_index); - - posix_socket_to_index_map_.erase(socket); - - SB_DCHECK(socket_events_.size() == waitees_.size()); - SB_DCHECK(socket_events_.size() == posix_socket_to_index_map_.size()); - return true; -} - -#endif // SB_API_VERSION >= 16 - -SbSocketWaiterPrivate::Waitee* SbSocketWaiterPrivate::WaiteeRegistry::GetWaitee( - SbSocket socket) { - starboard::optional token = GetIndex(socket); - if (!token) { - return nullptr; - } - return waitees_[token.value()].get(); -} - -starboard::optional SbSocketWaiterPrivate::WaiteeRegistry::GetIndex( - SbSocket socket) { - auto iterator = socket_to_index_map_.find(socket); - if (iterator == socket_to_index_map_.end()) { - return starboard::nullopt; - } - return iterator->second; -} - -SbSocketWaiterPrivate::WaiteeRegistry::LookupToken -SbSocketWaiterPrivate::WaiteeRegistry::AddSocketEventAndWaitee( - WSAEVENT socket_event, - std::unique_ptr waitee) { - SB_DCHECK(socket_event != WSA_INVALID_EVENT); - SB_DCHECK(socket_events_.size() == waitees_.size()); - - if (!waitee) { -#if SB_API_VERSION >= 16 - posix_socket_to_index_map_.emplace(-1, socket_events_.size()); -#endif - socket_to_index_map_.emplace(kSbSocketInvalid, socket_events_.size()); - } else { - if (waitee->use_posix_socket == 1) { -#if SB_API_VERSION >= 16 - posix_socket_to_index_map_.emplace(waitee->posix_socket, - socket_events_.size()); -#endif - } else { - socket_to_index_map_.emplace(waitee->socket, socket_events_.size()); - } - } - - socket_events_.emplace_back(socket_event); - waitees_.emplace_back(std::move(waitee)); - - return socket_events_.size() - 1; -} - -bool SbSocketWaiterPrivate::WaiteeRegistry::RemoveSocket(SbSocket socket) { - auto iterator = socket_to_index_map_.find(socket); - if (iterator == socket_to_index_map_.end()) { - return false; - } - - const std::size_t current_size = socket_events_.size(); - SB_DCHECK(current_size == waitees_.size()); - - const std::size_t socket_index = iterator->second; - SbSocket socket_to_swap = waitees_[current_size - 1]->socket; - // Since |EraseIndexFromVector| will swap the last socket and the socket - // at current index, |socket_to_index_| will need to be updated. - socket_to_index_map_[socket_to_swap] = socket_index; - - // Note that |EraseIndexFromVector| only touches the last element and the - // element to remove. - EraseIndexFromVector(&socket_events_, socket_index); - EraseIndexFromVector(&waitees_, socket_index); - - socket_to_index_map_.erase(socket); - - SB_DCHECK(socket_events_.size() == waitees_.size()); - SB_DCHECK(socket_events_.size() == socket_to_index_map_.size()); - return true; -} - -SbSocketWaiterPrivate::Waitee* -SbSocketWaiterPrivate::WaiteeRegistry::GetWaiteeByIndex( - const SbSocketWaiterPrivate::WaiteeRegistry::LookupToken socket_index) { - SB_DCHECK(socket_index >= 0); - - SB_DCHECK(static_cast(socket_index) <= socket_events_.size()); - return waitees_[socket_index].get(); -} diff --git a/starboard/shared/win32/socket_waiter_internal.h b/starboard/shared/win32/socket_waiter_internal.h deleted file mode 100644 index bc3fa2903c66..000000000000 --- a/starboard/shared/win32/socket_waiter_internal.h +++ /dev/null @@ -1,213 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_SOCKET_WAITER_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_SOCKET_WAITER_INTERNAL_H_ - -#include -#include - -#include -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/optional.h" -#include "starboard/common/socket.h" -#include "starboard/shared/internal_only.h" -#include "starboard/shared/win32/auto_event_handle.h" -#include "starboard/shared/win32/socket_internal.h" -#include "starboard/socket_waiter.h" -#include "starboard/thread.h" -#include "starboard/types.h" - -namespace sbwin32 = starboard::shared::win32; - -#pragma warning(push) - -// SbSocketWaiterPrivate is defined as a struct, but for windows implementation -// enough functionality has been added so that it warrants being a class -// per Google's C++ style guide. This mismatch causes the Microsoft's compiler -// to generate a warning. -#pragma warning(disable : 4099) -class SbSocketWaiterPrivate { - public: - SbSocketWaiterPrivate(); - ~SbSocketWaiterPrivate(); - - // These methods implement the SbSocketWaiter API defined in socket_waiter.h. -#if SB_API_VERSION >= 16 - bool Add(int socket, - SbSocketWaiter waiter, - void* context, - SbPosixSocketWaiterCallback callback, - int interests, - bool persistent); - bool Remove(int socket, SbSocketWaiter waiter); - bool CheckSocketRegistered(int socket); -#endif // SB_API_VERSION >= 16 - bool Add(SbSocket socket, - void* context, - SbSocketWaiterCallback callback, - int interests, - bool persistent); - bool Remove(SbSocket socket); - - void Wait(); - SbSocketWaiterResult WaitTimed(int64_t duration_usec); - void WakeUp(); - void HandleWakeUpRead(); - bool CheckSocketRegistered(SbSocket socket); - - private: - // A registration of a socket with a socket waiter. - struct Waitee { -#if SB_API_VERSION >= 16 - Waitee(SbSocketWaiter waiter, - int socket, - sbwin32::AutoEventHandle* socket_event_ptr, - void* context, - SbPosixSocketWaiterCallback callback, - int interests, - bool persistent) - : waiter(waiter), - posix_socket(socket), - socket_event_ptr(socket_event_ptr), - context(context), - posix_callback(callback), - interests(interests), - persistent(persistent) { - use_posix_socket = 1; - } - // The socket registered with the waiter. - int posix_socket; - - // The callback to call when one or more registered interests become ready. - SbPosixSocketWaiterCallback posix_callback; - - // The event related to the socket_handle. Used for SbSocketWaiter. - sbwin32::AutoEventHandle* socket_event_ptr; -#endif // SB_API_VERSION >= 16 - Waitee(SbSocketWaiter waiter, - SbSocket socket, - void* context, - SbSocketWaiterCallback callback, - int interests, - bool persistent) - : waiter(waiter), - socket(socket), - context(context), - callback(callback), - interests(interests), - persistent(persistent) { - use_posix_socket = 0; - } - - int use_posix_socket; - - // The socket registered with the waiter. - SbSocket socket; - - // The callback to call when one or more registered interests become ready. - SbSocketWaiterCallback callback; - - // The waiter this event is registered with. - SbSocketWaiter waiter; - - // A context value that will be passed to the callback. - void* context; - - // The set of interests registered with the waiter. - int interests; - - // Whether this Waitee should stay registered after the next callback. - bool persistent; - }; - - class WaiteeRegistry { - public: - typedef int64_t LookupToken; - typedef std::deque> Waitees; -#if SB_API_VERSION >= 16 - typedef std::unordered_map posix_SocketToIndex; -#endif // SB_API_VERSION >= 16 - typedef std::unordered_map SocketToIndex; - - WSAEVENT* GetHandleArray() { return socket_events_.data(); } - std::size_t GetHandleArraySize() { return socket_events_.size(); } - const Waitees& GetWaitees() const { return waitees_; } - -#if SB_API_VERSION >= 16 - // Gets the Waitee associated with the given socket, or nullptr. - Waitee* GetWaitee(int socket); - - // Gets the index by socket - starboard::optional GetIndex(int socket); - - // Returns true if socket was found, and removed. - bool RemoveSocket(int socket); -#endif // SB_API_VERSION >= 16 - // Gets the Waitee associated with the given socket, or nullptr. - Waitee* GetWaitee(SbSocket socket); - - // Gets the index by socket - starboard::optional GetIndex(SbSocket socket); - - // Returns true if socket was found, and removed. - bool RemoveSocket(SbSocket socket); - - // Gets the Waitee by index. - Waitee* GetWaiteeByIndex(LookupToken socket_index); - - // Returns the index of the event. - LookupToken AddSocketEventAndWaitee(WSAEVENT socket_event, - std::unique_ptr waitee); - - private: -#if SB_API_VERSION >= 16 - posix_SocketToIndex posix_socket_to_index_map_; -#endif // SB_API_VERSION >= 16 - SocketToIndex socket_to_index_map_; - - std::vector socket_events_; - std::deque> waitees_; - }; - - void SignalWakeupEvent(); - void ResetWakeupEvent(); - -#if SB_API_VERSION >= 16 - bool CheckSocketWaiterIsThis(int socket, SbSocketWaiter waiter); -#endif // SB_API_VERSION >= 16 - bool CheckSocketWaiterIsThis(SbSocket socket); - - // The thread this waiter was created on. Immutable, so accessible from any - // thread. - const pthread_t thread_; - - // The registry of currently registered Waitees. - WaiteeRegistry waitees_; - WaiteeRegistry::LookupToken wakeup_event_token_; - - // This mutex covers the next two variables. - starboard::Mutex unhandled_wakeup_count_mutex_; - // Number of times wake up has been called, and not handled. - std::int32_t unhandled_wakeup_count_; - // The WSAEvent that is set by Wakeup(); - sbwin32::AutoEventHandle wakeup_event_; -}; -#pragma warning(pop) - -#endif // STARBOARD_SHARED_WIN32_SOCKET_WAITER_INTERNAL_H_ diff --git a/starboard/shared/win32/socket_waiter_remove.cc b/starboard/shared/win32/socket_waiter_remove.cc deleted file mode 100644 index 165921b76133..000000000000 --- a/starboard/shared/win32/socket_waiter_remove.cc +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -bool SbSocketWaiterRemove(SbSocketWaiter waiter, SbSocket socket) { - if (!SbSocketWaiterIsValid(waiter)) { - return false; - } - - return waiter->Remove(socket); -} - -#if SB_API_VERSION >= 16 -bool SbPosixSocketWaiterRemove(SbSocketWaiter waiter, int socket) { - if (!SbSocketWaiterIsValid(waiter)) { - return false; - } - - return waiter->Remove(socket, waiter); -} -#endif diff --git a/starboard/shared/win32/socket_waiter_wait.cc b/starboard/shared/win32/socket_waiter_wait.cc deleted file mode 100644 index c46052a993c6..000000000000 --- a/starboard/shared/win32/socket_waiter_wait.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -void SbSocketWaiterWait(SbSocketWaiter waiter) { - if (!SbSocketWaiterIsValid(waiter)) { - return; - } - - waiter->Wait(); -} diff --git a/starboard/shared/win32/socket_waiter_wait_timed.cc b/starboard/shared/win32/socket_waiter_wait_timed.cc deleted file mode 100644 index 25c266bdc2ce..000000000000 --- a/starboard/shared/win32/socket_waiter_wait_timed.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -SbSocketWaiterResult SbSocketWaiterWaitTimed(SbSocketWaiter waiter, - int64_t duration) { - if (!SbSocketWaiterIsValid(waiter)) { - return kSbSocketWaiterResultInvalid; - } - - return waiter->WaitTimed(duration); -} diff --git a/starboard/shared/win32/socket_waiter_wake_up.cc b/starboard/shared/win32/socket_waiter_wake_up.cc deleted file mode 100644 index 06c13cf18d3d..000000000000 --- a/starboard/shared/win32/socket_waiter_wake_up.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/socket_waiter.h" - -#include "starboard/shared/win32/socket_waiter_internal.h" - -void SbSocketWaiterWakeUp(SbSocketWaiter waiter) { - if (!SbSocketWaiterIsValid(waiter)) { - return; - } - - waiter->WakeUp(); -} diff --git a/starboard/shared/win32/starboard_main.cc b/starboard/shared/win32/starboard_main.cc deleted file mode 100644 index 372d797a982b..000000000000 --- a/starboard/shared/win32/starboard_main.cc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/starboard_main.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include "starboard/common/string.h" -#include "starboard/shared/starboard/audio_sink/audio_sink_internal.h" -#include "starboard/shared/starboard/command_line.h" -#include "starboard/shared/starboard/net_log.h" -#include "starboard/shared/win32/application_win32.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::starboard::CommandLine; -using starboard::shared::starboard::kNetLogCommandSwitchWait; -using starboard::shared::starboard::NetLogFlushThenClose; -using starboard::shared::starboard::NetLogWaitForClientConnected; -using starboard::shared::win32::ApplicationWin32; - -namespace { - -void WaitForNetLogIfNecessary(const CommandLine& cmd_line) { - if (cmd_line.HasSwitch(kNetLogCommandSwitchWait)) { - int64_t timeout_usec = 2'000'000; // 2 seconds. - std::string val = cmd_line.GetSwitchValue(kNetLogCommandSwitchWait); - if (!val.empty()) { - timeout_usec = atoi(val.c_str()); - } - NetLogWaitForClientConnected(timeout_usec); - } -} - -} // namespace. - -extern "C" int StarboardMain(int argc, char** argv) { - WSAData wsaData; - const int kWinSockVersionMajor = 2; - const int kWinSockVersionMinor = 2; - const int init_result = WSAStartup( - MAKEWORD(kWinSockVersionMajor, kWinSockVersionMajor), &wsaData); - - SB_CHECK(init_result == 0); - // WSAStartup returns the highest version that is supported up to the version - // we request. - SB_CHECK(LOBYTE(wsaData.wVersion) == kWinSockVersionMajor && - HIBYTE(wsaData.wVersion) == kWinSockVersionMinor); - - // Initialize COM for XAudio2 APIs. - CoInitialize(nullptr); - SbAudioSinkPrivate::Initialize(); - starboard::shared::win32::RegisterMainThread(); - // TODO: Do this with pthread_once when media is first used instead. - HRESULT hr = MFStartup(MF_VERSION); - SB_DCHECK(SUCCEEDED(hr)); - - WaitForNetLogIfNecessary(CommandLine(argc, argv)); -#if SB_API_VERSION >= 15 - return SbRunStarboardMain(argc, argv, SbEventHandle); -#else - ApplicationWin32 application; - // This will run the message loop. - const int main_return_value = application.Run(argc, argv); - NetLogFlushThenClose(); - - MFShutdown(); - WSACleanup(); - return main_return_value; -#endif // SB_API_VERSION >= 15 -} - -#if SB_API_VERSION >= 15 -int SbRunStarboardMain(int argc, char** argv, SbEventHandleCallback callback) { - ApplicationWin32 application(callback); - // This will run the message loop. - const int main_return_value = application.Run(argc, argv); - NetLogFlushThenClose(); - - MFShutdown(); - WSACleanup(); - return main_return_value; -} -#endif // SB_API_VERSION >= 15 diff --git a/starboard/shared/win32/starboard_main.h b/starboard/shared/win32/starboard_main.h deleted file mode 100644 index 60cff15a1a14..000000000000 --- a/starboard/shared/win32/starboard_main.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_STARBOARD_MAIN_H_ -#define STARBOARD_SHARED_WIN32_STARBOARD_MAIN_H_ - -#include "starboard/export.h" - -extern "C" SB_EXPORT_PLATFORM int StarboardMain(int argc, char** argv); - -#endif // STARBOARD_SHARED_WIN32_STARBOARD_MAIN_H_ diff --git a/starboard/shared/win32/storage_write_record.cc b/starboard/shared/win32/storage_write_record.cc deleted file mode 100644 index a83a955673c1..000000000000 --- a/starboard/shared/win32/storage_write_record.cc +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/storage.h" - -#include -#include -#include - -#include -#include - -#include "starboard/common/file.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/shared/starboard/file_storage/storage_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -const char kTempFileSuffix[] = ".temp"; - -bool SbStorageWriteRecord(SbStorageRecord record, - const char* data, - int64_t data_size) { - if (!SbStorageIsValidRecord(record) || !data || data_size < 0) { - return false; - } - - const char* name = record->name.c_str(); - std::vector original_file_path(kSbFileMaxPath); - if (!starboard::shared::starboard::GetStorageFilePath( - name, original_file_path.data(), kSbFileMaxPath)) { - return false; - } - - std::vector temp_file_path(kSbFileMaxPath + 1, 0); - starboard::strlcpy(temp_file_path.data(), original_file_path.data(), - kSbFileMaxPath); - starboard::strlcat(temp_file_path.data(), kTempFileSuffix, kSbFileMaxPath); - - int temp_file = open(temp_file_path.data(), O_CREAT | O_TRUNC | O_RDWR, - S_IRUSR | S_IWUSR); - if (!starboard::IsValid(temp_file)) { - return false; - } - - ftruncate(temp_file, 0); - - const char* source = data; - int64_t to_write = data_size; - while (to_write > 0) { - int to_write_max = - static_cast(std::min(to_write, static_cast(kSbInt32Max))); - int bytes_written = write(temp_file, source, to_write_max); - if (bytes_written < 0) { - close(temp_file); - unlink(temp_file_path.data()); - return false; - } - - source += bytes_written; - to_write -= bytes_written; - } - - fsync(temp_file); - - if (starboard::IsValid(record->file) && close(record->file)) { - return false; - } - - record->file = -1; - - if (close(temp_file)) { - return false; - } - - std::wstring original_path_wstring = - starboard::shared::win32::NormalizeWin32Path( - starboard::shared::win32::CStringToWString( - original_file_path.data())); - std::wstring temp_path_wstring = starboard::shared::win32::NormalizeWin32Path( - starboard::shared::win32::CStringToWString(temp_file_path.data())); - if (ReplaceFileW(original_path_wstring.c_str(), temp_path_wstring.c_str(), - NULL, 0, NULL, NULL) == 0) { - return false; - } - int new_record_file = - open(original_file_path.data(), O_RDWR, S_IRUSR | S_IWUSR); - record->file = new_record_file; - - return true; -} diff --git a/starboard/shared/win32/string_compare_no_case.cc b/starboard/shared/win32/string_compare_no_case.cc deleted file mode 100644 index 85862f19f9ab..000000000000 --- a/starboard/shared/win32/string_compare_no_case.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCase(const char* string1, const char* string2) { - return _stricmp(string1, string2); -} -#endif diff --git a/starboard/shared/win32/string_compare_no_case_n.cc b/starboard/shared/win32/string_compare_no_case_n.cc deleted file mode 100644 index 3ac38d73a953..000000000000 --- a/starboard/shared/win32/string_compare_no_case_n.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include - -#if SB_API_VERSION < 16 -int SbStringCompareNoCaseN(const char* string1, - const char* string2, - size_t count) { - return _strnicmp(string1, string2, count); -} -#endif diff --git a/starboard/shared/win32/string_format.cc b/starboard/shared/win32/string_format.cc deleted file mode 100644 index d4dd55b2892a..000000000000 --- a/starboard/shared/win32/string_format.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include - -int SbStringFormat(char* out_buffer, - size_t buffer_size, - const char* format, - va_list arguments) { - return vsnprintf(out_buffer, buffer_size, format, arguments); -} diff --git a/starboard/shared/win32/string_format_wide.cc b/starboard/shared/win32/string_format_wide.cc deleted file mode 100644 index 79e8479686b4..000000000000 --- a/starboard/shared/win32/string_format_wide.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/string.h" - -#include - -#if SB_API_VERSION < 16 -int SbStringFormatWide(wchar_t* out_buffer, - size_t buffer_size, - const wchar_t* format, - va_list arguments) { - return _vsnwprintf(out_buffer, buffer_size, format, arguments); -} -#endif diff --git a/starboard/shared/win32/system_break_into_debugger.cc b/starboard/shared/win32/system_break_into_debugger.cc deleted file mode 100644 index ba66e7074a97..000000000000 --- a/starboard/shared/win32/system_break_into_debugger.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -#include "starboard/shared/starboard/net_log.h" - -void SbSystemBreakIntoDebugger() { - // Note: neither DebugBreak() nor ExitProcess() are valid - // on some Windows platforms (eg UWP) so we use __debugbreak() - // instead. - starboard::shared::starboard::NetLogFlush(); - __debugbreak(); -} diff --git a/starboard/shared/win32/system_clear_last_error.cc b/starboard/shared/win32/system_clear_last_error.cc deleted file mode 100644 index 1105b3dae029..000000000000 --- a/starboard/shared/win32/system_clear_last_error.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -void SbSystemClearLastError() { - SetLastError(0); -} diff --git a/starboard/shared/win32/system_get_error_string.cc b/starboard/shared/win32/system_get_error_string.cc deleted file mode 100644 index b59e1aa7b456..000000000000 --- a/starboard/shared/win32/system_get_error_string.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -#include "starboard/common/string.h" -#include "starboard/shared/win32/error_utils.h" - -int SbSystemGetErrorString(SbSystemError error, - char* out_string, - int string_length) { - std::ostringstream out; - out << starboard::shared::win32::Win32ErrorCode(error); - if (out_string != nullptr) { - starboard::strlcpy(out_string, out.str().c_str(), string_length); - } - return static_cast(out.str().size()); -} diff --git a/starboard/shared/win32/system_get_extensions.cc b/starboard/shared/win32/system_get_extensions.cc deleted file mode 100644 index 09a5726bb0ad..000000000000 --- a/starboard/shared/win32/system_get_extensions.cc +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include "starboard/common/string.h" -#include "starboard/extension/configuration.h" -#include "starboard/extension/graphics.h" -#include "starboard/shared/win32/configuration.h" -#include "starboard/shared/win32/graphics.h" - -const void* SbSystemGetExtension(const char* name) { - if (strcmp(name, kCobaltExtensionGraphicsName) == 0) { - return starboard::shared::win32::GetGraphicsApi(); - } - if (strcmp(name, kCobaltExtensionConfigurationName) == 0) { - return starboard::shared::win32::GetConfigurationApi(); - } - return NULL; -} diff --git a/starboard/shared/win32/system_get_last_error.cc b/starboard/shared/win32/system_get_last_error.cc deleted file mode 100644 index f01b6aa8b923..000000000000 --- a/starboard/shared/win32/system_get_last_error.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -SbSystemError SbSystemGetLastError() { - return GetLastError(); -} diff --git a/starboard/shared/win32/system_get_locale_id.cc b/starboard/shared/win32/system_get_locale_id.cc deleted file mode 100644 index 417471994503..000000000000 --- a/starboard/shared/win32/system_get_locale_id.cc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -#include "starboard/common/log.h" -#include "starboard/common/once.h" - -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wchar_utils.h" - -using starboard::shared::win32::DebugLogWinError; -using starboard::shared::win32::wchar_tToUTF8; - -namespace { -class LocaleString { - public: - static LocaleString* Get(); - const char* value() const { return value_.c_str(); } - - private: - LocaleString() { - wchar_t name[LOCALE_NAME_MAX_LENGTH]; - int result = GetUserDefaultLocaleName(name, LOCALE_NAME_MAX_LENGTH); - if (result != 0) { - value_ = wchar_tToUTF8(name); - } else { - SB_LOG(ERROR) << "Error retrieving GetUserDefaultLocaleName"; - DebugLogWinError(); - value_ = "en-US"; - } - } - std::string value_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(LocaleString, LocaleString::Get); -} // namespace - -const char* SbSystemGetLocaleId() { - return LocaleString::Get()->value(); -} diff --git a/starboard/shared/win32/system_get_number_of_processors.cc b/starboard/shared/win32/system_get_number_of_processors.cc deleted file mode 100644 index b3b64869ca3d..000000000000 --- a/starboard/shared/win32/system_get_number_of_processors.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -int SbSystemGetNumberOfProcessors() { - // Note that this returns the number of logical processors. - SYSTEM_INFO system_info = {0}; - GetSystemInfo(&system_info); - return system_info.dwNumberOfProcessors; -} diff --git a/starboard/shared/win32/system_get_property.cc b/starboard/shared/win32/system_get_property.cc deleted file mode 100644 index 76eb1f05fcb9..000000000000 --- a/starboard/shared/win32/system_get_property.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/device_type.h" -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/shared/environment.h" -#include "starboard/system.h" - -namespace { - -const char* kFriendlyName = "Windows Desktop"; -const char* kPlatformName = "win32; Windows x86_64"; - -bool CopyStringAndTestIfSuccess(char* out_value, - int value_length, - const char* from_value) { - if (strlen(from_value) + 1 > value_length) - return false; - starboard::strlcpy(out_value, from_value, value_length); - return true; -} - -} // namespace - -bool SbSystemGetProperty(SbSystemPropertyId property_id, - char* out_value, - int value_length) { - if (!out_value || !value_length) { - return false; - } - - switch (property_id) { - case kSbSystemPropertyBrandName: - case kSbSystemPropertyChipsetModelNumber: - case kSbSystemPropertyFirmwareVersion: - case kSbSystemPropertyModelName: - case kSbSystemPropertyModelYear: - case kSbSystemPropertySystemIntegratorName: - case kSbSystemPropertySpeechApiKey: - return false; - - case kSbSystemPropertyFriendlyName: - return CopyStringAndTestIfSuccess(out_value, value_length, kFriendlyName); - - case kSbSystemPropertyPlatformName: - return CopyStringAndTestIfSuccess(out_value, value_length, kPlatformName); - - // Implementation provided for testing purposes only - case kSbSystemPropertyAdvertisingId: - return CopyStringAndTestIfSuccess( - out_value, value_length, - starboard::GetEnvironment("COBALT_ADVERTISING_ID").c_str()); - case kSbSystemPropertyLimitAdTracking: - return CopyStringAndTestIfSuccess( - out_value, value_length, - starboard::GetEnvironment("COBALT_LIMIT_AD_TRACKING").c_str()); - -#if SB_API_VERSION >= 15 - case kSbSystemPropertyDeviceType: - return CopyStringAndTestIfSuccess(out_value, value_length, - starboard::kSystemDeviceTypeDesktopPC); -#endif - - default: - SB_DLOG(WARNING) << __FUNCTION__ - << ": Unrecognized property: " << property_id; - break; - } - - return false; -} diff --git a/starboard/shared/win32/system_get_random_data.cc b/starboard/shared/win32/system_get_random_data.cc deleted file mode 100644 index 5bcb0ecba150..000000000000 --- a/starboard/shared/win32/system_get_random_data.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -// This must be included after windows.h -#include - -#include "starboard/common/log.h" -#include "starboard/shared/win32/error_utils.h" - -namespace sbwin32 = starboard::shared::win32; - -void SbSystemGetRandomData(void* out_buffer, int buffer_size) { - // Note: this might not be secure before Windows 10, as - // BCRYPT_RNG_DUAL_EC_ALGORITHM might be used. See: - // https://msdn.microsoft.com/en-us/library/windows/desktop/aa375534%28v=vs.85%29.aspx - // "Windows 10: Beginning with Windows 10, the dual elliptic curve random - // number generator algorithm has been removed. Existing uses of this - // algorithm will continue to work; however, the random number generator is - // based on the AES counter mode specified in the NIST SP 800-90 standard. New - // code should use BCRYPT_RNG_ALGORITHM, and it is recommended that existing - // code be changed to use BCRYPT_RNG_ALGORITHM." - NTSTATUS status = - BCryptGenRandom(nullptr, reinterpret_cast(out_buffer), - buffer_size, BCRYPT_USE_SYSTEM_PREFERRED_RNG); - SB_DCHECK(status == 0) << "Error while calling CryptGenRandom: " - << sbwin32::Win32ErrorCode(GetLastError()); -} diff --git a/starboard/shared/win32/system_get_random_uint64.cc b/starboard/shared/win32/system_get_random_uint64.cc deleted file mode 100644 index 159d472901c7..000000000000 --- a/starboard/shared/win32/system_get_random_uint64.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -uint64_t SbSystemGetRandomUInt64() { - uint64_t return_value = 0; - SbSystemGetRandomData(&return_value, sizeof(return_value)); - return return_value; -} diff --git a/starboard/shared/win32/system_get_stack.cc b/starboard/shared/win32/system_get_stack.cc deleted file mode 100644 index de30224f939b..000000000000 --- a/starboard/shared/win32/system_get_stack.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -__declspec(noinline) int SbSystemGetStack(void** out_stack, int stack_size) { - ULONG frames_to_skip = 1; - int num_captured = - CaptureStackBackTrace(frames_to_skip, stack_size, out_stack, nullptr); - return num_captured; -} diff --git a/starboard/shared/win32/system_get_total_cpu_memory.cc b/starboard/shared/win32/system_get_total_cpu_memory.cc deleted file mode 100644 index 6dd47801148e..000000000000 --- a/starboard/shared/win32/system_get_total_cpu_memory.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -int64_t SbSystemGetTotalCPUMemory() { - MEMORYSTATUSEX statex = {0}; - statex.dwLength = sizeof(statex); - GlobalMemoryStatusEx(&statex); - return static_cast(statex.ullTotalPhys); -} diff --git a/starboard/shared/win32/system_get_used_cpu_memory.cc b/starboard/shared/win32/system_get_used_cpu_memory.cc deleted file mode 100644 index 7376eafd0f24..000000000000 --- a/starboard/shared/win32/system_get_used_cpu_memory.cc +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -#include "starboard/common/log.h" - -int64_t SbSystemGetUsedCPUMemory() { - MEMORYSTATUSEX statex = {0}; - statex.dwLength = sizeof(statex); - GlobalMemoryStatusEx(&statex); - int64_t remaining_bytes = static_cast(statex.ullTotalPhys) - - static_cast(statex.ullAvailPhys); - SB_DCHECK(remaining_bytes >= 0); - return remaining_bytes; -} diff --git a/starboard/shared/win32/system_is_debugger_attached.cc b/starboard/shared/win32/system_is_debugger_attached.cc deleted file mode 100644 index 93403add5347..000000000000 --- a/starboard/shared/win32/system_is_debugger_attached.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include - -bool SbSystemIsDebuggerAttached() { - return IsDebuggerPresent(); -} diff --git a/starboard/shared/win32/system_raise_platform_error.cc b/starboard/shared/win32/system_raise_platform_error.cc deleted file mode 100644 index 2fa51dc351b8..000000000000 --- a/starboard/shared/win32/system_raise_platform_error.cc +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/application_win32.h" -#include "starboard/system.h" - -using starboard::shared::win32::ApplicationWin32; - -bool SbSystemRaisePlatformError(SbSystemPlatformErrorType type, - SbSystemPlatformErrorCallback callback, - void* user_data) { - return ApplicationWin32::Get()->OnSbSystemRaisePlatformError(type, callback, - user_data); -} diff --git a/starboard/shared/win32/system_symbolize.cc b/starboard/shared/win32/system_symbolize.cc deleted file mode 100644 index 52cc344fd02d..000000000000 --- a/starboard/shared/win32/system_symbolize.cc +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2018 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#ifndef COBALT_BUILD_TYPE_GOLD - -#include -#include - -// Must go before dbghelp.h -#include // NOLINT(build/include_order) -#include // NOLINT(build/include_order) - -#include "starboard/common/log.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/common/string.h" -#include "starboard/memory.h" - -namespace { - -typedef std::function SymbolResolverFunction; - -// Handles dynamically loading functions from dbghelp.dll used -// for symbol resolution. -SymbolResolverFunction CreateWin32SymbolResolver() { - SymbolResolverFunction null_function = [](const void*, std::string*) { - return false; - }; - - if (!::SymInitialize(GetCurrentProcess(), NULL, TRUE)) { - auto error = GetLastError(); - SB_LOG(WARNING) << "SymInitialize returned error : " << error << "\n"; - return null_function; - } - - ::SymSetOptions(SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS); - return [=](const void* address, std::string* destination) { - char sym_buf[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; - SYMBOL_INFO* symbol = reinterpret_cast(sym_buf); - symbol->SizeOfStruct = sizeof(SYMBOL_INFO); - symbol->MaxNameLen = MAX_SYM_NAME; - - DWORD64 offset = 0; - bool ok = - ::SymFromAddr(::GetCurrentProcess(), reinterpret_cast(address), - &offset, symbol); - - const char* name = symbol->Name; - if (name[0] == '_') { - name++; - } - *destination = name; - return ok; - }; -} - -class SymbolResolver { - public: - static SymbolResolver* Instance(); - - bool Resolve(const void* address, char* out_buffer, int buffer_size) { - std::string symbol; - - starboard::ScopedLock lock(mutex_); - if (resolver_(address, &symbol)) { - starboard::strlcpy(out_buffer, symbol.c_str(), buffer_size); - return true; - } else { - return false; - } - } - - private: - SymbolResolver() { resolver_ = CreateWin32SymbolResolver(); } - starboard::Mutex mutex_; - SymbolResolverFunction resolver_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(SymbolResolver, SymbolResolver::Instance); - -} // namespace - -bool SbSystemSymbolize(const void* address, char* out_buffer, int buffer_size) { - SymbolResolver* db = SymbolResolver::Instance(); - bool ok = db->Resolve(address, out_buffer, buffer_size); - return ok; -} - -#else // COBALT_BUILD_TYPE_GOLD - -bool SbSystemSymbolize(const void*, char*, int) { - return false; -} - -#endif diff --git a/starboard/shared/win32/test_filters.py b/starboard/shared/win32/test_filters.py deleted file mode 100644 index 81ef96333048..000000000000 --- a/starboard/shared/win32/test_filters.py +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard Win32 Platform Test Filters.""" - -from starboard.tools.testing import test_filter - -_FILTERED_TESTS = { - 'nplb': [ - # Windows uses a special time zone format that ICU accepts, so we don't - # enforce IANA. - # TODO(b/304335954): Re-enable the test for UWP after fixing DST - # implementation. - 'SbTimeZoneGetNameTest.IsIANAFormat', - 'PosixSocketResolveTest.SunnyDayFamily', - 'PosixSocketResolveTest.SunnyDayFlags', - ], - 'base_test': [ - # The `ProcessMetricsHelper` depends on the virtual files in /proc. - # This is limited to Linux platforms. - # See https://man7.org/linux/man-pages/man5/proc.5.html. - 'ProcessMetricsHelperTest.GetClockTicksPerS', - 'ProcessMetricsHelperTest.GetCumulativeCPUUsagePerThread', - ], -} - - -class TestFilters(object): - """Starboard Win32 platform test filters.""" - - def GetTestFilters(self): - """Gets all tests to be excluded from a unit test run. - - Returns: - A list of initialized TestFilter objects. - """ - filters = [] - for target, tests in _FILTERED_TESTS.items(): - filters.extend(test_filter.TestFilter(target, test) for test in tests) - return filters diff --git a/starboard/shared/win32/thread_create.cc b/starboard/shared/win32/thread_create.cc deleted file mode 100644 index 058452247a80..000000000000 --- a/starboard/shared/win32/thread_create.cc +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include -#include - -#include - -#include "starboard/common/log.h" -#include "starboard/common/once.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/thread_private.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace sbwin32 = starboard::shared::win32; - -using sbwin32::DebugLogWinError; -using sbwin32::GetThreadSubsystemSingleton; -using sbwin32::SbThreadPrivate; -using sbwin32::ThreadCreateInfo; -using sbwin32::ThreadGetLocalValue; -using sbwin32::ThreadSetLocalValue; -using sbwin32::ThreadSubsystemSingleton; -using sbwin32::wchar_tToUTF8; - -void ResetWinError() { - SetLastError(0); -} - -int RunThreadLocalDestructors(ThreadSubsystemSingleton* singleton) { - int num_destructors_called = 0; - - for (auto it = singleton->thread_local_keys_.begin(); - it != singleton->thread_local_keys_.end();) { - auto curr_it = it++; - - if (!curr_it->second->destructor) { - continue; - } - auto key = curr_it->second; - void* entry = ThreadGetLocalValue(reinterpret_cast(key)); - if (!entry) { - continue; - } - ThreadSetLocalValue(reinterpret_cast(key), nullptr); - ++num_destructors_called; - curr_it->second->destructor(entry); - } - return num_destructors_called; -} - -int CountTlsObjectsRemaining(ThreadSubsystemSingleton* singleton) { - int num_objects_remain = 0; - for (auto it = singleton->thread_local_keys_.begin(); - it != singleton->thread_local_keys_.end(); ++it) { - if (!it->second->destructor) { - continue; - } - auto key = it->second; - void* entry = ThreadGetLocalValue(reinterpret_cast(key)); - if (!entry) { - continue; - } - ++num_objects_remain; - } - return num_objects_remain; -} - -void CallThreadLocalDestructorsMultipleTimes() { - // The number of passes conforms to the base_unittests. This is useful for - // destructors that insert new objects into thread local storage. These - // objects then need to be destroyed as well in subsequent passes. The total - // number of passes is 4, which is one more than what base_unittest tests - // for. - const int kNumDestructorPasses = 4; - - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - int num_tls_objects_remaining = 0; - // TODO note that the implementation below holds a global lock - // while processing TLS destructors on thread exit. This could - // be a bottleneck in some scenarios. A lockless approach may be preferable. - pthread_mutex_lock(&singleton->mutex_); - - for (int i = 0; i < kNumDestructorPasses; ++i) { - // Run through each destructor and call it. - const int num_destructors_called = RunThreadLocalDestructors(singleton); - if (0 == num_destructors_called) { - break; // No more destructors to call. - } - } - num_tls_objects_remaining = CountTlsObjectsRemaining(singleton); - pthread_mutex_unlock(&singleton->mutex_); - - SB_DCHECK(num_tls_objects_remaining == 0) << "Dangling objects in TLS exist."; -} - -namespace { - -unsigned ThreadTrampoline(void* thread_create_info_context) { - std::unique_ptr info( - static_cast(thread_create_info_context)); - - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - ThreadSetLocalValue(singleton->thread_private_key_, &info->thread_private_); - pthread_setname_np(pthread_self(), info->name_.c_str()); - - void* result = info->entry_point_(info->user_context_); - - CallThreadLocalDestructorsMultipleTimes(); - - pthread_mutex_lock(&info->thread_private_.mutex_); - info->thread_private_.result_ = result; - info->thread_private_.result_is_valid_ = true; - pthread_cond_signal(&info->thread_private_.condition_); - while (info->thread_private_.wait_for_join_) { - pthread_cond_wait(&info->thread_private_.condition_, - &info->thread_private_.mutex_); - } - pthread_mutex_destroy(&info->thread_private_.mutex_); - - return 0; -} - -int SbThreadPriorityToWin32Priority(SbThreadPriority priority) { - switch (priority) { - case kSbThreadPriorityLowest: - return THREAD_PRIORITY_LOWEST; - case kSbThreadPriorityLow: - return THREAD_PRIORITY_BELOW_NORMAL; - case kSbThreadPriorityNormal: - case kSbThreadNoPriority: - return THREAD_PRIORITY_NORMAL; - case kSbThreadPriorityHigh: - return THREAD_PRIORITY_ABOVE_NORMAL; - case kSbThreadPriorityHighest: - return THREAD_PRIORITY_HIGHEST; - case kSbThreadPriorityRealTime: - return THREAD_PRIORITY_TIME_CRITICAL; - } - SB_NOTREACHED() << "Invalid priority " << priority; - return 0; -} - -SbThreadPriority Win32PriorityToSbThreadPriority(int priority) { - switch (priority) { - case THREAD_PRIORITY_LOWEST: - return kSbThreadPriorityLowest; - case THREAD_PRIORITY_BELOW_NORMAL: - return kSbThreadPriorityLow; - case THREAD_PRIORITY_NORMAL: - return kSbThreadPriorityNormal; - case THREAD_PRIORITY_ABOVE_NORMAL: - return kSbThreadPriorityHigh; - case THREAD_PRIORITY_HIGHEST: - return kSbThreadPriorityHighest; - case THREAD_PRIORITY_TIME_CRITICAL: - return kSbThreadPriorityRealTime; - } - SB_NOTREACHED() << "Invalid priority " << priority; - return kSbThreadPriorityNormal; -} -} // namespace - -#if SB_API_VERSION < 16 -// Note that SetThreadAffinityMask() is not available on some -// platforms (eg UWP). If it's necessary for a non-UWP platform, -// please fork this implementation for UWP. -SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context) { - if (entry_point == NULL) { - return kSbThreadInvalid; - } - ThreadCreateInfo* info = new ThreadCreateInfo(); - - info->entry_point_ = entry_point; - info->user_context_ = context; - info->thread_private_.wait_for_join_ = joinable; - if (name) { - info->name_ = name; - } - - // Create the thread suspended, and then resume once ThreadCreateInfo::handle_ - // has been set, so that it's always valid in the ThreadCreateInfo - // destructor. - uintptr_t handle = - _beginthreadex(NULL, static_cast(stack_size), - ThreadTrampoline, info, CREATE_SUSPENDED, NULL); - SB_DCHECK(handle); - info->thread_private_.handle_ = reinterpret_cast(handle); - ResetWinError(); - if (priority != kSbThreadNoPriority && - !SetThreadPriority(info->thread_private_.handle_, - SbThreadPriorityToWin32Priority(priority)) && - !GetLastError()) { - SB_LOG(ERROR) << "Failed to set priority for thread " << (name ? name : "") - << " to " << priority; - DebugLogWinError(); - } - - ResumeThread(info->thread_private_.handle_); - - return &info->thread_private_; -} -#endif // SB_API_VERSION < 16 - -bool SbThreadSetPriority(SbThreadPriority priority) { - return SetThreadPriority(GetCurrentThread(), - SbThreadPriorityToWin32Priority(priority)); -} - -bool SbThreadGetPriority(SbThreadPriority* priority) { - int res = GetThreadPriority(GetCurrentThread()); - *priority = Win32PriorityToSbThreadPriority(res); - return true; -} diff --git a/starboard/shared/win32/thread_create_local_key.cc b/starboard/shared/win32/thread_create_local_key.cc deleted file mode 100644 index 1b1b771fb3cd..000000000000 --- a/starboard/shared/win32/thread_create_local_key.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include - -#include "starboard/common/mutex.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetThreadSubsystemSingleton; -using starboard::shared::win32::ThreadSubsystemSingleton; - -namespace starboard { -namespace shared { -namespace win32 { - -SbThreadLocalKey SbThreadCreateLocalKeyInternal( - SbThreadLocalDestructor destructor, - ThreadSubsystemSingleton* singleton) { - // Note that destructor used here to allow destruction of objects created by - // TLS access by non-starboard threads. - // Note that FlsAlloc's destructor mechanism is insufficient to pass - // base_unittests, which expects that multiple destructor passes for - // objects which insert destructable TLS pointers as side effects. For - // starboard threads, the TLS destructors will run first and set the - // TLS pointers to null, then the destructors will run a second time - // but this is okay since the pointers will now be nullptrs, which is - // a no-op. For non starboard threads, only the secondary destructor - // will run. - DWORD index = TlsInternalAlloc(destructor); - - if (index == TLS_OUT_OF_INDEXES) { - return kSbThreadLocalKeyInvalid; - } - - SbThreadLocalKeyPrivate* result = static_cast( - malloc(sizeof(SbThreadLocalKeyPrivate))); - - if (result == nullptr) { - return kSbThreadLocalKeyInvalid; - } - - result->tls_index = index; - result->destructor = destructor; - - pthread_mutex_lock(&singleton->mutex_); - singleton->thread_local_keys_.insert(std::make_pair(index, result)); - pthread_mutex_unlock(&singleton->mutex_); - return result; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard - -SbThreadLocalKey SbThreadCreateLocalKey(SbThreadLocalDestructor destructor) { - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - return SbThreadCreateLocalKeyInternal(destructor, singleton); -} diff --git a/starboard/shared/win32/thread_destroy_local_key.cc b/starboard/shared/win32/thread_destroy_local_key.cc deleted file mode 100644 index d03267928199..000000000000 --- a/starboard/shared/win32/thread_destroy_local_key.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/memory.h" -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetThreadSubsystemSingleton; -using starboard::shared::win32::ThreadSubsystemSingleton; -using starboard::shared::win32::TlsInternalFree; - -void SbThreadDestroyLocalKey(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return; - } - // To match pthreads, the thread local pointer for the key is set to null - // so that a supplied destructor doesn't run. - SbThreadSetLocalValue(key, nullptr); - DWORD tls_index = static_cast(key)->tls_index; - ThreadSubsystemSingleton* singleton = GetThreadSubsystemSingleton(); - - SbMutexAcquire(&singleton->mutex_); - singleton->thread_local_keys_.erase(tls_index); - SbMutexRelease(&singleton->mutex_); - - TlsInternalFree(tls_index); - free(key); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_detach.cc b/starboard/shared/win32/thread_detach.cc deleted file mode 100644 index 1dfff6d24c50..000000000000 --- a/starboard/shared/win32/thread_detach.cc +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::SbThreadPrivate; - -void SbThreadDetach(SbThread thread) { - if (thread == kSbThreadInvalid) { - return; - } - SbThreadPrivate* thread_private = static_cast(thread); - - SbMutexAcquire(&thread_private->mutex_); - thread_private->wait_for_join_ = false; - SbConditionVariableSignal(&thread_private->condition_); - SbMutexRelease(&thread_private->mutex_); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_get_current.cc b/starboard/shared/win32/thread_get_current.cc deleted file mode 100644 index b3dc47319993..000000000000 --- a/starboard/shared/win32/thread_get_current.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetCurrentSbThreadPrivate; -using starboard::shared::win32::SbThreadPrivate; - -SbThread SbThreadGetCurrent() { - return GetCurrentSbThreadPrivate(); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_get_id.cc b/starboard/shared/win32/thread_get_id.cc deleted file mode 100644 index 6580ba1a849a..000000000000 --- a/starboard/shared/win32/thread_get_id.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include - -SbThreadId SbThreadGetId() { - return GetCurrentThreadId(); -} diff --git a/starboard/shared/win32/thread_get_local_value.cc b/starboard/shared/win32/thread_get_local_value.cc deleted file mode 100644 index 4bffe5b802c4..000000000000 --- a/starboard/shared/win32/thread_get_local_value.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::TlsInternalGetValue; - -void* SbThreadGetLocalValue(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return NULL; - } - DWORD tls_index = static_cast(key)->tls_index; - return TlsInternalGetValue(tls_index); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_get_name.cc b/starboard/shared/win32/thread_get_name.cc deleted file mode 100644 index 80d784a14c72..000000000000 --- a/starboard/shared/win32/thread_get_name.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/common/string.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetCurrentSbThreadPrivate; -using starboard::shared::win32::SbThreadPrivate; - -void SbThreadGetName(char* buffer, int buffer_size) { - SbThreadPrivate* thread_private = GetCurrentSbThreadPrivate(); - starboard::strlcpy(buffer, thread_private->name_.c_str(), buffer_size); -} - -#endif diff --git a/starboard/shared/win32/thread_is_equal.cc b/starboard/shared/win32/thread_is_equal.cc deleted file mode 100644 index ae7ae9a7d2b1..000000000000 --- a/starboard/shared/win32/thread_is_equal.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -bool SbThreadIsEqual(SbThread thread1, SbThread thread2) { - return thread1 == thread2; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_join.cc b/starboard/shared/win32/thread_join.cc deleted file mode 100644 index 4fd30c911df4..000000000000 --- a/starboard/shared/win32/thread_join.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::SbThreadPrivate; - -bool SbThreadJoin(SbThread thread, void** out_return) { - if (thread == kSbThreadInvalid) { - return false; - } - - SbThreadPrivate* thread_private = static_cast(thread); - - SbMutexAcquire(&thread_private->mutex_); - if (!thread_private->wait_for_join_) { - // Thread has already been detached. - SbMutexRelease(&thread_private->mutex_); - return false; - } - while (!thread_private->result_is_valid_) { - SbConditionVariableWait(&thread_private->condition_, - &thread_private->mutex_); - } - thread_private->wait_for_join_ = false; - SbConditionVariableSignal(&thread_private->condition_); - if (out_return != NULL) { - *out_return = thread_private->result_; - } - SbMutexRelease(&thread_private->mutex_); - return true; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_local_internal.cc b/starboard/shared/win32/thread_local_internal.cc deleted file mode 100644 index a77106439bff..000000000000 --- a/starboard/shared/win32/thread_local_internal.cc +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/thread_local_internal.h" - -#include - -namespace starboard { -namespace shared { -namespace win32 { - -// FlsAlloc() is like TlsAlloc(), but allows destructors. -// The downside is that FlsAlloc() has a small upper limit of -// about ~100 available keys. To provide extra keys, TlsAlloc() -// is used whenever a destructor is not necessary. -DWORD TlsInternalAlloc(SbThreadLocalDestructor destructor_fn) { - DWORD output = 0; - if (destructor_fn) { - output = FlsAlloc(destructor_fn); - } else { - output = TlsAlloc(); - } - if (output == TLS_OUT_OF_INDEXES) { - return TLS_OUT_OF_INDEXES; - } - return (output << 1) | (destructor_fn ? 0x1 : 0x0); -} - -void TlsInternalFree(DWORD key) { - bool has_destructor = key & 0x1; - DWORD index = key >> 1; - if (has_destructor) { - FlsFree(index); - } else { - TlsFree(index); - } -} - -void* TlsInternalGetValue(DWORD key) { - bool has_destructor = key & 0x1; - DWORD index = key >> 1; - if (has_destructor) { - return FlsGetValue(index); - } else { - return TlsGetValue(index); - } -} - -bool TlsInternalSetValue(DWORD key, void* value) { - bool has_destructor = key & 0x1; - DWORD index = key >> 1; - if (has_destructor) { - return FlsSetValue(index, value); - } else { - return TlsSetValue(index, value); - } -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/thread_local_internal.h b/starboard/shared/win32/thread_local_internal.h deleted file mode 100644 index 27e4794707d9..000000000000 --- a/starboard/shared/win32/thread_local_internal.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_THREAD_LOCAL_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_THREAD_LOCAL_INTERNAL_H_ - -#include - -#include "starboard/shared/win32/thread_private.h" -#include "starboard/thread.h" - -namespace starboard { -namespace shared { -namespace win32 { - -DWORD TlsInternalAlloc(SbThreadLocalDestructor destructor_fn); -void TlsInternalFree(DWORD key); - -void* TlsInternalGetValue(DWORD key); -bool TlsInternalSetValue(DWORD key, void* value); - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_THREAD_LOCAL_INTERNAL_H_ diff --git a/starboard/shared/win32/thread_private.cc b/starboard/shared/win32/thread_private.cc deleted file mode 100644 index d537477be8f4..000000000000 --- a/starboard/shared/win32/thread_private.cc +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/once.h" -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetThreadSubsystemSingleton; -using starboard::shared::win32::SbThreadPrivate; -using starboard::shared::win32::ThreadSubsystemSingleton; -using starboard::shared::win32::TlsInternalSetValue; - -namespace starboard { -namespace shared { -namespace win32 { - -SB_ONCE_INITIALIZE_FUNCTION(ThreadSubsystemSingleton, - GetThreadSubsystemSingleton); - -bool ThreadSetLocalValue(SbThreadLocalKey key, void* value) { - if (!SbThreadIsValidLocalKey(key)) { - return false; - } - DWORD tls_index = reinterpret_cast(key)->tls_index; - return TlsInternalSetValue(tls_index, value); -} - -void* ThreadGetLocalValue(SbThreadLocalKey key) { - if (!SbThreadIsValidLocalKey(key)) { - return nullptr; - } - DWORD tls_index = reinterpret_cast(key)->tls_index; - return TlsInternalGetValue(tls_index); -} - -void RegisterMainThread() { - std::unique_ptr thread_private(new SbThreadPrivate()); - - // GetCurrentThread() returns a pseudo-handle that must be duplicated - // to be used in general cases. - HANDLE pseudo_handle = GetCurrentThread(); - HANDLE handle; - BOOL success = - DuplicateHandle(GetCurrentProcess(), pseudo_handle, GetCurrentProcess(), - &handle, 0, false, DUPLICATE_SAME_ACCESS); - SB_DCHECK(success) << "DuplicateHandle failed"; - - thread_private->handle_ = handle; - thread_private->wait_for_join_ = false; - - ThreadSetLocalValue(GetThreadSubsystemSingleton()->thread_private_key_, - thread_private.release()); -} - -SbThreadPrivate* GetCurrentSbThreadPrivate() { - SbThreadPrivate* sb_thread_private = static_cast( - ThreadGetLocalValue(GetThreadSubsystemSingleton()->thread_private_key_)); - if (sb_thread_private == nullptr) { - // We are likely on a thread we did not create, so TLS needs to be setup. - RegisterMainThread(); - sb_thread_private = static_cast(ThreadGetLocalValue( - GetThreadSubsystemSingleton()->thread_private_key_)); - // TODO: Clean up TLS storage for threads we do not create. - } - return sb_thread_private; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/thread_private.h b/starboard/shared/win32/thread_private.h deleted file mode 100644 index 4f14d05e9825..000000000000 --- a/starboard/shared/win32/thread_private.h +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_THREAD_PRIVATE_H_ -#define STARBOARD_SHARED_WIN32_THREAD_PRIVATE_H_ - -#include - -#include -#include - -#include "starboard/common/condition_variable.h" -#include "starboard/common/mutex.h" -#include "starboard/common/once.h" -#include "starboard/shared/internal_only.h" -#include "starboard/thread.h" - -#define kSbThreadLocalKeyInvalid (SbThreadLocalKey) NULL - -typedef void (*SbThreadLocalDestructor)(void* value); - -struct SbThreadLocalKeyPrivate { - DWORD tls_index; - SbThreadLocalDestructor destructor; -}; - -typedef SbThreadLocalKeyPrivate* SbThreadLocalKey; - -static inline bool SbThreadIsValidLocalKey(SbThreadLocalKey key) { - return key != kSbThreadLocalKeyInvalid; -} - -namespace starboard { -namespace shared { -namespace win32 { - -class ThreadSubsystemSingleton; - -SbThreadLocalKey ThreadCreateLocalKey(SbThreadLocalDestructor destructor); -void ThreadDestroyLocalKey(SbThreadLocalKey key); -void* ThreadGetLocalValue(SbThreadLocalKey key); -bool ThreadSetLocalValue(SbThreadLocalKey key, void* value); - -// Creates a SbThreadLocalKey given a ThreadSubsystemSingleton. Used -// to create the first SbThreadLocalKey. -SbThreadLocalKey SbThreadCreateLocalKeyInternal( - SbThreadLocalDestructor destructor, - ThreadSubsystemSingleton* singleton); - -// Singleton state for the thread subsystem. -class ThreadSubsystemSingleton { - public: - ThreadSubsystemSingleton() - : mutex_(PTHREAD_MUTEX_INITIALIZER), - thread_private_key_(SbThreadCreateLocalKeyInternal(NULL, this)) {} - // This mutex protects all class members - pthread_mutex_t mutex_; - // Allocated thread_local_keys. Note that std::map is used - // so that elements can be deleted without triggering an allocation. - std::map thread_local_keys_; - // Thread-local key for the thread's SbThreadPrivate - SbThreadLocalKey thread_private_key_; -}; - -// Obtains the ThreadsSubsystemSingleton(); -ThreadSubsystemSingleton* GetThreadSubsystemSingleton(); - -// Registers the main thread. setting it's SbThreadPrivate* -void RegisterMainThread(); - -// Private thread state, stored in thread local storage and -// cleaned up when thread exits. -class SbThreadPrivate { - public: - SbThreadPrivate() - : mutex_(PTHREAD_MUTEX_INITIALIZER), - condition_(PTHREAD_COND_INITIALIZER), - handle_(NULL), - result_(NULL), - wait_for_join_(false), - result_is_valid_(false) {} - - ~SbThreadPrivate() { - if (handle_) { - CloseHandle(handle_); - } - - pthread_mutex_destroy(&mutex_); - pthread_cond_destroy(&condition_); - } - - // This mutex protects all class members - pthread_mutex_t mutex_; - pthread_cond_t condition_; - std::string name_; - HANDLE handle_; - // The result of the thread. The return value of SbThreadEntryPoint - // to return to SbThreadJoin. - void* result_; - // True if a thread must wait to be joined before completely exiting. - // Changes to this must signal |condition_|. - bool wait_for_join_; - // True if |result_| is valid (the thread has completed and is waiting - // to exit). Changes to this must signal |condition_|. - bool result_is_valid_; -}; - -// Obtains the current thread's SbThreadPrivate* from thread-local storage. -SbThreadPrivate* GetCurrentSbThreadPrivate(); - -typedef void* (*SbThreadEntryPoint)(void* context); - -class ThreadCreateInfo { - public: - SbThreadPrivate thread_private_; - SbThreadEntryPoint entry_point_; - void* user_context_; - std::string name_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_THREAD_PRIVATE_H_ diff --git a/starboard/shared/win32/thread_set_local_value.cc b/starboard/shared/win32/thread_set_local_value.cc deleted file mode 100644 index e69e198adbaf..000000000000 --- a/starboard/shared/win32/thread_set_local_value.cc +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/win32/thread_local_internal.h" -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::TlsInternalSetValue; - -bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value) { - if (!SbThreadIsValidLocalKey(key)) { - return false; - } - DWORD tls_index = static_cast(key)->tls_index; - return TlsInternalSetValue(tls_index, value); -} -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/thread_set_name.cc b/starboard/shared/win32/thread_set_name.cc deleted file mode 100644 index 6eec1a147fa6..000000000000 --- a/starboard/shared/win32/thread_set_name.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/win32/thread_private.h" - -using starboard::shared::win32::GetCurrentSbThreadPrivate; -using starboard::shared::win32::SbThreadPrivate; - -namespace { - -// The code below is from -// https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx -// A |dwThreadID| of -1 means "current thread"; -// -// Usage: SetThreadName ((DWORD)-1, "MainThread"); -// -const DWORD MS_VC_EXCEPTION = 0x406D1388; -#pragma pack(push, 8) -typedef struct tagTHREADNAME_INF { - DWORD dwType; // Must be 0x1000. - LPCSTR szName; // Pointer to name (in user addr space). - DWORD dwThreadID; // Thread ID (-1=caller thread). - DWORD dwFlags; // Reserved for future use, must be zero. -} THREADNAME_INFO; -#pragma pack(pop) -void SetThreadName(DWORD dwThreadID, const char* threadName) { - THREADNAME_INFO info; - info.dwType = 0x1000; - info.szName = threadName; - info.dwThreadID = dwThreadID; - info.dwFlags = 0; -#pragma warning(push) -#pragma warning(disable : 6320 6322) - __try { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), - reinterpret_cast(&info)); - } __except (EXCEPTION_EXECUTE_HANDLER) { // NOLINT(whitespace/parens) - } -#pragma warning(pop) -} - -} // namespace - -void SbThreadSetName(const char* name) { - SbThreadPrivate* thread_private = GetCurrentSbThreadPrivate(); - - // We store the thread name in our own TLS context as well as telling - // the OS because it's much easier to retrieve from our own TLS context. - thread_private->name_ = name; - SetThreadName(static_cast(-1), name); -} - -#endif diff --git a/starboard/shared/win32/thread_sleep.cc b/starboard/shared/win32/thread_sleep.cc deleted file mode 100644 index 1e19a368e072..000000000000 --- a/starboard/shared/win32/thread_sleep.cc +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include - -#include "starboard/shared/win32/time_utils.h" - -using starboard::shared::win32::ConvertUsecToMillisRoundUp; - -void SbThreadSleep(int64_t duration) { - if (duration < 0) { - return; - } - Sleep(ConvertUsecToMillisRoundUp(duration)); -} diff --git a/starboard/shared/win32/thread_yield.cc b/starboard/shared/win32/thread_yield.cc deleted file mode 100644 index 98eb8cf2f3ca..000000000000 --- a/starboard/shared/win32/thread_yield.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/thread.h" - -#include - -void SbThreadYield() { - Sleep(0); -} diff --git a/starboard/shared/win32/time_get_monotonic_now.cc b/starboard/shared/win32/time_get_monotonic_now.cc deleted file mode 100644 index 6cc71b3dd9d9..000000000000 --- a/starboard/shared/win32/time_get_monotonic_now.cc +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -#include "starboard/common/log.h" - -SbTimeMonotonic SbTimeGetMonotonicNow() { - LARGE_INTEGER counts; - bool success; - - success = QueryPerformanceCounter(&counts); - - // "On systems that run Windows XP or later, - // the function will always succeed and will thus never return zero." - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx - SB_DCHECK(success); - - LARGE_INTEGER countsPerSecond; - success = QueryPerformanceFrequency(&countsPerSecond); - // "On systems that run Windows XP or later, - // the function will always succeed and will thus never return zero." - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx - SB_DCHECK(success); - - // An observed value of countsPerSecond on a desktop x86 machine is - // ~2.5e6. With this frequency, it will take ~37500 days to exceed - // 2^53, which is the mantissa precision of a double. - // Hence, we can safely convert to a double here without losing precision. - double result = static_cast(counts.QuadPart); - result *= (1000.0 * 1000.0) / countsPerSecond.QuadPart; - - return static_cast(result); -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/time_get_now.cc b/starboard/shared/win32/time_get_now.cc deleted file mode 100644 index a9ab54efb2b8..000000000000 --- a/starboard/shared/win32/time_get_now.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include "starboard/time.h" - -#include - -SbTime SbTimeGetNow() { - SYSTEMTIME system_time; - GetSystemTime(&system_time); - - FILETIME file_time; - SystemTimeToFileTime(&system_time, &file_time); - - ULARGE_INTEGER large_int; - large_int.LowPart = file_time.dwLowDateTime; - large_int.HighPart = file_time.dwHighDateTime; - return static_cast(large_int.QuadPart) / 10; -} - -#endif // SB_API_VERSION < 16 diff --git a/starboard/shared/win32/time_utils.h b/starboard/shared/win32/time_utils.h deleted file mode 100644 index 584fcfbd3979..000000000000 --- a/starboard/shared/win32/time_utils.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_TIME_UTILS_H_ -#define STARBOARD_SHARED_WIN32_TIME_UTILS_H_ - -#include "starboard/common/log.h" - -namespace starboard { -namespace shared { -namespace win32 { - -inline int64_t ConvertFileTimeTicksToUsec(const LARGE_INTEGER ticks) { - // According to - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284(v=vs.85).aspx - // FILETIME format is "Contains a 64-bit value representing the number of - // 100-nanosecond intervals since January 1, 1601 (UTC)" - const uint64_t kNumber100nanosecondTicksInMicrosecond = 10; - return ticks.QuadPart / kNumber100nanosecondTicksInMicrosecond; -} - -inline int64_t ConvertFileTimeToUsec(const FILETIME file_time) { - // According to - // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724284(v=vs.85).aspx - // FILETIME format is "Contains a 64-bit value representing the number of - // 100-nanosecond intervals since January 1, 1601 (UTC)" - LARGE_INTEGER ticks; - ticks.QuadPart = (static_cast(file_time.dwHighDateTime) << 32) | - file_time.dwLowDateTime; - return ConvertFileTimeTicksToUsec(ticks); -} - -// Many Win32 calls take millis, but Starboard uses microseconds. -// Many nplb tests assume waits are at least as long as requested, so -// round up. -inline DWORD ConvertUsecToMillisRoundUp(int64_t duration_usec) { - const int64_t milliseconds_to_sleep = (duration_usec + 1000 - 1) / 1000; - return static_cast(milliseconds_to_sleep); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_TIME_UTILS_H_ diff --git a/starboard/shared/win32/time_zone_get_current.cc b/starboard/shared/win32/time_zone_get_current.cc deleted file mode 100644 index e8d8c3268dbc..000000000000 --- a/starboard/shared/win32/time_zone_get_current.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/time_zone.h" - -#include - -#include "starboard/common/log.h" -SbTimeZone SbTimeZoneGetCurrent() { - DYNAMIC_TIME_ZONE_INFORMATION time_zone_info; - - DWORD zone_id = GetDynamicTimeZoneInformation(&time_zone_info); - - switch (zone_id) { - case TIME_ZONE_ID_UNKNOWN: - return time_zone_info.Bias; - case TIME_ZONE_ID_STANDARD: - return time_zone_info.Bias + time_zone_info.StandardBias; - case TIME_ZONE_ID_DAYLIGHT: - return time_zone_info.Bias + time_zone_info.DaylightBias; - default: - SB_NOTREACHED(); - return 0; - } -} diff --git a/starboard/shared/win32/time_zone_get_name.cc b/starboard/shared/win32/time_zone_get_name.cc deleted file mode 100644 index 7db27c5f85e9..000000000000 --- a/starboard/shared/win32/time_zone_get_name.cc +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/time_zone.h" - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/once.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { -class TimeZoneString { - public: - static TimeZoneString* Get(); - const char* value() const { return value_.c_str(); } - - private: - // Returns a string representing a time zone name, e.g. "EST" for Eastern - // Standard Time or "PDT" for Pacific Daylight Time. There isn't a native way - // to convert these to IANA name format on Windows without UWP, so we're - // making use of GetDynamicTimeZoneInformation for now. - TimeZoneString() { - DYNAMIC_TIME_ZONE_INFORMATION time_zone_info; - DWORD zone_id = GetDynamicTimeZoneInformation(&time_zone_info); - - std::wstring wide_string; - switch (zone_id) { - case TIME_ZONE_ID_UNKNOWN: - case TIME_ZONE_ID_STANDARD: - wide_string = time_zone_info.StandardName; - break; - case TIME_ZONE_ID_DAYLIGHT: - wide_string = time_zone_info.DaylightName; - break; - default: - SB_NOTREACHED(); - } - value_ = starboard::shared::win32::wchar_tToUTF8(wide_string.c_str()); - } - std::string value_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(TimeZoneString, TimeZoneString::Get); -} // namespace. - -const char* SbTimeZoneGetName() { - const char* output = TimeZoneString::Get()->value(); - return output; -} diff --git a/starboard/shared/win32/types_internal.h b/starboard/shared/win32/types_internal.h deleted file mode 100644 index fcc10c88d41a..000000000000 --- a/starboard/shared/win32/types_internal.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Defines the pthread versions of Starboard synchronization primitives and the -// static initializers for those primitives. - -#ifndef STARBOARD_SHARED_WIN32_TYPES_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_TYPES_INTERNAL_H_ - -#define SB_WIN32_INTERNAL_MUTEX(mutex_ptr) \ - reinterpret_cast((mutex_ptr)->mutex_buffer) -#define SB_WIN32_INTERNAL_CONDITION(condition_ptr) \ - reinterpret_cast((condition_ptr)->condition_buffer) -#define SB_WIN32_INTERNAL_ONCE(once_ptr) \ - reinterpret_cast((once_ptr)->once_buffer) -#else -#define SB_WIN32_INTERNAL_MUTEX(mutex_ptr) reinterpret_cast(mutex_ptr) -#define SB_WIN32_INTERNAL_CONDITION(condition_ptr) \ - reinterpret_cast(condition_ptr) -#define SB_WIN32_INTERNAL_ONCE(once_ptr) reinterpret_cast(once_ptr) - -#endif // STARBOARD_SHARED_WIN32_TYPES_INTERNAL_H_ diff --git a/starboard/shared/win32/video_decoder.cc b/starboard/shared/win32/video_decoder.cc deleted file mode 100644 index ac7dc8133deb..000000000000 --- a/starboard/shared/win32/video_decoder.cc +++ /dev/null @@ -1,797 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/video_decoder.h" - -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/shared/pthread/thread_create_priority.h" -#include "starboard/shared/win32/dx_context_video_decoder.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/hardware_decode_target_internal.h" - -// Include this after all other headers to avoid introducing redundant -// definitions from other header files. -// For CODECAPI_* -#include // NOLINT(build/include_order) -// For DXVA_ModeVP9_VLD_Profile0 -#include // NOLINT(build/include_order) - -namespace starboard { -namespace shared { -namespace win32 { - -namespace { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::starboard::player::filter::VideoFrame; -using std::placeholders::_1; -using std::placeholders::_2; - -// Limit the number of active output samples to control memory usage. -// NOTE: Higher numbers may result in increased dropped frames when the video -// resolution changes during playback (if the decoder is not forced to use -// max resolution resources). -const int kMaxOutputSamples = 10; - -// Throttle the number of queued inputs to control memory usage. -const int kMaxInputSamples = 15; - -// Prime the VP9 decoder for a certain number of output frames to reduce -// hitching at the start of playback. -const int kVp9PrimingFrameCount = 10; - -// Decode targets are cached for reuse. Ensure the cache size is large enough -// to accommodate the depth of the presentation swap chain, otherwise the -// video textures may be updated before or while they are actually rendered. -const int kDecodeTargetCacheSize = 2; - -// Allocate decode targets at the maximum size to allow them to be reused for -// all resolutions. This minimizes hitching during resolution changes. -#ifdef ENABLE_VP9_8K_SUPPORT -const int kMaxDecodeTargetWidth = 7680; -const int kMaxDecodeTargetHeight = 4320; -#else // ENABLE_VP9_8K_SUPPORT -const int kMaxDecodeTargetWidth = 3840; -const int kMaxDecodeTargetHeight = 2160; -#endif // ENABLE_VP9_8K_SUPPOR - -DEFINE_GUID(DXVA_ModeVP9_VLD_Profile0, - 0x463707f8, - 0xa1d0, - 0x4585, - 0x87, - 0x6d, - 0x83, - 0xaa, - 0x6d, - 0x60, - 0xb8, - 0x9e); - -DEFINE_GUID(DXVA_ModeVP9_VLD_10bit_Profile2, - 0xa4c749ef, - 0x6ecf, - 0x48aa, - 0x84, - 0x48, - 0x50, - 0xa7, - 0xa1, - 0x16, - 0x5f, - 0xf7); - -std::unique_ptr CreateVideoTransform( - const GUID& decoder_guid, - const GUID& input_guid, - const GUID& output_guid, - const IMFDXGIDeviceManager* device_manager) { - std::unique_ptr media_transform( - new MediaTransform(decoder_guid)); - if (!media_transform->HasValidTransform()) { - // Decoder Transform setup failed - return std::unique_ptr(); - } - media_transform->EnableInputThrottle(true); - - ComPtr attributes = media_transform->GetAttributes(); - if (!attributes) { - // Decoder Transform setup failed - return std::unique_ptr(); - } - - UINT32 is_d3d_aware_attribute = false; - HRESULT hr = attributes->GetUINT32(MF_SA_D3D_AWARE, &is_d3d_aware_attribute); - if (SUCCEEDED(hr) && is_d3d_aware_attribute) { - // Ignore the return value, an error is expected when running in Session 0. - hr = media_transform->SendMessage(MFT_MESSAGE_SET_D3D_MANAGER, - ULONG_PTR(device_manager)); - if (FAILED(hr)) { - SB_LOG(WARNING) << "Unable to set device manager for d3d aware decoder, " - "disabling DXVA."; - hr = attributes->SetUINT32(CODECAPI_AVDecVideoAcceleration_H264, FALSE); - if (FAILED(hr)) { - SB_LOG(WARNING) << "Unable to disable DXVA."; - return std::unique_ptr(); - } - } else { - hr = attributes->SetUINT32(CODECAPI_AVDecVideoAcceleration_H264, TRUE); - if (FAILED(hr)) { - SB_LOG(INFO) << "Unable to enable DXVA for video decoder."; - } - } - } else { - SB_LOG(WARNING) << "Video decoder is not D3D aware, decoding may be slow."; - } - - // Tell the decoder to allocate resources for the maximum resolution in - // order to minimize glitching on resolution changes. - if (FAILED(attributes->SetUINT32(MF_MT_DECODER_USE_MAX_RESOLUTION, 1))) { - return std::unique_ptr(); - } - - ComPtr input_type; - if (FAILED(MFCreateMediaType(&input_type)) || !input_type) { - return std::unique_ptr(); - } - CheckResult(input_type->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video)); - CheckResult(input_type->SetGUID(MF_MT_SUBTYPE, input_guid)); - CheckResult(input_type->SetUINT32(MF_MT_INTERLACE_MODE, - MFVideoInterlace_Progressive)); - if (input_guid == MFVideoFormat_VP90 || input_guid == MFVideoFormat_AV1) { - // Set the expected video resolution. Setting the proper resolution can - // mitigate a format change, but the decoder will adjust to the real - // resolution regardless. - CheckResult(MFSetAttributeSize(input_type.Get(), MF_MT_FRAME_SIZE, - kMaxDecodeTargetWidth, - kMaxDecodeTargetHeight)); - } - media_transform->SetInputType(input_type); - - media_transform->SetOutputTypeBySubType(output_guid); - - return media_transform; -} - -class VideoFrameImpl : public VideoFrame { - public: - VideoFrameImpl(int64_t timestamp, std::function release_cb) - : VideoFrame(timestamp), release_cb_(release_cb) { - SB_DCHECK(release_cb_); - } - ~VideoFrameImpl() { release_cb_(this); } - - private: - std::function release_cb_; -}; - -} // namespace - -VideoDecoder::VideoDecoder( - SbMediaVideoCodec video_codec, - SbPlayerOutputMode output_mode, - SbDecodeTargetGraphicsContextProvider* graphics_context_provider, - SbDrmSystem drm_system, - bool is_hdr_supported) - : video_codec_(video_codec), - graphics_context_provider_(graphics_context_provider), - drm_system_(drm_system), - is_hdr_supported_(is_hdr_supported) { - SB_DCHECK(output_mode == kSbPlayerOutputModeDecodeToTexture); - - HardwareDecoderContext hardware_context = GetDirectXForHardwareDecoding(); - d3d_device_ = hardware_context.dx_device_out; - device_manager_ = hardware_context.dxgi_device_manager_out; - if (!d3d_device_ || !device_manager_) { - return; - } - - HRESULT hr = d3d_device_.As(&video_device_); - if (FAILED(hr)) { - return; - } - - ComPtr d3d_context; - d3d_device_->GetImmediateContext(d3d_context.GetAddressOf()); - d3d_context.As(&video_context_); -} - -VideoDecoder::~VideoDecoder() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - Reset(); - ShutdownCodec(); -} - -// static -bool VideoDecoder::IsHardwareVp9DecoderSupported(bool is_hdr_required) { - static bool s_first_time_update = true; - static bool s_is_vp9_supported = false; - static bool s_is_hdr_supported = false; - - const UINT D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED = 0x10; - - if (s_first_time_update) { - ComPtr d3d11_device; - HRESULT hr = D3D11CreateDevice( - nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, - D3D11_SDK_VERSION, d3d11_device.GetAddressOf(), nullptr, nullptr); - if (FAILED(hr)) { - return false; - } - ComPtr video_device; - if (FAILED(d3d11_device.As(&video_device))) { - return false; - } - const DXGI_RATIONAL kFps = {30, 1}; // 30 fps = 30/1 - const UINT kBitrate = 0; - UINT caps_profile_0 = 0; - if (SUCCEEDED(video_device->GetVideoDecoderCaps(&DXVA_ModeVP9_VLD_Profile0, - 3840, 2160, &kFps, kBitrate, - NULL, &caps_profile_0))) { - s_is_vp9_supported = - caps_profile_0 != D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED; - } - - UINT caps_profile_2 = 0; - if (SUCCEEDED(video_device->GetVideoDecoderCaps( - &DXVA_ModeVP9_VLD_10bit_Profile2, 3840, 2160, &kFps, kBitrate, NULL, - &caps_profile_2))) { - s_is_hdr_supported = - caps_profile_2 != D3D11_VIDEO_DECODER_CAPS_UNSUPPORTED; - } - s_first_time_update = false; - } - return is_hdr_required ? s_is_vp9_supported && s_is_hdr_supported - : s_is_vp9_supported; -} - -size_t VideoDecoder::GetPrerollFrameCount() const { - return kMaxOutputSamples; -} - -size_t VideoDecoder::GetMaxNumberOfCachedFrames() const { - return kMaxOutputSamples; -} - -void VideoDecoder::Initialize(const DecoderStatusCB& decoder_status_cb, - const ErrorCB& error_cb) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(!decoder_status_cb_); - SB_DCHECK(decoder_status_cb); - SB_DCHECK(!error_cb_); - SB_DCHECK(error_cb); - decoder_status_cb_ = decoder_status_cb; - error_cb_ = error_cb; - if (video_device_) { - InitializeCodec(); - } - if (!decoder_) { - error_cb_(kSbPlayerErrorDecode, "Cannot initialize codec."); - } -} - -void VideoDecoder::WriteInputBuffers(const InputBuffers& input_buffers) { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(input_buffers.size() == 1); - SB_DCHECK(input_buffers[0]); - SB_DCHECK(decoder_status_cb_); - EnsureDecoderThreadRunning(); - if (error_occured_.load()) { - return; - } - const auto& input_buffer = input_buffers[0]; - if (TryUpdateOutputForHdrVideo(input_buffer->video_stream_info())) { - ScopedLock lock(thread_lock_); - thread_events_.emplace_back( - new Event{Event::kWriteInputBuffer, input_buffer}); - } else { - error_cb_(kSbPlayerErrorCapabilityChanged, - "HDR sink lost while HDR video playing."); - } -} - -void VideoDecoder::WriteEndOfStream() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - SB_DCHECK(decoder_status_cb_); - EnsureDecoderThreadRunning(); - if (error_occured_.load()) { - return; - } - - ScopedLock lock(thread_lock_); - thread_events_.emplace_back(new Event{Event::kWriteEndOfStream}); -} - -void VideoDecoder::Reset() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - StopDecoderThread(); - - // Make sure all output samples have been released before flushing the - // decoder. Be sure to Acquire the mutexes in the same order as - // CreateDecodeTarget to avoid possible deadlock. - outputs_reset_lock_.Acquire(); - thread_lock_.Acquire(); - thread_outputs_.clear(); - thread_lock_.Release(); - outputs_reset_lock_.Release(); - error_occured_.store(false); - - // If the previous priming hasn't finished, restart it. This happens rarely - // as it is only triggered when a seek is requested immediately after video is - // started. - if (priming_output_count_ > 0) { - priming_output_count_ = kVp9PrimingFrameCount; - } - - decoder_status_cb_(kReleaseAllFrames, nullptr); - if (decoder_) { - decoder_->Reset(); - } -} - -SbDecodeTarget VideoDecoder::GetCurrentDecodeTarget() { - auto decode_target = CreateDecodeTarget(); - - if (SbDecodeTargetIsValid(decode_target)) { - if (SbDecodeTargetIsValid(current_decode_target_)) { - prev_decode_targets_.emplace_back(current_decode_target_); - } - current_decode_target_ = decode_target; - } - if (SbDecodeTargetIsValid(current_decode_target_)) { - // Add a reference for the caller. - current_decode_target_->AddRef(); - } - return current_decode_target_; -} - -SbDecodeTarget VideoDecoder::CreateDecodeTarget() { - RECT video_area; - ComPtr video_sample; - - // Don't allow a decoder reset (flush) while an IMFSample is - // alive. However, the decoder thread should be allowed to continue - // while the SbDecodeTarget is being created. - ScopedLock reset_lock(outputs_reset_lock_); - - // Use the oldest output. - thread_lock_.Acquire(); - if (!thread_outputs_.empty()) { - // This function should not remove output frames. However, it's possible - // for the same frame to be requested multiple times. To avoid re-creating - // SbDecodeTargets, release the video_sample once it is used to create - // an output frame. The next call to CreateDecodeTarget for the same frame - // will return kSbDecodeTargetInvalid, and |current_decode_target_| will - // be reused. - Output& output = thread_outputs_.front(); - video_area = output.video_area; - video_sample.Swap(output.video_sample); - } - thread_lock_.Release(); - - SbDecodeTarget decode_target = kSbDecodeTargetInvalid; - if (video_sample != nullptr) { - // Try reusing the previous decode target to avoid the performance hit of - // creating a new texture. - SB_DCHECK(prev_decode_targets_.size() <= kDecodeTargetCacheSize + 1); - if (prev_decode_targets_.size() >= kDecodeTargetCacheSize) { - decode_target = prev_decode_targets_.front(); - prev_decode_targets_.pop_front(); - auto hardware_decode_target = - reinterpret_cast(decode_target); - if (!hardware_decode_target->Update( - d3d_device_, video_device_, video_context_, video_enumerator_, - video_processor_, video_sample, video_area, is_hdr_supported_)) { - // The cached decode target was not compatible; just release it. - SbDecodeTargetRelease(decode_target); - decode_target = kSbDecodeTargetInvalid; - } - } - - if (!SbDecodeTargetIsValid(decode_target)) { - decode_target = new HardwareDecodeTargetPrivate( - d3d_device_, video_device_, video_context_, video_enumerator_, - video_processor_, video_sample, video_area, is_hdr_supported_); - auto hardware_decode_target = - reinterpret_cast(decode_target); - if (!hardware_decode_target->d3d_texture) { - error_cb_(kSbPlayerErrorDecode, - "Failed to allocate texture with error code: " + - ::starboard::shared::win32::HResultToString( - hardware_decode_target->create_texture_2d_h_result)); - decode_target = kSbDecodeTargetInvalid; - } - } - - // Release the video_sample before releasing the reset lock. - video_sample.Reset(); - } - return decode_target; -} - -void VideoDecoder::InitializeCodec() { - std::unique_ptr media_transform; - - // If this is updated then media_is_video_supported.cc also needs to be - // updated. - switch (video_codec_) { - case kSbMediaVideoCodecH264: { - media_transform = - CreateVideoTransform(CLSID_MSH264DecoderMFT, MFVideoFormat_H264, - MFVideoFormat_NV12, device_manager_.Get()); - priming_output_count_ = 0; - if (!media_transform) { - SB_LOG(WARNING) << "H264 hardware decoder creation failed."; - return; - } - break; - } - case kSbMediaVideoCodecVp9: { - if (IsHardwareVp9DecoderSupported()) { - media_transform = - CreateVideoTransform(CLSID_MSVPxDecoder, MFVideoFormat_VP90, - MFVideoFormat_NV12, device_manager_.Get()); - priming_output_count_ = kVp9PrimingFrameCount; - } - if (!media_transform) { - SB_LOG(WARNING) << "VP9 hardware decoder creation failed."; - return; - } - break; - } - case kSbMediaVideoCodecAv1: { - media_transform = - CreateVideoTransform(MFVideoFormat_AV1, MFVideoFormat_AV1, - MFVideoFormat_NV12, device_manager_.Get()); - priming_output_count_ = 0; - if (!media_transform) { - SB_LOG(WARNING) << "AV1 hardware decoder creation failed."; - return; - } - break; - } - default: { - SB_NOTREACHED(); - } - } - - decoder_.reset( - new DecryptingDecoder("video", std::move(media_transform), drm_system_)); - MediaTransform* transform = decoder_->GetDecoder(); - - DWORD input_stream_count = 0; - DWORD output_stream_count = 0; - SB_DCHECK(transform); - transform->GetStreamCount(&input_stream_count, &output_stream_count); - SB_DCHECK(1 == input_stream_count); - SB_DCHECK(1 == output_stream_count); - - ComPtr attributes = transform->GetAttributes(); - SB_DCHECK(attributes); - CheckResult( - attributes->SetUINT32(MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT, - static_cast(GetMaxNumberOfCachedFrames()))); - - UpdateVideoArea(transform->GetCurrentOutputType()); - - // The transform must output textures that are bound to shader resources, - // or we can't draw them later via ANGLE. - ComPtr output_attributes = - transform->GetOutputStreamAttributes(); - SB_DCHECK(output_attributes); - CheckResult(output_attributes->SetUINT32( - MF_SA_D3D11_BINDFLAGS, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DECODER)); - - // The resolution and framerate will adjust to the actual content data. - D3D11_VIDEO_PROCESSOR_CONTENT_DESC content_desc = {}; - content_desc.InputFrameFormat = D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE; - content_desc.InputFrameRate.Numerator = 60; - content_desc.InputFrameRate.Denominator = 1; - content_desc.InputWidth = kMaxDecodeTargetWidth; - content_desc.InputHeight = kMaxDecodeTargetHeight; - content_desc.OutputFrameRate.Numerator = 60; - content_desc.OutputFrameRate.Denominator = 1; - content_desc.OutputWidth = kMaxDecodeTargetWidth; - content_desc.OutputHeight = kMaxDecodeTargetHeight; - content_desc.Usage = D3D11_VIDEO_USAGE_PLAYBACK_NORMAL; - CheckResult(video_device_->CreateVideoProcessorEnumerator( - &content_desc, video_enumerator_.GetAddressOf())); - CheckResult(video_device_->CreateVideoProcessor( - video_enumerator_.Get(), 0, video_processor_.GetAddressOf())); - SB_DCHECK(video_context_); - video_context_->VideoProcessorSetStreamFrameFormat( - video_processor_.Get(), MediaTransform::kStreamId, - D3D11_VIDEO_FRAME_FORMAT_PROGRESSIVE); - video_context_->VideoProcessorSetStreamAutoProcessingMode( - video_processor_.Get(), 0, false); -} - -void VideoDecoder::ShutdownCodec() { - SB_DCHECK(decoder_thread_ == 0); - SB_DCHECK(thread_outputs_.empty()); - if (!decoder_) { - return; - } - - // Work around a VP9 decoder crash. All IMFSamples and anything that may - // reference them indirectly (the d3d texture in SbDecodeTarget) must be - // released before releasing the IMFTransform. Do this on the render thread - // since graphics resources are being released. - graphics_context_provider_->gles_context_runner( - graphics_context_provider_, &VideoDecoder::ReleaseDecodeTargets, this); - - // Microsoft recommends stalling to let other systems release their - // references to the IMFSamples. - if (video_codec_ == kSbMediaVideoCodecVp9) { - usleep(150'000); - } - decoder_.reset(); - video_processor_.Reset(); - video_enumerator_.Reset(); -} - -// static -void VideoDecoder::ReleaseDecodeTargets(void* context) { - VideoDecoder* this_ptr = static_cast(context); - while (!this_ptr->prev_decode_targets_.empty()) { - SbDecodeTargetRelease(this_ptr->prev_decode_targets_.front()); - this_ptr->prev_decode_targets_.pop_front(); - } - if (SbDecodeTargetIsValid(this_ptr->current_decode_target_)) { - SbDecodeTargetRelease(this_ptr->current_decode_target_); - this_ptr->current_decode_target_ = kSbDecodeTargetInvalid; - } -} - -void VideoDecoder::EnsureDecoderThreadRunning() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - // NOTE: The video decoder thread will exit after processing the - // kWriteEndOfStream event. In this case, Reset must be called (which will - // then StopDecoderThread) before WriteInputBuffers or WriteEndOfStream again. - SB_DCHECK(!decoder_thread_stopped_); - - if (decoder_thread_ == 0) { - if (!decoder_) { - error_cb_(kSbPlayerErrorDecode, "Decoder is not valid."); - return; - } - SB_DCHECK(decoder_ != nullptr); - SB_DCHECK(thread_events_.empty()); - decoder_thread_stop_requested_ = false; - pthread_create(&decoder_thread_, nullptr, &VideoDecoder::DecoderThreadEntry, - this); - SB_DCHECK(decoder_thread_ != 0); - } -} - -void VideoDecoder::StopDecoderThread() { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - if (decoder_thread_ != 0) { - decoder_thread_stop_requested_ = true; - pthread_join(decoder_thread_, nullptr); - SB_DCHECK(decoder_thread_stopped_); - decoder_thread_stopped_ = false; - decoder_thread_ = 0; - } - thread_events_.clear(); -} - -void VideoDecoder::UpdateVideoArea(const ComPtr& media) { - MFVideoArea video_area; - HRESULT hr = media->GetBlob(MF_MT_MINIMUM_DISPLAY_APERTURE, - reinterpret_cast(&video_area), - sizeof(video_area), nullptr); - if (SUCCEEDED(hr)) { - video_area_.left = video_area.OffsetX.value; - video_area_.top = video_area.OffsetY.value; - video_area_.right = video_area_.left + video_area.Area.cx; - video_area_.bottom = video_area_.top + video_area.Area.cy; - return; - } - - UINT32 width; - UINT32 height; - hr = MFGetAttributeSize(media.Get(), MF_MT_FRAME_SIZE, &width, &height); - if (SUCCEEDED(hr)) { - video_area_.left = 0; - video_area_.top = 0; - video_area_.right = width; - video_area_.bottom = height; - return; - } - - SB_NOTREACHED() << "Could not determine new video output resolution"; -} - -scoped_refptr VideoDecoder::CreateVideoFrame( - const ComPtr& sample) { - // NOTE: All samples must be released before flushing the decoder. Since - // the host may hang onto VideoFrames that are created here, make them - // weak references to the actual sample. - LONGLONG win32_sample_time = 0; - CheckResult(sample->GetSampleTime(&win32_sample_time)); - int64_t sample_time = ConvertWin32TimeToUsec(win32_sample_time); - - thread_lock_.Acquire(); - thread_outputs_.emplace_back(sample_time, video_area_, sample); - thread_lock_.Release(); - - // The "native texture" for the VideoFrame is actually just the timestamp - // for the output sample. - return new VideoFrameImpl( - sample_time, std::bind(&VideoDecoder::DeleteVideoFrame, this, _1)); -} - -void VideoDecoder::DeleteVideoFrame(VideoFrame* video_frame) { - ScopedLock lock(thread_lock_); - for (auto iter = thread_outputs_.begin(); iter != thread_outputs_.end(); - ++iter) { - if (iter->time == video_frame->timestamp()) { - thread_outputs_.erase(iter); - break; - } - } -} - -void VideoDecoder::DecoderThreadRun() { - std::list > priming_events; - std::unique_ptr event; - bool is_end_of_stream = false; - - while (!decoder_thread_stop_requested_) { - int outputs_to_process = 1; - bool wrote_input = false; - bool read_output = false; - - // Process a new event or re-try the previous event. - if (event == nullptr) { - ScopedLock lock(thread_lock_); - if (!thread_events_.empty()) { - event.swap(thread_events_.front()); - thread_events_.pop_front(); - } - } - - if (event == nullptr) { - usleep(1000); - } else { - switch (event->type) { - case Event::kWriteInputBuffer: - SB_DCHECK(event->input_buffer != nullptr); - if (error_occured_) { - event.reset(); - break; - } - if (decoder_->TryWriteInputBuffer(event->input_buffer, 0)) { - if (priming_output_count_ > 0) { - // Save this event for the actual playback. - priming_events.emplace_back(event.release()); - } - // The event was successfully processed. Discard it. - event.reset(); - wrote_input = true; - } else { - // The decoder must be full. Re-try the event on the next - // iteration. Additionally, try reading an extra output frame to - // start draining the decoder. - ++outputs_to_process; - } - break; - case Event::kWriteEndOfStream: - if (priming_output_count_ > 0) { - // Finish priming when eos is encountered. - priming_output_count_ = 0; - thread_lock_.Acquire(); - while (!priming_events.empty()) { - thread_events_.emplace_front(priming_events.back().release()); - priming_events.pop_back(); - } - // Also append the eos event. - thread_events_.emplace_back(event.release()); - thread_lock_.Release(); - decoder_->Reset(); - break; - } - event.reset(); - decoder_->Drain(); - is_end_of_stream = true; - wrote_input = true; - break; - } - } - - // Process output frame(s). - for (int outputs = 0; outputs < outputs_to_process; ++outputs) { - // NOTE: IMFTransform::ProcessOutput (called by decoder_->ProcessAndRead) - // may stall if the number of active IMFSamples would exceed the value of - // MF_SA_MINIMUM_OUTPUT_SAMPLE_COUNT. - thread_lock_.Acquire(); - bool input_full = thread_events_.size() >= kMaxInputSamples; - bool output_full = thread_outputs_.size() >= GetMaxNumberOfCachedFrames(); - thread_lock_.Release(); - - Status status = input_full ? kBufferFull : kNeedMoreInput; - decoder_status_cb_(status, nullptr); - - if (output_full) { - // Wait for the active samples to be consumed before polling for more. - break; - } - - ComPtr sample; - ComPtr media_type; - bool hasError; - decoder_->ProcessAndRead(&sample, &media_type, &hasError); - if (hasError) { - error_occured_.exchange(true); - error_cb_(kSbPlayerErrorDecode, "Something went wrong in decoding."); - break; - } - if (media_type) { - UpdateVideoArea(media_type); - } - if (sample) { - if (priming_output_count_ > 0) { - // Ignore the output samples while priming the decoder. - if (--priming_output_count_ == 0) { - // Replay all the priming events once priming is finished. - if (event != nullptr) { - priming_events.emplace_back(event.release()); - } - thread_lock_.Acquire(); - while (!priming_events.empty()) { - thread_events_.emplace_front(priming_events.back().release()); - priming_events.pop_back(); - } - thread_lock_.Release(); - decoder_->Reset(); - } - } else { - decoder_status_cb_(status, CreateVideoFrame(sample)); - } - read_output = true; - } else if (is_end_of_stream) { - decoder_status_cb_(kBufferFull, VideoFrame::CreateEOSFrame()); - return; - } - } - - if (!wrote_input && !read_output) { - // Throttle decode loop since no I/O was possible. - usleep(1000); - } - } -} - -// static -void* VideoDecoder::DecoderThreadEntry(void* context) { - pthread_setname_np(pthread_self(), "VideoDecoder"); - ::starboard::shared::pthread::ThreadSetPriority(kSbThreadPriorityHigh); - - SB_DCHECK(context); - VideoDecoder* decoder = static_cast(context); - decoder->DecoderThreadRun(); - decoder->decoder_thread_stopped_ = true; - return nullptr; -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/video_decoder.h b/starboard/shared/win32/video_decoder.h deleted file mode 100644 index c54336253c01..000000000000 --- a/starboard/shared/win32/video_decoder.h +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_VIDEO_DECODER_H_ -#define STARBOARD_SHARED_WIN32_VIDEO_DECODER_H_ - -#include -#include -#include - -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/configuration.h" -#include "starboard/decode_target.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/filter/video_decoder_internal.h" -#include "starboard/shared/starboard/thread_checker.h" -#include "starboard/shared/win32/decrypting_decoder.h" -#include "starboard/thread.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class VideoDecoder - : public ::starboard::shared::starboard::player::filter::VideoDecoder { - public: - VideoDecoder(SbMediaVideoCodec video_codec, - SbPlayerOutputMode output_mode, - SbDecodeTargetGraphicsContextProvider* graphics_context_provider, - SbDrmSystem drm_system, - bool is_hdr_supported = false); - ~VideoDecoder() override; - - // Queries for support without creating the vp9 decoder. The function caches - // the result for the first call. Note that the first call to this function - // isn't thread safe and is supposed to be called on startup. - static bool IsHardwareVp9DecoderSupported(bool is_hdr_required = false); - - bool IsHdrSupported() const { return is_hdr_supported_; } - - // Implement VideoDecoder interface. - void Initialize(const DecoderStatusCB& decoder_status_cb, - const ErrorCB& error_cb) override; - size_t GetPrerollFrameCount() const override; - int64_t GetPrerollTimeout() const override { return kSbInt64Max; } - size_t GetMaxNumberOfCachedFrames() const override; - - void WriteInputBuffers(const InputBuffers& input_buffers) override; - void WriteEndOfStream() override; - void Reset() override; - SbDecodeTarget GetCurrentDecodeTarget() override; - - private: - typedef ::starboard::shared::starboard::media::VideoStreamInfo - VideoStreamInfo; - - template - using ComPtr = Microsoft::WRL::ComPtr; - - struct Event { - enum Type { - kWriteInputBuffer, - kWriteEndOfStream, - }; - Type type; - scoped_refptr input_buffer; - }; - - struct Output { - Output(int64_t time, - const RECT& video_area, - const ComPtr& video_sample) - : time(time), video_area(video_area), video_sample(video_sample) {} - int64_t time; - RECT video_area; - ComPtr video_sample; - }; - - // This function returns false if HDR video is played, but HDR support is - // lost. Otherwise it returns true. For inherited class it also updates HDMI - // color metadata and sets HDR mode for Angle, if the video stream is HDR - // stream. - virtual bool TryUpdateOutputForHdrVideo(const VideoStreamInfo& stream_info) { - return true; - } - - void InitializeCodec(); - void ShutdownCodec(); - static void ReleaseDecodeTargets(void* context); - - void UpdateVideoArea(const ComPtr& media); - scoped_refptr CreateVideoFrame(const ComPtr& sample); - void DeleteVideoFrame(VideoFrame* video_frame); - SbDecodeTarget CreateDecodeTarget(); - - void EnsureDecoderThreadRunning(); - void StopDecoderThread(); - void DecoderThreadRun(); - static void* DecoderThreadEntry(void* context); - - ::starboard::shared::starboard::ThreadChecker thread_checker_; - - // These variables will be initialized inside ctor or Initialize() and will - // not be changed during the life time of this class. - const SbMediaVideoCodec video_codec_; - DecoderStatusCB decoder_status_cb_; - ErrorCB error_cb_; - SbDecodeTargetGraphicsContextProvider* graphics_context_provider_; - SbDrmSystem const drm_system_; - - // These are platform-specific objects required to create and use a codec. - ComPtr d3d_device_; - ComPtr device_manager_; - ComPtr video_device_; - ComPtr video_context_; - ComPtr video_enumerator_; - ComPtr video_processor_; - - std::unique_ptr decoder_; - RECT video_area_; - - pthread_t decoder_thread_ = 0; - volatile bool decoder_thread_stop_requested_ = false; - bool decoder_thread_stopped_ = false; - Mutex thread_lock_; - std::list > thread_events_; - - // This structure shadows the list of outstanding frames held by the host. - // When a new output is added to this structure, the host should be notified - // of a new VideoFrame. When the host deletes the VideoFrame, the delete - // callback is used to update this structure. The VideoDecoder may need to - // delete outputs without notifying the host. In such a situation, the host's - // VideoFrames will be invalid if they still require the IMFSample; it's - // possible that the VideoFrame was converted to a texture already, so it - // will continue to be valid since the IMFSample is no longer needed. - Mutex outputs_reset_lock_; - std::list thread_outputs_; - - // To workaround the startup hitch for VP9, exercise the decoder for a - // certain number of frames while prerolling the initial playback. - int priming_output_count_; - - SbDecodeTarget current_decode_target_ = kSbDecodeTargetInvalid; - std::list prev_decode_targets_; - - bool is_hdr_supported_; - std::atomic_bool error_occured_ = {false}; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_VIDEO_DECODER_H_ diff --git a/starboard/shared/win32/wasapi_include.h b/starboard/shared/win32/wasapi_include.h deleted file mode 100644 index 94126009fbe7..000000000000 --- a/starboard/shared/win32/wasapi_include.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_WASAPI_INCLUDE_H_ -#define STARBOARD_SHARED_WIN32_WASAPI_INCLUDE_H_ - -#include -#include - -#define KSAUDIO_SPEAKER_DIRECTOUT 0 -#define KSAUDIO_SPEAKER_STEREO (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) -#define KSAUDIO_SPEAKER_5POINT1 \ - (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT | SPEAKER_FRONT_CENTER | \ - SPEAKER_LOW_FREQUENCY | SPEAKER_BACK_LEFT | SPEAKER_BACK_RIGHT) - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS, - 0x0000000a, - 0x0cea, - 0x0010, - 0x80, - 0x00, - 0x00, - 0xaa, - 0x00, - 0x38, - 0x9b, - 0x71); - -// IEC 60958 specific values. -constexpr int kAc3SamplesPerSecond = 48000; -constexpr int kEac3SamplesPerSecond = 192000; -constexpr int kIec60958Channels = 2; -constexpr int kIec60958BitsPerSample = 16; -constexpr int kIec60958BlockAlign = 4; -// Values taken from the Dolby Audio Decoder MFT documentation -// https://docs.microsoft.com/en-us/windows/win32/medfound/dolby-audio-decoder -constexpr size_t kAc3BufferSize = 6144; -constexpr size_t kEac3BufferSize = 24576; - -namespace starboard { -namespace shared { -namespace win32 { - -typedef struct { - WAVEFORMATEXTENSIBLE FormatExt; - - DWORD dwEncodedSamplesPerSec; - DWORD dwEncodedChannelCount; - DWORD dwAverageBytesPerSec; -} WAVEFORMATEXTENSIBLE_IEC61937, *PWAVEFORMATEXTENSIBLE_IEC61937; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_WASAPI_INCLUDE_H_ diff --git a/starboard/shared/win32/wchar_utils.h b/starboard/shared/win32/wchar_utils.h deleted file mode 100644 index e1791a94341c..000000000000 --- a/starboard/shared/win32/wchar_utils.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_WCHAR_UTILS_H_ -#define STARBOARD_SHARED_WIN32_WCHAR_UTILS_H_ - -#include -#include -#include -#include - -namespace starboard { -namespace shared { -namespace win32 { - -inline std::string wchar_tToUTF8(const wchar_t* const str) { - std::wstring_convert, wchar_t> converter; - return converter.to_bytes(str); -} - -inline std::string wchar_tToUTF8(const wchar_t* const str, - const std::size_t size) { - std::wstring_convert, wchar_t> converter; - return converter.to_bytes(str, str + size); -} - -inline std::wstring CStringToWString(const char* str) { - std::wstring_convert, wchar_t> converter; - return converter.from_bytes(str); -} - -#if defined(__cplusplus_winrt) -inline std::string platformStringToString(Platform::String ^ to_convert) { - std::wstring ws(to_convert->Begin(), to_convert->End()); - return wchar_tToUTF8(ws.data(), ws.size()); -} - -inline Platform::String ^ - stringToPlatformString(const std::string& to_convert) { - return ref new Platform::String( - CStringToWString(to_convert.c_str()).c_str()); - } -#endif - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_WCHAR_UTILS_H_ diff --git a/starboard/shared/win32/win32_audio_decoder.cc b/starboard/shared/win32/win32_audio_decoder.cc deleted file mode 100644 index d550cd7bfed2..000000000000 --- a/starboard/shared/win32/win32_audio_decoder.cc +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/win32_audio_decoder.h" - -#include -#include -#include - -#include "starboard/atomic.h" -#include "starboard/shared/starboard/player/filter/audio_frame_discarder.h" -#include "starboard/shared/starboard/thread_checker.h" -#include "starboard/shared/win32/atomic_queue.h" -#include "starboard/shared/win32/audio_decoder.h" -#include "starboard/shared/win32/audio_transform.h" -#include "starboard/shared/win32/decrypting_decoder.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/media_foundation_utils.h" -#include "starboard/shared/win32/wasapi_include.h" - -namespace starboard { -namespace shared { -namespace win32 { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::starboard::ThreadChecker; -using ::starboard::shared::starboard::media::AudioStreamInfo; -using ::starboard::shared::win32::CreateAudioTransform; - -const size_t kAacSamplesPerFrame = 1024; -// We are using float samples for AAC on Xb1. -const size_t kAacBytesPerSample = sizeof(float); - -namespace { -size_t GetExpectedBufferSize(SbMediaAudioCodec codec, int num_channels) { - switch (codec) { - case kSbMediaAudioCodecAac: - return num_channels * kAacSamplesPerFrame * kAacBytesPerSample; - case kSbMediaAudioCodecAc3: - return kAc3BufferSize; - case kSbMediaAudioCodecEac3: - return kEac3BufferSize; - default: - SB_NOTREACHED(); - return size_t(0); - } -} - -class AbstractWin32AudioDecoderImpl : public AbstractWin32AudioDecoder { - public: - AbstractWin32AudioDecoderImpl(SbMediaAudioFrameStorageType audio_frame_fmt, - SbMediaAudioSampleType sample_type, - const AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system) - : thread_checker_(ThreadChecker::kSetThreadIdOnFirstCheck), - codec_(audio_stream_info.codec), - audio_frame_fmt_(audio_frame_fmt), - sample_type_(sample_type), - number_of_channels_(audio_stream_info.number_of_channels), - expected_buffer_size_( - GetExpectedBufferSize(codec_, - audio_stream_info.number_of_channels)) { - std::unique_ptr audio_decoder = - CreateAudioTransform(audio_stream_info); - impl_.reset( - new DecryptingDecoder("audio", std::move(audio_decoder), drm_system)); - switch (codec_) { - case kSbMediaAudioCodecAc3: - samples_per_second_ = kAc3SamplesPerSecond; - number_of_channels_ = kIec60958Channels; - break; - case kSbMediaAudioCodecEac3: - samples_per_second_ = kEac3SamplesPerSecond; - number_of_channels_ = kIec60958Channels; - break; - default: - samples_per_second_ = - static_cast(audio_stream_info.samples_per_second); - number_of_channels_ = audio_stream_info.number_of_channels; - } - } - - void Consume(ComPtr sample) { - DWORD buff_count = 0; - HRESULT hr = sample->GetBufferCount(&buff_count); - CheckResult(hr); - SB_DCHECK(buff_count == 1); - - ComPtr media_buffer; - hr = sample->GetBufferByIndex(0, &media_buffer); - if (FAILED(hr)) { - return; - } - - LONGLONG win32_timestamp = 0; - hr = sample->GetSampleTime(&win32_timestamp); - CheckResult(hr); - - BYTE* buffer; - DWORD length; - hr = media_buffer->Lock(&buffer, NULL, &length); - CheckResult(hr); - SB_DCHECK(length); - - const uint8_t* data = reinterpret_cast(buffer); - const size_t data_size = static_cast(length); - - if (codec_ == kSbMediaAudioCodecAac && - (data_size / expected_buffer_size_ == 2)) { - heaac_detected_.store(true); - } - - const size_t decoded_data_size = std::max(expected_buffer_size_, data_size); - - if (codec_ == kSbMediaAudioCodecAc3) { - SB_DCHECK(decoded_data_size == kAc3BufferSize); - } else if (codec_ == kSbMediaAudioCodecEac3) { - SB_DCHECK(decoded_data_size == kEac3BufferSize); - } - - DecodedAudioPtr data_ptr( - new DecodedAudio(number_of_channels_, sample_type_, audio_frame_fmt_, - ConvertWin32TimeToUsec(win32_timestamp), - static_cast(decoded_data_size))); - - std::copy(data, data + data_size, data_ptr->data()); - std::memset(data_ptr->data() + data_size, 0, decoded_data_size - data_size); - - if (codec_ == kSbMediaAudioCodecAac) { - audio_frame_discarder_.AdjustForDiscardedDurations(GetSamplesPerSecond(), - &data_ptr); - } - output_queue_.push(data_ptr); - media_buffer->Unlock(); - } - - bool TryWrite(const scoped_refptr& buff) override { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - if (codec_ == kSbMediaAudioCodecAac) { - // The incoming audio is in ADTS format which has a 7 bytes header. But - // the audio decoder is configured to accept raw AAC. So we have to - // adjust the data, size, and subsample mapping to skip the ADTS header. - const int kADTSHeaderSize = 7; - if (impl_->TryWriteInputBuffer(buff, kADTSHeaderSize)) { - audio_frame_discarder_.OnInputBuffers({buff}); - return true; - } - return false; - } - return impl_->TryWriteInputBuffer(buff, 0); - } - - void WriteEndOfStream() override { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - impl_->Drain(); - ComPtr sample; - ComPtr media_type; - bool hasError; - while (impl_->ProcessAndRead(&sample, &media_type, &hasError)) { - if (sample) { - Consume(sample); - } - } - output_queue_.push(new DecodedAudio); - if (codec_ == kSbMediaAudioCodecAac) { - audio_frame_discarder_.OnDecodedAudioEndOfStream(); - } - } - - scoped_refptr ProcessAndRead() override { - SB_DCHECK(thread_checker_.CalledOnValidThread()); - - ComPtr sample; - ComPtr media_type; - bool hasError; - while (impl_->ProcessAndRead(&sample, &media_type, &hasError)) { - if (sample) { - Consume(sample); - } - } - if (output_queue_.empty()) { - return NULL; - } - scoped_refptr output = output_queue_.front(); - output_queue_.pop(); - return output; - } - - void Reset() override { - impl_->Reset(); - audio_frame_discarder_.Reset(); - std::queue empty; - output_queue_.swap(empty); - thread_checker_.Detach(); - } - - int GetSamplesPerSecond() const override { - if (heaac_detected_.load()) { - return samples_per_second_ * 2; - } - return samples_per_second_; - } - - // The object is single-threaded and is driven by a dedicated thread. - // However the thread may gets destroyed and re-created over the life time of - // this object. We enforce that certain member functions can only called - // from one thread while still allows this object to be driven by different - // threads by: - // 1. The |thread_checker_| is initially created without attaching to any - // thread. - // 2. When a thread is destroyed, Reset() will be called which in turn calls - // Detach() on the |thread_checker_| to allow the object to attach to a - // new thread. - ::starboard::shared::starboard::ThreadChecker thread_checker_; - const SbMediaAudioCodec codec_; - const SbMediaAudioSampleType sample_type_; - const SbMediaAudioFrameStorageType audio_frame_fmt_; - - starboard::player::filter::AudioFrameDiscarder audio_frame_discarder_; - std::unique_ptr impl_; - std::queue output_queue_; - uint16_t number_of_channels_; - std::atomic_bool heaac_detected_{false}; - int samples_per_second_; - const size_t expected_buffer_size_; -}; - -} // anonymous namespace. - -std::unique_ptr AbstractWin32AudioDecoder::Create( - SbMediaAudioFrameStorageType audio_frame_fmt, - SbMediaAudioSampleType sample_type, - const AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system) { - return std::unique_ptr( - new AbstractWin32AudioDecoderImpl(audio_frame_fmt, sample_type, - audio_stream_info, drm_system)); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/win32_audio_decoder.h b/starboard/shared/win32/win32_audio_decoder.h deleted file mode 100644 index dda9cf98a46d..000000000000 --- a/starboard/shared/win32/win32_audio_decoder.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_WIN32_AUDIO_DECODER_H_ -#define STARBOARD_SHARED_WIN32_WIN32_AUDIO_DECODER_H_ - -#include -#include - -#include "starboard/common/ref_counted.h" -#include "starboard/drm.h" -#include "starboard/media.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/decoded_audio_internal.h" -#include "starboard/shared/win32/media_common.h" -#include "starboard/types.h" - -namespace starboard { -namespace shared { -namespace win32 { - -// AudioDecoder for Win32. -class AbstractWin32AudioDecoder { - public: - static std::unique_ptr Create( - SbMediaAudioFrameStorageType audio_frame_fmt, - SbMediaAudioSampleType sample_type, - const starboard::media::AudioStreamInfo& audio_stream_info, - SbDrmSystem drm_system); - virtual ~AbstractWin32AudioDecoder() {} - - // INPUT: - // - virtual bool TryWrite(const scoped_refptr& buff) = 0; - virtual void WriteEndOfStream() = 0; - // OUTPUT - // - virtual DecodedAudioPtr ProcessAndRead() = 0; - // Reset - virtual void Reset() = 0; - - // Dynamically query the audio frequency to support HE-AAC. - virtual int GetSamplesPerSecond() const = 0; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_WIN32_AUDIO_DECODER_H_ diff --git a/starboard/shared/win32/window_create.cc b/starboard/shared/win32/window_create.cc deleted file mode 100644 index 72c009d8d996..000000000000 --- a/starboard/shared/win32/window_create.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/window.h" - -#include "starboard/shared/win32/application_win32.h" - -using ::starboard::shared::win32::ApplicationWin32; - -SbWindow SbWindowCreate(const SbWindowOptions* options) { - return ApplicationWin32::Get()->CreateWindowForWin32(options); -} diff --git a/starboard/shared/win32/window_destroy.cc b/starboard/shared/win32/window_destroy.cc deleted file mode 100644 index 34a8c5446f33..000000000000 --- a/starboard/shared/win32/window_destroy.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/application_win32.h" -#include "starboard/window.h" - -using ::starboard::shared::win32::ApplicationWin32; - -bool SbWindowDestroy(SbWindow window) { - return ApplicationWin32::Get()->DestroyWindow(window); -} diff --git a/starboard/shared/win32/window_get_platform_handle.cc b/starboard/shared/win32/window_get_platform_handle.cc deleted file mode 100644 index 566cf47fc9f1..000000000000 --- a/starboard/shared/win32/window_get_platform_handle.cc +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "starboard/shared/win32/window_internal.h" -#include "starboard/window.h" - -void* SbWindowGetPlatformHandle(SbWindow window) { - if (!SbWindowIsValid(window)) { - return NULL; - } - - return reinterpret_cast(window->GetWindowHandle()); -} diff --git a/starboard/shared/win32/window_get_size.cc b/starboard/shared/win32/window_get_size.cc deleted file mode 100644 index 6ca581b4c998..000000000000 --- a/starboard/shared/win32/window_get_size.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/common/log.h" -#include "starboard/shared/win32/window_internal.h" -#include "starboard/window.h" - -bool SbWindowGetSize(SbWindow window, SbWindowSize* size) { - if (!SbWindowIsValid(window)) { - SB_LOG(ERROR) << __FUNCTION__ << ": Invalid window."; - return false; - } - - size->width = window->width; - size->height = window->height; - // The video resolution is the same as the graphics resolution. - size->video_pixel_ratio = 1.0f; - return true; -} diff --git a/starboard/shared/win32/window_internal.cc b/starboard/shared/win32/window_internal.cc deleted file mode 100644 index 02939b3c5622..000000000000 --- a/starboard/shared/win32/window_internal.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/window_internal.h" - -// TODO: Make sure the width and height here behave well given that we want -// 1080 video, but perhaps 4k UI where applicable. -SbWindowPrivate::SbWindowPrivate(const SbWindowOptions* options, - HWND window_handle) - : width(options->size.width), - height(options->size.height), - window_handle_(window_handle) { - RECT window_client_rect; - - if (GetClientRect(window_handle_, &window_client_rect)) { - width = window_client_rect.right - window_client_rect.left; - height = window_client_rect.bottom - window_client_rect.top; - } -} - -SbWindowPrivate::~SbWindowPrivate() {} diff --git a/starboard/shared/win32/window_internal.h b/starboard/shared/win32/window_internal.h deleted file mode 100644 index 2feb933d4fb8..000000000000 --- a/starboard/shared/win32/window_internal.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_WINDOW_INTERNAL_H_ -#define STARBOARD_SHARED_WIN32_WINDOW_INTERNAL_H_ - -#include - -// Windows headers. -#include - -#include "starboard/atomic.h" -#include "starboard/window.h" - -struct SbWindowPrivate { - SbWindowPrivate(const SbWindowOptions* options, HWND window_handle); - ~SbWindowPrivate(); - - HWND GetWindowHandle() { return window_handle_; } - - // The width of this window. - int width; - - // The height of this window. - int height; - - private: - HWND window_handle_; -}; - -#endif // STARBOARD_SHARED_WIN32_WINDOW_INTERNAL_H_ diff --git a/starboard/shared/win32/window_set_default_options.cc b/starboard/shared/win32/window_set_default_options.cc deleted file mode 100644 index f0f124f308c0..000000000000 --- a/starboard/shared/win32/window_set_default_options.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/memory.h" -#include "starboard/window.h" - -void SbWindowSetDefaultOptions(SbWindowOptions* options) { - memset(options, 0, sizeof(*options)); - options->size.width = 1920; - options->size.height = 1080; - options->name = "YouTube"; -} diff --git a/starboard/shared/win32/wrm_header.cc b/starboard/shared/win32/wrm_header.cc deleted file mode 100644 index 59f32127ff39..000000000000 --- a/starboard/shared/win32/wrm_header.cc +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/wrm_header.h" - -#include -#include -#include - -#include - -#include "starboard/memory.h" -#include "starboard/shared/win32/error_utils.h" - -namespace starboard { -namespace shared { -namespace win32 { - -using Microsoft::WRL::ComPtr; - -namespace { - -// The playready system id used to create the content header. -DEFINE_GUID(kPlayreadyContentHeaderCLSID, - 0xF4637010, - 0x03C3, - 0x42CD, - 0xB9, - 0x32, - 0xB4, - 0x8A, - 0xDF, - 0x3A, - 0x6A, - 0x54); - -// The playready system id used to identify the wrm header in the -// initialization data. -DEFINE_GUID(kPlayreadyInitializationDataCLSID, - 0x79f0049a, - 0x4098, - 0x8642, - 0xab, - 0x92, - 0xe6, - 0x5b, - 0xe0, - 0x88, - 0x5f, - 0x95); - -const uint16_t kPlayreadyWRMTag = 0x0001; - -class Reader { - public: - Reader(const uint8_t* data, size_t length) - : start_(data), curr_(data), end_(data + length) {} - - size_t GetPosition() const { return curr_ - start_; } - size_t GetRemaining() const { return end_ - curr_; } - - const uint8_t* curr() const { curr_; } - - bool Skip(size_t distance) { - if (distance > GetRemaining()) - return false; - curr_ += distance; - return true; - } - - bool ReadGUID(GUID* guid) { - if (sizeof(*guid) > GetRemaining()) { - return false; - } - memcpy(guid, curr_, sizeof(*guid)); - curr_ += sizeof(*guid); - return true; - } - - bool ReadBigEndianU32(uint32_t* i) { - if (sizeof(*i) > GetRemaining()) - return false; - *i = - curr_[0] * 0x1000000 + curr_[1] * 0x10000 + curr_[2] * 0x100 + curr_[3]; - curr_ += sizeof(*i); - return true; - } - - bool ReadLittleEndianU16(uint16_t* i) { - if (sizeof(*i) > GetRemaining()) - return false; - *i = curr_[0] + curr_[1] * 0x100; - curr_ += sizeof(*i); - return true; - } - - private: - const uint8_t* const start_; - const uint8_t* curr_; - const uint8_t* const end_; -}; - -std::vector ParseWrmHeaderFromInitializationData( - const void* initialization_data, - int initialization_data_size) { - if (initialization_data_size == 0) { - SB_NOTIMPLEMENTED(); - return std::vector(); - } - - std::vector output; - const uint8_t* data = static_cast(initialization_data); - - Reader reader(data, initialization_data_size); - while (reader.GetRemaining() > 0) { - // Parse pssh atom (big endian) - // - // 4 bytes -- size - // 4 bytes -- "pssh" - // 4 bytes -- flags - // 16 bytes -- guid - uint32_t pssh_size; - if (!reader.ReadBigEndianU32(&pssh_size)) { - return output; - } - - // Skipping pssh and flags - if (!reader.Skip(8)) { - return output; - } - GUID system_id; - if (!reader.ReadGUID(&system_id)) { - return output; - } - if (system_id != kPlayreadyInitializationDataCLSID) { - // Skip entire pssh atom - if (!reader.Skip(pssh_size - 28)) { - return output; - } - continue; - } - - // 4 bytes -- size of PlayreadyObject - // followed by PlayreadyObject - - // Skip size, and continue parsing - if (!reader.Skip(4)) { - return output; - } - - // Parse Playready object (little endian) - // 4 bytes -- size - // 2 bytes -- record count - // - // Playready Record - // 2 bytes -- type - // 2 bytes -- size of record - // n bytes -- record - if (!reader.Skip(4)) { - return output; - } - uint16_t num_records; - if (!reader.ReadLittleEndianU16(&num_records)) { - return output; - } - - for (int i = 0; i < num_records; i++) { - uint16_t record_type; - if (!reader.ReadLittleEndianU16(&record_type)) { - return output; - } - uint16_t record_size; - if (!reader.ReadLittleEndianU16(&record_size)) { - return output; - } - if ((record_type & kPlayreadyWRMTag) == kPlayreadyWRMTag) { - std::copy(data + reader.GetPosition(), - data + reader.GetPosition() + record_size, - std::back_inserter(output)); - return output; - } - if (!reader.Skip(record_size)) { - return output; - } - } - } - - return output; -} - -uint32_t Base64ToValue(uint8_t byte) { - if (byte >= 'A' && byte <= 'Z') { - return byte - 'A'; - } - if (byte >= 'a' && byte <= 'z') { - return byte - 'a' + 26; - } - if (byte >= '0' && byte <= '9') { - return byte - '0' + 52; - } - if (byte == '+') { - return 62; - } - if (byte == '/') { - return 63; - } - SB_DCHECK(byte == '='); - return 0; -} - -std::string Base64Decode(const std::wstring& input) { - SB_DCHECK(input.size() % 4 == 0); - - std::string output; - - output.reserve(input.size() / 4 * 3); - for (size_t i = 0; i < input.size() - 3; i += 4) { - uint32_t decoded = - Base64ToValue(input[i]) * 4 + Base64ToValue(input[i + 1]) / 16; - output += static_cast(decoded); - if (input[i + 2] != '=') { - decoded = Base64ToValue(input[i + 1]) % 16 * 16 + - Base64ToValue(input[i + 2]) / 4; - output += static_cast(decoded); - if (input[i + 3] != '=') { - decoded = - Base64ToValue(input[i + 2]) % 4 * 64 + Base64ToValue(input[i + 3]); - output += static_cast(decoded); - } - } - } - - return output; -} - -GUID ParseKeyIdFromWrmHeader(const std::vector& wrm_header) { - // The wrm_header is an XML in wchar_t that contains the base64 encoded key - // id in node in base64. The original key id should be 16 characters, - // so it is 24 characters after based64 encoded. - const size_t kEncodedKeyIdLength = 24; - - SB_DCHECK(wrm_header.size() % 2 == 0); - std::wstring wrm_header_copy( - reinterpret_cast(wrm_header.data()), - wrm_header.size() / 2); - std::wstring::size_type begin = wrm_header_copy.find(L""); - if (begin == wrm_header_copy.npos) { - return WrmHeader::kInvalidKeyId; - } - std::wstring::size_type end = wrm_header_copy.find(L"", begin); - if (end == wrm_header_copy.npos) { - return WrmHeader::kInvalidKeyId; - } - begin += 5; - if (end - begin != kEncodedKeyIdLength) { - return WrmHeader::kInvalidKeyId; - } - - std::string key_id_in_string = - Base64Decode(wrm_header_copy.substr(begin, kEncodedKeyIdLength)); - if (key_id_in_string.size() != sizeof(GUID)) { - return WrmHeader::kInvalidKeyId; - } - - GUID key_id = *reinterpret_cast(key_id_in_string.data()); - - key_id.Data1 = _byteswap_ulong(key_id.Data1); - key_id.Data2 = _byteswap_ushort(key_id.Data2); - key_id.Data3 = _byteswap_ushort(key_id.Data3); - - return key_id; -} - -ComPtr CreateWrmHeaderStream(const std::vector& wrm_header) { - ComPtr stream; - HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); - if (FAILED(hr)) { - return NULL; - } - - DWORD wrm_header_size = static_cast(wrm_header.size()); - ULONG bytes_written = 0; - - if (wrm_header_size != 0) { - hr = stream->Write(wrm_header.data(), wrm_header_size, &bytes_written); - if (FAILED(hr)) { - return NULL; - } - } - - return stream; -} - -ComPtr CreateContentHeaderFromWrmHeader( - const std::vector& wrm_header) { - ComPtr content_header; - // Assume we use one license for one stream. - const DWORD kNumStreams = 1; - const DWORD kNextStreamId = static_cast(-1); - - HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, &content_header); - if (FAILED(hr)) { - return NULL; - } - - // Initialize spInitStm with the required data - // Format: (All DWORD values are serialized in little-endian order) - // [GUID (content protection system guid, see msprita.idl)] - // [DWORD (stream count, use the actual stream count even if all streams are - // encrypted using the same data, note that zero is invalid)] [DWORD (next - // stream ID, use -1 if all remaining streams are encrypted using the same - // data)] [DWORD (next stream's binary data size)] [BYTE* (next stream's - // binary data)] { Repeat from "next stream ID" above for each stream } - DWORD wrm_header_size = static_cast(wrm_header.size()); - ULONG bytes_written = 0; - hr = content_header->Write(&kPlayreadyContentHeaderCLSID, - sizeof(kPlayreadyContentHeaderCLSID), - &bytes_written); - if (FAILED(hr)) { - return NULL; - } - - hr = content_header->Write(&kNumStreams, sizeof(kNumStreams), &bytes_written); - if (FAILED(hr)) { - return NULL; - } - - hr = content_header->Write(&kNextStreamId, sizeof(kNextStreamId), - &bytes_written); - if (FAILED(hr)) { - return NULL; - } - - hr = content_header->Write(&wrm_header_size, sizeof(wrm_header_size), - &bytes_written); - if (FAILED(hr)) { - return NULL; - } - - if (0 != wrm_header_size) { - hr = content_header->Write(wrm_header.data(), wrm_header_size, - &bytes_written); - if (FAILED(hr)) { - return NULL; - } - } - - return content_header; -} - -ComPtr ResetStreamPosition(const ComPtr& stream) { - if (stream == NULL) { - return NULL; - } - LARGE_INTEGER seek_position = {0}; - HRESULT hr = stream->Seek(seek_position, STREAM_SEEK_SET, NULL); - CheckResult(hr); - return stream; -} - -} // namespace. - -// static -GUID WrmHeader::kInvalidKeyId; - -WrmHeader::WrmHeader(const void* initialization_data, - int initialization_data_size) { - wrm_header_ = ParseWrmHeaderFromInitializationData(initialization_data, - initialization_data_size); - key_id_ = ParseKeyIdFromWrmHeader(wrm_header_); -} - -ComPtr WrmHeader::content_header() const { - SB_DCHECK(is_valid()); - - if (key_id_ == kInvalidKeyId) { - return NULL; - } - return ResetStreamPosition(CreateContentHeaderFromWrmHeader(wrm_header_)); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/shared/win32/wrm_header.h b/starboard/shared/win32/wrm_header.h deleted file mode 100644 index c13cf69e7278..000000000000 --- a/starboard/shared/win32/wrm_header.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_SHARED_WIN32_WRM_HEADER_H_ -#define STARBOARD_SHARED_WIN32_WRM_HEADER_H_ - -#include -#include -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/types.h" - -namespace starboard { -namespace shared { -namespace win32 { - -class WrmHeader { - public: - WrmHeader(const void* initialization_data, int initialization_data_size); - - static GUID kInvalidKeyId; - - bool is_valid() const { - return key_id_ != kInvalidKeyId && !wrm_header_.empty(); - } - const GUID& key_id() const { - SB_DCHECK(is_valid()); - return key_id_; - } - Microsoft::WRL::ComPtr content_header() const; - const std::vector& wrm_header() const { return wrm_header_; } - - private: - GUID key_id_; - std::vector wrm_header_; -}; - -} // namespace win32 -} // namespace shared -} // namespace starboard - -#endif // STARBOARD_SHARED_WIN32_WRM_HEADER_H_ diff --git a/starboard/storage.h b/starboard/storage.h index 55db9509ddfc..696e2b54ac2f 100644 --- a/starboard/storage.h +++ b/starboard/storage.h @@ -31,9 +31,6 @@ #include "starboard/export.h" #include "starboard/types.h" -#if SB_API_VERSION < 16 -#include "starboard/user.h" -#endif // SB_API_VERSION < 16 #ifdef __cplusplus extern "C" { @@ -53,20 +50,6 @@ static inline bool SbStorageIsValidRecord(SbStorageRecord record) { return record != kSbStorageInvalidRecord; } -#if SB_API_VERSION < 16 -// Opens and returns the SbStorageRecord for |user| named |name|, blocking I/O -// on the calling thread until the open is completed. If |user| is not a valid -// |SbUser|, the function returns |kSbStorageInvalidRecord|. Will return an -// |SbStorageRecord| of size zero if the record does not yet exist. Opening an -// already-open |SbStorageRecord| has undefined behavior. -// -// If |name| is NULL, opens the default storage record for the user, like what -// would have been saved with the previous version of SbStorageOpenRecord. -// -// |user|: The user for which the storage record will be opened. -// |name|: The filesystem-safe name of the record to open. -SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name); -#else // SB_API_VERSION < 16 // Opens and returns the SbStorageRecord named |name|, blocking I/O // on the calling thread until the open is completed. Will return an // |SbStorageRecord| of size zero if the record does not yet exist. Opening an @@ -77,7 +60,6 @@ SB_EXPORT SbStorageRecord SbStorageOpenRecord(SbUser user, const char* name); // // |name|: The filesystem-safe name of the record to open. SB_EXPORT SbStorageRecord SbStorageOpenRecord(const char* name); -#endif // SB_API_VERSION < 16 // Closes |record|, synchronously ensuring that all written data is flushed. // This function performs blocking I/O on the calling thread. @@ -129,21 +111,6 @@ SB_EXPORT bool SbStorageWriteRecord(SbStorageRecord record, const char* data, int64_t data_size); -#if SB_API_VERSION < 16 -// Deletes the |SbStorageRecord| for |user| named |name|. The return value -// indicates whether the record existed and was successfully deleted. If the -// record did not exist or could not be deleted, the function returns |false|. -// -// If |name| is NULL, deletes the default storage record for the user, like what -// would have been deleted with the previous version of SbStorageDeleteRecord. -// -// This function must not be called while the user's storage record is open. -// This function performs blocking I/O on the calling thread. -// -// |user|: The user for whom the record will be deleted. -// |name|: The filesystem-safe name of the record to open. -SB_EXPORT bool SbStorageDeleteRecord(SbUser user, const char* name); -#else // SB_API_VERSION < 16 // Deletes the |SbStorageRecord| named |name|. The return value // indicates whether the record existed and was successfully deleted. If the // record did not exist or could not be deleted, the function returns |false|. @@ -156,7 +123,6 @@ SB_EXPORT bool SbStorageDeleteRecord(SbUser user, const char* name); // // |name|: The filesystem-safe name of the record to open. SB_EXPORT bool SbStorageDeleteRecord(const char* name); -#endif // SB_API_VERSION < 16 #ifdef __cplusplus } // extern "C" diff --git a/starboard/stub/BUILD.gn b/starboard/stub/BUILD.gn index 9001c81a3acb..f4d16a1b858d 100644 --- a/starboard/stub/BUILD.gn +++ b/starboard/stub/BUILD.gn @@ -38,8 +38,6 @@ static_library("stub_sources") { "//starboard/shared/starboard/command_line.h", "//starboard/shared/starboard/event_cancel.cc", "//starboard/shared/starboard/event_schedule.cc", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", - "//starboard/shared/starboard/memory.cc", "//starboard/shared/starboard/queue_application.cc", "//starboard/shared/stub/atomic_public.h", "//starboard/shared/stub/audio_sink_create.cc", @@ -50,21 +48,9 @@ static_library("stub_sources") { "//starboard/shared/stub/audio_sink_is_audio_frame_storage_type_supported.cc", "//starboard/shared/stub/audio_sink_is_audio_sample_type_supported.cc", "//starboard/shared/stub/audio_sink_is_valid.cc", - "//starboard/shared/stub/byte_swap.cc", - "//starboard/shared/stub/condition_variable_broadcast.cc", - "//starboard/shared/stub/condition_variable_create.cc", - "//starboard/shared/stub/condition_variable_destroy.cc", - "//starboard/shared/stub/condition_variable_signal.cc", - "//starboard/shared/stub/condition_variable_wait.cc", - "//starboard/shared/stub/condition_variable_wait_timed.cc", "//starboard/shared/stub/cpu_features_get.cc", "//starboard/shared/stub/decode_target_get_info.cc", "//starboard/shared/stub/decode_target_release.cc", - "//starboard/shared/stub/directory_can_open.cc", - "//starboard/shared/stub/directory_close.cc", - "//starboard/shared/stub/directory_create.cc", - "//starboard/shared/stub/directory_get_next.cc", - "//starboard/shared/stub/directory_open.cc", "//starboard/shared/stub/drm_close_session.cc", "//starboard/shared/stub/drm_create_system.cc", "//starboard/shared/stub/drm_destroy_system.cc", @@ -75,20 +61,6 @@ static_library("stub_sources") { "//starboard/shared/stub/drm_update_session.cc", "//starboard/shared/stub/environment.cc", "//starboard/shared/stub/file_atomic_replace.cc", - "//starboard/shared/stub/file_can_open.cc", - "//starboard/shared/stub/file_close.cc", - "//starboard/shared/stub/file_delete.cc", - "//starboard/shared/stub/file_exists.cc", - "//starboard/shared/stub/file_flush.cc", - "//starboard/shared/stub/file_get_info.cc", - "//starboard/shared/stub/file_get_path_info.cc", - "//starboard/shared/stub/file_open.cc", - "//starboard/shared/stub/file_read.cc", - "//starboard/shared/stub/file_seek.cc", - "//starboard/shared/stub/file_truncate.cc", - "//starboard/shared/stub/file_write.cc", - "//starboard/shared/stub/image_decode.cc", - "//starboard/shared/stub/image_is_decode_supported.cc", "//starboard/shared/stub/log.cc", "//starboard/shared/stub/log_flush.cc", "//starboard/shared/stub/log_format.cc", @@ -103,7 +75,6 @@ static_library("stub_sources") { "//starboard/shared/stub/media_get_buffer_allocation_unit.cc", "//starboard/shared/stub/media_get_buffer_garbage_collection_duration_threshold.cc", "//starboard/shared/stub/media_get_buffer_padding.cc", - "//starboard/shared/stub/media_get_buffer_storage_type.cc", "//starboard/shared/stub/media_get_initial_buffer_capacity.cc", "//starboard/shared/stub/media_get_max_buffer_capacity.cc", "//starboard/shared/stub/media_get_progressive_buffer_budget.cc", @@ -112,13 +83,9 @@ static_library("stub_sources") { "//starboard/shared/stub/media_is_buffer_using_memory_pool.cc", "//starboard/shared/stub/memory_allocate_aligned_unchecked.cc", "//starboard/shared/stub/memory_allocate_unchecked.cc", - "//starboard/shared/stub/memory_flush.cc", "//starboard/shared/stub/memory_free.cc", "//starboard/shared/stub/memory_free_aligned.cc", - "//starboard/shared/stub/memory_map.cc", - "//starboard/shared/stub/memory_protect.cc", "//starboard/shared/stub/memory_reallocate_unchecked.cc", - "//starboard/shared/stub/memory_unmap.cc", "//starboard/shared/stub/microphone_close.cc", "//starboard/shared/stub/microphone_create.cc", "//starboard/shared/stub/microphone_destroy.cc", @@ -126,12 +93,6 @@ static_library("stub_sources") { "//starboard/shared/stub/microphone_is_sample_rate_supported.cc", "//starboard/shared/stub/microphone_open.cc", "//starboard/shared/stub/microphone_read.cc", - "//starboard/shared/stub/mutex_acquire.cc", - "//starboard/shared/stub/mutex_acquire_try.cc", - "//starboard/shared/stub/mutex_create.cc", - "//starboard/shared/stub/mutex_destroy.cc", - "//starboard/shared/stub/mutex_release.cc", - "//starboard/shared/stub/once.cc", "//starboard/shared/stub/player_create.cc", "//starboard/shared/stub/player_destroy.cc", "//starboard/shared/stub/player_get_audio_configuration.cc", @@ -186,12 +147,6 @@ static_library("stub_sources") { "//starboard/shared/stub/storage_open_record.cc", "//starboard/shared/stub/storage_read_record.cc", "//starboard/shared/stub/storage_write_record.cc", - "//starboard/shared/stub/string_compare_no_case.cc", - "//starboard/shared/stub/string_compare_no_case_n.cc", - "//starboard/shared/stub/string_duplicate.cc", - "//starboard/shared/stub/string_format.cc", - "//starboard/shared/stub/string_format_wide.cc", - "//starboard/shared/stub/string_scan.cc", "//starboard/shared/stub/system_break_into_debugger.cc", "//starboard/shared/stub/system_clear_last_error.cc", "//starboard/shared/stub/system_egl.cc", @@ -225,53 +180,24 @@ static_library("stub_sources") { "//starboard/shared/stub/system_supports_resume.cc", "//starboard/shared/stub/system_symbolize.cc", "//starboard/shared/stub/thread_context_get_pointer.cc", - "//starboard/shared/stub/thread_create.cc", - "//starboard/shared/stub/thread_create_local_key.cc", "//starboard/shared/stub/thread_create_priority.cc", - "//starboard/shared/stub/thread_destroy_local_key.cc", - "//starboard/shared/stub/thread_detach.cc", - "//starboard/shared/stub/thread_get_current.cc", "//starboard/shared/stub/thread_get_id.cc", - "//starboard/shared/stub/thread_get_local_value.cc", - "//starboard/shared/stub/thread_get_name.cc", - "//starboard/shared/stub/thread_is_equal.cc", - "//starboard/shared/stub/thread_join.cc", "//starboard/shared/stub/thread_priority.cc", "//starboard/shared/stub/thread_sampler_create.cc", "//starboard/shared/stub/thread_sampler_destroy.cc", "//starboard/shared/stub/thread_sampler_freeze.cc", "//starboard/shared/stub/thread_sampler_is_supported.cc", "//starboard/shared/stub/thread_sampler_thaw.cc", - "//starboard/shared/stub/thread_set_local_value.cc", - "//starboard/shared/stub/thread_set_name.cc", "//starboard/shared/stub/thread_sleep.cc", "//starboard/shared/stub/thread_yield.cc", - "//starboard/shared/stub/time_get_monotonic_now.cc", - "//starboard/shared/stub/time_get_monotonic_thread_now.cc", - "//starboard/shared/stub/time_get_now.cc", - "//starboard/shared/stub/time_is_time_thread_now_supported.cc", "//starboard/shared/stub/time_zone_get_current.cc", "//starboard/shared/stub/time_zone_get_name.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/user_get_current.cc", - "//starboard/shared/stub/user_get_property.cc", - "//starboard/shared/stub/user_get_signed_in.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", "//starboard/shared/stub/window_create.cc", "//starboard/shared/stub/window_destroy.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", "//starboard/shared/stub/window_get_platform_handle.cc", "//starboard/shared/stub/window_get_size.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", "//starboard/shared/stub/window_set_default_options.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", ] public_configs = [ "//starboard/build/config:starboard_implementation" ] diff --git a/starboard/stub/configuration_constants.cc b/starboard/stub/configuration_constants.cc index db2439f62ba7..1f70040994ef 100644 --- a/starboard/stub/configuration_constants.cc +++ b/starboard/stub/configuration_constants.cc @@ -121,11 +121,6 @@ const char* kSbPathSepString = ":"; // generally prefer a byte order of RGBA, regardless of endianness. const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - // The maximum size the cache directory is allowed to use in bytes. const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB diff --git a/starboard/stub/configuration_public.h b/starboard/stub/configuration_public.h index 2ea3d945748e..80f29bfa6aa9 100644 --- a/starboard/stub/configuration_public.h +++ b/starboard/stub/configuration_public.h @@ -48,14 +48,6 @@ #define SB_IS_WCHAR_T_UNSIGNED 1 #endif -// --- Media Configuration --------------------------------------------------- - -#if SB_API_VERSION <= 15 -// The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only -// when this macro is defined. -#undef SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES -#endif // SB_API_VERSION <= 15 - // --- Network Configuration ------------------------------------------------- // Specifies whether this platform supports IPV6. diff --git a/starboard/thread.h b/starboard/thread.h index c7f3e9fc92ec..f706f9912a0d 100644 --- a/starboard/thread.h +++ b/starboard/thread.h @@ -103,178 +103,6 @@ SB_EXPORT bool SbThreadSetPriority(SbThreadPriority priority); SB_EXPORT bool SbThreadGetPriority(SbThreadPriority* priority); #endif -#if SB_API_VERSION < 16 -// An opaque handle to a thread type. -typedef void* SbThread; - -#define kSbThreadInvalid (SbThread) NULL - -// Function pointer type for SbThreadCreate. |context| is a pointer-sized bit -// of data passed in from the calling thread. -typedef void* (*SbThreadEntryPoint)(void* context); - -// Function pointer type for Thread-Local destructors. -typedef void (*SbThreadLocalDestructor)(void* value); - -// Type for thread core affinity. This generally will be a single cpu (or core -// or hyperthread) identifier. Some platforms may not support affinity, and some -// may have specific rules about how it must be used. -typedef int32_t SbThreadAffinity; - -// Private structure representing a thread-local key. -typedef struct SbThreadLocalKeyPrivate SbThreadLocalKeyPrivate; - -// A handle to a thread-local key. -typedef SbThreadLocalKeyPrivate* SbThreadLocalKey; - -// Well-defined constant value to mean "no affinity." -#define kSbThreadNoAffinity (SbThreadAffinity) kSbInvalidInt - -// Well-defined constant value to mean "no thread local key." -#define kSbThreadLocalKeyInvalid (SbThreadLocalKey) NULL - -// Returns whether the given thread handle is valid. -static inline bool SbThreadIsValid(SbThread thread) { - return thread != kSbThreadInvalid; -} - -// Returns whether the given thread affinity is valid. -static inline bool SbThreadIsValidAffinity(SbThreadAffinity affinity) { - return affinity != kSbThreadNoAffinity; -} - -// Returns whether the given thread local variable key is valid. -static inline bool SbThreadIsValidLocalKey(SbThreadLocalKey key) { - return key != kSbThreadLocalKeyInvalid; -} - -// Creates a new thread, which starts immediately. -// - If the function succeeds, the return value is a handle to the newly -// created thread. -// - If the function fails, the return value is |kSbThreadInvalid|. -// -// |stack_size|: The amount of memory reserved for the thread. Set the value -// to |0| to indicate that the default stack size should be used. -// |priority|: The thread's priority. This value can be set to -// |kSbThreadNoPriority| to use the platform's default priority. As examples, -// it could be set to a fixed, standard priority or to a priority inherited -// from the thread that is calling SbThreadCreate(), or to something else. -// |affinity|: The thread's affinity. This value can be set to -// |kSbThreadNoAffinity| to use the platform's default affinity. -// |joinable|: Indicates whether the thread can be joined (|true|) or should -// start out "detached" (|false|). Note that for joinable threads, when -// you are done with the thread handle, you must call |SbThreadJoin| to -// release system resources associated with the thread. This is not necessary -// for detached threads, but detached threads cannot be joined. -// |name|: A name used to identify the thread. This value is used mainly for -// debugging, it can be |NULL|, and it might not be used in production builds. -// |entry_point|: A pointer to a function that will be executed on the newly -// created thread. -// |context|: This value will be passed to the |entry_point| function. -SB_EXPORT SbThread SbThreadCreate(int64_t stack_size, - SbThreadPriority priority, - SbThreadAffinity affinity, - bool joinable, - const char* name, - SbThreadEntryPoint entry_point, - void* context); - -// Joins the thread on which this function is called with joinable |thread|. -// This function blocks the caller until the designated thread exits, and then -// cleans up that thread's resources. The cleanup process essentially detaches -// thread. -// -// The return value is |true| if the function is successful and |false| if -// |thread| is invalid or detached. -// -// Each joinable thread can only be joined once and must be joined to be fully -// cleaned up. Once SbThreadJoin is called, the thread behaves as if it were -// detached to all threads other than the joining thread. -// -// |thread|: The thread to which the current thread will be joined. The -// |thread| must have been created with SbThreadCreate. -// |out_return|: If this is not |NULL|, then the SbThreadJoin function populates -// it with the return value of the thread's |main| function. -SB_EXPORT bool SbThreadJoin(SbThread thread, void** out_return); - -// Detaches |thread|, which prevents it from being joined. This is sort of like -// a non-blocking join. This function is a no-op if the thread is already -// detached or if the thread is already being joined by another thread. -// -// |thread|: The thread to be detached. -SB_EXPORT void SbThreadDetach(SbThread thread); - -// Yields the currently executing thread, so another thread has a chance to run. -SB_EXPORT void SbThreadYield(); - -// Sleeps the currently executing thread. -// -// |duration|: The minimum amount of time, in microseconds, that the currently -// executing thread should sleep. The function is a no-op if this value is -// negative or |0|. -SB_EXPORT void SbThreadSleep(int64_t duration); - -// Returns the handle of the currently executing thread. -SB_EXPORT SbThread SbThreadGetCurrent(); - -// Indicates whether |thread1| and |thread2| refer to the same thread. -// -// |thread1|: The first thread to compare. -// |thread2|: The second thread to compare. -SB_EXPORT bool SbThreadIsEqual(SbThread thread1, SbThread thread2); - -// Returns the debug name of the currently executing thread. -SB_EXPORT void SbThreadGetName(char* buffer, int buffer_size); - -// Sets the debug name of the currently executing thread by copying the -// specified name string. -// -// |name|: The name to assign to the thread. -SB_EXPORT void SbThreadSetName(const char* name); - -// Creates and returns a new, unique key for thread local data. If the function -// does not succeed, the function returns |kSbThreadLocalKeyInvalid|. -// -// If |destructor| is specified, it will be called in the owning thread, and -// only in the owning thread, when the thread exits. In that case, it is called -// on the local value associated with the key in the current thread as long as -// the local value is not NULL. -// -// |destructor|: A pointer to a function. The value may be NULL if no clean up -// is needed. -SB_EXPORT SbThreadLocalKey -SbThreadCreateLocalKey(SbThreadLocalDestructor destructor); - -// Destroys thread local data for the specified key. The function is a no-op -// if the key is invalid (kSbThreadLocalKeyInvalid|) or has already been -// destroyed. This function does NOT call the destructor on any stored values. -// -// |key|: The key for which to destroy thread local data. -SB_EXPORT void SbThreadDestroyLocalKey(SbThreadLocalKey key); - -// Returns the pointer-sized value for |key| in the currently executing thread's -// local storage. Returns |NULL| if key is |kSbThreadLocalKeyInvalid| or if the -// key has already been destroyed. -// -// |key|: The key for which to return the value. -SB_EXPORT void* SbThreadGetLocalValue(SbThreadLocalKey key); - -// Sets the pointer-sized value for |key| in the currently executing thread's -// local storage. The return value indicates whether |key| is valid and has -// not already been destroyed. -// -// |key|: The key for which to set the key value. -// |value|: The new pointer-sized key value. -SB_EXPORT bool SbThreadSetLocalValue(SbThreadLocalKey key, void* value); - -// Returns whether |thread| is the current thread. -// -// |thread|: The thread to check. -static inline bool SbThreadIsCurrent(SbThread thread) { - return SbThreadGetCurrent() == thread; -} -#endif - // Private structure representing the context of a frozen thread. typedef struct SbThreadContextPrivate SbThreadContextPrivate; @@ -334,12 +162,8 @@ SB_EXPORT bool SbThreadSamplerIsSupported(); // Creates a new thread sampler for the specified |thread|. // // If successful, this function returns the newly created handle. -// If unsuccessful, this function returns |kSbThreadSamplerInvalid|. -#if SB_API_VERSION < 16 -SB_EXPORT SbThreadSampler SbThreadSamplerCreate(SbThread thread); -#else +// If unsuccessful, this function returns |kSbThreadSamplerInvalid| SB_EXPORT SbThreadSampler SbThreadSamplerCreate(pthread_t thread); -#endif // Destroys the |sampler| and frees whatever resources it was using. SB_EXPORT void SbThreadSamplerDestroy(SbThreadSampler sampler); diff --git a/starboard/time.h b/starboard/time.h index ab5c0bf66a88..a0f1a71cd291 100644 --- a/starboard/time.h +++ b/starboard/time.h @@ -19,98 +19,6 @@ #ifndef STARBOARD_TIME_H_ #define STARBOARD_TIME_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// The number of microseconds since the epoch of January 1, 1601 UTC, or the -// number of microseconds between two times. Always microseconds, ALWAYS UTC. -typedef int64_t SbTime; - -// A number of microseconds from some point. The main property of this time is -// that it increases monotonically. It should also be as high-resolution a timer -// as we can get on a platform. So, it is good for measuring the time between -// two calls without worrying about a system clock adjustment. It's not good -// for getting the wall clock time. -typedef int64_t SbTimeMonotonic; - -// How many nanoseconds in one SbTime unit (microseconds). -#define kSbTimeNanosecondsPerMicrosecond ((SbTime)1000) - -// One millisecond in SbTime units (microseconds). -#define kSbTimeMillisecond ((SbTime)1000) - -// One second in SbTime units (microseconds). -#define kSbTimeSecond (kSbTimeMillisecond * 1000) - -// One minute in SbTime units (microseconds). -#define kSbTimeMinute (kSbTimeSecond * 60) - -// One hour in SbTime units (microseconds). -#define kSbTimeHour (kSbTimeMinute * 60) - -// One day in SbTime units (microseconds). -#define kSbTimeDay (kSbTimeHour * 24) - -// The maximum value of an SbTime. -#define kSbTimeMax (kSbInt64Max) - -// A term that can be added to an SbTime to convert it into the number of -// microseconds since the POSIX epoch. -#define kSbTimeToPosixDelta (SB_INT64_C(-11644473600) * kSbTimeSecond) - -// Converts |SbTime| into microseconds from the POSIX epoch. -// -// |time|: A time that is either measured in microseconds since the epoch of -// January 1, 1601, UTC, or that measures the number of microseconds -// between two times. -static SB_C_FORCE_INLINE int64_t SbTimeToPosix(SbTime time) { - return time + kSbTimeToPosixDelta; -} - -// Converts microseconds from the POSIX epoch into an |SbTime|. -// -// |time|: A time that measures the number of microseconds since -// January 1, 1970, 00:00:00, UTC. -static SB_C_FORCE_INLINE SbTime SbTimeFromPosix(int64_t time) { - return time - kSbTimeToPosixDelta; -} - -// Safely narrows a number from a more precise unit to a less precise one. This -// function rounds negative values toward negative infinity. -static SB_C_FORCE_INLINE int64_t SbTimeNarrow(int64_t time, int64_t divisor) { - return time >= 0 ? time / divisor : (time - divisor + 1) / divisor; -} - -// Gets the current system time as an |SbTime|. -SB_EXPORT SbTime SbTimeGetNow(); - -// Gets a monotonically increasing time representing right now. -SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicNow(); - -// Returns whether the current platform supports time thread now -SB_EXPORT bool SbTimeIsTimeThreadNowSupported(); - -// Gets a monotonically increasing time representing how long the current -// thread has been in the executing state (i.e. not pre-empted nor waiting -// on an event). This is not necessarily total time and is intended to allow -// measuring thread execution time between two timestamps. If this is not -// available then SbTimeGetMonotonicNow() should be used. -SB_EXPORT SbTimeMonotonic SbTimeGetMonotonicThreadNow(); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_TIME_H_ diff --git a/starboard/tools/port_symlink.py b/starboard/tools/port_symlink.py index 26be7a68b17d..93a3cbe12ad9 100644 --- a/starboard/tools/port_symlink.py +++ b/starboard/tools/port_symlink.py @@ -21,30 +21,19 @@ import sys from starboard.tools import util -from starboard.tools import win_symlink # This file is still executed with Python2 in CI. # pylint:disable=consider-using-f-string -def IsWindows(): - return sys.platform in ['win32', 'cygwin'] - - def ToLongPath(path): """Converts to a path that supports long filenames.""" - if IsWindows(): - return win_symlink.ToDevicePath(path) - else: - return path + return path def IsSymLink(path): """Platform neutral version os os.path.islink().""" - if IsWindows(): - return win_symlink.IsReparsePoint(path) - else: - return os.path.islink(path) + return os.path.islink(path) def MakeSymLink(target_path, link_path): @@ -57,37 +46,26 @@ def MakeSymLink(target_path, link_path): Returns: None """ - if IsWindows(): - win_symlink.CreateReparsePoint(target_path, link_path) - else: - util.MakeDirs(os.path.dirname(link_path)) - os.symlink(target_path, link_path) + util.MakeDirs(os.path.dirname(link_path)) + os.symlink(target_path, link_path) def ReadSymLink(link_path): """Returns the path (abs. or rel.) to the folder referred to by link_path.""" - if IsWindows(): - path = win_symlink.ReadReparsePoint(link_path) - else: - try: - path = os.readlink(link_path) - except OSError: - path = None + try: + path = os.readlink(link_path) + except OSError: + path = None return path def DelSymLink(link_path): - if IsWindows(): - win_symlink.UnlinkReparsePoint(link_path) - else: - os.unlink(link_path) + os.unlink(link_path) def Rmtree(path): """See Rmtree() for documentation of this function.""" - if IsWindows(): - func = win_symlink.RmtreeShallow - elif not os.path.islink(path): + if not os.path.islink(path): func = shutil.rmtree else: os.unlink(path) @@ -97,10 +75,7 @@ def Rmtree(path): def OsWalk(root_dir, topdown=True, onerror=None, followlinks=False): - if IsWindows(): - return win_symlink.OsWalk(root_dir, topdown, onerror, followlinks) - else: - return os.walk(root_dir, topdown, onerror, followlinks) + return os.walk(root_dir, topdown, onerror, followlinks) def _CreateArgumentParser(): diff --git a/starboard/tools/port_symlink_test.py b/starboard/tools/port_symlink_test.py index 304c6e954dcd..f6bae33312c6 100644 --- a/starboard/tools/port_symlink_test.py +++ b/starboard/tools/port_symlink_test.py @@ -107,8 +107,7 @@ def testRmtreeRemovesBrokenLink(self): # os.path.exists() will return false for broken links (not true for reparse # points on Windows) since their target does not exist. Rmtree # implementations should still be able to remove the link. - if not port_symlink.IsWindows(): - self.assertFalse(os.path.exists(self.link_dir)) + self.assertFalse(os.path.exists(self.link_dir)) self.assertTrue(IsSymLink(self.link_dir)) Rmtree(self.link_dir) self.assertFalse(IsSymLink(self.link_dir)) diff --git a/starboard/tools/win_symlink.py b/starboard/tools/win_symlink.py deleted file mode 100644 index 8c0505ded818..000000000000 --- a/starboard/tools/win_symlink.py +++ /dev/null @@ -1,288 +0,0 @@ -#!/usr/bin/python -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Provides functions for symlinking on Windows. - -Reparse points: Are os-level symlinks for folders which can be created without -admin access. Symlinks for folders are supported using this mechanism. Note -that reparse points require special care for traversal, because reparse points -are often skipped or treated as files by the various python path manipulation -functions in os and shutil modules. rmtree() as a replacement for -shutil.rmtree() is provided. - -""" - -import logging -import os -import re -import shutil -import stat -import subprocess -import time - -_RETRY_TIMES = 10 - - -def ToDevicePath(dos_path, encoding=None): - r"""Convert to a device path to avoid MAX_PATH limits on Windows. - - https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation - - Args: - dos_path: Path to a file that's not already a device path. - encoding: Optional character encoding of dos_path, if it's not unicode. - - Returns: - Absolute device path starting with "\\?\". - """ - # This type is compatible with both python 2 and 3. - unicode_type = type('') - if not isinstance(dos_path, unicode_type) and encoding is not None: - dos_path = dos_path.decode(encoding) - path = os.path.abspath(dos_path) - if path.startswith('\\\\'): - return '\\\\?\\UNC\\' + path[2:] - return '\\\\?\\' + path - - -def _RemoveEmptyDirectory(path): - """Removes a directory with retry amounts.""" - for i in range(0, _RETRY_TIMES): - try: - os.chmod(path, stat.S_IWRITE) - os.rmdir(path) - return - except Exception: # pylint: disable=broad-except - if i == _RETRY_TIMES - 1: - raise - else: - time.sleep(.1) - - -def _RmtreeOsWalk(root_dir): - """Walks the directory structure to delete directories and files.""" - del_dirs = [] # Defer deletion of directories. - if IsReparsePoint(root_dir): - UnlinkReparsePoint(root_dir) - return - for root, dirs, files in OsWalk(root_dir, followlinks=False): - for name in files: - path = os.path.join(root, name) - os.remove(path) - for name in dirs: - path = os.path.join(root, name) - if IsReparsePoint(path): - UnlinkReparsePoint(path) - else: - del_dirs.append(path) - # At this point, all files should be deleted and all symlinks should be - # unlinked. - for d in del_dirs + [root_dir]: - try: - if os.path.isdir(d): - shutil.rmtree(d) - except Exception as err: # pylint: disable=broad-except - logging.exception('Error while deleting: %s', err) - - -def _RmtreeShellCmd(root_dir): - subprocess.call(['cmd', '/c', 'rmdir', '/S', '/Q', root_dir]) - - -def RmtreeShallow(root_dir): - """Emulates shutil.rmtree on linux. - - Will delete symlinks but doesn't follow them. Note that shutil.rmtree on - windows will follow the symlink and delete the files in the original - directory! - - Args: - root_dir: The start path to delete files. - """ - try: - # This can fail if there are very long file names. - _RmtreeOsWalk(root_dir) - except OSError: - # This fallback will handle very long file. Note that it is VERY slow - # in comparison to the _RmtreeOsWalk() version. - _RmtreeShellCmd(root_dir) - if os.path.isdir(root_dir): - logging.error('Directory %s still exists.', root_dir) - - -def ReadReparsePointShell(path): - """Implements reading a reparse point via a shell command.""" - cmd_parts = ['cmd', '/C', 'dir', os.path.dirname(path)] - try: - out = subprocess.check_output(cmd_parts) - except subprocess.CalledProcessError: - # Expected if the link doesn't exist. - return None - try: - pattern = re.compile(f'.*[ ]+{os.path.basename(path)} \\[(.*)]') - for l in out.splitlines(): - m = pattern.match(l) - if m: - return m.group(1) - except Exception as err: # pylint: disable=broad-except - logging.exception(err) - return None - - -def ReadReparsePoint(path): - """Mimics os.readlink for usage.""" - try: - # pylint: disable=import-outside-toplevel - from starboard.tools import win_symlink_fast - return win_symlink_fast.FastReadReparseLink(path) - except Exception as err: # pylint: disable=broad-except - logging.exception(' error: %s, falling back to command line version.', err) - return ReadReparsePointShell(path) - - -def IsReparsePoint(path): - """Mimics os.islink for usage.""" - try: - # pylint: disable=import-outside-toplevel - from starboard.tools import win_symlink_fast - return win_symlink_fast.FastIsReparseLink(path) - except Exception as err: # pylint: disable=broad-except - logging.exception(' error: %s, falling back to command line version.', err) - return None is not ReadReparsePointShell(path) - - -def CreateReparsePoint(from_folder, link_folder): - """Mimics os.symlink for usage. - - Args: - from_folder: Path of target directory. - link_folder: Path to create link. - - Returns: - None. - - Raises: - OSError: if link cannot be created - """ - if os.path.isdir(link_folder): - _RemoveEmptyDirectory(link_folder) - else: - UnlinkReparsePoint(link_folder) # Deletes if it exists. - try: - # pylint: disable=import-outside-toplevel - from starboard.tools import win_symlink_fast - win_symlink_fast.FastCreateReparseLink(from_folder, link_folder) - return - except OSError: - pass - except Exception as err: # pylint: disable=broad-except - logging.exception( - 'unexpected error: %s, from=%s, link=%s, falling back to ' - 'command line version.', err, from_folder, link_folder) - par_dir = os.path.dirname(link_folder) - if not os.path.isdir(par_dir): - os.makedirs(par_dir) - try: - subprocess.check_output( - ['cmd', '/c', 'mklink', '/d', link_folder, from_folder], - stderr=subprocess.STDOUT) - except subprocess.CalledProcessError: - # Fallback to junction points, which require less privileges to create. - subprocess.check_output( - ['cmd', '/c', 'mklink', '/j', link_folder, from_folder]) - if not IsReparsePoint(link_folder): - raise OSError(f'Could not create sym link {link_folder} to {from_folder}') - - -def UnlinkReparsePoint(link_dir): - """Mimics os.unlink for usage. The sym link_dir is removed.""" - if not IsReparsePoint(link_dir): - return - cmd_parts = ['fsutil', 'reparsepoint', 'delete', link_dir] - subprocess.check_output(cmd_parts) - # The folder will now be unlinked, but will still exist. - if os.path.isdir(link_dir): - try: - _RemoveEmptyDirectory(link_dir) - except Exception as err: # pylint: disable=broad-except - logging.exception('could not remove %s because of %s', link_dir, err) - if IsReparsePoint(link_dir): - raise IOError(f'Link still exists: {ReadReparsePoint(link_dir)}') - if os.path.isdir(link_dir): - logging.info('WARNING - Link as folder still exists: %s', link_dir) - - -def _IsSamePath(p1, p2): - """Returns true if p1 and p2 represent the same path.""" - if not p1: - p1 = None - if not p2: - p2 = None - if p1 == p2: - return True - if (not p1) or (not p2): - return False - p1 = os.path.abspath(os.path.normpath(p1)) - p2 = os.path.abspath(os.path.normpath(p2)) - if p1 == p2: - return True - try: - return os.stat(p1) == os.stat(p2) - except Exception: # pylint: disable=broad-except - return False - - -def OsWalk(top, topdown=True, onerror=None, followlinks=False): - """Emulates os.walk() on linux. - - Args: - top: see os.walk(...) - topdown: see os.walk(...) - onerror: see os.walk(...) - followlinks: see os.walk(...) - - Yields: - see os.walk(...) - - Correctly handles windows reparse points as symlinks. - All symlink directories are returned in the directory list and the caller must - call IsReparsePoint() on the path to determine whether the directory is - real or a symlink. - """ - # Need an absolute path to use listdir and isdir with long paths. - top_abs_path = top - if not os.path.isabs(top_abs_path): - top_abs_path = os.path.join(os.getcwd(), top_abs_path) - top_abs_path = ToDevicePath(top) - try: - names = os.listdir(top_abs_path) - except OSError as err: - if onerror is not None: - onerror(err) - return - dirs, nondirs = [], [] - for name in names: - if os.path.isdir(os.path.join(top_abs_path, name)): - dirs.append(name) - else: - nondirs.append(name) - if topdown: - yield top, dirs, nondirs - for name in dirs: - new_path = os.path.join(top, name) - if followlinks or not IsReparsePoint(new_path): - for x in OsWalk(new_path, topdown, onerror, followlinks): - yield x - if not topdown: - yield top, dirs, nondirs diff --git a/starboard/tools/win_symlink_fast.py b/starboard/tools/win_symlink_fast.py deleted file mode 100644 index 8c5e9407b174..000000000000 --- a/starboard/tools/win_symlink_fast.py +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/python -# Copyright 2019 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Provides functions for symlinking on Windows.""" - -import ctypes -from ctypes import wintypes -import os - -DWORD = wintypes.DWORD -LPCWSTR = wintypes.LPCWSTR -HANDLE = wintypes.HANDLE -LPVOID = wintypes.LPVOID -BOOL = wintypes.BOOL -USHORT = wintypes.USHORT -ULONG = wintypes.ULONG -WCHAR = wintypes.WCHAR - -kernel32 = ctypes.windll.kernel32 -LPDWORD = ctypes.POINTER(DWORD) -UCHAR = ctypes.c_ubyte - -GetFileAttributesW = kernel32.GetFileAttributesW -GetFileAttributesW.restype = DWORD -GetFileAttributesW.argtypes = (LPCWSTR,) # lpFileName In - -INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF -FILE_ATTRIBUTE_REPARSE_POINT = 0x00400 - -CreateFileW = kernel32.CreateFileW -CreateFileW.restype = HANDLE -CreateFileW.argtypes = ( - LPCWSTR, # lpFileName In - DWORD, # dwDesiredAccess In - DWORD, # dwShareMode In - LPVOID, # lpSecurityAttributes In_opt - DWORD, # dwCreationDisposition In - DWORD, # dwFlagsAndAttributes In - HANDLE) # hTemplateFile In_opt - -CloseHandle = kernel32.CloseHandle -CloseHandle.restype = BOOL -CloseHandle.argtypes = (HANDLE,) # hObject In - -INVALID_HANDLE_VALUE = HANDLE(-1).value # pylint:disable=invalid-name -OPEN_EXISTING = 3 -FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 -FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 - -DeviceIoControl = kernel32.DeviceIoControl -DeviceIoControl.restype = BOOL -DeviceIoControl.argtypes = ( - HANDLE, # hDevice In - DWORD, # dwIoControlCode In - LPVOID, # lpInBuffer In_opt - DWORD, # nInBufferSize In - LPVOID, # lpOutBuffer Out_opt - DWORD, # nOutBufferSize In - LPDWORD, # lpBytesReturned Out_opt - LPVOID) # lpOverlapped Inout_opt - -FSCTL_GET_REPARSE_POINT = 0x000900A8 -IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 -IO_REPARSE_TAG_SYMLINK = 0xA000000C -MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 0x4000 -SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 -# Developer Mode must be enabled in order to use the following flag. -SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2 -SYMLINK_FLAG_RELATIVE = 0x1 - - -class GenericReparseBuffer(ctypes.Structure): - """Win32 api data structure.""" - _fields_ = (('DataBuffer', UCHAR * 1),) - - -class SymbolicLinkReparseBuffer(ctypes.Structure): - """Win32 api data structure.""" - - _fields_ = (('SubstituteNameOffset', USHORT), - ('SubstituteNameLength', USHORT), ('PrintNameOffset', USHORT), - ('PrintNameLength', USHORT), ('Flags', ULONG), ('PathBuffer', - WCHAR * 1)) - - @property - def print_name(self): - arrayt = WCHAR * (self.PrintNameLength // 2) - offset = type(self).PathBuffer.offset + self.PrintNameOffset - return arrayt.from_address(ctypes.addressof(self) + offset).value - - @property - def substitute_name(self): - arrayt = WCHAR * (self.SubstituteNameLength // 2) - offset = type(self).PathBuffer.offset + self.SubstituteNameOffset - return arrayt.from_address(ctypes.addressof(self) + offset).value - - @property - def is_relative_path(self): - return bool(self.Flags & SYMLINK_FLAG_RELATIVE) - - -class MountPointReparseBuffer(ctypes.Structure): - """Win32 api data structure.""" - _fields_ = (('SubstituteNameOffset', USHORT), - ('SubstituteNameLength', USHORT), ('PrintNameOffset', USHORT), - ('PrintNameLength', USHORT), ('PathBuffer', WCHAR * 1)) - - @property - def print_name(self): - arrayt = WCHAR * (self.PrintNameLength // 2) - offset = type(self).PathBuffer.offset + self.PrintNameOffset - return arrayt.from_address(ctypes.addressof(self) + offset).value - - @property - def substitute_name(self): - arrayt = WCHAR * (self.SubstituteNameLength // 2) - offset = type(self).PathBuffer.offset + self.SubstituteNameOffset - return arrayt.from_address(ctypes.addressof(self) + offset).value - - -class ReparseDataBuffer(ctypes.Structure): - """Win32 api data structure.""" - - class ReparseBuffer(ctypes.Union): - """Win32 api data structure.""" - _fields_ = (('SymbolicLinkReparseBuffer', SymbolicLinkReparseBuffer), - ('MountPointReparseBuffer', MountPointReparseBuffer), - ('GenericReparseBuffer', GenericReparseBuffer)) - - _fields_ = (('ReparseTag', ULONG), ('ReparseDataLength', USHORT), - ('Reserved', USHORT), ('ReparseBuffer', ReparseBuffer)) - _anonymous_ = ('ReparseBuffer',) - - -def _ToUnicode(s): - try: - return s.decode('utf-8') - except AttributeError: - return s - - -_kdll = None - - -def _GetKernel32Dll(): - global _kdll - if _kdll: - return _kdll - _kdll = ctypes.windll.LoadLibrary('kernel32.dll') - return _kdll - - -def FastCreateReparseLink(from_folder, link_folder): - """Creates a reparse link. - - Args: - from_folder: The folder that the link will point to. - link_folder: The path of the link to be created. - - Returns: - None - - Raises: - OSError: if link cannot be created - """ - from_folder = _ToUnicode(from_folder) - link_folder = _ToUnicode(link_folder) - par_dir = os.path.dirname(link_folder) - if not os.path.isdir(par_dir): - os.makedirs(par_dir) - kdll = _GetKernel32Dll() - # Only supported from Windows 10 Insiders build 14972 - flags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE | \ - SYMBOLIC_LINK_FLAG_DIRECTORY - ok = kdll.CreateSymbolicLinkW(link_folder, from_folder, flags) - if not ok or not FastIsReparseLink(link_folder): - raise OSError('Could not create sym link ' + link_folder + ' to ' + - from_folder) - - -def FastIsReparseLink(path): - path = _ToUnicode(path) - result = GetFileAttributesW(path) - if result == INVALID_FILE_ATTRIBUTES: - return False - return bool(result & FILE_ATTRIBUTE_REPARSE_POINT) - - -def FastReadReparseLink(path): - """See api docstring, above.""" - path = _ToUnicode(path) - reparse_point_handle = CreateFileW( - path, 0, 0, None, OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, None) - if reparse_point_handle == INVALID_HANDLE_VALUE: - return None - # Remove false positive below. - # pylint: disable=deprecated-method - target_buffer = ctypes.c_buffer(MAXIMUM_REPARSE_DATA_BUFFER_SIZE) - n_bytes_returned = DWORD() - io_result = DeviceIoControl(reparse_point_handle, FSCTL_GET_REPARSE_POINT, - None, 0, target_buffer, len(target_buffer), - ctypes.byref(n_bytes_returned), None) - CloseHandle(reparse_point_handle) - if not io_result: - return None - rdb = ReparseDataBuffer.from_buffer(target_buffer) - if rdb.ReparseTag == IO_REPARSE_TAG_SYMLINK: - return rdb.SymbolicLinkReparseBuffer.print_name - elif rdb.ReparseTag == IO_REPARSE_TAG_MOUNT_POINT: - return rdb.MountPointReparseBuffer.print_name - return None diff --git a/starboard/tools/win_symlink_fast_test.py b/starboard/tools/win_symlink_fast_test.py deleted file mode 100644 index f828de54dc2f..000000000000 --- a/starboard/tools/win_symlink_fast_test.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2019 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Tests the win_symlink_fast functionality.""" - -import sys -import unittest - -if __name__ == '__main__' and sys.platform == 'win32': - from starboard.tools import port_symlink_test # pylint: disable=g-import-not-at-top - from starboard.tools import util # pylint: disable=g-import-not-at-top - from starboard.tools import win_symlink # pylint: disable=g-import-not-at-top - from starboard.tools import win_symlink_fast # pylint: disable=g-import-not-at-top - - # Override the port_symlink_test symlink functions to point to our win_symlink - # and win_symlink_fast versions. - def MakeSymLink(*args, **kwargs): - return win_symlink_fast.FastCreateReparseLink(*args, **kwargs) - - def IsSymLink(*args, **kwargs): - return win_symlink_fast.FastIsReparseLink(*args, **kwargs) - - def ReadSymLink(*args, **kwargs): - return win_symlink_fast.FastReadReparseLink(*args, **kwargs) - - def Rmtree(*args, **kwargs): - return win_symlink.RmtreeShallow(*args, **kwargs) - - def OsWalk(*args, **kwargs): - return win_symlink.OsWalk(*args, **kwargs) - - port_symlink_test.MakeSymLink = MakeSymLink - port_symlink_test.IsSymLink = IsSymLink - port_symlink_test.ReadSymLink = ReadSymLink - port_symlink_test.Rmtree = Rmtree - port_symlink_test.OsWalk = OsWalk - - # Makes a unit test available to the unittest.main (through magic). - class WinSymlinkTest(port_symlink_test.PortSymlinkTest): - pass - - util.SetupDefaultLoggingConfig() - unittest.main(verbosity=2) diff --git a/starboard/tools/win_symlink_test.py b/starboard/tools/win_symlink_test.py deleted file mode 100644 index 4ea889a82b4b..000000000000 --- a/starboard/tools/win_symlink_test.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Tests win_symlink.""" - -import os -import shutil -import sys -import tempfile -import unittest - -if __name__ == '__main__' and sys.platform == 'win32': - from starboard.tools import port_symlink_test # pylint: disable=g-import-not-at-top - from starboard.tools import util # pylint: disable=g-import-not-at-top - from starboard.tools import win_symlink # pylint: disable=g-import-not-at-top - - # Override the port_symlink_test symlink functions to point to our win_symlink - # versions. - def MakeSymLink(*args, **kwargs): - return win_symlink.CreateReparsePoint(*args, **kwargs) - - def IsSymLink(*args, **kwargs): - return win_symlink.IsReparsePoint(*args, **kwargs) - - def ReadSymLink(*args, **kwargs): - return win_symlink.ReadReparsePoint(*args, **kwargs) - - def Rmtree(*args, **kwargs): - return win_symlink.RmtreeShallow(*args, **kwargs) - - def OsWalk(*args, **kwargs): - return win_symlink.OsWalk(*args, **kwargs) - - port_symlink_test.MakeSymLink = MakeSymLink - port_symlink_test.IsSymLink = IsSymLink - port_symlink_test.ReadSymLink = ReadSymLink - port_symlink_test.Rmtree = Rmtree - port_symlink_test.OsWalk = OsWalk - - # Makes a unit test available to the unittest.main (through magic). - class WinSymlinkTest(port_symlink_test.PortSymlinkTest): - - def testRmtreeOsWalkDoesNotFollowSymlinks(self): - """_RmtreeOsWalk(...) will delete the symlink and not the target.""" - external_temp_dir = tempfile.mkdtemp() - try: - external_temp_file = os.path.join(external_temp_dir, 'test.txt') - with open(external_temp_file, 'w', encoding='utf-8') as fd: - fd.write('HI') - link_dir = os.path.join(self.tmp_dir, 'foo', 'link_dir') - MakeSymLink(external_temp_file, link_dir) - win_symlink._RmtreeOsWalk(self.tmp_dir) # pylint:disable=protected-access - # The target file should still exist - self.assertTrue(os.path.isfile(external_temp_file)) - finally: - shutil.rmtree(external_temp_dir, ignore_errors=True) - - def testRmtreeCmdShellDoesNotFollowSymlinks(self): - """_RmtreeShellCmd(...) will delete the symlink and not the target.""" - external_temp_dir = tempfile.mkdtemp() - try: - external_temp_file = os.path.join(external_temp_dir, 'test.txt') - with open(external_temp_file, 'w', encoding='utf-8') as fd: - fd.write('HI') - link_dir = os.path.join(self.tmp_dir, 'foo', 'link_dir') - MakeSymLink(external_temp_file, link_dir) - win_symlink._RmtreeShellCmd(self.tmp_dir) # pylint:disable=protected-access - # The target file should still exist - self.assertTrue(os.path.isfile(external_temp_file)) - finally: - shutil.rmtree(external_temp_dir, ignore_errors=True) - - util.SetupDefaultLoggingConfig() - unittest.main(verbosity=2) diff --git a/starboard/ui_navigation.h b/starboard/ui_navigation.h index 6363b2d383fb..16729a4ec8f5 100644 --- a/starboard/ui_navigation.h +++ b/starboard/ui_navigation.h @@ -33,283 +33,6 @@ #ifndef STARBOARD_UI_NAVIGATION_H_ #define STARBOARD_UI_NAVIGATION_H_ -#if SB_API_VERSION < 16 - -#include "starboard/configuration.h" -#include "starboard/export.h" -#include "starboard/types.h" -#include "starboard/window.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// --- Types ----------------------------------------------------------------- - -// An opaque handle to an implementation-private structure representing a -// navigation item. -typedef struct SbUiNavItemPrivate* SbUiNavItem; - -// Navigation items may be one of the following types. This must be specified -// upon item creation and may not change during the item's lifespan. -typedef enum SbUiNavItemType { - // This is a single focusable item. - kSbUiNavItemTypeFocus, - - // This is a container of navigation items which can also be containers - // themselves or focusable items. Containers themselves cannot be focused. - kSbUiNavItemTypeContainer, -} SbUiNavItemType; - -// Navigation items of type kSbUiNavItemTypeContainer have directionality. If -// directionality is not specified for a container, it should default to -// left-to-right and top-to-bottom. -// @verbatim -// For left-to-right, content offset x = 0 shows the leftmost content. -// |<--Container Size-->| -// +--------------------+--------------------+--------------------+ -// | Not selectable. | Selectable. | Selectable. | -// | Offscreen. | Onscreen. | Offscreen. | -// | Negative position. | Positive position. | Positive position. | -// +--------------------+--------------------+--------------------+ -// ^ -// Content Offset X = 0. -// -// For right-to-left, content offset x = 0 shows the rightmost content. -// |<--Container Size-->| -// +--------------------+--------------------+--------------------+ -// | Selectable. | Selectable. | Not selectable. | -// | Offscreen. | Onscreen. | Offscreen. | -// | Negative position. | Positive position. | Positive position. | -// +--------------------+--------------------+--------------------+ -// ^ -// Content Offset X = 0. @endverbatim -// -// Top-to-bottom is similar to left-to-right, but for the Y position. -// Bottom-to-top is similar to right-to-left, but for the Y position. -typedef struct SbUiNavItemDir { - bool is_left_to_right; - bool is_top_to_bottom; -} SbUiNavItemDir; - -// This represents a 2x3 transform matrix in row-major order. -// @verbatim -// | a b tx | -// | c d ty | @endverbatim -typedef struct SbUiNavMatrix2x3 { - float m[6]; -} SbUiNavMatrix2x3; - -// This represents a 4x4 transform matrix in row-major order. -typedef struct SbUiNavMatrix4 { - float m[16]; -} SbUiNavMatrix4; - -// This structure specifies all the callbacks which the platform UI engine -// should invoke for various interaction events on navigation items. These -// callbacks may be invoked from any thread at any frequency. The -// |callback_context| is the value that was passed on creation of the -// relevant SbUiNavItem. -typedef struct SbUiNavCallbacks { - // Invoke when an item has lost focus. This is only used with focus items. - void (*onblur)(SbUiNavItem item, void* callback_context); - - // Invoke when an item has gained focus. This is only used with focus items. - void (*onfocus)(SbUiNavItem item, void* callback_context); - - // Invoke when an item's content offset is changed. This is only used with - // container items. - void (*onscroll)(SbUiNavItem item, void* callback_context); -} SbUiNavCallbacks; - -// This structure declares the interface to the UI navigation implementation. -// All function pointers must be specified if the platform supports UI -// navigation. -typedef struct SbUiNavInterface { - // Create a new navigation item. When the user interacts with this item - // the appropriate SbUiNavCallbacks function will be invoked with the - // provided |callback_context|. An item is not interactable until it is - // enabled. - SbUiNavItem (*create_item)(SbUiNavItemType type, - const SbUiNavCallbacks* callbacks, - void* callback_context); - - // Destroy the given navigation item. If this is a content of another item, - // then it will first be unregistered. Additionally, if this item contains - // other items, then those will be unregistered as well, but they will not - // be automatically destroyed. - void (*destroy_item)(SbUiNavItem item); - - // This is used to manually force focus on a navigation item of type - // kSbUiNavItemTypeFocus. Any previously focused navigation item should - // receive the blur event. If the item is not transitively a content of the - // root item, then this does nothing. - // - // Specifying kSbUiNavItemInvalid should remove focus from the UI navigation - // system. - void (*set_focus)(SbUiNavItem item); - - // This is used to enable or disable user interaction with the specified - // navigation item. All navigation items are disabled when created, and - // they must be explicitly enabled to allow user interaction. If a container - // is disabled, then all of its contents are not interactable even though - // they remain enabled. If |enabled| is false, it must be guaranteed that - // once this function returns, no callbacks associated with this item will - // be invoked until the item is re-enabled. - void (*set_item_enabled)(SbUiNavItem item, bool enabled); - - // This specifies directionality for container items. Containers within - // containers do not inherit directionality. Directionality must be specified - // for each container explicitly. - // - // This should work even if |item| is disabled. - void (*set_item_dir)(SbUiNavItem item, SbUiNavItemDir dir); - - // Set the minimum amount of time the focus item should remain focused once - // it becomes focused. This may be used to make important focus items harder - // to navigate over. Focus may still be moved before |seconds| has elapsed by - // using the set_focus() function. - // By default, item focus duration is 0 seconds. - void (*set_item_focus_duration)(SbUiNavItem item, float seconds); - - // Set the interactable size of the specified navigation item. By default, - // an item's size is (0,0). - void (*set_item_size)(SbUiNavItem item, float width, float height); - - // Set the transform for the navigation item and its contents if the item is - // a container. This specifies the placement of the item's center within its - // container. The transform origin is the center of the item. Distance is - // measured in pixels with the origin being the top-left of the item's - // container. By default, an item's transform is identity. - void (*set_item_transform)(SbUiNavItem item, - const SbUiNavMatrix2x3* transform); - - // Retrieve the focus transform matrix for the navigation item. The UI - // engine may translate, rotate, and/or tilt focus items to reflect user - // interaction. This transform should be multiplied with the item's transform - // to get its position inside its container. The transform origin is the - // center of the item. Return false if the item position should not be - // changed (i.e. the transform should be treated as identity). - bool (*get_item_focus_transform)(SbUiNavItem item, - SbUiNavMatrix4* out_transform); - - // Retrieve a vector representing the focus location within a focused item. - // This is used to provide feedback about user input that is too small to - // result in a focus change. If there is no focus vector for the navigation - // item, then return false and leave |out_x| and |out_y| unchanged. Otherwise, - // return true and set the output values in the range of [-1, +1] with - // (out_x, out_y) of (-1, -1) being the top-left corner of the navigation - // item and (0, 0) being the center. - bool (*get_item_focus_vector)(SbUiNavItem item, float* out_x, float* out_y); - - // This attaches the given navigation item (which must be a container) to - // the specified window. Navigation items are only interactable if they are - // transitively attached to a window. - // - // The native UI engine should never change this navigation item's content - // offset. It is assumed to be used as a proxy for the system window. - // - // A navigation item may only have a SbUiNavItem or SbWindow as its direct - // container. The navigation item hierarchy is established using - // set_item_container_item() with the root container attached to a SbWindow - // using set_item_container_window() to enable interaction with all enabled - // items in the hierarchy. - // - // If |item| is already registered with a different window, then this will - // unregister it from that window then attach it to the given |window|. It - // is an error to register more than one navigation item with any given - // window. If |window| is kSbWindowInvalid, then this will unregister the - // |item| from its current window if any. Upon destruction of |item| or - // |window|, the |item| is automatically unregistered from the |window|. - void (*set_item_container_window)(SbUiNavItem item, SbWindow window); - - // A container navigation item may contain other navigation items. However, - // it is an error to have circular containment or for |container| to not - // be of type kSbUiNavItemTypeContainer. If |item| already has a different - // container, then this first serves that connection. If |container| is - // kSbUiNavItemInvalid, then this removes |item| from its current container. - // Upon destruction of |item| or |container|, the |item| is automatically - // removed from the |container|. - // - // The position of items within a container are specified relative to the - // container's position. The position of these content items are further - // modified by the container's "content offset". - // - // For example, consider item A with position (5,5) and content offset (0,0). - // Given item B with position (10,10) is registered as a content of item A. - // - // 1) Item B should be drawn at position (15,15). - // - // 2) If item A's content offset is changed to (10,0), then item B should be - // drawn at position (5,15). - // - // Essentially, content items should be drawn at: - // [container position] + [content position] - [container content offset] - // - // Content items may overlap within a container. This can cause obscured items - // to be unfocusable. The only rule that needs to be followed is that contents - // which are focus items can obscure other contents which are containers, but - // not vice versa. The caller must ensure that content focus items do not - // overlap other content focus items and content container items do not - // overlap other content container items. - void (*set_item_container_item)(SbUiNavItem item, SbUiNavItem container); - - // Set the current content offset for the given container. This may be used - // to force scrolling to make certain content items visible. A container - // item's content offset helps determine where its content items should be - // drawn. Essentially, a content item should be drawn at: - // [container position] + [content position] - [container content offset] - // If |item| is not a container, then this does nothing. - // By default, the content offset is (0,0). - // - // This should update the values returned by get_item_content_offset() even - // if the |item| is disabled. - void (*set_item_content_offset)(SbUiNavItem item, - float content_offset_x, - float content_offset_y); - - // Retrieve the current content offset for the navigation item. If |item| is - // not a container, then the content offset is (0,0). - // - // The native UI engine should not change the content offset of a container - // unless one of its contents (possibly recursively) is focused. This is to - // allow seamlessly disabling then re-enabling focus items without having - // their containers change offsets. - void (*get_item_content_offset)(SbUiNavItem item, - float* out_content_offset_x, - float* out_content_offset_y); - - // Call |update_function| with |context| to perform a series of UI navigation - // changes atomically before returning. - void (*do_batch_update)(void (*update_function)(void*), void* context); -} SbUiNavInterface; - -// --- Constants ------------------------------------------------------------- - -// Well-defined value for an invalid navigation item. -#define kSbUiNavItemInvalid ((SbUiNavItem)NULL) - -// --- Functions ------------------------------------------------------------- - -// Returns whether the given navigation item handle is valid. -static SB_C_INLINE bool SbUiNavItemIsValid(SbUiNavItem item) { - return item != kSbUiNavItemInvalid; -} - -// Retrieve the platform's UI navigation implementation. If the platform does -// not provide one, then return false without modifying |out_interface|. -// Otherwise, initialize all members of |out_interface| and return true. -// The |out_interface| pointer must not be NULL. -SB_EXPORT bool SbUiNavGetInterface(SbUiNavInterface* out_interface); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_UI_NAVIGATION_H_ diff --git a/starboard/user.h b/starboard/user.h index 378b04a558dc..c350bfc393d5 100644 --- a/starboard/user.h +++ b/starboard/user.h @@ -25,100 +25,6 @@ #ifndef STARBOARD_USER_H_ #define STARBOARD_USER_H_ -#if SB_API_VERSION < 16 - -#include "starboard/export.h" -#include "starboard/types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Private structure representing a device user. -typedef struct SbUserPrivate SbUserPrivate; - -// A handle to a user. -typedef SbUserPrivate* SbUser; - -// A set of string properties that can be queried on a user. -#if SB_API_VERSION < 16 -typedef enum SbUserPropertyId { - // The URL to the avatar for a user. Avatars are not provided on all - // platforms. - kSbUserPropertyAvatarUrl, - - // The path to a user's home directory, if supported on this platform. - kSbUserPropertyHomeDirectory, - - // The username of a user, which may be the same as the User ID, or it may be - // friendlier. - kSbUserPropertyUserName, - - // A unique user ID of a user. - kSbUserPropertyUserId, -} SbUserPropertyId; -#endif - -// Well-defined value for an invalid user. -#define kSbUserInvalid (SbUser) NULL - -// Returns whether the given user handle is valid. -static SB_C_INLINE bool SbUserIsValid(SbUser user) { - return user != kSbUserInvalid; -} - -// Gets the current primary user, if one exists. This is the user that is -// determined, in a platform-specific way, to be the primary user controlling -// the application. For example, the determination might be made because that -// user launched the app, though it should be made using whatever criteria are -// appropriate for the platform. -// -// It is expected that there will be a unique SbUser per signed-in user, and -// that the referenced objects will persist for the lifetime of the app. -SB_EXPORT SbUser SbUserGetCurrent(); - -// Gets a list of up to |users_size| signed-in users and places the results in -// |out_users|. The return value identifies the actual number of signed-in -// users, which may be greater or less than |users_size|. -// -// It is expected that there will be a unique |SbUser| per signed-in user and -// that the referenced objects will persist for the lifetime of the app. -// -// |out_users|: Handles for the retrieved users. -// |users_size|: The maximum number of signed-in users to retrieve. -SB_EXPORT int SbUserGetSignedIn(SbUser* out_users, int users_size); - -// Returns the size of the value of |property_id| for |user|, INCLUDING the -// terminating null character. The function returns |0| if |user| is invalid -// or if |property_id| is not recognized, supported, or set for the user. -// -// |user|: The user for which property size data is being retrieved. -// |property_id|: The property for which the data is requested. -SB_EXPORT int SbUserGetPropertySize(SbUser user, SbUserPropertyId property_id); - -// Retrieves the value of |property_id| for |user| and places it in |out_value|. -// The function returns: -// - |true| if the property value is retrieved successfully -// - |false| if |user| is invalid; if |property_id| isn't recognized, supported, -// or set for |user|; or if |value_size| is too small. -// -// |user|: The user for which property size data is being retrieved. -// |property_id|: The property for which the data is requested. -// |out_value|: The retrieved property value. -// |value_size|: The size of the retrieved property value. -SB_EXPORT bool SbUserGetProperty(SbUser user, - SbUserPropertyId property_id, - char* out_value, - int value_size); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // SB_API_VERSION < 16 - #error This file is deprecated with SB_API_VERSION 16. -#endif // SB_API_VERSION < 16 - #endif // STARBOARD_USER_H_ diff --git a/starboard/win/__init__.py b/starboard/win/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/starboard/win/i18n/en-US.xlb b/starboard/win/i18n/en-US.xlb deleted file mode 100644 index 52f9c421394f..000000000000 --- a/starboard/win/i18n/en-US.xlb +++ /dev/null @@ -1,7 +0,0 @@ - - - - YouTube is not intended for use by children under 13. - Unable to contact YouTube. - - diff --git a/starboard/win/shared/BUILD.gn b/starboard/win/shared/BUILD.gn deleted file mode 100644 index 7421262998f7..000000000000 --- a/starboard/win/shared/BUILD.gn +++ /dev/null @@ -1,352 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") -import("//starboard/build/convert_i18n_data.gni") -import("//starboard/shared/starboard/player/buildfiles.gni") - -config("starboard_platform_config") { - if (current_os == "winuwp") { - # We want this to apply to all shared win sources for xb1. - configs = [ "//starboard/xb1:starboard_platform_config" ] - } - include_dirs = [ - "//third_party/angle/include", - "//third_party/angle/include/EGL", - "//third_party/angle/include/GLES2", - "//third_party/angle/include/KHR", - ] - - cflags = [ - "/EHsc", # C++ exceptions (required with /ZW) - "/FU${msvc_path}/lib/x86/store/references/platform.winmd", - "/FU${windows_sdk_path}/References/$wdk_version/Windows.Foundation.FoundationContract/4.0.0.0/Windows.Foundation.FoundationContract.winmd", - "/FU${windows_sdk_path}/References/$wdk_version/Windows.Foundation.UniversalApiContract/14.0.0.0/Windows.Foundation.UniversalApiContract.winmd", - "/FU${windows_sdk_path}/References/$wdk_version/Windows.UI.ViewManagement.ViewManagementViewScalingContract/1.0.0.0/Windows.UI.ViewManagement.ViewManagementViewScalingContract.winmd", - ] - - if (is_internal_build) { - cflags += [ - "/FU${windows_sdk_path}/References/$wdk_version/Windows.Xbox.ApplicationResourcesContract/2.0.0.0/Windows.Xbox.ApplicationResourcesContract.winmd", - "/FU${windows_sdk_path}/References/$wdk_version/Windows.Xbox.Security.ApplicationSpecificDeviceAuthenticationContract/1.0.0.0/Windows.Xbox.Security.ApplicationSpecificDeviceAuthenticationContract.winmd", - ] - } -} - -static_library("starboard_platform") { - has_pedantic_warnings = true - - sources = [ - "//starboard/common/thread.cc", - "//starboard/common/thread.h", - "//starboard/shared/egl/system_egl.cc", - "//starboard/shared/gles/system_gles2.cc", - "//starboard/shared/iso/string_scan.cc", - "//starboard/shared/nouser/user_get_current.cc", - "//starboard/shared/nouser/user_get_property.cc", - "//starboard/shared/nouser/user_get_signed_in.cc", - "//starboard/shared/nouser/user_internal.cc", - "//starboard/shared/opus/opus_audio_decoder.cc", - "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/posix/socket_is_ipv6_supported.cc", - "//starboard/shared/starboard/application.cc", - "//starboard/shared/starboard/audio_sink/audio_sink_create.cc", - "//starboard/shared/starboard/audio_sink/audio_sink_destroy.cc", - "//starboard/shared/starboard/audio_sink/audio_sink_get_min_buffer_size_in_frames.cc", - "//starboard/shared/starboard/audio_sink/audio_sink_internal.cc", - "//starboard/shared/starboard/audio_sink/audio_sink_internal.h", - "//starboard/shared/starboard/audio_sink/audio_sink_is_valid.cc", - "//starboard/shared/starboard/audio_sink/stub_audio_sink_type.cc", - "//starboard/shared/starboard/audio_sink/stub_audio_sink_type.h", - "//starboard/shared/starboard/command_line.cc", - "//starboard/shared/starboard/command_line.h", - "//starboard/shared/starboard/drm/drm_close_session.cc", - "//starboard/shared/starboard/drm/drm_destroy_system.cc", - "//starboard/shared/starboard/drm/drm_generate_session_update_request.cc", - "//starboard/shared/starboard/drm/drm_get_metrics.cc", - "//starboard/shared/starboard/drm/drm_system_internal.h", - "//starboard/shared/starboard/drm/drm_update_session.cc", - "//starboard/shared/starboard/event_cancel.cc", - "//starboard/shared/starboard/event_schedule.cc", - "//starboard/shared/starboard/file_atomic_replace_write_file.cc", - "//starboard/shared/starboard/file_atomic_replace_write_file.h", - "//starboard/shared/starboard/file_mode_string_to_flags.cc", - "//starboard/shared/starboard/file_storage/storage_close_record.cc", - "//starboard/shared/starboard/file_storage/storage_delete_record.cc", - "//starboard/shared/starboard/file_storage/storage_get_record_size.cc", - "//starboard/shared/starboard/file_storage/storage_open_record.cc", - "//starboard/shared/starboard/file_storage/storage_read_record.cc", - "//starboard/shared/starboard/log_mutex.cc", - "//starboard/shared/starboard/log_mutex.h", - "//starboard/shared/starboard/media/media_can_play_mime_and_key_system.cc", - "//starboard/shared/starboard/media/media_get_audio_buffer_budget.cc", - "//starboard/shared/starboard/media/media_get_audio_output_count_single_audio_output.cc", - "//starboard/shared/starboard/media/media_get_buffer_alignment.cc", - "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", - "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", - "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", - "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", - "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", - "//starboard/shared/starboard/media/media_get_video_buffer_budget.cc", - "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", - "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", - "//starboard/shared/starboard/net_args.cc", - "//starboard/shared/starboard/net_args.h", - "//starboard/shared/starboard/net_log.cc", - "//starboard/shared/starboard/net_log.h", - "//starboard/shared/starboard/string_duplicate.cc", - "//starboard/shared/stub/cpu_features_get.cc", - "//starboard/shared/stub/image_decode.cc", - "//starboard/shared/stub/image_is_decode_supported.cc", - "//starboard/shared/stub/speech_synthesis_cancel.cc", - "//starboard/shared/stub/speech_synthesis_is_supported.cc", - "//starboard/shared/stub/speech_synthesis_speak.cc", - "//starboard/shared/stub/system_get_total_gpu_memory.cc", - "//starboard/shared/stub/system_get_used_gpu_memory.cc", - "//starboard/shared/stub/system_has_capability.cc", - "//starboard/shared/stub/system_hide_splash_screen.cc", - "//starboard/shared/stub/system_network_is_disconnected.cc", - "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/stub/thread_context_get_pointer.cc", - "//starboard/shared/stub/thread_create_priority.cc", - "//starboard/shared/stub/thread_sampler_create.cc", - "//starboard/shared/stub/thread_sampler_destroy.cc", - "//starboard/shared/stub/thread_sampler_freeze.cc", - "//starboard/shared/stub/thread_sampler_is_supported.cc", - "//starboard/shared/stub/thread_sampler_thaw.cc", - "//starboard/shared/stub/time_get_monotonic_thread_now.cc", - "//starboard/shared/stub/time_is_time_thread_now_supported.cc", - "//starboard/shared/stub/ui_nav_get_interface.cc", - "//starboard/shared/stub/window_blur_on_screen_keyboard.cc", - "//starboard/shared/stub/window_focus_on_screen_keyboard.cc", - "//starboard/shared/stub/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/stub/window_get_on_screen_keyboard_bounding_rect.cc", - "//starboard/shared/stub/window_hide_on_screen_keyboard.cc", - "//starboard/shared/stub/window_is_on_screen_keyboard_shown.cc", - "//starboard/shared/stub/window_on_screen_keyboard_is_supported.cc", - "//starboard/shared/stub/window_on_screen_keyboard_suggestions_supported.cc", - "//starboard/shared/stub/window_set_on_screen_keyboard_keep_focus.cc", - "//starboard/shared/stub/window_show_on_screen_keyboard.cc", - "//starboard/shared/stub/window_update_on_screen_keyboard_suggestions.cc", - "//starboard/shared/win32/adapter_utils.cc", - "//starboard/shared/win32/adapter_utils.h", - "//starboard/shared/win32/atomic_public.h", - "//starboard/shared/win32/atomic_queue.h", - "//starboard/shared/win32/audio_decoder.cc", - "//starboard/shared/win32/audio_decoder.h", - "//starboard/shared/win32/audio_decoder_thread.cc", - "//starboard/shared/win32/audio_decoder_thread.h", - "//starboard/shared/win32/audio_sink.cc", - "//starboard/shared/win32/audio_sink_get_max_channels.cc", - "//starboard/shared/win32/audio_sink_get_nearest_supported_sample_frequency.cc", - "//starboard/shared/win32/audio_sink_is_audio_frame_storage_type_supported.cc", - "//starboard/shared/win32/audio_sink_is_audio_sample_type_supported.cc", - "//starboard/shared/win32/audio_transform.cc", - "//starboard/shared/win32/audio_transform.h", - "//starboard/shared/win32/auto_event_handle.h", - "//starboard/shared/win32/byte_swap.cc", - "//starboard/shared/win32/condition_variable_broadcast.cc", - "//starboard/shared/win32/condition_variable_create.cc", - "//starboard/shared/win32/condition_variable_destroy.cc", - "//starboard/shared/win32/condition_variable_signal.cc", - "//starboard/shared/win32/condition_variable_wait.cc", - "//starboard/shared/win32/condition_variable_wait_timed.cc", - "//starboard/shared/win32/decode_target_internal.cc", - "//starboard/shared/win32/decode_target_internal.h", - "//starboard/shared/win32/decrypting_decoder.cc", - "//starboard/shared/win32/decrypting_decoder.h", - "//starboard/shared/win32/directory_can_open.cc", - "//starboard/shared/win32/directory_close.cc", - "//starboard/shared/win32/directory_create.cc", - "//starboard/shared/win32/directory_get_next.cc", - "//starboard/shared/win32/directory_internal.cc", - "//starboard/shared/win32/directory_internal.h", - "//starboard/shared/win32/directory_open.cc", - "//starboard/shared/win32/drm_system_playready.cc", - "//starboard/shared/win32/drm_system_playready.h", - "//starboard/shared/win32/dx_context_video_decoder.cc", - "//starboard/shared/win32/dx_context_video_decoder.h", - "//starboard/shared/win32/environment.cc", - "//starboard/shared/win32/error_utils.cc", - "//starboard/shared/win32/error_utils.h", - "//starboard/shared/win32/file_atomic_replace.cc", - "//starboard/shared/win32/file_can_open.cc", - "//starboard/shared/win32/file_close.cc", - "//starboard/shared/win32/file_delete.cc", - "//starboard/shared/win32/file_exists.cc", - "//starboard/shared/win32/file_flush.cc", - "//starboard/shared/win32/file_get_info.cc", - "//starboard/shared/win32/file_get_path_info.cc", - "//starboard/shared/win32/file_internal.cc", - "//starboard/shared/win32/file_internal.h", - "//starboard/shared/win32/file_open.cc", - "//starboard/shared/win32/file_read.cc", - "//starboard/shared/win32/file_seek.cc", - "//starboard/shared/win32/file_truncate.cc", - "//starboard/shared/win32/file_write.cc", - "//starboard/shared/win32/graphics.cc", - "//starboard/shared/win32/graphics.h", - "//starboard/shared/win32/hardware_decode_target_internal.cc", - "//starboard/shared/win32/hardware_decode_target_internal.h", - "//starboard/shared/win32/log.cc", - "//starboard/shared/win32/log_flush.cc", - "//starboard/shared/win32/log_format.cc", - "//starboard/shared/win32/log_raw_dump_stack.cc", - "//starboard/shared/win32/media_common.cc", - "//starboard/shared/win32/media_common.h", - "//starboard/shared/win32/media_foundation_utils.cc", - "//starboard/shared/win32/media_foundation_utils.h", - "//starboard/shared/win32/media_get_max_buffer_capacity.cc", - "//starboard/shared/win32/media_transform.cc", - "//starboard/shared/win32/media_transform.h", - "//starboard/shared/win32/memory_allocate_aligned_unchecked.cc", - "//starboard/shared/win32/memory_allocate_unchecked.cc", - "//starboard/shared/win32/memory_flush.cc", - "//starboard/shared/win32/memory_free.cc", - "//starboard/shared/win32/memory_free_aligned.cc", - "//starboard/shared/win32/memory_map.cc", - "//starboard/shared/win32/memory_protect.cc", - "//starboard/shared/win32/memory_reallocate_unchecked.cc", - "//starboard/shared/win32/memory_unmap.cc", - "//starboard/shared/win32/mutex_acquire.cc", - "//starboard/shared/win32/mutex_acquire_try.cc", - "//starboard/shared/win32/mutex_create.cc", - "//starboard/shared/win32/mutex_destroy.cc", - "//starboard/shared/win32/mutex_release.cc", - "//starboard/shared/win32/once.cc", - "//starboard/shared/win32/posix_emu/dirent.cc", - "//starboard/shared/win32/posix_emu/ifaddrs.cc", - "//starboard/shared/win32/posix_emu/mman.cc", - "//starboard/shared/win32/posix_emu/pthread.cc", - "//starboard/shared/win32/posix_emu/sched.cc", - "//starboard/shared/win32/posix_emu/socket.cc", - "//starboard/shared/win32/posix_emu/stat.cc", - "//starboard/shared/win32/posix_emu/stdlib.cc", - "//starboard/shared/win32/posix_emu/string.cc", - "//starboard/shared/win32/posix_emu/strings.cc", - "//starboard/shared/win32/posix_emu/time.cc", - "//starboard/shared/win32/posix_emu/usleep.cc", - "//starboard/shared/win32/set_non_blocking_internal.cc", - "//starboard/shared/win32/set_non_blocking_internal.h", - "//starboard/shared/win32/socket_accept.cc", - "//starboard/shared/win32/socket_bind.cc", - "//starboard/shared/win32/socket_clear_last_error.cc", - "//starboard/shared/win32/socket_connect.cc", - "//starboard/shared/win32/socket_create.cc", - "//starboard/shared/win32/socket_destroy.cc", - "//starboard/shared/win32/socket_free_resolution.cc", - "//starboard/shared/win32/socket_get_interface_address.cc", - "//starboard/shared/win32/socket_get_last_error.cc", - "//starboard/shared/win32/socket_get_local_address.cc", - "//starboard/shared/win32/socket_internal.cc", - "//starboard/shared/win32/socket_internal.h", - "//starboard/shared/win32/socket_is_connected.cc", - "//starboard/shared/win32/socket_is_connected_and_idle.cc", - "//starboard/shared/win32/socket_join_multicast_group.cc", - "//starboard/shared/win32/socket_listen.cc", - "//starboard/shared/win32/socket_receive_from.cc", - "//starboard/shared/win32/socket_resolve.cc", - "//starboard/shared/win32/socket_send_to.cc", - "//starboard/shared/win32/socket_set_broadcast.cc", - "//starboard/shared/win32/socket_set_receive_buffer_size.cc", - "//starboard/shared/win32/socket_set_reuse_address.cc", - "//starboard/shared/win32/socket_set_send_buffer_size.cc", - "//starboard/shared/win32/socket_set_tcp_keep_alive.cc", - "//starboard/shared/win32/socket_set_tcp_no_delay.cc", - "//starboard/shared/win32/socket_set_tcp_window_scaling.cc", - "//starboard/shared/win32/socket_waiter_add.cc", - "//starboard/shared/win32/socket_waiter_create.cc", - "//starboard/shared/win32/socket_waiter_destroy.cc", - "//starboard/shared/win32/socket_waiter_internal.cc", - "//starboard/shared/win32/socket_waiter_remove.cc", - "//starboard/shared/win32/socket_waiter_wait.cc", - "//starboard/shared/win32/socket_waiter_wait_timed.cc", - "//starboard/shared/win32/socket_waiter_wake_up.cc", - "//starboard/shared/win32/storage_write_record.cc", - "//starboard/shared/win32/string_compare_no_case.cc", - "//starboard/shared/win32/string_compare_no_case_n.cc", - "//starboard/shared/win32/string_format.cc", - "//starboard/shared/win32/string_format_wide.cc", - "//starboard/shared/win32/system_break_into_debugger.cc", - "//starboard/shared/win32/system_clear_last_error.cc", - "//starboard/shared/win32/system_get_error_string.cc", - "//starboard/shared/win32/system_get_last_error.cc", - "//starboard/shared/win32/system_get_locale_id.cc", - "//starboard/shared/win32/system_get_number_of_processors.cc", - "//starboard/shared/win32/system_get_random_data.cc", - "//starboard/shared/win32/system_get_random_uint64.cc", - "//starboard/shared/win32/system_get_stack.cc", - "//starboard/shared/win32/system_is_debugger_attached.cc", - "//starboard/shared/win32/thread_create.cc", - "//starboard/shared/win32/thread_create_local_key.cc", - "//starboard/shared/win32/thread_destroy_local_key.cc", - "//starboard/shared/win32/thread_detach.cc", - "//starboard/shared/win32/thread_get_current.cc", - "//starboard/shared/win32/thread_get_id.cc", - "//starboard/shared/win32/thread_get_local_value.cc", - "//starboard/shared/win32/thread_get_name.cc", - "//starboard/shared/win32/thread_is_equal.cc", - "//starboard/shared/win32/thread_join.cc", - "//starboard/shared/win32/thread_local_internal.cc", - "//starboard/shared/win32/thread_local_internal.h", - "//starboard/shared/win32/thread_private.cc", - "//starboard/shared/win32/thread_private.h", - "//starboard/shared/win32/thread_set_local_value.cc", - "//starboard/shared/win32/thread_set_name.cc", - "//starboard/shared/win32/thread_sleep.cc", - "//starboard/shared/win32/thread_yield.cc", - "//starboard/shared/win32/time_get_monotonic_now.cc", - "//starboard/shared/win32/time_get_now.cc", - "//starboard/shared/win32/time_utils.h", - "//starboard/shared/win32/time_zone_get_current.cc", - "//starboard/shared/win32/video_decoder.cc", - "//starboard/shared/win32/video_decoder.h", - "//starboard/shared/win32/wasapi_include.h", - "//starboard/shared/win32/wchar_utils.h", - "//starboard/shared/win32/win32_audio_decoder.cc", - "//starboard/shared/win32/win32_audio_decoder.h", - "//starboard/shared/win32/wrm_header.cc", - "//starboard/shared/win32/wrm_header.h", - ] - - sources += common_player_sources - - configs += [ - "//starboard/build/config:starboard_implementation", - ":starboard_platform_config", - ] - - public_deps = [ - "//starboard/common", - "//starboard/shared/starboard/media:media_util", - "//starboard/shared/starboard/player/filter:filter_based_player_sources", - ] - - deps = [ - "//starboard/egl_and_gles", - "//starboard/shared/starboard/media:media_util", - "//starboard/shared/starboard/player/filter:filter_based_player_sources", - "//third_party/opus", - ] - - if (is_internal_build) { - deps += [ "//internal/starboard/private/shared/stub:private_sources" ] - } - - if (gl_type == "angle") { - deps += [ "//third_party/angle:translator" ] - } -} diff --git a/starboard/win/shared/configuration_constants.cc b/starboard/win/shared/configuration_constants.cc deleted file mode 100644 index 2b849fc8fab7..000000000000 --- a/starboard/win/shared/configuration_constants.cc +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This file defines all configuration constants for a platform. - -#include "starboard/configuration_constants.h" - -// Determines the threshold of allocation size that should be done with mmap -// (if available), rather than allocated within the core heap. -const size_t kSbDefaultMmapThreshold = 256 * 1024U; - -// The current platform's maximum length of the name of a single directory -// entry, not including the absolute path. -const int32_t kSbFileMaxName = 260; - -// The current platform's maximum number of files that can be opened at the -// same time by one process. -// This is set to MAXIMUM_WAIT_OBJECTS - 1, since we use WaitForMultipleEvents -// and that only supports MAXIMUM_WAIT_OBJECTS events. The -1 is since we -// use a dummy event to wake up the socket. -const uint32_t kSbFileMaxOpen = 63; - -// The current platform's alternate file path component separator character. -// This is like SB_FILE_SEP_CHAR, except if your platform supports an alternate -// character, then you can place that here. For example, on windows machines, -// the primary separator character is probably '\', but the alternate is '/'. -const char kSbFileAltSepChar = '/'; - -// The string form of SB_FILE_ALT_SEP_CHAR. -const char* kSbFileAltSepString = "/"; - -// The current platform's maximum length of an absolute path. -const uint32_t kSbFileMaxPath = 4096; - -// The current platform's file path component separator character. This is the -// character that appears after a directory in a file path. For example, the -// absolute canonical path of the file "/path/to/a/file.txt" uses '/' as a path -// component separator character. -const char kSbFileSepChar = '\\'; - -// The string form of SB_FILE_SEP_CHAR. -const char* kSbFileSepString = "\\"; - -// Specifies whether this platform has webm/vp9 support. This should be set to -// non-zero on platforms with webm/vp9 support. -const bool kSbHasMediaWebmVp9Support = true; - -// Whether the current platform supports thread priorities. -const bool kSbHasThreadPrioritySupport = true; - -// Determines the alignment that allocations should have on this platform. -const size_t kSbMallocAlignment = 16; - -// The maximum number of thread local storage keys supported by this platform. -const uint32_t kSbMaxThreadLocalKeys = 512; - -// The maximum length of a name for a thread, including the NULL-terminator. -const int32_t kSbMaxThreadNameLength = 16; - -// Defines the path where memory debugging logs should be written to. -const char* kSbMemoryLogPath = "/tmp/starboard"; - -// The maximum audio bitrate the platform can decode. The following value -// equals to 5M bytes per seconds which is more than enough for compressed -// audio. -const uint32_t kSbMediaMaxAudioBitrateInBitsPerSecond = 40 * 1024 * 1024; - -// The maximum video bitrate the platform can decode. The following value -// equals to 25M bytes per seconds which is more than enough for compressed -// video. -const uint32_t kSbMediaMaxVideoBitrateInBitsPerSecond = 200 * 1024 * 1024; - -// Specifies how video frame buffers must be aligned on this platform. -const uint32_t kSbMediaVideoFrameAlignment = 256; - -// The memory page size, which controls the size of chunks on memory that -// allocators deal with, and the alignment of those chunks. This doesn't have to -// be the hardware-defined physical page size, but it should be a multiple of -// it. -const size_t kSbMemoryPageSize = 4096; - -// Specifies the network receive buffer size in bytes, set via -// SbSocketSetReceiveBufferSize(). -// -// Setting this to 0 indicates that SbSocketSetReceiveBufferSize() should -// not be called. Use this for OSs (such as Linux) where receive buffer -// auto-tuning is better. -// -// On some platforms, this may affect max TCP window size which may -// dramatically affect throughput in the presence of latency. -// -// If your platform does not have a good TCP auto-tuning mechanism, -// a setting of (128 * 1024) here is recommended. -const uint32_t kSbNetworkReceiveBufferSize = 0; - -// Defines the maximum number of simultaneous threads for this platform. Some -// platforms require sharing thread handles with other kinds of system handles, -// like mutexes, so we want to keep this manageable. -const uint32_t kSbMaxThreads = 90; - -// The current platform's search path component separator character. When -// specifying an ordered list of absolute paths of directories to search for a -// given reason, this is the character that appears between entries. For -// example, the search path of "/etc/search/first:/etc/search/second" uses ':' -// as a search path component separator character. -#ifdef __cplusplus -extern "C" { -#endif -const char kSbPathSepChar = ';'; -#ifdef __cplusplus -} // extern "C" -#endif - -// The string form of SB_PATH_SEP_CHAR. -const char* kSbPathSepString = ";"; - -// Specifies the preferred byte order of color channels in a pixel. Refer to -// starboard/configuration.h for the possible values. EGL/GLES platforms should -// generally prefer a byte order of RGBA, regardless of endianness. -const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; - -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - -// The maximum size the cache directory is allowed to use in bytes. -const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB - -#if SB_API_VERSION >= 16 -// Whether this platform can map executable memory. This is required for -// platforms that want to JIT. -SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; - -// Platform can support partial audio frames -SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; -#endif diff --git a/starboard/win/shared/configuration_public.h b/starboard/win/shared/configuration_public.h deleted file mode 100644 index 0337f7cf6fda..000000000000 --- a/starboard/win/shared/configuration_public.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Other source files should never include this header directly, but should -// include the generic "starboard/configuration.h" instead. - -#ifndef STARBOARD_WIN_SHARED_CONFIGURATION_PUBLIC_H_ -#define STARBOARD_WIN_SHARED_CONFIGURATION_PUBLIC_H_ - -// --- System Header Configuration ------------------------------------------- - -// Any system headers listed here that are not provided by the platform will be -// emulated in starboard/types.h. - -// Whether the current platform provides the standard header sys/types.h. -#define SB_HAS_SYS_TYPES_H 0 - -// Whether the current platform provides ssize_t. -#define SB_HAS_SSIZE_T 0 - -#if !defined(__WCHAR_MAX__) -#include -#define __WCHAR_MAX__ WCHAR_MAX -#endif - -// Type detection for wchar_t. -#if defined(__WCHAR_MAX__) && \ - (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) -#define SB_IS_WCHAR_T_UTF32 1 -#elif defined(__WCHAR_MAX__) && \ - (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) -#define SB_IS_WCHAR_T_UTF16 1 -#endif - -// Chrome only defines this for ARMEL. -#if defined(__ARMEL__) -// Chrome has an exclusion for iOS here, we should too when we support iOS. -#define SB_IS_WCHAR_T_UNSIGNED 1 -#endif - -// --- Network Configuration ------------------------------------------------- - -// Specifies whether this platform supports IPV6. -#define SB_HAS_IPV6 1 - -// --- Platform Specific Quirks ---------------------------------------------- -#define SB_HAS_QUIRK_NO_CONDATTR_SETCLOCK_SUPPORT 1 - -#endif // STARBOARD_WIN_SHARED_CONFIGURATION_PUBLIC_H_ diff --git a/starboard/win/shared/platform_configuration/BUILD.gn b/starboard/win/shared/platform_configuration/BUILD.gn deleted file mode 100644 index ec9ec17da098..000000000000 --- a/starboard/win/shared/platform_configuration/BUILD.gn +++ /dev/null @@ -1,97 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") - -config("platform_configuration") { - configs = [ - "//starboard/build/config/sabi", - "//starboard/build/config/win:common", - ] - - defines = [ - # Disable warnings. These options were inherited from Chromium. - "_CRT_SECURE_NO_DEPRECATE", - "_CRT_NONSTDC_NO_WARNINGS", - "_CRT_NONSTDC_NO_DEPRECATE", - "_SCL_SECURE_NO_DEPRECATE", - - # Disable suggestions to switch to Microsoft-specific secure CRT. - "_CRT_SECURE_NO_WARNINGS", - "__STDC_FORMAT_MACROS", # so that we get PRI* - - # By defining this, M_PI will get #defined. - "_USE_MATH_DEFINES", - - # Conform with C99 spec. - "_CRT_STDIO_ISO_WIDE_SPECIFIERS", - ] - - include_dirs = [ - # POSIX emulation headers - these need to come *before* system include_dirs. - "//starboard/shared/win32/posix_emu/include", - ] - - ldflags = [ - # Suppress import library warning caused by the win32/posix_emu - "/ignore:4286", - ] - if (is_qa || is_gold || !cobalt_fastbuild) { - ldflags += [ "/DEBUG:FASTLINK" ] - } - - if (cobalt_pending_clean_up) { - # TODO: b/330363799 - These were added for the base/net update and should - # be removed. - cflags = [ - "/wd4003", - "/wd4722", - "/wd4715", - "/wd4359", - "/wd4312", - "/wd4005", - "/wd4180", - "/wd4359", - "/wd4553", - "/wd4229", - "/wd4146", - "/wd4324", - "/wd4245", - "/wd4700", - "/wd4702", - "/wd4717", - ] - defines += [ "_ITERATOR_DEBUG_LEVEL=0" ] - } -} - -config("no_pedantic_warnings") { - cflags = [ - # Enable some warnings, even those that are disabled by default. - # See https://msdn.microsoft.com/en-us/library/23k5d385.aspx - "/W2", - ] -} - -config("pedantic_warnings") { - cflags = [ - # Enable some warnings, even those that are disabled by default. - # See https://msdn.microsoft.com/en-us/library/23k5d385.aspx - "/W4", - - # Warn if an enumeration value is unhandled in switch (C4062). - # This warning is off by default, so it must be turned on explicitly. - "/w44062", - ] -} diff --git a/starboard/win/shared/platform_configuration/configuration.gni b/starboard/win/shared/platform_configuration/configuration.gni deleted file mode 100644 index 74fe80625278..000000000000 --- a/starboard/win/shared/platform_configuration/configuration.gni +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/build/config/base_configuration.gni") - -# No GL drivers available. -gl_type = "angle" - -sabi_path = "//starboard/sabi/x64/windows/sabi-v$sb_api_version.json" - -install_target_path = "//starboard/build/install/no_install.gni" - -no_pedantic_warnings_config_path = - "//starboard/win/shared/platform_configuration:no_pedantic_warnings" -pedantic_warnings_config_path = - "//starboard/win/shared/platform_configuration:pedantic_warnings" - -cobalt_platform_dependencies = [ "//starboard/egl_and_gles" ] diff --git a/starboard/win/shared/system_get_path.cc b/starboard/win/shared/system_get_path.cc deleted file mode 100644 index ba0233518887..000000000000 --- a/starboard/win/shared/system_get_path.cc +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include -// pathcch.h must come after windows.h. -#include - -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/file_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -namespace { - -using starboard::shared::win32::CreateDirectoryHierarchy; -using starboard::shared::win32::NormalizeWin32Path; - -// Places up to |path_size| - 1 characters of the path to the current -// executable in |out_path|, ensuring it is NULL-terminated. Returns success -// status. The result being greater than |path_size| - 1 characters is a -// failure. |out_path| may be written to in unsuccessful cases. -bool GetExecutablePath(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - - std::vector w_file_path(kSbFileMaxPath); - DWORD characters_written = - GetModuleFileName(NULL, w_file_path.data(), kSbFileMaxPath); - if (characters_written < 1) { - return false; - } - std::string utf8_string = - starboard::shared::win32::wchar_tToUTF8(w_file_path.data()); - if (utf8_string.length() >= path_size) { - return false; - } - return starboard::strlcpy(out_path, utf8_string.c_str(), path_size); -} - -// Places up to |path_size| - 1 characters of the path to the directory -// containing the current executable in |out_path|, ensuring it is -// NULL-terminated. Returns success status. The result being greater than -// |path_size| - 1 characters is a failure. |out_path| may be written to in -// unsuccessful cases. -bool GetExecutableDirectory(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - - std::vector w_file_path(kSbFileMaxPath); - DWORD characters_written = - GetModuleFileName(NULL, w_file_path.data(), kSbFileMaxPath); - if (characters_written < 1) { - return false; - } - PathCchRemoveFileSpec(w_file_path.data(), kSbFileMaxPath); - std::string utf8_string = - starboard::shared::win32::wchar_tToUTF8(w_file_path.data()); - if (utf8_string.length() >= path_size) { - return false; - } - return starboard::strlcpy(out_path, utf8_string.c_str(), path_size); -} - -bool GetRelativeDirectory(const char* relative_path, - char* out_path, - int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - std::vector file_path(kSbFileMaxPath); - file_path[0] = '\0'; - if (!GetExecutableDirectory(file_path.data(), path_size)) { - return false; - } - if (starboard::strlcat(file_path.data(), relative_path, kSbFileMaxPath) >= - path_size) { - return false; - } - - if (!CreateDirectoryHierarchy(NormalizeWin32Path(file_path.data()))) { - return false; - } - return starboard::strlcpy(out_path, file_path.data(), path_size); -} - -// Places up to |path_size| - 1 characters of the path to the content directory -// in |out_path|, ensuring it is NULL-terminated. Returns success -// status. The result being greater than |path_size| - 1 characters is a -// failure. |out_path| may be written to in unsuccessful cases. -bool GetContentPath(char* out_path, int path_size) { - return GetRelativeDirectory("\\content\\data", out_path, path_size); -} - -bool GetCachePath(char* out_path, int path_size) { - return GetRelativeDirectory("\\content\\cache", out_path, path_size); -} - -bool CreateAndGetTempPath(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - std::vector w_file_path(kSbFileMaxPath); - w_file_path[0] = L'\0'; - - int64_t characters_written = - static_cast(GetTempPathW(kSbFileMaxPath, w_file_path.data())); - if (characters_written >= (path_size + 1) || characters_written < 1) { - return false; - } - // Remove the last slash, to match other Starboard implementations. - w_file_path[characters_written - 1] = L'\0'; - - std::string utf8_string = - starboard::shared::win32::wchar_tToUTF8(w_file_path.data()); - - if (starboard::strlcpy(out_path, utf8_string.c_str(), path_size) >= - path_size) { - return false; - } - mkdir(out_path, 0700); - - size_t length = strlen(out_path); - if (length < 1 || length > path_size) { - return false; - } - return true; -} - -} // namespace - -// Note: This function is only minimally implemented to allow tests to run. -bool SbSystemGetPath(SbSystemPathId path_id, char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - - switch (path_id) { - case kSbSystemPathContentDirectory: - return GetContentPath(out_path, path_size); - case kSbSystemPathDebugOutputDirectory: - return SbSystemGetPath(kSbSystemPathTempDirectory, out_path, path_size); - case kSbSystemPathExecutableFile: - return GetExecutablePath(out_path, path_size); - case kSbSystemPathTempDirectory: - return CreateAndGetTempPath(out_path, path_size); - case kSbSystemPathCacheDirectory: - return GetCachePath(out_path, path_size); - case kSbSystemPathFontConfigurationDirectory: - return false; - case kSbSystemPathFontDirectory: - return false; - // TODO: implement all the other cases. - default: - SB_NOTIMPLEMENTED(); - return false; - } -} diff --git a/starboard/win/win32/BUILD.gn b/starboard/win/win32/BUILD.gn deleted file mode 100644 index 746db846b634..000000000000 --- a/starboard/win/win32/BUILD.gn +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -static_library("starboard_platform") { - sources = [ - "//starboard/shared/starboard/localized_strings.cc", - "//starboard/shared/starboard/media/media_get_audio_configuration.cc", - "//starboard/shared/starboard/queue_application.cc", - "//starboard/shared/starboard/system_request_blur.cc", - "//starboard/shared/starboard/system_request_conceal.cc", - "//starboard/shared/starboard/system_request_focus.cc", - "//starboard/shared/starboard/system_request_freeze.cc", - "//starboard/shared/starboard/system_request_reveal.cc", - "//starboard/shared/starboard/system_request_stop.cc", - "//starboard/shared/starboard/system_supports_resume.cc", - "//starboard/shared/stub/drm_is_server_certificate_updatable.cc", - "//starboard/shared/stub/drm_update_server_certificate.cc", - "//starboard/shared/stub/microphone_close.cc", - "//starboard/shared/stub/microphone_create.cc", - "//starboard/shared/stub/microphone_destroy.cc", - "//starboard/shared/stub/microphone_get_available.cc", - "//starboard/shared/stub/microphone_is_sample_rate_supported.cc", - "//starboard/shared/stub/microphone_open.cc", - "//starboard/shared/stub/microphone_read.cc", - "//starboard/shared/win32/application_win32.cc", - "//starboard/shared/win32/application_win32_key_event.cc", - "//starboard/shared/win32/configuration.cc", - "//starboard/shared/win32/configuration.h", - "//starboard/shared/win32/dialog.cc", - "//starboard/shared/win32/drm_create_system.cc", - "//starboard/shared/win32/get_home_directory.cc", - "//starboard/shared/win32/log_file_impl.cc", - "//starboard/shared/win32/log_file_impl.h", - "//starboard/shared/win32/log_raw.cc", - "//starboard/shared/win32/log_raw_format.cc", - "//starboard/shared/win32/media_is_audio_supported.cc", - "//starboard/shared/win32/media_is_supported.cc", - "//starboard/shared/win32/media_is_video_supported.cc", - "//starboard/shared/win32/minidump.cc", - "//starboard/shared/win32/minidump.h", - "//starboard/shared/win32/player_components_factory.cc", - "//starboard/shared/win32/playready_license.cc", - "//starboard/shared/win32/starboard_main.cc", - "//starboard/shared/win32/system_get_device_type.cc", - "//starboard/shared/win32/system_get_extensions.cc", - "//starboard/shared/win32/system_get_property.cc", - "//starboard/shared/win32/system_get_total_cpu_memory.cc", - "//starboard/shared/win32/system_get_used_cpu_memory.cc", - "//starboard/shared/win32/system_raise_platform_error.cc", - "//starboard/shared/win32/system_symbolize.cc", - "//starboard/shared/win32/time_zone_get_name.cc", - "//starboard/shared/win32/window_create.cc", - "//starboard/shared/win32/window_destroy.cc", - "//starboard/shared/win32/window_get_platform_handle.cc", - "//starboard/shared/win32/window_get_size.cc", - "//starboard/shared/win32/window_internal.cc", - "//starboard/shared/win32/window_internal.h", - "//starboard/shared/win32/window_set_default_options.cc", - "//starboard/win/shared/configuration_constants.cc", - "//starboard/win/shared/system_get_path.cc", - "atomic_public.h", - "configuration_public.h", - "main.cc", - ] - - configs += [ - "//starboard/build/config:starboard_implementation", - "//starboard/win/shared:starboard_platform_config", - ] - - public_deps = [ "//starboard/win/shared:starboard_platform" ] - - deps = [ "//starboard/win/win32/i18n" ] -} diff --git a/starboard/win/win32/__init__.py b/starboard/win/win32/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/starboard/win/win32/args.gn b/starboard/win/win32/args.gn deleted file mode 100644 index ca2004d1ac11..000000000000 --- a/starboard/win/win32/args.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -target_platform = "win-win32" -target_os = "win" -target_cpu = "x64" -is_clang = false diff --git a/starboard/win/win32/atomic_public.h b/starboard/win/win32/atomic_public.h deleted file mode 100644 index b015b9824060..000000000000 --- a/starboard/win/win32/atomic_public.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_WIN_WIN32_ATOMIC_PUBLIC_H_ -#define STARBOARD_WIN_WIN32_ATOMIC_PUBLIC_H_ - -#include "starboard/shared/win32/atomic_public.h" - -#endif // STARBOARD_WIN_WIN32_ATOMIC_PUBLIC_H_ diff --git a/starboard/win/win32/cobalt/configuration.py b/starboard/win/win32/cobalt/configuration.py deleted file mode 100644 index 6816e04556ed..000000000000 --- a/starboard/win/win32/cobalt/configuration.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard Win32 Cobalt configuration.""" - -from cobalt.build import cobalt_configuration -from starboard.tools.testing import test_filter - - -class CobaltWinWin32Configuration(cobalt_configuration.CobaltConfiguration): - """Starboard Nintendo Switch Cobalt configuration.""" - - def GetTestFilters(self): - filters = super().GetTestFilters() - for target, tests in self.__FILTERED_TESTS.items(): - filters.extend(test_filter.TestFilter(target, test) for test in tests) - return filters - - def GetWebPlatformTestFilters(self): - filters = super().GetWebPlatformTestFilters() - filters += [ - '*WebPlatformTest.Run*', - ] - return filters - - __FILTERED_TESTS = { # pylint: disable=invalid-name - # These unittest cases are failing after C++14 migration. They will be - # fixed soon and re-enabled. - 'base_unittests': [ - '*TaskScheduler*', - 'TaskTraits*', - 'FileTest.Length', - ], - 'renderer_test': [ - # Flaky test is still being counted as a fail. - ('RendererPipelineTest.FLAKY_' - 'RasterizerSubmitCalledAtExpectedFrequencyAfterManyPipelineSubmits'), - ('RendererPipelineTest.FLAKY_' - 'RasterizerSubmitCalledAtExpectedFrequencyAfterSinglePipelineSubmit' - ), - ], - 'net_unittests': [ - # TODO(b/271006511): Flaky tests to be re-enabled once fixed. - 'CookieMonsterTest.DeleteExpiredAfterTimeElapsed_GetAllCookies', - 'CookieMonsterTest.DeleteExpiredCookiesAfterTimeElapsed', - 'CookieMonsterTest.DeleteExpiredPartitionedCookiesAfterTimeElapsed', - 'CookieMonsterTest.PredicateSeesAllCookies', - ], - } diff --git a/starboard/win/win32/configuration_public.h b/starboard/win/win32/configuration_public.h deleted file mode 100644 index aaf0aad1bb0c..000000000000 --- a/starboard/win/win32/configuration_public.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Other source files should never include this header directly, but should -// include the generic "starboard/configuration.h" instead. - -#ifndef STARBOARD_WIN_WIN32_CONFIGURATION_PUBLIC_H_ -#define STARBOARD_WIN_WIN32_CONFIGURATION_PUBLIC_H_ - -#include "starboard/win/shared/configuration_public.h" - -#endif // STARBOARD_WIN_WIN32_CONFIGURATION_PUBLIC_H_ diff --git a/starboard/win/win32/gyp_configuration.py b/starboard/win/win32/gyp_configuration.py deleted file mode 100644 index 4483aa6def03..000000000000 --- a/starboard/win/win32/gyp_configuration.py +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2016 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard win-win32 platform configuration for gyp_cobalt.""" - -from __future__ import print_function - -import imp # pylint: disable=deprecated-module -import logging -import os - -from starboard.shared.win32 import gyp_configuration - - -def CreatePlatformConfig(): - try: - win_lib_config = WinWin32PlatformConfig('win-win32') - return win_lib_config - except RuntimeError as e: - logging.critical(e) - return None - - -class WinWin32PlatformConfig(gyp_configuration.Win32SharedConfiguration): - """Starboard win-32 platform configuration.""" - - def GetLauncher(self): - """Gets the module used to launch applications on this platform.""" - module_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), 'launcher.py')) - - launcher_module = imp.load_source('launcher', module_path) - return launcher_module diff --git a/starboard/win/win32/i18n/BUILD.gn b/starboard/win/win32/i18n/BUILD.gn deleted file mode 100644 index 58213635dcaf..000000000000 --- a/starboard/win/win32/i18n/BUILD.gn +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/build/convert_i18n_data.gni") - -convert_i18n_data("i18n") { - install_content = true - xlb_files = [ "en.xlb" ] -} diff --git a/starboard/win/win32/i18n/en.xlb b/starboard/win/win32/i18n/en.xlb deleted file mode 100644 index ce8f4e3455fc..000000000000 --- a/starboard/win/win32/i18n/en.xlb +++ /dev/null @@ -1,8 +0,0 @@ - - - -Exit -Sorry, could not connect to YouTube. -Retry - - diff --git a/starboard/win/win32/launcher.py b/starboard/win/win32/launcher.py deleted file mode 100644 index 6bce76c8cea7..000000000000 --- a/starboard/win/win32/launcher.py +++ /dev/null @@ -1,90 +0,0 @@ -# -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard win-win32 launcher.""" - -from __future__ import print_function - -import os -import socket -import subprocess -import sys -import traceback - -from starboard.shared.win32 import mini_dump_printer -from starboard.tools import abstract_launcher - - -class Launcher(abstract_launcher.AbstractLauncher): - """Run an application on Windows.""" - - def __init__(self, platform, target_name, config, device_id, **kwargs): - super().__init__(platform, target_name, config, device_id, **kwargs) - self.executable_path = self.GetTargetPath() - - self.executable_mini_dump_path = self.executable_path + '.dmp' - if os.path.exists(self.executable_mini_dump_path): - self.LogLn('Found previous crash mini dump: deleting.') - os.remove(self.executable_mini_dump_path) - - def Run(self): - """Runs launcher's executable_path.""" - self.LogLn('\n***Running Launcher***') - self.proc = subprocess.Popen( # pylint: disable=consider-using-with - [self.executable_path] + self.target_command_line_params, - stdout=self.output_file, - stderr=self.output_file, - universal_newlines=True) - self.pid = self.proc.pid - self.proc.communicate() - self.proc.poll() - rtn_code = self.proc.returncode - self.DetectAndHandleCrashDump() - self.LogLn('Finished running executable.') - return rtn_code - - def Kill(self): - self.LogLn('\n***Killing Launcher***') - if self.pid: - try: - self.proc.kill() - except OSError: - self.LogLn('Error killing launcher with SIGKILL:') - traceback.print_exc(file=sys.stdout) - # If for some reason Kill() fails then os_.exit(1) will kill the - # child process without cleanup. Otherwise the process will hang. - os._exit(1) # pylint: disable=protected-access - else: - self.LogLn('Kill() called before Run(), cannot kill.') - - def Log(self, s): - self.output_file.write(s) - - def LogLn(self, s): - self.Log(s + '\n') - - def DetectAndHandleCrashDump(self): - if not os.path.exists(self.executable_mini_dump_path): - return - self.LogLn('\n*** Found crash dump! ***\nMinDumpPath:' + - self.executable_mini_dump_path) - mini_dump_printer.PrintMiniDump(self.executable_mini_dump_path, - self.output_file) - - def GetDeviceIp(self): - """Gets the device IP.""" - return socket.gethostbyname(socket.getfqdn()) - - def GetDeviceOutputPath(self): - return os.getenv('TMP') diff --git a/starboard/win/win32/main.cc b/starboard/win/win32/main.cc deleted file mode 100644 index 12e66ac6883a..000000000000 --- a/starboard/win/win32/main.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/shared/win32/starboard_main.h" - -int main(int argc, char** argv) { - StarboardMain(argc, argv); -} diff --git a/starboard/win/win32/platform_configuration/BUILD.gn b/starboard/win/win32/platform_configuration/BUILD.gn deleted file mode 100644 index 12b860980e0f..000000000000 --- a/starboard/win/win32/platform_configuration/BUILD.gn +++ /dev/null @@ -1,72 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") - -config("platform_configuration") { - configs = [ - "//starboard/build/config/sabi", - "//starboard/win/shared/platform_configuration", - ] - - ldflags = [ "/SUBSYSTEM:CONSOLE" ] - libs = [ - "shell32.lib", - "winmm.lib", - "gdi32.lib", - "dbghelp.lib", - "user32.lib", - "shlwapi.lib", - "mfplat.lib", - "mfuuid.lib", - "windowsapp.lib", - ] - - include_dirs = [] - - ldflags += [ - "/DYNAMICBASE", - - # TODO: SubSystem is hardcoded in - # win/sources_template.vcxproj. This will have the exe behave in the - # expected way in MSVS: when it's run without debug (Ctrl+F5), it - # will pause after finish; when debugging (F5) it will not pause - # before the cmd window disappears. - # Currently the value is ignored by msvs_makefile.py which generates - # the MSVS project files (it's in "data" in GenerateOutput()). Fix - # it if we ever need to change SubSystem. - "/SUBSYSTEM:CONSOLE", - "/MACHINE:x64", - - # Do not generate a WinMD file. - "/WINMD:NO", - - # Don't send error reports to MS. - "/errorReport:none", - ] - - cflags = [ - # Following V8 upstream to disable narrowing conversion. - "/wd4838", - ] - - defines = [ - "_WIN32", - "WIN32", - "WINDOWS", - - # Enable GNU extensions to get prototypes like ffsl. - "_GNU_SOURCE=1", - ] -} diff --git a/starboard/win/win32/platform_configuration/configuration.gni b/starboard/win/win32/platform_configuration/configuration.gni deleted file mode 100644 index 4b4c6372f88e..000000000000 --- a/starboard/win/win32/platform_configuration/configuration.gni +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/win/shared/platform_configuration/configuration.gni") - -platform_i18n_config_path = "//starboard/win/win32/i18n:i18n" - -v8_enable_webassembly = true diff --git a/starboard/win/win32/test_filters.py b/starboard/win/win32/test_filters.py deleted file mode 100644 index afd6cc771023..000000000000 --- a/starboard/win/win32/test_filters.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard win-win32 Platform Test Filters.""" - -from starboard.shared.win32 import test_filters as shared_test_filters -from starboard.tools.testing import test_filter - - -# pylint: disable=line-too-long -_FILTERED_TESTS = { - 'nplb': [ - # These tests hang too long on Windows. - 'PosixSocketSendTest.RainyDaySendToClosedSocket', - 'PosixSocketSendtoTest.RainyDaySendToClosedSocket', - - # Currently frequently flaky on Windows - 'SbConditionVariableWaitTimedTest.FLAKY_SunnyDayAutoInit', - 'PosixConditionVariableWaitTimedTest.FLAKY_SunnyDayAutoInit', - - # This single test takes >15 minutes. - 'SbPlayerTest.MultiPlayer', - # This test fails on win-win32 devel builds, because the compiler - # performs an optimization that defeats the SB_C_NOINLINE 'noinline' - # attribute. - 'SbSystemGetStackTest.SunnyDayStackDirection', - - # These tests are failing. Enable them once they're supported. - 'MultiplePlayerTests/*beneath_the_canopy_137_avc_dmp*', - 'SbMediaSetAudioWriteDurationTests/SbMediaSetAudioWriteDurationTest.WriteContinuedLimitedInput*', - 'SbPlayerWriteSampleTests/SbPlayerWriteSampleTest.SecondaryPlayerTest/*', - - # Failures tracked by b/256160416. - 'SbSystemGetPathTest.ReturnsRequiredPaths', - 'SbPlayerGetAudioConfigurationTests/*_video_beneath_the_canopy_137_avc_dmp_output_decode_to_texture_*', - 'SbPlayerGetMediaTimeTests/*_video_beneath_the_canopy_137_avc_dmp_output_decode_to_texture_*', - 'SbPlayerWriteSampleTests/*_video_beneath_the_canopy_137_avc_dmp_output_decode_to_texture_*', - 'SbSocketAddressTypes/SbSocketBindTest.RainyDayBadInterface/type_ipv6_filter_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDayDestination/type_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDaySourceForDestination/type_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDaySourceNotLoopback/type_ipv6', - 'SbSocketAddressTypes/SbSocketResolveTest.SunnyDayFiltered/filter_ipv6_type_ipv6', - 'SbSocketAddressTypes/SbSocketSetOptionsTest.RainyDayInvalidSocket/type_ipv4', - 'SbSocketAddressTypes/SbSocketSetOptionsTest.RainyDayInvalidSocket/type_ipv6', - # Flakiness is tracked in b/278276779. - 'Semaphore.ThreadTakesWait_TimeExpires', - # Failure tracked by b/287666606. - 'VerticalVideoTests/VerticalVideoTest.WriteSamples*', - - # Enable once verified on the platform. - 'SbMediaCanPlayMimeAndKeySystem.MinimumSupport', - - # TODO: b/349109647 Disable flaky test. - 'SbPlayerGetMediaTimeTests/*', - ], - 'player_filter_tests': [ - # These tests fail on our VMs for win-win32 builds due to missing - # or non functioning system video decoders. - 'VideoDecoderTests/VideoDecoderTest.*/beneath_the_canopy_137_avc_dmp_DecodeToTexture*', - 'VideoDecoderTests/VideoDecoderTest.*/black_test_avc_1080p_30to60_fps_dmp_DecodeToTexture*', - - # PlayerComponentsTests fail on our VMs. Preroll callback is always not called in - # 5 seconds, which causes timeout error. - 'PlayerComponentsTests/*', - ], - - # TODO: b/330792170 - Fix remaining failing win32 tests. - 'net_unittests': [ - 'CookieMonsterTest.InheritCreationDate', - 'FileStreamTest.UseFileHandle', # Fails on github but not locally. - 'UDPSocketTest.PartialRecv', - 'UDPSocketTest.ConnectRandomBind', - 'UDPSocketTest.ConnectFail', - 'UDPSocketTest.LimitConnectFail', - 'UDPSocketTest.ReadWithSocketOptimization', # This test crashes. - 'EmbeddedTestServerTestInstantiation/EmbeddedTestServerTest.ConnectionListenerComplete/0', - 'PartitionedCookiesURLRequestHttpJobTest.PrivacyMode/0', - ], -} - - -def CreateTestFilters(): - return WinWin32TestFilters() - - -class WinWin32TestFilters(shared_test_filters.TestFilters): - """Starboard win-win32 Platform Test Filters.""" - - def GetTestFilters(self): - """Gets all tests to be excluded from a unit test run. - - Returns: - A list of initialized TestFilter objects. - """ - filters = super().GetTestFilters() - for target, tests in _FILTERED_TESTS.items(): - filters.extend(test_filter.TestFilter(target, test) for test in tests) - return filters diff --git a/starboard/win/win32/toolchain/BUILD.gn b/starboard/win/win32/toolchain/BUILD.gn deleted file mode 100644 index ae9ace22f528..000000000000 --- a/starboard/win/win32/toolchain/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") -import("//build/toolchain/win/msvc_toolchain.gni") -import("//starboard/build/toolchain/win/variables.gni") - -msvc_toolchain("target") { - cl = "$tool_base_path/cl.exe" - lib = "$tool_base_path/lib.exe" - link = "$tool_base_path/link.exe" - asm = "$tool_base_path/ml64.exe" - sys_lib_flags = sys_libpaths - - toolchain_args = { - is_clang = false - current_os = "win" - current_cpu = "x64" - } -} diff --git a/starboard/window.h b/starboard/window.h index 06c2b73ebaf7..66e76f300daf 100644 --- a/starboard/window.h +++ b/starboard/window.h @@ -137,94 +137,6 @@ SB_EXPORT bool SbWindowGetSize(SbWindow window, SbWindowSize* size); // |window|: The SbWindow to retrieve the platform handle for. SB_EXPORT void* SbWindowGetPlatformHandle(SbWindow window); -#if SB_API_VERSION < 16 - -// System-triggered OnScreenKeyboard events have ticket value -// kSbEventOnScreenKeyboardInvalidTicket. -#define kSbEventOnScreenKeyboardInvalidTicket (-1) - -// Defines a rectangle via a point |(x, y)| and a size |(width, height)|. This -// structure is used as output for SbWindowGetOnScreenKeyboardBoundingRect. -typedef struct SbWindowRect { - float x; - float y; - float width; - float height; -} SbWindowRect; - -// Return whether the current platform supports an on screen keyboard -SB_EXPORT bool SbWindowOnScreenKeyboardIsSupported(); - -// Determine if the on screen keyboard is shown. -SB_EXPORT bool SbWindowIsOnScreenKeyboardShown(SbWindow window); - -// Get the rectangle of the on screen keyboard in screen pixel coordinates. -// Return |true| if successful. Return |false| if the on screen keyboard is not -// showing. If the function returns |false|, then |rect| will not have been -// modified. -SB_EXPORT -bool SbWindowGetOnScreenKeyboardBoundingRect(SbWindow window, - SbWindowRect* bounding_rect); - -// Notify the system that |keepFocus| has been set for the OnScreenKeyboard. -// |keepFocus| true indicates that the user may not navigate focus off of the -// OnScreenKeyboard via input; focus may only be moved via events sent by the -// app. |keepFocus| false indicates that the user may navigate focus off of the -// OnScreenKeyboard via input. |keepFocus| is initialized to false in the -// OnScreenKeyboard constructor. -SB_EXPORT void SbWindowSetOnScreenKeyboardKeepFocus(SbWindow window, - bool keep_focus); - -// Show the on screen keyboard and populate the input with text |input_text|. -// Fire kSbEventTypeWindowSizeChange and kSbEventTypeOnScreenKeyboardShown if -// necessary. kSbEventTypeOnScreenKeyboardShown has data |ticket|. The passed -// in |input_text| will never be NULL, but may be an empty string. Calling -// SbWindowShowOnScreenKeyboard() when the keyboard is already shown is -// permitted, and the input will be replaced with |input_text|. Showing the on -// screen keyboard does not give it focus. -SB_EXPORT void SbWindowShowOnScreenKeyboard(SbWindow window, - const char* input_text, - int ticket); - -// Hide the on screen keyboard. Fire kSbEventTypeWindowSizeChange and -// kSbEventTypeOnScreenKeyboardHidden if necessary. -// kSbEventTypeOnScreenKeyboardHidden has data |ticket|. Calling -// SbWindowHideOnScreenKeyboard() when the keyboard is already hidden is -// permitted. -SB_EXPORT void SbWindowHideOnScreenKeyboard(SbWindow window, int ticket); - -// Focus the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardFocused. -// kSbEventTypeOnScreenKeyboardFocused has data |ticket|. Calling -// SbWindowFocusOnScreenKeyboard() when the keyboard is already focused is -// permitted. Calling SbWindowFocusOnScreenKeyboard while the on screen keyboard -// is not showing does nothing and does not fire any event. -SB_EXPORT void SbWindowFocusOnScreenKeyboard(SbWindow window, int ticket); - -// Blur the on screen keyboard. Fire kSbEventTypeOnScreenKeyboardBlurred. -// kSbEventTypeOnScreenKeyboardBlurred has data |ticket|. Calling -// SbWindowBlurOnScreenKeyboard() when the keyboard is already blurred is -// permitted. Calling SbWindowBlurOnScreenKeyboard while the on screen keyboard -// is not showing does nothing and does not fire any event. -SB_EXPORT void SbWindowBlurOnScreenKeyboard(SbWindow window, int ticket); - -// Update the on screen keyboard custom suggestions. Fire -// kSbEventTypeOnScreenKeyboardSuggestionsUpdated. -// kSbEventTypeOnScreenKeyboardSuggestionsUpdated has data |ticket|. The -// suggestions should remain up-to-date when the keyboard is shown after being -// hidden. -SB_EXPORT void SbWindowUpdateOnScreenKeyboardSuggestions( - SbWindow window, - const char* suggestions[], - int num_suggestions, - int ticket); - -// Determine if the on screen keyboard has suggestions implemented. If this -// returns false, then calling SbWindowUpdateOnScreenKeyboardSuggestions() will -// be undefined. -SB_EXPORT bool SbWindowOnScreenKeyboardSuggestionsSupported(SbWindow window); - -#endif // SB_API_VERSION < 16 - #ifdef __cplusplus } // extern "C" #endif diff --git a/starboard/xb1/BUILD.gn b/starboard/xb1/BUILD.gn deleted file mode 100644 index 80402c9c3a5b..000000000000 --- a/starboard/xb1/BUILD.gn +++ /dev/null @@ -1,253 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -config("starboard_platform_config") { - cflags_cc = [ - "/ZW", # Windows Runtime - "/ZW:nostdlib", # Windows Runtime, no default #using - ] - defines = [ - # VS2017 always defines this for UWP apps - "WINAPI_FAMILY=WINAPI_FAMILY_APP", - - # VS2017 always defines this for UWP apps - "__WRL_NO_DEFAULT_LIB__", - ] -} - -static_library("starboard_platform") { - sources = [ - "//starboard/shared/egl/system_egl.cc", - "//starboard/shared/gles/system_gles2.cc", - "//starboard/shared/opus/opus_audio_decoder.cc", - "//starboard/shared/opus/opus_audio_decoder.h", - "//starboard/shared/starboard/decode_target/decode_target_context_runner.cc", - "//starboard/shared/starboard/decode_target/decode_target_context_runner.h", - "//starboard/shared/starboard/drm/drm_close_session.cc", - "//starboard/shared/starboard/drm/drm_destroy_system.cc", - "//starboard/shared/starboard/drm/drm_generate_session_update_request.cc", - "//starboard/shared/starboard/drm/drm_get_metrics.cc", - "//starboard/shared/starboard/drm/drm_is_server_certificate_updatable.cc", - "//starboard/shared/starboard/drm/drm_system_internal.h", - "//starboard/shared/starboard/drm/drm_update_server_certificate.cc", - "//starboard/shared/starboard/drm/drm_update_session.cc", - "//starboard/shared/starboard/localized_strings.cc", - "//starboard/shared/starboard/media/media_can_play_mime_and_key_system.cc", - "//starboard/shared/starboard/media/media_get_audio_buffer_budget.cc", - "//starboard/shared/starboard/media/media_get_audio_output_count_single_audio_output.cc", - "//starboard/shared/starboard/media/media_get_buffer_alignment.cc", - "//starboard/shared/starboard/media/media_get_buffer_allocation_unit.cc", - "//starboard/shared/starboard/media/media_get_buffer_garbage_collection_duration_threshold.cc", - "//starboard/shared/starboard/media/media_get_buffer_padding.cc", - "//starboard/shared/starboard/media/media_get_buffer_storage_type.cc", - "//starboard/shared/starboard/media/media_get_initial_buffer_capacity.cc", - "//starboard/shared/starboard/media/media_get_progressive_buffer_budget.cc", - "//starboard/shared/starboard/media/media_get_video_buffer_budget.cc", - "//starboard/shared/starboard/media/media_is_buffer_pool_allocate_on_demand.cc", - "//starboard/shared/starboard/media/media_is_buffer_using_memory_pool.cc", - "//starboard/shared/starboard/memory.cc", - "//starboard/shared/starboard/microphone/microphone_close.cc", - "//starboard/shared/starboard/microphone/microphone_create.cc", - "//starboard/shared/starboard/microphone/microphone_destroy.cc", - "//starboard/shared/starboard/microphone/microphone_get_available.cc", - "//starboard/shared/starboard/microphone/microphone_internal.h", - "//starboard/shared/starboard/microphone/microphone_is_sample_rate_supported.cc", - "//starboard/shared/starboard/microphone/microphone_open.cc", - "//starboard/shared/starboard/microphone/microphone_read.cc", - "//starboard/shared/starboard/player/filter/audio_frame_tracker.cc", - "//starboard/shared/starboard/player/filter/audio_frame_tracker.h", - "//starboard/shared/starboard/player/filter/audio_renderer_internal.h", - "//starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.cc", - "//starboard/shared/starboard/player/filter/audio_renderer_internal_pcm.h", - "//starboard/shared/starboard/player/filter/audio_renderer_sink.h", - "//starboard/shared/starboard/player/filter/audio_renderer_sink_impl.cc", - "//starboard/shared/starboard/player/filter/audio_renderer_sink_impl.h", - "//starboard/shared/starboard/player/filter/audio_resampler_impl.cc", - "//starboard/shared/starboard/player/filter/audio_time_stretcher.cc", - "//starboard/shared/starboard/player/filter/decoded_audio_queue.cc", - "//starboard/shared/starboard/player/filter/filter_based_player_worker_handler.cc", - "//starboard/shared/starboard/player/filter/media_time_provider.h", - "//starboard/shared/starboard/player/filter/media_time_provider_impl.cc", - "//starboard/shared/starboard/player/filter/media_time_provider_impl.h", - "//starboard/shared/starboard/player/filter/video_frame_internal.h", - "//starboard/shared/starboard/player/filter/video_render_algorithm.h", - "//starboard/shared/starboard/player/filter/video_render_algorithm_impl.cc", - "//starboard/shared/starboard/player/filter/video_render_algorithm_impl.h", - "//starboard/shared/starboard/player/filter/video_renderer_internal.h", - "//starboard/shared/starboard/player/filter/video_renderer_internal_impl.cc", - "//starboard/shared/starboard/player/filter/video_renderer_internal_impl.h", - "//starboard/shared/starboard/player/filter/wsola_internal.cc", - "//starboard/shared/starboard/system_request_blur.cc", - "//starboard/shared/starboard/system_request_conceal.cc", - "//starboard/shared/starboard/system_request_focus.cc", - "//starboard/shared/starboard/system_request_freeze.cc", - "//starboard/shared/starboard/system_request_reveal.cc", - "//starboard/shared/starboard/system_request_stop.cc", - "//starboard/shared/starboard/system_supports_resume.cc", - "//starboard/shared/stub/system_symbolize.cc", - "//starboard/shared/uwp/analog_thumbstick_input.cc", - "//starboard/shared/uwp/analog_thumbstick_input.h", - "//starboard/shared/uwp/analog_thumbstick_input_thread.cc", - "//starboard/shared/uwp/analog_thumbstick_input_thread.h", - "//starboard/shared/uwp/application_uwp.cc", - "//starboard/shared/uwp/application_uwp.h", - "//starboard/shared/uwp/application_uwp_key_event.cc", - "//starboard/shared/uwp/async_utils.h", - "//starboard/shared/uwp/audio_renderer_passthrough.cc", - "//starboard/shared/uwp/audio_renderer_passthrough.h", - "//starboard/shared/uwp/decoder_utils.cc", - "//starboard/shared/uwp/decoder_utils.h", - "//starboard/shared/uwp/extended_resources_manager.cc", - "//starboard/shared/uwp/extended_resources_manager.h", - "//starboard/shared/uwp/get_home_directory.cc", - "//starboard/shared/uwp/keys.h", - "//starboard/shared/uwp/log_file_impl.cc", - "//starboard/shared/uwp/log_file_impl.h", - "//starboard/shared/uwp/log_raw.cc", - "//starboard/shared/uwp/log_raw_format.cc", - "//starboard/shared/uwp/log_writer_interface.h", - "//starboard/shared/uwp/log_writer_uwp.cc", - "//starboard/shared/uwp/log_writer_uwp.h", - "//starboard/shared/uwp/log_writer_win32.cc", - "//starboard/shared/uwp/log_writer_win32.h", - "//starboard/shared/uwp/media_get_audio_configuration.cc", - "//starboard/shared/uwp/media_is_audio_supported.cc", - "//starboard/shared/uwp/media_is_video_supported.cc", - "//starboard/shared/uwp/microphone_impl.cc", - "//starboard/shared/uwp/player_components_factory.cc", - "//starboard/shared/uwp/system_get_device_type.cc", - "//starboard/shared/uwp/system_get_property.cc", - "//starboard/shared/uwp/system_get_total_cpu_memory.cc", - "//starboard/shared/uwp/system_get_used_cpu_memory.cc", - "//starboard/shared/uwp/system_platform_error_internal.cc", - "//starboard/shared/uwp/system_platform_error_internal.h", - "//starboard/shared/uwp/system_raise_platform_error.cc", - "//starboard/shared/uwp/wasapi_audio.cc", - "//starboard/shared/uwp/wasapi_audio.h", - "//starboard/shared/uwp/wasapi_audio_sink.cc", - "//starboard/shared/uwp/wasapi_audio_sink.h", - "//starboard/shared/uwp/watchdog_log.cc", - "//starboard/shared/uwp/watchdog_log.h", - "//starboard/shared/uwp/window_create.cc", - "//starboard/shared/uwp/window_destroy.cc", - "//starboard/shared/uwp/window_get_diagonal_size_in_inches.cc", - "//starboard/shared/uwp/window_get_platform_handle.cc", - "//starboard/shared/uwp/window_get_size.cc", - "//starboard/shared/uwp/window_internal.cc", - "//starboard/shared/uwp/window_internal.h", - "//starboard/shared/uwp/window_set_default_options.cc", - "//starboard/shared/uwp/xb1_get_type.cc", - "//starboard/shared/uwp/xb1_get_type.h", - "//starboard/shared/uwp/xb1_media_session_client.cc", - "//starboard/shared/uwp/xb1_media_session_client.h", - "//starboard/shared/win32/atomic_queue.h", - "//starboard/shared/win32/audio_decoder.cc", - "//starboard/shared/win32/audio_decoder.h", - "//starboard/shared/win32/audio_decoder_thread.cc", - "//starboard/shared/win32/audio_decoder_thread.h", - "//starboard/shared/win32/audio_transform.cc", - "//starboard/shared/win32/audio_transform.h", - "//starboard/shared/win32/decode_target_internal.cc", - "//starboard/shared/win32/decode_target_internal.h", - "//starboard/shared/win32/decrypting_decoder.cc", - "//starboard/shared/win32/decrypting_decoder.h", - "//starboard/shared/win32/drm_system_playready.cc", - "//starboard/shared/win32/drm_system_playready.h", - "//starboard/shared/win32/dx_context_video_decoder.cc", - "//starboard/shared/win32/dx_context_video_decoder.h", - "//starboard/shared/win32/hardware_decode_target_internal.cc", - "//starboard/shared/win32/hardware_decode_target_internal.h", - "//starboard/shared/win32/media_common.cc", - "//starboard/shared/win32/media_common.h", - "//starboard/shared/win32/media_foundation_utils.cc", - "//starboard/shared/win32/media_foundation_utils.h", - "//starboard/shared/win32/media_get_max_buffer_capacity.cc", - "//starboard/shared/win32/media_transform.cc", - "//starboard/shared/win32/media_transform.h", - - # TODO (b/304335954): Use uwp implementation for correct IANA name once - # daylight savings offset is fixed. - "//starboard/shared/win32/time_zone_get_name.cc", - "//starboard/shared/win32/video_decoder.cc", - "//starboard/shared/win32/video_decoder.h", - "//starboard/shared/win32/win32_audio_decoder.cc", - "//starboard/shared/win32/win32_audio_decoder.h", - "//starboard/shared/win32/wrm_header.cc", - "//starboard/shared/win32/wrm_header.h", - "//starboard/xb1/shared/gpu_base_video_decoder.cc", - "//starboard/xb1/shared/gpu_base_video_decoder.h", - "//starboard/xb1/shared/internal_shims.h", - "//starboard/xb1/shared/playready_license.cc", - "//starboard/xb1/shared/video_decoder_uwp.cc", - "//starboard/xb1/shared/video_decoder_uwp.h", - "//starboard/xb1/shared/video_frame_impl.h", - "atomic_public.h", - "configuration_public.h", - "shared/configuration.cc", - "shared/configuration.h", - "shared/configuration_constants.cc", - "shared/system_get_extensions.cc", - "shared/system_get_path.cc", - ] - - configs += [ - "//starboard/build/config:starboard_implementation", - "//starboard/win/shared:starboard_platform_config", - ] - - public_deps = [ "//starboard/win/shared:starboard_platform" ] - - deps = [ - "//third_party/angle:translator", - "//third_party/opus", - ] - - if (is_internal_build) { - sources += [ - "//internal/starboard/shared/uwp/keys.cc", - "//internal/starboard/xb1/dav1d_video_decoder.cc", - "//internal/starboard/xb1/dav1d_video_decoder.h", - "//internal/starboard/xb1/drm_create_system.cc", - "//internal/starboard/xb1/internal_shims.cc", - "//internal/starboard/xb1/media_is_supported.cc", - "//internal/starboard/xb1/oemcrypto_engine_device_properties_xb1.cc", - "//internal/starboard/xb1/system_sign_with_certification_secret_key.cc", - "//internal/starboard/xb1/vpx_video_decoder.cc", - "//internal/starboard/xb1/vpx_video_decoder.h", - "//starboard/keyboxes/xbox/system_properties.cc", - "//starboard/shared/widevine/drm_system_widevine.cc", - "//starboard/shared/widevine/drm_system_widevine.h", - "//starboard/shared/widevine/widevine_storage.cc", - "//starboard/shared/widevine/widevine_storage.h", - "//starboard/shared/widevine/widevine_timer.cc", - "//starboard/shared/widevine/widevine_timer.h", - ] - deps += [ - "//starboard/shared/widevine:oemcrypto", - "//third_party/internal/ce_cdm/cdm:widevine_cdm_core", - "//third_party/internal/ce_cdm/cdm:widevine_ce_cdm_static", - "//third_party/internal/dav1d_gpu/xb1:dav1d_xb1", - "//third_party/internal/libvpx_xb1", - ] - } else { - sources += [ - "//starboard/shared/stub/drm_create_system.cc", - "//starboard/shared/stub/media_is_supported.cc", - "//starboard/shared/stub/system_sign_with_certification_secret_key.cc", - "//starboard/shared/uwp/keys.cc", - "//starboard/xb1/public_system_properties.cc", - "//starboard/xb1/shared/internal_stubs.cc", - ] - } -} diff --git a/starboard/xb1/__init__.py b/starboard/xb1/__init__.py deleted file mode 100644 index 2b2e9ab17c8c..000000000000 --- a/starboard/xb1/__init__.py +++ /dev/null @@ -1,17 +0,0 @@ -# -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -"""Imports the Package class so the starboard Packager class can discover it.""" -from starboard.xb1.tools.packager import Package diff --git a/starboard/xb1/appx_product_settings.py b/starboard/xb1/appx_product_settings.py deleted file mode 100644 index 862ae1244f9d..000000000000 --- a/starboard/xb1/appx_product_settings.py +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright 2023 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Contains Xbox variables for the appx manifest.""" - -# Required product settings used in the xml template. If any of these are -# missing, the AppxManifest.xml file will fail to generate properly. -PRODUCT_SETTINGS = { - 'cobalt': { - # Value for the Name attribute of Identity: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-identity#attributes - 'IDENTITY_NAME': 'Cobalt', - # Value for the Publisher attribute of Identity: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-identity#attributes - 'PUBLISHER': 'CN=CommonName', - # Value for the DisplayName element: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-displayname - 'DISPLAY_NAME': 'Cobalt', - # Value for the PublisherDisplayName element: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-publisherdisplayname - 'PUBLISHER_DISPLAY_NAME': 'My Company', - # Value for the EntryPoint attribute of Application: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-application#attributes - 'ENTRYPOINT': 'https://youtube.com/tv', - # Value for the DisplayName attribute of VisualElements: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-visualelements#attributes - 'APPLICATION_DISPLAY_NAME': 'CobaltApp', - # Value for the Description attribute of VisualElements: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-visualelements#attributes - 'APPLICATION_DESCRIPTION': 'The Cobalt App', - }, -} - -# Optional fields used in the xml template. If any of these are included in a -# product in PRODUCT_SETTINGS above they will be used, otherwise they will be -# skipped. -OPTIONAL_PRODUCT_SETTINGS = { - # Value for the IgnorableNamespaces attribute of Package: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-package#attributes - 'IGNORABLE_NAMESPACES': - 'uap mp build', - # XML element for PhoneIdentity: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-mp-phoneidentity - 'PHONE_IDENTITY': - '', - # List of XML elements for capabilities: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-capabilities - # Will simply be inserted line by line into the template within the - # element. - 'EXTRA_CAPABILITIES': [''], - # List of XML elements for extensions: - # https://learn.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-uap-extension - # Will simply be inserted line by line into the template within the - # element. - 'EXTRA_EXTENSIONS': [ - '', - ' ' - ' ' - ' ' - ' ,' - ], -} diff --git a/starboard/xb1/args.gn b/starboard/xb1/args.gn deleted file mode 100644 index 2bf80655f42b..000000000000 --- a/starboard/xb1/args.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -target_platform = "xb1" -target_os = "winuwp" -target_cpu = "x64" -is_clang = false diff --git a/starboard/xb1/assets/Square150x150Logo.scale-100.png b/starboard/xb1/assets/Square150x150Logo.scale-100.png deleted file mode 100644 index e66555b923d45c32f3a9cfda8dab4e49cbade923..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7212 zcmZ`;XIK+munv)g5SlbY6+)9x1A?KK5V}YWL7G%)(j&b^dJ_x17b#MMfJhY(K|l~b zDFRYNnlu6FAl!KW-5>YaXZJjN_RM)_X6L+TW;fp8o+b^H4GI7NXtcF3Mx-|V-w6Se zt_oz{OQeR}NmWl30H{x)y08V2?z!!?jPwA2AOQd%A_@RFBXvcr0|1Ya0KkR~03eqM z0KmL*TMZRR55RW1ni#;vd}~eHswSF*$t7)wob1oKBV=B({G5#ux|Qa`A?E!_vR?M{^EYI(5!zlv zf(>6Ue^lMK*Cw{|eKIFngG}Auz?6hWbM0WRhU4#Fr-H@94?auE2M>=a&NavvDEpVS zJxJ*cD)2vaL(}*UOr_XiE#hiiX}`~MO?Vc3_R{cxxn{wmqZWZZOvuNK*_GX+Nd@QM z#mxBIH#xE}?u8EXZjke(1%ye%cN}2hLBXT%;78lDRkg|8bMisFy=5jqZ znzw4`ZVl5X&mO_W0tc-y&Ysjl&Tji9;X0a%=6ATs;N*O;#WDa&CTakFmkjZWSrXCR z!YuUC7hrU4-9nV6|KhbkLe|#|qAKtO4>Vd1=Yv|A?BZe%Y^bs%4+fwMCx=?c0RE=)v zLPV)VuPMb=S-|!+i)#xoRVLHJHjms!no z$gqJ8+>I?%tAgXFi*F#p5NKpplvQVCB1AQAaH^nL$dzg5dPXPBTuqlh4gQe2CYTgT z83+}@z(YLhe3R-+5_ir1 zq?bWUl>s5zOvmA?4wG(Ie8a4|De8TupCKakx?q>lVsolWfHJO$m1`VBR0<7;8L^H` z*3eq_vsjsYmSE`GU^W%^7QtHRG*(%eKwDIXzs6*z6fmq)^calQyA37Lx$>C(Rw`o6 z9TJ6>fSAqV(4T}1x!ob2F}miegVCR!{sS^oTluP&4t&WeKazD=v=-SE>QA2Chl>^g zz0L5cCcl1k`;qfeNpKIlPVSi4U{&&#Gb{}aA^_h&59(u3ELpx`-Cw&~x5mQwj0D^s zz=X^R(OQ5Snsf%umk(vj1#>Lhv@#Ve*k!+p2}P^N&?Kxlk)J7L2puU09pygQ#STH+$g-hg& zX>6@yl9EHeEPq5gk2dep$lSfWG2Ga8{wm}}m z^9ziMxwLnMd_p~9VtZCJM+gihGMz-A2_1au+7v-NW(DodjC+mR?2}QokI@8-3Xfx9 ziG0F9CU}4O`$&(>cT${P@f16Os5wN6yYo|SJvq#OiHoEPOrPse>4IXVYJb`sGc9SC ztfH|iY(fRr5j)R~1myhkjrY52DK`J;YZm?*5qt(n(to|a{*)(8!cE9T3=I7w^sIhY zDLm_zjpI!xs*K<39~?}|3m>$^NSqPp)>7^|>`soo&W5H9$eLiID=U#Llo@>rVXB3S zM$SG9B{@TKgevLDnMtr#{B7os^VWr_U5n08%`>}E8bih+pO%=xej{#&;*wrJtWqt= z?R*D9ZM@7BkYu&SY*g$i7+>2hb5~4}ONb6c(qvTgM+cy89aBrbx#Y?5(d2uf{p<(a zZ4IvapSk2+%M4c6ybow@!Cy5`wFZkA$o|v9a$|pSWU0S;wI|Ic?`Y?t7U4E?pU0aL zYD|O&gkvYs)|qc5FT6~4*SQc-DBi{)VCYf-fIVsY`wN0slZvfw=}KVMBClZUFUl9x z5Rjbc%q!mWDg<;9nOH*RQjZSSDrbZ*wytqz##J&MG*mIOGii~(k`$PilZ%eiR9ks& zJ#Tjb#01MwPuKf4h~BDpO>VON$)*)gCkSn$RB2J;15_J)dM5aXu7VwC~Do0@zg`+ifTXGSkltJ|VV&>-5B(y?jw$TDC3sLGgBoL0CWx0LmO%6f>*&Fanh9nd^B9#~2a z)_5WFA1v0kRXN-G!@ou2upF*uF!tptJ*q^g-A+?ErvLUoUkDi%UT2t#^u{0c+4%UY zVR<{+Kc4W@Z>PT)daAkb`xA(xrrxwUralOJ3grWUVKOsZn&EtuC>-4s$q6YX(9b{2 zh;J1+2`&j`kHmMs8KpF*(^GNmB-=TQY=5I8vgisLM3i>@z8-yb_f4bbqRvNp=6v7a zTYUoKxj<#pjXjKt#){0S^on^!dfYxVkPzp0tyO{eb>7+r{&d`IEpHwQ_i8OBikDzO z3}ge1gh;C$5ngLMX%nSufH~39q{rWouy-tPDgH$z-byMOT`K$x5+{JigWu6TkEaG*+tP_1>(`Y{2i(O-w+A}BsVp)t9u!^%@dUB` zm&&=I*dYXKZ0ehN*GXoy^mj!NDfwL0NuP2%psx@E8JoRLoicpw%&>@Vz+aYdG*~e3Ftc%mvZnCDUoR^B+3ZbGd)c$CV`{|JYg2@I)I(pOGK2HrSOV z27!xF+oI)pWWL^pQBfdKpc~ZKJGj4MgOGjd3pjYzb5ZAG`#WLO2%#JO`+UiogH_95 z)M)V*>`aUv$vm~Y`a|174U3!4y+9H2nMk3S=Y$J;3l*&DJ6jKAhrd!7E*~w1a^#qd zjWMdvl>KGgkRETRCc`&JC7JqiXZyu72Tr$yWBVK7qm3Qe6pUKE)&rdU||28Pz z!u3{GLThT0yJw~5>qtTbvlUFau6=u@3c`$jimJy`et(cLZG1?3`Z zwX|WRN&(sO)#I&$r$Aqk${u%pnr`H(X<<{+H;m>nlR$B)C~qxACC?kEi8Z~*mf!tV z2UX_FzxE|3KiPR9pl^;zW95I8d4YD6oSrwcL=Yy2*7>3rY=yV@UTy7WlBP7XZ<3a1 zbe|5WEFP^n?NH%yWA!FY{NmRVSZPx_)t&kp9;J0}x57!!$QMcFD_ z_c?x`$b&4=agiyq=ax35pYPjSUGBXky?d;xEv+aOyr_8~v1+44P#J@q&%SJU$xS(q)RRFin#f3IT&77-2ai*btUciM= zZa~NoLMhtAKB}tNDm`6`1@EXWD#u5o3NZP?uZEbh+2x}A|LClP3DkL zwfgh^l3y?1xo|Vtc%7D34Y5%|<`(6ttvWgSpv{TK^quyzrb|)D!|GzERX>@?djjr$ z>`E28rkBhj|H7+Hi}{Begu>$(abVxKd#{c2AN{@fjaiRA8M3^iO|ETn{u5|}6fw^0w?^}KD&>G4LuU2+EMb~E4{>Emu zRu+^k7A6=KGP2zxq8S&lSCP;?W-`yUr`qStjv|-8>hx$%G`sO=YSQn7Nhho9q%8H# z&^A!?7G(16J*#Vz=Y;*47ASq_7}tItBV_!cQvz96Wcd3VblbnadHMvtCzoobYO=h} zK%#JNr75wos5^EC(r|~(=qt^&A&>?=~yHQh*G(k26|2|pEA^ni6ZKP2BQe;`X)pb&0+h!$S@)Q4j zF{9IiEx^#1pSRIspty+o*VN$t1l%IW+PgT3){${p`QPlZbDgE2EdPV;y{g$C$AlTYIpE*AT&3zl|h%gd8|$pD$;ATlxMxoe*^V6{}OpG(CM~GUbsHw)VG<+it0L9 z$xERajcwyaj;VK<2z>HuD!J2E<+jkF+k!!QeYG|2yXR&-8~l@L@2;l<_3(7PwmzB# z_Za(gykRXZ^>h=TFklx+Rf@)DtyVNKJ)e=WY8lT=to(e!#{Ak~MW zZ)WR?Ak3};hbU!!y%TVj3pa(FKJb9eCoVI|D5TfU{6S#w62|N1#%uUh9PPWmi~zx( z_v`v=T{V$~e0PoKdHLI?ryj?DmuGFu#o54>cv>Y`j`Et`G>vT+kf~(R(Rc3t2ROQ! zKZC<9-Hm#-&Z@)x10(Jw0b#Fh!HoG7QA`eGFju3vrjr;^cXX^^!BNlNdz}lk1D-ei z`n_w`dR7$FM$PpQYGq%MJJL2g*V6k2x1n6$#HqwJkrvm?{7o^l;w_MBk7RmL+U4zQ zG&>{wrU#HunD4!v*NlT@VRSaE!q2JVcT_W&%pgBl?C=@OZ$1vkB88xn`R>~?-o_;+ zkLzQ_jrkeKN*Gx&eRCwIJDx#|*IkX*8mCK{%bArMk4~hwAt(2F zxz6Tg^}lbr%qH^c^W+VG)7+VTspUlRy9$U~2m%{~{05BzN96t#zpw1aVIDuB}Y< zjm{MWB>T3!N_9pctq+Ej6{Aag+sHG9VJ52aBjlTx$2N1>#Bu7*9I8{@{@=yW>tv*~ znTIiJhH7H=c-OFO6ze*}U0$Gze}t>EvY1``BTB=+YF%j^Nm?iR7!>Lb=!@4`3r4d! zF(=c+`<3{q)5u4EgAY2N5lCzzR3yqvMB+Q54S6l8z zlMBqj3iB}GE3U?OwY#@+E4TG{kq@l#pL989guj)7LCY~c0!Wo*TI}p&x7aAueRepd z-?y<^I8MEXuMvC>VX?L&0j3;yml1`VQnf8Q{l+JKaqe|%dAOR`g?_tf>*De>Epk3% za1fYr(M}sdysk_i+EOIDd+Alu@%w4ThQN~AwVy03_b%h9_P7nbRxCAv7WS`cqyFe+V3BZSx_)8298br;Z~fUEuvVelK-5jv+qcNBv4^muy(1 zz97`<`O^*jWk*`{P!kHE=!a#$P`V+lP}u7Nq7B3lc0lqfm}aRO8qXsN;l!A#x^%Xj zyCupm!qTWtuUncF50GqK(rT+vf%8dCU_ul?qNQp&zwUKGa^il_A`G50SkX*2JdmNS z876!E>p~m89NuOKMw=2|Rtgs}pwUyZQWH@wkP1o~;}6~#Udkz;2ByG)q*Fo_e&%rH zkijaPb)Lkd5O8Wm_sX1+T}Aek0Fc3@3MN=tO~S-)Z>tP^U!i=4ZsjBb=;!`xZ~f6Y z`4gA^7&sLP0#L}`LP{2O4n_w+uqI25z=;inmqy{|b`|C&Kaz@X=xnP+)><%M4#M9m zGZGg1&3jZ=Vw1-Db31R6t*7vjDvgHAdJYW;<=5+rAq1po6uB0hoE_-wObfq$6v;w1 za>FVEJ)g^>t++vl2sq96XAUjA9;+l(SX zaqH=QkA?40RED`ZSxNyecJ`dI!-b3m2W7-EA;;`$PU9@yN6h}p6L zW4gC##L1pTy!Ng@aF+FTv#9P#RDm1V(NqvOP{tR})^%{lF^UfMIMeAL{QI>>QqpIo z9)}DM@JnpuHqIi^_1aEgH0aBufqAsF2|dcFhAk;hsZs7%r4Y#SV6Rs5>y;{M%?U5`y*U@*Z0~VGNfuv7_YaXusgG7B- zxo|Y()U9nqUMjukTdE@T;BFz*8)<_%a8WNBDpoVJ^jhd?iwu%9if=W}*X#jF&?{Y3CU*85Z(q9r)mn%&dP3_hLD=sBoXRZ=H7~ zx5QH>eq`SHzU|_)MvGUKp$F?X0oA&xuNKH)~ zHKXyF@O}P$yOi5^Z4ZIEEasm))h1H+b@(4Ve=f=7g4nA<$MsQN1s+-2>5*?bH5Ww0 z5P78Xl*OVh^y>R*lFKA+ih9UWuQ6o1>UDS-%P3N;aSB0L=&gzc4_e0NwV6EDO&Lk* zapGz<)jpwI%sYBN^`NMGUw%9UI*}((HG6(lgkHO2Y0~usgSR-3cf03espzYQ(jR6P ziwV0}fl!1-3il`}+aKUE*OX%hK(vP#dfk!tnu2S<7?0ruP;b%FCSt?NiG0<-BCOZm(9g>=aLMoHNlUxoaWlZ~#^2xS_L2JQ;06Aui|vpFb`I^~DwPos zi2=&?SFF@THEO}StFFY8c4?9Um4aKop>=wzT-L$g&t7^%2!H-69dVs@V0gH*w?UPp zVwBPg{${giqsjRGa?o>IWwz`O4Z$S7L4VQ(oUZ=%2-S3djqKMBe|%f&0}CWNgb+g7 zms!3b3?8OAd9m~{?EJt+-cOL~W*NdQ3tcy*diucQY%wD#ySg5*c&5m^i)fUS_X?5# z9MJN6y%Pt+0p03;O{$7|Pr1qLqHNTxX*6DG!>{&gu6~8Tc^C=0OP8C^MXJ$y8G_E| z)fly$sCP+KpQd$J&#)~y`jQuO@<^`|*`Iyv5ov;4G_E-G^4w}CC9YYISFjn6CLA_6 z%*`oK0m6JUS6stju9&81N-xsyG=99g8Q#Gb?|QKYn}q^yaAq#RO0 sPEuMFiIPJiI}Xd}|BryXr-RGG!2e(1bH&XXk^n$k{T`+kZS&-R0O3U{6aWAK diff --git a/starboard/xb1/assets/Square310x310Logo.scale-100.png b/starboard/xb1/assets/Square310x310Logo.scale-100.png deleted file mode 100644 index daf83b0ac62d58a307bbec16ccbc1e6b8dbe2f5d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16100 zcmZ{LbySpH)bG%Zw1gnt4Fb|bcXvoPNR2dzba#ow(2XG7QbP(OARPkI-HqSld)NBz zx_{gSEEdB)&)Lt8-;T3Sw1%2I4kkG!2n51WRFKgEfe-}#{h*@)pB!{{R{+0|?ZB#F z5U4&8>(K%Q_?y~FK}!_`@?!*ng2O2ZQU+?-JOdaoey1}YmmT)fRnd3qKJe-K`SL^r$wPVIAvY& zfr?y*-lEuqI*n5rT3}zyyv^Q`MK|XY??2w=<9Q|!eJ&O0S0-jo;?zyzkR@{xMfp#E zi?ST$op3ljr5MF9wv-gq!M+4}JG~!F6d0BoOZilKLTy(6Z2n!1sAlWOa{Td?6qV93 zq^_DJj8fWA;m8|;tu4h5O&Auw`6gMNuiy28dX z4!)fqQ9fIootOBWA%p|s4=yDq#5&-(WHjmNx5_F!D=kS&dM{3QLEkuzG4E5H=C)!Q zlJQsHFDdNy(|NINBq1JWcgIVqsL%t)A80C}xGPU@=CtRTaN})}NrMCx%iWrk0XtsR7NFX8P`#g)8&dbI2eo$~Y z2m0e98`=h&1l41h!_*#Om$eQ>gi|vRWXY$JzsaiXy@YfBn%2FUhWUB%p6(`K@Z^g@%^!02J!rep z0m3x2zx1LZZ^oW-)RLd=P9o_urR@C6FSrl29%`d%k^wOae{IHKR@Z*XHRUe?&izF! zM0iak1kX!Gu75H1@uDk#ky7X|6k2W@Qwfc}8N6QM(qk{xBbsO8loSNdblV^Gqc+st zeUFZul=j!(-^@_7GeP`-?347%`F9m@xNW3@PP+^s9u11&%$68K!&k?zVtds!EF13~p+ldZte(G&lfmU#MumGRUtA>F!F(uSt_zawCy; zXfEEGn77ZXSAC*Bj8%T_A_x*b=89B^LhC6s_II1|||v=rDB z&3&H1zh#|##vg0^8SgT%eoy1OSYxysLiG8 z-tjsDUUfloNjcb=F-3mVFA$-Xw>DPmcRl}d=?FbVZ_9#(sc4vN@fbodz>-~R3m!6O zGm=qznpCrPCVR)tbXg*GQl%OO_EmONE?!8?b zIOsddz>ngCyb~&MAGz1x`}B};Ouz1j1EzbT5Y^E*y1%RLWOt1rF8i+D#LZ4Zs`Op@Yxzqx39FyvyRYhh zW>z1&Z*-i*#^Wfa-Ax4Q+CEth(vtpX!4fqJVoTrL?@1uo6Z4qEpD8+ix4$c|=e!)$ z0tAeVU)MS!)tCJ10&bH__^m6FzA`0on*}Y#^U?v9PXGdeHZXHR|2Txg?$2jfXnn%TcZaysGc)+hfu{-Tby6IlNl zpBq5e7xeF&@%+@(8t}c%>gtGtTmBx2USbzZSbpAk)l&&g#pgxIK)EUyvwE;R|G}=( zj;WLpWc{H8Uj|^1YGOIUdXVr^{Pw6;K+eoD}h&EuRLjRfT zr-HGL>p@spbbs`drU)8DJ1~=_ zrWHDdF^z4et=H0*2g^H}=uR#@olyWw!_nY1)-riZ-=2?9p3F&_4NqrVswMeJoUw%S zmZdW}tWkA)U$=KwnW?aryMK8o@kuj&qb&~j4ZNSa9chunr>mR2I}ZG((Er{X#I}D> z4TQo{0eV)+@%w_YPA(GkQFiI2T&j>;{;0f#Z|;6*%Vmgm&V0Yizw*=NL261a=;p`~ zoQ|?svB){-o!@Q&QZ4a(F?;1>#*Us=4@C%;hZ?I`h&}8_Yy<=v%-eo1$(O+U=qq+@ zF-EkL5sN~Z$bdd}eFop^x*j~IeC*`fmayTp_uaJ!agUrCbRy##<0{EF3Gn8UY%DC8 zxDR)Lci8@oex7>i3HV(2tEHD0tFH`yJXrP?@FL?#PK4xDu8Xa7?%fuehVeB!oL;l7 zN{Vh7#qP|#vr1dzi*He{?kR!jLh&28B|ZB|ae!d9j@^$(ajDJ{-e{>K-YqRoX%Q=}Lr;LY{w%?XGLa zV?9K~-<;f1R=Va6YnsT$35*fUMr_nUuzRQ~<(@&p%sT9mP?kw8UK5@7o>Ph#BAQdL z`e}O3yYEBEF9SPM7t%s!4rY9F5zHlT7@RL_T{}l!C(n=*KWRkC`6#OJqtK?ekV@WYW6oxQ1VP+VlivQ-hj0;rrZu+v zu0K%E-rO#39HUhYyXQWB84I=D3{qO^&)4u}ftcj1BX1$>N?AAv)Frc_Q?pmGtvc8O zwQ_?szg9Duj)TA&NG20aT%yjG_302TG0=XvXvz@cM*U5@Q$jf@Pz{rZe(0;q)6~ki z>|=L+SWmmD{hp9Fg9f;{SuF`f$g!x6BgT5sM)M+>m9SCt5}o?}oKgh`g|d^^t$yI^ zfc1%YN#HSx{p$QLsOg-MoYY8kWQ~pT$s!> zQbr+dM@X1|hKOtWuF%!I5%y2DcS!8@GMrJ0XJYuazz%$i?&%hlBS7V&;(i2c8NU~S z<)c4#qkuOYlQK!9-?5cQP$0KS)6MYMLyH~kSitjr)Xoy!0L`>-=53pUt z!x!tmeyXcGf}yG9B|Zl|Jl(O{8yaZPQadR-A4C;+GXpBpl}`VMkA7ha%eBxM3c;t) zp5)s=wvayGmK$p8Xd9fS*-6#Z(Y_D@guS@PjB938`G%lKZQ{DEWu_-;_sWd@=!_pj z_mo(6&LFo%j-z4W(VS^>Q=2Ru5|T7@g<=!_7FiyGmOCz;WDD>T7XkDt16|A}tM^vb z+5)K#;z0Lm$-l=Y2CE#Kbx`KJ{W92diFxDSi!eIBEkk^Y9&S~2sCd`)hIB&w=;Vk3zr7mS-ej&8+=ClLtg~Zb`G?Eku8-yHxL`j zXM0je>yt$=$4;X>Njo$`29lcY_`y8o6GiHLas>8W@NMnIbCEQ$3P%f(4VPHBV9ux^ zJXjyxgxZd#HQ&vL8cE@bg=;+VSuzoELqKvwa2CzUsok-M>gDoJq-i|me^&OH@y-mk z@IuJ}a>@8}mN>Eua`jwBjL@9JSDH^PUe)AReb@XuFtC!>>f!cdBTZ`hcHvzC8xCD- z4JGpTRPq{A_rpVFsrqta?B<*XDFXY@0%>*TB71fC7h+u&XZhzR1X9wbHM`Fc3k|@b zf48>rtgax5!a6kEBJ|LAHPP!8St?fN@#0u_-{Id=N>;oDBqfzmUtBQp*k%*+dka3C zc-G9&+&l!A7%#)XL^vrRjzdVgtxh`sDJbxI$D943xRSS7+x19h@p}Aid;yy(T^8DM zbg<5%w5LB&zoxhZ51WTK!>WB|$UN%Qx2B9_lRd~XM>g0GEzo@P=m@;sB9_N?+?O~6| zO)wdMrdE8*->b5YU1N`p7dQhzC2t`Vp7u)J^ldKE33Z zVQwmI*sC6^&-lbF&S*8xQo@_vOx7{6q2}Nrm`_WiEYG-A=M9$e1hu3(!2qf~#~0T- zZF)Blc4#---rHyk8(4 z){fLJEaYuwV3LTAq@P~)5y9__Bw;3!Y{9S)XDzuD$uQK^ zG;8|kFO;zUeE0w)`RZZNyP%tqaC_>-hdoQw` zi3CfzKOc2*s~F7~*gdz{#1KBk$vQ!qBw$P1JgffS$&Ad&5Thr-?H`?24dh z79qogqzQ|#Pi*@EEl?$g!$Z}=8WCK5N0KH{(ce69h2Zyee3#{#J;Nskm{PI_RZbhAMt0l^Bx&!mqN*BWU9Nas~W2$khz#gT=V9fkN$!x z(txB|p2v6x6@v!21z`R|6Qu1vae|-;_-GVO(yi$4#{%D?uOdPyCDk>%4hP<}sUPBG zvG%$6a6TG|L7zapFin6GmSK()( zE7*uO0;<#5vg&MO)<}SB%UFsvW_)!Ko3z3Lc_mCLsu0 zlJztuDst~|j70`qgQH&tlB?DJb*uT@Wnksy7K`)iAWSl2ax{K}ZUYU#LmPfhk;rx` z4f$M985tIV7OR`in8vEd|8{(PRH}X2;x1IYTMZy?{IjqKw=Vkp&oL^_s{WM78@QPRGUcgV*xLQj`D_&t-w(&)`E z-||>TkHxrvF}}Oa$N_dS0@=!CGzVA7?M@=s;~M#XeJ?b6Vy>iQ9)1)TpQ~W~=P^Rq zGaj$8Zhr3I^$4`2>m26O0M+H71FYygCoe;FO9J1!9a(E${Q6`mNx|Q;H)j~&XL%Zh zT=GN`bIA*4E|Na&GZv!vi#hn1I_o31bjDi!trT_mQ4QJ;`9&}Fx)^70`Ye#>7B;aV z=<7w4*F$+gPoEW*D+{^=XJ4;-b9dtjS%~;sy|l#e50dU`gW>5kA{=TtG`7Y6fu(Cn4~Y9@XNn?jbO~|ubpMwMU~}jvMZas!^RQ@+}KziyURutW=uC12@8S6 zZ5raO6gFM2mZ!)q2jY{Wc};9ng{koL)UQ59+r-=u2NWO|^HKd%^(&4^p4ASlY$ls$ zGg4F#H)hndX$jS0eVZS-`;F{KJ|Q=LetSJ}bTQk$V_f0CR4v)#>^?ygJFTMJSF3Nr z*21pgv>1)#jjbS2)G>X3fRBat{D}b~n7Vp*-v-A`EYPGJ9k49GF74k_$ch>U#kX`u z!c=g@vqr z&Yn0}sf-l${q)cO>_nqYa`h&X~>Va0{x8j2Y4+tR~R*?IAY zCjolx+AKk)0L=n+W`xsXIVb&BA{SPjq16sK1w0LspLX99Y@bM{R6z;XW9vAKmqA0R zLq-{`DfZVqcnE4iao#uPtne}npYL>h{=2@2E7;68O{%|qfm&IK)7kF*z7+4#gi|$F z9111HW>*tk%=7y1gfm;P6{ZZ4%$(DCdvo;;>uxu5MP1;&e~m)1DNj!Y_rHXh zp63;g?Iwr*+s}xF2<@?9x0EB~Jysa}48+a9lquGI&a(oDA$oI+h?XOdq$fV7Fu*Ng zL{xrM^zS2Pk14+3-iTyLYV%r%*l9Bnuz0`I4*e$^Yk_=Okenru_(ki~sS&yXOQM-S z)y^fE8Vj5n!bg~+>jJ%=)CLF=47zAN3LK(R?H+vpt9pi#CQx_y5n5chWo3{ciFh#A zbj*RX6Wf1JfYb~3JHeIMmzwfQY#nJDWm-B-d(X;vjx z@)`a&PrCKY4(8*B$@5FzByqp~w)_?V?hGQ?`P#>I>P9_z!;DtPc3n6SOMqfEZr~{8 zq|7}6cKhNf9B2cx-CX?$Ab~Ivnaoct&qr4u{rCakO$G`BV&U1cLx{n*#xe{8cvdhT z9sEjbWTNH^&^Iathzs52$BoI_%o#}__WZFxft9j1^=9=Olm|fy3Br}^!)$#g-qcgg zvb)l;@r+;}PbbY+2Yu=%b9PCj)h_(!t}3U{ml%-L2(Nd>lOzxUB9(cy4jU$C{U0vX zd~@U>8LC%1ji`R8TJw4U`Le+na+*+7ZDwtQ=K&?tJ*D!3b`t7JPung7#G9#{(=x}E zd;>}Q>21jyVL!t8Mf`B>Khwxo@lA&Bt8GH$CqnvefuEKK<<#Mm+~{$-*N!c zaRW?;Y1mKWLZ~o=w<_-FwL~ZBNUW~QrB7!-Yv8)8T#%r z>fCKr`8!G#S)NS^!m^ci!hX7m90h}F9%PQSHUH>fpQ*uvC3$WkBLmF~nEH~rrqyVu z5WcA^x!2Gd?rFDC!ROC)9FK&;{=7P7PI-3Z8=(*W2lJ#SbIpn7jlq*Z%(NOM#eu(2 zpm==XTOgOHVFWHG**@a}3eNa2P2>}*y~7P~P8IZ(Qa#Xw5A%P{5v=3aEk$mAoI z2ad@#LkG39SGTAh-9PbzW1p zTzG8gNe$4x+n#I% zAZoB?JJ>j%1Pqz@a3-J|Ze$1Qg43t$PZXhDA_x_iaWXE6*zp`p+B|Tx=z;j)X0wiT zEYv~k(LS%mcC})yZxt1*Mpo!XJkK8xe=CL0PArqUzUd#2xq)Y4GJv5JX-+LI04x>q zF|ge~yS|rQGmqGJ`r)an9pLkLAQODV3K+13ovX)UVQH_fT4~`=>U)IbTL}x<$Al8r zEG?MVuJH@W*$jDuj8?Bsz>9bdqyKduY`J0n?9vy-$OhwCF=6i*qfWq1{#b$=8DWay zN0&IJQH(jIZ?6iv*qQN@RCb1Zh7KJ}vw*i?pqGS%3gk3%9H^a&WK>%8=v{WLIfK{C zGsppPad=L$GUMYZ3;DP_Fh>+=6TWHAQAsaAXn)NegpybVEwSz)Te6584`th02bw7M zH**n10@+J)WumYzz{3OKY%-9d2mmM?mu!$()lC`f?>Ni0Ui z>zwMp=cdpXQizKDYCft>eM%_V&w|GU9X=r0AE;^u=K3Z$#3aT&JpdNPQB#x}LvE~A z8UxrlSL0cg+cYiU8A^=f^LkX!y8Ym{C)h`ND7r>P4T90Lwa6xICqQz+UY5eVNTe8n z!GDRF+^Xr|;M%t55`?Cme#qc#=Xw}+v=1xw^NgplXFxbjlLKnjBeCc}AheB*aD#&B zKXvDxwi|W4ml!-TsLT+n-mMU9D(YfVylUEho53P3g)EfU*PKAQ*uJUZ=-O)uEb4%R zo-_!bPIBPA09yV!Os?m6XAmoU;j~8fZJ2k&?oJ;L(u=yl4a*^kz< zuVLc}rh1M3)Y8E58TdiC|y!``G^*1>H|2a+jriVw5huB@mJe(avRr` z8O_XEWG}T?R;8`7MidEtwoo#4Sq3L z@>T!{SCFDl5@1tketEHOQNd3VH(3^yREW^V38C6&?}~3r#say2079YhbY*h4;mXp_ zVv&g!m3TN%fA09_VwtB$Zlg!ss0FO{^T<&7xv;@RoKW0L5z+_@@i6;7*g=h^hUp(& zjx)uQtpuj$bairM4C&6R!{fmV#}b->2M}ox+5k5gc0mN7rGm9d*g;>cg2upyt$yW% zHWe?4`qh)uEK$p=6uDd#e~DAkE9hD;w+eiZT){#pTecg8NDA&yPOT`kPvxKc*KEUP6T7mu>fApovTGM#lF^Uhg zM=J+PR}?*=R-`?9`|1|-*|}46j0kub?sCkQK^rHlZzfORRoPv6S|8R**zhnkmz%c$ zS>*4!Eynq4!IY%8=}Hza+0mGCYXi>wFobnTHB?2=DfsiW( z9)d650P%u@PY`M?qXu8p@6`u zHRUSSYc}T>A2(0xe84hHTB}`oWkCntb=ca@!VjsW(F=S{&`lbG4HZ6m@zvJO-jfnt zV#{xWkEh?ZvZnE3Y&|m4yrn+JSdWKzT{B=kwc+$ZzuH7JpyhqHQ&ff(_o0Hg1Yc}k zHQ!=!>MMT6+)~97&fQL^0Egi6shr6&=-%!&IV&pnriC4?yFTM&jK}WEEOtc#Vu&W1 z4@rnrfE(%!KMv`B>=`&I(L>QD5CGkdY_VyW*}=Xgv?l;`EO-cX^?k;0jN0jcB5-|x z?-TY+AK!dq%VWW!0CnC@F~56H71aCT*AHjK&r09Dh!)#pt-wRlA*=5JU5rkz7j;kA zDaMX8h8>;#^})*Es{J(*=iR~t2zX1~&P+!|=xI*x8)dHBU zU}>g{)kDd}Cb;zKCo1=M_5iFXERSY#NS$Byx?1@loMud(l342zK zZ(J&bY}uVbr@y7UZV#GoJxv&FM#Fiq_FGF@0F{DIxUtVge~2f zX@4Cu!W}-~#gM&ZsbJF?V(rw2hyE)<66Kbg)<{YwVrNu7BNx(k=m*JNYpFV9i2}KF zJy9AoH-gK)opS>342J{BlPYaCI#2=vuHp%}O7hza-%d>$W&_)+qAEQa=jfl+HS;OF zpJ?<^aPm-csVC%U2C^Z%4d(+Ci%+;^hb-kbCf?gphlh%yJMH^=HS2d>LZ$6AAVU!$ zUAW>V@ugZn-W+R1b;8?OuzbrxDqPfr=bFdkFP2O{^ut& z18;2&0*Zt7qVcFp8_&F3D118pH@ILkQY($T6i*b{N0J^%o71P&X{bkZ4UY*H4vAa8p7 zl%%{XLH+rE_yMUUs~3k17X)NLgo(sL+ix~(&?5(;a-EisuKasdY_wQNAR!-q;G@>W zw7XiFq3IMlnz_lq$cfK!V_bnU^XTL zesli2Zi09mnsgQa7Jsd$pC__>>ETn~C-RUjM`GoG=OE^(VM6aRsS$yTlMd^* z^8>7&C-Vii#Q8pKkV*_AQqiYGiG3tSOla;nAwT}uv#sb2n4Zv^y z+rBM1GiSt_oBjpBuxW<5s4tS8e(bwG$QZ&BL_898f8apbOrQ`TvH@9R7{eDBtjiTq z9?eMmOd#|9w>_$ut}U3U^@V3R*vV3C!N!DPg~Dv|J*-K_&g{A(AYJD^kT1);p$cH(hUB}9a8)7)ni&|SyhHJQ1>cBQxS@>9#oEmTF@ziyJGxbDj z@J^&t&5a<{Kzv8X=0jur1D9z;gpud4*USf{y`Y{=ix3QaZlM&}6LXtflw1y9<@VWV z|FMLgpvbj#WYo2A98j}2!_Vn_-%uKb~C(FDbO-^2&AUbV~1Y(Jd;SOfD>|S$X-;Wyn zMuP{y_079ZBCKt>i1YXkV5Sb#=ImllA4}B?eXto%aWv)>TNj>KM5F@{P-_gY{Xt8; z4WRnNVGolw_I^cW3|FK9%m34f@1m&3551oLvvi=P>H56&x1eAmrJ~XM3)8QnprQWT zSRL{sXK-04H4SH-WBkpesmThVHxhuXZfhlDJY~ro4o!fRg$GC=!g%W-3wXB5vZ>!A zj!RJFCdDU00nq%Ea9Hi?3}J1RKpjJk_8o9G`wys%kc1ZCUo$LMw%W1yV4ehEEYuq~9n%bZPm02ZS^w ziHwbH2N%&;#-;p1{6*ZiR0O4)QR?}n{>$D{x~n#pqrqiU-QIV)Bn(o(0N!Dn;L zv5Y_-89F8`Vm4GCr9b2{;561XJt`w@&lvH3J`?cO65I9`RdG+&Dk>8BWSz}n{|S$N zx6o}scmdN8s7)5bA1J?DKmOj>GU$Zba(~Q7<8TO1aT>6}GO|C{oobp&RZjR?2y71o zcG1g7D##1#d^eLOKvG-vktpfTU@ROAVHo!yv6AEF{6S@rk`YPYbzjZL$hYwsDmH%@ z)hmad5+YgHwH$#CbP~WUJD`2da+uItg6LaHWd{=6iTX;<+oZ0(G@A(X>@1fTviT!Z;?HRA0X;Psco z?P~}CCA*b`cfCc&$IY?!U&!z$VjEf6bq%JQFmQ+f`Z^GB?fqT;L<(#h zhOSWBhPnSz3hrLYz?qrHn|LP|yS7eb7Z04{&`}BFzOj(D<@E?<`jr|K*{||~#nTR) zO4bY&r%`|pt{Yv5y@_uEcF#cpc2@y*SJtEu07mD?kfDhj6XY3uqVeiJH5Ea{hHQTY~H;V|wb97=Fz&GbmlqbTkh8fn{a9$jfM92Jv3cMVXMX6RN301vpo z!qj7C(r={AS(WBNzmH=x3hKpYGJohQMm{B!8PR|OLme&?0n1~Gstfkmj3=QogT;3c zGdY9cKM9Avm;cC^VFI!V5o7o_8Fb-Z{ykon^!odYt%X+O&{b@AT3zJ=M_UXbx0Pv6R`gmt#Rccd6$Pj@x z1q>v(p+_Xs2#=io7$CJf;2%exr^Jg$9%w9c%)KL+gaF#YiP^ zw9U&Cu=#RBu`ZzR)A6xTQmXpDzy0=cn~SHJ?7)A_d3utoA|WxGE$T8_XHdVLgC>fH24^sfB@YH+6Pem@gGC;GOh zVwDyki3tE3w^AagmeS`M7;>rp@saQirN%bOKG_0JF37g?`ljZ$>T-<{08uaB9Soh? zZ(Gc1djmYbqNNtM1-D@uT_r(pvNBrd8%o>QF=E7l>#Xuw_wDv=tB7L>h z03H8=XOV0X)#L^H@^Ry;*I~KF58xy3lMrgraer;uLW&v)A5UF)cULu-l9?}$N14@y zCE)=E#At-?faZYex=NFfmMb^8MWJHMlf(nxT`U~P^mt8BRtUSvtVrp1JsMVpId$yr zD6v2!&87ewTGb|c(=Ht;9D73ZA;;0P!8=N=WG{bXlYGx&C~2C~zDRfw{99EVv4((* z;ktmr&CxhFn}tRilE7Gb+%sZD(pW-=IXC?)kPjq@q{Y&j5N4%3?|_!aMuUxDL9Wa7 zDASlNiNREpXLQ%gwKpN(ePYa>Q-1`rS`#B}dQix2HGum78PZ0i* z>T$c*^mj6obUsE+((#N8FXAWA#M#j;VqieDR75jgDsr>AGKBMhJxwv@bhSymY7i!` z&C3oeo6BVyF~eGO-Sgl1P7${s)L$_qeyZ6;7WG&$*3frq-K+L*NNe9`uQ*_B{4khY zUo{r8-?;^Ge$mWf_gGwGO43y3$Wh6HY-*_eQdmIi^%+C3<9%1IK#OPwEMel0#B5mn zLpT&jaFTY5B0Sb5qBw4XP{5uSq`Xi}TV=+(Yxjkdb zWcoxl6G@^y0Hx1jy|m%{L96oRV?r5R2xzL87{Z~Li#{HRc8P?o<}hJt6#|G&IgLjn zK4#{hkn~G`6Uh5O-hUIci8~w)scUCMF~F>3v$tLXN?-#sbku{|w!}!MG|MbnCu@RUR3Z zl)z0Swe6~MDaowDLljQ$45Iph@(Y!W_OeGgnyxbQJ3(zIxjRW3phzieEe;L z#??vA;jg?noBKThI2*5t&}oOp+hu-#GyA=g#q5)|lEj~d)jcDt%aJ!|FSp2@W$h$g zr}yfl3Y$1BIk}N3b>G`5MhDw3!+=h_iEdDQtCf8I=!(aL^-3Py(3|^=d|8GVURD;XM zd4*~|Btm|bDZ=>@gKR$ZO7sLA%Yg3gzw$-F2=dD@C~neI88`&7MnjrEt`fDPOTE!s zK+n;-FEB~hi5J)XeI~a&B!HD|Y{Zl8_S!=%@GEC1&Ch?6oxria^=T*yv?*eTb>8qr z0-fQ^b#JYB>#C6D6UO}B`EDp-$f~Qs2BJe%$bp8hf`4$^@7i|;A$r>!d+R|%4H72m z>%VIHNn;j2HA9V@6x2N<1f&)4Xl+t@9pc~bRjP;XP9_F^&|N?Nw1!oM-2Ko&)Q+b8 zH?5^O9$3ul$13BHpLLP&_5 zRTws~CxuwU$-RfzcbgN0tU)Nib+O55H%eVy-HF1~uZ6bSxW#nf5Od_Z7$q4r0t%maK9`1Pl~pS?kVKaUu~dc|Z?ku5+P-YhCRyUq|7nv>ooHN3I^oRe)-@1t z0)v=1U2{}9gpFcCsmP`){5@yGTan{z!)U0=?PEEv;-vk<<)1DU4sb5 z1&@0~45?Ouu*FhyL%`%iYw0F~WiCey^BA_`YJv}U6{tzPsUTt>UL$G%XennUApDRL z6p0wj*9e8C%L#lQ`(21I3i#%WtWqI~)YIJ)PX7;H`CB)ZtkFQJmY^Z@$J+T$OnpD| zF=5EdgV5b&Xw6P^8(H-m6a~A6|C?_t`4Lvwcf&qB{kcgj%Coa|nSv_CdLjU0S<^|xl&Z9g$FljyQMeat(`WicfVy#K=IkB)8U zEDJ4Bx8&az+ikx`3*tW}K%nEH$bEV?(5T@zk?(8vBqNVC@~w-Mz2X6^MBLs8=DScV zE%emFcMn`3i5WogzV737_z+lg73=^PQSx;e()F=9;Fhy2aT)l5egjRhmb3MSfR{yZ_I#)u%^3Kr#ru8 z!|y>>V|j9#Jex?VjZYXwD zfv8vqp&W@%)}loYX!YR9IgkfN?@}Y;*lg_C?Y#a#e4qdM-c!*xu_j8??Z{E4FCw?T zi$bj8uhHSbLV}EwK4P=+GHW^clJuBTYwdYQ3M>u%_4RLd-rekWB=Ur;79rl6*Vb%C zhJ`zXH|VT+3@fW-(#HCQ_6Ng;YABP_?6xW+?3G&g`gt6a=f!bi7grU! ziVHCr!9R6(5Vcw&`fWAYS^o7^EgvR)H2nsy8*_k(f;<949Yji*umTy{hr@4HoYE)L z6iiQK&4moVGv{jMnCTBy^nxZ+@3*8rb{{D;eqj0y^wU{O)`7th#)94WZsb_(_GSmQ zBmDT-Qd^(-n2e+ov1D0!`NwG>;2cZoD!vJ(6tS{D;LJhMy=%r9$w>W-F!-%pY0s>! zSyb6KO6)2ADWAcH%}5GY=n}CNbBT_oet>%bzk$+K#~!Ov=a{|hp!~b|n_Lzon6VC+ zyL!QR=Fz99KxZb<>&`tBy0eG#5Wr>pli+;XNsrDtIkkQ(UTa_9_QBUsL?0!$24!W% z!_OI*&#AA9Sg3w`A7MUCd*R~VALE8gL%*Q0~u++JxHI&5{o#- zWwW-t?$>;`Um5;u&fb*SLY@Tq__^{6?gHhr9L>LCbG~iBRzts!vLM@;$4FFrY_Nkh@n6*}70WEaz=3c2fKJsvL-1?%PDl}co|*Fm zQXYGdPusOKUY!^LZzdTkCC~E}4_15NYZ9H204omQggj-wzt9hlp0Tl92ErYM`px~} zE|1AmwF9_G8y0(V9FDi~yWQvlxCbgd^qdQ_eif~66ajSA{Z$5Z?{+YNQ7RoIdi3?| zN6i{{S=5>jk(V=N(7nN-XWuti#!0Q4Zz;aI#0Clw2pqp^C^kY`61Lpk4V(@EhIDje zQHSSMe><`#B{u+Eqjgq`&Ut>wsj&}+hEAekI42rxd-Oy5ql0^YvIA4)G$lcv0eAqz zMl_ucn$y0qtjO5flIX%&=ucCxh9uW2rkbPrylS zxjaaINvUe%NZ~iAItk~7a|A!OD{rpLqfH(hD!*U;iI3H=Wu2usY&@f2ie8WnKY5n; zB5h!k-InzSxCYJuku`u=TR?1ttvqaiUm#v?9w83yHypfgb$ED%xp{004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Rd1sw$e8HR96aR2}ZK1oDDR9M5cnO|&MR~^Sc zzw0z{lBH>r6tx4b&@!raA(V}RI;2WWLj0)^TQ^uU9+1$AgoF@^R5f%1G>MKxus$$} zq5*;j)^x0tP3(oIJ;1b=O_a20(l-A}ngQdQ5v1q7-i5(qm&|>$)dHsYOFb0S4+d6`BXbV zrwF}3w7q!~OTK2#RpF~_!5V|n2CYmUE(d6h&B0rX);UKs^Ulvb$hGH4;^LEhLDc_3V2zScL&)U40f zzqsR=h`b6k6pjfHa}^Wu0BsCb+g!IQjn3w}*yvpKs-*%bz;)o8!0^bK#|c&8uH9Sd z+D)g3oG6AZ5I5CJcuUI2ElU=?sZ#qdOe z#l;{TVK~r2{swX`64}b&nMVO|s-69nUypP8cbAAb(k;SMrLc>s43|ddi7$kQRa)Wu zKECg-20IG84AvVtb8z{?sukY9vz7fn?0O_WD%|x}V16-RcsxPMQ%HzkLdc31;sbq& z)b%UdwtRZUfr^*v8Hf>yNK?d-KZwv>d~9w$&B){eX`m{*RrFRLH|N*k`-SY%=!d5!Nr*+Il{jyeucFS%KUMibnbzYDvLU0<4l3hrvK%N2h7(RR+h zGr!kyq<0~ii4IRBNT#yn9Nv(M77_sc5ox|`A|})q>R$TCBI!UkIu0k}3;x3+6AQTM zEZXRe1TEw(kh9u)jJ&#fbpf28f1?NB*_oL4%+T08$&^nJ1RK%yr5Oi)5mtpl>VAB- zuWMo|**kt~A?kVo#^^OKc~*-^P6ctImmR{XunatYbD@7O;qK8YOSIl$l?mLsB&*Cj znT&cJ0)}d+En$}OW%?R;QETmIUmy)#bgvCwYG8cLZZuB`&SY6Y&5Vj zFfx%K?%SaLf%+dU%(}0Mzz4tF8@dhWvCb`n*4jR6@vY5GayH@*U^eb?d(H!)0n3Tj zZOxsVJDO{{Y3IEUV`#%0)^dKMDk}nRS}}fW39XlZ(Yr)=5o?>j^s5`;flqgD!x7Tf z+Ly_#P}e=$SSF{INO{@PY3Y+9@?8Ap5|6zQ&SnST{r|-2KHN5Jt?eVXJXzQ3&c@SB z$GmcL=mvxn9XmI7wzf5eYp?K6&%hj!h|?5t5&^M#*Pzx0Zy#QTGH=zFH^ zinXj+je-g@b}YMB?ZDywt*#g)&C zBJ}?2{LOuB+c(#6pDe4w|l5 z^l1?}`msIj95{YC95BG(Sb~4PH+{L>s38K=F^}1jQ6bm$D?v;9b{TxSB6t*`ck255 z-j?kx;gl$&#ves^_O1$9E{?=;{oI=*Ye6f6Ql{cQT-jI3c?h7;wxQGw@VB5#H{y9=hTP^#Kar;jC&W>$OX%W7B`;J#P zF|~wJhHOTolv(?VJ6}ST(fDqLY@iUwsf*M(d%dLp@0y=QJp(Zs>YbKkDl_oktMS8$ z#bDJ}T5F00i3ri=dK#J=F8m*!B*lS4cH@o!001R)MObuXVRU6WV{&C-bY%cCFflkS zFf}bQIaDz+IxsOhGBqtQH##sdz4fLM0000bbVXQnWMOn=I&E)cX=Zr004R>004l5008;`004mK004C`008P>0026e000+ooVrmw00006 zVoOIv0RI600RN!9r;`8x00(qQO+^Rd1sw$e8HR96aR2}eQAtEWRCwCeoLg)h*L{b- z|LiW87m<=;OTI9*B+Evs*ouV)RqPn8^ANi)jqS*dYfExar}jgg!V=JmHlnyF8auV+ zw29OrZqpPl8c}JTI#ryuKw}{BOIrkJ9bGJOrI1`oye~;{x%b(bb50*-hv8*+xtAfS z`~baZuKV%-%{g=C%m}NH!@UWjkA=r<|6g6j5~2I1_U9~1{xXqvqE}{Zj9G64B@o7VFkFpx70OX)SEF2o>$*5a2c^_y zZOjwlpb!4xn>qmYh)53*y>UZ?w5^!Vx@%uO28`BdrBSXff$(4$Z9GuMpp*y3RW3jQ zcr~3J{#l@K4)soIQS9jMc+Rrq>p+XYOn|A3!_YMw9gtqe7>qLW0F>itqLo(_ z)lvZpKtISMz{S`b_Yqj-Z0~LbxJN{eECd5!fEzkIy%L%F^(uFrP_8b4(B1)RNEIkh z(kYgC_2S;h*8qa4oWs3SghH|*61M(9gvZLQBS7BO{5(;hYU^dd7>#zlswj7zs5dJ> z@pB5~S%F;N8}|VaY8K1`U+P0)xN%eT8OxIAtL-yl31Le}71Vs|l*`C$1}v@No*%rFs^bb z6bcjyg?hmZfV=`M0|QNHwe5}_2z;y-owPQ@N7D?ArP101#-+hZ@nZw8MOr?5!EvX{ zuFw#iLnjkxZ8k*0)|W-tQE5E^9Hki;PBA=@3G5c4#@1)0{42;Qr#MQiOw~XGT7Blv z0B0N$NjDYQEV(}zb$AbamDpk@a-z*qkr)(uK&_Lzv+S!GH-KBe{vO0-C zzMzQ3lT6L#1A!7irTDRdW0BCN4{mPjBvxg`y5Jn@O`x>tsHT$$WO5FDgGsK<*+>%? zn1G@9IStb5syW_$eOJ{LYwiT@eCB;J1($8NbbP_Gdj!Ovp2G^vsWoKSI%P(ZCj{QbQu_6I$0n#m?WEb8v@g0>$6h4)+yY1-l$?t8`K16 zflfz7xV_vu6Ek@(4J9eqs%|i=48_k6Je@N1ee>R$HdwK>+JF2C@Ba4~;gB2<;nAhb z4KSL>(le{d>oI||{^euVCZEEZFt}zrp?|}4bZP%=m zpNd*N@KTHur(%RdvVWmYB2aWSmxq$x?LZB^yEW8jY2uzvCQ~mMs8Tt5cW+_u?k$US z5`luPxI8q+#7wRxDCs?jQS z-s;UeASbnUIrkU48rs1!t)BkdF^)g=?}S70qzIq&!K5+{AM{^idbTo{U+B~Hy-%|l z0{IG%sim`5Da$J7#?37p`KO2P5|I~ys0hr?+4RMeq_a-h7HOUJS(+knEF>-GOv9s9 zW#Bx2GJ)2#N5V3%)6}&Bv3QbPVR^6jI)mcp9gy#6$6gZN}at--y6+=fd!SbbNeQayfyPt%aRw3Av!Xdq5o~+k>@Q2D_$lcWK4VGK&nOqe>FQ|d7@o*{X>cTU=U5_* zyl3N0!Cn~zydH8SVzo!Y*58S+f4w180+Y+ToVheJKRVF1shyVg(nD9n+gh97Gsa}z z>)9U2F)e@-Pi@7rB&W1_#Tfe68$`KiZHSMhD-N3=d`2w!yq$Hq|IY@3g99)yl;rit zZ@5^}%U*97i+;DjE4#X2pGr&m|xo@hrf^FS9J>iLriB4MjN61KiA!jtO_#Rrqk zyPRF1lb=Oe`7!*9*5>IT^jb7lcH-b7y@ILDCZiU$PPNeFVX@??eA;I3(aTL8d)b{@ z-Zs4ba%SrO&)ty|k>4VKNtKO81SY5R434JDE|0WE2t}6tgpde#MWW%Kw6upO<3IXF z=5+v16v7sox^q0 zOO@skRsyqPgh#}ZgSljmj~qE492|h3o}c1tZ(jVs81ouy+MQElO&lL^9Mt0NM&{$7ONT`Mr2PSa#^)#v$C)yhv3dR2Y0bKGmavPzqm zjbU&t;3#E?kEB-wQ**r5>p*HI&wYPd-|gdykG)2xGW^GT!)v0~d}nW_DV>%kDnieu zt?j$pI$P@6a78$$zPOD~-+wEvGQGxddNsjhaxU@F6iNj?8hN`QUpAVKPrWu292{8I zdaa6HN*Us#so->48n5*_Fg=>)lYeqCI5+@r|L6+;b3Sq27;}t(^%C*s6i&|MR|kxj zs0c4?y{&6^Ygb3Ga0b5pYkd4yZ@^XNq%r&;NHCe4OMGNibXuC*MdYY4bks6(Sl2v+ zC3?k!I9p$*MyKc29pO>2EDe-TPOqv? zOA{5Lr~A&$cYoy3y}`oy;UC?>-M4RSS}*@KfOzSdeB=9Ri0V#3j;_>tH8j2F#DT3? zmSnWoIc!KTzq8kfPR4-iYO={Zg^cYzm8h4I@L92B|HYq*f#?BP$g%lOxg}Xo5eOEMEexoMe@k|g7 zS#`bRDFW%N!`VwSHCK%>pp?dSG`gIE1|%dz+goVwYNe$;f>=`9lWoIywKmTfV{%LH zy_%XeS8Ba{y@qPp#%rBw(`mj^3SOn?O4lawUcoM;ZLgBX>!>7QpIEa0y`B^7IlOpi zqv<&t;X9wkQD$;;SBoPe4_4c!2#h6i42@-0grbzjDJoo7*Z!8D00!KmqL3@%7F;aL zA{4Q_N~-V^MEK~A2S4%Swyx;Z!jZ$Z`yxR}r!$vk$W^GC74@k%zHV(1+BddU*UfNB zYxAtpI``fS-g|aUPDb_ejRRYJy}nXOFSpb>l>=i8xK0iF)Ei&7OzFZso~o>yr`MA| z>Df-`uG9YJ!Q{!~S5d~WqkF^hub>DFPh^S3lZ!sPU<@c%$BSN=T{fK4y9weh-HPXu(j)IEcIWja=Ul9H$iJOyfKw2zIFD}%tOhP z9q3n1RxPF0t+k_tXh-z){{!R;SnZa-yS@Mb03~!qSaf7zbY(hYa%Ew3WdJfTF*q$S zH7znZR53C-FflqZH7zhVIxsN3^`;R3001R)MObuXVRU6WZEs|0W_bWIFflkSFf}bQ jIaDz+IxsOhGBqtQH##sd%%~o%00000NkvXXu0mjfpzMPg diff --git a/starboard/xb1/assets/Wide310x150Logo.scale-100.png b/starboard/xb1/assets/Wide310x150Logo.scale-100.png deleted file mode 100644 index c228fa4e417078a83edc3ba365ecdcf891cf2612..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10063 zcmZ{KWmH>HvvzPRQrs!-?ocT1QY1JOr??ja6qf?UTBH!X5Gd{%thhTAOQARvTHN8D zzVBUkt?$RTl9iL3tbJzoJTuRpnZ09QYboPmQ(}WaAY4@y1zivbNd)+wj)@L@>Ms_Z z0T)yUSxs3Gs5S}b-Ux(&64VsEvDf8Ugy!m^5KVKTiZs47=J($i%{k=Ze z9^9cFDOOZfW|)@ts$=u)?g5jjU}M4j;jMctL&=hZ@>iF5`;+pvS<+b-Ji_yJrcY|J zpbuD2ydWf`9<&#zVpor*Ey&s49)nSvEgmiyRh#c{!stfsm{EgHdi*>Q#_=b8lkG$1 zi+Nolg;V1nQ@TJhzVVDHBK&3TpQ{=bba620;oZ#lmfKIivgKQl!_S7hc;P=cd16M* zTX-;btFHX%FHwHH-J3w7_<_6wU1_U@OW|qykqV2HHnU;h@G#pdZcJixt=?? z7?}+%L7C3Sh-*-H5g$jlgF!?fvZ!uUde9%bsNIu1d5@Oth<2WqzY%NKZ!RFAzgZ$* zGNEb{lnn(kskr@|O#+Wn@xOF3BS@&hQyQL+l*!rOt&fgJG{ja6N6@wvS+Jv1o;>Dn z-^x0Va5-BiL+8~o-3NBO$X2)4zXw`qblHoeCu_<5-~}xr$FBcP9JRH?39o)AqH^F) zvhwJ&sYxh&&MqEKi`X>K#GZ`<|PnltYDV|;Ku~Yne=`RY8y{c zF(sd-hSa={A$HIR`c>!QmH$gGBQmPv8}@rEZ1sg-GoQ|GQ0rpvpTB^z>E!Ny_htOB zxjvzexRMvB0f&~;NyZ8;Zw@(X`Kan`nSkl3*qL{E&LLQ!44h{>_Yr7@v|Mw@^=tmT zZk^gc&aiLYTfU3MQ9V4?c@>O;L8LOlsxlH$9tdXroQCu4I5_^u*m(OVqXkMu5%Hf@1YP0US?1g>n;pO0hw~Chf?GEa6xrXv@L%9R zm-EBv@m2s}YZ}$M0a5%I=@U*mFR0Af*qvk@YJNHx8+|W&G`k(p@x4dRYwUaeOQTXQ zB4pCOYmG9o(X5(0FgKF(K(hpWax2m0;K;S~B~dc2CayzQ>a2En>oa$$o8eh$mEfz< zZd~ol0^eHfaStfv=18U9T7wq@YVrd0d7^PL1r83AE!Cf}Ak^8TB+Yk2BZ{;y0x{`d z5r(s3T9uduXekE&Q6KZWWU8&;j`LZtAWEpwEb*Qlk=?K?;B}>E#wUdpQ;HxWLcKQv zZHQ><;sQSpg6cBEALP1)8Rh!(aR%!lYsOPnHJCu4br}c`6lkbFEP0HWqm{JT(4ip z@6~I4WLNdVDcojmQoBR2-LadA_;4mqz$~eN(giISv92p@#h;fa3Hv6huBcdQdyAG@VekJ&pa``-f zsm5(DtaWd4^J7G)ZjnwI3EHT_ciHU3gqXRV=!d#R$U6UW9K#>YTtY6{j6-H)7L zhzuq#uEAjF+XjmCA=+5R6z45FC?`)=OVn#9l!WXwt2uC{)H|adJvP8GPo?HVcVS`o zDxs`wR$@XJqOLrEGB|EOKlhzBk#PWU|LF2?|+PXw8H(?fHb-TN+Ii< ziCm@UB>M_lQo>x~h*W{7PtMQ~WMkhvsa>jb(D8uhpc<&s*%}t)955SIAZNf%nj%h*-wxxZ1k7Eu6e>M8C6y^6#pU zoJ7x>AC}He4rwF7mLXy{z2vU8fjQ0vVN4T0Q|38~iDYJI$>l&VUSaiiF4VEr>#1UF zE;&F)4e%TSB!~$}Ty7|v!z=Yu+tb0*c<*4XwIky@mscMz4td+)l&cM~Z39DJVjt;o zzfur2_1f`q5^dhu2sVY5dk-Onx)>3gURqC(qsEK=s#KPyTzwnFj2T?wdxOQDZ@ zWKnMR=jImp&c?Mx?_0j@TX{9Q)|AKS@ap_tW6FkuOB8puf2uSQ2#2NYIbp3qpF10{MQ4fH z3k;CU+rm+cu`{dE5eDkj%Z+>t;r0{^sZd?--U*8aA>{&y@2uPg4AO?4JnO=wM~SYd zyC_B?3=F0m0ss$nLGlj|k2(!q*Pokn^<6n;GH4(>fYss+sN}nu$S$flj9dFA#I{A- z9>f;^oYXBNlbu0J9`Ey;l>t*PJ)b}c*V7@QUFi>bK?j7J)B&f z-ZC>iexqSGuejb`XR-7ul!c~lO4nmnf_gE?+=`zXD-$Y0R`w{;e)A1bb+EuuE8lII z$=pU^P)1E&>vLN)*H1l?kI1%?^ymEa{$+Cs;PCu1_g3FPjK3RaCLX_SZ#RRrCwalk znw$rekd^AHf?mEu!^P6m3Dt`s*-#$>!iR*=?Yg&uh~RU1*(Apv{q4%DVmj)u~ zjOMTEq>5EKB)U4HmHEy;LNwC|iS(Q|5AisSBRPln3pLrgwf-OEb*gro@ff=y?&I z#LHbApflPtcK=+ zlu^lYmh*G2%zr^X0L5|!e{=Sre_?w=JA8iaM!AGW?-f}pc7DwoPOE2$8ekf7n2AcN zhbAfUgumeacyH2G;xN405MITfevyTRU(#{VQ2HrUq%jEp>S~DT({OTz><~KXo15_R ztFXA+Wo_ss5!OLebqJiybzJ9d^vc{^{%Qr=R$#HmEXzKn4f-c}N~Lm{#pLZkrZXAN z^K;_xE5folvwx^=8FanZCLCR{QE{j^1Jct&9N$^&JBO?d%eM;30>zBbW;s)Hc?sK3 zXh57|U|CJddVH?KL?CDrb91fo3u#x<@aYE2>=MW|GArmUvf3O!`y^~!9a36hIqA*g z>?f=4!~&#LH{IB{n7M2;?>jr9*za}+&Hb(Dto|(PxS{{+$QmFL6UimUX0E#Gxrn(< zVSvt;v|%FkVPp!lp?3tgm0gPRv$JA?IoO6Vb_V{`U^ltT{tM)PW$!Kr? zW=R}($eqQkqAG>o%JB6fLFnSCX8NBLRCEYMcQl)G;Ix-As;L(}V!4iKPZo^Jj7#zp zktuWd2~()o(aGtx`{f}lhrc}R`p%(kLsnY}9H{-p5&+6-_DzgU?(ueaca>UJPY5$muF3)YuS3vKP& zY=ZBo@tZ@JGHogbQaG1Ccv^QggN}(tr!&Ut2b6pl+_FlXF^dE@$0Jz}D2tyt<;oAl zKYro*$%sV}ye8!1Vbw99@+@Or@4Ekz?}PgMaJY1<`_W#1T(RetaEUOjjbAx-Ydpb> z#Af_+P}BjX>_(1oE#IW!xokAa0z_rR!BS1@iA8wuT2GJbE?jv7baG`nQ zaT-2cqZ;H)e{fky6yl9F`^w?NSiA*y%v*J5d6`~+4@jOChVlMnoX1g}x4e^*q6_s% z3Re-WoEu|@uhx~*xpM1lHD<2;H$~bIC2F#i3_|p{c-_#FW#a%?>sB%Wfx;fTYgYAZ zkLbcww9;&hW9~lYF3EaaT)k#<<%#C-X@6w$MoNmc^&fBe@Cp3_c;ifDRs4XmE-0xe z8bXmzwdr(-6D`QVmb7ui%7YuAAw29TKhX%JSanj-*~dcM0O|(hH$26gZYK0=?B&Mf zYEOG#2Uz z8ST|WYw(QG0Nia3trI$s8{wh(nk8P=Ak_IYlhhNwe$v2JKfGkA-9d@}Yw_lBrqodMXfzuqYuI>? zZh`-0S#OQm2Q2*ThF2_-tg1|%P|_RWn4`KM4DgE~McJfp$1gx0^NedojV}``?3GPO z6*~(!8hSl%AdEJ_f*T*PR(3#r{;|#gGz^(4J(`Ea-`~d&f@uj*FbKPuJ^F@*26WdZs_#EQO^; zSJ?OXu36KmyC-q&6{s<7SOvLf!sRfR2uhB4_kxTt3)Y9U*jLeUTW_a{t|(#e{Un^L z=5TS$Fo)P!QnHbG!Bb5xR}>S|s-f%J5N2-(Uo6f8PP=@pA`tLF)_W`5n^2Wo z7Sqy%dN5FM?|>r0t<4f!v4|d7ZrC_7nYXFR#Y248eUOrIfgp~ji;fH5@o92 z$Ly$#&JedL`D#-H?_O>_`Jam&X;K|yR-3KSGe;M$6n)7klkoTQlv?NZ`OxDcE~q0i z6-WltGugX#c;@#TW$QTTJQ)7&=^+27*4oKqY8flhTVui~x3-2wjOn1o#wWJ^$< zj(v{5_j^o`viddn7W8#%CLe<{ML&E)2gO{4L z7MP9JlzXMy7w}SHN&_TVNZ>9#fKas&Fz5>P+Aww7op;S|J;R_}MN1SAX4qzU{CLy8 zbcsT#;|@3cwmU2Tr`x!CtPlyx%ucAv<$snySsyUwf&xuq zY4IQMy&+Y!>qtMgetPe9X`rPQ$oKcGeWDNg=c9}rkeLWSUGUHTT5PNOL3iHG{3%Lq z9bB?cHRtj7Ep`NBJ&w~^e%Na-481++#f_)nzy7%uYhK8Con4%JN%{7fpA!Sms!*3r zf0elGFr?_CM1rFCei{$!Q=^(vw-^`6sUF&Bv2-y<}2)Yy*MOUeO9+F zKYBPLsFWfm$>9~Lj`kX#F#{G#lr&8Tia2~RBf_!u%nhrxyBodR8-Yp&9fLm{s+jq5 zuYKpd8jXn3t;rvo`oE=Qke87sM^sge9(BkOFY(HjkFPK+KI;9A`tu*4kCN_**X&@G z5dl{?R|X8nzK8u!#_Ac%La?J1M~+L z=8IvU;ltuW>ag)aZv=IxVr-3tp0};U!b>*wi$=*{kx-f^yH^YD=I#IObx)!{C^293 z?0;HRSENAs7a%7Be*Mul)%ac4J?bm{EADT}ANylQ@Av2N>^M39rRNPI$|7JPc9kOc_&e;;fDTdmC&aH%T4>{MpUia3K%ir=%N4Q zqPC%u;V-A(Wf$tsj)?hh%VyTTeoP;;i_6O8Sq?L3DW?e zONL7GBS>hXUvTxgsZr$Ra$Cg1sU?z3DAo1kBmiypNGh@xCu+9o{;V7`$;HAtYyZrL8im@4D0*a3aRQPb=9 z4)2*~WB!zZTC5y+mrZS^o;7p-O9?dqiG4;Ba)wvrx^^lSyd+k5E}*yxsPow%aT?5J zw&(HgzyXPPrW`q_;EavuWeLT5MhQu0$6mvG1Z)OUuEWAy%_=aJaLQDj5jTbLFM=0Z zm@Wg}DO5udu!2qwkjG(eaCU12Qm>=8roJ7`$CUEoGXqoq;X@u^)tP!#(X+j+4#))) z0`8eD+PTDkBTZTW`)2CztLMtA*&6}|1wBl=RaiV%w(y2#QIhP#=gGe{gxQd&0i))L z0c?BvX%|UMzsM1#Z>-DUO1gt<*`G$Af=DgizbB59^TL1n8|s5_0?B~}x5cKRJBiR+Tu?@u>FG*SRyQKevYI=(-Pp?L@Wbxr8D!VX|AhMZ=nNCF^t z_pD%z*hm>+0cOgPT}wjYhq#{AC=g$%@vyXUorjcnmLso^zS{eK{7yA0%mS^k|?rQqtPEI11i?7{h%Q`qhcj51^;iS}uw0Hi%uFMPshqr(0qLYgd zrH2_1LW$`D0@3&7p(@9u*XJgQmL7N0d5PVZC!tDJpy{m{qIGKm?X(4Ic?<7lO6%XW ziUodZyWByM%z(T(HA@sei{0^^q*_c(3uIu|Zc@dqm5jm{_ zk0f2q`~9*><%knJOjLlR;Tc2UjbwH&YIO9%#v^cef(Kjo-oAD7m&zD1Y&l~sLbLw4E1)x`Tqt}epVRgqrJ|!yg<9t{k2h@}>*+h~3~JmzVvqsqitCvI>RxD{ z7rLqvXB~?O3$rzIVBZAp!@=o%tiW7Na9yM!J^g}Jqs?p_>PBr*4_DyDnFf|>Y|!e- zZ_vBrz?jvCW-`(MXfVqj|GY#bD1F?sju-w<=)iwC*)z1=x>u5yF2r*@FE3)%gBIAX zlfWZ&x&nNDdtbUibTD}~equ#4GM|3WbDjY;c=sarnXV(_-bQLp0H#YfDqt*a!L+T9 z@F>GS_#qMou5U;{|Lqrk@j;9z04Rp2^qz413z7@MA3-d05WPgoo4=CozMf!^l2eG5d;ks_54dXd`dC32tRc-}{IYz4^R}%+A zw3c5RL}Gr%jOfbG-VMxL|2G_=%#om`-s#U{8@6w@C8}c*+Hips3iCwrI4(hxyH-@7 zccc8wAj1&tZvZs6mMdC+`P0M-7dun6--Ruoe(^tJP5=mEO+fd5>oJT8d5c&aJyRBV z|6oA^`nkFgVRyt2Y*5aT8y265phRt5gr)Anz}^5$C5Kgh_ydpS)+oj@ZI;&whgXSC zKJ8ZtPOoL4*#NncO$@CtcW};OTt)<~;g=Vvd|YJ8+KC&l7fYWxNy}kkZcG{<-krVW zT7Y<8FZwx=S8%85i|8 zoMIQjOAlf$lu2NJZNrg@iK54bNsllG#~k|ngxsY#x3_1ic>}3XTB4-@sjVfnI}P7= za}4Zhd-kpYk`ho^Hidh!2cP#ky>-bX9$J;-J40T+#z%UA*j1#6BD8v4$icvmrlxR$ zOjFq|6lN&9+ABE(+m`b|*L%UJkL&Fevj z4+V9e*&g>9FQv-7TV_3Z(nM10kSS5>FwP;=>DEU#VGWz`MkvH&dgdkx@h=W#UN?`Y zc_R)sBqez}I|Re*T=}_`cDi*HJ^S1wQ>4X87>vdV# z6o%6@q&#NpLN#oRWc@pieHtAmTt*q|%SgTgi9#WE>K9~1yUnnwzxDIl1rsX+(dj>^ zT2m7Ex$JpG#^^ykgs_~!9h@YCCy9ZZ3m@lS`%SNUtE zSpY}qcbyq%SkNtaz?<7XFP7vQ1;}z2h5c@DM<+t2xzMtRzw<$StcugNI17)Ls_G3X zQb>)o`|;xme|z86r1;Ht==JyVma|*$+J`P0#zS`_phr7}LBW`Z7hvRF`~{vnlpj)h z`)Sd^*V>qqSla@tRNzELE{f7BA6)tclm61%(B(el$!n`$`*9x4{{%6Umt`=$DE@Nw zT%XRMp+9+erQAlxz<0v5k+~WtjD2*363@2efsap-Uxy_RZV+qDfO-o@z>eKUj3)S9 zsec$r>{e2CE*5N^<(OX&VURJFFHP^jh8lx&noq~d)w}&q187I$?hs)u6jD*1Hy zt%&0!jQMr+Nq1xneGsW^fs13N%<6;K`-bfSM$MwJqdZQ%P-SJ_vp{I{1O%E2moAIp zk%`>tt0VQ#v;IY=5^2QGz5t;T%uV8sYx^4e4A0H{M^E@O7v^;sP|CR`%89Nv`KMN1 z1wutIqnPCnK;MUQPMG z!qvD{D+>ut>EzM6=%%e)v@K@_Di$HU&s}yezAJUDBfB-`87*MXva|4$I0+# zn9os$*tqZ|W$ZwlI8aPuZzgh?(i;_1CYGHGpEt$ocnQVFZ|Dx91WR{1RGZaBDs+aOtV6$WeZg8qS5vRxf&sagCP z{mwV~2R2MJO3CyrE>^|@vo=QZURmD`%hazXr1!UjyFg7^Y&qTjVBNd8H}@j4kC(4< zAP|LOCRns2-A8(+QI(NQm5(2GuIQ0LjgurynQwI0b~P z8WG~et$^Ny?QvnVCiWF*H0>y52z_JrM#K#tJ{X^$XRtubbB)w?#v0;c-$V+Qg|a_O zbNfcX0Sw@12ZqN!+PIic&~JgRi50TlLwFhk-Nt945mK*NhzhXr(jcPp^mTnMM2I{21Aozso znG4-3e#nD@JNh#9r^W5qVkSPdZ(sa7G@HGk?!_DwwYX#$A{rK1Bi*E+H+QO{6DH4l zEl2+MNKCyq;$Ou>NO3;S@SiEjjrzpJcKLuAu-O<(Bq7`3@jtzIL`1ma?)fuB{?1$t zX21k$(1woM?`i`S8KadFa0;Ii$OJU8Nr?Kr_Zj#})b#h!d+?uLRloT9v`R4a?_e9VkD`%}t(A|RgpHRS zZ~+PM@r!Zu33CgG>+=gp@bOCs2y^p^O7QV@T)>|HKLcFdZ5{0)|NjAFrL>j60FbJp LmO_=BW%&O9aVJ*? diff --git a/starboard/xb1/atomic_public.h b/starboard/xb1/atomic_public.h deleted file mode 100644 index ed90f7e44709..000000000000 --- a/starboard/xb1/atomic_public.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_ATOMIC_PUBLIC_H_ -#define STARBOARD_XB1_ATOMIC_PUBLIC_H_ - -#include "starboard/shared/win32/atomic_public.h" - -#endif // STARBOARD_XB1_ATOMIC_PUBLIC_H_ diff --git a/starboard/xb1/cert/README.md b/starboard/xb1/cert/README.md deleted file mode 100644 index 746201370563..000000000000 --- a/starboard/xb1/cert/README.md +++ /dev/null @@ -1,32 +0,0 @@ -This directory contains a cobalt.pfx cert for signing UWP appx packages. - -This cert is not for use with submitting to the Microsoft store. It -is intended only to be used for running the Windows App Cert Kit. Note that -you will need to regenerate this file to be able to sign a cobalt appx yourself. - -It was generated as follows, using tools in SDK 10.0.22621.0 run in PowerShell -as an administrator: - -Create a new self-signed certificate with an extended key usage for code -signing. The Subject must match the Publisher field in your AppxManifest. -`New-SelfSignedCertificate -Type Custom -Subject "" -FriendlyName "cobalt-cert" -KeyUsage DigitalSignature -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.3")` - -Verify that the cert was created properly. You should see the new cert if you -run the following command (Cert:\LocalMachine\My is the default cert store, -yours may be in a different location). -`Get-ChildItem Cert:\LocalMachine\My | Format-Table Subject, FriendlyName, Thumbprint` - -Export the certificate to a Personal Information Exchange (pfx) file. -`Export-PfxCertificate -cert Cert:\LocalMachine\My\ -FilePath .pfx -ProtectTo ` - -See the following for more information: - -https://learn.microsoft.com/en-us/windows/msix/package/create-certificate-package-signing - -It is recommended that you remove any certificates once they are no longer -necessary to prevent them from being used maliciously. If you need to remove -this certificate, run the following in PowerShell as an administrator. - -`Get-ChildItem Cert:\LocalMachine\My | Format-Table Subject, FriendlyName, Thumbprint` - -`Get-ChildItem Cert:\LocalMachine\My\ | Remove-Item` diff --git a/starboard/xb1/cert/cobalt.pfx b/starboard/xb1/cert/cobalt.pfx deleted file mode 100644 index 3f8d22dc798679dbc8ab22d8eaac8062ebafa15f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3255 zcma)8XH*mI5>7%09YmUdNC=1&0~;U^Koq4n1tJ}k-jOOrYJzkLNL7k7kt)52v`;~# zNR?1T_yh!$B1J%y;$6MoPw%;Z?%6Z%%=^sDv+tfg`^*AF`dS#20wB`6BWOe-)g!+! zK&ha)M0!g&k=`7HjR7Kp>AzA42%JcH01zqnK-)&p{pzBpg~D=)@FRc-{|1~y(EbMo z$r<6)xS}NPT6|d*3`R8sC&DKl;nR3f5Blk9DG3fQAO}^0UFu$yllu#*C zyYg(7Bk}nY^E^iUsA9SMpFfKBSQZIWcGbP#Lnp>MhHz5dQAlh|{mPRt&HCtilh009 zxn7GFO0va*j}-=glCVJ``_X!t(eXX2N(4ZarMB$&PNjp>{b>*a=A3X?F>(CPS@FCO z>&(EN`;A%{MlmTCPsNm=Y5+0NWXbQ6ezyr@*3Gq3DBIaB5MF*crKd}>pmMrhwZyRN zF{vn4FE>YzoGp@XM0vUDd!gM^pGYyfRTJs#@#KW~x%0aj3(+;t4m}%VHP1K0w5P*d zXh!=k&D(h-H@(qrE-@KA7E9jUk!T%Hg{k9pxOuikr3J zyX(*pTK${=#mKrm6Z1ulk5!?>OA2%B3ohqYOL1pukBf}Ci_w%C^jw?jdf`E`(v=%wW;Kte zLcUx0uKbKn8@06kMb8C)JvXg*+4FP!cou!JJlc8>^*xEC+qKasAQO@oRC@Bptuwej z8w>}V#~pjIYdBHv(YHkk#%xt}ljZD(WPZP4KV+rTp`VqFS_agEsi0N$)^_osPJ68G z0>|_6g{-_5>S&v#_s$~kg3Gpmn$4o7ItDz| zq6QV`S9RS~Cexgr+tZ|mowZ7Xp5S|%RI)Y)7rAL;g3pOCRvxY!igjL^N!b0s$oxHV zL%Dv1;r3_om+{Z7$7*jRt2*+}4;?lXweS7?#*NKz5dHzBk4s~k4riGXUFq#Q$tQEI zEA~TI#glRo>B}+37^YZS#)dBm!Q`T4e{Y*4Y-ap6*j7rDwz~0#(jh78ZvuA(jDXwJ-iyH zcjXlI8U?3J8i%nauM&Exr0X0D_twP9o)^_cplWr!*j&vmQe>}UubxmQ3{_JIDC>&_z)`Lv5%Ivhs1 zoTomCE&GHCd-5|Ul+{$vSuQl-j~%Gna46WFbCdGBz9MI-*I-pUc1dA0G_EplfsnUU znW->8x@56?UQ5(NsSiUA8~QukP=_l~V922H72ig4%uvI=+f`&2W93u!0I}kR#WU@9 zI!pztCm3G(g>G~<*ri*V2yt^R<*hBws%_6cFKR6f?A;>QsI_$~^}UZ?J8>y|e0A3OhDTp-07WA?pVh^!~*nleHJbdHSBPS<&V~&m8}j{d+kT`*f61KG-+LU*Cxv zRpK$x{rrvA43p3xt(@AE}@$7*j*8sU7D{OB>kMFD1MtMRNyQzP=Zs zeu)l!_eI-538jxasXbQh)$K(f|GBsfqbQ<{DM2PC)g9{?Te$Xl>bn2Cg0le~k%?6g z%rNGrZnatrB#7#5XUySjSXdGuoD~2uQ>#PU!sZ2@S!27=g&_w~IyG<01Jj3rio-g;DgrMrn6@~?kJb7*-A%Y*X#*q_?JHfaUiutN*H)M%|ALxv0Bt8 ze~)mXvfle?!$?<^jbZ~+tdcLiJb*2}7Td&5f?UA|R7+1$)D{oS3l%|c%fnKHe zr}#0!U4v#t^@+0^S7NkHr$SB#<&LPI!0V9x+T7|YI@zs}#8sV0t&BH9xvpsG)RStH zQ;7qd9_fCi^|HxFT!ZN&bp1J#bmWJ$5|^E59wI(P#WasZWJrFuVI&YcQ%#lG*d9n0 zu%~NeFYg$qi}A6B2O6Ig{;RmMqh=~H+B8?yn{dI=&mzI7#H6r}EYKr3`_^QgWa_3- z!`3bEFrWg5YG`G_6*&b$NcV2R(17q9{_SJ<-S0Cm?s;r$(qFkxt}5WTskyAxJFx4& zsqjR`T>1T*9Xp>R`DOM)=C4v#MHlf|GYif0tC^3QCOf(NOZ;y+q%I~QNdluO7F$<7 z5L0S=Oz^dgDuYX~X@4mrj)yL`{lQAoef|MZ^C!|iz2#FQoKd9W5jX*V=jB$Nh&g;a z^TUG(txe?&&CE_@)OUe~L6Z{`2pU z5=>HqApEyB!E=ew9XJuX2@s)w=mrG{&w$Vy7!-yfLS^%bP%I1z2MBv`LhcXw)KbQ4 z!9ec>ZrDMO0F98(z>13+)YxV>uXk?iK_fv-@Rz}o%jW98LT+?U8Sw9($TCmR<8x*n z7}Ra^N;;-)8_i$^>Y5m+k3Tfe1B@KN$Q@i=LACog?gldbe^mhfpXbwr0;&kwUqY-2 zg#tK08jzx=z-uVeqw#1A8jF^|pe1D`qye0S6k0|~QVJ`H!AhYqQW6ppk^lyW#zQFlhI1~*RN}W&{NiJh?aQXJ^W{Ha{XPh(3vC|qsN75X6#u{aoo=-b& z%wE2=2z`?>O40(NA6V)+31t9womMk_hT)3?8F)92U>J!+XZfJx=nD@QGGF3JPE02P8#l#v3) z1!qlL`4+_|_|8$ZQIJ7ZJfz}9$%SulRvDIPtG7xVH9~&lA%*&J%8KdSt3O7^zW|C9 BZHNE> diff --git a/starboard/xb1/cobalt/__init__.py b/starboard/xb1/cobalt/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/starboard/xb1/cobalt/configuration.py b/starboard/xb1/cobalt/configuration.py deleted file mode 100644 index 532c374ab6a5..000000000000 --- a/starboard/xb1/cobalt/configuration.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard Microsoft Xbox Cobalt configuration.""" - -from cobalt.build import cobalt_configuration -from starboard.tools.testing import test_filter - - -class CobaltXB1Configuration(cobalt_configuration.CobaltConfiguration): - """Starboard Microsoft Xbox Cobalt configuration.""" - - def WebdriverBenchmarksEnabled(self): - return True - - def GetTestFilters(self): - filters = super().GetTestFilters() - for target, tests in self.__FILTERED_TESTS.items(): - filters.extend(test_filter.TestFilter(target, test) for test in tests) - return filters - - def GetWebPlatformTestFilters(self): - filters = super().GetWebPlatformTestFilters() - filters += [ - '*WebPlatformTest.Run*', - ] - return filters - - __FILTERED_TESTS = { # pylint: disable=invalid-name - 'base_unittests': ['PathServiceTest.Get',], - # TODO(b/284008426): update comment or re-enable once fixed. - 'persistent_settings_test': [ - 'PersistentSettingTest.DeleteSettings', - 'PersistentSettingTest.InvalidSettings' - ], - # TODO(b/275908073): update comment or re-enable once fixed. - 'renderer_test': ['StressTest.TooManyTextures'], - } diff --git a/starboard/xb1/cobalt/package.py b/starboard/xb1/cobalt/package.py deleted file mode 100644 index 79546012b446..000000000000 --- a/starboard/xb1/cobalt/package.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/python - -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Cobalt specific configuration for XB1 packages.""" - -from starboard.tools import config - -_PACKAGE_CONFIGURATIONS = [ - config.Config.QA, - config.Config.GOLD, -] - - -def DefaultPackageParameters(_, product): - """Default parameters to be passed to XB1's Package constructor.""" - return {'publisher': None, 'product': product} - - -def NightlyPackageParametersList(product): - """Yield a (config, package_parameters, install_targets) tuple.""" - for configuration in _PACKAGE_CONFIGURATIONS: - package_parameters = DefaultPackageParameters(configuration, product) - yield (configuration, package_parameters, None) diff --git a/starboard/xb1/configuration_public.h b/starboard/xb1/configuration_public.h deleted file mode 100644 index 3c6556032930..000000000000 --- a/starboard/xb1/configuration_public.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Other source files should never include this header directly, but should -// include the generic "starboard/configuration.h" instead. - -#ifndef STARBOARD_XB1_CONFIGURATION_PUBLIC_H_ -#define STARBOARD_XB1_CONFIGURATION_PUBLIC_H_ - -#include "starboard/xb1/shared/configuration_public.h" - -#define DEPRECATED_SCOPED_PTR - -#endif // STARBOARD_XB1_CONFIGURATION_PUBLIC_H_ diff --git a/starboard/xb1/gyp_configuration.py b/starboard/xb1/gyp_configuration.py deleted file mode 100644 index 7cde6827e6a4..000000000000 --- a/starboard/xb1/gyp_configuration.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2016 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard Xbox One platform configuration for gyp_cobalt.""" -import imp # pylint: disable=deprecated-module -import logging -import os -from starboard.shared.win32 import gyp_configuration as gyp_configuration_win32 - - -def CreatePlatformConfig(): - try: - xb1_config = Xb1Configuration('xb1') - return xb1_config - except RuntimeError as e: - logging.critical(e) - return None - - -class Xb1Configuration(gyp_configuration_win32.Win32SharedConfiguration): - """Starboard XB1 platform configuration.""" - - def GetLauncher(self): - """Gets the module used to launch applications on this platform.""" - module_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), 'launcher.py')) - launcher_module = imp.load_source('launcher', module_path) - return launcher_module diff --git a/starboard/xb1/i18n/BUILD.gn b/starboard/xb1/i18n/BUILD.gn deleted file mode 100644 index bc52aeba1dc7..000000000000 --- a/starboard/xb1/i18n/BUILD.gn +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/build/convert_i18n_data.gni") - -convert_i18n_data("i18n") { - install_content = true - xlb_files = [ - "da.xlb", - "de-AT.xlb", - "de-CH.xlb", - "de.xlb", - "en-AU.xlb", - "en-CA.xlb", - "en-GB.xlb", - "en-IE.xlb", - "en.xlb", - "es-419.xlb", - "es-AR.xlb", - "es-CL.xlb", - "es-CO.xlb", - "es-MX.xlb", - "es-US.xlb", - "es.xlb", - "fi.xlb", - "fr-CA.xlb", - "fr-CH.xlb", - "fr.xlb", - "it.xlb", - "ja.xlb", - "ko.xlb", - "nb.xlb", - "nl.xlb", - "pl.xlb", - "pt-BR.xlb", - "pt-PT.xlb", - "pt.xlb", - "ru.xlb", - "sv.xlb", - "tr.xlb", - "zh-CN.xlb", - "zh-HK.xlb", - "zh-TW.xlb", - "zh.xlb", - ] -} diff --git a/starboard/xb1/i18n/da.xlb b/starboard/xb1/i18n/da.xlb deleted file mode 100644 index b9d99bf989af..000000000000 --- a/starboard/xb1/i18n/da.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -For at bruge YouTube skal du logge ind på en konto med et Xbox Live-medlemskab. -Vælg en konto -Afslut -Der kunne desværre ikke oprettes forbindelse til YouTube. -Du kan få flere oplysninger om dette problem på youtube.com/xb1_help, eller du kan give feedback på youtube.com/xb1_feedback. Du kan også gå til www.xbox.com/status for at få flere oplysninger om applikationsudfald. -Xbox Live kan ikke kontaktes. -Prøv igen - - diff --git a/starboard/xb1/i18n/de-AT.xlb b/starboard/xb1/i18n/de-AT.xlb deleted file mode 100644 index a74dbfc98e4e..000000000000 --- a/starboard/xb1/i18n/de-AT.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Melde dich bei einem Konto mit Xbox Live-Mitgliedschaft an, um YouTube zu nutzen. -Konto auswählen -Schließen -Die Verbindung zu YouTube konnte nicht hergestellt werden. -Weitere Informationen zu diesem Problem erhältst du unter youtube.com/xb1_help. Unter youtube.com/xb1_feedback kannst du Feedback abgeben. Weitere Informationen zu Anwendungsausfällen findest du auch unter www.xbox.com/status. -Kontakt zu Xbox Live konnte nicht hergestellt werden. -Erneut versuchen - - diff --git a/starboard/xb1/i18n/de-CH.xlb b/starboard/xb1/i18n/de-CH.xlb deleted file mode 100644 index 9b2323ff9daa..000000000000 --- a/starboard/xb1/i18n/de-CH.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Melde dich bei einem Konto mit Xbox Live-Mitgliedschaft an, um YouTube zu nutzen. -Konto auswählen -Schliessen -Die Verbindung zu YouTube konnte nicht hergestellt werden. -Weitere Informationen zu diesem Problem erhältst du unter youtube.com/xb1_help. Unter youtube.com/xb1_feedback kannst du Feedback abgeben. Weitere Informationen zu Anwendungsausfällen findest du auch unter www.xbox.com/status. -Kontakt zu Xbox Live konnte nicht hergestellt werden. -Erneut versuchen - - diff --git a/starboard/xb1/i18n/de.xlb b/starboard/xb1/i18n/de.xlb deleted file mode 100644 index ade1f9e91ea3..000000000000 --- a/starboard/xb1/i18n/de.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Melde dich bei einem Konto mit Xbox Live-Mitgliedschaft an, um YouTube zu nutzen. -Konto auswählen -Schließen -Die Verbindung zu YouTube konnte nicht hergestellt werden. -Weitere Informationen zu diesem Problem erhältst du unter youtube.com/xb1_help. Unter youtube.com/xb1_feedback kannst du Feedback abgeben. Weitere Informationen zu Anwendungsausfällen findest du auch unter www.xbox.com/status. -Kontakt zu Xbox Live konnte nicht hergestellt werden. -Erneut versuchen - - diff --git a/starboard/xb1/i18n/en-AU.xlb b/starboard/xb1/i18n/en-AU.xlb deleted file mode 100644 index a9efb4a89f97..000000000000 --- a/starboard/xb1/i18n/en-AU.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -To use YouTube, please sign in to an account with Xbox Live membership. -Choose an account -Exit -Sorry, could not connect to YouTube. -You can find more information on this issue at youtube.com/xb1_help, or leave feedback at youtube.com/xb1_feedback. For more information on application outages, you can also visit www.xbox.com/status. -Unable to contact Xbox Live. -Retry - - diff --git a/starboard/xb1/i18n/en-CA.xlb b/starboard/xb1/i18n/en-CA.xlb deleted file mode 100644 index a69d35e6bb71..000000000000 --- a/starboard/xb1/i18n/en-CA.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -To use YouTube, please sign in to an account with Xbox Live membership. -Choose an account -Exit -Sorry, could not connect to YouTube. -You can find more information on this issue at youtube.com/xb1_help, or leave feedback at youtube.com/xb1_feedback. For more information on application outages, you can also visit www.xbox.com/status. -Unable to contact Xbox Live. -Retry - - diff --git a/starboard/xb1/i18n/en-GB.xlb b/starboard/xb1/i18n/en-GB.xlb deleted file mode 100644 index 580d8b5f0526..000000000000 --- a/starboard/xb1/i18n/en-GB.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -To use YouTube, please sign in to an account with Xbox Live membership. -Choose an account -Exit -Sorry, could not connect to YouTube. -You can find more information on this issue at youtube.com/xb1_help, or leave feedback at youtube.com/xb1_feedback. For more information on application outages, you can also visit www.xbox.com/status. -Unable to contact Xbox Live. -Retry - - diff --git a/starboard/xb1/i18n/en-IE.xlb b/starboard/xb1/i18n/en-IE.xlb deleted file mode 100644 index 40f91cb5258a..000000000000 --- a/starboard/xb1/i18n/en-IE.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -To use YouTube, please sign in to an account with Xbox Live membership. -Choose an account -Exit -Sorry, could not connect to YouTube. -You can find more information on this issue at youtube.com/xb1_help, or leave feedback at youtube.com/xb1_feedback. For more information on application outages, you can also visit www.xbox.com/status. -Unable to contact Xbox Live. -Retry - - diff --git a/starboard/xb1/i18n/en.xlb b/starboard/xb1/i18n/en.xlb deleted file mode 100644 index 9081b301664e..000000000000 --- a/starboard/xb1/i18n/en.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -To use YouTube, please sign in to an account with Xbox Live membership. -Choose an account -Exit -Sorry, could not connect to YouTube. -You can find more information on this issue at youtube.com/xb1_help, or leave feedback at youtube.com/xb1_feedback. For more information on application outages, you can also visit www.xbox.com/status. -Unable to contact Xbox Live. -Retry - - diff --git a/starboard/xb1/i18n/es-419.xlb b/starboard/xb1/i18n/es-419.xlb deleted file mode 100644 index 0c8b68c43337..000000000000 --- a/starboard/xb1/i18n/es-419.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es-AR.xlb b/starboard/xb1/i18n/es-AR.xlb deleted file mode 100644 index 3b9aed70b474..000000000000 --- a/starboard/xb1/i18n/es-AR.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es-CL.xlb b/starboard/xb1/i18n/es-CL.xlb deleted file mode 100644 index 36a2b2b8734a..000000000000 --- a/starboard/xb1/i18n/es-CL.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es-CO.xlb b/starboard/xb1/i18n/es-CO.xlb deleted file mode 100644 index ea1dcc338233..000000000000 --- a/starboard/xb1/i18n/es-CO.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es-MX.xlb b/starboard/xb1/i18n/es-MX.xlb deleted file mode 100644 index 26e394618573..000000000000 --- a/starboard/xb1/i18n/es-MX.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es-US.xlb b/starboard/xb1/i18n/es-US.xlb deleted file mode 100644 index b578686eb8b1..000000000000 --- a/starboard/xb1/i18n/es-US.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar YouTube, accede a una cuenta de miembros de Xbox Live. -Elegir una cuenta -Salir -No se puede establecer conexión con YouTube. -Puedes encontrar más información sobre este problema en youtube.com/xb1_help o dejar un comentario en youtube.com/xb1_feedback. Para obtener más información sobre las interrupciones de la app, también puedes visitar www.xbox.com/status. -No es posible contactarse con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/es.xlb b/starboard/xb1/i18n/es.xlb deleted file mode 100644 index a52d178af536..000000000000 --- a/starboard/xb1/i18n/es.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para utilizar YouTube, inicia sesión en una cuenta de Xbox Live. -Selecciona una cuenta -Salir -No se puede establecer conexión con YouTube. -Obtén más información sobre este problema en youtube.com/xb1_help o envía tus sugerencias en youtube.com/xb1_feedback. Si necesitas más información sobre las interrupciones de la aplicación, también puedes ir a www.xbox.com/status. -No se ha podido establecer contacto con Xbox Live. -Reintentar - - diff --git a/starboard/xb1/i18n/fi.xlb b/starboard/xb1/i18n/fi.xlb deleted file mode 100644 index 10c55d6a3d6e..000000000000 --- a/starboard/xb1/i18n/fi.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Jos haluat käyttää YouTubea, kirjaudu sisään Xbox Live -tilillä. -Valitse tili -Sulje -YouTubeen yhdistäminen ei onnistu. -Lisätietoja ongelmasta on osoitteessa youtube.com/xb1_help. Voit myös lähettää palautetta osoitteessa youtube.com/xb1_feedback. Lisätietoja sovellusten käyttökatkoksista on osoitteessa www.xbox.com/status. -Yhteyden muodostaminen Xbox Liveen ei onnistu. -Yritä uudelleen - - diff --git a/starboard/xb1/i18n/fr-CA.xlb b/starboard/xb1/i18n/fr-CA.xlb deleted file mode 100644 index 43abcbc364e5..000000000000 --- a/starboard/xb1/i18n/fr-CA.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Pour utiliser YouTube, veuillez vous connecter à un compte avec abonnement à Xbox Live. -Sélectionner un compte -Quitter -Désolés, la connexion à YouTube est impossible. -Vous pouvez en savoir plus sur ce problème à l'adresse youtube.com/xb1_help, ou nous envoyer vos commentaires sur youtube.com/xb1_feedback. Pour en savoir plus au sujet des pannes d'application, vous pouvez également vous rendre à l'adresse www.xbox.com/status. -Communication impossible avec Xbox Live. -Réessayer - - diff --git a/starboard/xb1/i18n/fr-CH.xlb b/starboard/xb1/i18n/fr-CH.xlb deleted file mode 100644 index c5c78871c14d..000000000000 --- a/starboard/xb1/i18n/fr-CH.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Pour utiliser YouTube, veuillez vous connecter à un compte disposant d'un abonnement Xbox Live. -Sélectionner un compte -Quitter -Impossible de se connecter à YouTube. -Vous pouvez rechercher plus d'informations relatives à ce problème sur youtube.com/xb1_help, ou laisser un commentaire sur youtube.com/xb1_feedback. Pour plus d'informations sur les interruptions d'application, vous pouvez également accéder à www.xbox.com/status. -Impossible de se connecter à Xbox Live. -Réessayer - - diff --git a/starboard/xb1/i18n/fr.xlb b/starboard/xb1/i18n/fr.xlb deleted file mode 100644 index 32b80a4a3323..000000000000 --- a/starboard/xb1/i18n/fr.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Pour utiliser YouTube, veuillez vous connecter à un compte disposant d'un abonnement Xbox Live. -Sélectionner un compte -Quitter -Impossible de se connecter à YouTube. -Vous pouvez rechercher plus d'informations relatives à ce problème sur youtube.com/xb1_help, ou laisser un commentaire sur youtube.com/xb1_feedback. Pour plus d'informations sur les interruptions d'application, vous pouvez également accéder à www.xbox.com/status. -Impossible de se connecter à Xbox Live. -Réessayer - - diff --git a/starboard/xb1/i18n/it.xlb b/starboard/xb1/i18n/it.xlb deleted file mode 100644 index 475b59259cf6..000000000000 --- a/starboard/xb1/i18n/it.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Per utilizzare YouTube, accedi a un account con l'iscrizione a Xbox Live. -Scegli un account -Esci -Impossibile connettersi a YouTube. -Puoi trovare ulteriori informazioni su questo problema all'indirizzo youtube.com/xb1_help o lasciare un commento su youtube.com/xb1_feedback. Per maggiori informazioni sulle interruzioni dell'applicazione, puoi visitare la pagina www.xbox.com/status. -Impossibile contattare Xbox Live. -Riprova - - diff --git a/starboard/xb1/i18n/ja.xlb b/starboard/xb1/i18n/ja.xlb deleted file mode 100644 index 6fb5c9ed576b..000000000000 --- a/starboard/xb1/i18n/ja.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -YouTube を使用するには、Xbox Live メンバーシップのあるアカウントでログインしてください。 -アカウントを選択 -終了 -YouTube に接続できませんでした。 -この問題について詳しくは youtube.com/xb1_help をご覧ください。また、youtube.com/xb1_feedback からフィードバックを送信してください。アプリケーションのサービス停止については www.xbox.com/status をご覧ください。 -Xbox Live に接続できません。 -再試行 - - diff --git a/starboard/xb1/i18n/ko.xlb b/starboard/xb1/i18n/ko.xlb deleted file mode 100644 index cb27060ac20b..000000000000 --- a/starboard/xb1/i18n/ko.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -YouTube를 사용하려면 Xbox LIVE 멤버십으로 계정에 로그인하세요. -계정 선택 -종료 -YouTube에 연결할 수 없습니다. -youtube.com/xb1_help에서 이 문제에 대한 자세한 내용을 확인하거나 youtube.com/xb1_feedback에서 의견을 남길 수 있습니다. 애플리케이션 중단에 대한 자세한 내용은 www.xbox.com/status에서도 확인할 수 있습니다. -Xbox LIVE에 연결할 수 없습니다. -다시 시도 - - diff --git a/starboard/xb1/i18n/nb.xlb b/starboard/xb1/i18n/nb.xlb deleted file mode 100644 index 5ac3f262f7e9..000000000000 --- a/starboard/xb1/i18n/nb.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Hvis du vil bruke YouTube, må du logge deg på en konto med Xbox Live-medlemskap. -Velg en konto -Avslutt -Beklager, kunne ikke koble til YouTube. -Du kan finne mer informasjon om dette problemet på youtube.com/xb1_help eller gi tilbakemelding på youtube.com/xb1_feedback. Hvis du vil ha mer informasjon om problemer med appen, kan du gå til www.xbox.com/status. -Kan ikke kontakte Xbox Live. -Prøv på nytt - - diff --git a/starboard/xb1/i18n/nl.xlb b/starboard/xb1/i18n/nl.xlb deleted file mode 100644 index 5d53c43135c2..000000000000 --- a/starboard/xb1/i18n/nl.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Log in op een account met een Xbox Live-lidmaatschap om YouTube te gebruiken. -Een account selecteren -Afsluiten -Er kan geen verbinding worden gemaakt met YouTube. -Ga voor meer informatie over dit probleem naar youtube.com/xb1_help of laat een reactie achter op youtube.com/xb1_feedback. Meer informatie over problemen met applicaties vind je op www.xbox.com/status. -Kan geen contact maken met Xbox Live. -Opnieuw proberen - - diff --git a/starboard/xb1/i18n/pl.xlb b/starboard/xb1/i18n/pl.xlb deleted file mode 100644 index 750069fc9ad2..000000000000 --- a/starboard/xb1/i18n/pl.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Aby korzystać z YouTube, zaloguj się na konto Xbox Live. -Wybierz konto -Zamknij -Nie udało się połączyć z YouTube. -Więcej informacji o tym problemie znajdziesz na youtube.com/xb1. Możesz także pozostawić swoją opinię na youtube.com/xb1_feedback. Informacje o przerwach w działaniu aplikacji znajdziesz na www.xbox.com/status. -Nie można połączyć się z usługą Xbox Live. -Spróbuj jeszcze raz - - diff --git a/starboard/xb1/i18n/pt-BR.xlb b/starboard/xb1/i18n/pt-BR.xlb deleted file mode 100644 index db78a2568fcf..000000000000 --- a/starboard/xb1/i18n/pt-BR.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar o YouTube, faça login em uma conta usando a Assinatura Xbox Live. -Escolha uma conta -Sair -Infelizmente, não foi possível conectar ao YouTube. -Você pode encontrar mais informações sobre este problema em youtube.com/xb1_help ou deixar um feedback em youtube.com/xb1_feedback. Para mais informações sobre falhas no aplicativo, visite também www.xbox.com/status. -Não foi possível contatar o Xbox Live. -Tentar novamente - - diff --git a/starboard/xb1/i18n/pt-PT.xlb b/starboard/xb1/i18n/pt-PT.xlb deleted file mode 100644 index aaaeed291d82..000000000000 --- a/starboard/xb1/i18n/pt-PT.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para utilizar o YouTube, inicie sessão numa conta com uma subscrição Xbox Live. -Selecione uma conta -Sair -Lamentamos, não foi possível estabelecer a ligação ao YouTube. -Pode encontrar mais informações acerca deste problema em youtube.com/xb1_help, ou deixar um comentário em youtube.com/xb1_feedback. Para mais informações acerca de falhas da app, também pode visitar www.xbox.com/status. -Não é possível comunicar com o Xbox Live. -Tentar novamente - - diff --git a/starboard/xb1/i18n/pt.xlb b/starboard/xb1/i18n/pt.xlb deleted file mode 100644 index 92da77a91732..000000000000 --- a/starboard/xb1/i18n/pt.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Para usar o YouTube, faça login em uma conta usando a Assinatura Xbox Live. -Escolha uma conta -Sair -Infelizmente, não foi possível conectar ao YouTube. -Você pode encontrar mais informações sobre este problema em youtube.com/xb1_help ou deixar um feedback em youtube.com/xb1_feedback. Para mais informações sobre falhas no aplicativo, visite também www.xbox.com/status. -Não foi possível contatar o Xbox Live. -Tentar novamente - - diff --git a/starboard/xb1/i18n/ru.xlb b/starboard/xb1/i18n/ru.xlb deleted file mode 100644 index ae2239f0dd60..000000000000 --- a/starboard/xb1/i18n/ru.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Чтобы использовать YouTube, войдите в аккаунт с доступом к Xbox Live. -Выбрать аккаунт -Выйти -Не удалось установить соединение с YouTube. -Подробнее о проблеме читайте здесь: youtube.com/xb1_help. Если вы хотите оставить отзыв, перейдите на эту страницу: youtube.com/xb1_feedback. О сбоях в работе приложения мы также рассказываем на странице www.xbox.com/status. -Невозможно подключиться к Xbox Live. -Повторить - - diff --git a/starboard/xb1/i18n/sv.xlb b/starboard/xb1/i18n/sv.xlb deleted file mode 100644 index ca1ce0a60b8e..000000000000 --- a/starboard/xb1/i18n/sv.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -Om du vill använda YouTube loggar du in på ett konto med Xbox Live-medlemskap. -Välj ett konto -Avsluta -Det gick inte att ansluta till YouTube. -Det finns mer information om det här problemet på youtube.com/xb1_help, och du kan skicka feedback på youtube.com/xb1_feedback. Mer information om programavbrott finns på www.xbox.com/status. -Det går inte att kontakta Xbox Live. -Försök igen - - diff --git a/starboard/xb1/i18n/tr.xlb b/starboard/xb1/i18n/tr.xlb deleted file mode 100644 index 6f80207bdad4..000000000000 --- a/starboard/xb1/i18n/tr.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -YouTube'u kullanmak için lütfen Xbox Live üyeliğine sahip bir hesapta oturum açın. -Bir hesap seç -Çıkış yap -Maalesef YouTube'a bağlanılamadı. -youtube.com/xb1_help adresinde bu sorunla ilgili daha fazla bilgi bulabilir veya youtube.com/xb1_feedback adresinde geri bildirim bırakabilirsiniz. Uygulamanın geçici olarak hizmet dışı kalmasıyla ilgili daha fazla bilgi için www.xbox.com/status adresini de ziyaret edebilirsiniz. -XBox Live'a erişilemiyor. -Tekrar Dene - - diff --git a/starboard/xb1/i18n/zh-CN.xlb b/starboard/xb1/i18n/zh-CN.xlb deleted file mode 100644 index 8dc3d59feb0c..000000000000 --- a/starboard/xb1/i18n/zh-CN.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -要使用YouTube,请以Xbox Live会员身份登录帐号。 -选择帐号 -退出 -抱歉,无法连接到 YouTube。 -您可以访问 youtube.com/xb1_help 详细了解此问题,或访问 youtube.com/xb1_feedback 提供反馈。有关应用停止运行的详情,您还可访问 www.xbox.com/status。 -无法联系 Xbox Live。 -重试 - - diff --git a/starboard/xb1/i18n/zh-HK.xlb b/starboard/xb1/i18n/zh-HK.xlb deleted file mode 100644 index 87a5c9240266..000000000000 --- a/starboard/xb1/i18n/zh-HK.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -如要使用 YouTube,請登入具有 Xbox Live 會員資格的帳戶。 -選擇帳戶 -結束 -抱歉!無法連結 YouTube。 -你可以在 www.youtube.com/xb1_help 查看更多資訊,或前往 youtube.com/xb1_feedback 留下意見。如要瞭解更多有關應用程式故障的事宜,你也可以前往:www.xbox.com/status。 -無法連線至 Xbox Live。 -重試 - - diff --git a/starboard/xb1/i18n/zh-TW.xlb b/starboard/xb1/i18n/zh-TW.xlb deleted file mode 100644 index d5343a28cf93..000000000000 --- a/starboard/xb1/i18n/zh-TW.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -如要使用 YouTube,請登入具有 Xbox Live 會員資格的帳戶。 -選擇帳戶 -離開 -很抱歉,無法連線至 YouTube -如需進一步瞭解這個問題,請前往 youtube.com/xb1_help;如要提供意見,請前往 youtube.com/xb1_feedback。如要進一步瞭解應用程式暫停服務的相關細節,請瀏覽 www.xbox.com/status。 -無法連線至 Xbox Live。 -重試 - - diff --git a/starboard/xb1/i18n/zh.xlb b/starboard/xb1/i18n/zh.xlb deleted file mode 100644 index 77ae1b35e273..000000000000 --- a/starboard/xb1/i18n/zh.xlb +++ /dev/null @@ -1,12 +0,0 @@ - - - -要使用YouTube,请以Xbox Live会员身份登录帐号。 -选择帐号 -退出 -抱歉,无法连接到 YouTube。 -您可以访问 youtube.com/xb1_help 详细了解此问题,或访问 youtube.com/xb1_feedback 提供反馈。有关应用停止运行的详情,您还可访问 www.xbox.com/status。 -无法联系 Xbox Live。 -重试 - - diff --git a/starboard/xb1/install_target.gni b/starboard/xb1/install_target.gni deleted file mode 100644 index 45ee0c70344b..000000000000 --- a/starboard/xb1/install_target.gni +++ /dev/null @@ -1,168 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") -import("//starboard/build/toolchain/win/variables.gni") - -template("install_target") { - not_needed(invoker, [ "type" ]) - installable_target_name = invoker.installable_target_name - should_run_mspdbcmf = - installable_target_name == "cobalt" && (is_qa || is_gold) - - if (should_run_mspdbcmf) { - # This takes a long time to run and is only necessary for cobalt. - create_pdb_file_name = "${installable_target_name}_create_pdb_file" - action(create_pdb_file_name) { - forward_variables_from(invoker, [ "testonly" ]) - script = "//starboard/build/run_bash.py" - sources = [ "$root_out_dir/${installable_target_name}.exe" ] - outputs = [ "$root_out_dir/${installable_target_name}.exe.pdb" ] - args = [ - "$tool_base_path/mspdbcmf.exe", - rebase_path(outputs[0], root_build_dir), - ] - deps = [ ":$installable_target_name" ] - } - } - - if (is_internal_build) { - products = [ "youtube" ] - if (installable_target_name == "cobalt") { - products += [ - "youtubetv", - "mainappbeta", - ] - } - } else { - products = [ "cobalt" ] - } - - foreach(product, products) { - if (product == "youtube" || product == "cobalt") { - target_base_name = target_name - appx_output_dir = "$root_out_dir/appx" - template_output_dir = "$root_out_dir/templates" - } else if (product == "youtubetv") { - not_needed([ "target_name" ]) - target_base_name = product + "_install" - appx_output_dir = "$root_out_dir/youtubetv-appx" - template_output_dir = "$root_out_dir/youtubetv-templates" - } else if (product == "mainappbeta") { - not_needed([ "target_name" ]) - target_base_name = product + "_install" - appx_output_dir = "$root_out_dir/mainappbeta-appx" - template_output_dir = "$root_out_dir/mainappbeta-templates" - } else { - assert( - false, - "|product| must be one of youtube, youtubetv, mainappbeta, or cobalt.") - } - - appx_template_dir_src = "//starboard/xb1/templates" - application_section_output = - "$template_output_dir/ApplicationSection.$installable_target_name.xml" - application_template = - "$appx_template_dir_src/ApplicationSection.xml.template" - - copy_application_name = "${target_base_name}_copy_exe" - copy(copy_application_name) { - forward_variables_from(invoker, [ "testonly" ]) - sources = [ "$root_out_dir/${installable_target_name}.exe" ] - outputs = [ "${appx_output_dir}/${installable_target_name}.exe" ] - deps = [ ":$installable_target_name" ] - } - - copy_winmd_name = "${target_base_name}_copy_winmd_for_appx" - action(copy_winmd_name) { - forward_variables_from(invoker, [ "testonly" ]) - sources = [ rebase_path("$root_out_dir/${installable_target_name}.exe") ] - outputs = [ "${appx_output_dir}/${installable_target_name}.winmd" ] - - script = "//starboard/build/copy_file.py" - args = [ - rebase_path("$root_out_dir/${installable_target_name}.winmd"), - rebase_path(outputs[0], root_build_dir), - ] - deps = [ ":$installable_target_name" ] - } - - generate_application_section_name = - "${target_base_name}_generate_application_section" - action(generate_application_section_name) { - forward_variables_from(invoker, [ "testonly" ]) - script = "//starboard/xb1/tools/application_section_generator.py" - - inputs = [ application_template ] - outputs = [ application_section_output ] - args = [ - "--config", - build_type, - "--application_template", - rebase_path(application_template, root_build_dir), - "--application_name", - installable_target_name, - "--product", - product, - "--output", - rebase_path(outputs[0], root_build_dir), - ] - deps = [ ":$installable_target_name" ] - } - - appx_run_name = "${target_base_name}_appx_run" - action(appx_run_name) { - forward_variables_from(invoker, [ "testonly" ]) - script = "//starboard/xb1/tools/appx.py" - appx_manifest_template = - "$appx_template_dir_src/AppxManifest.xml.template" - inputs = [ - appx_manifest_template, - application_section_output, - ] - outputs = [ "$template_output_dir/${installable_target_name}.should_not_exist.always_run" ] - args = [ - "--config", - build_type, - "--appx_template", - rebase_path(appx_manifest_template, root_build_dir), - "--template_directory", - rebase_path(template_output_dir, root_build_dir), - "--manifest_out", - rebase_path("$appx_output_dir/AppxManifest.xml", root_out_dir), - "--product", - product, - ] - deps = [ ":$generate_application_section_name" ] - } - - group(target_base_name) { - forward_variables_from(invoker, [ "testonly" ]) - deps = invoker.deps + [ - ":$appx_run_name", - ":$copy_application_name", - ":$copy_winmd_name", - ":$generate_application_section_name", - ":$installable_target_name", - "//starboard/xb1/install_target:${product}_copy_assets", - ] - if (is_debug || is_devel) { - deps += [ "//starboard/xb1/install_target:${product}_copy_ucrt_dll" ] - } - if (should_run_mspdbcmf) { - deps += [ ":$create_pdb_file_name" ] - } - } - } -} diff --git a/starboard/xb1/install_target/BUILD.gn b/starboard/xb1/install_target/BUILD.gn deleted file mode 100644 index a5fa487c16bd..000000000000 --- a/starboard/xb1/install_target/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if (is_internal_build) { - _products = [ - "youtube", - "youtubetv", - "mainappbeta", - ] -} else { - _products = [ "cobalt" ] -} -foreach(product, _products) { - if (product == "youtube") { - appx_output_dir = "$root_out_dir/appx" - appx_asset_dir_src = "//internal/starboard/xb1/assets" - } else if (product == "youtubetv") { - appx_output_dir = "$root_out_dir/youtubetv-appx" - appx_asset_dir_src = "//internal/starboard/xb1/youtubetv/assets" - } else if (product == "mainappbeta") { - appx_output_dir = "$root_out_dir/mainappbeta-appx" - appx_asset_dir_src = "//starboard/xb1/assets" - } else if (product == "cobalt") { - appx_output_dir = "$root_out_dir/appx" - } else { - assert( - false, - "|product| must be one of youtube, youtubetv, mainappbeta, or cobalt.") - } - - if (!is_internal_build) { - # Use Cobalt assets for all external builds - appx_asset_dir_src = "//starboard/xb1/assets" - } - - copy("${product}_copy_assets") { - sources = [ - "$appx_asset_dir_src/Square150x150Logo.scale-100.png", - "$appx_asset_dir_src/Square310x310Logo.scale-100.png", - "$appx_asset_dir_src/Square44x44Logo.scale-100.png", - "$appx_asset_dir_src/Square71x71Logo.scale-100.png", - "$appx_asset_dir_src/Wide310x150Logo.scale-100.png", - ] - outputs = [ "$appx_output_dir/Assets/{{source_file_part}}" ] - } - - if (is_debug || is_devel) { - copy("${product}_copy_ucrt_dll") { - sources = [ "C:/Program Files (x86)/Microsoft SDKs/Windows Kits/10/ExtensionSDKs/Microsoft.UniversalCRT.Debug/$wdk_version/Redist/Debug/x64/ucrtbased.dll" ] - outputs = [ "$appx_output_dir/ucrtbased.dll" ] - } - } -} diff --git a/starboard/xb1/launcher.py b/starboard/xb1/launcher.py deleted file mode 100644 index 583aa3b9b031..000000000000 --- a/starboard/xb1/launcher.py +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""XB1 implementation of Starboard launcher abstraction.""" - -from __future__ import print_function - -from starboard.tools import abstract_launcher -from starboard.xb1.tools import uwp_launcher -from starboard.xb1.tools import xb1_launcher - -_UWP_XB1_MESSAGE = '****************************************************\n' + \ - '* UWP on XB1 *\n' + \ - '****************************************************\n' - -_UWP_WIN_MESSAGE = '****************************************************\n' + \ - '* UWP on Windows *\n' + \ - '****************************************************\n' - - -# This Launcher delegates either to an xb1 launcher or to a uwp launcher. -# The xb1 launcher runs tests on the xb1 remote device. -# The uwp launcher runs tests on the local windows device. -class Launcher(abstract_launcher.AbstractLauncher): - """Run an application on XB1.""" - - def __init__(self, platform, target_name, config, device_id, **kwargs): - super().__init__(platform, target_name, config, device_id, **kwargs) - if not device_id: - raise ValueError('\nMissing device_id, please specify --device_id ' - ' or --device_id win_uwp (running in Windows).') - if device_id == 'win_uwp': - self.output_file.write('\n' + _UWP_WIN_MESSAGE) - self.delegate = uwp_launcher.Launcher(platform, target_name, config, - device_id, **kwargs) - else: - # Assume the address points to an xbox. - self.output_file.write('\n' + _UWP_XB1_MESSAGE) - # Defer loading because depot_tools does not have the required - # python requests library installed. - # TODO: Install requests library depot_tools and update. - self.delegate = xb1_launcher.Launcher(platform, target_name, config, - device_id, **kwargs) - - # Run() and Kill() needs to be explicitly implemented per AbstractLauncher. - def Run(self): - return self.delegate.Run() - - def Kill(self): - return self.delegate.Kill() - - # All other functions are automatically delegated using this function. - def __getattr__(self, fname): - return getattr(self.delegate, fname) - - def GetDeviceIp(self): - """Gets the device IP. TODO: Implement.""" - return None - - def GetDeviceOutputPath(self): - self.delegate.GetDeviceOutputPath() diff --git a/starboard/xb1/platform_configuration/BUILD.gn b/starboard/xb1/platform_configuration/BUILD.gn deleted file mode 100644 index 10b82842bef2..000000000000 --- a/starboard/xb1/platform_configuration/BUILD.gn +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -config("platform_configuration") { - configs = [ - "//starboard/win/shared/platform_configuration", - ":target", - ] -} - -config("target") { - if (is_internal_build) { - include_dirs = [ - "//third_party/internal/libvpx_xb1", - "//third_party/internal/libav1_xb1/libav1", - "//third_party/internal/libav1_xb1/libav1/build", - ] - } - libs = [] - ldflags = [ - "/MACHINE:x64", - - # Don't send error reports to MS. - "/errorReport:none", - ] - arflags = [] - cflags = [ - # The warning "Padding was added at the end of a structure" happens - # in the library third_party/internal/libav1_xb1. - "/wd4324", - "/Zc:__cplusplus", # enable preprocessor macro for language support - ] - - if (is_debug || is_devel) { - libs = [ - "vccorlibd.lib", - "msvcrtd.lib", - "msvcprtd.lib", - "vcruntimed.lib", - "ucrtd.lib", - ] - } else { - libs = [ - "vccorlib.lib", - "msvcrt.lib", - "msvcprt.lib", - "vcruntime.lib", - "ucrt.lib", - ] - } - - ldflags += [ "/NODEFAULTLIB" ] - arflags += [ "/NODEFAULTLIB" ] - libs += [ - "d3d12.lib", - "dxguid.lib", - "iso_stdio_wide_specifiers.lib", - "mfplat.lib", - "mfuuid.lib", - "oldnames.lib", - "windowsapp.lib", - ] - ldflags += [ - "/SUBSYSTEM:WINDOWS", - - # WinMD file required for UWP. - "/WINMD", - - # Required for UWP - "/APPCONTAINER", - ] -} diff --git a/starboard/xb1/platform_configuration/configuration.gni b/starboard/xb1/platform_configuration/configuration.gni deleted file mode 100644 index 44a17e4494a6..000000000000 --- a/starboard/xb1/platform_configuration/configuration.gni +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//starboard/win/shared/platform_configuration/configuration.gni") - -sb_widevine_platform = "xbox" -sb_static_contents_output_data_dir = "$root_out_dir/appx/content/data" -cobalt_font_package = "standard" - -install_target_path = "//starboard/xb1/install_target.gni" - -platform_i18n_config_path = "//starboard/xb1/i18n:i18n" - -platform_tests_path = "//starboard/xb1/shared:starboard_platform_tests" diff --git a/starboard/xb1/public_system_properties.cc b/starboard/xb1/public_system_properties.cc deleted file mode 100644 index fb8b877c9a56..000000000000 --- a/starboard/xb1/public_system_properties.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/xb1/system_properties.h" - -const char kCertificationScope[] = ""; -const char kBase64EncodedCertificationSecret[] = ""; diff --git a/starboard/xb1/shared/BUILD.gn b/starboard/xb1/shared/BUILD.gn deleted file mode 100644 index a3a3538a779b..000000000000 --- a/starboard/xb1/shared/BUILD.gn +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2023 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -target(gtest_target_type, "starboard_platform_tests") { - testonly = true - - sources = [ - "//starboard/common/test_main.cc", - "//starboard/shared/uwp/system_get_property_test.cc", - ] - - configs += [ "//starboard/build/config:starboard_implementation" ] - - deps = [ - "//starboard:starboard_group", - "//testing/gmock", - "//testing/gtest", - ] -} diff --git a/starboard/xb1/shared/configuration.cc b/starboard/xb1/shared/configuration.cc deleted file mode 100644 index 3d1d30e10f03..000000000000 --- a/starboard/xb1/shared/configuration.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/xb1/shared/configuration.h" - -#include "starboard/common/configuration_defaults.h" -#include "starboard/extension/configuration.h" - -namespace starboard { -namespace xb1 { -namespace shared { - -namespace { - -const char* CobaltFallbackSplashScreenUrl() { - return "file:///splash_screen/youtube_splash_screen.html"; -} - -int CobaltLocalTypefaceCacheSizeInBytes() { - // 24MB font cache size is recommended when using the |expanded| - // cobalt font package. - return 24 * 1024 * 1024; -} - -const CobaltExtensionConfigurationApi kConfigurationApi = { - kCobaltExtensionConfigurationName, - 3, - &common::CobaltUserOnExitStrategyDefault, - &common::CobaltRenderDirtyRegionOnlyDefault, - &common::CobaltEglSwapIntervalDefault, - &CobaltFallbackSplashScreenUrl, - &common::CobaltEnableQuicDefault, - &common::CobaltSkiaCacheSizeInBytesDefault, - &common::CobaltOffscreenTargetCacheSizeInBytesDefault, - &common::CobaltEncodedImageCacheSizeInBytesDefault, - &common::CobaltImageCacheSizeInBytesDefault, - &CobaltLocalTypefaceCacheSizeInBytes, - &common::CobaltRemoteTypefaceCacheSizeInBytesDefault, - &common::CobaltMeshCacheSizeInBytesDefault, - &common::CobaltSoftwareSurfaceCacheSizeInBytesDefault, - &common::CobaltImageCacheCapacityMultiplierWhenPlayingVideoDefault, - &common::CobaltSkiaGlyphAtlasWidthDefault, - &common::CobaltSkiaGlyphAtlasHeightDefault, - &common::CobaltJsGarbageCollectionThresholdInBytesDefault, - &common::CobaltReduceCpuMemoryByDefault, - &common::CobaltReduceGpuMemoryByDefault, - &common::CobaltGcZealDefault, - &common::CobaltRasterizerTypeDefault, - &common::CobaltEnableJitDefault, - &common::CobaltFallbackSplashScreenTopicsDefault, - &common::CobaltCanStoreCompiledJavascriptDefault, -}; - -} // namespace - -const void* GetConfigurationApi() { - return &kConfigurationApi; -} - -} // namespace shared -} // namespace xb1 -} // namespace starboard diff --git a/starboard/xb1/shared/configuration.h b/starboard/xb1/shared/configuration.h deleted file mode 100644 index 6aec4e1fb911..000000000000 --- a/starboard/xb1/shared/configuration.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SHARED_CONFIGURATION_H_ -#define STARBOARD_XB1_SHARED_CONFIGURATION_H_ - -namespace starboard { -namespace xb1 { -namespace shared { - -const void* GetConfigurationApi(); - -} // namespace shared -} // namespace xb1 -} // namespace starboard - -#endif // STARBOARD_XB1_SHARED_CONFIGURATION_H_ diff --git a/starboard/xb1/shared/configuration_constants.cc b/starboard/xb1/shared/configuration_constants.cc deleted file mode 100644 index 52ee88b84d4f..000000000000 --- a/starboard/xb1/shared/configuration_constants.cc +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2019 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This file defines all configuration constants for a platform. - -#include "starboard/configuration_constants.h" - -// Determines the threshold of allocation size that should be done with mmap -// (if available), rather than allocated within the core heap. -const size_t kSbDefaultMmapThreshold = 256 * 1024U; - -// The current platform's maximum length of the name of a single directory -// entry, not including the absolute path. -const int32_t kSbFileMaxName = 260; - -// The current platform's maximum number of files that can be opened at the -// same time by one process. -const uint32_t kSbFileMaxOpen = 63; - -// The current platform's alternate file path component separator character. -// This is like SB_FILE_SEP_CHAR, except if your platform supports an alternate -// character, then you can place that here. For example, on windows machines, -// the primary separator character is probably '\', but the alternate is '/'. -const char kSbFileAltSepChar = '/'; - -// The string form of SB_FILE_ALT_SEP_CHAR. -const char* kSbFileAltSepString = "/"; - -// The current platform's maximum length of an absolute path. -const uint32_t kSbFileMaxPath = 4096; - -// The current platform's file path component separator character. This is the -// character that appears after a directory in a file path. For example, the -// absolute canonical path of the file "/path/to/a/file.txt" uses '/' as a path -// component separator character. -const char kSbFileSepChar = '\\'; - -// The string form of SB_FILE_SEP_CHAR. -const char* kSbFileSepString = "\\"; - -// Specifies whether this platform has webm/vp9 support. This should be set to -// non-zero on platforms with webm/vp9 support. -const bool kSbHasMediaWebmVp9Support = true; - -// Whether the current platform supports thread priorities. -const bool kSbHasThreadPrioritySupport = true; - -// Determines the alignment that allocations should have on this platform. -const size_t kSbMallocAlignment = 16; - -// The maximum number of thread local storage keys supported by this platform. -const uint32_t kSbMaxThreadLocalKeys = 512; - -// The maximum length of a name for a thread, including the NULL-terminator. -const int32_t kSbMaxThreadNameLength = 16; - -// Defines the path where memory debugging logs should be written to. -const char* kSbMemoryLogPath = "/tmp/starboard"; - -// The maximum audio bitrate the platform can decode. The following value -// equals to 5M bytes per seconds which is more than enough for compressed -// audio. -const uint32_t kSbMediaMaxAudioBitrateInBitsPerSecond = 40 * 1024 * 1024; - -// The maximum video bitrate the platform can decode. The following value -// equals to 25M bytes per seconds which is more than enough for compressed -// video. -const uint32_t kSbMediaMaxVideoBitrateInBitsPerSecond = 200 * 1024 * 1024; - -// Specifies how video frame buffers must be aligned on this platform. -const uint32_t kSbMediaVideoFrameAlignment = 256; - -// The memory page size, which controls the size of chunks on memory that -// allocators deal with, and the alignment of those chunks. This doesn't have to -// be the hardware-defined physical page size, but it should be a multiple of -// it. -const size_t kSbMemoryPageSize = 4096; - -// Specifies the network receive buffer size in bytes, set via -// SbSocketSetReceiveBufferSize(). -// -// Setting this to 0 indicates that SbSocketSetReceiveBufferSize() should -// not be called. Use this for OSs (such as Linux) where receive buffer -// auto-tuning is better. -// -// On some platforms, this may affect max TCP window size which may -// dramatically affect throughput in the presence of latency. -// -// If your platform does not have a good TCP auto-tuning mechanism, -// a setting of (128 * 1024) here is recommended. -const uint32_t kSbNetworkReceiveBufferSize = 0; - -// Defines the maximum number of simultaneous threads for this platform. Some -// platforms require sharing thread handles with other kinds of system handles, -// like mutexes, so we want to keep this manageable. -const uint32_t kSbMaxThreads = 90; - -// The current platform's search path component separator character. When -// specifying an ordered list of absolute paths of directories to search for a -// given reason, this is the character that appears between entries. For -// example, the search path of "/etc/search/first:/etc/search/second" uses ':' -// as a search path component separator character. -#ifdef __cplusplus -extern "C" { -#endif -const char kSbPathSepChar = ';'; -#ifdef __cplusplus -} // extern "C" -#endif - -// The string form of SB_PATH_SEP_CHAR. -const char* kSbPathSepString = ";"; - -// Specifies the preferred byte order of color channels in a pixel. Refer to -// starboard/configuration.h for the possible values. EGL/GLES platforms should -// generally prefer a byte order of RGBA, regardless of endianness. -const int kSbPreferredRgbaByteOrder = SB_PREFERRED_RGBA_BYTE_ORDER_RGBA; - -#if SB_API_VERSION < 16 -// The maximum number of users that can be signed in at the same time. -const uint32_t kSbUserMaxSignedIn = 1; -#endif // SB_API_VERSION < 16 - -// The maximum size the cache directory is allowed to use in bytes. -const uint32_t kSbMaxSystemPathCacheDirectorySize = 24 << 20; // 24MiB - -#if SB_API_VERSION >= 16 -// Whether this platform can map executable memory. This is required for -// platforms that want to JIT. -SB_EXPORT extern const bool kSbCanMapExecutableMemory = true; - -// Platform can support partial audio frames -SB_EXPORT extern const bool kHasPartialAudioFramesSupport = true; -#endif diff --git a/starboard/xb1/shared/configuration_public.h b/starboard/xb1/shared/configuration_public.h deleted file mode 100644 index 278d3fe7e894..000000000000 --- a/starboard/xb1/shared/configuration_public.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Other source files should never include this header directly, but should -// include the generic "starboard/configuration.h" instead. - -#ifndef STARBOARD_XB1_SHARED_CONFIGURATION_PUBLIC_H_ -#define STARBOARD_XB1_SHARED_CONFIGURATION_PUBLIC_H_ - -// --- System Header Configuration ------------------------------------------- - -// Any system headers listed here that are not provided by the platform will be -// emulated in starboard/types.h. - -// Whether the current platform provides the standard header sys/types.h. -#define SB_HAS_SYS_TYPES_H 0 - -// Whether the current platform provides ssize_t. -#define SB_HAS_SSIZE_T 0 - -#if !defined(__WCHAR_MAX__) -#include -#define __WCHAR_MAX__ WCHAR_MAX -#endif - -// Type detection for wchar_t. -#if defined(__WCHAR_MAX__) && \ - (__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff) -#define SB_IS_WCHAR_T_UTF32 1 -#elif defined(__WCHAR_MAX__) && \ - (__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff) -#define SB_IS_WCHAR_T_UTF16 1 -#endif - -// Chrome only defines this for ARMEL. -#if defined(__ARMEL__) -// Chrome has an exclusion for iOS here, we should too when we support iOS. -#define SB_IS_WCHAR_T_UNSIGNED 1 -#endif - -// --- Network Configuration ------------------------------------------------- - -// Specifies whether this platform supports IPV6. -#define SB_HAS_IPV6 1 - -// --- Platform Specific Quirks ---------------------------------------------- -#define SB_HAS_QUIRK_NO_CONDATTR_SETCLOCK_SUPPORT 1 - -#endif // STARBOARD_XB1_SHARED_CONFIGURATION_PUBLIC_H_ diff --git a/starboard/xb1/shared/gpu_base_video_decoder.cc b/starboard/xb1/shared/gpu_base_video_decoder.cc deleted file mode 100644 index 2bd7e17d254f..000000000000 --- a/starboard/xb1/shared/gpu_base_video_decoder.cc +++ /dev/null @@ -1,793 +0,0 @@ -// Copyright 2021 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/xb1/shared/gpu_base_video_decoder.h" - -#include -#include -#include - -#include "starboard/common/once.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/async_utils.h" -#include "starboard/shared/uwp/decoder_utils.h" -#include "starboard/shared/uwp/extended_resources_manager.h" -#include "starboard/shared/win32/decode_target_internal.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/thread.h" -#include "third_party/angle/include/EGL/egl.h" -#include "third_party/angle/include/EGL/eglext.h" -#include "third_party/angle/include/GLES2/gl2.h" -#include "third_party/angle/include/GLES2/gl2ext.h" -#include "third_party/angle/include/angle_hdr.h" -#if defined(INTERNAL_BUILD) -#include "third_party/internal/libav1_xb1/libav1/d3dx12.h" -#endif // defined(INTERNAL_BUILD) - -namespace starboard { -namespace xb1 { -namespace shared { - -namespace { - -using Microsoft::WRL::ComPtr; -using starboard::shared::starboard::player::JobThread; -using starboard::shared::starboard::player::filter::VideoFrame; -using starboard::shared::uwp::ApplicationUwp; -using starboard::shared::uwp::ExtendedResourcesManager; -using starboard::shared::uwp::FindByTimestamp; -using starboard::shared::uwp::RemoveByTimestamp; -using starboard::shared::uwp::UpdateHdrColorMetadataToCurrentDisplay; -using Windows::Graphics::Display::Core::HdmiDisplayInformation; - -// Limit the number of pending buffers. -constexpr int kMaxNumberOfPendingBuffers = 8; -// Limit the cached presenting images. -constexpr int kNumberOfCachedPresentingImage = 3; -// The number of frame buffers in decoder -constexpr int kNumOutputFrameBuffers = 7; - -const char kDecoderThreadName[] = "gpu_video_decoder_thread"; -} // namespace - -class GpuFrameBufferPool { - public: - HRESULT AllocateFrameBuffers( - uint16_t width, - uint16_t height, - DXGI_FORMAT dxgi_format, - Microsoft::WRL::ComPtr d3d11_device, - Microsoft::WRL::ComPtr d3d12_device) { - HRESULT hr; - uint16_t number_of_buffers = kNumOutputFrameBuffers; - if (!frame_buffers_.empty()) { - auto& buffer = frame_buffers_.front(); - D3D11_TEXTURE2D_DESC desc; - buffer->texture(0)->GetDesc(&desc); - if (desc.Format != dxgi_format || buffer->width() < width || - buffer->height() < height || - d3d11_device.Get() != buffer->device11().Get() || - d3d12_device.Get() != buffer->device12().Get()) { - frame_buffers_.clear(); - } - } - if (frame_buffers_.empty()) { - frame_buffers_.reserve(number_of_buffers); - while (number_of_buffers--) { - GpuVideoDecoderBase::GpuFrameBuffer* gpu_fb = - new GpuVideoDecoderBase::GpuFrameBuffer(width, height, dxgi_format, - d3d11_device, d3d12_device); - hr = gpu_fb->CreateTextures(); - if (FAILED(hr)) { - frame_buffers_.clear(); - return hr; - } - frame_buffers_.emplace_back(gpu_fb); - } - } - return S_OK; - } - - GpuVideoDecoderBase::GpuFrameBuffer* GetFreeBuffer() { - SB_DCHECK(!frame_buffers_.empty()); - auto iter = std::find_if( - frame_buffers_.begin(), frame_buffers_.end(), - [](const auto& frame_buffer) { return frame_buffer->HasOneRef(); }); - if (iter == frame_buffers_.end()) - return nullptr; - else - return iter->get(); - } - - bool CheckIfAllBuffersAreReleased() { - for (auto&& frame_buffer : frame_buffers_) { - if (!frame_buffer->HasOneRef()) - return false; - } - return true; - } - - void Clear() { frame_buffers_.clear(); } - - private: - std::vector> - frame_buffers_; -}; - -SB_ONCE_INITIALIZE_FUNCTION(GpuFrameBufferPool, GetGpuFrameBufferPool); - -class GpuVideoDecoderBase::GPUDecodeTargetPrivate - : public SbDecodeTargetPrivate { - public: - GPUDecodeTargetPrivate( - void* egl_display, - void* egl_config, - const scoped_refptr& image) - : egl_display_(egl_display), egl_config_(egl_config), image_(image) { - SB_DCHECK(egl_display_); - SB_DCHECK(egl_config); - - if (image->bit_depth() == 8) { - info.format = kSbDecodeTargetFormat3PlaneYUVI420; - } else { - SB_DCHECK(image->bit_depth() == 10); - info.format = image->is_compacted() - ? kSbDecodeTargetFormat3Plane10BitYUVI420Compact - : kSbDecodeTargetFormat3Plane10BitYUVI420; - } - info.is_opaque = true; - info.width = image->width(); - info.height = image->height(); - GLuint gl_textures_yuv[kNumberOfPlanes] = {}; - glGenTextures(kNumberOfPlanes, gl_textures_yuv); - SB_DCHECK(glGetError() == GL_NO_ERROR); - - for (unsigned int i = 0; i < kNumberOfPlanes; ++i) { - const int stride = image->stride(i); - const int subsampling = i > 0; - const int width = info.width >> subsampling; - const int height = info.height >> subsampling; - EGLint texture_attributes[] = {EGL_WIDTH, - static_cast(stride), - EGL_HEIGHT, - static_cast(height), - EGL_TEXTURE_TARGET, - EGL_TEXTURE_2D, - EGL_TEXTURE_FORMAT, - EGL_TEXTURE_RGBA, - EGL_NONE}; - surfaces_[i] = eglCreatePbufferFromClientBuffer( - egl_display_, EGL_D3D_TEXTURE_ANGLE, image->texture(i).Get(), - egl_config, texture_attributes); - SB_DCHECK(glGetError() == GL_NO_ERROR && surfaces_[i] != EGL_NO_SURFACE); - glBindTexture(GL_TEXTURE_2D, gl_textures_yuv[i]); - SB_DCHECK(glGetError() == GL_NO_ERROR); - bool result = - eglBindTexImage(egl_display_, surfaces_[i], EGL_BACK_BUFFER); - SB_DCHECK(result); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - - D3D11_TEXTURE2D_DESC tex_desc = {}; - image->texture(i)->GetDesc(&tex_desc); - - SbDecodeTargetInfoPlane* plane = &info.planes[i]; - plane->width = - image->is_compacted() ? tex_desc.Width * 3 : tex_desc.Width; - plane->height = tex_desc.Height; - plane->content_region.left = image->texture_corner_left(i); - plane->content_region.top = plane->height - image->texture_corner_top(i); - plane->content_region.bottom = plane->content_region.top - height; - plane->content_region.right = plane->content_region.left + width; - plane->texture = gl_textures_yuv[i]; - plane->gl_texture_target = GL_TEXTURE_2D; - plane->gl_texture_format = GL_RED_EXT; - } - } - - ~GPUDecodeTargetPrivate() override { - for (unsigned int i = 0; i < kNumberOfPlanes; ++i) { - glDeleteTextures(1, &(info.planes[i].texture)); - eglReleaseTexImage(egl_display_, surfaces_[i], EGL_BACK_BUFFER); - eglDestroySurface(egl_display_, surfaces_[i]); - } - } - - int64_t timestamp() { return image_->timestamp(); } - - void ReleaseImage() { - // Release the codec resource, while the D3D textures are still safe to use. - SB_DCHECK(image_); - image_ = nullptr; - } - - private: - // Hold the codec resource until it's not needed in render pipeline to prevent - // it being reused and overwritten. - scoped_refptr image_; - // EGLSurface is defined as void* in "third_party/angle/include/EGL/egl.h". - // Use void* directly here to avoid `egl.h` being included broadly. - void* surfaces_[kNumberOfPlanes]; - void* egl_display_; - void* egl_config_; -}; - -GpuVideoDecoderBase::GpuFrameBuffer::GpuFrameBuffer( - uint16_t width, - uint16_t height, - DXGI_FORMAT dxgi_format, - Microsoft::WRL::ComPtr d3d11_device, - Microsoft::WRL::ComPtr d3d12_device) - : d3d11_device_(d3d11_device), d3d12_device_(d3d12_device) { - SB_DCHECK(d3d11_device_); - SB_DCHECK(d3d12_device_); - - texture_desc_.Format = dxgi_format; - texture_desc_.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; - texture_desc_.DepthOrArraySize = 1; - texture_desc_.MipLevels = 1; - texture_desc_.SampleDesc.Count = 1; - texture_desc_.SampleDesc.Quality = 0; - texture_desc_.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - texture_desc_.Layout = D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE; - - width_ = width; - height_ = height; -} - -HRESULT GpuVideoDecoderBase::GpuFrameBuffer::CreateTextures() { - const D3D12_HEAP_PROPERTIES kHeapPropertyTypeDefault = { - D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, - D3D12_MEMORY_POOL_UNKNOWN, 1, 1}; - HRESULT hr = E_FAIL; - for (unsigned int i = 0; i < kNumberOfPlanes; i++) { - const int subsampling = i > 0; - const int plane_width = - (texture_desc_.Format == DXGI_FORMAT_R10G10B10A2_UNORM) - ? (((width_ + subsampling) >> subsampling) + 2) / 3 - : ((width_ + subsampling) >> subsampling); - const int plane_height = (height_ + subsampling) >> subsampling; - - // Create interop resources. - texture_desc_.Width = plane_width; - texture_desc_.Height = plane_height; - hr = d3d12_device_->CreateCommittedResource( - &kHeapPropertyTypeDefault, D3D12_HEAP_FLAG_SHARED, &texture_desc_, - D3D12_RESOURCE_STATE_RENDER_TARGET, 0, - IID_PPV_ARGS(&d3d12_resources_[i])); - SB_DCHECK(SUCCEEDED(hr)); - if (FAILED(hr)) { - return hr; - } - - // Lowering the priority of texture reduces the amount of texture - // thrashing when the Xbox attempts to transfer textures to faster - // memory as it become more reluctant to be moved. - Microsoft::WRL::ComPtr d3d12_device1; - if (SUCCEEDED(d3d12_device_.As(&d3d12_device1)) && d3d12_device1) { - Microsoft::WRL::ComPtr d3d12_pageable; - if (SUCCEEDED(d3d12_resources_[i].As(&d3d12_pageable)) && - d3d12_pageable) { - D3D12_RESIDENCY_PRIORITY priority = D3D12_RESIDENCY_PRIORITY_LOW; - hr = d3d12_device1->SetResidencyPriority( - 1, d3d12_pageable.GetAddressOf(), &priority); - SB_DCHECK(SUCCEEDED(hr)); - if (FAILED(hr)) { - return hr; - } - } - } - - HANDLE interop_handle = 0; - hr = d3d12_device_->CreateSharedHandle(d3d12_resources_[i].Get(), 0, - GENERIC_ALL, NULL, &interop_handle); - SB_DCHECK(SUCCEEDED(hr)); - if (FAILED(hr)) { - return hr; - } - hr = d3d11_device_->OpenSharedResource1(interop_handle, - IID_PPV_ARGS(&d3d11_textures_[i])); - SB_DCHECK(SUCCEEDED(hr)); - if (FAILED(hr)) { - return hr; - } - CloseHandle(interop_handle); - } - return S_OK; -} - -GpuVideoDecoderBase::GpuVideoDecoderBase( - SbDecodeTargetGraphicsContextProvider* - decode_target_graphics_context_provider, - const VideoStreamInfo& video_stream_info, - bool is_hdr_video, - bool is_10x3_preferred, - const ComPtr& d3d12_device, - const ComPtr d3d12OutputPoolBufferHeap, - void* d3d12_queue) - : decode_target_context_runner_(decode_target_graphics_context_provider), - is_hdr_video_(is_hdr_video), - is_10x3_preferred_(is_10x3_preferred), - d3d12_device_(d3d12_device), - d3d12_queue_(d3d12_queue), - d3d12FrameBuffersHeap_(d3d12OutputPoolBufferHeap), - frame_buffers_condition_(frame_buffers_mutex_) { - SB_DCHECK(d3d12_device_); - SB_DCHECK(d3d12_queue_); - SB_DCHECK(d3d12FrameBuffersHeap_); - - egl_display_ = eglGetDisplay(EGL_DEFAULT_DISPLAY); - EGLint attribute_list[] = {EGL_SURFACE_TYPE, // this must be first - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - EGL_RED_SIZE, - 8, - EGL_GREEN_SIZE, - 8, - EGL_BLUE_SIZE, - 8, - EGL_ALPHA_SIZE, - 8, - EGL_BIND_TO_TEXTURE_RGBA, - EGL_TRUE, - EGL_RENDERABLE_TYPE, - EGL_OPENGL_ES2_BIT, - EGL_NONE}; - SB_DCHECK(egl_display_); - EGLint num_configs; - int result = eglChooseConfig(egl_display_, attribute_list, &egl_config_, 1, - &num_configs); - SB_DCHECK(result); - - ComPtr d3d11_device = - starboard::shared::uwp::GetDirectX11Device(egl_display_); - HRESULT hr = d3d11_device.As(&d3d11_device_); - SB_DCHECK(SUCCEEDED(hr)); - - if (is_hdr_video_) { - UpdateHdrMetadata(video_stream_info.color_metadata); - } - frame_width_ = video_stream_info.frame_width; - frame_height_ = video_stream_info.frame_height; -} - -GpuVideoDecoderBase::~GpuVideoDecoderBase() { - // Reset() should be already called before ~GpuVideoDecoderBase(). - SB_DCHECK(!decoder_thread_); - SB_DCHECK(pending_inputs_.empty()); - SB_DCHECK(written_inputs_.empty()); - SB_DCHECK(output_queue_.empty()); - SB_DCHECK(decoder_behavior_.load() == kDecodingStopped); - SB_DCHECK(GetGpuFrameBufferPool()->CheckIfAllBuffersAreReleased()); - // All presenting decode targets should be released. - SB_DCHECK(presenting_decode_targets_.empty()); - - if (ApplicationUwp::Get()->IsHdrSupported() && IsHdrAngleModeEnabled()) { - SetHdrAngleModeEnabled(false); - auto hdmi_display_info = HdmiDisplayInformation::GetForCurrentView(); - starboard::shared::uwp::WaitForComplete( - hdmi_display_info->SetDefaultDisplayModeAsync()); - } -} - -void GpuVideoDecoderBase::Initialize(const DecoderStatusCB& decoder_status_cb, - const ErrorCB& error_cb) { - SB_DCHECK(decoder_status_cb); - SB_DCHECK(!decoder_status_cb_); - SB_DCHECK(error_cb); - SB_DCHECK(!error_cb_); - decoder_status_cb_ = decoder_status_cb; - error_cb_ = error_cb; -} - -size_t GpuVideoDecoderBase::GetPrerollFrameCount() const { - // The underlying decoder has its own output queue. We notify the underlying - // decoder to preroll frames once we receive first needed frame. Then the - // underlying decoder will delay outputs until it has enough prerolled frames. - // When we receive the second output frame, the underlying decoder should - // already have enough prerolled frames in its own output queue. So, we always - // return 2 here. - return 2; -} - -size_t GpuVideoDecoderBase::GetMaxNumberOfCachedFrames() const { - return GetMaxNumberOfCachedFramesInternal() + kNumOutputFrameBuffers; -} - -void GpuVideoDecoderBase::WriteInputBuffers(const InputBuffers& input_buffers) { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(decoder_status_cb_); - SB_DCHECK(input_buffers.size() == 1); - SB_DCHECK(input_buffers[0]); - SB_DCHECK(decoder_behavior_.load() != kResettingDecoder); - SB_DCHECK(decoder_behavior_.load() != kEndingStream); - - if (error_occured_.load()) { - return; - } - - const auto& input_buffer = input_buffers[0]; - - if (!decoder_thread_) { - decoder_thread_.reset(new JobThread(kDecoderThreadName)); - decoder_thread_->job_queue()->Schedule( - std::bind(&GpuVideoDecoderBase::InitializeCodecIfNeededInternal, this)); - } - - bool needs_more_input = false; - { - ScopedLock pending_inputs_lock(pending_inputs_mutex_); - pending_inputs_.push_back(input_buffer); - - needs_more_input = pending_inputs_.size() < kMaxNumberOfPendingBuffers; - } - decoder_behavior_.store(kDecodingFrames); - decoder_thread_->job_queue()->Schedule( - std::bind(&GpuVideoDecoderBase::DecodeOneBuffer, this)); - if (needs_more_input) { - decoder_status_cb_(kNeedMoreInput, nullptr); - } -} - -void GpuVideoDecoderBase::WriteEndOfStream() { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(decoder_status_cb_); - SB_DCHECK(decoder_behavior_.load() != kResettingDecoder); - SB_DCHECK(decoder_behavior_.load() != kEndingStream); - - if (error_occured_.load()) { - return; - } - - if (decoder_thread_) { - SB_DCHECK(decoder_behavior_.load() == kDecodingFrames); - decoder_behavior_.store(kEndingStream); - decoder_thread_->job_queue()->Schedule( - std::bind(&GpuVideoDecoderBase::DecodeEndOfStream, this)); - return; - } - - SB_DCHECK(decoder_behavior_.load() == kDecodingStopped); - decoder_status_cb_(kBufferFull, VideoFrame::CreateEOSFrame()); -} - -void GpuVideoDecoderBase::Reset() { - SB_DCHECK(BelongsToCurrentThread()); - SB_DCHECK(decoder_status_cb_); - decoder_behavior_.store(kResettingDecoder); - if (decoder_thread_) { - // Release stored frames to free frame buffers. - decoder_status_cb_(kReleaseAllFrames, nullptr); - decoder_thread_->job_queue()->ScheduleAndWait( - std::bind(&GpuVideoDecoderBase::DrainDecoder, this)); - decoder_thread_.reset(); - } - pending_inputs_.clear(); - { - ScopedLock input_queue_lock(written_inputs_mutex_); - written_inputs_.clear(); - } - // Release all frames after decoder thread is destroyed. - decoder_status_cb_(kReleaseAllFrames, nullptr); - { - ScopedLock output_queue_lock(output_queue_mutex_); - output_queue_.clear(); - } - error_occured_.store(false); - decoder_behavior_.store(kDecodingStopped); - is_drain_decoder_called_ = false; -} - -SbDecodeTarget GpuVideoDecoderBase::GetCurrentDecodeTarget() { - scoped_refptr image = nullptr; - { - ScopedLock output_queue_lock(output_queue_mutex_); - if (!output_queue_.empty()) { - image = output_queue_.front(); - } - } - - if (!image && presenting_decode_targets_.empty()) { - return kSbDecodeTargetInvalid; - } - - if (presenting_decode_targets_.empty() || - (image && - image->timestamp() != presenting_decode_targets_.back()->timestamp())) { - // Create the new decode target and update hdr meta data. - if (is_hdr_video_) { - UpdateHdrMetadata(image->color_metadata()); - } - presenting_decode_targets_.push_back( - new GPUDecodeTargetPrivate(egl_display_, egl_config_, image)); - number_of_presenting_decode_targets_++; - } - - // Increment the refcount for the returned decode target. - presenting_decode_targets_.back()->AddRef(); - - // There's a data synchronization issue (b/180532476) between decoder and - // render pipelines. If we release the decode target immediately after it's - // released on render pipeline (the underllying resources may be reused by the - // libvpx/av1 decoder), there's a chance that the rendering frame gets - // overwritten. The root cause is still unclear and under investigating. So, - // as a workaround, we retain the decode target for longer time until it's no - // longer used by the renderer thread. - while (presenting_decode_targets_.size() > kNumberOfCachedPresentingImage && - presenting_decode_targets_.front()->refcount == 1) { - SbDecodeTargetRelease(presenting_decode_targets_.front()); - presenting_decode_targets_.pop_front(); - number_of_presenting_decode_targets_--; - } - return presenting_decode_targets_.back(); -} - -bool GpuVideoDecoderBase::BelongsToDecoderThread() const { - return decoder_thread_->job_queue()->BelongsToCurrentThread(); -} - -int GpuVideoDecoderBase::OnOutputRetrieved( - const scoped_refptr& image) { - SB_DCHECK(decoder_thread_); - SB_DCHECK(decoder_status_cb_); - SB_DCHECK(image); - - if (decoder_behavior_.load() == kResettingDecoder || error_occured_) { - return 0; - } - - int64_t timestamp = image->timestamp(); - { - ScopedLock input_queue_lock(written_inputs_mutex_); - const auto iter = FindByTimestamp(written_inputs_, timestamp); - // Reset might be called too early, cause clearing of written_inputs_ and - // absence of requested timestamp. - if (iter != written_inputs_.cend()) { - if (is_hdr_video_) { - image->AttachColorMetadata((*iter)->video_stream_info().color_metadata); - } - written_inputs_.erase(iter); - } - } - scoped_refptr frame(new VideoFrameImpl( - timestamp, std::bind(&GpuVideoDecoderBase::DeleteVideoFrame, this, - std::placeholders::_1))); - decoder_status_cb_( - decoder_behavior_.load() == kEndingStream ? kBufferFull : kNeedMoreInput, - frame); - - // The underlying decoder relies on the return value of OnOutputRetrieved() to - // determine stream preroll status. The underlying decoder will start - // prorolling at the first time it receives 1 from OnOutputRetrieved(). In - // other words, if OnOutputRetrieved() returns 1, the underlying decoder will - // delay next output until it has enough prerolled frames inside the - // underlying decoder. - if (!frame->HasOneRef()) { - ScopedLock output_queue_lock(output_queue_mutex_); - output_queue_.push_back(image); - if (is_waiting_frame_after_drain_) { - is_waiting_frame_after_drain_ = false; - return 1; - } - } - return 0; -} - -void GpuVideoDecoderBase::OnDecoderDrained() { - SB_DCHECK(decoder_thread_); - SB_DCHECK(decoder_status_cb_); - SB_DCHECK(decoder_behavior_.load() == kEndingStream || - decoder_behavior_.load() == kResettingDecoder); - - is_waiting_frame_after_drain_ = true; - - if (!BelongsToDecoderThread()) { - decoder_thread_->job_queue()->Schedule( - std::bind(&GpuVideoDecoderBase::OnDecoderDrained, this)); - return; - } - - if (decoder_behavior_.load() == kEndingStream) { - decoder_status_cb_(kBufferFull, VideoFrame::CreateEOSFrame()); - } - decoder_behavior_.store(kDecodingStopped); -} - -void GpuVideoDecoderBase::ClearCachedImages() { - SB_DCHECK(output_queue_.empty()); - // All cached images should be released. - decode_target_context_runner_.RunOnGlesContext( - std::bind(&GpuVideoDecoderBase::ClearPresentingDecodeTargets, this)); -} - -void GpuVideoDecoderBase::ReportError(const SbPlayerError error, - const std::string& error_message) { - SB_DCHECK(error_cb_); - if (!error_occured_.exchange(true)) { - SB_LOG(ERROR) << error_message << " (error code: " << error << " )"; - error_cb_(error, error_message); - } -} - -void GpuVideoDecoderBase::DecodeOneBuffer() { - SB_DCHECK(decoder_thread_); - SB_DCHECK(BelongsToDecoderThread()); - - if (decoder_behavior_.load() == kResettingDecoder || error_occured_) { - return; - } - - // Both decoders av1 & vp9 return decoded frames in separate thread, - // so there isn't danger of deadlock in DecodeOneBuffer() and there isn't - // necessity of IsCacheFull call - scoped_refptr input = 0; - bool needs_more_input = false; - { - ScopedLock pending_inputs_lock(pending_inputs_mutex_); - SB_DCHECK(!pending_inputs_.empty()); - input = pending_inputs_.front(); - pending_inputs_.pop_front(); - if (pending_inputs_.size() < kMaxNumberOfPendingBuffers) { - needs_more_input = true; - } - } - { - ScopedLock input_queue_lock(written_inputs_mutex_); - written_inputs_.push_back(input); - } - if (needs_more_input) { - decoder_status_cb_(kNeedMoreInput, nullptr); - } - DecodeInternal(input); -} - -void GpuVideoDecoderBase::DecodeEndOfStream() { - SB_DCHECK(decoder_thread_); - SB_DCHECK(BelongsToDecoderThread()); - SB_DCHECK(decoder_status_cb_); - - if (decoder_behavior_.load() == kResettingDecoder || error_occured_) { - return; - } - - { - ScopedLock pending_inputs_lock(pending_inputs_mutex_); - if (!pending_inputs_.empty()) { - decoder_thread_->job_queue()->Schedule( - std::bind(&GpuVideoDecoderBase::DecodeEndOfStream, this), 1000); - return; - } - } - DrainDecoder(); -} - -void GpuVideoDecoderBase::DrainDecoder() { - SB_DCHECK(BelongsToDecoderThread()); - // Use |is_drain_decoder_called_| to prevent calling DrainDecoderInternal() - // twice. Theoretically, if Reset() is called during DecodeEndOfStream() - // executing, DrainDecoderInternal() could be called twice, one from - // DecodeEndOfStream(), and one from Reset(). - if (!is_drain_decoder_called_) { - is_drain_decoder_called_ = true; - DrainDecoderInternal(); - // DrainDecoderInternal is sync command, after it finished, we can be sure - // that drain really completed. - OnDecoderDrained(); - } -} - -void GpuVideoDecoderBase::DeleteVideoFrame(const VideoFrame* video_frame) { - ScopedLock output_queue_lock(output_queue_mutex_); - RemoveByTimestamp(&output_queue_, video_frame->timestamp()); -} - -void GpuVideoDecoderBase::UpdateHdrMetadata( - const SbMediaColorMetadata& color_metadata) { - SB_DCHECK(is_hdr_video_); - if (!ApplicationUwp::Get()->IsHdrSupported()) { - ReportError(kSbPlayerErrorCapabilityChanged, - "HDR sink lost while HDR video playing."); - return; - } - if (!needs_hdr_metadata_update_) { - return; - } - needs_hdr_metadata_update_ = false; - if (!IsHdrAngleModeEnabled()) { - SetHdrAngleModeEnabled(true); - } - if (memcmp(&color_metadata, &last_presented_color_metadata_, - sizeof(color_metadata)) != 0) { - last_presented_color_metadata_ = color_metadata; - UpdateHdrColorMetadataToCurrentDisplay(color_metadata); - } -} - -void GpuVideoDecoderBase::ClearPresentingDecodeTargets() { - // Delete all unused decode targets. - while (!presenting_decode_targets_.empty() && - presenting_decode_targets_.front()->refcount == 1) { - SbDecodeTargetRelease(presenting_decode_targets_.front()); - presenting_decode_targets_.pop_front(); - } - // The remaining decode targets are still used by the render pipeline. Force - // to release the underlying image to release the codec resources and - // decrement the refcount. - for (auto it = presenting_decode_targets_.begin(); - it != presenting_decode_targets_.end(); ++it) { - (*it)->ReleaseImage(); - SbDecodeTargetRelease(*it); - } - presenting_decode_targets_.clear(); - number_of_presenting_decode_targets_ = 0; -} - -HRESULT GpuVideoDecoderBase::AllocateFrameBuffers(uint16_t width, - uint16_t height) { - HRESULT hr = S_OK; - DXGI_FORMAT dxgi_format = - is_hdr_video_ ? (is_10x3_preferred_ ? DXGI_FORMAT_R10G10B10A2_UNORM - : DXGI_FORMAT_R16_UNORM) - : DXGI_FORMAT_R8_UNORM; - return GetGpuFrameBufferPool()->AllocateFrameBuffers( - width, height, dxgi_format, d3d11_device_, d3d12_device_); -} - -void GpuVideoDecoderBase::ReleaseFrameBuffer(GpuFrameBuffer* frame_buffer) { - SB_DCHECK(frame_buffer); - ScopedLock lock(frame_buffers_mutex_); - frame_buffer->Release(); - SB_DCHECK(frame_buffer->HasOneRef()); - frame_buffers_condition_.Signal(); -} - -void GpuVideoDecoderBase::ClearFrameBuffersPool() { - GetGpuFrameBufferPool()->Clear(); -} - -GpuVideoDecoderBase::GpuFrameBuffer* -GpuVideoDecoderBase::GetAvailableFrameBuffer(uint16_t width, uint16_t height) { - if (decoder_behavior_.load() == kResettingDecoder) { - return nullptr; - } - - GpuFrameBuffer* frame_buffer = nullptr; - bool is_resetting = false; - while (!frame_buffer) { - ScopedLock lock(frame_buffers_mutex_); - frame_buffer = GetGpuFrameBufferPool()->GetFreeBuffer(); - // Wait until we get next free frame buffer. - if (!frame_buffer) { - if (is_resetting) { - // We should have enough free frame buffers during resetting. If that - // error happens it means that the frames are not released properly by - // either GpuVideoDecoderBase or VideoRenderer. - SB_NOTREACHED(); - ReportError(kSbPlayerErrorDecode, - "Timed out on waiting for available frame buffer."); - return nullptr; - } - is_resetting = decoder_behavior_.load() == kResettingDecoder; - frame_buffers_condition_.WaitTimed(50'000); // 50ms - continue; - } - } - - // Increment the refcount for |frame_buffer| so that its data buffer - // persists until ReleaseFrameBuffer is called. - frame_buffer->AddRef(); - return frame_buffer; -} -} // namespace shared -} // namespace xb1 -} // namespace starboard diff --git a/starboard/xb1/shared/gpu_base_video_decoder.h b/starboard/xb1/shared/gpu_base_video_decoder.h deleted file mode 100644 index 5ef5210ff80b..000000000000 --- a/starboard/xb1/shared/gpu_base_video_decoder.h +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright 2021 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SHARED_GPU_BASE_VIDEO_DECODER_H_ -#define STARBOARD_XB1_SHARED_GPU_BASE_VIDEO_DECODER_H_ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "starboard/common/mutex.h" -#include "starboard/common/ref_counted.h" -#include "starboard/shared/starboard/decode_target/decode_target_context_runner.h" -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/starboard/player/filter/video_decoder_internal.h" -#include "starboard/shared/starboard/player/input_buffer_internal.h" -#include "starboard/shared/starboard/player/job_thread.h" -#include "starboard/xb1/shared/video_frame_impl.h" - -namespace starboard { -namespace xb1 { -namespace shared { - -class GpuVideoDecoderBase - : public starboard::shared::starboard::player::filter::VideoDecoder, - private starboard::shared::starboard::player::JobQueue::JobOwner { - public: - static constexpr unsigned int kNumberOfPlanes = 3; - - typedef ::starboard::shared::starboard::decode_target:: - DecodeTargetContextRunner DecodeTargetContextRunner; - - ~GpuVideoDecoderBase() override; - - class GpuFrameBuffer : public RefCountedThreadSafe { - public: - GpuFrameBuffer(uint16_t width, - uint16_t height, - DXGI_FORMAT dxgi_format, - Microsoft::WRL::ComPtr d3d11_device, - Microsoft::WRL::ComPtr d3d12_device); - - HRESULT CreateTextures(); - - const Microsoft::WRL::ComPtr& resource(int index) const { - SB_DCHECK(index < kNumberOfPlanes); - SB_DCHECK(d3d12_resources_[index] != nullptr); - return d3d12_resources_[index]; - } - - const Microsoft::WRL::ComPtr& texture(int index) const { - SB_DCHECK(index < kNumberOfPlanes); - SB_DCHECK(d3d11_textures_[index] != nullptr); - return d3d11_textures_[index]; - } - - uint16_t width() const { return width_; } - uint16_t height() const { return height_; } - const Microsoft::WRL::ComPtr& device11() { - return d3d11_device_; - } - const Microsoft::WRL::ComPtr& device12() { - return d3d12_device_; - } - - private: - uint16_t width_ = 0; - uint16_t height_ = 0; - D3D12_RESOURCE_DESC texture_desc_ = {0}; - - Microsoft::WRL::ComPtr d3d12_resources_[kNumberOfPlanes]; - Microsoft::WRL::ComPtr d3d11_textures_[kNumberOfPlanes]; - - const Microsoft::WRL::ComPtr d3d11_device_; - const Microsoft::WRL::ComPtr d3d12_device_; - }; - void ReleaseFrameBuffer(GpuFrameBuffer* frame_buffer); - int GetWidth() { return frame_width_; } - int GetHeight() { return frame_height_; } - bool IsHdrVideo() { return is_hdr_video_; } - static void ClearFrameBuffersPool(); - - protected: - typedef ::starboard::shared::starboard::media::VideoStreamInfo - VideoStreamInfo; - - class DecodedImage : public RefCountedThreadSafe { - public: - virtual ~DecodedImage() { - if (release_cb_) { - release_cb_(); - } - } - - bool is_compacted() const { return is_compacted_; } - unsigned int width() const { return width_; } - unsigned int height() const { return height_; } - unsigned int bit_depth() const { return bit_depth_; } - int texture_corner_left(size_t index) const { - SB_DCHECK(index < kNumberOfPlanes); - return texture_corner_left_[index]; - } - int texture_corner_top(size_t index) const { - SB_DCHECK(index < kNumberOfPlanes); - return texture_corner_top_[index]; - } - Microsoft::WRL::ComPtr texture(size_t index) const { - SB_DCHECK(index < kNumberOfPlanes); - return textures_[index]; - } - int stride(size_t index) const { - SB_DCHECK(index < kNumberOfPlanes); - return strides_[index]; - } - int64_t timestamp() const { return timestamp_; } - const SbMediaColorMetadata& color_metadata() const { - return color_metadata_; - } - - void AttachColorMetadata(const SbMediaColorMetadata& color_metadata) { - color_metadata_ = color_metadata; - } - - protected: - explicit DecodedImage(const std::function& release_cb = nullptr) - : release_cb_(release_cb) {} - - unsigned int width_; - unsigned int height_; - unsigned int bit_depth_; - bool is_compacted_ = false; - int texture_corner_left_[kNumberOfPlanes]; - int texture_corner_top_[kNumberOfPlanes]; - Microsoft::WRL::ComPtr textures_[kNumberOfPlanes]; - int strides_[kNumberOfPlanes]; - int64_t timestamp_; // microseconds - SbMediaColorMetadata color_metadata_; - const std::function release_cb_; - }; - - enum RetrievingBehavior { - kDecodingStopped, - kDecodingFrames, - kResettingDecoder, - kEndingStream - }; - - GpuVideoDecoderBase( - SbDecodeTargetGraphicsContextProvider* - decode_target_graphics_context_provider, - const VideoStreamInfo& video_stream_info, - bool is_hdr_video, - bool is_10x3_preferred, - const Microsoft::WRL::ComPtr& d3d12_device, - const Microsoft::WRL::ComPtr d3d12OutputPoolBufferHeap, - void* d3d12_queue); - - // VideoDecoder methods - void Initialize(const DecoderStatusCB& decoder_status_cb, - const ErrorCB& error_cb) final; - size_t GetPrerollFrameCount() const final; - int64_t GetPrerollTimeout() const final { return kSbInt64Max; } - size_t GetMaxNumberOfCachedFrames() const override; - - void WriteInputBuffers(const InputBuffers& input_buffers) final; - void WriteEndOfStream() final; - void Reset() final; - SbDecodeTarget GetCurrentDecodeTarget() final; - - // Methods for inherited classes to implement. - virtual void InitializeCodecIfNeededInternal() = 0; - virtual void DecodeInternal( - const scoped_refptr& input_buffer) = 0; - virtual void DrainDecoderInternal() = 0; - virtual size_t GetMaxNumberOfCachedFramesInternal() const = 0; - - bool BelongsToDecoderThread() const; - void OnDecoderDrained(); - void ClearCachedImages(); - void ReportError(const SbPlayerError error, const std::string& error_message); - int OnOutputRetrieved(const scoped_refptr& image); - HRESULT AllocateFrameBuffers(uint16_t width, uint16_t height); - GpuVideoDecoderBase::GpuFrameBuffer* GetAvailableFrameBuffer(uint16_t width, - uint16_t height); - - const bool is_hdr_video_; - const bool is_10x3_preferred_; - int frame_width_; - int frame_height_; - std::atomic decoder_behavior_{kDecodingStopped}; - std::atomic_bool error_occured_ = {false}; - - // These are platform-specific objects required to create and use a codec. - Microsoft::WRL::ComPtr d3d11_device_; - Microsoft::WRL::ComPtr d3d12_device_; - Microsoft::WRL::ComPtr - d3d12FrameBuffersHeap_; // output buffers queue memory - void* d3d12_queue_ = nullptr; - - Mutex frame_buffers_mutex_; - ConditionVariable frame_buffers_condition_; - - private: - class GPUDecodeTargetPrivate; - - void DecodeOneBuffer(); - void DecodeEndOfStream(); - void DrainDecoder(); - void DeleteVideoFrame(const VideoFrame* video_frame); - void UpdateHdrMetadata(const SbMediaColorMetadata& color_metadata); - void ClearPresentingDecodeTargets(); - - // The following callbacks will be initialized in Initialize() and won't be - // changed during the life time of this class. - DecoderStatusCB decoder_status_cb_; - ErrorCB error_cb_; - - void* egl_config_ = nullptr; - void* egl_display_ = nullptr; - DecodeTargetContextRunner decode_target_context_runner_; - - std::unique_ptr - decoder_thread_; - - // |pending_inputs_| is shared between player main thread and decoder thread. - Mutex pending_inputs_mutex_; - std::deque> pending_inputs_; - // |written_inputs_| is shared between decoder thread and underlying decoder - // output thread. - Mutex written_inputs_mutex_; - std::vector> written_inputs_; - // |output_queue_| is shared between decoder thread and render thread. - Mutex output_queue_mutex_; - std::vector> output_queue_; - // |presenting_decode_targets_| is only accessed on render thread. - std::deque presenting_decode_targets_; - std::atomic_int number_of_presenting_decode_targets_ = {0}; - - SbMediaColorMetadata last_presented_color_metadata_ = {}; - - bool is_drain_decoder_called_ = false; - bool is_waiting_frame_after_drain_ = false; - - bool needs_hdr_metadata_update_ = true; -}; - -} // namespace shared -} // namespace xb1 -} // namespace starboard - -#endif // STARBOARD_XB1_SHARED_GPU_BASE_VIDEO_DECODER_H_ diff --git a/starboard/xb1/shared/internal_shims.h b/starboard/xb1/shared/internal_shims.h deleted file mode 100644 index 877ed8b57fbb..000000000000 --- a/starboard/xb1/shared/internal_shims.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SHARED_INTERNAL_SHIMS_H_ -#define STARBOARD_XB1_SHARED_INTERNAL_SHIMS_H_ - -#include -#include "starboard/atomic.h" -#include "starboard/system.h" - -namespace starboard { -namespace xb1 { -namespace shared { - -bool CanAcquire(); - -Windows::Foundation::IAsyncOperation ^ Acquire(); - -void Release(); - -Platform::String ^ GetCertScope(); - -bool GetSignature(Windows::Storage::Streams::IBuffer ^ message_buffer, - Windows::Storage::Streams::IBuffer ^ *signature); - -} // namespace shared -} // namespace xb1 -} // namespace starboard - -#endif // STARBOARD_XB1_SHARED_INTERNAL_SHIMS_H_ diff --git a/starboard/xb1/shared/internal_stubs.cc b/starboard/xb1/shared/internal_stubs.cc deleted file mode 100644 index b243b4bd3790..000000000000 --- a/starboard/xb1/shared/internal_stubs.cc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2022 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/xb1/shared/internal_shims.h" - -#include - -namespace starboard { -namespace xb1 { -namespace shared { - -bool CanAcquire() { - return false; -} - -// clang-format off -Windows::Foundation::IAsyncOperation ^ Acquire() { - return concurrency::create_async([] { return false; }); -} - -void Release() {} - -Platform::String ^ GetCertScope() { return ""; } - -bool GetSignature(Windows::Storage::Streams::IBuffer ^ message_buffer, - Windows::Storage::Streams::IBuffer ^ *signature) { - return false; -} -// clang-format on - -} // namespace shared -} // namespace xb1 -} // namespace starboard diff --git a/starboard/xb1/shared/playready_license.cc b/starboard/xb1/shared/playready_license.cc deleted file mode 100644 index 33444d437f5b..000000000000 --- a/starboard/xb1/shared/playready_license.cc +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include - -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/optional.h" -#include "starboard/memory.h" -#include "starboard/shared/win32/drm_system_playready.h" -#include "starboard/shared/win32/error_utils.h" -#include "starboard/shared/win32/wrm_header.h" - -namespace starboard { -namespace xb1 { -namespace shared { -namespace { - -using Microsoft::WRL::ComPtr; -using ::starboard::shared::win32::DrmSystemPlayready; -using ::starboard::shared::win32::WrmHeader; - -class PlayreadyLicense : public DrmSystemPlayready::License { - public: - PlayreadyLicense(const void* initialization_data, - int initialization_data_size); - ~PlayreadyLicense() override; - - GUID key_id() const override { return key_id_; } - bool usable() const override { return usable_; } - std::string license_challenge() const override { return license_challenge_; } - Microsoft::WRL::ComPtr decryptor() override { - return decryptor_; - } - - void UpdateLicense(const void* license, int license_size) override; - bool IsHDCPRequired() override; - - private: - bool CreateTrustedInputAndTrustedInputAuthority( - Microsoft::WRL::ComPtr content_header); - void GenerateChallenge(); - void UpdateLicenseInternal(); - - WrmHeader wrm_header_; - GUID key_id_; - Microsoft::WRL::ComPtr trusted_input_; - Microsoft::WRL::ComPtr trusted_input_authority_; - Microsoft::WRL::ComPtr decryptor_; - - Windows::Media::Protection::PlayReady::IPlayReadyServiceRequest ^ - service_request_; - std::string license_challenge_; - bool usable_; - optional hdcp_required_; - - // The following variables are not really instance variables. They are saved - // in the class to simplify the passing of data to functions run on newly - // created MTA threads. - Platform::Array ^ license_response_; -}; - -typedef void (PlayreadyLicense::*PlayreadyLicenseMemberFunction)(); - -struct ThreadParam { - PlayreadyLicenseMemberFunction function; - PlayreadyLicense* license_object; -}; - -DWORD WINAPI MTAThreadFunc(void* param) { - SB_DCHECK(param); - - CoInitializeEx(NULL, COINIT_MULTITHREADED); - ThreadParam* thread_param = static_cast(param); - ((*thread_param->license_object).*(thread_param->function))(); - CoUninitialize(); - - return 0; -} - -// Playready licensing functions are required to run in MTA. This function -// makes it easy to run a particular member function in MTA synchronously. -void RunFunctionOnMTA(PlayreadyLicenseMemberFunction function, - PlayreadyLicense* license_object) { - DWORD thread_id; - ThreadParam param = {function, license_object}; - // Use plain vanilla Windows thread to avoid any side effect. - HANDLE thread = CreateThread(NULL, 0, MTAThreadFunc, ¶m, 0, &thread_id); - WaitForSingleObject(thread, INFINITE); - CloseHandle(thread); -} - -PlayreadyLicense::PlayreadyLicense(const void* initialization_data, - int initialization_data_size) - : wrm_header_(initialization_data, initialization_data_size), - key_id_(WrmHeader::kInvalidKeyId), - service_request_(nullptr), - license_response_(nullptr), - usable_(false) { - SB_DCHECK(wrm_header_.is_valid()); - if (!wrm_header_.is_valid()) { - return; - } - if (CreateTrustedInputAndTrustedInputAuthority( - wrm_header_.content_header())) { - RunFunctionOnMTA(&PlayreadyLicense::GenerateChallenge, this); - key_id_ = wrm_header_.key_id(); - } -} - -PlayreadyLicense::~PlayreadyLicense() { - decryptor_.Reset(); - if (trusted_input_authority_) { - trusted_input_authority_->Reset(); - } -} - -bool PlayreadyLicense::CreateTrustedInputAndTrustedInputAuthority( - ComPtr content_header) { - SB_DCHECK(content_header); - - ComPtr inspectable; - ComPtr persist_stream; - - HRESULT hr = ::Windows::Foundation::ActivateInstance( - ::Microsoft::WRL::Wrappers::HStringReference( - L"Windows.Media.Protection.PlayReady." - L"PlayReadyWinRTTrustedInput") - .Get(), - &inspectable); - CheckResult(hr); - if (FAILED(hr)) { - return false; - } - - hr = inspectable.As(&persist_stream); - CheckResult(hr); - if (FAILED(hr)) { - return false; - } - - hr = persist_stream->Load(content_header.Get()); - CheckResult(hr); - if (FAILED(hr)) { - return false; - } - - hr = inspectable.As(&trusted_input_); - CheckResult(hr); - if (FAILED(hr)) { - return false; - } - - const int kDefaultStreamId = 0; - ComPtr unknown; - hr = trusted_input_->GetInputTrustAuthority(kDefaultStreamId, - IID_IMFInputTrustAuthority, - unknown.ReleaseAndGetAddressOf()); - CheckResult(hr); - if (FAILED(hr)) { - return false; - } - - hr = unknown.As(&trusted_input_authority_); - CheckResult(hr); - - hr = trusted_input_authority_->GetDecrypter(IID_IMFTransform, &decryptor_); - CheckResult(hr); - - return SUCCEEDED(hr); -} - -void PlayreadyLicense::GenerateChallenge() { - SB_DCHECK(trusted_input_); - SB_DCHECK(trusted_input_authority_); - SB_DCHECK(!service_request_); - SB_DCHECK(license_challenge_.empty()); - - using Windows::Media::Protection::PlayReady::IPlayReadyServiceRequest; - using Windows::Media::Protection::PlayReady::PlayReadyContentHeader; - using Windows::Media::Protection::PlayReady:: - PlayReadyLicenseAcquisitionServiceRequest; - using Windows::Media::Protection::PlayReady::PlayReadySoapMessage; - - ComPtr enabler_activate; - - HRESULT hr = trusted_input_authority_->RequestAccess( - PEACTION_PLAY, enabler_activate.GetAddressOf()); - - if (SUCCEEDED(hr)) { - // The license is usable but we still want to generate a challenge to - // ensure that the implementation conforms to the EME spec. - PlayReadyLicenseAcquisitionServiceRequest ^ fake_service_request = - ref new PlayReadyLicenseAcquisitionServiceRequest; - - std::vector copy_of_header(wrm_header_.wrm_header()); - PlayReadyContentHeader ^ content_header = - ref new PlayReadyContentHeader(ref new Platform::Array( - copy_of_header.data(), static_cast(copy_of_header.size()))); - fake_service_request->ContentHeader = content_header; - - PlayReadySoapMessage ^ soap_message = - fake_service_request->GenerateManualEnablingChallenge(); - - if (soap_message != nullptr) { - Platform::Array ^ challenge = - soap_message->GetMessageBody(); - - license_challenge_.assign(challenge->begin(), challenge->end()); - SB_DCHECK(!license_challenge_.empty()); - SB_LOG(INFO) << "Playready license is already usable, force challenge " - << "generating using license acquisition service request"; - } - - usable_ = true; - return; - } - - if (!enabler_activate) { - SB_NOTREACHED() << "enabler_activate is NULL but the license isn't usable."; - return; - } - - hr = enabler_activate->ActivateObject( - __uuidof(IPlayReadyServiceRequest ^), - reinterpret_cast(&service_request_)); - CheckResult(hr); - if (FAILED(hr)) { - return; - } - - PlayReadySoapMessage ^ soap_message = - service_request_->GenerateManualEnablingChallenge(); - - if (soap_message != nullptr) { - Platform::Array ^ challenge = soap_message->GetMessageBody(); - - license_challenge_.assign(challenge->begin(), challenge->end()); - SB_DCHECK(!license_challenge_.empty()); - } -} - -void PlayreadyLicense::UpdateLicense(const void* license, int license_size) { - if (!service_request_) { - SB_DCHECK(usable_); - return; - } - - SB_DCHECK(!license_response_); - - // Note that store the response in the object is not an ideal way to exchange - // data between the function and the MTA thread but it allows us to easily - // unify the RunFunctionOnMTA() interface. - unsigned char* license_in_unsigned_char = - static_cast(const_cast(license)); - license_response_ = ref new Platform::Array( - license_in_unsigned_char, license_size); - RunFunctionOnMTA(&PlayreadyLicense::UpdateLicenseInternal, this); - - if (!usable_) { - SB_LOG(INFO) - << "License is not usable, try to re-create the ITA and challenge"; - if (CreateTrustedInputAndTrustedInputAuthority( - wrm_header_.content_header())) { - RunFunctionOnMTA(&PlayreadyLicense::GenerateChallenge, this); - key_id_ = wrm_header_.key_id(); - } - SB_LOG_IF(INFO, usable_) << "License is usable after retry"; - } -} - -void PlayreadyLicense::UpdateLicenseInternal() { - Windows::Foundation::HResult hresult = - service_request_->ProcessManualEnablingResponse(license_response_); - SB_LOG_IF(ERROR, FAILED(hresult.Value)) - << "ProcessManualEnablingResponse() failed with 0x" << std::hex - << hresult.Value; - SB_DCHECK(SUCCEEDED(hresult.Value)); - - ComPtr enabler_activate; - HRESULT hr = trusted_input_authority_->RequestAccess( - PEACTION_PLAY, enabler_activate.GetAddressOf()); - SB_LOG_IF(ERROR, FAILED(hr)) - << "RequestAccess() failed after license update with 0x" << std::hex - << hr; - - // TODO: It is possible that the above license is invalid and the player will - // retry after error status is propagated. However, consider to generate a - // new license message directly using the |enabler_activate| above. - usable_ = SUCCEEDED(hr); - license_response_ = nullptr; - service_request_ = nullptr; -} - -bool PlayreadyLicense::IsHDCPRequired() { - if (hdcp_required_.has_engaged()) { - return hdcp_required_.value(); - } - - ComPtr output_policy; - HRESULT hr = trusted_input_authority_->GetPolicy( - PEACTION_PLAY, output_policy.GetAddressOf()); - CheckResult(hr); - - ComPtr required_schemas; - DWORD attributes = MFOUTPUTATTRIBUTE_DIGITAL | MFOUTPUTATTRIBUTE_VIDEO; - GUID protection_schema = MFPROTECTION_HDCP; - - hr = output_policy->GenerateRequiredSchemas(attributes, MFCONNECTOR_HDMI, - &protection_schema, 1, - required_schemas.GetAddressOf()); - CheckResult(hr); - - DWORD element_count; - hr = required_schemas->GetElementCount(&element_count); - CheckResult(hr); - hdcp_required_ = false; - if (element_count != 1) { - SB_DCHECK(element_count == 0); - return false; - } - - ComPtr unknown; - ComPtr output_schema; - hr = required_schemas->GetElement(0, unknown.GetAddressOf()); - CheckResult(hr); - hr = unknown.As(&output_schema); - CheckResult(hr); - GUID schema_id; - hr = output_schema->GetSchemaType(&schema_id); - CheckResult(hr); - SB_DCHECK(schema_id == MFPROTECTION_HDCP); - hdcp_required_ = true; - return true; -} - -} // namespace -} // namespace shared -} // namespace xb1 -} // namespace starboard - -namespace starboard { -namespace shared { -namespace win32 { - -scoped_refptr DrmSystemPlayready::License::Create( - const void* initialization_data, - int initialization_data_size) { - return new ::starboard::xb1::shared::PlayreadyLicense( - initialization_data, initialization_data_size); -} - -} // namespace win32 -} // namespace shared -} // namespace starboard diff --git a/starboard/xb1/shared/system_get_extensions.cc b/starboard/xb1/shared/system_get_extensions.cc deleted file mode 100644 index 009b8d78ff25..000000000000 --- a/starboard/xb1/shared/system_get_extensions.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include "starboard/common/string.h" -#include "starboard/extension/configuration.h" -#include "starboard/extension/graphics.h" -#include "starboard/extension/media_session.h" -#include "starboard/shared/uwp/xb1_media_session_client.h" -#include "starboard/shared/win32/graphics.h" -#include "starboard/xb1/shared/configuration.h" - -const void* SbSystemGetExtension(const char* name) { - if (strcmp(name, kCobaltExtensionGraphicsName) == 0) { - return starboard::shared::win32::GetGraphicsApi(); - } - if (strcmp(name, kCobaltExtensionConfigurationName) == 0) { - return starboard::xb1::shared::GetConfigurationApi(); - } - if (strcmp(name, kCobaltExtensionMediaSessionName) == 0) { - return starboard::shared::uwp::GetMediaSessionApi(); - } - return NULL; -} diff --git a/starboard/xb1/shared/system_get_path.cc b/starboard/xb1/shared/system_get_path.cc deleted file mode 100644 index feffb5ddb237..000000000000 --- a/starboard/xb1/shared/system_get_path.cc +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright 2017 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/system.h" - -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/common/string.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/win32/directory_internal.h" -#include "starboard/shared/win32/wchar_utils.h" - -using starboard::shared::win32::platformStringToString; -using starboard::shared::win32::wchar_tToUTF8; - -namespace { - -std::string GetBinaryName() { - const size_t kMaxModuleNameSize = kSbFileMaxName; - std::vector buffer(kMaxModuleNameSize); - DWORD result = GetModuleFileName(NULL, buffer.data(), buffer.size()); - std::string full_binary_path; - if (result == 0) { - full_binary_path = "unknown"; - } else { - full_binary_path = wchar_tToUTF8(buffer.data(), result).c_str(); - } - - std::string::size_type index = full_binary_path.rfind(kSbFileSepChar); - if (index == std::string::npos) { - return full_binary_path; - } - - return full_binary_path.substr(index + 1); -} - -// Places up to |path_size| - 1 characters of the path to the current -// executable in |out_path|, ensuring it is NULL-terminated. Returns success -// status. The result being greater than |path_size| - 1 characters is a -// failure. |out_path| may be written to in unsuccessful cases. -bool GetExecutablePath(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - auto folder = - Windows::ApplicationModel::Package::Current->InstalledLocation->Path; - if (folder->Length() >= static_cast(path_size) || - folder->Length() < 1) { - return false; - } - auto app_name = Windows::ApplicationModel::Package::Current->Id->Name; - if (app_name->Length() >= static_cast(path_size) || - app_name->Length() < 1) { - return false; - } - - std::string utf8_string = - (platformStringToString(folder) + "\\" + GetBinaryName()); - - if (utf8_string.length() > static_cast(path_size)) { - return false; - } - return starboard::strlcpy(out_path, utf8_string.c_str(), path_size); -} - -// Places up to |path_size| - 1 characters of the path to the directory -// containing the current executable in |out_path|, ensuring it is -// NULL-terminated. Returns success status. The result being greater than -// |path_size| - 1 characters is a failure. |out_path| may be written to in -// unsuccessful cases. -bool GetExecutableDirectory(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - auto folder = - Windows::ApplicationModel::Package::Current->InstalledLocation->Path; - if (folder->Length() >= static_cast(path_size) || - folder->Length() < 1) { - return false; - } - std::string utf8_string = - starboard::shared::win32::wchar_tToUTF8(folder->Data(), folder->Length()); - return starboard::strlcpy(out_path, utf8_string.c_str(), path_size); -} - -// Places up to |path_size| - 1 characters of the path to the content directory -// in |out_path|, ensuring it is NULL-terminated. Returns success -// status. The result being greater than |path_size| - 1 characters is a -// failure. |out_path| may be written to in unsuccessful cases. -bool GetContentPath(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - std::vector file_path(kSbFileMaxPath); - file_path[0] = '\0'; - if (!GetExecutableDirectory(file_path.data(), path_size)) { - return false; - } - if (starboard::strlcat(file_path.data(), "\\content\\data", kSbFileMaxPath) >= - path_size) { - return false; - } - return starboard::strlcpy(out_path, file_path.data(), path_size); -} - -// Places up to |path_size| - 1 characters of the path to the temporary -// directory in |out_path|, ensuring it is NULL-terminated, and creates the -// directory if necessary. Returns success status. The result being greater than -// |path_size| - 1 characters is a failure. |out_path| may be written to in -// unsuccessful cases. -bool CreateAndGetTempPath(char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - std::vector w_file_path(kSbFileMaxPath); - w_file_path[0] = L'\0'; - - DWORD characters_written = GetTempPathW(kSbFileMaxPath, w_file_path.data()); - if (static_cast(characters_written) >= (path_size + 1) || - characters_written < 1) { - return false; - } - // Remove the last slash, to match other Starboard implementations. - w_file_path[characters_written - 1] = L'\0'; - - std::string utf8_string = wchar_tToUTF8(w_file_path.data()); - - if (starboard::strlcpy(out_path, utf8_string.c_str(), path_size) >= - path_size) { - return false; - } - mkdir(out_path, 0700); - - size_t length = strlen(out_path); - if (length < 1 || length > path_size) { - return false; - } - return true; -} - -// Places up to |path_size| - 1 characters of the path to the directory in -// |out_path|, ensuring it is NULL-terminated, and creates the directory if -// necessary. Returns success status. The result being greater than |path_size| -// - 1 characters is a failure. |out_path| may be written to in unsuccessful -// cases. -bool CreateAndGetApplicationDataFolder(Windows::Storage::StorageFolder ^ folder, - char* out_path, - int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - - // The caller expects that the output string will only be written if when - // true is returned. Therefore we have to buffer the string in case there is a - // false condition, such as small memory input size to hold the output - // parameter. - std::vector out_path_copy(kSbFileMaxPath, 0); - std::string local_path = platformStringToString(folder->Path); - if (starboard::strlcpy(out_path_copy.data(), local_path.c_str(), - out_path_copy.size()) >= out_path_copy.size()) { - return false; - } - - size_t length = strlen(out_path_copy.data()); - if (length < 1 || length > out_path_copy.size()) { - return false; - } - - // The copy is verified, transfer it over to out_path. - size_t len = std::min(path_size, kSbFileMaxPath); - starboard::strlcpy(out_path, out_path_copy.data(), len); - - return true; -} -} // namespace - -// Note: This function is only minimally implemented to allow tests to run. -bool SbSystemGetPath(SbSystemPathId path_id, char* out_path, int path_size) { - if (!out_path || (path_size <= 0)) { - return false; - } - - switch (path_id) { - case kSbSystemPathContentDirectory: - return GetContentPath(out_path, path_size); - case kSbSystemPathDebugOutputDirectory: - // We send debug output to the cache directory instead of the temp - // directory, because the temp directory is removed as soon as the - // application exits, while also a file can not be opened or copied while - // it is still open for writing. Using the cache directory makes it - // possible to retrieve the file contents after the application exits. - return SbSystemGetPath(kSbSystemPathCacheDirectory, out_path, path_size); - case kSbSystemPathExecutableFile: - return GetExecutablePath(out_path, path_size); - case kSbSystemPathStorageDirectory: - return CreateAndGetApplicationDataFolder( - Windows::Storage::ApplicationData::Current->LocalFolder, out_path, - path_size); - case kSbSystemPathTempDirectory: - // Note: This temp directory is removed as soon as the application exits. - return CreateAndGetTempPath(out_path, path_size); - case kSbSystemPathCacheDirectory: - return CreateAndGetApplicationDataFolder( - Windows::Storage::ApplicationData::Current->LocalCacheFolder, - out_path, path_size); - // TODO: implement all the other cases. - default: - SB_NOTIMPLEMENTED(); - return false; - } -} diff --git a/starboard/xb1/shared/video_decoder_uwp.cc b/starboard/xb1/shared/video_decoder_uwp.cc deleted file mode 100644 index 721303912f79..000000000000 --- a/starboard/xb1/shared/video_decoder_uwp.cc +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "starboard/xb1/shared/video_decoder_uwp.h" - -#include -#include - -#include "starboard/shared/uwp/async_utils.h" -#include "starboard/shared/uwp/decoder_utils.h" -#include "starboard/shared/uwp/xb1_get_type.h" -#include "third_party/angle/include/angle_hdr.h" - -using ::starboard::shared::uwp::ApplicationUwp; -using ::starboard::shared::uwp::UpdateHdrColorMetadataToCurrentDisplay; -using ::starboard::shared::uwp::WaitForComplete; -using Windows::Graphics::Display::Core::HdmiDisplayInformation; - -namespace starboard { -namespace xb1 { -namespace shared { - -const int kXboxeOneXMaxOutputSamples = 5; - -// Set of devices that shouldn't use hardware AV1 decoding. -// TODO (b/259431190): Series devices had performance issues with hardware AV1 -// decoders during our initial rollout. Disable hardware AV1 decoding in favor -// of the software decoder to test if performance improves. -const std::set hw_av1_disabled_devices = { - starboard::shared::uwp::kXboxSeriesS, starboard::shared::uwp::kXboxSeriesX}; - -VideoDecoderUwp::~VideoDecoderUwp() { - if (IsHdrSupported() && IsHdrAngleModeEnabled()) { - SetHdrAngleModeEnabled(false); - auto hdmi_display_info = HdmiDisplayInformation::GetForCurrentView(); - WaitForComplete(hdmi_display_info->SetDefaultDisplayModeAsync()); - } -} - -// static -bool VideoDecoderUwp::IsHardwareVp9DecoderSupported() { - return ::starboard::shared::win32::VideoDecoder:: - IsHardwareVp9DecoderSupported(ApplicationUwp::Get()->IsHdrSupported()); -} - -// static -bool VideoDecoderUwp::IsHardwareAv1DecoderSupported() { - // XboxOneS/Base has av1 mft decoder, but sw av1 decoder - // is more preferred for Xbox OneS/Base because of performance. - // So to avoid using av1 mft in these devices we test if - // the current XBOX has vp9 hw decoder. If it doesn't it means - // that there is XboxOneS/Base and we don't use mft av1 decoder. - return hw_av1_disabled_devices.find(starboard::shared::uwp::GetXboxType()) == - hw_av1_disabled_devices.end() && - VideoDecoderUwp::IsHardwareVp9DecoderSupported() && - ::starboard::shared::win32::IsHardwareAv1DecoderSupported(); -} - -bool VideoDecoderUwp::TryUpdateOutputForHdrVideo( - const VideoStreamInfo& stream_info) { - bool is_hdr_video = - stream_info.color_metadata.primaries == kSbMediaPrimaryIdBt2020; - if (is_hdr_video && !ApplicationUwp::Get()->IsHdrSupported()) { - return false; - } - if (is_first_input_) { - is_first_input_ = false; - const SbMediaColorMetadata& color_metadata = stream_info.color_metadata; - if (is_hdr_video && IsHdrSupported()) { - if (!IsHdrAngleModeEnabled()) { - SetHdrAngleModeEnabled(true); - } - if (memcmp(&color_metadata, ¤t_color_metadata_, - sizeof(color_metadata)) != 0) { - current_color_metadata_ = color_metadata; - UpdateHdrColorMetadataToCurrentDisplay(color_metadata); - } - } - } - return true; -} - -size_t VideoDecoderUwp::GetPrerollFrameCount() const { - return GetMaxNumberOfCachedFrames(); -} - -size_t VideoDecoderUwp::GetMaxNumberOfCachedFrames() const { - return (::starboard::shared::uwp::kXboxOneX == - ::starboard::shared::uwp::GetXboxType()) - ? kXboxeOneXMaxOutputSamples - : ::starboard::shared::win32::VideoDecoder::GetPrerollFrameCount(); -} - -} // namespace shared -} // namespace xb1 -} // namespace starboard diff --git a/starboard/xb1/shared/video_decoder_uwp.h b/starboard/xb1/shared/video_decoder_uwp.h deleted file mode 100644 index a7eb58243c1b..000000000000 --- a/starboard/xb1/shared/video_decoder_uwp.h +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2020 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SHARED_VIDEO_DECODER_UWP_H_ -#define STARBOARD_XB1_SHARED_VIDEO_DECODER_UWP_H_ - -#include "starboard/shared/starboard/media/media_util.h" -#include "starboard/shared/uwp/application_uwp.h" -#include "starboard/shared/uwp/xb1_get_type.h" -#include "starboard/shared/win32/video_decoder.h" - -namespace starboard { -namespace xb1 { -namespace shared { - -class VideoDecoderUwp : public ::starboard::shared::win32::VideoDecoder { - public: - typedef ::starboard::shared::starboard::media::VideoStreamInfo - VideoStreamInfo; - - VideoDecoderUwp::VideoDecoderUwp( - SbMediaVideoCodec video_codec, - SbPlayerOutputMode output_mode, - SbDecodeTargetGraphicsContextProvider* graphics_context_provider, - SbDrmSystem drm_system) - : VideoDecoder( - video_codec, - output_mode, - graphics_context_provider, - drm_system, - ::starboard::shared::uwp::ApplicationUwp::Get()->IsHdrSupported()) { - } - - ~VideoDecoderUwp() override; - - static bool IsHardwareVp9DecoderSupported(); - static bool IsHardwareAv1DecoderSupported(); - - bool TryUpdateOutputForHdrVideo(const VideoStreamInfo& stream_info) override; - - size_t GetPrerollFrameCount() const override; - size_t GetMaxNumberOfCachedFrames() const override; - - private: - SbMediaColorMetadata current_color_metadata_ = {}; - bool is_first_input_ = true; -}; - -} // namespace shared -} // namespace xb1 -} // namespace starboard - -#endif // STARBOARD_XB1_SHARED_VIDEO_DECODER_UWP_H_ diff --git a/starboard/xb1/shared/video_frame_impl.h b/starboard/xb1/shared/video_frame_impl.h deleted file mode 100644 index 6440d28654fa..000000000000 --- a/starboard/xb1/shared/video_frame_impl.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2021 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SHARED_VIDEO_FRAME_IMPL_H_ -#define STARBOARD_XB1_SHARED_VIDEO_FRAME_IMPL_H_ - -#include - -#include "starboard/common/log.h" -#include "starboard/shared/starboard/player/filter/video_frame_internal.h" - -namespace starboard { -namespace xb1 { -namespace shared { - -class VideoFrameImpl - : public ::starboard::shared::starboard::player::filter::VideoFrame { - public: - typedef ::starboard::shared::starboard::player::filter::VideoFrame VideoFrame; - - VideoFrameImpl(int64_t timestamp, std::function release_cb) - : VideoFrame(timestamp), release_cb_(release_cb) { - SB_DCHECK(release_cb_); - } - ~VideoFrameImpl() override { release_cb_(this); } - - private: - std::function release_cb_; -}; - -} // namespace shared -} // namespace xb1 -} // namespace starboard - -#endif // STARBOARD_XB1_SHARED_VIDEO_FRAME_IMPL_H_ diff --git a/starboard/xb1/system_properties.h b/starboard/xb1/system_properties.h deleted file mode 100644 index a040bf494baa..000000000000 --- a/starboard/xb1/system_properties.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2023 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef STARBOARD_XB1_SYSTEM_PROPERTIES_H_ -#define STARBOARD_XB1_SYSTEM_PROPERTIES_H_ - -#include "starboard/configuration.h" - -extern const char kCertificationScope[]; -extern const char kBase64EncodedCertificationSecret[]; - -#endif // STARBOARD_XB1_SYSTEM_PROPERTIES_H_ diff --git a/starboard/xb1/templates/ApplicationSection.xml.template b/starboard/xb1/templates/ApplicationSection.xml.template deleted file mode 100644 index cc1b094a3ea3..000000000000 --- a/starboard/xb1/templates/ApplicationSection.xml.template +++ /dev/null @@ -1,50 +0,0 @@ -{% if __IS_COBALT__ %} -{# Currently, DIAL expects an application ID of "App" to work. #} - #} - EntryPoint="{{__PRODUCT_SETTINGS__['ENTRYPOINT']}}"> - - - - - {% if __IS_COBALT__ %} - {% if 'EXTRA_EXTENSIONS' in __PRODUCT_SETTINGS__ %} - {% for line in __PRODUCT_SETTINGS__['EXTRA_EXTENSIONS'] %} - {{line}} - {% endfor %} - {% endif %} - {% endif %} - {% if __CONFIG__ != 'gold' %} - {% if __IS_COBALT__ %} - - - - .txt - - - - {% endif %} - - {# Truncating because MS set the max length of Protocol Name to 39 characters. #} - - - {% endif %} - - diff --git a/starboard/xb1/templates/AppxManifest.xml.template b/starboard/xb1/templates/AppxManifest.xml.template deleted file mode 100644 index 5a2d9f2eab7b..000000000000 --- a/starboard/xb1/templates/AppxManifest.xml.template +++ /dev/null @@ -1,229 +0,0 @@ - - - - {% if 'PHONE_IDENTITY' in __PRODUCT_SETTINGS__ %} - {{ __PRODUCT_SETTINGS__['PHONE_IDENTITY']|indent(2) }} - {% endif %} - - {{__PRODUCT_SETTINGS__['DISPLAY_NAME']}} - {{__PRODUCT_SETTINGS__['PUBLISHER_DISPLAY_NAME']}} - Assets\Square44x44Logo.scale-100.png - single - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ __APPLICATIONS__|indent(4) }} - - - {% if __CONFIG__ != 'gold' %} - - - {% endif %} - - - - {% if 'EXTRA_CAPABILITIES' in __PRODUCT_SETTINGS__ %} - {% for line in __PRODUCT_SETTINGS__['EXTRA_CAPABILITIES'] %} - {{line}} - {% endfor %} - {% endif %} - - - - - diff --git a/starboard/xb1/test_filters.py b/starboard/xb1/test_filters.py deleted file mode 100644 index f8cd6a14b393..000000000000 --- a/starboard/xb1/test_filters.py +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright 2022 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Starboard Xbox One Platform Test Filters.""" - -from starboard.shared.win32 import test_filters as shared_test_filters -from starboard.tools.testing import test_filter - -# pylint: disable=line-too-long -_FILTERED_TESTS = { - 'nplb': [ - # Enable multiplayer tests once it's supported. - 'MultiplePlayerTests/*', - 'SbPlayerWriteSampleTests/SbPlayerWriteSampleTest.SecondaryPlayerTest/*', - # TODO: b/333412348 - 'SbMediaCanPlayMimeAndKeySystem.MinimumSupport', - # TODO: b/333416764 - 'SbSocketAddressTypes/SbSocketBindTest.RainyDayBadInterface/type_ipv6_filter_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDayDestination/type_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDaySourceForDestination/type_ipv6', - 'SbSocketAddressTypes/SbSocketGetInterfaceAddressTest.SunnyDaySourceNotLoopback/type_ipv6', - 'SbSocketAddressTypes/SbSocketResolveTest.SunnyDayFiltered/filter_ipv6_type_ipv6', - ], - 'player_filter_tests': [ - 'PlayerComponentsTests/PlayerComponentsTest.*', - 'VideoDecoderTests/VideoDecoderTest.HoldFramesUntilFull/*', - ('VideoDecoderTests/VideoDecoderTest' - '.MultipleValidInputsAfterInvalidKeyFrame/*'), - 'VideoDecoderTests/VideoDecoderTest.MultipleResets/sintel_399_av1_dmp_DecodeToTexture', - # AC3/EAC3 use a passthrough audio decoder that is incompatible with - # AdaptiveAudioDecoderTests. - # b/281740486. - 'AdaptiveAudioDecoderTests/AdaptiveAudioDecoderTest.MultipleInput/*c3*', - 'AdaptiveAudioDecoderTests/AdaptiveAudioDecoderTest.SingleInput/*c3*', - 'AudioDecoderTests/AudioDecoderTest.SingleInputHEAAC/*c3*', - # TODO: b/333412348 - 'VideoDecoderTests/VideoDecoderTest.SingleInput/beneath_the_canopy_248_vp9_dmp_DecodeToTexture', - 'VideoDecoderTests/VideoDecoderTest.ResetBeforeInput/beneath_the_canopy_248_vp9_dmp_DecodeToTexture', - 'VideoDecoderTests/VideoDecoderTest.MultipleResets/beneath_the_canopy_248_vp9_dmp_DecodeToTexture', - ], - 'trace_processor_minimal_smoke_tests': ['StorageMinimalSmokeTest/*',], -} - - -def CreateTestFilters(): - return Xb1TestFilters() - - -class Xb1TestFilters(shared_test_filters.TestFilters): - """Starboard Xbox One Platform Test Filters.""" - - def GetTestFilters(self): - """Gets all tests to be excluded from a unit test run. - - Returns: - A list of initialized TestFilter objects. - """ - filters = super().GetTestFilters() - for target, tests in _FILTERED_TESTS.items(): - filters.extend(test_filter.TestFilter(target, test) for test in tests) - return filters diff --git a/starboard/xb1/toolchain/BUILD.gn b/starboard/xb1/toolchain/BUILD.gn deleted file mode 100644 index a94a59217bda..000000000000 --- a/starboard/xb1/toolchain/BUILD.gn +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2021 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/config/win/visual_studio_version.gni") -import("//build/toolchain/win/msvc_toolchain.gni") -import("//starboard/build/toolchain/win/variables.gni") - -msvc_toolchain("target") { - cl = "$tool_base_path/cl.exe" - lib = "$tool_base_path/lib.exe" - link = "$tool_base_path/link.exe" - asm = "$tool_base_path/ml64.exe" - sys_lib_flags = "/LIBPATH:\"$msvc_path/lib/x64/store\" " + common_libpaths - - toolchain_args = { - is_clang = false - current_os = "win" - current_cpu = "x64" - } -} diff --git a/starboard/xb1/tools/__init__.py b/starboard/xb1/tools/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/starboard/xb1/tools/application_section_generator.py b/starboard/xb1/tools/application_section_generator.py deleted file mode 100644 index 82276a52884f..000000000000 --- a/starboard/xb1/tools/application_section_generator.py +++ /dev/null @@ -1,126 +0,0 @@ -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Generated the application section for xb1.""" - -from __future__ import print_function - -import argparse -import os -import sys - -try: - from internal.starboard.xb1 import appx_product_settings - PRODUCT_SETTINGS = appx_product_settings.PRODUCT_SETTINGS -except ImportError: - from starboard.xb1 import appx_product_settings - PRODUCT_SETTINGS = appx_product_settings.PRODUCT_SETTINGS - -THIRD_PARTY_PATH = os.path.normpath( - os.path.join( - os.path.realpath(__file__), os.pardir, os.pardir, os.pardir, os.pardir, - 'third_party')) -sys.path.append(THIRD_PARTY_PATH) -from jinja2 import Template # pylint: disable=wrong-import-position - -#pylint: disable=anomalous-backslash-in-string - - -def _GenerateApplicationSection(application_name, application_template_filename, - config, product): - """Uses templates to generate an application section for 1 application in the - appx xml file. - - Example input: 'cobalt', 'application.template', 'extension.template' - Example output: - - - - - - - - - - - - """ - if product not in PRODUCT_SETTINGS: - raise ValueError( - f'Unknown product value: {product}. ' - 'Product settings must be defined in appx_product_settings.py') - - with open(application_template_filename, 'r', encoding='utf-8') as fileobj: - application_template = Template( - fileobj.read(), trim_blocks=True, lstrip_blocks=True) - - return application_template.render( - __APPLICATION_NAME__=application_name, - __CONFIG__=config, - __IS_COBALT__=application_name == 'cobalt', - __PRODUCT_SETTINGS__=PRODUCT_SETTINGS[product]) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - '--application_name', - dest='application_name', - required=True, - help='application name', - type=str) - parser.add_argument( - '--application_template', - dest='application_template', - required=True, - help='path to the application section template', - type=str) - parser.add_argument( - '--product', - dest='product', - required=False, - default='cobalt', - help='Name of product being built (e.g. cobalt/youtube/youtubetv)', - type=str) - parser.add_argument( - '--output', - dest='output', - required=True, - help='output filename', - type=str) - parser.add_argument( - '--config', - dest='config', - required=True, - help='config (e.g. debug/devel/qa/gold)', - type=str) - if len(sys.argv) == 1: - parser.print_help() - sys.exit(1) - options = parser.parse_args(sys.argv[1:]) - with open(options.output, 'w', encoding='utf-8') as outfile: - outfile.write( - _GenerateApplicationSection(options.application_name, - options.application_template, - options.config, options.product)) - - -if __name__ == '__main__': - main() diff --git a/starboard/xb1/tools/appx.py b/starboard/xb1/tools/appx.py deleted file mode 100644 index 9a75101d302d..000000000000 --- a/starboard/xb1/tools/appx.py +++ /dev/null @@ -1,200 +0,0 @@ -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -"""Deploy script for UWP. Generates AppxManifest.xml""" - -from __future__ import print_function - -import argparse -import datetime -import glob -import os -import sys -import time -import msvcrt - -try: - from internal.starboard.xb1 import appx_product_settings - PRODUCT_SETTINGS = appx_product_settings.PRODUCT_SETTINGS -except ImportError: - from starboard.xb1 import appx_product_settings - PRODUCT_SETTINGS = appx_product_settings.PRODUCT_SETTINGS - -# Sometimes we must up the appx version number even if 24 hours have not -# elapsed. -# This number must not exceed floor((999 - 537) / 10) = 46, or the resulting -# version would exceed the XML schema limit of 999 for that version field. -_MANUAL_APPX_VERSION_OFFSET = 0 - -THIRD_PARTY_PATH = os.path.normpath( - os.path.join( - os.path.realpath(__file__), os.pardir, os.pardir, os.pardir, os.pardir, - 'third_party')) -sys.path.append(THIRD_PARTY_PATH) - -from jinja2 import Template # pylint: disable=wrong-import-position - -_APPLICATION_SECTION_REGEX = 'ApplicationSection.*.xml' - - -def _GenerateAppxManifestContent(appx_template, template_directory, config, - product): - """ Generates content of the AppxManifest. - - This function finds all files that match |_APPLICATION_SECTION_REGEX| in - |template_directory|, and uses them to create the body that will replace - __APPLICATIONS__. It then generates the content for AppxManifest by - parsing |appx_template|. - - Args: - appx_template: Path to AppxManifest.xml.template - template_directory: Path to directory containing files with Application - section of AppxManifest - config: Current config being built. E.g. gold, devel, or qa Reads - AppxManifest.xml.template from |appx_template|, and then in the generates - the new content by replacing __APPLICATIONS__. - """ - if product not in PRODUCT_SETTINGS: - raise ValueError( - f'Unknown product value: {product}. ' - 'Product settings must be defined in appx_product_settings.py') - application_sections = [] - search_path = os.path.join(template_directory, _APPLICATION_SECTION_REGEX) - for filename in glob.glob(search_path): - with open(filename, encoding='utf-8') as f: - application_sections.append(f.read()) - application_section = '\n'.join(application_sections) - - today = datetime.datetime.utcnow().isocalendar() - # The appx version number is formatted as a dotted-quad like - # "a.b.c.d" where a!=0, d==0, and the other elements must be 0-999 - # In order to generate a distinct one every day, we set 'b' to - # the year since 2017 and 'c' to ((week_number*10) + (day_of_week) + - # config_build_offset). The reference for Identity can be found here: - # https://docs.microsoft.com/en-us/uwp/schemas/appxpackage/uapmanifestschema/element-identity - # Note that MS Partner Center mandates the revision number must be 0. - config_build_offsets = {'debug': 0, 'devel': 1, 'qa': 2, 'gold': 3} - if config not in config_build_offsets: - raise ValueError(f'Unknown config value: {config}') - config_build_offset = config_build_offsets[config] - build_number = ((today[1] * 10) + today[2] + - (_MANUAL_APPX_VERSION_OFFSET * 10) + config_build_offset) - major_version = today[0] - 2017 - appx_version = f'1.{major_version}.{build_number}.0' - - with open(appx_template, encoding='utf-8') as source: - manifest_template = Template( - source.read(), trim_blocks=True, lstrip_blocks=True) - return manifest_template.render( - __APPX_VERSION__=appx_version, - __CONFIG__=config, - __APPLICATIONS__=application_section, - __PRODUCT_SETTINGS__=PRODUCT_SETTINGS[product]) - - -def _WriteAppxManifest(out_filename, appx_template, template_directory, config, - product): - """ Generate AppxManifest and write the contents to |out_filename|. - - Args: - out_filename: Name of the destination AppxManifest file. - appx_template: Path to AppxManifest.xml.template - template_directory: Path to directory containing files with Application - section of AppxManifest - config: Current |config| being built, e.g. gold, debug, etc - """ - num_bytes_to_lock = 1 - - with open(out_filename, 'w', encoding='utf-8') as dest: - # Sometimes, we're building tens of targets, and the retry logic - # in msvcrt.locking is not enough. Thus, additional waits - # are added, with backoffs to help each task finish. - - # Wait longer between retries. These times are in seconds. - for retry_time in [3, 5, 10, 20]: - try: - # According to the documentation, this will retry the lock up to 10 - # times, and wait 1 second between each retry. If this fails, an - # IOError exception is raised. Source: - # https://docs.python.org/2/library/msvcrt.html - msvcrt.locking(dest.fileno(), msvcrt.LK_LOCK, num_bytes_to_lock) - break - except IOError: - print( - f'Unable to lock {out_filename}. Retrying in {retry_time} seconds.') - time.sleep(retry_time) - else: - # Try one last time, this time without a try/catch block, - # so that the exception can propagate. - msvcrt.locking(dest.fileno(), msvcrt.LK_LOCK, num_bytes_to_lock) - - try: - # Note that both the manifest generation, and writing - # the content are done under a lock. - manifest_content = _GenerateAppxManifestContent(appx_template, - template_directory, - config, product) - dest.write(manifest_content) - finally: - # Writing to the appx manifest moves the current file position. - # Therefore, seek to position 0, as that is the locked position. - dest.seek(0) - msvcrt.locking(dest.fileno(), msvcrt.LK_UNLCK, num_bytes_to_lock) - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - '--manifest_out', - dest='manifest_out', - required=True, - help='output manifest filename', - type=str) - parser.add_argument( - '--config', - dest='config', - required=True, - help='config (e.g. debug/devel/qa/gold)', - type=str) - parser.add_argument( - '--appx_template', - dest='appx_template', - required=True, - help='Path to AppxManifest.xml.template', - type=str) - parser.add_argument( - '--template_directory', - dest='template_directory', - required=True, - help='Path to directory containing files with Application section of ' - 'AppxManifest', - type=str) - parser.add_argument( - '--product', - dest='product', - required=False, - default='cobalt', - help='Name of product being built (e.g. cobalt/youtube/youtubetv)', - type=str) - if len(sys.argv) == 1: - parser.print_help() - sys.exit(1) - options = parser.parse_args(sys.argv[1:]) - _WriteAppxManifest(options.manifest_out, options.appx_template, - options.template_directory, options.config, - options.product) - - -if __name__ == '__main__': - main() diff --git a/starboard/xb1/tools/list_apps_in_uwp_package.ps1 b/starboard/xb1/tools/list_apps_in_uwp_package.ps1 deleted file mode 100644 index f09ce5adde53..000000000000 --- a/starboard/xb1/tools/list_apps_in_uwp_package.ps1 +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -$PackageName = $args[0] - -Write-Verbose "Getting AppX package information for $PackageName" -$Apps = Get-AppxPackage -Name "*$PackageName*" -foreach ($Package in $Apps) { - [xml]$AppXManifest = $Package | Get-AppxPackageManifest - $Applications = ($AppXManifest.Package.Applications) - - foreach ($a in $Applications.Application) { - foreach ($e in $a.Extensions.Extension) { - if ($e.Category -eq 'windows.protocol') { - Write-Output ("^:" + $Package.Name + ":" + $a.id + ":" + $a.Executable + ":" + $e.Protocol.Name) - } - } - } -} diff --git a/starboard/xb1/tools/list_running_processes.ps1 b/starboard/xb1/tools/list_running_processes.ps1 deleted file mode 100644 index 861af3258947..000000000000 --- a/starboard/xb1/tools/list_running_processes.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -foreach ($p in Get-Process) { - Write-Output ("" + $p.Id + ":" + $p.ProcessName) -} diff --git a/starboard/xb1/tools/list_uwp_packages.ps1 b/starboard/xb1/tools/list_uwp_packages.ps1 deleted file mode 100644 index 845e0202d5b2..000000000000 --- a/starboard/xb1/tools/list_uwp_packages.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -(get-appxpackage) diff --git a/starboard/xb1/tools/packager.py b/starboard/xb1/tools/packager.py deleted file mode 100644 index a5bcf6038f96..000000000000 --- a/starboard/xb1/tools/packager.py +++ /dev/null @@ -1,321 +0,0 @@ -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Generate a xb1 package. - - Generates a xb1 package from the loose files. - Called by package_application.py -""" - -import argparse -import logging -import os -import platform -import shutil -import subprocess -import sys -from xml.etree import ElementTree as ET -import zipfile - -from starboard.tools import package - -_INTERNAL_CERT_PATH = os.path.join( - os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, - os.pardir, 'internal', 'starboard', 'xb1', 'cert', 'youtube.pfx') -_EXTERNAL_CERT_PATH = os.path.join( - os.path.dirname(os.path.realpath(__file__)), os.pardir, os.pardir, - os.pardir, 'starboard', 'xb1', 'cert', 'cobalt.pfx') -_APPX_MANIFEST_XML_NAMESPACE = \ - 'http://schemas.microsoft.com/appx/manifest/foundation/windows10' -_NAMESPACE_DICT = {'appx': _APPX_MANIFEST_XML_NAMESPACE} -_PUBLISHER_XPATH = './appx:Identity[@Publisher]' -_PRODUCT_APPX_NAME = { - 'cobalt': 'cobalt', - 'youtube': 'cobalt', - 'mainappbeta': 'mainappbeta', - 'youtubetv': 'youtubetv' -} -_PRODUCT_CERT_PATH = { - 'cobalt': _EXTERNAL_CERT_PATH, - 'youtube': _INTERNAL_CERT_PATH, - 'mainappbeta': _INTERNAL_CERT_PATH, - 'youtubetv': _INTERNAL_CERT_PATH, -} -_DEFAULT_SDK_BIN_DIR = 'C:\\Program Files (x86)\\Windows Kits\\10\\bin' -_DEFAULT_WIN_SDK_VERSION = '10.0.22621.0' -_BACKUP_WIN_SDK_VERSION = '10.0.22000.0' -_SOURCE_SPLASH_SCREEN_SUB_PATH = os.path.join('internal', 'cobalt', 'browser', - 'splash_screen') -# The splash screen file referenced in starboard/xb1/shared/configuration.cc -# must be in appx/content/data/web/ to be found at runtime. -_DESTINATION__SPLASH_SCREEN_SUB_PATH = os.path.join('appx', 'content', 'data', - 'web', 'splash_screen') -_SPLASH_SCREEN_FILE = { - 'cobalt': '', - 'youtube': 'youtube_splash_screen.html', - 'youtubetv': 'ytv_splash_screen.html', - 'mainappbeta': 'youtube_splash_screen.html', -} - - -def _SelectBestPath(os_var_name: str, path: str) -> str: - if os_var_name in os.environ: - return os.environ[os_var_name] - if os.path.exists(path): - return path - new_path = path.replace('Program Files (x86)', 'mappedProgramFiles') - if os.path.exists(new_path): - return new_path - return path - - -def _GetSourceSplashScreenDir(): - # Relative to this file, the path is - # "../../../internal/cobalt/browser/splash_screen". - src_dir = os.path.join( - os.path.dirname(__file__), os.pardir, os.pardir, os.pardir) - return os.path.join(src_dir, _SOURCE_SPLASH_SCREEN_SUB_PATH) - - -def GetWinToolsPath() -> str: - windows_sdk_bin_dir = _SelectBestPath('WindowsSdkBinPath', - _DEFAULT_SDK_BIN_DIR) - - # This check can be removed once it's confirmed our builders are using the new - # version of the win sdk. - path = os.path.join(windows_sdk_bin_dir, _DEFAULT_WIN_SDK_VERSION, 'x64') - if os.path.exists(path): - return path - return os.path.join(windows_sdk_bin_dir, _BACKUP_WIN_SDK_VERSION, 'x64') - - -class Package(package.PackageBase): - """A class representing an installable UWP Appx package.""" - - @classmethod - def AddArguments(cls, arg_parser): - """Add xb1-specific command-line arguments to the ArgumentParser.""" - super(Package, cls).AddArguments(arg_parser) - arg_parser.add_argument( - '-p', - '--publisher', - dest='publisher', - default=None, - help='Publisher Identity in Package.') - - @classmethod - def ExtractArguments(cls, options): - kwargs = super(Package, cls).ExtractArguments(options) - kwargs['publisher'] = options.publisher - kwargs['product'] = options.product - return kwargs - - def _GetDestinationSplashScreenDir(self): - return os.path.join(self.source_dir, _DESTINATION__SPLASH_SCREEN_SUB_PATH) - - def _CleanSplashScreenDir(self): - splash_screen_dir = self._GetDestinationSplashScreenDir() - - if not os.path.exists(splash_screen_dir): - return - - shutil.rmtree(splash_screen_dir) - - def _CopySplashScreen(self): - splash_screen_dir = self._GetDestinationSplashScreenDir() - # Create the splash screen directory if necessary. - if not os.path.exists(splash_screen_dir): - try: - os.makedirs(splash_screen_dir) - except OSError as e: - raise RuntimeError(f'Failed to create {splash_screen_dir}: {e}') from e - # Copy the correct splash screen for the current product into content. - splash_screen_file = _SPLASH_SCREEN_FILE[self.product] - src_splash_screen_dir = _GetSourceSplashScreenDir() - src_splash_screen_file = os.path.join(src_splash_screen_dir, - splash_screen_file) - if not os.path.exists(src_splash_screen_file): - logging.error('Failed to find splash screen file in source : %s', - src_splash_screen_file) - return - shutil.copy(src_splash_screen_file, splash_screen_dir) - - def _CopyAppxData(self): - appx_data_output_dir = os.path.join(self.appx_folder_location, 'content', - 'data') - source_dir = os.path.join(self.source_dir, 'appx', 'content', 'data') - if not os.path.exists(source_dir): - logging.error('Failed to find source content in: %s', source_dir) - return - shutil.copytree(source_dir, appx_data_output_dir) - - @classmethod - def SupportedPlatforms(cls): - if platform.system() == 'Windows': - return ['xb1'] - else: - return [] - - def __init__(self, publisher, product, **kwargs): - self.windows_sdk_host_tools = GetWinToolsPath() - self.publisher = publisher - self.product = product - super().__init__(**kwargs) - - if not os.path.exists(self.source_dir): - raise RuntimeError( - f'Package source directory {self.source_dir} not found.') - - logging.debug('Building package') - if self.publisher: - self._UpdateAppxManifestPublisher(publisher) - - # For YouTubeTV and MainAppBeta move the appx data content to the correct - # appx directory. - if (self.product in ['youtubetv', 'mainappbeta']): - self._CopyAppxData() - - # Remove any previous splash screen from content. - self._CleanSplashScreenDir() - # Copy the correct splash screen into content. - self._CopySplashScreen() - - self.package = self._BuildPackage() - if not os.path.exists(self.package): - raise RuntimeError(f'Package file {self.package} does not exist.') - - appxsym_out_file = self.appxsym_location - with zipfile.ZipFile(appxsym_out_file, 'w', zipfile.ZIP_DEFLATED) as z: - if os.path.isfile(os.path.join(self.source_dir, 'cobalt.exe.pdb')): - z.write(os.path.join(self.source_dir, 'cobalt.exe.pdb')) - - with zipfile.ZipFile(self.appxupload_location, 'w', - zipfile.ZIP_DEFLATED) as z: - z.write(appxsym_out_file) - z.write(self.appx_location) - - logging.info('Finished.') - - def _UpdateAppxManifestPublisher(self, publisher): - logging.info('Updating Appx with publisher [%s]', publisher) - tree = ET.parse(self.appxmanifest_location) - for element in tree.findall(_PUBLISHER_XPATH, _NAMESPACE_DICT): - assert 'Publisher' in element.attrib - element.attrib['Publisher'] = publisher - tree.write(self.appxmanifest_location) - - def Install(self, targets=None): - # TODO: implement - pass - - @property - def appx_folder_location(self): - product_locations = { - 'cobalt': 'appx', - 'youtube': 'appx', - 'mainappbeta': 'mainappbeta-appx', - 'youtubetv': 'youtubetv-appx' - } - return os.path.join(self.source_dir, product_locations[self.product]) - - @property - def appx_location(self): - return os.path.join(self.output_dir, - _PRODUCT_APPX_NAME[self.product] + '.appx') - - @property - def appxsym_location(self): - return os.path.join(self.output_dir, - _PRODUCT_APPX_NAME[self.product] + '.appxsym') - - @property - def appxupload_location(self): - return os.path.join(self.output_dir, - _PRODUCT_APPX_NAME[self.product] + '.appxupload') - - @property - def appxmanifest_location(self): - return os.path.join(self.appx_folder_location, 'AppxManifest.xml') - - def _BuildPackage(self): - """Build the package for XB1. - - Raises: - RuntimeError: if packaging or verification (if requested) fails. - Returns: - path to package location. - """ - - logging.info('Creating the package at: %s', self.appx_location) - - tools_path = self.windows_sdk_host_tools - - makeappx_args = [ - os.path.join(tools_path, 'makeappx.exe'), 'pack', '/l', '/o', '/d', - self.appx_folder_location, '/p', self.appx_location - ] - logging.info('Running %s', ' '.join(makeappx_args)) - subprocess.check_call(makeappx_args) - - cert_path = _PRODUCT_CERT_PATH[self.product] - - try: - signtool_args = [ - os.path.join(tools_path, 'signtool.exe'), 'sign', '/fd', 'SHA256', - '/a', '/f', cert_path, '/v', '/debug', self.appx_location - ] - logging.info('Running %s', ' '.join(signtool_args)) - subprocess.check_call(signtool_args) - except subprocess.CalledProcessError as sub_err: - if '0x80070070' in str(sub_err): - print('\n\n*** ERROR CAUSED BY LOW DISK SPACE!! ***\n\n') - raise # Rethrow original error with original stack trace. - - return self.appx_location - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument( - '-s', - '--source', - required=True, - help='Source directory from which to create a package.') - parser.add_argument( - '-o', - '--output', - default=os.path.join( - os.path.dirname(os.path.realpath(__file__)), 'package'), - help='Output directory to place the packaged app. Defaults to ./package/') - parser.add_argument( - '-p', - '--product', - default='cobalt', - help=( - 'Product name. This must be one of [cobalt, youtube, youtubetv,' - 'mainappbeta]. Any builds that are not internal to YouTube should use' - 'cobalt.')) - args, _ = parser.parse_known_args() - - if not os.path.exists(args.output): - os.makedirs(args.output) - - Package( - publisher=None, - product=args.product, - source_dir=args.source, - output_dir=args.output) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/starboard/xb1/tools/register_uwp_package.ps1 b/starboard/xb1/tools/register_uwp_package.ps1 deleted file mode 100644 index da5d797eb12e..000000000000 --- a/starboard/xb1/tools/register_uwp_package.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -$AppxManifestPath = $args[0] -add-appxpackage -register "$AppxManifestPath" -ForceApplicationShutdown diff --git a/starboard/xb1/tools/remove_uwp_package.ps1 b/starboard/xb1/tools/remove_uwp_package.ps1 deleted file mode 100644 index 1b90b5f5c7f1..000000000000 --- a/starboard/xb1/tools/remove_uwp_package.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -$PackageName = $args[0] -get-appxpackage "$PackageName" | remove-appxpackage diff --git a/starboard/xb1/tools/stop_process_by_id.ps1 b/starboard/xb1/tools/stop_process_by_id.ps1 deleted file mode 100644 index 2ae614dca91c..000000000000 --- a/starboard/xb1/tools/stop_process_by_id.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -$ProcessId = $args[0] -Stop-Process -Id "$ProcessId" diff --git a/starboard/xb1/tools/uwp_api.py b/starboard/xb1/tools/uwp_api.py deleted file mode 100644 index 345c224f8ac4..000000000000 --- a/starboard/xb1/tools/uwp_api.py +++ /dev/null @@ -1,443 +0,0 @@ -#!/usr/bin/python -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""UWP API.""" - -from __future__ import print_function - -from glob import glob -import os -import pprint -from six.moves import input -import subprocess -import sys - - -_PS_SCRIPT_LIST_APPS_IN_PACKAGE = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'list_apps_in_uwp_package.ps1')) - -_PS_SCRIPT_LIST_RUNNING_PROCESSES = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'list_running_processes.ps1')) - -_PS_SCRIPT_REMOVE_UWP_PACKAGE = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'remove_uwp_package.ps1')) - -_PS_SCRIPT_REGISTER_UWP_PACKAGE = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'register_uwp_package.ps1')) - -_PS_SCRIPT_LIST_UWP_PACKAGES = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'list_uwp_packages.ps1')) - -_PS_SCRIPT_STOP_PROCESS_BY_ID = \ - os.path.realpath(os.path.join( - os.path.dirname(__file__), 'stop_process_by_id.ps1')) - - -def ExecutePowershellScript(script_file, args_str=''): - try: - cmd = 'powershell ' + os.path.abspath(script_file) - if args_str: - cmd += ' ' + args_str - out = subprocess.check_output(cmd, shell=True, universal_newlines=True) - except Exception as e: - raise e - return out - - -#----------- Command Generation -def GetPackageDir(package_full_name): - """ Queries the os to get the directory for the given package name. """ - return os.path.join( - os.path.expandvars('%LocalAppData%'), 'Packages', package_full_name) - - -def GetPackageAppMap(package_filter='', app_name_filter=''): - """Returns a map of {full_package_name: { AppName0: { ... - - }, ...}} |package_filter| is an optional parameter, only packages - containing the package_filter name will be returned. - - |app_name_filter| is an optional parameter, only app names, aliases or ids - containing app_name_filter will be returned. - """ - result = ExecutePowershellScript(_PS_SCRIPT_LIST_APPS_IN_PACKAGE, - package_filter) - package_map = {} - for line in result.split('\n'): - try: - if not line: - continue - vals = line.split(':') - if len(vals) != 5: - continue - - # Note that valid lines start with '^' so that errors may be filtered out. - if vals[0] != '^': - continue - (unused_anchor, package_name, id_, executable_name, alias_name) = vals - - if len(package_filter) > 0: - if not package_filter in package_name: - continue - - if len(app_name_filter) > 0: - app_found = (app_name_filter in id_) or \ - (app_name_filter in executable_name) or \ - (app_name_filter in alias_name) - - if not app_found: - continue - - app_map = package_map.setdefault(package_name, {}) - props = app_map.setdefault(id_, {}) - props.setdefault('exe', executable_name) - props.setdefault('aliases', []).append(alias_name) - except Exception as e: # pylint: disable=broad-except - print(str(e) + ' for line "' + line + '"') - return package_map - - -def GetRunningProcessMap(exe_name_filter=''): - """Returns a dictionary mapping of int(process_id) -> str(exe_name). - - Note that many process id's may have the same exe_name! - """ - lines = ExecutePowershellScript(_PS_SCRIPT_LIST_RUNNING_PROCESSES) - - if exe_name_filter is None: - exe_name_filter = '' - exe_name_filter = exe_name_filter.lower() - exe_name_filter = RemoveSuffix(exe_name_filter, '.exe') - - process_map = {} - for line in lines.split('\n'): - try: - if not line: - continue - (pid, name) = line.split(':') - name = name.lower() - if exe_name_filter and name != exe_name_filter: - continue - process_map[int(pid)] = name - except Exception as e: # pylint: disable=broad-except - print(str(e) + ' for line "' + line + '"') - return process_map - - -def RemoveSuffix(name, suffix_str): - if name is None: - return name - if not name.lower().endswith(suffix_str): - return name - return name[0:-len(suffix_str)] - - -############################################################# -# UwpApi acts wraps Windows10 shell commands in a friendly api. -class UwpApi: - """UWP API class.""" - - def __init__(self, logger): - self.logger = logger - #self.cached_installed_apps = {} - - def GetAllInstalledPackageNames(self): - infos = self.GetInstalledPackageInfos() - names = [] - for props in infos.values(): - try: - names.append(props['Name']) - except KeyError as ke: - print(ke) - continue - return names - - # Resolves to the best possible package name, given the partial_package_name. - def ResolveFullPackageName(self, partial_package_name): - package_map = GetPackageAppMap(partial_package_name) - best_package_match = None - for package_name in package_map: - if not best_package_match: - best_package_match = package_name - else: - diff_curr = abs(len(package_name) - len(partial_package_name)) - diff_prev = abs(len(best_package_match) - len(partial_package_name)) - if diff_curr < diff_prev: - # Smallest possible match allowed. - best_package_match = package_name - return best_package_match - - def GetRunningProcesses(self, exe_filter_name=None): - return GetRunningProcessMap(exe_filter_name) - - def GetProcessIds(self, exe_name): - exe_name = exe_name.lower() - exe_name = RemoveSuffix(exe_name, '.exe') - proc_map = GetRunningProcessMap(exe_name) - out_ids = [] - for id_, name in proc_map.items(): - if name == exe_name: - out_ids.append(id_) - return out_ids - - def IsExeRunning(self, exe_name): - ids = self.GetProcessIds(exe_name) - return len(ids) > 0 - - def ResolveExeNameToAliases(self, partial_package_name, exe_name): - packages = GetPackageAppMap(partial_package_name) - - for apps_dict in packages.values(): - for props in apps_dict.values(): - try: - if exe_name == props.get('exe', ''): - aliases = props.get('aliases', []) - return aliases - except KeyError: - pass - return None - - def GetAppsInPackage(self, package_name): - package_app_map = GetPackageAppMap(package_name) - output = [] - for apps_dict in package_app_map.values(): - for app_name in apps_dict: # key is app name - output.append(app_name) - return output - - def GetAppsExesInPackage(self, package_name): - package_app_map = GetPackageAppMap(package_name) - output = [] - for apps_dict in package_app_map.values(): - for app_dict in apps_dict.values(): # key is app name - try: - output.append(app_dict['exe']) - except KeyError: - pass - return output - - def GetAppAliasesInPackage(self, package_name): - package_app_map = GetPackageAppMap(package_name) - output = [] - for apps_dict in package_app_map.values(): - for app_name in apps_dict: # key is app name - try: - aliases = apps_dict[app_name]['aliases'] - output.extend(aliases) - except Exception: # pylint: disable=broad-except - pass - return output - - def IsAppInstalled(self, package_name, id_): - return id_ in self.GetAppsInPackage(package_name) - - def GetPackageInfo(self, package_name): - infos = self.GetInstalledPackageInfos() - for key, val in infos.items(): - if package_name in key: - return val - return None - - def GetInstalledPackageInfos(self): - """Finds all the app packages and returns all their info. - - Doesn't include the installed app names.""" - - def GetKeyVal(line): - try: - key, val = line.split(':', 1) - key = key.strip() - val = val.strip() - except ValueError: - return '', '' - return key, val - - output = ExecutePowershellScript(_PS_SCRIPT_LIST_UWP_PACKAGES) - infos = [] - current = {} - - for line in output.splitlines(): - key, val = GetKeyVal(line) - if key == 'Name': - if len(current) > 0: - infos.append(current) - current = {} - if key and val: - current[key] = val - infos.append(current) - - output = {} - for info in infos: - output[info['PackageFullName']] = info - return output - - # Will throw subprocess.CalledProcessError if any folders/files are - # locked. - def RemovePackage(self, package_name): - package_name = '*' + package_name.replace('_', '*') + '*' - ExecutePowershellScript(_PS_SCRIPT_REMOVE_UWP_PACKAGE, package_name) - - def InstallPackage(self, package_path): - if not package_path: - raise IOError('Could not find starboard directory.') - full_path = os.path.join(package_path, 'AppxManifest.xml') - ExecutePowershellScript(_PS_SCRIPT_REGISTER_UWP_PACKAGE, full_path) - - def StartAppByAliasName(self, app_alias_name, args): - cmd = 'start ' + app_alias_name + ':' + ';'.join(args) - self.Log('\nExecute command:\n ' + cmd + '\n') - subprocess.Popen(cmd, shell=True) # pylint: disable=consider-using-with - self.Log(' ...Process started\n') - - def KillAppByExeName(self, exe_name): - for id_ in self.GetProcessIds(exe_name): - self.KillAppByProcessId(id_) - - def KillAppByProcessId(self, proc_id): - ExecutePowershellScript(_PS_SCRIPT_STOP_PROCESS_BY_ID, str(proc_id)) - - # Private section - # Sends to the test framework output file. - def Log(self, s): - if self.logger: - self.logger.write(str(s)) - self.logger.flush() - else: - print(str(s), end='') - - def LogLn(self, s): - self.Log(str(s) + '\n') - - -############################################################# -def InteractiveCommandLineMode(): - api = UwpApi(logger=None) # Prints to stdout - - def PrintInstalledExecutables(): - package_name = input('Which package? ') - package_map = GetPackageAppMap(package_name) - - pprint.pprint(package_map) - - def PrintInstalledPackages(): - v = input('Just names (y) or full package infos (n)?') - if 'y' in v or 'Y' in v: - package_names = api.GetAllInstalledPackageNames() - print('Installed Packages:') - for name in sorted(package_names, key=lambda s: s.lower()): - print(' ' + name) - return - else: - infos = api.GetInstalledPackageInfos() - for key in sorted(infos, key=lambda s: s.lower()): - print(key + ':') - pprint.pprint(infos[key]) - print('') - - def PrintInspectPackage(): - package_name = input('Which package? ') - info = api.GetPackageInfo(package_name) - pprint.pprint(info) - - def PrintFilesInPackage(): - package_name = input('Which package? ') - info = api.GetPackageInfo(package_name) - if not info: - print('ERROR could not find package name ' + package_name) - pprint.pprint(glob(os.path.join(info['InstallLocation'], '*'))) - - def InstallPackage(): - appx_dir = input('Path to appx directory: ') - try: - api.InstallPackage(appx_dir) - except Exception: # pylint: disable=broad-except - print('Failed to install ' + appx_dir + ', maybe uninstall first?') - - def UninstallPackage(): - package_name = input('Which package: ') - api.RemovePackage(package_name) - - def KillRunningProgramByNameOrId(): - answer = input('By (i)d or by (n)ame: ') - if 'i' in answer: - id_ = input('process id: ') - api.KillAppByProcessId(id_) - elif 'n' in answer: - app_name = input('Exe name: ') - api.KillAppByExeName(app_name) - else: - print('Unexpected response: ' + answer) - - def PrintRunningProcesses(): - filter_name = None - if 'y' in input('filter by name (y/n)?: '): - filter_name = input('exe name: ') - running_procs = api.GetRunningProcesses(filter_name) - - if len(running_procs) < 1: - print('No running processes found.') - else: - print('Found processes:') - for key in sorted(running_procs): - print(f' {key}: {running_procs[key]}') - - while True: - print('What would you like to do?') - print(' [0] Show all installed packages.') - print(' [1] See all installed executables in an installed package') - print(' [2] Inspect a package by name') - print(' [3] List directories and files in the package') - print(' [4] Install package') - print(' [5] Uninstall package') - print(' [6] Run from alias') - print(' [7] Kill process by exe name or id') - print(' [8] Show all running processes') - print(' [q] Quit') - val = input('> ') - - if val in ('', 'q'): - print('quitting.') - sys.exit(0) - elif '0' == val: - PrintInstalledPackages() - elif '1' == val: - PrintInstalledExecutables() - elif '2' == val: - PrintInspectPackage() - elif '3' == val: - PrintFilesInPackage() - elif '4' == val: - InstallPackage() - elif '5' == val: - UninstallPackage() - elif '6' == val: - alias_name = input('Which app alias: ') - args = input('Args: ') - api.StartAppByAliasName(alias_name, args) - elif '7' == val: - KillRunningProgramByNameOrId() - elif '8' == val: - PrintRunningProcesses() - else: - print('Unexpected answer: ' + val) - input('press the return key to continue....') - - -if __name__ == '__main__': - InteractiveCommandLineMode() diff --git a/starboard/xb1/tools/uwp_launcher.py b/starboard/xb1/tools/uwp_launcher.py deleted file mode 100644 index cff291897757..000000000000 --- a/starboard/xb1/tools/uwp_launcher.py +++ /dev/null @@ -1,273 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2018 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""UWP implementation of Starboard launcher abstraction.""" - -from __future__ import print_function - -import fnmatch -import os -import subprocess -import sys -import time - -from starboard.shared.win32 import mini_dump_printer -from starboard.tools import abstract_launcher -from starboard.xb1.tools import uwp_api - -APPX_NAME = 'YouTube' -PACKAGE_NAME = 'GoogleInc.YouTube' -PACKAGE_FULL_NAME = PACKAGE_NAME + '_yfg5n0ztvskxp' - - -#----------- Global Functions -def GlobalVars(): - return GlobalVars.__dict__ - - -# First call returns True, otherwise return false. -def FirstRun(): - v = GlobalVars() - if 'first_run' in v: - return False - v['first_run'] = False - return True - - -# Repeatedly tests to see if a file path exists. Returns True -# on success, or else False after timeout time with no success -# has elapsed. -def WaitForFileToAppear(file_path, timeout): - start_time = time.process_time() - while True: - if os.path.exists(file_path): - return True - if (time.process_time() - start_time) > timeout: - return False - time.sleep(.01) - - -def FindAppxDirectoryOrRaise(target_dir): - appx_paths = [target_dir, os.path.join(target_dir, 'appx')] - - final_path = None - for p in appx_paths: - if os.path.exists(os.path.join(p, 'AppxManifest.xml')): - final_path = p - break - - if not final_path or not os.path.exists(final_path): - msg = ('Could not find AppxManifest in paths ' + str(appx_paths) + '.' + - '\nPlease run again with --out_directory ') - raise IOError(msg) - return final_path - - -# Input: "--url=https://www.youtube.com/tv?v=1FmJdQiKy_w,--install=True" -# Output: {'url': 'https://www.youtube.com/tv?v=1FmJdQiKy_w', 'install': 'True'} -def CommandArgsToDict(s): - if not s: - return {} - - array = s.split(',') - out = {} - for v in array: - elems = v.split('=', 1) - if len(elems) < 1: - continue - key = elems[0] - - if key.startswith('--'): - key = key[2:] - val = None - if len(elems) > 1: - val = elems[1] - out[key] = val - return out - - -# Returns full names. -def GlobFiles(dir_path, file_pattern): - if not os.path.exists(dir_path): - return [] - files = [ - os.path.join(dir_path, f) - for f in os.listdir(dir_path) - if fnmatch.fnmatch(f, file_pattern) - ] - return files - - -########################################################################### -class Launcher(abstract_launcher.AbstractLauncher): - """Run an application on UWP target.""" - - def __init__(self, platform, target_name, config, device_id, **kwargs): - super().__init__(platform, target_name, config, device_id, **kwargs) - - self.UwpApi = uwp_api.UwpApi(None) # pylint: disable=invalid-name - self.package_dir = uwp_api.GetPackageDir(PACKAGE_FULL_NAME) - local_cache_path = os.path.join(self.package_dir, 'LocalCache') - self.executable = self.GetTargetPath() - self.kill_called = False - - self.stdout_file_name = target_name + '_stdout.txt' - self.stdout_file_path = os.path.join(local_cache_path, - self.stdout_file_name) - self.uwp_app_exe_name = self.target_name + '.exe' - self.uwp_app_exe_path = self.GetTargetPath() + '.exe' - - self.uwp_dump_file_pattern = '*' + self.uwp_app_exe_name + '*.dmp' - - self.uwp_app_dmp_path = os.path.join(os.environ['LOCALAPPDATA'], - 'CrashDumps') - - # Clear out dump files from a previous run. - self.DeleteFiles(self.uwp_app_dmp_path, self.uwp_dump_file_pattern) - - self.args = ['--xb1_log_file=' + self.stdout_file_name] - - # Merge target params into the user_params. - user_params = kwargs.get('target_params', '') - if user_params and len(user_params) > 0: - user_params_dict = CommandArgsToDict(','.join(user_params)) - for key, val in user_params_dict.items(): - if val: - self.args.append('--' + str(key) + '=' + str(val)) - else: - self.args.append('--' + str(key)) - - if FirstRun(): - self.InitInstallAppxPackage() - # Hack to prevent UWP app from launching a window that will block - # progress in unit tests. - first_run_file = os.path.join(local_cache_path, 'first_run') - dirname = os.path.dirname(first_run_file) - if not os.path.exists(dirname): - os.makedirs(dirname) - with open(first_run_file, 'w', encoding='utf-8') as _: - pass - - # Install Appx Package. - def InitInstallAppxPackage(self): - target_dir = os.path.dirname(self.GetTargetPath()) - final_path = FindAppxDirectoryOrRaise(target_dir) - self.Output('final_appx path: ' + final_path) - try: - self.UwpApi.RemovePackage(PACKAGE_NAME) - self.UwpApi.InstallPackage(final_path) - except subprocess.CalledProcessError as e: - msg = ('Could not complete remove / install cycle for \n' + - PACKAGE_FULL_NAME + '.\n' + 'This error is usually ' + - 'caused by a file being open in the package ' + - 'directory which is currently:\n ' + - os.path.abspath(self.package_dir)) - raise IOError(msg) from e - - # Sends to the test framework output file. - def Output(self, s): - self.output_file.write(str(s)) - self.output_file.flush() - - # Waits for the test execution to finish by inspecting the watchdog_log_path. - # On error, this function will throw an IOError. - def WaitForExecutionCompletion(self, exe_name, log_path): - if not WaitForFileToAppear(log_path, 30): - raise IOError('----> ERROR - expected log file ' + log_path + - ' was not generated') - - log_file = None - try: - log_file = open(log_path, 'r', encoding='utf-8') # pylint: disable=consider-using-with - - while self.UwpApi.IsExeRunning(exe_name) and not self.kill_called: - self.Output(''.join(log_file.readlines())) - except Exception as e: - raise IOError(str(e)) from e - - finally: - time.sleep(.5) # Give time for the |log_file| to finish writing. - if log_file: - self.Output(''.join(log_file.readlines())) - log_file.close() - - # Note that alias resolving is done in the launcher since it - # appears that multiple aliases are linked to the same binary. - # However, only the aliases with '-starboard' seem to work. - def ResolveAliasName(self, exe_name): - app_aliases = self.UwpApi.ResolveExeNameToAliases(PACKAGE_NAME, exe_name) - if not app_aliases: - return [] - # Prefer alias names that have "-starboard" in them. Other alias names - # that map to the same binary seem not to work. - for name in app_aliases: - if '-starboard' in name: - return name - return app_aliases[0] - - def Run(self): - crashed = False - app_alias = self.ResolveAliasName(self.uwp_app_exe_name) - if not app_alias: - msg = ('ERROR - "' + self.uwp_app_exe_name + '" is not installed.\n' + - 'Installed Apps:\n' + ' ' + - str(self.UwpApi.GetAppsExesInPackage(PACKAGE_NAME)) + '\n' + - 'Maybe you need to build and/or deploy ' + self.uwp_app_exe_name + - ' first?') - raise IOError(msg) - - try: - self.UwpApi.StartAppByAliasName(app_alias, self.args) - self.WaitForExecutionCompletion(self.uwp_app_exe_name, - self.stdout_file_path) - except KeyboardInterrupt: - self.Output('ctrl-c captured, quitting app...') - except IOError as io_err: - self.Output('IOError while running ' + app_alias + ', reason: ' + - str(io_err)) - except KeyError as key_err: - self.Output('Error while running app ' + app_alias + ': ' + str(key_err)) - finally: - self.UwpApi.KillAppByExeName(self.uwp_app_exe_name) - crashed = self.DetectAndHandleCrashDump() - return crashed - - def Kill(self): - self.kill_called = True - sys.stderr.write('\n***Killing UWP Launcher***\n') - self.UwpApi.KillAppByExeName(self.uwp_app_exe_name) - - def DeleteFiles(self, dir_path, glob_pattern): - dump_files = GlobFiles(dir_path, glob_pattern) - for f in dump_files: - try: - os.remove(f) - self.Output('Removed ' + f) - except Exception as err: # pylint: disable=broad-except - self.Output(f'Failed to remove {f} error:{err!r}') - - def DetectAndHandleCrashDump(self): - dump_files = GlobFiles(self.uwp_app_dmp_path, self.uwp_dump_file_pattern) - for dmp_file in dump_files: - mini_dump_printer.PrintMiniDump(dmp_file, self.output_file) - return len(dump_files) > 0 - - def GetDeviceIp(self): - """Gets the device IP. TODO: Implement.""" - return None - - def GetDeviceOutputPath(self): - # TODO: Implement - return None diff --git a/starboard/xb1/tools/xb1_launcher.py b/starboard/xb1/tools/xb1_launcher.py deleted file mode 100644 index b83a9e6984a7..000000000000 --- a/starboard/xb1/tools/xb1_launcher.py +++ /dev/null @@ -1,640 +0,0 @@ -#!/usr/bin/python -# -"""This script uses the UWP Device Portal API [1] to run unit tests on the Xbox. - -This module is designed to be integrated with the abstract_launcher framework. -It does the following when it is asked to run an app: - 1. Uninstall existing appx. - 2. Upload and install new application. - 3. Wait for the install to finish - 4. Run the application - 5. Wait for the application to finish running - 6. Fetch the content and write it to the appropriate place. - -When combined with starboard/tools/example/app_launcher_client.py, this module -enables changing target names (e.g. nplb), the Xbox used for testing, and - -Examples: -python starboard/tools/example/app_launcher_client.py --p xb1 -t nplb - -c debug -d 172.31.164.179 --target_params="--gtest_filter=*SbSocket*ait*" - -python starboard/tools/example/app_launcher_client.py --p xb1 -t nplb - -c debug -d 172.31.164.179 - --target_params="--gtest_filter=*Sb*Win*" - -Caveats: - Since we cannot launch write to a location any of the user directories like -LocalCache before the application is run for the first time, we have to bake -in the commandline arguments at install time. Thus, we have to reinstall -the package each time we want to run the binary with different arguments. - -Sample output (truncated for brevity): - Uninstalling App (if it exists). - Uninstall successfully started - Installing on NAVREETXB1 - Uploading 6 files in appx/...Done. - . - . - Uploading 80 files in appx/content/data/icu/icudt56l/zone...Done. - Skipping appx/microsoft.system.package.metadata since it has 0 files. - Done uploading. - Uploading args. [ --gtest_filter=*Sb*Win*; ] - Uploading 1 files in appx/content/data/arguments...Done. - Done uploading. - Done registering. - Installation is running.. - Installation complete. - Starting GoogleInc.YouTube::nplb - App started successfully. - nplb is running. - nplb is running. - Fetching log.. - Found 12 installed apps. - [1800:61781033300:INFO:application_uwp.cc(465)] Starting nplb.exe - Note: Google Test filter = *Sb*Win* - [==========] Running 7 tests from 4 test cases. - [----------] Global test environment set-up. - [----------] 2 tests from SbWindowCreateTest - [ RUN ] SbWindowCreateTest.SunnyDayDefault - [ OK ] SbWindowCreateTest.SunnyDayDefault (1 ms) - . - . - . - [----------] Global test environment tear-down - [==========] 7 tests from 4 test cases ran. (5644 ms total) - [ PASSED ] 7 tests. - Killing Process (if running). - Found 12 installed apps. - Log file found. Deleting. - -[1] -https://docs.microsoft.com/en-us/windows/uwp/debug-test-perf/device-portal-api-core -""" - -from __future__ import print_function - -import os -import subprocess -import sys -import time - -from starboard.shared.win32 import mini_dump_printer -from starboard.tools import abstract_launcher -from starboard.tools.abstract_launcher import TargetStatus -from starboard.tools import net_args -from starboard.tools import net_log -from starboard.xb1.tools import packager -from starboard.xb1.tools import xb1_network_api - -_ARGS_DIRECTORY = 'content/data/arguments' -_STARBOARD_ARGUMENTS_FILE = 'starboard_arguments.txt' -_DEFAULT_PACKAGE_NAME = 'GoogleInc.YouTube' -_STUB_PACKAGE_NAME = 'Microsoft.Title.StubApp' -_DEBUG_VC_LIBS_PACKAGE_NAME = 'Microsoft.VCLibs.140.00.Debug' -_DEFAULT_APPX_NAME = 'cobalt.appx' -_DEFAULT_STAGING_APP_NAME = 'appx' -_EXTENSION_SDK_DIR = os.path.realpath( - os.path.expandvars('%ProgramFiles(x86)%\\Microsoft SDKs' - '\\Windows Kits\\10\\ExtensionSDKs')) -_DEBUG_VC_LIBS_PATH = os.path.join(_EXTENSION_SDK_DIR, 'Microsoft.VCLibs', - '14.0', 'Appx', 'Debug', 'x64', - 'Microsoft.VCLibs.x64.Debug.14.00.appx') -_XB1_LOG_FILE_PARAM = 'xb1_log_file' -_XB1_PORT = 11443 -_XB1_NET_LOG_PORT = 49353 -_XB1_NET_ARG_PORT = 49355 - -# Number of times a test will try or retry. -_TEST_MAX_TRIES = 4 -# Seconds to wait between retries (scales with backoff factor). -_TEST_RETRY_WAIT = 8 -# Amount to multiply retry time with each failed attempt (i.e. 2 doubles the -# amount of time to wait between retries). -_TEST_RETRY_BACKOFF_FACTOR = 2 - -_PROCESS_TIMEOUT = 60 * 5.0 -_PROCESS_KILL_TIMEOUT_SECONDS = 5.0 - -_RESTART_TIMEOUT = 180 - - -def ToAppxFriendlyName(app_name): - if app_name == 'cobalt': - app_name = 'App' - else: - app_name = app_name.replace('_', '') + 'App' - return app_name - - -def GlobalVars(): - return GlobalVars.__dict__ - - -# First call returns True, otherwise return false. -def FirstRun(): - v = GlobalVars() - if 'first_run' in v: - return False - v['first_run'] = False - return True - - -def GetXb1NetworkApiFor(device_id, port): - v = GlobalVars() - network_key = str(device_id) + str(port) - if network_key not in v: - v[network_key] = xb1_network_api.Xb1NetworkApi(device_id, port) - return v[network_key] - - -def TryGetAppxDirectory(target_dir): - appx_path = os.path.join(target_dir, _DEFAULT_STAGING_APP_NAME) - if os.path.exists(os.path.join(appx_path, 'AppxManifest.xml')): - return appx_path - return None - - -def TryGetTargetPath(appx_path, target_name): - if not appx_path: - return None - target_path = os.path.join(appx_path, target_name + '.exe') - if os.path.exists(target_path): - return target_path - return None - - -def TryGetPackagedBinary(target_path): - path = os.path.join(target_path, 'package', _DEFAULT_APPX_NAME) - if os.path.exists(path): - return path - return None - - -def CheckEnvironment(): - v = GlobalVars() - if 'os_checked' not in v: - v['os_checked'] = True - path = os.path.abspath(__file__) - if path.startswith('/cygdrive'): - # os.path.abspath() does not work in cygwin, maybe other - # path operations don't work either. - raise OSError('\n **** cygwin not supported ****') - - -# Input: "--url=https://www.youtube.com/tv?v=1FmJdQiKy_w,--install=True" -# Output: {'url': 'https://www.youtube.com/tv?v=1FmJdQiKy_w', 'install': 'True'} -def CommandArgsToDict(s): - if not s: - return {} - - array = s.split(',') - out = {} - for v in array: - elems = v.split('=', 1) - if len(elems) < 1: - continue - key = elems[0] - - if key.startswith('--'): - key = key[2:] - val = None - if len(elems) > 1: - val = elems[1] - out[key] = val - return out - - -def Str2Bool(s): - if not s: - return False - s = s.lower() - return s in ('true', '1') - - -class Launcher(abstract_launcher.AbstractLauncher): - """Class for launching Cobalt/tools on Xbox.""" - - def __init__(self, platform, target_name, config, device_id, **kwargs): - """Launcher constructor. - - Args: - platform: Platform name (e.g. xb1, or xb1-future) - target_name: Target name (e.g. "nplb") - config: Config name (e.g. debug, devel, qa, gold) - device_id: IP address of the device (e.g. 172.2.3.4) - """ - super().__init__(platform, target_name, config, device_id, **kwargs) - - CheckEnvironment() - self._network_api = GetXb1NetworkApiFor(device_id, _XB1_PORT) - self._network_api.SetLoggingFunction(self._Log) - self._logfile_name = target_name + '_stdout.txt' - # Global argument will be visible to every launched application. - # --net_args_wait_for_connection will instruct the app to wait - # until net_args can connect via a socket and receive the command - # arguments. - # --net_log_wait_for_connection will instruct the app to wait until - # the netlog attaches. - self._global_args = (';--net_args_wait_for_connection' - ';--net_log_wait_for_connection') - # Once net_args is connected, the following _target_args will be sent - # over the wire. - self._target_args = ['--' + _XB1_LOG_FILE_PARAM + '=' + self._logfile_name] - self._do_deploy = True - self._do_restart = True - self._do_run = True - self._device_id = device_id - self._platform = platform - self._config = config - - # Note that target_params is an array of strings, not a string. - user_params = kwargs.get('target_params', '') - if user_params and len(user_params) > 0: - self.InitTargetParams(','.join(user_params)) - - self._package_root_dir = os.path.split(self.GetTargetPath())[0] - - # Ensure that target is built and ready to be packaged. - self._source_appx_path = TryGetAppxDirectory(self._package_root_dir) - self._source_exe_path = TryGetTargetPath(self._source_appx_path, - target_name) - if not self._source_exe_path: - raise IOError(f'Target {target_name} not found in appx directory.') - - def InitTargetParams(self, user_params_str): - args_dict = CommandArgsToDict(user_params_str) - # If --restart is present, consume the field - self._do_restart = Str2Bool(args_dict.pop('restart', 'True')) - - # If --deploy is present, then consume the value and - # remove from the rest of the arguments. - if 'deploy' in args_dict: - val = args_dict['deploy'] - del args_dict['deploy'] - if val is not None: - self._do_deploy = Str2Bool(val) - - # If --run is present, then consume the value and - # remove from the rest of the arguments. - if 'run' in args_dict: - val = args_dict['run'] - del args_dict['run'] - if val is not None: - self._do_run = Str2Bool(val) - # If there are still arguments then add them to the target - # args. - if len(args_dict) > 0: - args = [] - for key, val in args_dict.items(): - entry = '--' + key - if val is not None: - entry += '=' + val - args.append(entry) - self._target_args.extend(args) - - def _Log(self, s): - try: - self.output_file.write(s) - except UnicodeEncodeError: - s = s.encode('ascii', 'replace').decode() - self.output_file.write(s) - self.output_file.flush() - - def _LogLn(self, s): - try: - # Attempt to convert to a string if the type is bytes. - s = s.decode() - except (UnicodeDecodeError, AttributeError): - pass - self._Log(s + '\n') - - def InstallStarboardArgument(self, global_args): - args_path = [self._source_appx_path] - args_path.extend(_ARGS_DIRECTORY.split('/')) - args_path.append(_STARBOARD_ARGUMENTS_FILE) - args_path = os.path.join(*args_path) # splat args_path into flat list. - - args_dir_path = os.path.dirname(args_path) - if not os.path.exists(args_dir_path): - os.makedirs(args_dir_path) - - if not global_args: - if os.path.exists(args_path): - os.remove(args_path) - self._LogLn('Removed global command argument file: ' + args_path) - else: - with open(args_path, 'w', encoding='utf-8') as fd: - fd.write(global_args) - self._LogLn('Installed global command arguments: \"' + global_args + - '\" to:\n' + os.path.realpath(args_path)) - - def GetSerial(self): - try: - poll = self._network_api.GetDeviceInfo() - return poll['SerialNumber'] - except IOError: - return '' - - def RestartDevkit(self): - dev_info = self._network_api.GetDeviceInfo() - serial = dev_info['SerialNumber'] - console_type = dev_info['ConsoleType'] - self._Log('Connected to: ') - self._LogLn(self._network_api.ComputerName() + ' Type:' + console_type + - ' Serial:' + serial + ', triggering restart') - start = time.time() - self._network_api.Restart() - - while self.GetSerial(): # Wait for at least one failed poll - time.sleep(1) - - while self.GetSerial() != serial: - elapsed = int(time.time() - start) - if elapsed > _RESTART_TIMEOUT: - raise RuntimeError('Timed out waiting for restart, ' - f'timeout:{_RESTART_TIMEOUT}') - self._LogLn(f'Waiting for restart, elapsed seconds:{elapsed} ' - f'( timeout: {_RESTART_TIMEOUT} )') - time.sleep(1) - - time.sleep(10) - self._Log('Restart complete: ') - self._LogLn(self._network_api.ComputerName()) - - def SignIn(self): - self._Log('Connected to: ') - self._LogLn(self._network_api.ComputerName()) - - users = self._network_api.GetXboxLiveUserInfos().get('Users', []) - - if len(users) == 0: - raise IOError('Please add at least one user to the test accounts on\n' + - 'the Xbox developer homescreen.') - - # If we find an existing user that is signed in, then use that. - for user in users: - if user.get('SignedIn', False): - return - - # Else, sign in the first user. - self._network_api.SetXboxLiveSignedInUserState(users[0]['EmailAddress'], - True) - - def WinAppDeployCmd(self, command: str): - try: - exe_path = os.path.join(packager.GetWinToolsPath(), 'WinAppDeployCmd.exe') - command_str = f'{exe_path} {command} -ip {self.GetDeviceIp()}' - self._LogLn('Running: ' + command_str) - out = subprocess.check_output(command_str).decode() - except subprocess.CalledProcessError as e: - self._LogLn(e.output) - raise e - - return out - - def PackageCobalt(self): - # Package all targets into an appx. - package_parameters = { - 'source_dir': self.out_directory, - 'output_dir': os.path.join(self.out_directory, 'package'), - 'publisher': None, - 'product': 'youtube', - } - if not os.path.exists(package_parameters['output_dir']): - os.makedirs(package_parameters['output_dir']) - packager.Package(**package_parameters) - - def UninstallSubPackages(self): - # Check for sub-packages left over. Force uninstall any that exist. - uninstalled_packages = [] - packages = self._network_api.GetInstalledPackages() - for package in packages: - try: - package_full_name = package['PackageFullName'] - if package_full_name.find( - _DEFAULT_PACKAGE_NAME) != -1 or package_full_name.find( - _STUB_PACKAGE_NAME) != -1: - if package_full_name not in uninstalled_packages: - self._LogLn('Existing YouTube app found on device. Uninstalling: ' + - package_full_name) - uninstalled_packages.append(package_full_name) - self.WinAppDeployCmd('uninstall -package ' + package_full_name) - except KeyError: - # Some packages don't include all fields. Ignore those. - pass - except subprocess.CalledProcessError as err: - self._LogLn(err.output) - - def DeleteLooseApps(self): - self._network_api.ClearLooseAppFiles() - - def Deploy(self): - # starboard_arguments.txt is packaged with the appx. It instructs the app - # to wait for the NetArgs thread to send command-line args via the socket. - self.InstallStarboardArgument(self._global_args) - - self.PackageCobalt() - appx_package_file = TryGetPackagedBinary(self._package_root_dir) - if not appx_package_file: - raise IOError('Packaged appx not found in package directory. Perhaps ' - 'package_cobalt script did not complete successfully.') - - existing_package = self.CheckPackageIsDeployed(_DEFAULT_PACKAGE_NAME) - if existing_package: - self._LogLn('Existing YouTube app found on device. Uninstalling.') - self.WinAppDeployCmd('uninstall -package ' + existing_package) - - if not self.CheckPackageIsDeployed(_DEBUG_VC_LIBS_PACKAGE_NAME): - self._LogLn('Required dependency missing. Attempting to install.') - self.WinAppDeployCmd(f'install -file "{_DEBUG_VC_LIBS_PATH}"') - - self._LogLn('Deleting temporary files') - self._network_api.ClearTempFiles() - - try: - self.WinAppDeployCmd(f'install -file {appx_package_file}') - except subprocess.CalledProcessError: - # Install exited with non-zero status code, clear everything out, restart, - # and attempt another install. - self._LogLn('Error installing appx. Attempting a clean install...') - self.UninstallSubPackages() - self.DeleteLooseApps() - self.RestartDevkit() - self.WinAppDeployCmd(f'install -file {appx_package_file}') - - # Cleanup starboard arguments file. - self.InstallStarboardArgument(None) - - # Validate that app was installed correctly by checking to make sure - # that the full package name can now be found. - def CheckPackageIsDeployed(self, package_name=_DEFAULT_PACKAGE_NAME): - package_list = self.WinAppDeployCmd('list') - package_index = package_list.find(package_name) - if package_index == -1: - return False - return package_list[package_index:].split('\n')[0].strip() - - def RunTest(self, appx_name: str): - self.net_args_thread = None - attempt_num = 0 - retry_wait_s = _TEST_RETRY_WAIT - while attempt_num < _TEST_MAX_TRIES: - if not self.net_args_thread or not self.net_args_thread.is_alive(): - # This thread must start before the app executes or else it is possible - # the app will hang at _network_api.ExecuteBinary() - self.net_args_thread = net_args.NetArgsThread(self.device_id, - _XB1_NET_ARG_PORT, - self._target_args) - if self._network_api.ExecuteBinary(_DEFAULT_PACKAGE_NAME, appx_name): - break - - if not self.net_args_thread.ArgsSent(): - self._LogLn( - 'Net Args were not sent to the test! This will likely cause ' - 'the test to fail!') - attempt_num += 1 - self._LogLn(f'Retry attempt {attempt_num}.') - time.sleep(retry_wait_s) - retry_wait_s *= _TEST_RETRY_BACKOFF_FACTOR - if hasattr(self, 'net_args_thread'): - self.net_args_thread.join() - - def InitDevice(self): - if not self._network_api.IsInDevMode(): - raise IOError('\n\n**** Please set the XBOX at ' + self._device_id + - ' to dev mode!!!! ****\n') - self.SignIn() - - def Run(self): - # Only upload and install Appx on the first run. - if FirstRun(): - if self._do_restart: - self.RestartDevkit() - - self.InitDevice() - if self._do_deploy: - self.Deploy() - else: - self._LogLn('Skipping deploy step.') - - if not self.CheckPackageIsDeployed(_DEFAULT_PACKAGE_NAME): - raise IOError('Could not resolve ' + _DEFAULT_PACKAGE_NAME + ' to\n' + - 'it\'s full package name after install! This means that' + - '\n the package is not deployed correctly!\n\n') - - if not self._do_run: - self._LogLn('Skipping running step.') - return 0 - - status, _ = self.Run2() - if status == TargetStatus.CRASH: - return 1 - else: - return 0 - - def Run2(self): - try: - self.Kill() # Kill existing running app. - # While binary is running, extract the net log and stream it to - # the output. - self.net_log_thread = net_log.NetLogThread(self.device_id, - _XB1_NET_LOG_PORT) - - appx_name = ToAppxFriendlyName(self.target_name) - - self.RunTest(appx_name) - - while self._network_api.IsBinaryRunning(self.target_name): - self._Log(self.net_log_thread.GetLog()) - - self._Log(self.net_log_thread.GetLog()) - self._LogLn('Program Exited...') - - except KeyboardInterrupt: - self._LogLn('User cancelled...') - except IOError as io_err: - _, _, exc_tb = sys.exc_info() - fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] - msg = (f'Exception happened at {fname}({exc_tb.tb_lineno}) during ' - f'to run cycle of {self.target_name} this ' - 'is common if no one is signed in to the xbox.\n' - f' Error: {repr(io_err)}') - raise IOError(msg) from io_err - finally: - if hasattr(self, 'net_args_thread'): - self.net_args_thread.join() - if hasattr(self, 'net_log_thread'): - self.net_log_thread.join() - - self.Kill() - self._LogLn('Finished running...') - if self._DetectAndHandleAnyCrashes(self.target_name): - return TargetStatus.CRASH, 0 - else: - return TargetStatus.NA, 0 - - def _DetectAndHandleAnyCrashes(self, target_name): - crashes_detected = False - (files, - _) = self._network_api.ListPackageFilesAndDirs(_DEFAULT_PACKAGE_NAME, 'AC') - for f in files: - if f.startswith(target_name) and f.endswith('dmp'): - self._LogLn('\n***** Application ' + target_name + - ' crashed! *****\nDump file: ' + f) - crashes_detected = True - data = self._network_api.FetchPackageFile( - _DEFAULT_PACKAGE_NAME, - 'AC/' + f, - raise_on_failure=True, - is_text=False) - # Ensure that directory exists. - dump_dir_path = os.path.join(os.environ['LOCALAPPDATA'], 'CrashDumps', - 'xbox_remote') - if not os.path.exists(dump_dir_path): - os.makedirs(dump_dir_path) - - dump_file_path = os.path.join(dump_dir_path, f) - # Clean previous dump file, if it exists. - if os.path.exists(dump_file_path): - try: - os.remove(dump_file_path) - except IOError as io_err: - self._LogLn('Error, could not remove old file ' + str(io_err)) - - try: - with open(dump_file_path, 'wb') as fp: - fp.write(data) - self._LogLn('Copied dump to ' + dump_file_path) - mini_dump_printer.PrintMiniDump(dump_file_path, self.output_file) - except Exception as err: # pylint: disable=broad-except - self._LogLn('Failed to dump file ' + dump_file_path + ' because: ' + - str(err)) - return crashes_detected - - def Kill(self): - self._Log('Killing Process (if running).\n') - running_processes = self._network_api.GetRunningProcesses() - exe_name = self.target_name + '.exe' - filtered_processes = list( - filter(lambda p: p['ImageName'] == exe_name, running_processes)) - if len(filtered_processes) == 0: - return - process_under_test = filtered_processes[0] - if not process_under_test['IsRunning']: - return - pid = process_under_test['ProcessId'] - self._Log('Going to kill pid ' + str(pid) + '\n') - - self._network_api.KillProcess(pid) - self._Log('Kill signal sent. Waiting for the process to die.\n') - self._network_api.WaitForBinaryToFinishRunning( - self.target_name, _PROCESS_KILL_TIMEOUT_SECONDS) - self._Log('Done killing.\n') - - def GetDeviceIp(self): - """Gets the device IP.""" - return self.device_id - - def GetDeviceOutputPath(self): - # TODO: Implement - return None diff --git a/starboard/xb1/tools/xb1_network_api.py b/starboard/xb1/tools/xb1_network_api.py deleted file mode 100644 index fac5872c835a..000000000000 --- a/starboard/xb1/tools/xb1_network_api.py +++ /dev/null @@ -1,843 +0,0 @@ -#!/usr/bin/python -# Copyright 2017 The Cobalt Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -""" This script provides an API for the Xbox REST API. """ - -from __future__ import print_function - -import base64 -import os -import pprint -import sys -import time -import traceback - -from distutils.util import strtobool # pylint: disable=deprecated-module -import requests -from requests.compat import urljoin -# This helps the script run in an consistent way across multiple different -# library versions(requests) and python runtime versions. -try: - from requests.packages import urllib3 -except ImportError: - import urllib3 -try: - from urllib3.exceptions import InsecureRequestWarning - urllib3.disable_warnings(InsecureRequestWarning) -except ImportError: - pass - -try: - input_fn = raw_input -except NameError: - input_fn = input - -_DEFAULT_URL_FORMAT = 'https://{}:{}}/' - -_APPX_RELATIVE_PATH = 'appx' -_DEVELOPMENT_FILES = 'DevelopmentFiles' -_LOOSE_APPS = 'LooseApps' -_LOCAL_APP_DATA = 'LocalAppData' -_LOCAL_CACHE_FOLDERNAME = r'\\LocalCache' -_TEMP_FILE_FOLDERNAME = r'\\WdpTempWebFolder' -_DEFAULT_STAGING_APP_NAME = 'appx' - -_APP_INSTALLATION_STATUS_ENDPOINT = '/api/app/packagemanager/state' -_DELETE_APP_ENDPOINT = '/api/app/packagemanager/package' -_DELETE_FILE_ENDPOINT = '/api/filesystem/apps/file' -_DEVICE_INFO_ENDPOINT = '/ext/xbox/info' -_EXT_USER_ENDPOINT = '/ext/user' -_GET_FILE_ENDPOINT = '/api/filesystem/apps/file' -_GET_FILES_ENDPOINT = '/api/filesystem/apps/files' -_KILL_PROCESS_ENDPOINT = 'api/taskmanager/process' -_LIST_ALL_APPS_ENDPOINT = '/api/app/packagemanager/packages' -_MACHINENAME_ENDPOINT = '/api/os/machinename' -_NETWORK_CREDS_ENDPOINT = '/ext/networkcredential' -_REGISTER_ENDPOINT = 'api/app/packagemanager/register' -_RESOURCE_MANAGER_PROCESSES_ENDPOINT = 'api/resourcemanager/processes' -_SANDBOX_ENDPOINT = '/ext/xboxlive/sandbox' -_SETTINGS_ENDPOINT = '/ext/settings' -_OS_UPDATE_ENDPOINT = '/ext/settings/osupdatepolicy' -_TASKMANAGER_ENDPOINT = '/api/taskmanager/app' -_UPLOAD_FILE_ENDPOINT = '/api/filesystem/apps/file' -_UPLOAD_FOLDER_ENDPOINT = '/api/app/packagemanager/upload' -_DEPLOY_INFO_ENDPOINT = '/ext/app/deployinfo' -_DEVELOPER_FOLDER_ENDPOINT = '/ext/smb/developerfolder' - -# This header is required for all non-GET requests for windows -# dev portal. It must be populated with the value of a specific cookie. -_CSRF_TOKEN_HEADER = 'X-CSRF-Token' - -_INSTALL_FINISH_TIMEOUT_SECONDS = 90.0 -_PROCESS_RUN_TIMEOUT_SECONDS = 300.0 -_PROCESS_KILL_TIMEOUT_SECONDS = 20.0 - -# Wait time to use when polling the same API repeatedly. -_API_RETRY_SECONDS = 2.0 - - -# Returns a dictionary of "directory_name" -> [file_paths,...] -def GetFilesRecursively(path): - path = os.path.abspath(path) - - all_file_paths = [] - for root, _, filenames in os.walk(path): - for filename in filenames: - all_file_paths.append(os.path.join(root, filename)) - - out = {} - for file_path in all_file_paths: - if os.path.isdir(file_path): - continue - dir_name = os.path.dirname(file_path) - if dir_name not in out: - out[dir_name] = [] - out[dir_name].append(file_path) - - return out - - -def _PrintAndRaiseIfError(response): - """If http response is not OK (200), then print information and raise error - - If the response is not http "OK", then an exception is raised by - |raise_for_status|, and this function will print additional information - such as the request url, the response headers, and the response content. - After that the exception is re-raised so that it can be handled at a higher - level. This function is mainly useful for debugging failed requests. - - Args: - response: Server's response to our http request. - - Raises: - requests.exceptions.HTTPError - Returns: - None - """ - try: - #The following line only raises on a response that is not status OK(200). - response.raise_for_status() - except Exception as e: - print('URL:', response.url) - print('status_code: ' + str(response.status_code)) - print('Headers:') - pprint.pprint(dict(response.headers)) - print('Response:') - try: - pprint.pprint(response.json()) - except Exception: #pylint: disable=broad-except - print(response.text) - raise e - - -class MissingDependencyError(Exception): - pass - - -# Xb1NetworkApi allows an interface for communicating with a remote xbox -# device. -class Xb1NetworkApi: - """ This header is required for all non-GET requests for windows - dev portal. It must be populated with the value of a specific cookie.""" - _CSRF_TOKEN_HEADER = 'X-CSRF-Token' - - def __init__(self, device_id, port): - #? self.out_directory = os.path.split(self.GetTargetPath())[0] - self.web_portal_url = f'https://{device_id}:{port}/' - self._logfile_name = None - self._csrf_token = None - self._cookie_jar = None - self.logging_function = None - self.cached_package_name_map = {} - self._AuthenticateOnce() - - def SetLoggingFunction(self, logging_function): - self.logging_function = logging_function - - def Log(self, s): - if self.logging_function: - self.logging_function(s) - else: - print(s, end='') - - def LogLn(self, s): - self.Log(s + '\n') - - def ComputerName(self): - return self._DoJsonRequest('GET', _MACHINENAME_ENDPOINT)['ComputerName'] - - def GetInstalledPackages(self): - installed_apps_response = self._DoJsonRequest('GET', - _LIST_ALL_APPS_ENDPOINT) - return installed_apps_response['InstalledPackages'] - - # Returns all running processes in the app. - def GetRunningProcesses(self): - response_decoded = self._DoJsonRequest( - 'GET', _RESOURCE_MANAGER_PROCESSES_ENDPOINT) - if 'Processes' in response_decoded: - return response_decoded['Processes'] - return {} - - def GetSettings(self): - val = self._DoJsonRequest('GET', _SETTINGS_ENDPOINT) - return val.get('Settings', []) - - def IsPendingOSUpdate(self): - """Detects whether there is a pending OS update.""" - try: - self._DoRequest('GET', _OS_UPDATE_ENDPOINT) - # Value returned is: - # So no pending update. - return False - except ValueError: - # If there is a pending OS update then the following exception is - # generated: - # URL: https://172.31.165.44:11443/ext/settings/osupdatepolicy - # status_code: 500 - # Headers: - # {'Content-Length': '0', - # 'Content-Type': 'text/plain', - # 'Date': 'Thu, 09 May 2019 18:10:59 GMT', - # 'Server': 'Microsoft-HTTPAPI/2.0', - # 'Set-Cookie': 'CSRF-Token=YNsSUe/7hKTHsW/o/goM1opGEnYb6gi/'} - # In this case there is a response code with error 500. - return True - except Exception as err: #pylint: disable=broad-except - traceback.print_exc() - print(f'Unexpected {err}') - return True - - def GetSetting(self, name): - settings = self.GetSettings() - for setting in settings: - if setting.get('Name', '') == name: - return setting - return {} - - def IsInDevMode(self): - setting = self.GetSetting('DefaultApp') - return setting.get('Value', '') == 'Dev Home' - - def GetDeviceInfo(self): - return self._DoJsonRequest('GET', _DEVICE_INFO_ENDPOINT) - - def GetLiveSandboxInfo(self): - return self._DoRequest('GET', _SANDBOX_ENDPOINT).text - - def GetNetworkCredentials(self): - val = self._DoJsonRequest('GET', _NETWORK_CREDS_ENDPOINT) - if val.get('Credentials'): - return (val['Username'], val['Password'], val['Path']) - return () - - def AddNetworkCredentials(self, username, password, path): - p = {'Username': username, 'Password': password, 'NetworkPath': path} - return self._DoJsonRequest('POST', _NETWORK_CREDS_ENDPOINT, params=p) - - def GetSandbox(self): - return self._DoRequest('GET', '/ext/xboxlive/sandbox') - - def GetXboxLiveUserInfos(self): - return self._DoJsonRequest('GET', _EXT_USER_ENDPOINT) - - def GetUserId(self, email_address): - email_address = email_address.lower() - users = self.GetXboxLiveUserInfos().get('Users', []) - - if not users: - self.LogLn('Error - no users logged in') - return - - for user in users: - if user.get('EmailAddress', '').lower() == email_address: - return user.get('UserId', None) - - def Restart(self): - return self._DoRequest('POST', '/api/control/restart') - - def SetXboxLiveSignedInUserState(self, user_email, is_signed_in): - user_id = self.GetUserId(user_email) - if not user_id: - self.LogLn('Could not find any users registered on this device') - return - - creds = { - 'Users': [{ - 'UserId': int(user_id), - 'SignedIn': bool(strtobool(str(is_signed_in))), - },] - } - rtn = self._DoRequest('PUT', _EXT_USER_ENDPOINT, json=creds) - return rtn - - def GetXboxLiveUserIsLoggedIn(self, user_email): - user_email = user_email.lower() - infos = self.GetXboxLiveUserInfos().get('Users', []) - - for info in infos: - if info.get('EmailAddress', '').lower() == user_email: - return info.get('SignedIn', False) - return False - - def GetDeveloperFolderCredentials(self): - d = self._DoJsonRequest('GET', _DEVELOPER_FOLDER_ENDPOINT) - return (d['Username'], d['Password'], d['Path']) - - def GetDeploymentInfo(self, partial_package_name): - full_package_name = self.ResolvePackageFullName(partial_package_name) - - if not full_package_name: - self.LogLn('Could not get deployment info for ' + partial_package_name) - full_package_name = partial_package_name - return None - - body = { - 'DeployInfo': [{ - 'PackageFullName': full_package_name - },], - } - - val = self._DoJsonRequest('POST', _DEPLOY_INFO_ENDPOINT, json=body) - return val - - def IsBinaryRunning(self, target_name): - response_decoded = self._DoJsonRequest( - 'GET', _RESOURCE_MANAGER_PROCESSES_ENDPOINT) - running_processes = response_decoded['Processes'] - exe_name = target_name + '.exe' - filtered_processes = \ - list(filter(lambda p: p['ImageName'] == exe_name, running_processes)) - if len(filtered_processes) == 0: - return False - process_under_test = filtered_processes[0] - return process_under_test.get('IsRunning', False) - - def KillProcess(self, pid): - self._DoJsonRequest('DELETE', _KILL_PROCESS_ENDPOINT, params={'pid': pid}) - - def WaitForBinaryToFinishRunning(self, target_name, timeout_seconds): - """Waits up to |timeout_seconds| for |self.target_name| to finish running. - - Args: - timeout_seconds: Timeout in seconds. - """ - assert isinstance(timeout_seconds, float) - current_time = time.time() - max_time = current_time + timeout_seconds - while current_time <= max_time: - if not self.IsBinaryRunning(target_name): - return - time.sleep(_API_RETRY_SECONDS) - if self.IsBinaryRunning(target_name): - raise RuntimeError('Waiting for process to end timed out.') - - def FetchFileContent(self, filename_to_grab): - """Fetch a file from device and returns the content - - This function fetches a file named |filename_to_grab|, - within the |_LOCAL_APP_DATA| folder. - - Args: - filename_to_grab: name of the file to fetch. - """ - self.LogLn('Fetching log..') - package_full_name = self._GetPackageFullName() - if not package_full_name: - return - - fetch_log_request = requests.get( # pylint: disable=missing-timeout - urljoin(self.web_portal_url, self._GET_FILE_ENDPOINT), - verify=False, - params={ - 'knownfolderid': self._LOCAL_APP_DATA, - 'packagefullname': package_full_name, - 'filename': filename_to_grab, - 'path': self._LOCAL_CACHE_FOLDERNAME - }) - _PrintAndRaiseIfError(fetch_log_request) - return fetch_log_request.text - - # Fetch a file given the package and file path. - def FetchPackageFile(self, - package_name, - path_to_file, - raise_on_failure=True, - is_text=True): - """Fetch a file from device and returns the content - - Note that files associated with a running process will - fail to be fetched. - - Args: - path_to_file: name of the file to fetch. - raise_on_failure: when True, failure to fetch the file will result in an - raised exception. - """ - filename = os.path.basename(path_to_file) - path = os.path.dirname(path_to_file) - package_full_name = self.ResolvePackageFullName(package_name) - - if path: - path = '\\\\' + path - filename = '' + filename - - url = urljoin(self.web_portal_url, _GET_FILE_ENDPOINT) - - f = requests.get( # pylint: disable=missing-timeout - url, - verify=False, - params={ - 'knownfolderid': _LOCAL_APP_DATA, - 'packagefullname': package_full_name, - 'filename': filename, - 'path': path - }) - - if raise_on_failure: - _PrintAndRaiseIfError(f) - if is_text: - return f.text - else: - return f.content - else: - try: - if is_text: - return f.text - else: - return f.content - except Exception: #pylint: disable=broad-except - return None - return None - - def ExecuteBinary(self, partial_package_name: str, - app_alias_name: str) -> bool: - default_relative_name = self._GetDefaultRelativeId(partial_package_name) - if not default_relative_name or not '!' in default_relative_name: - raise IOError('Could not resolve package name "' + partial_package_name + - '"') - - relative_package_name = default_relative_name.split('!')[0] - package_relative_id = relative_package_name + '!' + app_alias_name - appid_64 = base64.b64encode(package_relative_id.encode('UTF-8')) - package_64 = base64.b64encode(default_relative_name.encode('UTF-8')) - - try: - self.LogLn('Executing: ' + package_relative_id) - response = self._DoJsonRequest( - 'POST', - _TASKMANAGER_ENDPOINT, - params={ - 'appid': appid_64, - 'package': package_64 - }, - raise_on_failure=False) - if not response or response == requests.codes.OK: - self.LogLn('Execution successful') - return True - self.LogLn('Execution not successful: ' + str(response)) - except Exception as err: - err_msg = '\n Failed to run:\n ' + package_relative_id + \ - '\n because of:\n' + str(err) - raise IOError(err_msg) from err - return False - - # Given a package name, return all files + directories. - # Throws IOError if the app is locked. - def ListFilesAndDirs(self, package_name, knownfolderid, sub_path): - args = {} - if sub_path: - args['path'] = '\\\\' + sub_path - if package_name: - args['packagefullname'] = self.ResolvePackageFullName(package_name) - # Per api, knownfolder id must 'LocalAppData' whenever package - # name is used. - assert knownfolderid == 'LocalAppData' - # 'knownfolderid' is required - args['knownfolderid'] = '' + knownfolderid - - response = self._DoRequest( - 'GET', - '/api/filesystem/apps/files', - params=args, - raise_on_failure=False) - - if response.status_code == 403: - raise IOError('Could not list files for ' + package_name + - ': permission denied.\n' + str(response)) - - response_json = response.json() - - sub_files = [] - sub_dirs = [] - if 'Items' in response_json: - for item in response_json['Items']: - name = item['Name'] - sub_path = item['SubPath'] - if sub_path.endswith(name): - sub_dirs.append(name) - else: - sub_files.append(name) - return sub_files, sub_dirs - - def ListPackageFilesAndDirs(self, package_name, sub_path=None): - return self.ListFilesAndDirs(package_name, 'LocalAppData', sub_path) - - # Returns files, dirs - def ListPackageFilesAndDirsRecursive(self, - package_name, - list_empty_dirs=True): - package_name = self.ResolvePackageFullName(package_name) - - def RecursiveStep(curr_dir_stack, found_files, found_dirs): - curr_dir = '/'.join(curr_dir_stack) - files, dirs = self.ListPackageFilesAndDirs( - package_name, sub_path=curr_dir) - - add_curr_dir = curr_dir and (files or list_empty_dirs) - if add_curr_dir: - found_dirs.append(curr_dir) - - for f in files: - tmp_path = curr_dir_stack[:] - tmp_path.append(f) - tmp_path = '/'.join(tmp_path) - found_files.append(tmp_path) - for d in dirs: - next_dir_stack = curr_dir_stack[:] # Copy by value. - next_dir_stack.append(d) - RecursiveStep(next_dir_stack, found_files, found_dirs) - - curr_dir_stack = [] - found_files = [] - found_dirs = [] - - RecursiveStep(curr_dir_stack, found_files, found_dirs) - return found_files, found_dirs - - def DeleteFile(self, known_folder_id, path, filename_to_delete): - """Deletes a file named |file|. - - This function deletes a file. - - Args: - known_folder_id: name of the top level known folder - path: path to the directory containing filename_to_delete - filename_to_delete: name of the file to delete - """ - self.LogLn(f'Deleting [{filename_to_delete}]') - file_listing = self._DoJsonRequest( - 'GET', - _GET_FILES_ENDPOINT, - params={ - 'knownfolderid': known_folder_id, - 'path': path - }) - for item in file_listing['Items']: - if item['Name'] == filename_to_delete: - break - else: - self.LogLn(filename_to_delete + ' was not found. Skipping delete step.') - return - - self.LogLn('File found. Deleting.') - self._DoJsonRequest( - 'DELETE', - _DELETE_FILE_ENDPOINT, - params={ - 'knownfolderid': known_folder_id, - 'filename': filename_to_delete, - 'path': path - }) - - def ClearDevFiles(self, path): - file_listing = self._DoJsonRequest( - 'GET', - _GET_FILES_ENDPOINT, - params={ - 'knownfolderid': _DEVELOPMENT_FILES, - 'path': path - }) - for file in file_listing['Items']: - self.DeleteFile(_DEVELOPMENT_FILES, _TEMP_FILE_FOLDERNAME, file['Name']) - - def ClearTempFiles(self): - self.ClearDevFiles(_TEMP_FILE_FOLDERNAME) - - def ClearLooseAppFiles(self): - self.ClearDevFiles(_LOOSE_APPS) - - def FindPackage(self, package_name): - all_packages = self.GetInstalledPackages() - - for package in all_packages: - if package_name in package['PackageRelativeId']: - return package - - for package in all_packages: - if package_name in package['PackageFullName']: - return package - - for package in all_packages: - if package_name in package['PackageFamilyName']: - return package - return None - - def ResolvePackageFullName(self, package_name): - if package_name not in self.cached_package_name_map: - package = self.FindPackage(package_name) - full_package_name = None - if package: - full_package_name = package['PackageFullName'] - self.cached_package_name_map[package_name] = full_package_name - return self.cached_package_name_map[package_name] - - def _GetDefaultRelativeId(self, partial_package_name): - package = self.FindPackage(partial_package_name) - if package is None: - return None - return package.get('PackageRelativeId', None) - - def _DoRequest(self, method, endpoint, **kwargs): - url_to_request = urljoin(self.web_portal_url, endpoint) - headers = {} - raise_on_failure = True - - if 'headers' in kwargs: - headers = kwargs['headers'] - del kwargs['headers'] - - if 'raise_on_failure' in kwargs: - raise_on_failure = kwargs['raise_on_failure'] - del kwargs['raise_on_failure'] - - cookie_jar = None - if method != 'GET': - cookie_jar = self._cookie_jar - if not self._csrf_token: - raise RuntimeError('CSRF token is required for all non-GET requests.') - headers.update({_CSRF_TOKEN_HEADER: self._csrf_token}) - - request_info = requests.request( - method, - url_to_request, - verify=False, - timeout=(60, 60), - cookies=cookie_jar, - headers=headers, - **kwargs) - if raise_on_failure: - _PrintAndRaiseIfError(request_info) - - if request_info.cookies: - self._cookie_jar = request_info.cookies - self._csrf_token = self._cookie_jar['CSRF-Token'] - return request_info - - def _DoJsonRequest(self, method, endpoint, **kwargs): - response = self._DoRequest(method, endpoint, **kwargs) - if response is None: - return {} - try: - return response.json() - except ValueError: - return {} - - def _AuthenticateOnce(self): - if self._csrf_token: - return - # Cookies / Authentication is a side effect of calling _DoRequest() - self._DoRequest('GET', _MACHINENAME_ENDPOINT) - if not self._csrf_token: - raise RuntimeError('Authentication failed.') - - -############################################ -# A little tester to test + inspect packages -def InteractiveCommandLineMode(): - - # Local functions used in this test. - def PrintCurrentlyRunningProcesses(network_api): - running_processes = network_api.GetRunningProcesses() - print('Found ' + str(len(running_processes)) + ' processes:') - - columns = ['ImageName', 'UserName', 'PageFileUsage', 'ProcessId'] - size_dict = {} - - for p in running_processes: - for key in columns: - val = p[key] - prev_val_size = size_dict.get(key, 0) - val_size = len(str(val)) - if prev_val_size <= val_size: - size_dict[key] = val_size - - header = '' - for key in columns: - n_size = max(len(key), size_dict.get(key, 0)) + 2 - size_dict[key] = n_size - header += key.upper().rjust(n_size) - print(header) - for _ in range(0, len(header)): - print('-', end='') - print() - for p in running_processes: - msg = '' - for key in columns: - val = p[key] - msg += str(val).rjust(size_dict[key]) - print(msg) - - def PrintInstalledPackage(network_api): - packages = network_api.GetInstalledPackages() - print('Apps currently installed:') - for p in packages: - print(' ' + p['PackageFamilyName']) - - def FindThenPrintPackage(network_api): - package_name = input_fn('Package name to inspect: ') - package = network_api.FindPackage(package_name) - if package is None: - print('Could not find package ' + package_name) - else: - pprint.pprint(package) - - def ListFilesAndDirsInPackage(network_api): - package_name = input_fn('Package name: ') - package = network_api.FindPackage(package_name) - if package is None: - print('Could not find package ' + package_name) - else: - try: - files, dirs = network_api.ListPackageFilesAndDirs(package_name) - print(f'Files in {package_name}:\n') - pprint.pprint({'files': files, 'dirs': dirs}) - except IOError as ioe: - print(ioe) - - def PromptAndRunExecutable(network_api): - package_name = input_fn('Package name: ') - app_name = input_fn('App name: ') - try: - print('Attempting to run: ' + app_name + ' in ' + package_name) - network_api.ExecuteBinary(package_name, app_name) - except Exception as e: #pylint: disable=broad-except - print('Could not run binary because: ' + str(e)) - - def PromptAndSignInUserToXboxLive(network_api): - network_api.GetXboxLiveUserInfos() - email_addr = input_fn('User EmailAddress: ') - signed_in_state = input_fn('SignInState: ') - network_api.SetXboxLiveSignedInUserState(email_addr, signed_in_state) - - def PromptPackageAndListFilesAndDirsRecursively(network_api): - package_name = input_fn('Package name: ') - files, dirs = network_api.ListPackageFilesAndDirsRecursive(package_name) - if files: - print('Files:') - for f in files: - print(' ' + f) - if dirs: - print('Directories:') - for d in dirs: - print(' ' + d) - - # Begin Test. - ip = input_fn('IP Address of XBOX: ') - if len(ip.split('.')) != 4: - print('Expected ip to have a 4 numbers') - return - - port = input_fn('port(default is 11443): ') - if len(port) == 0: - port = '11443' - - network_api = Xb1NetworkApi(ip, port) - - while True: - print('What would you like to do?') - print(' [0] See all currently running processes.') - print(' [1] Run executable.') - print(' [2] Find all installed packages.') - print(' [3] Inspect a package by name.') - print(' [4] List root directories and files in a package.') - print(' [5] Recursive list all files in package.') - print(' [6] Print System Settings.') - print(' [7] Print Device Info.') - print(' [8] Print Xbox Live Sandbox Mode.') - print(' [9] Print Network Credentials.') - print(' [10] XboxLive: Print signed in users.') - print(' [11] XboxLive: Sign in user.') - print(' [12] Print Network Credentials.') - print(' [13] Update Network Credentials.') - print(' [14] Print Deployment Info.') - print(' [15] Print whether OS Update is pending.') - print(' [q] Quit.') - val = input_fn('> ') - - if val in ('', 'q'): - print('quitting.') - sys.exit(0) - elif '0' == val: - PrintCurrentlyRunningProcesses(network_api) - elif '1' == val: - PromptAndRunExecutable(network_api) - elif '2' == val: - PrintInstalledPackage(network_api) - elif '3' == val: - FindThenPrintPackage(network_api) - elif '4' == val: - ListFilesAndDirsInPackage(network_api) - elif '5' == val: - PromptPackageAndListFilesAndDirsRecursively(network_api) - elif '6' == val: - pprint.pprint(network_api.GetSettings()) - elif '7' == val: - pprint.pprint(network_api.GetDeviceInfo()) - elif '8' == val: - pprint.pprint(network_api.GetLiveSandboxInfo()) - elif '9' == val: - pprint.pprint(network_api.GetNetworkCredentials()) - elif '10' == val: - pprint.pprint(network_api.GetXboxLiveUserInfos()) - elif '11' == val: - PromptAndSignInUserToXboxLive(network_api) - elif '12' == val: - pprint.pprint(network_api.GetNetworkCredentials()) - elif '13' == val: - user_name = input_fn('username: ') - password = input_fn('password: ') - path = input_fn( - 'path (blank = "D:\\DevelopmentFiles\\LooseApps\\appx"?): ') - if not path: - path = 'D:\\DevelopmentFiles\\LooseApps\\appx' - pprint.pprint( - network_api.AddNetworkCredentials(user_name, password, path)) - elif '14' == val: - package_name = input_fn('Package Name: ') - pprint.pprint(network_api.GetDeploymentInfo(package_name)) - elif '15' == val: - val = network_api.IsPendingOSUpdate() - if val: - print('----> OS has a pending update.\n') - else: - print('----> OS does NOT have a pending update.\n') - else: - print('Unexpected answer: ' + val) - input_fn('press the return key to continue....') - - -if __name__ == '__main__': - InteractiveCommandLineMode() diff --git a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h index f3ac2e6a6f0e..13c2809c8518 100644 --- a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h +++ b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h @@ -2080,11 +2080,6 @@ inline int DoIsATTY(int fd) { return 1; } // only called for stdout inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } -#if SB_API_VERSION < 16 -inline int StrCaseCmp(const char* s1, const char* s2) { - return SbStringCompareNoCase(s1, s2); -} -#endif //SB_API_VERSION < 16 inline char* StrDup(const char* src) { return strdup(src); } inline int RmDir(const char* dir) { return rmdir(dir); } diff --git a/third_party/musl/BUILD.gn b/third_party/musl/BUILD.gn index c74465777685..78ecc77aac79 100644 --- a/third_party/musl/BUILD.gn +++ b/third_party/musl/BUILD.gn @@ -376,7 +376,6 @@ static_library("c_internal") { # Starboardized implementations "src/starboard/ctype/__ctype_get_mb_cur_max.c", - "src/starboard/errno/__errno_location.c", "src/starboard/exit/abort.c", "src/starboard/hwcap/sethwcap.c", "src/starboard/locale/freelocale.c", @@ -385,29 +384,13 @@ static_library("c_internal") { "src/starboard/locale/newlocale.c", "src/starboard/locale/setlocale.c", "src/starboard/locale/uselocale.c", - "src/starboard/malloc/malloc.c", - "src/starboard/malloc/posix_memalign.c", - "src/starboard/mman/mman.c", - "src/starboard/network/socket.c", - "src/starboard/pthread/pthread.c", - "src/starboard/sched/sched.c", "src/starboard/stdio/fflush.c", "src/starboard/stdio/fputc.c", "src/starboard/stdio/stderr.c", "src/starboard/stdio/stdout.c", "src/starboard/stdio/vfprintf.c", - "src/starboard/stdio/vsnprintf.c", - "src/starboard/stdio/vsscanf.c", - "src/starboard/stdio/vswprintf.c", "src/starboard/stdlib/strtod_l.c", - "src/starboard/sys/time/gettimeofday.c", - "src/starboard/dirent.c", "src/starboard/time/__tz.c", - "src/starboard/time/clock_gettime.c", - "src/starboard/time/gmtime_r.c", - "src/starboard/time/time.c", - "src/starboard/sys/stat.c", - "src/starboard/unistd/unistd.c", "src/stdio/__toread.c", "src/stdio/__uflow.c", "src/stdio/fprintf.c", diff --git a/third_party/musl/src/starboard/dirent.c b/third_party/musl/src/starboard/dirent.c deleted file mode 100644 index 448cea605993..000000000000 --- a/third_party/musl/src/starboard/dirent.c +++ /dev/null @@ -1,67 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include -#include -#include -#include "starboard/common/log.h" -#include "starboard/configuration_constants.h" -#include "starboard/directory.h" -#include "starboard/file.h" - -// copied from starboard/common/string.h -int strlcpy_dirent(char* dst, const char* src, int dst_size) { - for (int i = 0; i < dst_size; ++i) { - if ((dst[i] = src[i]) == 0) // We hit and copied the terminating NULL. - return i; - } - - // We were left off at dst_size. We over copied 1 byte. Null terminate. - if (dst_size != 0) - dst[dst_size - 1] = 0; - - // Count the rest of the |src|, and return its length in characters. - while (src[dst_size]) - ++dst_size; - return dst_size; -} - -struct __dirstream { - SbDirectory dir; -}; - -typedef struct __dirstream DIR; - -DIR* opendir(const char *path){ - SbDirectory result = SbDirectoryOpen(path, NULL); - if (result == kSbDirectoryInvalid){ - return NULL; - } - DIR* ret = (DIR*)(malloc(sizeof(DIR))); - ret->dir = result; - return ret; -} - -int closedir(DIR* dir){ - if (!dir || !dir->dir){ - return -1; - } - return SbDirectoryClose(dir->dir) ? 0 : -1; -} - -int readdir_r(DIR* dir, struct dirent* dirent_buf, struct dirent** dirent){ - if (!dir || !dir->dir || !dirent_buf || !dirent){ - dirent = NULL; - return -1; - } - - *dirent = dirent_buf; - if (SbDirectoryGetNext(dir->dir, (*dirent)->d_name, kSbFileMaxName)){ - return 0; - } - dirent = NULL; - return -1; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/errno/__errno_location.c b/third_party/musl/src/starboard/errno/__errno_location.c deleted file mode 100644 index 98be08a44fe6..000000000000 --- a/third_party/musl/src/starboard/errno/__errno_location.c +++ /dev/null @@ -1,48 +0,0 @@ -#if SB_API_VERSION < 16 -#include -#include - -#include "starboard/common/log.h" -#include "starboard/thread.h" -#include "../pthread/pthread.h" - -static pthread_key_t g_errno_key = 0; -static pthread_once_t g_errno_once = PTHREAD_ONCE_INIT; - -void initialize_errno_key(void) { - pthread_key_create(&g_errno_key , free); - SB_DCHECK(g_errno_key); -} - -// __errno_location() provides every thread with its own copy of |errno|. -// -// The first time __errno_location() is invoked it will initialize a global key. -// This key will then by used by every thread to set, and get, their instance of -// errno from thread-local storage. - -// This function does not take much effect in musl, use SbSystemGetLastError to set -// errno instead. -int *__errno_location(void) { - int result = pthread_once(&g_errno_once, &initialize_errno_key); - SB_DCHECK(result == 0); - - int* value = (int*)pthread_getspecific(g_errno_key); - - if (value) { - return value; - } - - value = (int*)malloc(sizeof(int)); - - SB_DCHECK(value); - result = pthread_setspecific(g_errno_key, value); - SB_DCHECK(result == 0); - - *value = 0; - - return value; -} - -weak_alias(__errno_location, ___errno_location); - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/malloc/malloc.c b/third_party/musl/src/starboard/malloc/malloc.c deleted file mode 100644 index 8f8e79cbf286..000000000000 --- a/third_party/musl/src/starboard/malloc/malloc.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -void *calloc(size_t m, size_t n) { - return SbMemoryCalloc(m, n); -} - -void free(void *p) { - SbMemoryDeallocate(p); -} - -void *malloc(size_t n) { - return SbMemoryAllocate(n); -} - -void *realloc(void *p, size_t n) { - return SbMemoryReallocate(p, n); -} - -weak_alias(calloc, __libc_calloc); -weak_alias(free, __libc_free); -weak_alias(malloc, __libc_malloc); -weak_alias(realloc, __libc_realloc); - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/malloc/posix_memalign.c b/third_party/musl/src/starboard/malloc/posix_memalign.c deleted file mode 100644 index fbff429a584e..000000000000 --- a/third_party/musl/src/starboard/malloc/posix_memalign.c +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -int posix_memalign(void **res, size_t align, size_t len) { - if (align < sizeof(void *)) return EINVAL; - void *mem = SbMemoryAllocateAligned(align, len); - // Note that the original posix_memalign() implementation returns errno here, - // set to either EINVAL (if the alignment argument is not a power of 2) or - // ENOMEM (if there was insufficient memory to fulfill the allocation - // request). These are also the two possible errors from memalign() when NULL - // is returned. errno can't be used here because it leaks __errno_location. - // Also, the Starboardized implementation of memalign() returns - // SbMemoryAllocateAligned(), whose behavior is undefined when the alignment - // is not a power of 2. So ENOMEM is returned here. - if (!mem) return ENOMEM; - *res = mem; - return 0; -} -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/mman/mman.c b/third_party/musl/src/starboard/mman/mman.c deleted file mode 100644 index c6e7dae152d5..000000000000 --- a/third_party/musl/src/starboard/mman/mman.c +++ /dev/null @@ -1,61 +0,0 @@ -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#if SB_API_VERSION < 16 -#include "starboard/memory.h" - -static SbMemoryMapFlags ToSbMemoryMapFlags(int prot) { - SbMemoryMapFlags sb_prot = kSbMemoryMapProtectReserved; - if (prot & PROT_READ) { - sb_prot |= kSbMemoryMapProtectRead; - } - if (prot & PROT_WRITE) { - sb_prot |= kSbMemoryMapProtectWrite; - } -#if SB_CAN(MAP_EXECUTABLE_MEMORY) - if (prot & PROT_EXEC) { - sb_prot |= kSbMemoryMapProtectExec; - } -#endif - - return sb_prot; -} - -void *mmap (void* addr, size_t len, int prot, int flags, int fd, off_t off) { - if (addr != NULL) { - return MAP_FAILED; - } - if (fd != -1) { - return MAP_FAILED; - } - void*p = SbMemoryMap(len , ToSbMemoryMapFlags(prot), "musl allocation"); - if (!p) { - return MAP_FAILED; - } - return p; -} - -int munmap (void* addr, size_t len) { - if (SbMemoryUnmap(addr, len)) { - return 0; - } - return -1; -} - -int mprotect (void* addr, size_t len, int prot) { - if (SbMemoryProtect(addr, len, ToSbMemoryMapFlags(prot))) { - return 0; - } - return -1; -} - -int msync (void * addr, size_t len, int flags) { - SbMemoryFlush(addr, len); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/network/socket.c b/third_party/musl/src/starboard/network/socket.c deleted file mode 100644 index a14e0cc0835e..000000000000 --- a/third_party/musl/src/starboard/network/socket.c +++ /dev/null @@ -1,959 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "starboard/common/log.h" -#include "starboard/file.h" -#include "starboard/socket.h" -#include "starboard/system.h" -#include "starboard/time.h" -#include "starboard/types.h" -#include "../pthread/pthread.h" - -// Internal database function to convert SbSocket/SbFile object to -// integer, i.e. POSIX file descriptor. -typedef struct FileOrSocket { - bool is_file; - SbFile file; - SbSocket socket; -} FileOrSocket; - -typedef struct Node { - int key; - struct FileOrSocket* value; - struct Node* next; -} Node; - -typedef struct HashMap { - int size; - Node** array; -} HashMap; - -static pthread_mutex_t lock; -static HashMap* map = NULL; -const int mapSize = 2048; -static int mapRecCount = 0; -const socklen_t kAddressLengthIpv4 = 4; -#if SB_HAS(IPV6) -const socklen_t kAddressLengthIpv6 = 16; -#endif -static int get(int key, bool take, FileOrSocket** valuePtr); - -static void createHashMap(int size) { - map = (HashMap*)malloc(sizeof(HashMap)); - memset(map, 0, sizeof(sizeof(HashMap))); - map->size = size; - map->array = (Node**)malloc(size * sizeof(Node*)); - memset(map->array, 0, size * sizeof(Node*)); -} - -static void destroyHashMap(void){ - if (map!= NULL){ - if (map->array!= NULL){ - free(map->array); - } - free(map); - } -} - -static int generateKey(void){ - static int key = 0; - key++; - if (key == 0x7FFFFFFF){ - key = 1; - } - return key; -} - -static int hash(int key, int size) { - return key % size; -} - -static int put(FileOrSocket* value) { - if (map == NULL) { - pthread_mutex_init(&lock, 0); - createHashMap(mapSize); - } - if (mapRecCount == mapSize){ - return -1; - } - - // avoid collision in map - FileOrSocket* valuePtr = NULL; - int key = generateKey(); - while (get(key, false, &valuePtr) == 0){ - key = generateKey(); - } - - pthread_mutex_lock(&lock); - - int index = hash(key, map->size); - Node* node = (Node*)malloc(sizeof(Node)); - node->key = key; - node->value = value; - node->next = map->array[index]; - map->array[index] = node; - mapRecCount++; - - pthread_mutex_unlock(&lock); - return key; -} - -static int get(int key, bool take, FileOrSocket** valuePtr) { - int index = 0; - int status = 0; - if (map == NULL) { - return -1; - } - - pthread_mutex_lock(&lock); - - index = hash(key, map->size); - Node* node = map->array[index]; - if (node != NULL) { - if (node->key == key) { - *valuePtr = node->value; - } - if (take){ - free(map->array[index]); - map->array[index] = NULL; - mapRecCount--; - } - status = 0; - } else { - status = -1; - } - - pthread_mutex_unlock(&lock); - - return status; -} - -static SB_C_FORCE_INLINE time_t WindowsUsecToTimeT(int64_t time) { - int64_t posix_time = time - 11644473600000000ULL; - posix_time = posix_time / 1000000; - return posix_time; -} - -int TranslateSocketErrnoSbToPosix(SbSocketError sbError) { - switch (sbError) { - case kSbSocketOk: - return 0; - case kSbSocketPending: - return EINPROGRESS; - case kSbSocketErrorConnectionReset: - return ECONNRESET; - case kSbSocketErrorFailed: - default: - return -1; - } -} - -int ConvertSocketAddressPosixToSb(const struct sockaddr* address, SbSocketAddress* sbAddress){ - if (address == NULL){ - errno = EINVAL; - return -1; - } - struct sockaddr_in* addr_in = (struct sockaddr_in*)address; - switch (addr_in->sin_family){ - case AF_INET: - sbAddress->type = kSbSocketAddressTypeIpv4; - memcpy(sbAddress->address, &addr_in->sin_addr, kAddressLengthIpv4); - break; -#if SB_HAS(IPV6) - case AF_INET6: - sbAddress->type = kSbSocketAddressTypeIpv6; - memcpy(sbAddress->address, &addr_in->sin_addr, kAddressLengthIpv6); - break; -#endif - } - sbAddress->port = addr_in->sin_port; - - return 0; -} - -int ConvertSocketAddressSbToPosix(const SbSocketAddress* sbAddress, struct sockaddr* address){ - if (sbAddress == NULL){ - errno = EINVAL; - return -1; - } - struct sockaddr_in* addr_in = (struct sockaddr_in*)address; - switch (sbAddress->type){ - case kSbSocketAddressTypeIpv4: - addr_in->sin_family = AF_INET; - memcpy(&addr_in->sin_addr, sbAddress->address, kAddressLengthIpv4); - break; -#if SB_HAS(IPV6) - case kSbSocketAddressTypeIpv6: - addr_in->sin_family = AF_INET6; - memcpy(&addr_in->sin_addr, sbAddress->address, kAddressLengthIpv6); - break; -#endif - default:{} - } - addr_in->sin_port = sbAddress->port; - - return 0; -} - -// The exported POSIX APIs -// -int fstat(int fildes, struct stat* buf) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - SbFileInfo info; - if (!SbFileGetInfo(fileOrSock->file, &info)) { - return -1; - } - - buf->st_mode = 0; - if (info.is_directory) { - buf->st_mode = S_IFDIR; - } else if (info.is_symbolic_link) { - buf->st_mode = S_IFLNK; - } - buf->st_ctime = WindowsUsecToTimeT(info.creation_time); - buf->st_atime = WindowsUsecToTimeT(info.last_accessed); - buf->st_mtime = WindowsUsecToTimeT(info.last_modified); - buf->st_size = info.size; - - return 0; -} - -int fsync(int fildes) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - int result = SbFileFlush(fileOrSock->file) ? 0 : -1; - return result; -} - -int ftruncate(int fildes, off_t length) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - int result = SbFileTruncate(fileOrSock->file, length) ? 0 : -1; - return result; -} - -off_t lseek(int fildes, off_t offset, int whence) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - - SbFileWhence sbWhence; - if (whence == SEEK_SET) { - sbWhence = kSbFileFromBegin; - } else if (whence == SEEK_CUR) { - sbWhence = kSbFileFromCurrent; - } else if (whence == SEEK_END) { - sbWhence = kSbFileFromEnd; - } else { - return -1; - } - return (off_t)SbFileSeek(fileOrSock->file, sbWhence, (int64_t)offset); -} - -int open(const char* path, int oflag, ...) { - bool out_created; - SbFileError out_error; - - if (path == NULL){ - errno = EINVAL; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = true; - - // Accept the flag without passing it on. Starboard implementations are - // assumed to deal with it. - if (oflag & O_LARGEFILE) { - oflag &= ~O_LARGEFILE; - } - - // Check if mode is specified. Mode is hard-coded to S_IRUSR | S_IWUSR in - // SbFileOpen. Any other modes are not supported. - if (oflag & O_CREAT) { - mode_t sb_file_mode = S_IRUSR | S_IWUSR; - va_list args; - va_start(args, oflag); - mode_t mode = va_arg(args, int); - if (mode != sb_file_mode) { - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - } - - int sb_file_flags = 0; - int access_mode_flag = 0; - - if ((oflag & O_ACCMODE) == O_RDONLY) { - access_mode_flag |= kSbFileRead; - } else if ((oflag & O_ACCMODE) == O_WRONLY) { - access_mode_flag |= kSbFileWrite; - oflag &= ~O_WRONLY; - } else if ((oflag & O_ACCMODE) == O_RDWR) { - access_mode_flag |= kSbFileRead | kSbFileWrite; - oflag &= ~O_RDWR; - } else { - // Applications shall specify exactly one of the first three file access - // modes. - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - - if (!oflag) { - sb_file_flags = kSbFileOpenOnly; - } - - if (oflag & O_CREAT && oflag & O_EXCL) { - sb_file_flags = kSbFileCreateOnly; - oflag &= ~(O_CREAT | O_EXCL); - } - if (oflag & O_CREAT && oflag & O_TRUNC) { - sb_file_flags = kSbFileCreateAlways; - oflag &= ~(O_CREAT | O_TRUNC); - } - if (oflag & O_CREAT) { - sb_file_flags = kSbFileOpenAlways; - oflag &= ~O_CREAT; - } - if (oflag & O_TRUNC) { - sb_file_flags = kSbFileOpenTruncated; - oflag &= ~O_TRUNC; - } - - // SbFileOpen does not support any other combination of flags. - if (oflag || !sb_file_flags) { - out_error = kSbFileErrorFailed; - errno = EINVAL; - return -1; - } - - int open_flags = sb_file_flags | access_mode_flag; - - value->file = SbFileOpen(path, open_flags, &out_created, &out_error); - if (!SbFileIsValid(value->file)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - int result = put(value); - if (result <= 0){ - errno = EBADF; - SbFileClose(value->file); - free(value); - } - return result; -} - -ssize_t read(int fildes, void* buf, size_t nbyte) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - return (ssize_t)SbFileRead(fileOrSock->file, buf, (int)nbyte); -} - -ssize_t write(int fildes, const void* buf, size_t nbyte) { - if (fildes < 0) { - errno = EBADF; - return -1; - } - - FileOrSocket* fileOrSock = NULL; - if (get(fildes, false, &fileOrSock) != 0) { - errno = EBADF; - return -1; - } - - if (fileOrSock == NULL || !fileOrSock->is_file) { - errno = EBADF; - return -1; - } - return (ssize_t)SbFileWrite(fileOrSock->file, buf, (int)nbyte); -} - -int socket(int domain, int type, int protocol){ - int address_type, socket_protocol; - switch (domain){ - case AF_INET: - address_type = kSbSocketAddressTypeIpv4; - break; - case AF_INET6: - address_type = kSbSocketAddressTypeIpv6; - break; - default: - errno = EAFNOSUPPORT; - return -1; - } - switch (protocol){ - case IPPROTO_TCP: - socket_protocol = kSbSocketProtocolTcp; - break; - case IPPROTO_UDP: - socket_protocol = kSbSocketProtocolUdp; - break; - default: - errno = EAFNOSUPPORT; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = false; - value->socket = SbSocketCreate(address_type, socket_protocol); - if (!SbSocketIsValid(value->socket)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - int result = put(value); - if (result <= 0){ - SbSocketDestroy(value->socket); - free(value); - } - return result; -} - -int close(int fd){ - if (fd <= 0) { - errno = EBADF; - return -1; - } - FileOrSocket* valueptr = NULL; - if (get(fd, true, &valueptr) != 0) { - errno = EBADF; - return -1; - } - if (valueptr != NULL) { - bool result = false; - if (valueptr->is_file == false){ - result = SbSocketDestroy(valueptr->socket); - } else { - result = SbFileClose(valueptr->file); - } - if (!result){ - errno = EBADF; - return -1; - } - return 0; - } - errno = EBADF; - return -1; -} - -int bind(int socket, const struct sockaddr* address, socklen_t address_len) { - if (address == NULL){ - errno = EINVAL; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (socket <= 0 || get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(address, &local_address); - - SbSocketError sbError = SbSocketBind(fileOrSock->socket, &local_address); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk) { - return 0; - } - return -1; -} - -int listen(int socket, int backlog) { - if (socket <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketError sbError = SbSocketListen(fileOrSock->socket); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk) { - return 0; - } - return -1; -} - -int accept(int socket, struct sockaddr* addr, socklen_t* addrlen) { - if (socket <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - FileOrSocket* value = (FileOrSocket*)malloc(sizeof(struct FileOrSocket)); - memset(value, 0, sizeof(struct FileOrSocket)); - value->is_file = false; - value->socket = SbSocketAccept(fileOrSock->socket); - if (!SbSocketIsValid(value->socket)){ - errno = SbSystemGetLastError(); - free(value); - return -1; - } - - return put(value); -} - -int connect(int socket, const struct sockaddr* name, socklen_t namelen) { - if (socket <= 0 || name == NULL){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(socket, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(name, &local_address); - - SbSocketError sbError = SbSocketConnect(fileOrSock->socket, &local_address); - errno = TranslateSocketErrnoSbToPosix(sbError); - - if (sbError == kSbSocketOk || sbError == kSbSocketPending) { - return 0; - } - return -1; -} - -ssize_t send(int sockfd, const void* buf, size_t len, int flags) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - int result = SbSocketSendTo(fileOrSock->socket, buf, len, NULL); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t sendto(int sockfd, const void* buf, size_t len, int flags, - const struct sockaddr* dest_addr, - socklen_t dest_len) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(dest_addr, &local_address); - - int result = SbSocketSendTo(fileOrSock->socket, buf, len, dest_addr == NULL? NULL: &local_address); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t recv(int sockfd, void* buf, size_t len, int flags) { - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - int result = SbSocketReceiveFrom(fileOrSock->socket, buf, len, NULL); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -ssize_t recvfrom(int sockfd, - void* buf, - size_t len, - int flags, - struct sockaddr* address, - socklen_t* address_len) { - if (sockfd <= 0){ - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - SbSocketAddress local_address = {0}; - ConvertSocketAddressPosixToSb(address, &local_address); - - int result = SbSocketReceiveFrom(fileOrSock->socket, buf, len, address == NULL? NULL: &local_address); - if(result == -1) { - errno = SbSystemGetLastError(); - } - - return result; -} - -int getsockname(int sockfd, struct sockaddr *restrict addr, socklen_t *restrict addrlen){ - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - SbSocketAddress out_address = {0}; - int result = SbSocketGetLocalAddress(fileOrSock->socket, &out_address)? 0: -1; - - struct sockaddr_in* addr_in = (struct sockaddr_in*)addr; - addr_in->sin_family = AF_INET; - addr_in->sin_addr.s_addr = out_address.address; - addr_in->sin_port = out_address.port; - *addrlen = sizeof(struct sockaddr_in); - - return result; -} - -int setsockopt (int sockfd, int level, int optname, const void* optval, - socklen_t optlen){ - if (sockfd <= 0){ - errno = EBADF; - return -1; - } - FileOrSocket *fileOrSock = NULL; - if (get(sockfd, false, &fileOrSock) != 0){ - errno = EBADF; - return -1; - } - if (fileOrSock == NULL || fileOrSock->is_file == true) { - errno = EBADF; - return -1; - } - - if (level == SOL_SOCKET || level == SOL_TCP || level == IPPROTO_TCP || level == IPPROTO_IP) { - int* operation = (int*)optval; - switch (optname){ - case SO_BROADCAST:{ - bool bool_value = (*operation == 1)? true:false; - return SbSocketSetBroadcast(fileOrSock->socket, bool_value) == true? 0:-1; - } - case SO_REUSEADDR:{ - bool bool_value = *operation == 1? true:false; - return SbSocketSetReuseAddress(fileOrSock->socket, bool_value) == true? 0:-1; - } - case SO_RCVBUF:{ - return SbSocketSetReuseAddress(fileOrSock->socket, *operation) == true? 0:-1; - } - case SO_SNDBUF:{ - return SbSocketSetSendBufferSize(fileOrSock->socket, *operation) == true? 0:-1; - } - case SO_KEEPALIVE:{ - bool bool_value = *operation == 1? true:false; - if (bool_value == false){ - return SbSocketSetTcpKeepAlive(fileOrSock->socket, false, 0) == true? 0:-1; - } - } - case TCP_KEEPIDLE:{ - /* function SbSocketSetTcpKeepAlive() also calls setsockopt() with operation code - TCP_KEEPINTVL. Therefore there is not need to take care of case TCP_KEEPINTVL - separately.*/ - if (*operation > 0){ - SbTime period_microsecond = *operation; - period_microsecond *= 1000000; - return SbSocketSetTcpKeepAlive(fileOrSock->socket, true, period_microsecond) == true? 0:-1; - } - break; - } - case TCP_KEEPINTVL:{ - /* function SbSocketSetTcpKeepAlive() also calls setsockopt() with operation code - TCP_KEEPINTVL. Therefore there is not need to take care of case TCP_KEEPINTVL - separately when TCP_KEEPIDLE is set.*/ - break; - return 0; - } - case TCP_NODELAY: { - bool bool_value = *operation == 1? true:false; - return SbSocketSetTcpNoDelay(fileOrSock->socket, bool_value) == true? 0:-1; - } - case IP_ADD_MEMBERSHIP: { - if (optval == NULL) { - errno = EFAULT; - return -1; - } - const struct ip_mreq* imreq = (const struct ip_mreq*)optval; - SbSocketAddress* addr = (SbSocketAddress*)malloc(sizeof(SbSocketAddress)); - memcpy(addr->address, &(imreq->imr_multiaddr.s_addr), sizeof(imreq->imr_multiaddr.s_addr)); - - return SbSocketJoinMulticastGroup(fileOrSock->socket, addr) == true? 0:-1; - } - default: - return -1; - } - } else { - return -1; - } - - return 0; -} - -int fcntl(int fd, int cmd, ... /*arg*/) { - if (fd <= 0){ - return -1; - } - /* This function was used to set socket non-blocking, - * however since SbSocketCreate() sets the socket to - * non-blocking by default, we don't need to set it again.*/ - return 0; -} - -void freeaddrinfo(struct addrinfo *ai) -{ - struct addrinfo* ptr = ai; - while (ai != NULL){ - if (ai->ai_addr != NULL){ - free(ai->ai_addr); - } - ai = ai->ai_next; - free(ptr); - ptr = ai; - } -} - -int getaddrinfo(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res) -{ - int filters = 0; - if (hints != NULL){ - if (hints->ai_family == AF_INET) { - filters = kSbSocketResolveFilterIpv4; - } - else if (hints->ai_family == AF_INET6) { - filters = kSbSocketResolveFilterIpv6; - } - else if (hints->ai_family == AF_UNSPEC) { - filters = kSbSocketResolveFilterIpv6 & kSbSocketResolveFilterIpv4; - } - else { - return -1; - } - } - - SbSocketResolution* sbSockResolve = SbSocketResolve(node, filters); - if (sbSockResolve == NULL){ - return -1; - } - - struct addrinfo* ai = (struct addrinfo*)malloc(sizeof(struct addrinfo)); - memset(ai, 0, sizeof(struct addrinfo)); - *res = ai; - - for(int i = 0; i < sbSockResolve->address_count; i++){ - ai->ai_addr = (struct sockaddr*)malloc(sizeof(struct sockaddr)); - memset(ai->ai_addr, 0, sizeof(struct sockaddr)); - ConvertSocketAddressSbToPosix( &sbSockResolve->addresses[i], ai->ai_addr); - ai->ai_addrlen = sizeof(struct sockaddr); - - if (sbSockResolve->addresses[i].type == kSbSocketAddressTypeIpv4) { - ai->ai_family = AF_INET; - } -#if SB_HAS(IPV6) - if (sbSockResolve->addresses[i].type == kSbSocketAddressTypeIpv6) { - ai->ai_family = AF_INET6; - } -#endif - if (i < sbSockResolve->address_count - 1){ - ai->ai_next = (struct addrinfo*)malloc(sizeof(struct addrinfo)); - memset(ai->ai_next, 0, sizeof(struct addrinfo)); - ai = ai->ai_next; - } - } - - SbSocketFreeResolution(sbSockResolve); - return 0; -} - -void freeifaddrs(struct ifaddrs* ifa){ - struct ifaddrs* ptr = ifa; - while (ifa != NULL){ - if (ifa->ifa_addr != NULL){ - free(ifa->ifa_addr); - } - ifa = ifa->ifa_next; - free(ptr); - ptr = ifa; - } -} - -int getifaddrs(struct ifaddrs** ifap) { - - SbSocketAddress sbAddress = {0}; - if (!SbSocketGetInterfaceAddress(NULL, &sbAddress, NULL)){ - return -1; - } - - *ifap = (struct ifaddrs*)malloc(sizeof(struct ifaddrs)); - memset(*ifap, 0, sizeof(struct ifaddrs)); - struct ifaddrs* ifa = *ifap; - ifa->ifa_addr = (struct sockaddr*)malloc(sizeof(struct sockaddr)); - memset(ifa->ifa_addr, 0, sizeof(struct sockaddr)); - ConvertSocketAddressSbToPosix(&sbAddress, ifa->ifa_addr); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/pthread/pthread.c b/third_party/musl/src/starboard/pthread/pthread.c deleted file mode 100644 index 369ed1075984..000000000000 --- a/third_party/musl/src/starboard/pthread/pthread.c +++ /dev/null @@ -1,262 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "third_party/musl/src/starboard/pthread/pthread.h" - -#include - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "starboard/condition_variable.h" -#include "starboard/mutex.h" -#include "starboard/once.h" -#include "starboard/time.h" - -typedef struct pthread_attr_impl_t { - size_t stack_size; - int detach_state; -} pthread_attr_impl_t; - -int pthread_mutex_init(pthread_mutex_t* mutext, const pthread_mutexattr_t*) { - if (SbMutexCreate((SbMutex*)mutext->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_lock(pthread_mutex_t* mutex) { - SbMutexResult result = SbMutexAcquire((SbMutex*)mutex->mutex_buffer); - if (result == kSbMutexAcquired) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_unlock(pthread_mutex_t* mutex) { - if (SbMutexRelease((SbMutex*)mutex->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_trylock(pthread_mutex_t* mutex) { - SbMutexResult result = SbMutexAcquireTry((SbMutex*)mutex->mutex_buffer); - if (result == kSbMutexAcquired) { - return 0; - } - return EINVAL; -} - -int pthread_mutex_destroy(pthread_mutex_t* mutex) { - if (SbMutexDestroy((SbMutex*)mutex->mutex_buffer)) { - return 0; - } - return EINVAL; -} - -int pthread_cond_broadcast(pthread_cond_t* cond) { - return SbConditionVariableBroadcast((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_destroy(pthread_cond_t* cond) { - return SbConditionVariableDestroy((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr) { - return SbConditionVariableCreate((SbConditionVariable*)cond->cond_buffer, - NULL /* mutex */) - ? 0 - : -1; -} - -int pthread_cond_signal(pthread_cond_t* cond) { - return SbConditionVariableSignal((SbConditionVariable*)cond->cond_buffer) - ? 0 - : -1; -} - -int pthread_cond_timedwait(pthread_cond_t* cond, - pthread_mutex_t* mutex, - const struct timespec* t) { - SbTimeMonotonic now = SbTimeGetMonotonicNow(); - int64_t timeout_duration_microsec = t->tv_sec * 1000000 + t->tv_nsec / 1000; - timeout_duration_microsec -= now; - SbConditionVariableResult result = SbConditionVariableWaitTimed( - (SbConditionVariable*)cond->cond_buffer, (SbMutex*)mutex->mutex_buffer, - timeout_duration_microsec); - if (result == kSbConditionVariableSignaled) { - return 0; - } else if (result == kSbConditionVariableTimedOut) { - return ETIMEDOUT; - } - return -1; -} - -int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex) { - SbConditionVariableResult result = SbConditionVariableWait( - (SbConditionVariable*)cond->cond_buffer, (SbMutex*)mutex->mutex_buffer); - if (result == kSbConditionVariableSignaled) { - return 0; - } - return -1; -} - -int pthread_condattr_destroy(pthread_condattr_t* attr) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_init(pthread_condattr_t* attr) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_getclock(const pthread_condattr_t* attr, - clockid_t* clock_id) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock_id) { - // Not supported in Starboard 14/15 - SB_DCHECK(false); - return -1; -} - -int pthread_once(pthread_once_t* once_control, void (*init_routine)(void)) { - return SbOnce((SbOnceControl*)once_control->once_buffer, init_routine) ? 0 - : -1; -} - -int pthread_create(pthread_t* thread, - const pthread_attr_t* attr, - void* (*start_routine)(void*), - void* arg) { - int stack_size = 0; - bool joinable = true; - if (attr != NULL) { - stack_size = ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size; - if ((((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state == - PTHREAD_CREATE_DETACHED)) { - joinable = false; - } - } - - SbThread starboard_thread = - SbThreadCreate(stack_size, kSbThreadNoPriority, kSbThreadNoAffinity, - joinable, NULL, start_routine, arg); - if (SbThreadIsValid(thread)) { - *thread = starboard_thread; - return 0; - } - return EINVAL; -} - -int pthread_join(pthread_t thread, void** value_ptr) { - return SbThreadJoin(thread, value_ptr) ? 0 : EINVAL; -} - -int pthread_detach(pthread_t thread) { - SbThreadDetach(thread); - return 0; -} - -pthread_t pthread_self() { - return SbThreadGetCurrent(); -} - -int pthread_equal(pthread_t t1, pthread_t t2) { - return SbThreadIsEqual(t1, t2); -} - -int pthread_key_create(pthread_key_t* key, void (*destructor)(void*)) { - SbThreadLocalKey sb_key = SbThreadCreateLocalKey(destructor); - if (SbThreadIsValidLocalKey(sb_key)) { - *key = sb_key; - return 0; - } - return -1; -} - -int pthread_key_delete(pthread_key_t key) { - SbThreadDestroyLocalKey((SbThreadLocalKey)key); - return 0; -} - -void* pthread_getspecific(pthread_key_t key) { - return SbThreadGetLocalValue((SbThreadLocalKey)key); -} - -int pthread_setspecific(pthread_key_t key, const void* value) { - return SbThreadSetLocalValue((SbThreadLocalKey)key, value) ? 0 : -1; -} - -int pthread_setname_np(pthread_t thread, const char* name) { - // Starboard 14/15 can only set thread name for the current thread - if (SbThreadGetCurrent() != thread) { - SB_DCHECK(false); - return -1; - } - SbThreadSetName(name); - return 0; -} - -int pthread_getname_np(pthread_t thread, char* name, size_t len) { - // Starboard 14/15 can only get the thread name for the current thread - if (SbThreadGetCurrent() != thread) { - SB_DCHECK(false); - return -1; - } - SbThreadGetName(name, len); - return 0; -} - -int pthread_attr_init(pthread_attr_t* attr) { - memset(attr, 0, sizeof(pthread_attr_t)); - return 0; -} - -int pthread_attr_destroy(pthread_attr_t* attr) { - return 0; -} - -int pthread_attr_getstacksize(const pthread_attr_t* attr, size_t* stack_size) { - *stack_size = ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size; - return 0; -} - -int pthread_attr_setstacksize(pthread_attr_t* attr, size_t stack_size) { - ((pthread_attr_impl_t*)(attr->attr_buffer))->stack_size = stack_size; - return 0; -} - -int pthread_attr_getdetachstate(const pthread_attr_t* attr, int* detach_state) { - *detach_state = ((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state; - return 0; -} - -int pthread_attr_setdetachstate(pthread_attr_t* attr, int detach_state) { - ((pthread_attr_impl_t*)(attr->attr_buffer))->detach_state = detach_state; - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/sched/sched.c b/third_party/musl/src/starboard/sched/sched.c deleted file mode 100644 index 1fe6d369f4df..000000000000 --- a/third_party/musl/src/starboard/sched/sched.c +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include - -#include "starboard/thread.h" - -int sched_yield() { - SbThreadYield(); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/stdio/vsnprintf.c b/third_party/musl/src/starboard/stdio/vsnprintf.c deleted file mode 100644 index b2be99b3763e..000000000000 --- a/third_party/musl/src/starboard/stdio/vsnprintf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "starboard/string.h" - -#if SB_API_VERSION < 16 - -int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { - return SbStringFormat(s, n, fmt, ap); -} - -#endif diff --git a/third_party/musl/src/starboard/stdio/vsscanf.c b/third_party/musl/src/starboard/stdio/vsscanf.c deleted file mode 100644 index e84ba5097c67..000000000000 --- a/third_party/musl/src/starboard/stdio/vsscanf.c +++ /dev/null @@ -1,10 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include "starboard/string.h" - -int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap) { - return SbStringScan(s, fmt, ap); -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/stdio/vswprintf.c b/third_party/musl/src/starboard/stdio/vswprintf.c deleted file mode 100644 index a9f932f0b285..000000000000 --- a/third_party/musl/src/starboard/stdio/vswprintf.c +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include "starboard/string.h" - -#if SB_API_VERSION < 16 - -int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap) { - return SbStringFormatWide(s, n, fmt, ap); -} - -#endif diff --git a/third_party/musl/src/starboard/sys/stat.c b/third_party/musl/src/starboard/sys/stat.c deleted file mode 100644 index 81da1b228d2f..000000000000 --- a/third_party/musl/src/starboard/sys/stat.c +++ /dev/null @@ -1,56 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include -#include - -#include -#include -#include "starboard/directory.h" - -int mkdir(const char *path, mode_t mode) -{ - if (SbDirectoryCreate(path)){ - return 0; - } - return -1; -} - -// Reverse implementation of TimeTToWindowsUsec and PosixTimeToWindowsTime for backwards compatibility -// TimeTToWindowsUsec converts to microseconds (*1000000) and then calls PosixTimeToWindowsTime -// PosixTimeToWindows time adds number of microseconds since Jan 1, 1601 (UTC) until Jan 1, 1970 (UTC) -static SB_C_FORCE_INLINE time_t WindowsUsecToTimeT(int64_t time) { - int64_t posix_time = time - 11644473600000000ULL; - posix_time = posix_time / 1000000; - return posix_time; -} - -// SbDirectoryCanOpen, SbFileGetPathInfo, SbFileExists, SbFileCanOpen -int stat(const char *path, struct stat *file_info) -{ - if(!SbFileExists(path)) { - errno = ENOENT; - } - - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)){ - return -1; - } - - // In SB_API_VERSION < 16, all files are opened with S_IRUSR | S_IWUSR. - // See starboard/shared/posix/impl/file_open.h. - file_info->st_mode = S_IRUSR | S_IWUSR; - if (out_info.is_directory){ - file_info->st_mode |= S_IFDIR; - } else if (out_info.is_symbolic_link){ - file_info->st_mode |= S_IFLNK; - } - - file_info->st_ctime = WindowsUsecToTimeT(out_info.creation_time); - file_info->st_atime = WindowsUsecToTimeT(out_info.last_accessed); - file_info->st_mtime = WindowsUsecToTimeT(out_info.last_modified); - file_info->st_size = out_info.size; - - return 0; -} -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/sys/time/gettimeofday.c b/third_party/musl/src/starboard/sys/time/gettimeofday.c deleted file mode 100644 index 84e1ab7797fc..000000000000 --- a/third_party/musl/src/starboard/sys/time/gettimeofday.c +++ /dev/null @@ -1,22 +0,0 @@ -#if SB_API_VERSION < 16 - -#include -#include -#include - -#include "starboard/time.h" - -int gettimeofday(struct timeval* tp, void* tzp) { - if (tp == NULL) { - return -1; - } - - int64_t windows_time_micros = SbTimeGetNow(); - // Handle number of microseconds btw Jan 1, 1601 (UTC) and Jan 1, 1970 (UTC). - int64_t posix_time_micros = windows_time_micros - 11644473600000000ULL; - tp->tv_sec = (time_t)(posix_time_micros / 1000000); - tp->tv_usec = (suseconds_t)(posix_time_micros % 1000000); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/clock_gettime.c b/third_party/musl/src/starboard/time/clock_gettime.c deleted file mode 100644 index 54f2b49e25e0..000000000000 --- a/third_party/musl/src/starboard/time/clock_gettime.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -#if SB_API_VERSION < 16 - -#include "starboard/common/log.h" -#include "starboard/time.h" - -// Note that with the original musl implementation of clock_gettime(), errno is -// set when -1 is returned; specific errors are not set here. -int clock_gettime(clockid_t clk, struct timespec *ts) { - // There are only Starboard implementations for monotonic and realtime clocks. - // Starboard does also have SbTimeGetMonotonicThreadNow() for - // CLOCK_PROCESS_CPUTIME_ID, but its definition is wrapped in - // #if SB_HAS(TIME_THREAD_NOW) so it can't be used here. - // CLOCK_PROCESS_CPUTIME_ID is potentially used by Cobalt though, so -1 will - // be returned to indicate a failure instead of crashing with this DCHECK. - SB_DCHECK((clk == CLOCK_MONOTONIC) || (clk == CLOCK_REALTIME) || - (clk == CLOCK_PROCESS_CPUTIME_ID)); - - if (clk == CLOCK_MONOTONIC) { - SbTimeMonotonic t = SbTimeGetMonotonicNow(); - if (t == 0) return -1; - - ts->tv_sec = t / kSbTimeSecond; - ts->tv_nsec = (t % kSbTimeSecond) * kSbTimeNanosecondsPerMicrosecond; - return 0; - } else if (clk == CLOCK_REALTIME) { - SbTime t = SbTimeGetNow(); - if (t == 0) return -1; - - ts->tv_sec = t / kSbTimeSecond; - ts->tv_nsec = (t % kSbTimeSecond) * kSbTimeNanosecondsPerMicrosecond; - return 0; - } else { - return -1; - } -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/gmtime_r.c b/third_party/musl/src/starboard/time/gmtime_r.c deleted file mode 100644 index 7e89690add12..000000000000 --- a/third_party/musl/src/starboard/time/gmtime_r.c +++ /dev/null @@ -1,28 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include "starboard/client_porting/eztime/eztime.h" - -struct tm *gmtime_r(const time_t *restrict t, struct tm *restrict tm) { - if (!t || !tm) { - return NULL; - } - EzTimeT ezt = (EzTimeT)*t; - EzTimeExploded ezte; - if (EzTimeTExplodeUTC(&ezt, &ezte) == NULL) { - return NULL; - } - tm->tm_sec = ezte.tm_sec; - tm->tm_min = ezte.tm_min; - tm->tm_hour = ezte.tm_hour; - tm->tm_mday = ezte.tm_mday; - tm->tm_mon = ezte.tm_mon; - tm->tm_year = ezte.tm_year; - tm->tm_wday = ezte.tm_wday; - tm->tm_yday = ezte.tm_yday; - tm->tm_isdst = ezte.tm_isdst; - return tm; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/time/time.c b/third_party/musl/src/starboard/time/time.c deleted file mode 100644 index da7654d49c5c..000000000000 --- a/third_party/musl/src/starboard/time/time.c +++ /dev/null @@ -1,18 +0,0 @@ -#if SB_API_VERSION < 16 - -#include - -#include "starboard/time.h" - -time_t time(time_t *t) { - int64_t posix_us = SbTimeToPosix(SbTimeGetNow()); - int64_t posix_s = posix_us >= 0 ? posix_us / 1000000 - : (posix_us - 1000000 + 1) / 1000000; - time_t time_s = (time_t)posix_s; - if (t) { - *t = time_s; - } - return time_s; -} - -#endif // SB_API_VERSION < 16 diff --git a/third_party/musl/src/starboard/unistd/unistd.c b/third_party/musl/src/starboard/unistd/unistd.c deleted file mode 100644 index 20b36eafcb28..000000000000 --- a/third_party/musl/src/starboard/unistd/unistd.c +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2024 The Cobalt Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#if SB_API_VERSION < 16 -#include - -#include "starboard/file.h" -#include "starboard/thread.h" - -int rmdir(const char* path) { - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)) { - return -1; - } - int result = SbFileDelete(path) ? 0 : -1; - return result; -} - -int unlink(const char* path) { - SbFileInfo out_info; - if (!SbFileGetPathInfo(path, &out_info)) { - return -1; - } - int result = SbFileDelete(path) ? 0 : -1; - return result; -} - -int usleep(useconds_t useconds) { - SbThreadSleep(useconds); - return 0; -} - -#endif // SB_API_VERSION < 16 diff --git a/v8/src/base/platform/condition-variable.cc b/v8/src/base/platform/condition-variable.cc index 31cfbc01ea28..39be28376f02 100644 --- a/v8/src/base/platform/condition-variable.cc +++ b/v8/src/base/platform/condition-variable.cc @@ -166,9 +166,6 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { #elif V8_OS_STARBOARD ConditionVariable::ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableCreate(&native_handle_, nullptr); -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) pthread_condattr_t attribute; pthread_condattr_init(&attribute); @@ -182,49 +179,25 @@ ConditionVariable::ConditionVariable() { int result = pthread_cond_init(&native_handle_, nullptr); DCHECK(result == 0); #endif // !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) -#endif // SB_API_VERSION < 16 } ConditionVariable::~ConditionVariable() { -#if SB_API_VERSION < 16 - SbConditionVariableDestroy(&native_handle_); -#else pthread_cond_destroy(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::NotifyOne() { -#if SB_API_VERSION < 16 - SbConditionVariableSignal(&native_handle_); -#else pthread_cond_signal(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::NotifyAll() { -#if SB_API_VERSION < 16 - SbConditionVariableBroadcast(&native_handle_); -#else pthread_cond_broadcast(&native_handle_); -#endif // SB_API_VERSION < 16 } void ConditionVariable::Wait(Mutex* mutex) { -#if SB_API_VERSION < 16 - SbConditionVariableWait(&native_handle_, &mutex->native_handle()); -#else pthread_cond_wait(&native_handle_, &mutex->native_handle()); -#endif // SB_API_VERSION < 16 } bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { -#if SB_API_VERSION < 16 - int64_t microseconds = static_cast(rel_time.InMicroseconds()); - SbConditionVariableResult result = SbConditionVariableWaitTimed( - &native_handle_, &mutex->native_handle(), microseconds); - DCHECK(result != kSbConditionVariableFailed); - return result == kSbConditionVariableSignaled; -#else #if !SB_HAS_QUIRK(NO_CONDATTR_SETCLOCK_SUPPORT) int64_t timeout_time_usec = starboard::CurrentMonotonicTime(); #else @@ -238,7 +211,6 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { int result = pthread_cond_timedwait(&native_handle_, &mutex->native_handle(), &delay_timestamp); return result == 0; -#endif // SB_API_VERSION < 16 } #endif // V8_OS_STARBOARD diff --git a/v8/src/base/platform/condition-variable.h b/v8/src/base/platform/condition-variable.h index bc1740f1d412..d3737ece34f7 100644 --- a/v8/src/base/platform/condition-variable.h +++ b/v8/src/base/platform/condition-variable.h @@ -10,11 +10,7 @@ #include "src/base/platform/mutex.h" #if V8_OS_STARBOARD -#if SB_API_VERSION < 16 -#include "starboard/condition_variable.h" -#else #include -#endif // SB_API_VERSION < 16 #endif namespace v8 { @@ -75,11 +71,7 @@ class V8_BASE_EXPORT ConditionVariable final { #elif V8_OS_WIN using NativeHandle = CONDITION_VARIABLE; #elif V8_OS_STARBOARD -#if SB_API_VERSION < 16 - using NativeHandle = SbConditionVariable; -#else using NativeHandle = pthread_cond_t; -#endif // SB_API_VERSION < 16 #endif NativeHandle& native_handle() { diff --git a/v8/src/base/platform/mutex.cc b/v8/src/base/platform/mutex.cc index f62a82a94f65..45f45b193d1a 100644 --- a/v8/src/base/platform/mutex.cc +++ b/v8/src/base/platform/mutex.cc @@ -297,35 +297,19 @@ bool SharedMutex::TryLockExclusive() { #elif V8_OS_STARBOARD Mutex::Mutex() { -#if SB_API_VERSION < 16 - SbMutexCreate(&native_handle_); -#else pthread_mutex_init(&native_handle_, nullptr); -#endif } Mutex::~Mutex() { -#if SB_API_VERSION < 16 - SbMutexDestroy(&native_handle_); -#else pthread_mutex_destroy(&native_handle_); -#endif } void Mutex::Lock() { -#if SB_API_VERSION < 16 - SbMutexAcquire(&native_handle_); -#else pthread_mutex_lock(&native_handle_); -#endif } void Mutex::Unlock() { -#if SB_API_VERSION < 16 - SbMutexRelease(&native_handle_); -#else pthread_mutex_unlock(&native_handle_); -#endif } RecursiveMutex::RecursiveMutex() {} diff --git a/v8/src/base/platform/mutex.h b/v8/src/base/platform/mutex.h index 60e58ed73ef3..d3bf739097c6 100644 --- a/v8/src/base/platform/mutex.h +++ b/v8/src/base/platform/mutex.h @@ -68,11 +68,7 @@ class V8_BASE_EXPORT Mutex final { #elif V8_OS_WIN using NativeHandle = SRWLOCK; #elif V8_OS_STARBOARD -#if SB_API_VERSION < 16 - using NativeHandle = SbMutex; -#else using NativeHandle = pthread_mutex_t; -#endif // SB_API_VERSION < 16 #endif NativeHandle& native_handle() { diff --git a/v8/src/libsampler/sampler.cc b/v8/src/libsampler/sampler.cc index a0007f9e53de..e29d2d80f869 100644 --- a/v8/src/libsampler/sampler.cc +++ b/v8/src/libsampler/sampler.cc @@ -176,11 +176,7 @@ namespace sampler { class Sampler::PlatformData { public: PlatformData() -#if SB_API_VERSION < 16 - : thread_(SbThreadGetCurrent()), -#else : thread_(pthread_self()), -#endif thread_sampler_(kSbThreadSamplerInvalid) {} ~PlatformData() { ReleaseThreadSampler(); } @@ -199,11 +195,7 @@ class Sampler::PlatformData { } private: -#if SB_API_VERSION < 16 - SbThread thread_; -#else pthread_t thread_; -#endif SbThreadSampler thread_sampler_; };