mirror of
https://github.com/void-linux/void-packages.git
synced 2025-04-22 17:17:03 +02:00
New package: electron24-24.2.0
This commit is contained in:
parent
7126d3f3e7
commit
c9843a75eb
64 changed files with 4800 additions and 0 deletions
|
@ -0,0 +1,125 @@
|
|||
Source: https://git.alpinelinux.org/aports/tree/community/chromium/musl-sandbox.patch
|
||||
musl uses different syscalls from glibc for some functions, so the sandbox has
|
||||
to account for that
|
||||
--
|
||||
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
|
||||
index ff5a1c0..da56b9b 100644
|
||||
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
|
||||
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
|
||||
@@ -139,21 +139,11 @@ namespace sandbox {
|
||||
// present (as in newer versions of posix_spawn).
|
||||
ResultExpr RestrictCloneToThreadsAndEPERMFork() {
|
||||
const Arg<unsigned long> flags(0);
|
||||
-
|
||||
- // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2.
|
||||
- const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES |
|
||||
- CLONE_SIGHAND | CLONE_THREAD |
|
||||
- CLONE_SYSVSEM;
|
||||
- const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED;
|
||||
-
|
||||
- const uint64_t kGlibcPthreadFlags =
|
||||
- CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
|
||||
- CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
|
||||
- const BoolExpr glibc_test = flags == kGlibcPthreadFlags;
|
||||
-
|
||||
- const BoolExpr android_test =
|
||||
- AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask,
|
||||
- flags == kGlibcPthreadFlags);
|
||||
+ const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
|
||||
+ CLONE_THREAD | CLONE_SYSVSEM;
|
||||
+ const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
|
||||
+ CLONE_DETACHED;
|
||||
+ const BoolExpr thread_clone_ok = (flags&~safe)==required;
|
||||
|
||||
// The following two flags are the two important flags in any vfork-emulating
|
||||
// clone call. EPERM any clone call that contains both of them.
|
||||
@@ -163,7 +153,7 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
|
||||
AnyOf((flags & (CLONE_VM | CLONE_THREAD)) == 0,
|
||||
(flags & kImportantCloneVforkFlags) == kImportantCloneVforkFlags);
|
||||
|
||||
- return If(IsAndroid() ? android_test : glibc_test, Allow())
|
||||
+ return If(thread_clone_ok, Allow())
|
||||
.ElseIf(is_fork_or_clone_vfork, Error(EPERM))
|
||||
.Else(CrashSIGSYSClone());
|
||||
}
|
||||
diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
|
||||
index d9d1882..0567557 100644
|
||||
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
|
||||
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
|
||||
@@ -392,6 +392,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
|
||||
#if defined(__i386__)
|
||||
case __NR_waitpid:
|
||||
#endif
|
||||
+ case __NR_set_tid_address:
|
||||
return true;
|
||||
case __NR_clone: // Should be parameter-restricted.
|
||||
case __NR_setns: // Privileged.
|
||||
@@ -404,7 +405,6 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
|
||||
case __NR_set_thread_area:
|
||||
#endif
|
||||
- case __NR_set_tid_address:
|
||||
case __NR_unshare:
|
||||
#if !defined(__mips__) && !defined(__aarch64__)
|
||||
case __NR_vfork:
|
||||
@@ -514,6 +514,8 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
|
||||
case __NR_mlock:
|
||||
case __NR_munlock:
|
||||
case __NR_munmap:
|
||||
+ case __NR_mremap:
|
||||
+ case __NR_membarrier:
|
||||
return true;
|
||||
case __NR_madvise:
|
||||
case __NR_mincore:
|
||||
@@ -531,7 +533,6 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
|
||||
case __NR_modify_ldt:
|
||||
#endif
|
||||
case __NR_mprotect:
|
||||
- case __NR_mremap:
|
||||
case __NR_msync:
|
||||
case __NR_munlockall:
|
||||
case __NR_readahead:
|
||||
diff --git a/sandbox/linux/system_headers/linux_syscalls.h ./sandbox/linux/system_headers/linux_syscalls.h
|
||||
index 2b78a0c..b6fedb5 100644
|
||||
--- a/sandbox/linux/system_headers/linux_syscalls.h
|
||||
+++ b/sandbox/linux/system_headers/linux_syscalls.h
|
||||
@@ -10,6 +10,7 @@
|
||||
#define SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
|
||||
|
||||
#include "build/build_config.h"
|
||||
+#include <sys/syscall.h>
|
||||
|
||||
#if defined(__x86_64__)
|
||||
#include "sandbox/linux/system_headers/x86_64_linux_syscalls.h"
|
||||
--- a/sandbox/policy/linux/bpf_renderer_policy_linux.cc
|
||||
+++ b/sandbox/policy/linux/bpf_renderer_policy_linux.cc
|
||||
@@ -94,6 +94,9 @@
|
||||
case __NR_pwrite64:
|
||||
case __NR_sched_get_priority_max:
|
||||
case __NR_sched_get_priority_min:
|
||||
+ case __NR_sched_getparam:
|
||||
+ case __NR_sched_getscheduler:
|
||||
+ case __NR_sched_setscheduler:
|
||||
case __NR_sysinfo:
|
||||
case __NR_times:
|
||||
case __NR_uname:
|
||||
--- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
|
||||
+++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
|
||||
@@ -225,10 +225,15 @@
|
||||
if (sysno == __NR_getpriority || sysno ==__NR_setpriority)
|
||||
return RestrictGetSetpriority(current_pid);
|
||||
|
||||
+ // XXX: hacks for musl sandbox, calls needed?
|
||||
+ if (sysno == __NR_sched_getparam || sysno == __NR_sched_getscheduler ||
|
||||
+ sysno == __NR_sched_setscheduler) {
|
||||
+ return Allow();
|
||||
+ }
|
||||
+
|
||||
// The scheduling syscalls are used in threading libraries and also heavily in
|
||||
// abseil. See for example https://crbug.com/1370394.
|
||||
- if (sysno == __NR_sched_getaffinity || sysno == __NR_sched_getparam ||
|
||||
- sysno == __NR_sched_getscheduler || sysno == __NR_sched_setscheduler) {
|
||||
+ if (sysno == __NR_sched_getaffinity) {
|
||||
return RestrictSchedTarget(current_pid, sysno);
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
Source: https://git.alpinelinux.org/aports/plain/community/chromium/musl-tid-caching.patch
|
||||
the sandbox caching of thread id's only works with glibc
|
||||
see: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/32356
|
||||
see: https://gitlab.alpinelinux.org/alpine/aports/-/issues/13579
|
||||
--
|
||||
--- a/sandbox/linux/services/namespace_sandbox.cc
|
||||
+++ b/sandbox/linux/services/namespace_sandbox.cc
|
||||
@@ -209,6 +209,70 @@
|
||||
return base::LaunchProcess(argv, launch_options_copy);
|
||||
}
|
||||
|
||||
+#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
|
||||
+#define TLS_ABOVE_TP
|
||||
+#endif
|
||||
+
|
||||
+struct musl_pthread
|
||||
+{
|
||||
+ /* Part 1 -- these fields may be external or
|
||||
+ * internal (accessed via asm) ABI. Do not change. */
|
||||
+ struct pthread *self;
|
||||
+#ifndef TLS_ABOVE_TP
|
||||
+ uintptr_t *dtv;
|
||||
+#endif
|
||||
+ struct pthread *prev, *next; /* non-ABI */
|
||||
+ uintptr_t sysinfo;
|
||||
+#ifndef TLS_ABOVE_TP
|
||||
+#ifdef CANARY_PAD
|
||||
+ uintptr_t canary_pad;
|
||||
+#endif
|
||||
+ uintptr_t canary;
|
||||
+#endif
|
||||
+
|
||||
+/* Part 2 -- implementation details, non-ABI. */
|
||||
+ int tid;
|
||||
+ int errno_val;
|
||||
+ volatile int detach_state;
|
||||
+ volatile int cancel;
|
||||
+ volatile unsigned char canceldisable, cancelasync;
|
||||
+ unsigned char tsd_used:1;
|
||||
+ unsigned char dlerror_flag:1;
|
||||
+ unsigned char *map_base;
|
||||
+ size_t map_size;
|
||||
+ void *stack;
|
||||
+ size_t stack_size;
|
||||
+ size_t guard_size;
|
||||
+ void *result;
|
||||
+ struct __ptcb *cancelbuf;
|
||||
+ void **tsd;
|
||||
+ struct {
|
||||
+ volatile void *volatile head;
|
||||
+ long off;
|
||||
+ volatile void *volatile pending;
|
||||
+ } robust_list;
|
||||
+ int h_errno_val;
|
||||
+ volatile int timer_id;
|
||||
+ locale_t locale;
|
||||
+ volatile int killlock[1];
|
||||
+ char *dlerror_buf;
|
||||
+ void *stdio_locks;
|
||||
+
|
||||
+ /* Part 3 -- the positions of these fields relative to
|
||||
+ * the end of the structure is external and internal ABI. */
|
||||
+#ifdef TLS_ABOVE_TP
|
||||
+ uintptr_t canary;
|
||||
+ uintptr_t *dtv;
|
||||
+#endif
|
||||
+};
|
||||
+
|
||||
+void MaybeUpdateMuslTidCache()
|
||||
+{
|
||||
+ pid_t real_tid = sys_gettid();
|
||||
+ pid_t* cached_tid_location = &reinterpret_cast<struct musl_pthread*>(pthread_self())->tid;
|
||||
+ *cached_tid_location = real_tid;
|
||||
+}
|
||||
+
|
||||
// static
|
||||
pid_t NamespaceSandbox::ForkInNewPidNamespace(bool drop_capabilities_in_child) {
|
||||
const pid_t pid =
|
||||
@@ -226,6 +290,7 @@
|
||||
#if defined(LIBC_GLIBC)
|
||||
MaybeUpdateGlibcTidCache();
|
||||
#endif
|
||||
+ MaybeUpdateMuslTidCache();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
Source: https://git.alpinelinux.org/aports/plain/community/chromium/no-res-ninit-nclose.patch
|
||||
similar to dns-resolver.patch, musl doesn't have res_ninit and so on
|
||||
--
|
||||
--- a/net/dns/public/scoped_res_state.cc
|
||||
+++ b/net/dns/public/scoped_res_state.cc
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace net {
|
||||
|
||||
ScopedResState::ScopedResState() {
|
||||
-#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA)
|
||||
+#if BUILDFLAG(IS_OPENBSD) || BUILDFLAG(IS_FUCHSIA) || defined(_GNU_SOURCE)
|
||||
// Note: res_ninit in glibc always returns 0 and sets RES_INIT.
|
||||
// res_init behaves the same way.
|
||||
memset(&_res, 0, sizeof(_res));
|
||||
@@ -25,16 +25,8 @@
|
||||
}
|
||||
|
||||
ScopedResState::~ScopedResState() {
|
||||
-#if !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
|
||||
-
|
||||
- // Prefer res_ndestroy where available.
|
||||
-#if BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
|
||||
- res_ndestroy(&res_);
|
||||
-#else
|
||||
- res_nclose(&res_);
|
||||
-#endif // BUILDFLAG(IS_APPLE) || BUILDFLAG(IS_FREEBSD)
|
||||
-
|
||||
-#endif // !BUILDFLAG(IS_OPENBSD) && !BUILDFLAG(IS_FUCHSIA)
|
||||
+ // musl res_init() doesn't actually do anything
|
||||
+ // no destruction is necessary as no memory has been allocated
|
||||
}
|
||||
|
||||
bool ScopedResState::IsValid() const {
|
|
@ -0,0 +1,15 @@
|
|||
Source: https://git.alpinelinux.org/aports/plain/community/chromium/quiche-arena-size.patch
|
||||
back in the day when net_unittests were ran, the block arena size was not big
|
||||
enough for some reason. should look at this again
|
||||
--
|
||||
--- a/net/third_party/quiche/src/quiche/quic/core/quic_one_block_arena.h
|
||||
+++ b/net/third_party/quiche/src/quiche/quic/core/quic_one_block_arena.h
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
// QuicConnections currently use around 1KB of polymorphic types which would
|
||||
// ordinarily be on the heap. Instead, store them inline in an arena.
|
||||
-using QuicConnectionArena = QuicOneBlockArena<1280>;
|
||||
+using QuicConnectionArena = QuicOneBlockArena<1504>;
|
||||
|
||||
} // namespace quic
|
||||
|
|
@ -0,0 +1,333 @@
|
|||
From 6e554a30893150793c2638e3689cf208ffc8e375 Mon Sep 17 00:00:00 2001
|
||||
From: Dale Curtis <dalecurtis@chromium.org>
|
||||
Date: Sat, 2 Apr 2022 05:13:53 +0000
|
||||
Subject: [PATCH] Roll src/third_party/ffmpeg/ 574c39cce..32b2d1d526 (1125
|
||||
commits)
|
||||
|
||||
https://chromium.googlesource.com/chromium/third_party/ffmpeg.git/+log/574c39cce323..32b2d1d526
|
||||
|
||||
Created with:
|
||||
roll-dep src/third_party/ffmpeg
|
||||
|
||||
Fixed: 1293918
|
||||
Cq-Include-Trybots: luci.chromium.try:mac_chromium_asan_rel_ng,linux_chromium_asan_rel_ng,linux_chromium_chromeos_asan_rel_ng
|
||||
Change-Id: I41945d0f963e3d1f65940067bac22f63b68e37d2
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3565647
|
||||
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
|
||||
Reviewed-by: Dan Sanders <sandersd@chromium.org>
|
||||
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#988253}
|
||||
---
|
||||
.../clear_key_cdm/ffmpeg_cdm_audio_decoder.cc | 29 ++++++++++---------
|
||||
media/ffmpeg/ffmpeg_common.cc | 11 +++----
|
||||
media/filters/audio_file_reader.cc | 9 +++---
|
||||
media/filters/audio_file_reader_unittest.cc | 6 ++--
|
||||
.../filters/audio_video_metadata_extractor.cc | 11 +++++--
|
||||
.../filters/ffmpeg_aac_bitstream_converter.cc | 7 +++--
|
||||
...ffmpeg_aac_bitstream_converter_unittest.cc | 2 +-
|
||||
media/filters/ffmpeg_audio_decoder.cc | 13 +++++----
|
||||
8 files changed, 51 insertions(+), 37 deletions(-)
|
||||
|
||||
diff --git a/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc b/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc
|
||||
index e4fc3f460e2..9b1ad9f7675 100644
|
||||
--- a/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc
|
||||
+++ b/media/cdm/library_cdm/clear_key_cdm/ffmpeg_cdm_audio_decoder.cc
|
||||
@@ -74,7 +74,7 @@ void CdmAudioDecoderConfigToAVCodecContext(
|
||||
codec_context->sample_fmt = AV_SAMPLE_FMT_NONE;
|
||||
}
|
||||
|
||||
- codec_context->channels = config.channel_count;
|
||||
+ codec_context->ch_layout.nb_channels = config.channel_count;
|
||||
codec_context->sample_rate = config.samples_per_second;
|
||||
|
||||
if (config.extra_data) {
|
||||
@@ -124,8 +124,8 @@ void CopySamples(cdm::AudioFormat cdm_format,
|
||||
case cdm::kAudioFormatPlanarS16:
|
||||
case cdm::kAudioFormatPlanarF32: {
|
||||
const int decoded_size_per_channel =
|
||||
- decoded_audio_size / av_frame.channels;
|
||||
- for (int i = 0; i < av_frame.channels; ++i) {
|
||||
+ decoded_audio_size / av_frame.ch_layout.nb_channels;
|
||||
+ for (int i = 0; i < av_frame.ch_layout.nb_channels; ++i) {
|
||||
memcpy(output_buffer, av_frame.extended_data[i],
|
||||
decoded_size_per_channel);
|
||||
output_buffer += decoded_size_per_channel;
|
||||
@@ -185,13 +185,14 @@ bool FFmpegCdmAudioDecoder::Initialize(
|
||||
// Success!
|
||||
decoding_loop_ = std::make_unique<FFmpegDecodingLoop>(codec_context_.get());
|
||||
samples_per_second_ = config.samples_per_second;
|
||||
- bytes_per_frame_ = codec_context_->channels * config.bits_per_channel / 8;
|
||||
+ bytes_per_frame_ =
|
||||
+ codec_context_->ch_layout.nb_channels * config.bits_per_channel / 8;
|
||||
output_timestamp_helper_ =
|
||||
std::make_unique<AudioTimestampHelper>(config.samples_per_second);
|
||||
is_initialized_ = true;
|
||||
|
||||
// Store initial values to guard against midstream configuration changes.
|
||||
- channels_ = codec_context_->channels;
|
||||
+ channels_ = codec_context_->ch_layout.nb_channels;
|
||||
av_sample_format_ = codec_context_->sample_fmt;
|
||||
|
||||
return true;
|
||||
@@ -291,17 +292,19 @@ cdm::Status FFmpegCdmAudioDecoder::DecodeBuffer(
|
||||
for (auto& frame : audio_frames) {
|
||||
int decoded_audio_size = 0;
|
||||
if (frame->sample_rate != samples_per_second_ ||
|
||||
- frame->channels != channels_ || frame->format != av_sample_format_) {
|
||||
+ frame->ch_layout.nb_channels != channels_ ||
|
||||
+ frame->format != av_sample_format_) {
|
||||
DLOG(ERROR) << "Unsupported midstream configuration change!"
|
||||
<< " Sample Rate: " << frame->sample_rate << " vs "
|
||||
- << samples_per_second_ << ", Channels: " << frame->channels
|
||||
- << " vs " << channels_ << ", Sample Format: " << frame->format
|
||||
- << " vs " << av_sample_format_;
|
||||
+ << samples_per_second_
|
||||
+ << ", Channels: " << frame->ch_layout.nb_channels << " vs "
|
||||
+ << channels_ << ", Sample Format: " << frame->format << " vs "
|
||||
+ << av_sample_format_;
|
||||
return cdm::kDecodeError;
|
||||
}
|
||||
|
||||
decoded_audio_size = av_samples_get_buffer_size(
|
||||
- nullptr, codec_context_->channels, frame->nb_samples,
|
||||
+ nullptr, codec_context_->ch_layout.nb_channels, frame->nb_samples,
|
||||
codec_context_->sample_fmt, 1);
|
||||
if (!decoded_audio_size)
|
||||
continue;
|
||||
@@ -320,9 +323,9 @@ bool FFmpegCdmAudioDecoder::OnNewFrame(
|
||||
size_t* total_size,
|
||||
std::vector<std::unique_ptr<AVFrame, ScopedPtrAVFreeFrame>>* audio_frames,
|
||||
AVFrame* frame) {
|
||||
- *total_size += av_samples_get_buffer_size(nullptr, codec_context_->channels,
|
||||
- frame->nb_samples,
|
||||
- codec_context_->sample_fmt, 1);
|
||||
+ *total_size += av_samples_get_buffer_size(
|
||||
+ nullptr, codec_context_->ch_layout.nb_channels, frame->nb_samples,
|
||||
+ codec_context_->sample_fmt, 1);
|
||||
audio_frames->emplace_back(av_frame_clone(frame));
|
||||
return true;
|
||||
}
|
||||
diff --git a/media/ffmpeg/ffmpeg_common.cc b/media/ffmpeg/ffmpeg_common.cc
|
||||
index 87ca8969626..76f03d6608e 100644
|
||||
--- a/media/ffmpeg/ffmpeg_common.cc
|
||||
+++ b/media/ffmpeg/ffmpeg_common.cc
|
||||
@@ -345,10 +345,11 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
|
||||
codec_context->sample_fmt, codec_context->codec_id);
|
||||
|
||||
ChannelLayout channel_layout =
|
||||
- codec_context->channels > 8
|
||||
+ codec_context->ch_layout.nb_channels > 8
|
||||
? CHANNEL_LAYOUT_DISCRETE
|
||||
- : ChannelLayoutToChromeChannelLayout(codec_context->channel_layout,
|
||||
- codec_context->channels);
|
||||
+ : ChannelLayoutToChromeChannelLayout(
|
||||
+ codec_context->ch_layout.u.mask,
|
||||
+ codec_context->ch_layout.nb_channels);
|
||||
|
||||
int sample_rate = codec_context->sample_rate;
|
||||
switch (codec) {
|
||||
@@ -401,7 +402,7 @@ bool AVCodecContextToAudioDecoderConfig(const AVCodecContext* codec_context,
|
||||
extra_data, encryption_scheme, seek_preroll,
|
||||
codec_context->delay);
|
||||
if (channel_layout == CHANNEL_LAYOUT_DISCRETE)
|
||||
- config->SetChannelsForDiscrete(codec_context->channels);
|
||||
+ config->SetChannelsForDiscrete(codec_context->ch_layout.nb_channels);
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLATFORM_AC3_EAC3_AUDIO)
|
||||
// These are bitstream formats unknown to ffmpeg, so they don't have
|
||||
@@ -470,7 +471,7 @@ void AudioDecoderConfigToAVCodecContext(const AudioDecoderConfig& config,
|
||||
|
||||
// TODO(scherkus): should we set |channel_layout|? I'm not sure if FFmpeg uses
|
||||
// said information to decode.
|
||||
- codec_context->channels = config.channels();
|
||||
+ codec_context->ch_layout.nb_channels = config.channels();
|
||||
codec_context->sample_rate = config.samples_per_second();
|
||||
|
||||
if (config.extra_data().empty()) {
|
||||
diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc
|
||||
index 5f257bdfaa6..e1be5aa9a5b 100644
|
||||
--- a/media/filters/audio_file_reader.cc
|
||||
+++ b/media/filters/audio_file_reader.cc
|
||||
@@ -113,14 +113,15 @@ bool AudioFileReader::OpenDecoder() {
|
||||
|
||||
// Verify the channel layout is supported by Chrome. Acts as a sanity check
|
||||
// against invalid files. See http://crbug.com/171962
|
||||
- if (ChannelLayoutToChromeChannelLayout(codec_context_->channel_layout,
|
||||
- codec_context_->channels) ==
|
||||
+ if (ChannelLayoutToChromeChannelLayout(
|
||||
+ codec_context_->ch_layout.u.mask,
|
||||
+ codec_context_->ch_layout.nb_channels) ==
|
||||
CHANNEL_LAYOUT_UNSUPPORTED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Store initial values to guard against midstream configuration changes.
|
||||
- channels_ = codec_context_->channels;
|
||||
+ channels_ = codec_context_->ch_layout.nb_channels;
|
||||
audio_codec_ = CodecIDToAudioCodec(codec_context_->codec_id);
|
||||
sample_rate_ = codec_context_->sample_rate;
|
||||
av_sample_format_ = codec_context_->sample_fmt;
|
||||
@@ -223,7 +224,7 @@ bool AudioFileReader::OnNewFrame(
|
||||
if (frames_read < 0)
|
||||
return false;
|
||||
|
||||
- const int channels = frame->channels;
|
||||
+ const int channels = frame->ch_layout.nb_channels;
|
||||
if (frame->sample_rate != sample_rate_ || channels != channels_ ||
|
||||
frame->format != av_sample_format_) {
|
||||
DLOG(ERROR) << "Unsupported midstream configuration change!"
|
||||
diff --git a/media/filters/audio_file_reader_unittest.cc b/media/filters/audio_file_reader_unittest.cc
|
||||
index 2aba7927a31..1f45a50cace 100644
|
||||
--- a/media/filters/audio_file_reader_unittest.cc
|
||||
+++ b/media/filters/audio_file_reader_unittest.cc
|
||||
@@ -121,11 +121,11 @@ class AudioFileReaderTest : public testing::Test {
|
||||
EXPECT_FALSE(reader_->Open());
|
||||
}
|
||||
|
||||
- void RunTestFailingDecode(const char* fn) {
|
||||
+ void RunTestFailingDecode(const char* fn, int expect_read = 0) {
|
||||
Initialize(fn);
|
||||
EXPECT_TRUE(reader_->Open());
|
||||
std::vector<std::unique_ptr<AudioBus>> decoded_audio_packets;
|
||||
- EXPECT_EQ(reader_->Read(&decoded_audio_packets), 0);
|
||||
+ EXPECT_EQ(reader_->Read(&decoded_audio_packets), expect_read);
|
||||
}
|
||||
|
||||
void RunTestPartialDecode(const char* fn) {
|
||||
@@ -219,7 +219,7 @@ TEST_F(AudioFileReaderTest, AAC_ADTS) {
|
||||
}
|
||||
|
||||
TEST_F(AudioFileReaderTest, MidStreamConfigChangesFail) {
|
||||
- RunTestFailingDecode("midstream_config_change.mp3");
|
||||
+ RunTestFailingDecode("midstream_config_change.mp3", 42624);
|
||||
}
|
||||
#endif
|
||||
|
||||
diff --git a/media/filters/audio_video_metadata_extractor.cc b/media/filters/audio_video_metadata_extractor.cc
|
||||
index 185819eb936..69ff508c221 100644
|
||||
--- a/media/filters/audio_video_metadata_extractor.cc
|
||||
+++ b/media/filters/audio_video_metadata_extractor.cc
|
||||
@@ -113,6 +113,15 @@ bool AudioVideoMetadataExtractor::Extract(DataSource* source,
|
||||
if (!stream)
|
||||
continue;
|
||||
|
||||
+ void* display_matrix =
|
||||
+ av_stream_get_side_data(stream, AV_PKT_DATA_DISPLAYMATRIX, nullptr);
|
||||
+ if (display_matrix) {
|
||||
+ rotation_ = VideoTransformation::FromFFmpegDisplayMatrix(
|
||||
+ static_cast<int32_t*>(display_matrix))
|
||||
+ .rotation;
|
||||
+ info.tags["rotate"] = base::NumberToString(rotation_);
|
||||
+ }
|
||||
+
|
||||
// Extract dictionary from streams also. Needed for containers that attach
|
||||
// metadata to contained streams instead the container itself, like OGG.
|
||||
ExtractDictionary(stream->metadata, &info.tags);
|
||||
@@ -255,8 +264,6 @@ void AudioVideoMetadataExtractor::ExtractDictionary(AVDictionary* metadata,
|
||||
if (raw_tags->find(tag->key) == raw_tags->end())
|
||||
(*raw_tags)[tag->key] = tag->value;
|
||||
|
||||
- if (ExtractInt(tag, "rotate", &rotation_))
|
||||
- continue;
|
||||
if (ExtractString(tag, "album", &album_))
|
||||
continue;
|
||||
if (ExtractString(tag, "artist", &artist_))
|
||||
diff --git a/media/filters/ffmpeg_aac_bitstream_converter.cc b/media/filters/ffmpeg_aac_bitstream_converter.cc
|
||||
index 6f231c85729..ca5e5fb927d 100644
|
||||
--- a/media/filters/ffmpeg_aac_bitstream_converter.cc
|
||||
+++ b/media/filters/ffmpeg_aac_bitstream_converter.cc
|
||||
@@ -195,14 +195,15 @@ bool FFmpegAACBitstreamConverter::ConvertPacket(AVPacket* packet) {
|
||||
if (!header_generated_ || codec_ != stream_codec_parameters_->codec_id ||
|
||||
audio_profile_ != stream_codec_parameters_->profile ||
|
||||
sample_rate_index_ != sample_rate_index ||
|
||||
- channel_configuration_ != stream_codec_parameters_->channels ||
|
||||
+ channel_configuration_ !=
|
||||
+ stream_codec_parameters_->ch_layout.nb_channels ||
|
||||
frame_length_ != header_plus_packet_size) {
|
||||
header_generated_ =
|
||||
GenerateAdtsHeader(stream_codec_parameters_->codec_id,
|
||||
0, // layer
|
||||
stream_codec_parameters_->profile, sample_rate_index,
|
||||
0, // private stream
|
||||
- stream_codec_parameters_->channels,
|
||||
+ stream_codec_parameters_->ch_layout.nb_channels,
|
||||
0, // originality
|
||||
0, // home
|
||||
0, // copyrighted_stream
|
||||
@@ -214,7 +215,7 @@ bool FFmpegAACBitstreamConverter::ConvertPacket(AVPacket* packet) {
|
||||
codec_ = stream_codec_parameters_->codec_id;
|
||||
audio_profile_ = stream_codec_parameters_->profile;
|
||||
sample_rate_index_ = sample_rate_index;
|
||||
- channel_configuration_ = stream_codec_parameters_->channels;
|
||||
+ channel_configuration_ = stream_codec_parameters_->ch_layout.nb_channels;
|
||||
frame_length_ = header_plus_packet_size;
|
||||
}
|
||||
|
||||
diff --git a/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc b/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc
|
||||
index 1fd4c5ccd7d..f59bcd8fdaf 100644
|
||||
--- a/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc
|
||||
+++ b/media/filters/ffmpeg_aac_bitstream_converter_unittest.cc
|
||||
@@ -34,7 +34,7 @@ class FFmpegAACBitstreamConverterTest : public testing::Test {
|
||||
memset(&test_parameters_, 0, sizeof(AVCodecParameters));
|
||||
test_parameters_.codec_id = AV_CODEC_ID_AAC;
|
||||
test_parameters_.profile = FF_PROFILE_AAC_MAIN;
|
||||
- test_parameters_.channels = 2;
|
||||
+ test_parameters_.ch_layout.nb_channels = 2;
|
||||
test_parameters_.extradata = extradata_header_;
|
||||
test_parameters_.extradata_size = sizeof(extradata_header_);
|
||||
}
|
||||
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
|
||||
index 6a56c675f7d..4615fdeb3fb 100644
|
||||
--- a/media/filters/ffmpeg_audio_decoder.cc
|
||||
+++ b/media/filters/ffmpeg_audio_decoder.cc
|
||||
@@ -28,7 +28,7 @@ namespace media {
|
||||
|
||||
// Return the number of channels from the data in |frame|.
|
||||
static inline int DetermineChannels(AVFrame* frame) {
|
||||
- return frame->channels;
|
||||
+ return frame->ch_layout.nb_channels;
|
||||
}
|
||||
|
||||
// Called by FFmpeg's allocation routine to allocate a buffer. Uses
|
||||
@@ -231,7 +231,7 @@ bool FFmpegAudioDecoder::OnNewFrame(const DecoderBuffer& buffer,
|
||||
// Translate unsupported into discrete layouts for discrete configurations;
|
||||
// ffmpeg does not have a labeled discrete configuration internally.
|
||||
ChannelLayout channel_layout = ChannelLayoutToChromeChannelLayout(
|
||||
- codec_context_->channel_layout, codec_context_->channels);
|
||||
+ codec_context_->ch_layout.u.mask, codec_context_->ch_layout.nb_channels);
|
||||
if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED &&
|
||||
config_.channel_layout() == CHANNEL_LAYOUT_DISCRETE) {
|
||||
channel_layout = CHANNEL_LAYOUT_DISCRETE;
|
||||
@@ -348,11 +348,11 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) {
|
||||
// Success!
|
||||
av_sample_format_ = codec_context_->sample_fmt;
|
||||
|
||||
- if (codec_context_->channels != config.channels()) {
|
||||
+ if (codec_context_->ch_layout.nb_channels != config.channels()) {
|
||||
MEDIA_LOG(ERROR, media_log_)
|
||||
<< "Audio configuration specified " << config.channels()
|
||||
<< " channels, but FFmpeg thinks the file contains "
|
||||
- << codec_context_->channels << " channels";
|
||||
+ << codec_context_->ch_layout.nb_channels << " channels";
|
||||
ReleaseFFmpegResources();
|
||||
state_ = DecoderState::kUninitialized;
|
||||
return false;
|
||||
@@ -403,7 +403,7 @@ int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s,
|
||||
if (frame->nb_samples <= 0)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
- if (s->channels != channels) {
|
||||
+ if (s->ch_layout.nb_channels != channels) {
|
||||
DLOG(ERROR) << "AVCodecContext and AVFrame disagree on channel count.";
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
@@ -436,7 +436,8 @@ int FFmpegAudioDecoder::GetAudioBuffer(struct AVCodecContext* s,
|
||||
ChannelLayout channel_layout =
|
||||
config_.channel_layout() == CHANNEL_LAYOUT_DISCRETE
|
||||
? CHANNEL_LAYOUT_DISCRETE
|
||||
- : ChannelLayoutToChromeChannelLayout(s->channel_layout, s->channels);
|
||||
+ : ChannelLayoutToChromeChannelLayout(s->ch_layout.u.mask,
|
||||
+ s->ch_layout.nb_channels);
|
||||
|
||||
if (channel_layout == CHANNEL_LAYOUT_UNSUPPORTED) {
|
||||
DLOG(ERROR) << "Unsupported channel layout.";
|
|
@ -0,0 +1 @@
|
|||
-RNp1
|
|
@ -0,0 +1,55 @@
|
|||
From ded379824f5de39357b6b1894578101aba5cdf05 Mon Sep 17 00:00:00 2001
|
||||
From: Eugene Zemtsov <eugene@chromium.org>
|
||||
Date: Fri, 29 Jul 2022 04:41:04 +0000
|
||||
Subject: [PATCH] Roll src/third_party/ffmpeg/ 880df5ede..b71ecd02b (279
|
||||
commits)
|
||||
|
||||
https://chromium.googlesource.com/chromium/third_party/ffmpeg.git/+log/880df5ede50a..b71ecd02b479
|
||||
|
||||
$ git log 880df5ede..b71ecd02b --date=short --no-merges --format='%ad %ae %s'
|
||||
2022-07-27 eugene Roll for M106
|
||||
2022-07-25 andreas.rheinhardt avcodec/x86/pngdsp: Remove obsolete ff_add_bytes_l2_mmx()
|
||||
2022-07-22 andreas.rheinhardt avcodec/hevcdec: Output MD5-message in one piece
|
||||
2022-07-24 epirat07 configure: properly require libx264 if enabled
|
||||
2022-07-24 zane avformat/argo_cvg: expose loop/reverb/checksum via metadata
|
||||
(...)
|
||||
2022-05-03 leo.izen avcodec/libjxldec: properly tag output colorspace
|
||||
2022-06-25 ffmpeg avfilter/Makefile: always make colorspace.o
|
||||
2022-03-02 brad avutil/ppc/cpu: Use proper header for OpenBSD PPC CPU detection
|
||||
2022-06-24 jamrial avformat/http: include version.h
|
||||
2022-05-16 mbonda-at-nvidia.com AV1 VDPAU hwaccel Decode support
|
||||
|
||||
Created with:
|
||||
roll-dep src/third_party/ffmpeg
|
||||
|
||||
ffmpeg usage fix:
|
||||
Switch from AVFrame::pkt_duration to AVFrame::duration,
|
||||
AVFrame::pkt_duration is deprecated
|
||||
|
||||
Bug: 1344646
|
||||
Change-Id: Iaa3abf48ef81dae6d282bca8f0fa2a8dffeeba25
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3788638
|
||||
Reviewed-by: Will Cassella <cassew@chromium.org>
|
||||
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#1029623}
|
||||
---
|
||||
media/filters/audio_file_reader.cc | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc
|
||||
index e1be5aa9a5b..951c003956f 100644
|
||||
--- a/media/filters/audio_file_reader.cc
|
||||
+++ b/media/filters/audio_file_reader.cc
|
||||
@@ -243,10 +243,10 @@ bool AudioFileReader::OnNewFrame(
|
||||
// silence from being output. In the case where we are also discarding some
|
||||
// portion of the packet (as indicated by a negative pts), we further want to
|
||||
// adjust the duration downward by however much exists before zero.
|
||||
- if (audio_codec_ == AudioCodec::kAAC && frame->pkt_duration) {
|
||||
+ if (audio_codec_ == AudioCodec::kAAC && frame->duration) {
|
||||
const base::TimeDelta pkt_duration = ConvertFromTimeBase(
|
||||
glue_->format_context()->streams[stream_index_]->time_base,
|
||||
- frame->pkt_duration + std::min(static_cast<int64_t>(0), frame->pts));
|
||||
+ frame->duration + std::min(static_cast<int64_t>(0), frame->pts));
|
||||
const base::TimeDelta frame_duration =
|
||||
base::Seconds(frames_read / static_cast<double>(sample_rate_));
|
||||
|
|
@ -0,0 +1 @@
|
|||
-RNp1
|
|
@ -0,0 +1,39 @@
|
|||
Patch-Source: https://github.com/archlinux/svntogit-packages/blob/a353833a5a731abfaa465b658f61894a516aa49b/trunk/angle-wayland-include-protocol.patch
|
||||
diff -upr third_party/angle.orig/BUILD.gn third_party/angle/BUILD.gn
|
||||
--- a/third_party/angle.orig/BUILD.gn 2022-08-17 19:38:11.000000000 +0000
|
||||
+++ b/third_party/angle/BUILD.gn 2022-08-18 11:04:09.061751111 +0000
|
||||
@@ -489,6 +489,12 @@ config("angle_vulkan_wayland_config") {
|
||||
if (angle_enable_vulkan && angle_use_wayland &&
|
||||
defined(vulkan_wayland_include_dirs)) {
|
||||
include_dirs = vulkan_wayland_include_dirs
|
||||
+ } else if (angle_enable_vulkan && angle_use_wayland) {
|
||||
+ include_dirs = [
|
||||
+ "$wayland_gn_dir/src/src",
|
||||
+ "$wayland_gn_dir/include/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
+ ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,6 +1079,7 @@ if (angle_use_wayland) {
|
||||
include_dirs = [
|
||||
"$wayland_dir/egl",
|
||||
"$wayland_dir/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
]
|
||||
}
|
||||
|
||||
diff -upr third_party/angle.orig/src/third_party/volk/BUILD.gn third_party/angle/src/third_party/volk/BUILD.gn
|
||||
--- a/third_party/angle.orig/src/third_party/volk/BUILD.gn 2022-08-17 19:38:12.000000000 +0000
|
||||
+++ b/third_party/angle/src/third_party/volk/BUILD.gn 2022-08-18 11:04:36.499828006 +0000
|
||||
@@ -21,6 +21,9 @@ source_set("volk") {
|
||||
configs += [ "$angle_root:angle_no_cfi_icall" ]
|
||||
public_deps = [ "$angle_vulkan_headers_dir:vulkan_headers" ]
|
||||
if (angle_use_wayland) {
|
||||
- include_dirs = [ "$wayland_dir/src" ]
|
||||
+ include_dirs = [
|
||||
+ "$wayland_dir/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
+ ]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
--- a/chrome/browser/search/background/ntp_backgrounds.h 2020-08-10 20:39:20.000000000 +0200
|
||||
+++ b/chrome/browser/search/background/ntp_backgrounds.h 2020-09-04 13:48:22.640023256 +0200
|
||||
@@ -6,6 +6,7 @@
|
||||
#define CHROME_BROWSER_SEARCH_BACKGROUND_NTP_BACKGROUNDS_H_
|
||||
|
||||
#include <array>
|
||||
+#include <cstddef>
|
||||
|
||||
class GURL;
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
|
||||
index ac4713b07268..492a9a37d096 100644
|
||||
--- a/media/filters/ffmpeg_demuxer.cc
|
||||
+++ b/media/filters/ffmpeg_demuxer.cc
|
||||
@@ -427,11 +427,11 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
|
||||
scoped_refptr<DecoderBuffer> buffer;
|
||||
|
||||
if (type() == DemuxerStream::TEXT) {
|
||||
- size_t id_size = 0;
|
||||
+ int id_size = 0;
|
||||
uint8_t* id_data = av_packet_get_side_data(
|
||||
packet.get(), AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);
|
||||
|
||||
- size_t settings_size = 0;
|
||||
+ int settings_size = 0;
|
||||
uint8_t* settings_data = av_packet_get_side_data(
|
||||
packet.get(), AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);
|
||||
|
||||
@@ -443,7 +443,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
|
||||
buffer = DecoderBuffer::CopyFrom(packet->data, packet->size,
|
||||
side_data.data(), side_data.size());
|
||||
} else {
|
||||
- size_t side_data_size = 0;
|
||||
+ int side_data_size = 0;
|
||||
uint8_t* side_data = av_packet_get_side_data(
|
||||
packet.get(), AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, &side_data_size);
|
||||
|
||||
@@ -504,7 +504,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
|
||||
packet->size - data_offset);
|
||||
}
|
||||
|
||||
- size_t skip_samples_size = 0;
|
||||
+ int skip_samples_size = 0;
|
||||
const uint32_t* skip_samples_ptr =
|
||||
reinterpret_cast<const uint32_t*>(av_packet_get_side_data(
|
||||
packet.get(), AV_PKT_DATA_SKIP_SAMPLES, &skip_samples_size));
|
|
@ -0,0 +1,23 @@
|
|||
--- a/media/gpu/vaapi/BUILD.gn.orig
|
||||
+++ b/media/gpu/vaapi/BUILD.gn
|
||||
@@ -14,6 +14,12 @@
|
||||
assert(is_linux || is_chromeos)
|
||||
assert(use_vaapi)
|
||||
|
||||
+config("vaapi_permissive") {
|
||||
+ if (target_cpu == "x86") {
|
||||
+ cflags = [ "-fpermissive" ]
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
generate_stubs("libva_stubs") {
|
||||
extra_header = "va_stub_header.fragment"
|
||||
sigs = [ "va.sigs" ]
|
||||
@@ -90,6 +96,7 @@
|
||||
configs += [
|
||||
"//build/config/linux/libva",
|
||||
"//third_party/libvpx:libvpx_config",
|
||||
+ ":vaapi_permissive",
|
||||
]
|
||||
|
||||
deps = [
|
|
@ -0,0 +1,15 @@
|
|||
This was dropped for some reason in 6951c37cecd05979b232a39e5c10e6346a0f74ef
|
||||
--- a/third_party/closure_compiler/compiler.py 2021-05-20 04:17:53.000000000 +0200
|
||||
+++ b/third_party/closure_compiler/compiler.py 2021-05-20 04:17:53.000000000 +0200
|
||||
@@ -13,8 +13,9 @@
|
||||
|
||||
|
||||
_CURRENT_DIR = os.path.join(os.path.dirname(__file__))
|
||||
-_JAVA_PATH = os.path.join(_CURRENT_DIR, "..", "jdk", "current", "bin", "java")
|
||||
-assert os.path.isfile(_JAVA_PATH), "java only allowed in android builds"
|
||||
+_JAVA_BIN = "java"
|
||||
+_JDK_PATH = os.path.join(_CURRENT_DIR, "..", "jdk", "current", "bin", "java")
|
||||
+_JAVA_PATH = _JDK_PATH if os.path.isfile(_JDK_PATH) else _JAVA_BIN
|
||||
|
||||
class Compiler(object):
|
||||
"""Runs the Closure compiler on given source files to typecheck them
|
|
@ -0,0 +1,20 @@
|
|||
--- a/third_party/node/node.py
|
||||
+++ b/third_party/node/node.py
|
||||
@@ -13,11 +13,12 @@
|
||||
def GetBinaryPath():
|
||||
darwin_name = ('node-darwin-arm64' if platform.machine() == 'arm64' else
|
||||
'node-darwin-x64')
|
||||
- return os_path.join(os_path.dirname(__file__), *{
|
||||
- 'Darwin': ('mac', darwin_name, 'bin', 'node'),
|
||||
- 'Linux': ('linux', 'node-linux-x64', 'bin', 'node'),
|
||||
- 'Windows': ('win', 'node.exe'),
|
||||
- }[platform.system()])
|
||||
+ #return os_path.join(os_path.dirname(__file__), *{
|
||||
+ # 'Darwin': ('mac', darwin_name, 'bin', 'node'),
|
||||
+ # 'Linux': ('linux', 'node-linux-x64', 'bin', 'node'),
|
||||
+ # 'Windows': ('win', 'node.exe'),
|
||||
+ #}[platform.system()])
|
||||
+ return "/usr/bin/node"
|
||||
|
||||
|
||||
def RunNode(cmd_parts, stdout=None):
|
65
srcpkgs/electron24/files/patches/chromium-cross-build.patch
Normal file
65
srcpkgs/electron24/files/patches/chromium-cross-build.patch
Normal file
|
@ -0,0 +1,65 @@
|
|||
--- a/build/config/compiler/BUILD.gn.orig
|
||||
+++ b/build/config/compiler/BUILD.gn
|
||||
@@ -55,6 +55,10 @@
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
+ is_musl = false
|
||||
+}
|
||||
+
|
||||
+declare_args() {
|
||||
# Normally, Android builds are lightly optimized, even for debug builds, to
|
||||
# keep binary size down. Setting this flag to true disables such optimization
|
||||
android_full_debug = false
|
||||
@@ -917,8 +917,13 @@
|
||||
} else if (current_cpu == "arm64") {
|
||||
if (is_clang && !is_android && !is_nacl && !is_fuchsia &&
|
||||
!(is_chromeos_lacros && is_chromeos_device)) {
|
||||
- cflags += [ "--target=aarch64-linux-gnu" ]
|
||||
- ldflags += [ "--target=aarch64-linux-gnu" ]
|
||||
+ if (is_musl) {
|
||||
+ cflags += [ "--target=aarch64-linux-musl" ]
|
||||
+ ldflags += [ "--target=aarch64-linux-musl" ]
|
||||
+ } else {
|
||||
+ cflags += [ "--target=aarch64-linux-gnu" ]
|
||||
+ ldflags += [ "--target=aarch64-linux-gnu" ]
|
||||
+ }
|
||||
}
|
||||
if (is_android) {
|
||||
# Outline atomics crash on Exynos 9810. http://crbug.com/1272795
|
||||
--- a/build/toolchain/linux/unbundle/BUILD.gn.orig
|
||||
+++ b/build/toolchain/linux/unbundle/BUILD.gn
|
||||
@@ -39,3 +39,22 @@
|
||||
current_os = host_os
|
||||
}
|
||||
}
|
||||
+
|
||||
+gcc_toolchain("v8_snapshot_cross") {
|
||||
+ cc = getenv("BUILD_CC")
|
||||
+ cxx = getenv("BUILD_CXX")
|
||||
+ ar = getenv("BUILD_AR")
|
||||
+ nm = getenv("BUILD_NM")
|
||||
+ ld = cxx
|
||||
+
|
||||
+ extra_cflags = getenv("BUILD_CFLAGS")
|
||||
+ extra_cppflags = getenv("BUILD_CPPFLAGS")
|
||||
+ extra_cxxflags = getenv("BUILD_CXXFLAGS")
|
||||
+ extra_ldflags = getenv("BUILD_LDFLAGS")
|
||||
+
|
||||
+ toolchain_args = {
|
||||
+ current_cpu = host_cpu
|
||||
+ current_os = host_os
|
||||
+ v8_current_cpu = target_cpu
|
||||
+ }
|
||||
+}
|
||||
--- a/build/config/linux/pkg_config.gni.orig
|
||||
+++ b/build/config/linux/pkg_config.gni
|
||||
@@ -91,7 +91,7 @@
|
||||
assert(defined(invoker.packages),
|
||||
"Variable |packages| must be defined to be a list in pkg_config.")
|
||||
config(target_name) {
|
||||
- if (host_toolchain == current_toolchain) {
|
||||
+ if (current_cpu != target_cpu) {
|
||||
args = common_pkg_config_args + host_pkg_config_args + invoker.packages
|
||||
} else {
|
||||
args = common_pkg_config_args + pkg_config_args + invoker.packages
|
|
@ -0,0 +1,18 @@
|
|||
--- a/base/files/scoped_file_linux.cc.orig
|
||||
+++ b/base/files/scoped_file_linux.cc
|
||||
@@ -77,15 +77,3 @@
|
||||
}
|
||||
|
||||
} // namespace base
|
||||
-
|
||||
-extern "C" {
|
||||
-
|
||||
-int __close(int);
|
||||
-
|
||||
-__attribute__((visibility("default"), noinline)) int close(int fd) {
|
||||
- if (base::IsFDOwned(fd) && g_is_ownership_enforced)
|
||||
- CrashOnFdOwnershipViolation();
|
||||
- return __close(fd);
|
||||
-}
|
||||
-
|
||||
-} // extern "C"
|
|
@ -0,0 +1,13 @@
|
|||
instead of hardcoding the version, use the defined macro.
|
||||
--
|
||||
--- a/third_party/test_fonts/fontconfig/generate_fontconfig_caches.cc
|
||||
+++ b/third_party/test_fonts/fontconfig/generate_fontconfig_caches.cc
|
||||
@@ -56,7 +56,7 @@
|
||||
FcFini();
|
||||
|
||||
// Check existence of intended fontconfig cache file.
|
||||
- auto cache = fontconfig_caches + "/" + kCacheKey + "-le64.cache-9";
|
||||
+ auto cache = fontconfig_caches + "/" + kCacheKey + "-le64.cache-" + FC_CACHE_VERSION;
|
||||
bool cache_exists = access(cache.c_str(), F_OK) == 0;
|
||||
return !cache_exists;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
--- a/base/allocator/partition_allocator/tagging.cc
|
||||
+++ b/base/allocator/partition_allocator/tagging.cc
|
||||
@@ -28,13 +28,25 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
-#ifndef HAS_PR_MTE_MACROS
|
||||
+#ifndef PR_MTE_TCF_SHIFT
|
||||
#define PR_MTE_TCF_SHIFT 1
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TCF_NONE
|
||||
#define PR_MTE_TCF_NONE (0UL << PR_MTE_TCF_SHIFT)
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TCF_SYNC
|
||||
#define PR_MTE_TCF_SYNC (1UL << PR_MTE_TCF_SHIFT)
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TCF_ASYNC
|
||||
#define PR_MTE_TCF_ASYNC (2UL << PR_MTE_TCF_SHIFT)
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TCF_MASK
|
||||
#define PR_MTE_TCF_MASK (3UL << PR_MTE_TCF_SHIFT)
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TAG_SHIFT
|
||||
#define PR_MTE_TAG_SHIFT 3
|
||||
+#endif
|
||||
+#ifndef PR_MTE_TAG_MASK
|
||||
#define PR_MTE_TAG_MASK (0xffffUL << PR_MTE_TAG_SHIFT)
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
--- a/extensions/renderer/bindings/argument_spec.cc
|
||||
+++ b/extensions/renderer/bindings/argument_spec.cc
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
+#include <cmath>
|
||||
+
|
||||
#include "extensions/renderer/bindings/argument_spec.h"
|
||||
|
||||
#include "base/check.h"
|
|
@ -0,0 +1,21 @@
|
|||
--- a/third_party/blink/renderer/platform/media/web_media_player_impl.cc.orig
|
||||
+++ b/third_party/blink/renderer/platform/media/web_media_player_impl.cc
|
||||
@@ -3881,15 +3881,15 @@
|
||||
const T&... values) {
|
||||
std::string strkey = std::string(key);
|
||||
|
||||
- if constexpr (Flags & kEncrypted) {
|
||||
+ if constexpr (Flags & kEncrypted != 0) {
|
||||
if (is_encrypted_)
|
||||
UmaFunction(strkey + ".EME", values...);
|
||||
}
|
||||
|
||||
- if constexpr (Flags & kTotal)
|
||||
+ if constexpr (Flags & kTotal != 0)
|
||||
UmaFunction(strkey + ".All", values...);
|
||||
|
||||
- if constexpr (Flags & kPlaybackType) {
|
||||
+ if constexpr (Flags & kPlaybackType != 0) {
|
||||
auto demuxer_type = GetDemuxerType();
|
||||
if (!demuxer_type.has_value())
|
||||
return;
|
|
@ -0,0 +1,62 @@
|
|||
From f815e833c946a59620a2ca9df37a1da746f61460 Mon Sep 17 00:00:00 2001
|
||||
From: q66 <daniel@octaforge.org>
|
||||
Date: Sat, 1 Oct 2022 00:21:09 +0000
|
||||
Subject: [PATCH] fix dawn build for ppc64
|
||||
|
||||
---
|
||||
third_party/dawn/src/dawn/common/Assert.cpp | 4 ++--
|
||||
third_party/dawn/src/dawn/common/Platform.h | 10 +++++-----
|
||||
2 files changed, 7 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/third_party/dawn/src/dawn/common/Assert.cpp b/third_party/dawn/src/dawn/common/Assert.cpp
|
||||
index ecc92dfc..8ee91a90 100644
|
||||
--- a/third_party/dawn/src/dawn/common/Assert.cpp
|
||||
+++ b/third_party/dawn/src/dawn/common/Assert.cpp
|
||||
@@ -31,9 +31,9 @@ void BreakPoint() {
|
||||
__asm__ __volatile__("ebreak");
|
||||
#elif DAWN_PLATFORM_IS(MIPS)
|
||||
__asm__ __volatile__("break");
|
||||
-#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS_(S390X)
|
||||
+#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS(S390X)
|
||||
__asm__ __volatile__(".word 0x0001");
|
||||
-#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS_(PPC64)
|
||||
+#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS(PPC64)
|
||||
__asm__ __volatile__("twge 2,2");
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
diff --git a/third_party/dawn/src/dawn/common/Platform.h b/third_party/dawn/src/dawn/common/Platform.h
|
||||
index 39d5eb41..2011367d 100644
|
||||
--- a/third_party/dawn/src/dawn/common/Platform.h
|
||||
+++ b/third_party/dawn/src/dawn/common/Platform.h
|
||||
@@ -124,15 +124,15 @@
|
||||
#define DAWN_PLATFORM_IS_MIPS64 1
|
||||
#endif
|
||||
|
||||
-#elif defiend(__s390__)
|
||||
+#elif defined(__s390__)
|
||||
#define DAWN_PLATFORM_IS_S390 1
|
||||
-#elif defiend(__s390x__)
|
||||
+#elif defined(__s390x__)
|
||||
#define DAWN_PLATFORM_IS_S390X 1
|
||||
|
||||
-#elif defined(__PPC__)
|
||||
-#define DAWN_PLATFORM_IS_PPC 1
|
||||
#elif defined(__PPC64__)
|
||||
#define DAWN_PLATFORM_IS_PPC64 1
|
||||
+#elif defined(__PPC__)
|
||||
+#define DAWN_PLATFORM_IS_PPC 1
|
||||
|
||||
#else
|
||||
#error "Unsupported platform."
|
||||
@@ -149,7 +149,7 @@
|
||||
static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
|
||||
#elif defined(DAWN_PLATFORM_IS_I386) || defined(DAWN_PLATFORM_IS_ARM32) || \
|
||||
defined(DAWN_PLATFORM_IS_RISCV32) || defined(DAWN_PLATFORM_IS_MIPS32) || \
|
||||
- defined(DAWN_PLATFORM_IS_S390) || defined(DAWN_PLATFORM_IS_PPC32) || \
|
||||
+ defined(DAWN_PLATFORM_IS_S390) || defined(DAWN_PLATFORM_IS_PPC) || \
|
||||
defined(DAWN_PLATFORM_IS_EMSCRIPTEN) || defined(DAWN_PLATFORM_IS_LOONGARCH32)
|
||||
#define DAWN_PLATFORM_IS_32_BIT 1
|
||||
static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
|
||||
--
|
||||
2.34.1
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
--- a/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
|
||||
+++ b/chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.cc
|
||||
@@ -61,8 +61,11 @@
|
||||
|
||||
// TODO(crbug.com/1052397): Revisit the macro expression once build flag switch
|
||||
// of lacros-chrome is complete.
|
||||
-#if defined(__GLIBC__) && (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
|
||||
+#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
+
|
||||
+#if defined(__GLIBC__)
|
||||
#include <gnu/libc-version.h>
|
||||
+#endif
|
||||
|
||||
#include "base/linux_util.h"
|
||||
#include "base/strings/string_split.h"
|
|
@ -0,0 +1,21 @@
|
|||
This macro is defined in glibc, but not musl.
|
||||
|
||||
--- a/sandbox/linux/suid/process_util.h.orig
|
||||
+++ b/sandbox/linux/suid/process_util.h
|
||||
@@ -11,6 +11,16 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
+// Some additional functions
|
||||
+#if !defined(TEMP_FAILURE_RETRY)
|
||||
+# define TEMP_FAILURE_RETRY(expression) \
|
||||
+ (__extension__ \
|
||||
+ ({ long int __result; \
|
||||
+ do __result = (long int) (expression); \
|
||||
+ while (__result == -1L && errno == EINTR); \
|
||||
+ __result; }))
|
||||
+#endif
|
||||
+
|
||||
// This adjusts /proc/process/oom_score_adj so the Linux OOM killer
|
||||
// will prefer certain process types over others. The range for the
|
||||
// adjustment is [-1000, 1000], with [0, 1000] being user accessible.
|
|
@ -0,0 +1,10 @@
|
|||
--- a/net/third_party/quiche/src/quiche/http2/adapter/window_manager.h
|
||||
+++ b/net/third_party/quiche/src/quiche/http2/adapter/window_manager.h
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
+#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
#include "quiche/common/platform/api/quiche_export.h"
|
|
@ -0,0 +1,10 @@
|
|||
--- a/sandbox/linux/services/credentials.h
|
||||
+++ b/sandbox/linux/services/credentials.h
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
+#include <unistd.h>
|
||||
|
||||
#include "sandbox/linux/system_headers/capability.h"
|
||||
#include "sandbox/sandbox_export.h"
|
|
@ -0,0 +1,22 @@
|
|||
--- a/third_party/perfetto/include/perfetto/ext/base/thread_utils.h
|
||||
+++ b/third_party/perfetto/include/perfetto/ext/base/thread_utils.h
|
||||
@@ -30,7 +30,8 @@
|
||||
#include <algorithm>
|
||||
#endif
|
||||
|
||||
-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
|
||||
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || \
|
||||
+ (PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) && !defined(__GLIBC__))
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
@@ -58,7 +59,8 @@
|
||||
|
||||
inline bool GetThreadName(std::string& out_result) {
|
||||
char buf[16] = {};
|
||||
-#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
|
||||
+#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID) || \
|
||||
+ (PERFETTO_BUILDFLAG(PERFETTO_OS_LINUX) && !defined(__GLIBC__))
|
||||
if (prctl(PR_GET_NAME, buf) != 0)
|
||||
return false;
|
||||
#else
|
34
srcpkgs/electron24/files/patches/chromium-libc_malloc.patch
Normal file
34
srcpkgs/electron24/files/patches/chromium-libc_malloc.patch
Normal file
|
@ -0,0 +1,34 @@
|
|||
--- a/base/process/memory_linux.cc
|
||||
+++ b/base/process/memory_linux.cc
|
||||
@@ -18,6 +18,13 @@
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
+#if defined(LIBC_GLIBC)
|
||||
+extern "C" {
|
||||
+extern void *__libc_malloc(size_t size);
|
||||
+extern void *__libc_free(void *ptr);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
namespace base {
|
||||
|
||||
namespace {
|
||||
@@ -111,7 +118,7 @@
|
||||
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
|
||||
*result = malloc(size);
|
||||
#elif defined(LIBC_GLIBC)
|
||||
- *result = __libc_malloc(size);
|
||||
+ *result = ::__libc_malloc(size);
|
||||
#endif
|
||||
return *result != nullptr;
|
||||
}
|
||||
@@ -122,7 +129,7 @@
|
||||
#elif defined(MEMORY_TOOL_REPLACES_ALLOCATOR) || !defined(LIBC_GLIBC)
|
||||
free(ptr);
|
||||
#elif defined(LIBC_GLIBC)
|
||||
- __libc_free(ptr);
|
||||
+ ::__libc_free(ptr);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
Source: https://git.alpinelinux.org/aports/plain/community/chromium/no-execinfo.patch
|
||||
musl does not have execinfo.h, and hence no implementation of
|
||||
. backtrace()
|
||||
. backtrace_symbols()
|
||||
for discussion about this, see https://www.openwall.com/lists/musl/2021/07/16/1
|
||||
--
|
||||
--- a/v8/src/codegen/external-reference-table.cc
|
||||
+++ b/v8/src/codegen/external-reference-table.cc
|
||||
@@ -11,7 +11,9 @@
|
||||
|
||||
#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
|
||||
#define SYMBOLIZE_FUNCTION
|
||||
+#if defined(__GLIBC__)
|
||||
#include <execinfo.h>
|
||||
+#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -96,7 +98,7 @@
|
||||
}
|
||||
|
||||
const char* ExternalReferenceTable::ResolveSymbol(void* address) {
|
||||
-#ifdef SYMBOLIZE_FUNCTION
|
||||
+#if defined(SYMBOLIZE_FUNCTION) && defined(__GLIBC__)
|
||||
char** names = backtrace_symbols(&address, 1);
|
||||
const char* name = names[0];
|
||||
// The array of names is malloc'ed. However, each name string is static
|
||||
--- a/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
||||
+++ b/third_party/swiftshader/third_party/llvm-subzero/build/Linux/include/llvm/Config/config.h
|
||||
@@ -17,7 +17,11 @@
|
||||
#define ENABLE_CRASH_OVERRIDES 0
|
||||
|
||||
/* Define to 1 if you have the `backtrace' function. */
|
||||
+#ifdef __GLIBC__
|
||||
#define HAVE_BACKTRACE 1
|
||||
+#else
|
||||
+#define HAVE_BACKTRACE 0
|
||||
+#endif
|
||||
|
||||
/* Define to 1 if you have the <CrashReporterClient.h> header file. */
|
||||
/* #undef HAVE_CRASHREPORTERCLIENT_H */
|
||||
@@ -58,7 +62,11 @@
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
+#ifdef __GLIBC__
|
||||
#define HAVE_EXECINFO_H 1
|
||||
+#else
|
||||
+#define HAVE_EXECINFO_H 0
|
||||
+#endif
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
--- a/base/debug/stack_trace.cc
|
||||
+++ b/base/debug/stack_trace.cc
|
||||
@@ -251,7 +253,9 @@
|
||||
}
|
||||
|
||||
void StackTrace::OutputToStream(std::ostream* os) const {
|
||||
+#if defined(__GLIBC__) && !defined(_AIX)
|
||||
OutputToStreamWithPrefix(os, nullptr);
|
||||
+#endif
|
||||
}
|
||||
|
||||
std::string StackTrace::ToString() const {
|
||||
@@ -281,7 +281,7 @@
|
||||
}
|
||||
std::string StackTrace::ToStringWithPrefix(const char* prefix_string) const {
|
||||
std::stringstream stream;
|
||||
-#if !defined(__UCLIBC__) && !defined(_AIX)
|
||||
+#if defined(__GLIBC__) && !defined(_AIX)
|
||||
OutputToStreamWithPrefix(&stream, prefix_string);
|
||||
#endif
|
||||
return stream.str();
|
||||
--- a/base/debug/stack_trace_unittest.cc
|
||||
+++ b/base/debug/stack_trace_unittest.cc
|
||||
@@ -33,7 +33,7 @@
|
||||
typedef testing::Test StackTraceTest;
|
||||
#endif
|
||||
|
||||
-#if !defined(__UCLIBC__) && !defined(_AIX)
|
||||
+#if !defined(__UCLIBC__) && !defined(_AIX) && defined(__GLIBC__)
|
||||
// StackTrace::OutputToStream() is not implemented under uclibc, nor AIX.
|
||||
// See https://crbug.com/706728
|
||||
|
||||
@@ -156,7 +156,7 @@
|
||||
|
||||
#endif // !defined(__UCLIBC__) && !defined(_AIX)
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
+#if (BUILDFLAG(IS_POSIX) && defined(__GLIBC__)) && !BUILDFLAG(IS_ANDROID)
|
||||
#if !BUILDFLAG(IS_IOS)
|
||||
static char* newArray() {
|
||||
// Clang warns about the mismatched new[]/delete if they occur in the same
|
125
srcpkgs/electron24/files/patches/chromium-musl-no-mallinfo.patch
Normal file
125
srcpkgs/electron24/files/patches/chromium-musl-no-mallinfo.patch
Normal file
|
@ -0,0 +1,125 @@
|
|||
Source: https://git.alpinelinux.org/aports/plain/community/chromium/no-mallinfo.patch
|
||||
musl does not implement mallinfo()/mallinfo2()
|
||||
(or rather, malloc-ng, musl's allocator, doesn't)
|
||||
--
|
||||
--- a/base/trace_event/malloc_dump_provider.cc
|
||||
+++ b/base/trace_event/malloc_dump_provider.cc
|
||||
@@ -185,7 +185,6 @@
|
||||
#define MALLINFO2_FOUND_IN_LIBC
|
||||
struct mallinfo2 info = mallinfo2();
|
||||
#endif
|
||||
-#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
||||
#if !defined(MALLINFO2_FOUND_IN_LIBC)
|
||||
struct mallinfo info = mallinfo();
|
||||
#endif
|
||||
@@ -205,6 +204,7 @@
|
||||
sys_alloc_dump->AddScalar(MemoryAllocatorDump::kNameSize,
|
||||
MemoryAllocatorDump::kUnitsBytes, info.uordblks);
|
||||
}
|
||||
+#endif // defined(__GLIBC__) && defined(__GLIBC_PREREQ)
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -339,7 +340,7 @@
|
||||
&allocated_objects_count);
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
// TODO(fuchsia): Port, see https://crbug.com/706592.
|
||||
-#else
|
||||
+#elif defined(__GLIBC__)
|
||||
ReportMallinfoStats(/*pmd=*/nullptr, &total_virtual_size, &resident_size,
|
||||
&allocated_objects_size, &allocated_objects_count);
|
||||
#endif
|
||||
--- a/base/process/process_metrics_posix.cc
|
||||
+++ b/base/process/process_metrics_posix.cc
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
#endif // !BUILDFLAG(IS_FUCHSIA)
|
||||
|
||||
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
||||
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
||||
namespace {
|
||||
|
||||
size_t GetMallocUsageMallinfo() {
|
||||
@@ -123,7 +123,7 @@
|
||||
}
|
||||
|
||||
} // namespace
|
||||
-#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) ||
|
||||
+#endif // (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) ||
|
||||
// BUILDFLAG(IS_ANDROID)
|
||||
|
||||
size_t ProcessMetrics::GetMallocUsage() {
|
||||
@@ -131,9 +131,9 @@
|
||||
malloc_statistics_t stats = {0};
|
||||
malloc_zone_statistics(nullptr, &stats);
|
||||
return stats.size_in_use;
|
||||
-#elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
||||
+#elif (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
|
||||
return GetMallocUsageMallinfo();
|
||||
-#elif BUILDFLAG(IS_FUCHSIA)
|
||||
+#else
|
||||
// TODO(fuchsia): Not currently exposed. https://crbug.com/735087.
|
||||
return 0;
|
||||
#endif
|
||||
--- ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc.orig
|
||||
+++ ./third_party/tflite/src/tensorflow/lite/profiling/memory_info.cc
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
MemoryUsage GetMemoryUsage() {
|
||||
MemoryUsage result;
|
||||
-#ifdef __linux__
|
||||
+#if defined(__linux__) && defined(__GLIBC__)
|
||||
rusage res;
|
||||
if (getrusage(RUSAGE_SELF, &res) == 0) {
|
||||
result.max_rss_kb = res.ru_maxrss;
|
||||
--- ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc
|
||||
+++ ./third_party/swiftshader/third_party/llvm-subzero/lib/Support/Unix/Process.inc.orig
|
||||
@@ -86,11 +86,11 @@
|
||||
}
|
||||
|
||||
size_t Process::GetMallocUsage() {
|
||||
-#if defined(HAVE_MALLINFO2)
|
||||
+#if defined(HAVE_MALLINFO2) && defined(__GLIBC__)
|
||||
struct mallinfo2 mi;
|
||||
mi = ::mallinfo2();
|
||||
return mi.uordblks;
|
||||
-#elif defined(HAVE_MALLINFO)
|
||||
+#elif defined(HAVE_MALLINFO) && defined(__GLIBC__)
|
||||
struct mallinfo mi;
|
||||
mi = ::mallinfo();
|
||||
return mi.uordblks;
|
||||
|
||||
--- ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h.orig 2019-09-30 13:03:42.556880537 -0400
|
||||
+++ ./third_party/swiftshader/third_party/llvm-10.0/configs/linux/include/llvm/Config/config.h 2019-09-30 13:07:27.989821227 -0400
|
||||
@@ -122,7 +122,9 @@
|
||||
/* #undef HAVE_MALLCTL */
|
||||
|
||||
/* Define to 1 if you have the `mallinfo' function. */
|
||||
+#if defined(__GLIBC__)
|
||||
#define HAVE_MALLINFO 1
|
||||
+#endif
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#define HAVE_MALLOC_H 1
|
||||
--- a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
|
||||
+++ b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc.cc
|
||||
@@ -717,7 +717,7 @@
|
||||
|
||||
#endif // !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)
|
||||
|
||||
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
+#if 0
|
||||
SHIM_ALWAYS_EXPORT struct mallinfo mallinfo(void) __THROW {
|
||||
base::SimplePartitionStatsDumper allocator_dumper;
|
||||
Allocator()->DumpStats("malloc", true, &allocator_dumper);
|
||||
--- a/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
|
||||
+++ b/base/allocator/partition_allocator/shim/allocator_shim_default_dispatch_to_partition_alloc_unittest.cc
|
||||
@@ -24,7 +24,7 @@
|
||||
#if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
|
||||
|
||||
// Platforms on which we override weak libc symbols.
|
||||
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
NOINLINE void FreeForTest(void* data) {
|
||||
free(data);
|
|
@ -0,0 +1,11 @@
|
|||
--- a/base/allocator/partition_allocator/partition_root.cc
|
||||
+++ b/base/allocator/partition_allocator/partition_root.cc
|
||||
@@ -239,7 +239,7 @@
|
||||
if (!g_global_init_called.compare_exchange_strong(expected, true))
|
||||
return;
|
||||
|
||||
-#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
|
||||
+#if (BUILDFLAG(IS_LINUX) && defined(__GLIBC__)) || BUILDFLAG(IS_CHROMEOS)
|
||||
// When fork() is called, only the current thread continues to execute in the
|
||||
// child process. If the lock is held, but *not* by this thread when fork() is
|
||||
// called, we have a deadlock.
|
|
@ -0,0 +1,24 @@
|
|||
Use monotonic clock for pthread_cond_timedwait with musl too.
|
||||
|
||||
diff --git a/v8/src/base/platform/condition-variable.cc b/v8/src/base/platform/condition-variable.cc
|
||||
index 5ea7083..c13027e 100644
|
||||
--- a/v8/src/base/platform/condition-variable.cc
|
||||
+++ b/v8/src/base/platform/condition-variable.cc
|
||||
@@ -16,7 +16,7 @@ namespace base {
|
||||
|
||||
ConditionVariable::ConditionVariable() {
|
||||
#if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
|
||||
- (V8_OS_LINUX && V8_LIBC_GLIBC))
|
||||
+ V8_OS_LINUX)
|
||||
// On Free/Net/OpenBSD and Linux with glibc we can change the time
|
||||
// source for pthread_cond_timedwait() to use the monotonic clock.
|
||||
pthread_condattr_t attr;
|
||||
@@ -92,7 +92,7 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) {
|
||||
&native_handle_, &mutex->native_handle(), &ts);
|
||||
#else
|
||||
#if (V8_OS_FREEBSD || V8_OS_NETBSD || V8_OS_OPENBSD || \
|
||||
- (V8_OS_LINUX && V8_LIBC_GLIBC))
|
||||
+ V8_OS_LINUX)
|
||||
// On Free/Net/OpenBSD and Linux with glibc we can change the time
|
||||
// source for pthread_cond_timedwait() to use the monotonic clock.
|
||||
result = clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
@ -0,0 +1,27 @@
|
|||
--- a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc 2015-12-06 09:59:55.554536646 +0100
|
||||
+++ b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc 2015-12-06 10:01:16.818238035 +0100
|
||||
@@ -477,7 +477,9 @@ bool ExceptionHandler::SimulateSignalDel
|
||||
siginfo.si_code = SI_USER;
|
||||
siginfo.si_pid = getpid();
|
||||
ucontext_t context;
|
||||
+#if defined(__GLIBC__)
|
||||
getcontext(&context);
|
||||
+#endif
|
||||
return HandleSignal(sig, &siginfo, &context);
|
||||
}
|
||||
|
||||
@@ -647,9 +649,14 @@ bool ExceptionHandler::WriteMinidump() {
|
||||
sys_prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
|
||||
|
||||
CrashContext context;
|
||||
+
|
||||
+#if defined(__GLIBC__)
|
||||
int getcontext_result = getcontext(&context.context);
|
||||
if (getcontext_result)
|
||||
return false;
|
||||
+#else
|
||||
+ return false;
|
||||
+#endif
|
||||
|
||||
#if defined(__i386__)
|
||||
// In CPUFillFromUContext in minidumpwriter.cc the stack pointer is retrieved
|
11
srcpkgs/electron24/files/patches/chromium-old-clang.patch
Normal file
11
srcpkgs/electron24/files/patches/chromium-old-clang.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/build/config/compiler/BUILD.gn
|
||||
+++ b/build/config/compiler/BUILD.gn
|
||||
@@ -1288,7 +1288,7 @@
|
||||
} else {
|
||||
# -ffile-compilation-dir is an alias for both -fdebug-compilation-dir=
|
||||
# and -fcoverage-compilation-dir=.
|
||||
- cflags += [ "-ffile-compilation-dir=." ]
|
||||
+ cflags += [ "-fdebug-compilation-dir=." ]
|
||||
swiftflags += [ "-file-compilation-dir=." ]
|
||||
}
|
||||
if (!is_win) {
|
|
@ -0,0 +1,19 @@
|
|||
--- a/BUILD.gn.orig
|
||||
+++ b/BUILD.gn
|
||||
@@ -1616,16 +1616,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-# TODO(cassew): Add more OS's that don't support x86.
|
||||
-is_valid_x86_target =
|
||||
- target_os != "ios" && target_os != "mac" &&
|
||||
- (target_os != "linux" || use_libfuzzer || !build_with_chromium)
|
||||
-
|
||||
-# Note: v8_target_cpu == arm allows using the V8 arm simulator on x86 for fuzzing.
|
||||
-assert(
|
||||
- is_valid_x86_target || target_cpu != "x86" || v8_target_cpu == "arm",
|
||||
- "'target_cpu=x86' is not supported for 'target_os=$target_os'. Consider omitting 'target_cpu' (default) or using 'target_cpu=x64' instead.")
|
||||
-
|
||||
group("chromium_builder_perf") {
|
||||
testonly = true
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
--- a/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h
|
||||
+++ b/third_party/crashpad/crashpad/compat/linux/sys/ptrace.h
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
#include_next <sys/ptrace.h>
|
||||
|
||||
-#include <sys/cdefs.h>
|
||||
-
|
||||
// https://sourceware.org/bugzilla/show_bug.cgi?id=22433
|
||||
#if !defined(PTRACE_GET_THREAD_AREA) && !defined(PT_GET_THREAD_AREA) && \
|
||||
defined(__GLIBC__)
|
||||
--- a/third_party/libsync/src/include/sync/sync.h
|
||||
+++ b/third_party/libsync/src/include/sync/sync.h
|
||||
@@ -19,12 +19,13 @@
|
||||
#ifndef __SYS_CORE_SYNC_H
|
||||
#define __SYS_CORE_SYNC_H
|
||||
|
||||
-#include <sys/cdefs.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
-__BEGIN_DECLS
|
||||
+#ifdef __cplusplus
|
||||
+extern "C" {
|
||||
+#endif
|
||||
|
||||
struct sync_legacy_merge_data {
|
||||
int32_t fd2;
|
||||
@@ -158,6 +159,8 @@
|
||||
struct sync_pt_info *itr);
|
||||
void sync_fence_info_free(struct sync_fence_info_data *info);
|
||||
|
||||
-__END_DECLS
|
||||
+#ifdef __cplusplus
|
||||
+}
|
||||
+#endif
|
||||
|
||||
#endif /* __SYS_CORE_SYNC_H */
|
27
srcpkgs/electron24/files/patches/chromium-riscv-angle.patch
Normal file
27
srcpkgs/electron24/files/patches/chromium-riscv-angle.patch
Normal file
|
@ -0,0 +1,27 @@
|
|||
Index: chromium-103.0.5060.53/third_party/angle/gni/angle.gni
|
||||
===================================================================
|
||||
--- chromium-103.0.5060.53.orig/third_party/angle/gni/angle.gni
|
||||
+++ chromium-103.0.5060.53/third_party/angle/gni/angle.gni
|
||||
@@ -77,7 +77,8 @@ declare_args() {
|
||||
|
||||
if (current_cpu == "arm64" || current_cpu == "x64" ||
|
||||
current_cpu == "mips64el" || current_cpu == "s390x" ||
|
||||
- current_cpu == "ppc64" || current_cpu == "loong64") {
|
||||
+ current_cpu == "ppc64" || current_cpu == "loong64" ||
|
||||
+ current_cpu == "riscv64") {
|
||||
angle_64bit_current_cpu = true
|
||||
} else if (current_cpu == "arm" || current_cpu == "x86" ||
|
||||
current_cpu == "mipsel" || current_cpu == "s390" ||
|
||||
Index: chromium-103.0.5060.53/third_party/angle/src/common/platform.h
|
||||
===================================================================
|
||||
--- chromium-103.0.5060.53.orig/third_party/angle/src/common/platform.h
|
||||
+++ chromium-103.0.5060.53/third_party/angle/src/common/platform.h
|
||||
@@ -102,7 +102,7 @@
|
||||
#endif
|
||||
|
||||
// Mips and arm devices need to include stddef for size_t.
|
||||
-#if defined(__mips__) || defined(__arm__) || defined(__aarch64__)
|
||||
+#if defined(__mips__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv)
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
777
srcpkgs/electron24/files/patches/chromium-riscv-crashpad.patch
Normal file
777
srcpkgs/electron24/files/patches/chromium-riscv-crashpad.patch
Normal file
|
@ -0,0 +1,777 @@
|
|||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/minidump/minidump_context.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context.h
|
||||
@@ -592,6 +592,41 @@ struct MinidumpContextMIPS64 {
|
||||
uint64_t fir;
|
||||
};
|
||||
|
||||
+//! \brief 64bit RISC-V-specifc flags for MinidumpContextRISCV64::context_flags.
|
||||
+//! Based on minidump_cpu_riscv64.h from breakpad
|
||||
+enum MinidumpContextRISCV64Flags : uint32_t {
|
||||
+ //! \brief Identifies the context structure as RISCV64.
|
||||
+ kMinidumpContextRISCV64 = 0x00080000,
|
||||
+
|
||||
+ //! \brief Indicates the validity of integer registers.
|
||||
+ //!
|
||||
+ //! Registers `x1`-`x31` and pc are valid.
|
||||
+ kMinidumpContextRISCV64Integer = kMinidumpContextRISCV64 | 0x00000002,
|
||||
+
|
||||
+ //! \brief Indicates the validity of floating point registers.
|
||||
+ //!
|
||||
+ //! Floating point registers `f0`-`f31`, and `fcsr` are valid
|
||||
+ kMinidumpContextRISCV64FloatingPoint = kMinidumpContextRISCV64 | 0x00000004,
|
||||
+
|
||||
+ //! \brief Indicates the validity of all registers.
|
||||
+ kMinidumpContextRISCV64All = kMinidumpContextRISCV64Integer |
|
||||
+ kMinidumpContextRISCV64FloatingPoint,
|
||||
+};
|
||||
+
|
||||
+//! \brief A 64bit RISCV CPU context (register state) carried in a minidump file.
|
||||
+struct MinidumpContextRISCV64 {
|
||||
+ uint64_t context_flags;
|
||||
+
|
||||
+ //! \brief General purpose registers.
|
||||
+ uint64_t regs[32];
|
||||
+
|
||||
+ //! \brief FPU registers.
|
||||
+ uint64_t fpregs[32];
|
||||
+
|
||||
+ //! \brief FPU status register.
|
||||
+ uint64_t fcsr;
|
||||
+};
|
||||
+
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_H_
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context_writer.cc
|
||||
@@ -102,6 +102,13 @@ MinidumpContextWriter::CreateFromSnapsho
|
||||
break;
|
||||
}
|
||||
|
||||
+ case kCPUArchitectureRISCV64: {
|
||||
+ context = std::make_unique<MinidumpContextRISCV64Writer>();
|
||||
+ reinterpret_cast<MinidumpContextRISCV64Writer*>(context.get())
|
||||
+ ->InitializeFromSnapshot(context_snapshot->riscv64);
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
default: {
|
||||
LOG(ERROR) << "unknown context architecture "
|
||||
<< context_snapshot->architecture;
|
||||
@@ -453,5 +460,42 @@ size_t MinidumpContextMIPS64Writer::Cont
|
||||
DCHECK_GE(state(), kStateFrozen);
|
||||
return sizeof(context_);
|
||||
}
|
||||
+
|
||||
+MinidumpContextRISCV64Writer::MinidumpContextRISCV64Writer()
|
||||
+ : MinidumpContextWriter(), context_() {
|
||||
+ context_.context_flags = kMinidumpContextRISCV64;
|
||||
+}
|
||||
+
|
||||
+MinidumpContextRISCV64Writer::~MinidumpContextRISCV64Writer() = default;
|
||||
+
|
||||
+void MinidumpContextRISCV64Writer::InitializeFromSnapshot(
|
||||
+ const CPUContextRISCV64* context_snapshot) {
|
||||
+ DCHECK_EQ(state(), kStateMutable);
|
||||
+ DCHECK_EQ(context_.context_flags, kMinidumpContextRISCV64);
|
||||
+
|
||||
+ context_.context_flags = kMinidumpContextRISCV64All;
|
||||
+
|
||||
+ static_assert(sizeof(context_.regs) == sizeof(context_snapshot->regs),
|
||||
+ "GPRs size mismatch");
|
||||
+ memcpy(context_.regs, context_snapshot->regs, sizeof(context_.regs));
|
||||
+
|
||||
+ static_assert(sizeof(context_.fpregs) == sizeof(context_snapshot->fpregs),
|
||||
+ "FPRs size mismatch");
|
||||
+ memcpy(context_.fpregs,
|
||||
+ context_snapshot->fpregs,
|
||||
+ sizeof(context_.fpregs));
|
||||
+ context_.fcsr = context_snapshot->fcsr;
|
||||
+}
|
||||
+
|
||||
+bool MinidumpContextRISCV64Writer::WriteObject(
|
||||
+ FileWriterInterface* file_writer) {
|
||||
+ DCHECK_EQ(state(), kStateWritable);
|
||||
+ return file_writer->Write(&context_, sizeof(context_));
|
||||
+}
|
||||
+
|
||||
+size_t MinidumpContextRISCV64Writer::ContextSize() const {
|
||||
+ DCHECK_GE(state(), kStateFrozen);
|
||||
+ return sizeof(context_);
|
||||
+}
|
||||
|
||||
} // namespace crashpad
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_context_writer.h
|
||||
@@ -330,6 +330,49 @@ class MinidumpContextMIPS64Writer final
|
||||
MinidumpContextMIPS64 context_;
|
||||
};
|
||||
|
||||
+//! \brief The writer for a MinidumpContextRISCV64 structure in a minidump file.
|
||||
+class MinidumpContextRISCV64Writer final : public MinidumpContextWriter {
|
||||
+ public:
|
||||
+ MinidumpContextRISCV64Writer();
|
||||
+
|
||||
+ MinidumpContextRISCV64Writer(const MinidumpContextRISCV64Writer&) = delete;
|
||||
+ MinidumpContextRISCV64Writer& operator=(const MinidumpContextRISCV64Writer&) =
|
||||
+ delete;
|
||||
+
|
||||
+ ~MinidumpContextRISCV64Writer() override;
|
||||
+
|
||||
+ //! \brief Initializes the MinidumpContextRISCV based on \a context_snapshot.
|
||||
+ //!
|
||||
+ //! \param[in] context_snapshot The context snapshot to use as source data.
|
||||
+ //!
|
||||
+ //! \note Valid in #kStateMutable. No mutation of context() may be done before
|
||||
+ //! calling this method, and it is not normally necessary to alter
|
||||
+ //! context() after calling this method.
|
||||
+ void InitializeFromSnapshot(const CPUContextRISCV64* context_snapshot);
|
||||
+
|
||||
+ //! \brief Returns a pointer to the context structure that this object will
|
||||
+ //! write.
|
||||
+ //!
|
||||
+ //! \attention This returns a non-`const` pointer to this object’s private
|
||||
+ //! data so that a caller can populate the context structure directly.
|
||||
+ //! This is done because providing setter interfaces to each field in the
|
||||
+ //! context structure would be unwieldy and cumbersome. Care must be taken
|
||||
+ //! to populate the context structure correctly. The context structure
|
||||
+ //! must only be modified while this object is in the #kStateMutable
|
||||
+ //! state.
|
||||
+ MinidumpContextRISCV64* context() { return &context_; }
|
||||
+
|
||||
+ protected:
|
||||
+ // MinidumpWritable:
|
||||
+ bool WriteObject(FileWriterInterface* file_writer) override;
|
||||
+
|
||||
+ // MinidumpContextWriter:
|
||||
+ size_t ContextSize() const override;
|
||||
+
|
||||
+ private:
|
||||
+ MinidumpContextRISCV64 context_;
|
||||
+};
|
||||
+
|
||||
} // namespace crashpad
|
||||
|
||||
#endif // CRASHPAD_MINIDUMP_MINIDUMP_CONTEXT_WRITER_H_
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/minidump/minidump_misc_info_writer.cc
|
||||
@@ -135,6 +135,10 @@ std::string MinidumpMiscInfoDebugBuildSt
|
||||
static constexpr char kCPU[] = "mips";
|
||||
#elif defined(ARCH_CPU_MIPS64EL)
|
||||
static constexpr char kCPU[] = "mips64";
|
||||
+#elif defined(ARCH_CPU_RISCV32)
|
||||
+ static constexpr char kCPU[] = "riscv32";
|
||||
+#elif defined(ARCH_CPU_RISCV64)
|
||||
+ static constexpr char kCPU[] = "riscv64";
|
||||
#else
|
||||
#error define kCPU for this CPU
|
||||
#endif
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/capture_memory.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/capture_memory.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/capture_memory.cc
|
||||
@@ -112,6 +112,16 @@ void CaptureMemory::PointedToByContext(c
|
||||
for (size_t i = 0; i < std::size(context.mipsel->regs); ++i) {
|
||||
MaybeCaptureMemoryAround(delegate, context.mipsel->regs[i]);
|
||||
}
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ if (context.architecture == kCPUArchitectureRISCV64) {
|
||||
+ for (size_t i = 0; i < std::size(context.riscv64->regs); ++i) {
|
||||
+ MaybeCaptureMemoryAround(delegate, context.riscv64->regs[i]);
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (size_t i = 0; i < std::size(context.riscv32->regs); ++i) {
|
||||
+ MaybeCaptureMemoryAround(delegate, context.riscv32->regs[i]);
|
||||
+ }
|
||||
+ }
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_architecture.h
|
||||
@@ -43,7 +43,13 @@ enum CPUArchitecture {
|
||||
kCPUArchitectureMIPSEL,
|
||||
|
||||
//! \brief 64-bit MIPSEL.
|
||||
- kCPUArchitectureMIPS64EL
|
||||
+ kCPUArchitectureMIPS64EL,
|
||||
+
|
||||
+ //! \brief 32-bit RISCV.
|
||||
+ kCPUArchitectureRISCV32,
|
||||
+
|
||||
+ //! \brief 64-bit RISCV.
|
||||
+ kCPUArchitectureRISCV64
|
||||
};
|
||||
|
||||
} // namespace crashpad
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_context.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/cpu_context.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_context.cc
|
||||
@@ -197,10 +197,12 @@ bool CPUContext::Is64Bit() const {
|
||||
case kCPUArchitectureX86_64:
|
||||
case kCPUArchitectureARM64:
|
||||
case kCPUArchitectureMIPS64EL:
|
||||
+ case kCPUArchitectureRISCV64:
|
||||
return true;
|
||||
case kCPUArchitectureX86:
|
||||
case kCPUArchitectureARM:
|
||||
case kCPUArchitectureMIPSEL:
|
||||
+ case kCPUArchitectureRISCV32:
|
||||
return false;
|
||||
default:
|
||||
NOTREACHED();
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_context.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/cpu_context.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/cpu_context.h
|
||||
@@ -352,6 +352,20 @@ struct CPUContextMIPS64 {
|
||||
uint64_t fir;
|
||||
};
|
||||
|
||||
+//! \brief A context structure carrying RISCV32 CPU state.
|
||||
+struct CPUContextRISCV32 {
|
||||
+ uint32_t regs[32];
|
||||
+ uint64_t fpregs[32];
|
||||
+ uint32_t fcsr;
|
||||
+};
|
||||
+
|
||||
+//! \brief A context structure carrying RISCV64 CPU state.
|
||||
+struct CPUContextRISCV64 {
|
||||
+ uint64_t regs[32];
|
||||
+ uint64_t fpregs[32];
|
||||
+ uint32_t fcsr;
|
||||
+};
|
||||
+
|
||||
//! \brief A context structure capable of carrying the context of any supported
|
||||
//! CPU architecture.
|
||||
struct CPUContext {
|
||||
@@ -382,6 +396,8 @@ struct CPUContext {
|
||||
CPUContextARM64* arm64;
|
||||
CPUContextMIPS* mipsel;
|
||||
CPUContextMIPS64* mips64;
|
||||
+ CPUContextRISCV32* riscv32;
|
||||
+ CPUContextRISCV64* riscv64;
|
||||
};
|
||||
};
|
||||
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.cc
|
||||
@@ -266,6 +266,30 @@ void InitializeCPUContextARM64_OnlyFPSIM
|
||||
context->fpcr = float_context.fpcr;
|
||||
}
|
||||
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+
|
||||
+template <typename Traits>
|
||||
+void InitializeCPUContextRISCV(
|
||||
+ const typename Traits::SignalThreadContext& thread_context,
|
||||
+ const typename Traits::SignalFloatContext& float_context,
|
||||
+ typename Traits::CPUContext* context) {
|
||||
+ static_assert(sizeof(context->regs) == sizeof(thread_context),
|
||||
+ "registers size mismatch");
|
||||
+ static_assert(sizeof(context->fpregs) == sizeof(float_context.f),
|
||||
+ "fp registers size mismatch");
|
||||
+ memcpy(&context->regs, &thread_context, sizeof(context->regs));
|
||||
+ memcpy(&context->fpregs, &float_context.f, sizeof(context->fpregs));
|
||||
+ context->fcsr = float_context.fcsr;
|
||||
+}
|
||||
+template void InitializeCPUContextRISCV<ContextTraits32>(
|
||||
+ const ContextTraits32::SignalThreadContext& thread_context,
|
||||
+ const ContextTraits32::SignalFloatContext& float_context,
|
||||
+ ContextTraits32::CPUContext* context);
|
||||
+template void InitializeCPUContextRISCV<ContextTraits64>(
|
||||
+ const ContextTraits64::SignalThreadContext& thread_context,
|
||||
+ const ContextTraits64::SignalFloatContext& float_context,
|
||||
+ ContextTraits64::CPUContext* context);
|
||||
+
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
|
||||
} // namespace internal
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/cpu_context_linux.h
|
||||
@@ -174,6 +174,22 @@ void InitializeCPUContextMIPS(
|
||||
|
||||
#endif // ARCH_CPU_MIPS_FAMILY || DOXYGEN
|
||||
|
||||
+#if defined(ARCH_CPU_RISCV_FAMILY) || DOXYGEN
|
||||
+
|
||||
+//! \brief Initializes a CPUContextRISCV structure from native context
|
||||
+//! structures on Linux.
|
||||
+//!
|
||||
+//! \param[in] thread_context The native thread context.
|
||||
+//! \param[in] float_context The native float context.
|
||||
+//! \param[out] context The CPUContextRISCV structure to initialize.
|
||||
+template <typename Traits>
|
||||
+void InitializeCPUContextRISCV(
|
||||
+ const typename Traits::SignalThreadContext& thread_context,
|
||||
+ const typename Traits::SignalFloatContext& float_context,
|
||||
+ typename Traits::CPUContext* context);
|
||||
+
|
||||
+#endif // ARCH_CPU_RISCV_FAMILY || DOXYGEN
|
||||
+
|
||||
} // namespace internal
|
||||
} // namespace crashpad
|
||||
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.cc
|
||||
@@ -325,6 +325,61 @@ bool ExceptionSnapshotLinux::ReadContext
|
||||
reader, context_address, context_.mips64);
|
||||
}
|
||||
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+
|
||||
+template <typename Traits>
|
||||
+static bool ReadContext(ProcessReaderLinux* reader,
|
||||
+ LinuxVMAddress context_address,
|
||||
+ typename Traits::CPUContext* dest_context) {
|
||||
+ const ProcessMemory* memory = reader->Memory();
|
||||
+
|
||||
+ LinuxVMAddress gregs_address = context_address +
|
||||
+ offsetof(UContext<Traits>, mcontext) +
|
||||
+ offsetof(typename Traits::MContext, gregs);
|
||||
+
|
||||
+ typename Traits::SignalThreadContext thread_context;
|
||||
+ if (!memory->Read(gregs_address, sizeof(thread_context), &thread_context)) {
|
||||
+ LOG(ERROR) << "Couldn't read gregs";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ LinuxVMAddress fpregs_address = context_address +
|
||||
+ offsetof(UContext<Traits>, mcontext) +
|
||||
+ offsetof(typename Traits::MContext, fpregs);
|
||||
+
|
||||
+ typename Traits::SignalFloatContext fp_context;
|
||||
+ if (!memory->Read(fpregs_address, sizeof(fp_context), &fp_context)) {
|
||||
+ LOG(ERROR) << "Couldn't read fpregs";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ InitializeCPUContextRISCV<Traits>(thread_context, fp_context, dest_context);
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+template <>
|
||||
+bool ExceptionSnapshotLinux::ReadContext<ContextTraits32>(
|
||||
+ ProcessReaderLinux* reader,
|
||||
+ LinuxVMAddress context_address) {
|
||||
+ context_.architecture = kCPUArchitectureRISCV32;
|
||||
+ context_.riscv32 = &context_union_.riscv32;
|
||||
+
|
||||
+ return internal::ReadContext<ContextTraits32>(
|
||||
+ reader, context_address, context_.riscv32);
|
||||
+}
|
||||
+
|
||||
+template <>
|
||||
+bool ExceptionSnapshotLinux::ReadContext<ContextTraits64>(
|
||||
+ ProcessReaderLinux* reader,
|
||||
+ LinuxVMAddress context_address) {
|
||||
+ context_.architecture = kCPUArchitectureRISCV64;
|
||||
+ context_.riscv64 = &context_union_.riscv64;
|
||||
+
|
||||
+ return internal::ReadContext<ContextTraits64>(
|
||||
+ reader, context_address, context_.riscv64);
|
||||
+}
|
||||
+
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
|
||||
bool ExceptionSnapshotLinux::Initialize(
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/exception_snapshot_linux.h
|
||||
@@ -89,6 +89,9 @@ class ExceptionSnapshotLinux final : pub
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
CPUContextMIPS mipsel;
|
||||
CPUContextMIPS64 mips64;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ CPUContextRISCV32 riscv32;
|
||||
+ CPUContextRISCV64 riscv64;
|
||||
#endif
|
||||
} context_union_;
|
||||
CPUContext context_;
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/process_reader_linux.cc
|
||||
@@ -108,6 +108,9 @@ void ProcessReaderLinux::Thread::Initial
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.regs[29]
|
||||
: thread_info.thread_context.t32.regs[29];
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ stack_pointer = reader->Is64Bit() ? thread_info.thread_context.t64.sp
|
||||
+ : thread_info.thread_context.t32.sp;
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
||||
@@ -422,6 +422,67 @@ static_assert(offsetof(UContext<ContextT
|
||||
"context offset mismatch");
|
||||
#endif
|
||||
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+
|
||||
+struct MContext32 {
|
||||
+ uint32_t gregs[32];
|
||||
+ uint64_t fpregs[32];
|
||||
+ unsigned int fcsr;
|
||||
+};
|
||||
+
|
||||
+struct MContext64 {
|
||||
+ uint64_t gregs[32];
|
||||
+ uint64_t fpregs[32];
|
||||
+ unsigned int fcsr;
|
||||
+};
|
||||
+
|
||||
+struct ContextTraits32 : public Traits32 {
|
||||
+ using MContext = MContext32;
|
||||
+ using SignalThreadContext = ThreadContext::t32_t;
|
||||
+ using SignalFloatContext = FloatContext::f32_t;
|
||||
+ using CPUContext = CPUContextRISCV32;
|
||||
+};
|
||||
+
|
||||
+struct ContextTraits64 : public Traits64 {
|
||||
+ using MContext = MContext64;
|
||||
+ using SignalThreadContext = ThreadContext::t64_t;
|
||||
+ using SignalFloatContext = FloatContext::f64_t;
|
||||
+ using CPUContext = CPUContextRISCV64;
|
||||
+};
|
||||
+
|
||||
+template <typename Traits>
|
||||
+struct UContext {
|
||||
+ typename Traits::ULong flags;
|
||||
+ typename Traits::Address link;
|
||||
+ SignalStack<Traits> stack;
|
||||
+ Sigset<Traits> sigmask;
|
||||
+ char padding[128 - sizeof(sigmask)];
|
||||
+ typename Traits::Char_64Only padding2[8];
|
||||
+ typename Traits::MContext mcontext;
|
||||
+};
|
||||
+
|
||||
+#if defined(ARCH_CPU_RISCV32)
|
||||
+static_assert(offsetof(UContext<ContextTraits32>, mcontext) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext),
|
||||
+ "context offset mismatch");
|
||||
+static_assert(offsetof(UContext<ContextTraits32>, mcontext.gregs) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext.__gregs),
|
||||
+ "context offset mismatch");
|
||||
+static_assert(offsetof(UContext<ContextTraits32>, mcontext.fpregs) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext.__fpregs),
|
||||
+ "context offset mismatch");
|
||||
+#elif defined(ARCH_CPU_RISCV64)
|
||||
+static_assert(offsetof(UContext<ContextTraits64>, mcontext) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext),
|
||||
+ "context offset mismatch");
|
||||
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.gregs) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext.__gregs),
|
||||
+ "context offset mismatch");
|
||||
+static_assert(offsetof(UContext<ContextTraits64>, mcontext.fpregs) ==
|
||||
+ offsetof(ucontext_t, uc_mcontext.__fpregs),
|
||||
+ "context offset mismatch");
|
||||
+#endif
|
||||
+
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/system_snapshot_linux.cc
|
||||
@@ -205,6 +205,9 @@ CPUArchitecture SystemSnapshotLinux::Get
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
return process_reader_->Is64Bit() ? kCPUArchitectureMIPS64EL
|
||||
: kCPUArchitectureMIPSEL;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ return process_reader_->Is64Bit() ? kCPUArchitectureRISCV64
|
||||
+ : kCPUArchitectureRISCV32;
|
||||
#else
|
||||
#error port to your architecture
|
||||
#endif
|
||||
@@ -220,6 +223,9 @@ uint32_t SystemSnapshotLinux::CPURevisio
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
// Not implementable on MIPS
|
||||
return 0;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ // Not implementable on RISCV
|
||||
+ return 0;
|
||||
#else
|
||||
#error port to your architecture
|
||||
#endif
|
||||
@@ -240,6 +246,9 @@ std::string SystemSnapshotLinux::CPUVend
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
// Not implementable on MIPS
|
||||
return std::string();
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ // Not implementable on RISCV
|
||||
+ return std::string();
|
||||
#else
|
||||
#error port to your architecture
|
||||
#endif
|
||||
@@ -373,6 +382,9 @@ bool SystemSnapshotLinux::NXEnabled() co
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
// Not implementable on MIPS
|
||||
return false;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ // Not implementable on RISCV
|
||||
+ return false;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.cc
|
||||
@@ -189,6 +189,22 @@ bool ThreadSnapshotLinux::Initialize(
|
||||
thread.thread_info.float_context.f32,
|
||||
context_.mipsel);
|
||||
}
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ if (process_reader->Is64Bit()) {
|
||||
+ context_.architecture = kCPUArchitectureRISCV64;
|
||||
+ context_.riscv64 = &context_union_.riscv64;
|
||||
+ InitializeCPUContextRISCV<ContextTraits64>(
|
||||
+ thread.thread_info.thread_context.t64,
|
||||
+ thread.thread_info.float_context.f64,
|
||||
+ context_.riscv64);
|
||||
+ } else {
|
||||
+ context_.architecture = kCPUArchitectureRISCV32;
|
||||
+ context_.riscv32 = &context_union_.riscv32;
|
||||
+ InitializeCPUContextRISCV<ContextTraits32>(
|
||||
+ thread.thread_info.thread_context.t32,
|
||||
+ thread.thread_info.float_context.f32,
|
||||
+ context_.riscv32);
|
||||
+ }
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/snapshot/linux/thread_snapshot_linux.h
|
||||
@@ -73,6 +73,9 @@ class ThreadSnapshotLinux final : public
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
CPUContextMIPS mipsel;
|
||||
CPUContextMIPS64 mips64;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ CPUContextRISCV32 riscv32;
|
||||
+ CPUContextRISCV64 riscv64;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/util/linux/ptracer.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/util/linux/ptracer.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/util/linux/ptracer.cc
|
||||
@@ -398,6 +398,51 @@ bool GetThreadArea64(pid_t tid,
|
||||
return true;
|
||||
}
|
||||
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+
|
||||
+template <typename Destination>
|
||||
+bool GetRegisterSet(pid_t tid, int set, Destination* dest, bool can_log) {
|
||||
+ iovec iov;
|
||||
+ iov.iov_base = dest;
|
||||
+ iov.iov_len = sizeof(*dest);
|
||||
+ if (ptrace(PTRACE_GETREGSET, tid, reinterpret_cast<void*>(set), &iov) != 0) {
|
||||
+ PLOG_IF(ERROR, can_log) << "ptrace";
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (iov.iov_len != sizeof(*dest)) {
|
||||
+ LOG_IF(ERROR, can_log) << "Unexpected registers size";
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool GetFloatingPointRegisters32(pid_t tid,
|
||||
+ FloatContext* context,
|
||||
+ bool can_log) {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+bool GetFloatingPointRegisters64(pid_t tid,
|
||||
+ FloatContext* context,
|
||||
+ bool can_log) {
|
||||
+ return GetRegisterSet(tid, NT_PRFPREG, &context->f64.f, can_log);
|
||||
+}
|
||||
+
|
||||
+bool GetThreadArea32(pid_t tid,
|
||||
+ const ThreadContext& context,
|
||||
+ LinuxVMAddress* address,
|
||||
+ bool can_log) {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+bool GetThreadArea64(pid_t tid,
|
||||
+ const ThreadContext& context,
|
||||
+ LinuxVMAddress* address,
|
||||
+ bool can_log) {
|
||||
+ *address = context.t64.tp;
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/util/linux/thread_info.h
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/util/linux/thread_info.h
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/util/linux/thread_info.h
|
||||
@@ -79,6 +79,40 @@ union ThreadContext {
|
||||
uint32_t cp0_status;
|
||||
uint32_t cp0_cause;
|
||||
uint32_t padding1_;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ // Reflects user_regs_struct in asm/ptrace.h.
|
||||
+ uint32_t pc;
|
||||
+ uint32_t ra;
|
||||
+ uint32_t sp;
|
||||
+ uint32_t gp;
|
||||
+ uint32_t tp;
|
||||
+ uint32_t t0;
|
||||
+ uint32_t t1;
|
||||
+ uint32_t t2;
|
||||
+ uint32_t s0;
|
||||
+ uint32_t s1;
|
||||
+ uint32_t a0;
|
||||
+ uint32_t a1;
|
||||
+ uint32_t a2;
|
||||
+ uint32_t a3;
|
||||
+ uint32_t a4;
|
||||
+ uint32_t a5;
|
||||
+ uint32_t a6;
|
||||
+ uint32_t a7;
|
||||
+ uint32_t s2;
|
||||
+ uint32_t s3;
|
||||
+ uint32_t s4;
|
||||
+ uint32_t s5;
|
||||
+ uint32_t s6;
|
||||
+ uint32_t s7;
|
||||
+ uint32_t s8;
|
||||
+ uint32_t s9;
|
||||
+ uint32_t s10;
|
||||
+ uint32_t s11;
|
||||
+ uint32_t t3;
|
||||
+ uint32_t t4;
|
||||
+ uint32_t t5;
|
||||
+ uint32_t t6;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
@@ -132,6 +166,40 @@ union ThreadContext {
|
||||
uint64_t cp0_badvaddr;
|
||||
uint64_t cp0_status;
|
||||
uint64_t cp0_cause;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ // Reflects user_regs_struct in asm/ptrace.h.
|
||||
+ uint64_t pc;
|
||||
+ uint64_t ra;
|
||||
+ uint64_t sp;
|
||||
+ uint64_t gp;
|
||||
+ uint64_t tp;
|
||||
+ uint64_t t0;
|
||||
+ uint64_t t1;
|
||||
+ uint64_t t2;
|
||||
+ uint64_t s0;
|
||||
+ uint64_t s1;
|
||||
+ uint64_t a0;
|
||||
+ uint64_t a1;
|
||||
+ uint64_t a2;
|
||||
+ uint64_t a3;
|
||||
+ uint64_t a4;
|
||||
+ uint64_t a5;
|
||||
+ uint64_t a6;
|
||||
+ uint64_t a7;
|
||||
+ uint64_t s2;
|
||||
+ uint64_t s3;
|
||||
+ uint64_t s4;
|
||||
+ uint64_t s5;
|
||||
+ uint64_t s6;
|
||||
+ uint64_t s7;
|
||||
+ uint64_t s8;
|
||||
+ uint64_t s9;
|
||||
+ uint64_t s10;
|
||||
+ uint64_t s11;
|
||||
+ uint64_t t3;
|
||||
+ uint64_t t4;
|
||||
+ uint64_t t5;
|
||||
+ uint64_t t6;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
@@ -143,11 +211,12 @@ union ThreadContext {
|
||||
using NativeThreadContext = user_regs;
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
// No appropriate NativeThreadsContext type available for MIPS
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY || ARCH_CPU_ARM64
|
||||
|
||||
-#if !defined(ARCH_CPU_MIPS_FAMILY)
|
||||
+#if !defined(ARCH_CPU_MIPS_FAMILY) && !defined(ARCH_CPU_RISCV_FAMILY)
|
||||
#if defined(ARCH_CPU_32_BITS)
|
||||
static_assert(sizeof(t32_t) == sizeof(NativeThreadContext), "Size mismatch");
|
||||
#else // ARCH_CPU_64_BITS
|
||||
@@ -218,6 +287,9 @@ union FloatContext {
|
||||
} fpregs[32];
|
||||
uint32_t fpcsr;
|
||||
uint32_t fpu_id;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ uint64_t f[32];
|
||||
+ uint32_t fcsr;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
@@ -252,6 +324,9 @@ union FloatContext {
|
||||
double fpregs[32];
|
||||
uint32_t fpcsr;
|
||||
uint32_t fpu_id;
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
+ uint64_t f[32];
|
||||
+ uint32_t fcsr;
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86_FAMILY
|
||||
@@ -281,6 +356,7 @@ union FloatContext {
|
||||
static_assert(sizeof(f64) == sizeof(user_fpsimd_struct), "Size mismatch");
|
||||
#elif defined(ARCH_CPU_MIPS_FAMILY)
|
||||
// No appropriate floating point context native type for available MIPS.
|
||||
+#elif defined(ARCH_CPU_RISCV_FAMILY)
|
||||
#else
|
||||
#error Port.
|
||||
#endif // ARCH_CPU_X86
|
||||
Index: chromium-102.0.5005.61/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
|
||||
===================================================================
|
||||
--- chromium-102.0.5005.61.orig/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
|
||||
+++ chromium-102.0.5005.61/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
|
||||
@@ -237,6 +237,8 @@ std::string UserAgent() {
|
||||
#elif defined(ARCH_CPU_BIG_ENDIAN)
|
||||
static constexpr char arch[] = "aarch64_be";
|
||||
#endif
|
||||
+#elif defined(ARCH_CPU_RISCV64)
|
||||
+ static constexpr char arch[] = "riscv64";
|
||||
#else
|
||||
#error Port
|
||||
#endif
|
43
srcpkgs/electron24/files/patches/chromium-riscv-dav1d.patch
Normal file
43
srcpkgs/electron24/files/patches/chromium-riscv-dav1d.patch
Normal file
|
@ -0,0 +1,43 @@
|
|||
Index: chromium-102.0.5005.61/third_party/dav1d/config/linux/riscv64/config.h
|
||||
===================================================================
|
||||
--- /dev/null
|
||||
+++ chromium-102.0.5005.61/third_party/dav1d/config/linux/riscv64/config.h
|
||||
@@ -0,0 +1,38 @@
|
||||
+/*
|
||||
+ * Autogenerated by the Meson build system.
|
||||
+ * Do not edit, your changes will be lost.
|
||||
+ */
|
||||
+
|
||||
+#pragma once
|
||||
+
|
||||
+#define ARCH_AARCH64 0
|
||||
+
|
||||
+#define ARCH_ARM 0
|
||||
+
|
||||
+#define ARCH_PPC64LE 0
|
||||
+
|
||||
+#define ARCH_X86 0
|
||||
+
|
||||
+#define ARCH_X86_32 0
|
||||
+
|
||||
+#define ARCH_X86_64 0
|
||||
+
|
||||
+#define CONFIG_16BPC 1
|
||||
+
|
||||
+#define CONFIG_8BPC 1
|
||||
+
|
||||
+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium
|
||||
+
|
||||
+#define ENDIANNESS_BIG 0
|
||||
+
|
||||
+#define HAVE_ASM 0
|
||||
+
|
||||
+#define HAVE_AS_FUNC 0
|
||||
+
|
||||
+#define HAVE_CLOCK_GETTIME 1
|
||||
+
|
||||
+#define HAVE_GETAUXVAL 1
|
||||
+
|
||||
+#define HAVE_POSIX_MEMALIGN 1
|
||||
+
|
||||
+#define HAVE_UNISTD_H 1
|
|
@ -0,0 +1,10 @@
|
|||
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
|
||||
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
|
||||
@@ -370,6 +370,7 @@
|
||||
switch (sysno) {
|
||||
case __NR_exit:
|
||||
case __NR_exit_group:
|
||||
+ case __NR_membarrier:
|
||||
case __NR_wait4:
|
||||
case __NR_waitid:
|
||||
#if defined(__i386__)
|
877
srcpkgs/electron24/files/patches/chromium-sndio.patch
Normal file
877
srcpkgs/electron24/files/patches/chromium-sndio.patch
Normal file
|
@ -0,0 +1,877 @@
|
|||
diff -Naur chromium-83.0.4103.97.orig/media/BUILD.gn chromium-83.0.4103.97/media/BUILD.gn
|
||||
--- a/media/BUILD.gn 2020-06-03 20:40:26.000000000 +0200
|
||||
+++ b/media/BUILD.gn 2021-06-13 17:32:28.510395975 +0200
|
||||
@@ -65,6 +65,9 @@
|
||||
defines += [ "DLOPEN_PULSEAUDIO" ]
|
||||
}
|
||||
}
|
||||
+ if (use_sndio) {
|
||||
+ defines += [ "USE_SNDIO" ]
|
||||
+ }
|
||||
if (use_cras) {
|
||||
defines += [ "USE_CRAS" ]
|
||||
}
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/BUILD.gn chromium-83.0.4103.97/media/audio/BUILD.gn
|
||||
--- a/media/audio/BUILD.gn 2020-06-03 20:39:37.000000000 +0200
|
||||
+++ b/media/audio/BUILD.gn 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -236,6 +236,17 @@
|
||||
sources += [ "linux/audio_manager_linux.cc" ]
|
||||
}
|
||||
|
||||
+ if (use_sndio) {
|
||||
+ libs += [ "sndio" ]
|
||||
+ sources += [
|
||||
+ "sndio/audio_manager_sndio.cc",
|
||||
+ "sndio/sndio_input.cc",
|
||||
+ "sndio/sndio_input.h",
|
||||
+ "sndio/sndio_output.cc",
|
||||
+ "sndio/sndio_output.h"
|
||||
+ ]
|
||||
+ }
|
||||
+
|
||||
if (use_alsa) {
|
||||
libs += [ "asound" ]
|
||||
sources += [
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/linux/audio_manager_linux.cc chromium-83.0.4103.97/media/audio/linux/audio_manager_linux.cc
|
||||
--- a/media/audio/linux/audio_manager_linux.cc 2020-06-03 20:39:37.000000000 +0200
|
||||
+++ b/media/audio/linux/audio_manager_linux.cc 2020-06-13 18:09:43.623333167 +0200
|
||||
@@ -19,6 +19,11 @@
|
||||
#include "media/audio/pulse/audio_manager_pulse.h"
|
||||
#include "media/audio/pulse/pulse_util.h"
|
||||
#endif
|
||||
+#if defined(USE_SNDIO)
|
||||
+#include "media/audio/sndio/audio_manager_sndio.h"
|
||||
+#include "media/audio/sndio/sndio_input.h"
|
||||
+#include "media/audio/sndio/sndio_output.h"
|
||||
+#endif
|
||||
|
||||
namespace media {
|
||||
|
||||
std::unique_ptr<media::AudioManager> CreateAudioManager(
|
||||
@@ -39,6 +45,16 @@
|
||||
audio_log_factory);
|
||||
}
|
||||
|
||||
+#if defined(USE_SNDIO)
|
||||
+ struct sio_hdl *hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
|
||||
+ if (hdl != NULL) {
|
||||
+ sio_close(hdl);
|
||||
+ UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kSndio, kAudioIOMax + 1);
|
||||
+ return std::make_unique<AudioManagerSndio>(std::move(audio_thread),
|
||||
+ audio_log_factory);
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
#if defined(USE_CRAS)
|
||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseCras)) {
|
||||
UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kCras, kAudioIOMax + 1);
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/audio_manager_sndio.cc chromium-83.0.4103.97/media/audio/sndio/audio_manager_sndio.cc
|
||||
--- a/media/audio/sndio/audio_manager_sndio.cc 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/audio_manager_sndio.cc 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,148 @@
|
||||
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#include "media/audio/sndio/audio_manager_sndio.h"
|
||||
+
|
||||
+#include "base/metrics/histogram_macros.h"
|
||||
+#include "base/memory/ptr_util.h"
|
||||
+#include "media/audio/audio_device_description.h"
|
||||
+#include "media/audio/audio_output_dispatcher.h"
|
||||
+#include "media/audio/sndio/sndio_input.h"
|
||||
+#include "media/audio/sndio/sndio_output.h"
|
||||
+#include "media/base/limits.h"
|
||||
+#include "media/base/media_switches.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+
|
||||
+// Maximum number of output streams that can be open simultaneously.
|
||||
+static const int kMaxOutputStreams = 4;
|
||||
+
|
||||
+// Default sample rate for input and output streams.
|
||||
+static const int kDefaultSampleRate = 48000;
|
||||
+
|
||||
+void AddDefaultDevice(AudioDeviceNames* device_names) {
|
||||
+ DCHECK(device_names->empty());
|
||||
+ device_names->push_front(AudioDeviceName::CreateDefault());
|
||||
+}
|
||||
+
|
||||
+bool AudioManagerSndio::HasAudioOutputDevices() {
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool AudioManagerSndio::HasAudioInputDevices() {
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+void AudioManagerSndio::GetAudioInputDeviceNames(
|
||||
+ AudioDeviceNames* device_names) {
|
||||
+ DCHECK(device_names->empty());
|
||||
+ AddDefaultDevice(device_names);
|
||||
+}
|
||||
+
|
||||
+void AudioManagerSndio::GetAudioOutputDeviceNames(
|
||||
+ AudioDeviceNames* device_names) {
|
||||
+ AddDefaultDevice(device_names);
|
||||
+}
|
||||
+
|
||||
+const char* AudioManagerSndio::GetName() {
|
||||
+ return "SNDIO";
|
||||
+}
|
||||
+
|
||||
+AudioParameters AudioManagerSndio::GetInputStreamParameters(
|
||||
+ const std::string& device_id) {
|
||||
+ static const int kDefaultInputBufferSize = 1024;
|
||||
+
|
||||
+ int user_buffer_size = GetUserBufferSize();
|
||||
+ int buffer_size = user_buffer_size ?
|
||||
+ user_buffer_size : kDefaultInputBufferSize;
|
||||
+
|
||||
+ return AudioParameters(
|
||||
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
|
||||
+ kDefaultSampleRate, buffer_size);
|
||||
+}
|
||||
+
|
||||
+AudioManagerSndio::AudioManagerSndio(std::unique_ptr<AudioThread> audio_thread,
|
||||
+ AudioLogFactory* audio_log_factory)
|
||||
+ : AudioManagerBase(std::move(audio_thread),
|
||||
+ audio_log_factory) {
|
||||
+ DLOG(WARNING) << "AudioManagerSndio";
|
||||
+ SetMaxOutputStreamsAllowed(kMaxOutputStreams);
|
||||
+}
|
||||
+
|
||||
+AudioManagerSndio::~AudioManagerSndio() {
|
||||
+ Shutdown();
|
||||
+}
|
||||
+
|
||||
+AudioOutputStream* AudioManagerSndio::MakeLinearOutputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const LogCallback& log_callback) {
|
||||
+ DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
|
||||
+ return MakeOutputStream(params);
|
||||
+}
|
||||
+
|
||||
+AudioOutputStream* AudioManagerSndio::MakeLowLatencyOutputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) {
|
||||
+ DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!";
|
||||
+ DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
|
||||
+ return MakeOutputStream(params);
|
||||
+}
|
||||
+
|
||||
+AudioInputStream* AudioManagerSndio::MakeLinearInputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) {
|
||||
+ DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
|
||||
+ return MakeInputStream(params);
|
||||
+}
|
||||
+
|
||||
+AudioInputStream* AudioManagerSndio::MakeLowLatencyInputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) {
|
||||
+ DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
|
||||
+ return MakeInputStream(params);
|
||||
+}
|
||||
+
|
||||
+AudioParameters AudioManagerSndio::GetPreferredOutputStreamParameters(
|
||||
+ const std::string& output_device_id,
|
||||
+ const AudioParameters& input_params) {
|
||||
+ // TODO(tommi): Support |output_device_id|.
|
||||
+ DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
|
||||
+ static const int kDefaultOutputBufferSize = 2048;
|
||||
+
|
||||
+ ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
|
||||
+ int sample_rate = kDefaultSampleRate;
|
||||
+ int buffer_size = kDefaultOutputBufferSize;
|
||||
+ if (input_params.IsValid()) {
|
||||
+ sample_rate = input_params.sample_rate();
|
||||
+ channel_layout = input_params.channel_layout();
|
||||
+ buffer_size = std::min(buffer_size, input_params.frames_per_buffer());
|
||||
+ }
|
||||
+
|
||||
+ int user_buffer_size = GetUserBufferSize();
|
||||
+ if (user_buffer_size)
|
||||
+ buffer_size = user_buffer_size;
|
||||
+
|
||||
+ return AudioParameters(
|
||||
+ AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
|
||||
+ sample_rate, buffer_size);
|
||||
+}
|
||||
+
|
||||
+AudioInputStream* AudioManagerSndio::MakeInputStream(
|
||||
+ const AudioParameters& params) {
|
||||
+ DLOG(WARNING) << "MakeInputStream";
|
||||
+ return new SndioAudioInputStream(this,
|
||||
+ AudioDeviceDescription::kDefaultDeviceId, params);
|
||||
+}
|
||||
+
|
||||
+AudioOutputStream* AudioManagerSndio::MakeOutputStream(
|
||||
+ const AudioParameters& params) {
|
||||
+ DLOG(WARNING) << "MakeOutputStream";
|
||||
+ return new SndioAudioOutputStream(params, this);
|
||||
+}
|
||||
+
|
||||
+} // namespace media
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/audio_manager_sndio.h chromium-83.0.4103.97/media/audio/sndio/audio_manager_sndio.h
|
||||
--- a/media/audio/sndio/audio_manager_sndio.h 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/audio_manager_sndio.h 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,65 @@
|
||||
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#ifndef MEDIA_AUDIO_SNDIO_AUDIO_MANAGER_SNDIO_H_
|
||||
+#define MEDIA_AUDIO_SNDIO_AUDIO_MANAGER_SNDIO_H_
|
||||
+
|
||||
+#include <set>
|
||||
+
|
||||
+#include "base/compiler_specific.h"
|
||||
+#include "base/macros.h"
|
||||
+#include "base/memory/ref_counted.h"
|
||||
+#include "base/threading/thread.h"
|
||||
+#include "media/audio/audio_manager_base.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+class MEDIA_EXPORT AudioManagerSndio : public AudioManagerBase {
|
||||
+ public:
|
||||
+ AudioManagerSndio(std::unique_ptr<AudioThread> audio_thread,
|
||||
+ AudioLogFactory* audio_log_factory);
|
||||
+ ~AudioManagerSndio() override;
|
||||
+
|
||||
+ // Implementation of AudioManager.
|
||||
+ bool HasAudioOutputDevices() override;
|
||||
+ bool HasAudioInputDevices() override;
|
||||
+ void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
|
||||
+ void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
|
||||
+ AudioParameters GetInputStreamParameters(
|
||||
+ const std::string& device_id) override;
|
||||
+ const char* GetName() override;
|
||||
+
|
||||
+ // Implementation of AudioManagerBase.
|
||||
+ AudioOutputStream* MakeLinearOutputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const LogCallback& log_callback) override;
|
||||
+ AudioOutputStream* MakeLowLatencyOutputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) override;
|
||||
+ AudioInputStream* MakeLinearInputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) override;
|
||||
+ AudioInputStream* MakeLowLatencyInputStream(
|
||||
+ const AudioParameters& params,
|
||||
+ const std::string& device_id,
|
||||
+ const LogCallback& log_callback) override;
|
||||
+
|
||||
+ protected:
|
||||
+ AudioParameters GetPreferredOutputStreamParameters(
|
||||
+ const std::string& output_device_id,
|
||||
+ const AudioParameters& input_params) override;
|
||||
+
|
||||
+ private:
|
||||
+ // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
|
||||
+ AudioOutputStream* MakeOutputStream(const AudioParameters& params);
|
||||
+ AudioInputStream* MakeInputStream(const AudioParameters& params);
|
||||
+
|
||||
+ DISALLOW_COPY_AND_ASSIGN(AudioManagerSndio);
|
||||
+};
|
||||
+
|
||||
+} // namespace media
|
||||
+
|
||||
+#endif // MEDIA_AUDIO_SNDIO_AUDIO_MANAGER_SNDIO_H_
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/sndio_input.cc chromium-83.0.4103.97/media/audio/sndio/sndio_input.cc
|
||||
--- a/media/audio/sndio/sndio_input.cc 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/sndio_input.cc 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,200 @@
|
||||
+// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#include "base/bind.h"
|
||||
+#include "base/logging.h"
|
||||
+#include "base/macros.h"
|
||||
+#include "media/base/audio_timestamp_helper.h"
|
||||
+#include "media/audio/sndio/audio_manager_sndio.h"
|
||||
+#include "media/audio/audio_manager.h"
|
||||
+#include "media/audio/sndio/sndio_input.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+static const SampleFormat kSampleFormat = kSampleFormatS16;
|
||||
+
|
||||
+void SndioAudioInputStream::OnMoveCallback(void *arg, int delta)
|
||||
+{
|
||||
+ SndioAudioInputStream* self = static_cast<SndioAudioInputStream*>(arg);
|
||||
+
|
||||
+ self->hw_delay += delta;
|
||||
+}
|
||||
+
|
||||
+void *SndioAudioInputStream::ThreadEntry(void *arg) {
|
||||
+ SndioAudioInputStream* self = static_cast<SndioAudioInputStream*>(arg);
|
||||
+
|
||||
+ self->ThreadLoop();
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+SndioAudioInputStream::SndioAudioInputStream(AudioManagerBase* manager,
|
||||
+ const std::string& device_name,
|
||||
+ const AudioParameters& params)
|
||||
+ : manager(manager),
|
||||
+ params(params),
|
||||
+ audio_bus(AudioBus::Create(params)),
|
||||
+ state(kClosed) {
|
||||
+}
|
||||
+
|
||||
+SndioAudioInputStream::~SndioAudioInputStream() {
|
||||
+ if (state != kClosed)
|
||||
+ Close();
|
||||
+}
|
||||
+
|
||||
+bool SndioAudioInputStream::Open() {
|
||||
+ struct sio_par par;
|
||||
+ int sig;
|
||||
+
|
||||
+ if (state != kClosed)
|
||||
+ return false;
|
||||
+
|
||||
+ if (params.format() != AudioParameters::AUDIO_PCM_LINEAR &&
|
||||
+ params.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) {
|
||||
+ LOG(WARNING) << "Unsupported audio format.";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ sio_initpar(&par);
|
||||
+ par.rate = params.sample_rate();
|
||||
+ par.rchan = params.channels();
|
||||
+ par.bits = SampleFormatToBitsPerChannel(kSampleFormat);
|
||||
+ par.bps = par.bits / 8;
|
||||
+ par.sig = sig = par.bits != 8 ? 1 : 0;
|
||||
+ par.le = SIO_LE_NATIVE;
|
||||
+ par.appbufsz = params.frames_per_buffer();
|
||||
+
|
||||
+ hdl = sio_open(SIO_DEVANY, SIO_REC, 0);
|
||||
+
|
||||
+ if (hdl == NULL) {
|
||||
+ LOG(ERROR) << "Couldn't open audio device.";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
|
||||
+ LOG(ERROR) << "Couldn't set audio parameters.";
|
||||
+ goto bad_close;
|
||||
+ }
|
||||
+
|
||||
+ if (par.rate != (unsigned int)params.sample_rate() ||
|
||||
+ par.rchan != (unsigned int)params.channels() ||
|
||||
+ par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) ||
|
||||
+ par.sig != (unsigned int)sig ||
|
||||
+ (par.bps > 1 && par.le != SIO_LE_NATIVE) ||
|
||||
+ (par.bits != par.bps * 8)) {
|
||||
+ LOG(ERROR) << "Unsupported audio parameters.";
|
||||
+ goto bad_close;
|
||||
+ }
|
||||
+ state = kStopped;
|
||||
+ buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)];
|
||||
+ sio_onmove(hdl, &OnMoveCallback, this);
|
||||
+ return true;
|
||||
+bad_close:
|
||||
+ sio_close(hdl);
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::Start(AudioInputCallback* cb) {
|
||||
+
|
||||
+ StartAgc();
|
||||
+
|
||||
+ state = kRunning;
|
||||
+ hw_delay = 0;
|
||||
+ callback = cb;
|
||||
+ sio_start(hdl);
|
||||
+ if (pthread_create(&thread, NULL, &ThreadEntry, this) != 0) {
|
||||
+ LOG(ERROR) << "Failed to create real-time thread for recording.";
|
||||
+ sio_stop(hdl);
|
||||
+ state = kStopped;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::Stop() {
|
||||
+
|
||||
+ if (state == kStopped)
|
||||
+ return;
|
||||
+
|
||||
+ state = kStopWait;
|
||||
+ pthread_join(thread, NULL);
|
||||
+ sio_stop(hdl);
|
||||
+ state = kStopped;
|
||||
+
|
||||
+ StopAgc();
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::Close() {
|
||||
+
|
||||
+ if (state == kClosed)
|
||||
+ return;
|
||||
+
|
||||
+ if (state == kRunning)
|
||||
+ Stop();
|
||||
+
|
||||
+ state = kClosed;
|
||||
+ delete [] buffer;
|
||||
+ sio_close(hdl);
|
||||
+
|
||||
+ manager->ReleaseInputStream(this);
|
||||
+}
|
||||
+
|
||||
+double SndioAudioInputStream::GetMaxVolume() {
|
||||
+ // Not supported
|
||||
+ return 0.0;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::SetVolume(double volume) {
|
||||
+ // Not supported. Do nothing.
|
||||
+}
|
||||
+
|
||||
+double SndioAudioInputStream::GetVolume() {
|
||||
+ // Not supported.
|
||||
+ return 0.0;
|
||||
+}
|
||||
+
|
||||
+bool SndioAudioInputStream::IsMuted() {
|
||||
+ // Not supported.
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::SetOutputDeviceForAec(
|
||||
+ const std::string& output_device_id) {
|
||||
+ // Not supported.
|
||||
+}
|
||||
+
|
||||
+void SndioAudioInputStream::ThreadLoop(void) {
|
||||
+ size_t todo, n;
|
||||
+ char *data;
|
||||
+ unsigned int nframes;
|
||||
+ double normalized_volume = 0.0;
|
||||
+
|
||||
+ nframes = audio_bus->frames();
|
||||
+
|
||||
+ while (state == kRunning && !sio_eof(hdl)) {
|
||||
+
|
||||
+ GetAgcVolume(&normalized_volume);
|
||||
+
|
||||
+ // read one block
|
||||
+ todo = nframes * params.GetBytesPerFrame(kSampleFormat);
|
||||
+ data = buffer;
|
||||
+ while (todo > 0) {
|
||||
+ n = sio_read(hdl, data, todo);
|
||||
+ if (n == 0)
|
||||
+ return; // unrecoverable I/O error
|
||||
+ todo -= n;
|
||||
+ data += n;
|
||||
+ }
|
||||
+ hw_delay -= nframes;
|
||||
+
|
||||
+ // convert frames count to TimeDelta
|
||||
+ const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay,
|
||||
+ params.sample_rate());
|
||||
+
|
||||
+ // push into bus
|
||||
+ audio_bus->FromInterleaved<SignedInt16SampleTypeTraits>(reinterpret_cast<int16_t*>(buffer), nframes);
|
||||
+
|
||||
+ // invoke callback
|
||||
+ callback->OnData(audio_bus.get(), base::TimeTicks::Now() - delay, 1.);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+} // namespace media
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/sndio_input.h chromium-83.0.4103.97/media/audio/sndio/sndio_input.h
|
||||
--- a/media/audio/sndio/sndio_input.h 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/sndio_input.h 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,91 @@
|
||||
+// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#ifndef MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
||||
+#define MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
||||
+
|
||||
+#include <stdint.h>
|
||||
+#include <string>
|
||||
+#include <sndio.h>
|
||||
+
|
||||
+#include "base/compiler_specific.h"
|
||||
+#include "base/macros.h"
|
||||
+#include "base/memory/weak_ptr.h"
|
||||
+#include "base/time/time.h"
|
||||
+#include "media/audio/agc_audio_stream.h"
|
||||
+#include "media/audio/audio_io.h"
|
||||
+#include "media/audio/audio_device_description.h"
|
||||
+#include "media/base/audio_parameters.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+class AudioManagerBase;
|
||||
+
|
||||
+// Implementation of AudioOutputStream using sndio(7)
|
||||
+class SndioAudioInputStream : public AgcAudioStream<AudioInputStream> {
|
||||
+ public:
|
||||
+ // Pass this to the constructor if you want to attempt auto-selection
|
||||
+ // of the audio recording device.
|
||||
+ static const char kAutoSelectDevice[];
|
||||
+
|
||||
+ // Create a PCM Output stream for the SNDIO device identified by
|
||||
+ // |device_name|. If unsure of what to use for |device_name|, use
|
||||
+ // |kAutoSelectDevice|.
|
||||
+ SndioAudioInputStream(AudioManagerBase* audio_manager,
|
||||
+ const std::string& device_name,
|
||||
+ const AudioParameters& params);
|
||||
+
|
||||
+ ~SndioAudioInputStream() override;
|
||||
+
|
||||
+ // Implementation of AudioInputStream.
|
||||
+ bool Open() override;
|
||||
+ void Start(AudioInputCallback* callback) override;
|
||||
+ void Stop() override;
|
||||
+ void Close() override;
|
||||
+ double GetMaxVolume() override;
|
||||
+ void SetVolume(double volume) override;
|
||||
+ double GetVolume() override;
|
||||
+ bool IsMuted() override;
|
||||
+ void SetOutputDeviceForAec(const std::string& output_device_id) override;
|
||||
+
|
||||
+ private:
|
||||
+
|
||||
+ enum StreamState {
|
||||
+ kClosed, // Not opened yet
|
||||
+ kStopped, // Device opened, but not started yet
|
||||
+ kRunning, // Started, device playing
|
||||
+ kStopWait // Stopping, waiting for the real-time thread to exit
|
||||
+ };
|
||||
+
|
||||
+ // C-style call-backs
|
||||
+ static void OnMoveCallback(void *arg, int delta);
|
||||
+ static void* ThreadEntry(void *arg);
|
||||
+
|
||||
+ // Continuously moves data from the device to the consumer
|
||||
+ void ThreadLoop();
|
||||
+ // Our creator, the audio manager needs to be notified when we close.
|
||||
+ AudioManagerBase* manager;
|
||||
+ // Parameters of the source
|
||||
+ AudioParameters params;
|
||||
+ // We store data here for consumer
|
||||
+ std::unique_ptr<AudioBus> audio_bus;
|
||||
+ // Call-back that consumes recorded data
|
||||
+ AudioInputCallback* callback; // Valid during a recording session.
|
||||
+ // Handle of the audio device
|
||||
+ struct sio_hdl* hdl;
|
||||
+ // Current state of the stream
|
||||
+ enum StreamState state;
|
||||
+ // High priority thread running ThreadLoop()
|
||||
+ pthread_t thread;
|
||||
+ // Number of frames buffered in the hardware
|
||||
+ int hw_delay;
|
||||
+ // Temporary buffer where data is stored sndio-compatible format
|
||||
+ char* buffer;
|
||||
+
|
||||
+ DISALLOW_COPY_AND_ASSIGN(SndioAudioInputStream);
|
||||
+};
|
||||
+
|
||||
+} // namespace media
|
||||
+
|
||||
+#endif // MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/sndio_output.cc chromium-83.0.4103.97/media/audio/sndio/sndio_output.cc
|
||||
--- a/media/audio/sndio/sndio_output.cc 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/sndio_output.cc 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,183 @@
|
||||
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#include "base/logging.h"
|
||||
+#include "base/time/time.h"
|
||||
+#include "base/time/default_tick_clock.h"
|
||||
+#include "media/audio/audio_manager_base.h"
|
||||
+#include "media/base/audio_timestamp_helper.h"
|
||||
+#include "media/audio/sndio/sndio_output.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+static const SampleFormat kSampleFormat = kSampleFormatS16;
|
||||
+
|
||||
+void SndioAudioOutputStream::OnMoveCallback(void *arg, int delta) {
|
||||
+ SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
+
|
||||
+ self->hw_delay -= delta;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::OnVolCallback(void *arg, unsigned int vol) {
|
||||
+ SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
+
|
||||
+ self->vol = vol;
|
||||
+}
|
||||
+
|
||||
+void *SndioAudioOutputStream::ThreadEntry(void *arg) {
|
||||
+ SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
+
|
||||
+ self->ThreadLoop();
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+SndioAudioOutputStream::SndioAudioOutputStream(const AudioParameters& params,
|
||||
+ AudioManagerBase* manager)
|
||||
+ : manager(manager),
|
||||
+ params(params),
|
||||
+ audio_bus(AudioBus::Create(params)),
|
||||
+ state(kClosed),
|
||||
+ mutex(PTHREAD_MUTEX_INITIALIZER) {
|
||||
+}
|
||||
+
|
||||
+SndioAudioOutputStream::~SndioAudioOutputStream() {
|
||||
+ if (state != kClosed)
|
||||
+ Close();
|
||||
+}
|
||||
+
|
||||
+bool SndioAudioOutputStream::Open() {
|
||||
+ struct sio_par par;
|
||||
+ int sig;
|
||||
+
|
||||
+ if (params.format() != AudioParameters::AUDIO_PCM_LINEAR &&
|
||||
+ params.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) {
|
||||
+ LOG(WARNING) << "Unsupported audio format.";
|
||||
+ return false;
|
||||
+ }
|
||||
+ sio_initpar(&par);
|
||||
+ par.rate = params.sample_rate();
|
||||
+ par.pchan = params.channels();
|
||||
+ par.bits = SampleFormatToBitsPerChannel(kSampleFormat);
|
||||
+ par.bps = par.bits / 8;
|
||||
+ par.sig = sig = par.bits != 8 ? 1 : 0;
|
||||
+ par.le = SIO_LE_NATIVE;
|
||||
+ par.appbufsz = params.frames_per_buffer();
|
||||
+
|
||||
+ hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
|
||||
+ if (hdl == NULL) {
|
||||
+ LOG(ERROR) << "Couldn't open audio device.";
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
|
||||
+ LOG(ERROR) << "Couldn't set audio parameters.";
|
||||
+ goto bad_close;
|
||||
+ }
|
||||
+ if (par.rate != (unsigned int)params.sample_rate() ||
|
||||
+ par.pchan != (unsigned int)params.channels() ||
|
||||
+ par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) ||
|
||||
+ par.sig != (unsigned int)sig ||
|
||||
+ (par.bps > 1 && par.le != SIO_LE_NATIVE) ||
|
||||
+ (par.bits != par.bps * 8)) {
|
||||
+ LOG(ERROR) << "Unsupported audio parameters.";
|
||||
+ goto bad_close;
|
||||
+ }
|
||||
+ state = kStopped;
|
||||
+ volpending = 0;
|
||||
+ vol = 0;
|
||||
+ buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)];
|
||||
+ sio_onmove(hdl, &OnMoveCallback, this);
|
||||
+ sio_onvol(hdl, &OnVolCallback, this);
|
||||
+ return true;
|
||||
+ bad_close:
|
||||
+ sio_close(hdl);
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::Close() {
|
||||
+ if (state == kClosed)
|
||||
+ return;
|
||||
+ if (state == kRunning)
|
||||
+ Stop();
|
||||
+ state = kClosed;
|
||||
+ delete [] buffer;
|
||||
+ sio_close(hdl);
|
||||
+ manager->ReleaseOutputStream(this); // Calls the destructor
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::Start(AudioSourceCallback* callback) {
|
||||
+ state = kRunning;
|
||||
+ hw_delay = 0;
|
||||
+ source = callback;
|
||||
+ sio_start(hdl);
|
||||
+ if (pthread_create(&thread, NULL, &ThreadEntry, this) != 0) {
|
||||
+ LOG(ERROR) << "Failed to create real-time thread.";
|
||||
+ sio_stop(hdl);
|
||||
+ state = kStopped;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::Stop() {
|
||||
+ if (state == kStopped)
|
||||
+ return;
|
||||
+ state = kStopWait;
|
||||
+ pthread_join(thread, NULL);
|
||||
+ sio_stop(hdl);
|
||||
+ state = kStopped;
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::SetVolume(double v) {
|
||||
+ pthread_mutex_lock(&mutex);
|
||||
+ vol = v * SIO_MAXVOL;
|
||||
+ volpending = 1;
|
||||
+ pthread_mutex_unlock(&mutex);
|
||||
+}
|
||||
+
|
||||
+void SndioAudioOutputStream::GetVolume(double* v) {
|
||||
+ pthread_mutex_lock(&mutex);
|
||||
+ *v = vol * (1. / SIO_MAXVOL);
|
||||
+ pthread_mutex_unlock(&mutex);
|
||||
+}
|
||||
+
|
||||
+// This stream is always used with sub second buffer sizes, where it's
|
||||
+// sufficient to simply always flush upon Start().
|
||||
+void SndioAudioOutputStream::Flush() {}
|
||||
+
|
||||
+void SndioAudioOutputStream::ThreadLoop(void) {
|
||||
+ int avail, count, result;
|
||||
+
|
||||
+ while (state == kRunning) {
|
||||
+ // Update volume if needed
|
||||
+ pthread_mutex_lock(&mutex);
|
||||
+ if (volpending) {
|
||||
+ volpending = 0;
|
||||
+ sio_setvol(hdl, vol);
|
||||
+ }
|
||||
+ pthread_mutex_unlock(&mutex);
|
||||
+
|
||||
+ // Get data to play
|
||||
+ const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay,
|
||||
+ params.sample_rate());
|
||||
+ count = source->OnMoreData(delay, base::TimeTicks::Now(), 0, audio_bus.get());
|
||||
+ audio_bus->ToInterleaved<SignedInt16SampleTypeTraits>(count, reinterpret_cast<int16_t*>(buffer));
|
||||
+ if (count == 0) {
|
||||
+ // We have to submit something to the device
|
||||
+ count = audio_bus->frames();
|
||||
+ memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormat));
|
||||
+ LOG(WARNING) << "No data to play, running empty cycle.";
|
||||
+ }
|
||||
+
|
||||
+ // Submit data to the device
|
||||
+ avail = count * params.GetBytesPerFrame(kSampleFormat);
|
||||
+ result = sio_write(hdl, buffer, avail);
|
||||
+ if (result == 0) {
|
||||
+ LOG(WARNING) << "Audio device disconnected.";
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ // Update hardware pointer
|
||||
+ hw_delay += count;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+} // namespace media
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/audio/sndio/sndio_output.h chromium-83.0.4103.97/media/audio/sndio/sndio_output.h
|
||||
--- a/media/audio/sndio/sndio_output.h 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/media/audio/sndio/sndio_output.h 2020-06-13 17:32:28.511395969 +0200
|
||||
@@ -0,0 +1,86 @@
|
||||
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
+// Use of this source code is governed by a BSD-style license that can be
|
||||
+// found in the LICENSE file.
|
||||
+
|
||||
+#ifndef MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
||||
+#define MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
||||
+
|
||||
+#include <pthread.h>
|
||||
+#include <sndio.h>
|
||||
+
|
||||
+#include "base/time/tick_clock.h"
|
||||
+#include "base/time/time.h"
|
||||
+#include "media/audio/audio_io.h"
|
||||
+
|
||||
+namespace media {
|
||||
+
|
||||
+class AudioManagerBase;
|
||||
+
|
||||
+// Implementation of AudioOutputStream using sndio(7)
|
||||
+class SndioAudioOutputStream : public AudioOutputStream {
|
||||
+ public:
|
||||
+ // The manager is creating this object
|
||||
+ SndioAudioOutputStream(const AudioParameters& params,
|
||||
+ AudioManagerBase* manager);
|
||||
+ virtual ~SndioAudioOutputStream();
|
||||
+
|
||||
+ // Implementation of AudioOutputStream.
|
||||
+ bool Open() override;
|
||||
+ void Close() override;
|
||||
+ void Start(AudioSourceCallback* callback) override;
|
||||
+ void Stop() override;
|
||||
+ void SetVolume(double volume) override;
|
||||
+ void GetVolume(double* volume) override;
|
||||
+ void Flush() override;
|
||||
+
|
||||
+ friend void sndio_onmove(void *arg, int delta);
|
||||
+ friend void sndio_onvol(void *arg, unsigned int vol);
|
||||
+ friend void *sndio_threadstart(void *arg);
|
||||
+
|
||||
+ private:
|
||||
+ enum StreamState {
|
||||
+ kClosed, // Not opened yet
|
||||
+ kStopped, // Device opened, but not started yet
|
||||
+ kRunning, // Started, device playing
|
||||
+ kStopWait // Stopping, waiting for the real-time thread to exit
|
||||
+ };
|
||||
+
|
||||
+ // C-style call-backs
|
||||
+ static void OnMoveCallback(void *arg, int delta);
|
||||
+ static void OnVolCallback(void *arg, unsigned int vol);
|
||||
+ static void* ThreadEntry(void *arg);
|
||||
+
|
||||
+ // Continuously moves data from the producer to the device
|
||||
+ void ThreadLoop(void);
|
||||
+
|
||||
+ // Our creator, the audio manager needs to be notified when we close.
|
||||
+ AudioManagerBase* manager;
|
||||
+ // Parameters of the source
|
||||
+ AudioParameters params;
|
||||
+ // Source stores data here
|
||||
+ std::unique_ptr<AudioBus> audio_bus;
|
||||
+ // Call-back that produces data to play
|
||||
+ AudioSourceCallback* source;
|
||||
+ // Handle of the audio device
|
||||
+ struct sio_hdl* hdl;
|
||||
+ // Current state of the stream
|
||||
+ enum StreamState state;
|
||||
+ // High priority thread running ThreadLoop()
|
||||
+ pthread_t thread;
|
||||
+ // Protects vol, volpending and hw_delay
|
||||
+ pthread_mutex_t mutex;
|
||||
+ // Current volume in the 0..SIO_MAXVOL range
|
||||
+ int vol;
|
||||
+ // Set to 1 if volumes must be refreshed in the realtime thread
|
||||
+ int volpending;
|
||||
+ // Number of frames buffered in the hardware
|
||||
+ int hw_delay;
|
||||
+ // Temporary buffer where data is stored sndio-compatible format
|
||||
+ char* buffer;
|
||||
+
|
||||
+ DISALLOW_COPY_AND_ASSIGN(SndioAudioOutputStream);
|
||||
+};
|
||||
+
|
||||
+} // namespace media
|
||||
+
|
||||
+#endif // MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
||||
diff -Naur chromium-83.0.4103.97.orig/media/media_options.gni chromium-83.0.4103.97/media/media_options.gni
|
||||
--- a/media/media_options.gni
|
||||
+++ b/media/media_options.gni
|
||||
@@ -158,6 +158,9 @@
|
||||
# Enables runtime selection of ALSA library for audio.
|
||||
use_alsa = false
|
||||
|
||||
+ # Enable runtime selection of sndio(7)
|
||||
+ use_sndio = false
|
||||
+
|
||||
# Alsa should be used on all non-Android, non-Mac POSIX systems - with the
|
||||
# exception of CastOS desktop builds.
|
||||
#
|
|
@ -0,0 +1,48 @@
|
|||
From 7d1394bd639e3bcf68082ac3fc33eeed6a00d2e6 Mon Sep 17 00:00:00 2001
|
||||
From: Elly Fong-Jones <ellyjones@chromium.org>
|
||||
Date: Thu, 2 Mar 2023 00:15:11 +0000
|
||||
Subject: [PATCH] sql: relax constraints on VirtualCursor layout
|
||||
|
||||
VirtualCursor::FromSqliteCursor required that VirtualCursor had a
|
||||
standard layout, but in fact VirtualCursor shouldn't have a standard
|
||||
layout, and the fact that it does with libc++ is a deviation from the
|
||||
C++ standard. This change:
|
||||
|
||||
1. Relaxes the requirement that VirtualCursor has a standard layout, and
|
||||
2. Relaxes the requirement that the sqlite_cursor_ field has to be at
|
||||
offset 0
|
||||
|
||||
by use of offsetof() and pointer subtraction. This change both improves
|
||||
standards compliance and makes this code build with libstdc++.
|
||||
|
||||
Bug: 1380656
|
||||
Change-Id: I9c47abd9197b187da0360ca5619ccf7dadab4f33
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4292313
|
||||
Reviewed-by: Austin Sullivan <asully@chromium.org>
|
||||
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#1111925}
|
||||
---
|
||||
sql/recover_module/cursor.h | 10 ++++------
|
||||
1 file changed, 4 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
|
||||
index 1970bdca8c6..4cb06557009 100644
|
||||
--- a/sql/recover_module/cursor.h
|
||||
+++ b/sql/recover_module/cursor.h
|
||||
@@ -63,12 +63,10 @@ class VirtualCursor {
|
||||
// |sqlite_cursor| must have been returned by VirtualTable::SqliteCursor().
|
||||
static inline VirtualCursor* FromSqliteCursor(
|
||||
sqlite3_vtab_cursor* sqlite_cursor) {
|
||||
- static_assert(std::is_standard_layout<VirtualCursor>::value,
|
||||
- "needed for the reinterpret_cast below");
|
||||
- static_assert(offsetof(VirtualCursor, sqlite_cursor_) == 0,
|
||||
- "sqlite_cursor_ must be the first member of the class");
|
||||
- VirtualCursor* result = reinterpret_cast<VirtualCursor*>(sqlite_cursor);
|
||||
- DCHECK_EQ(sqlite_cursor, &result->sqlite_cursor_);
|
||||
+ VirtualCursor* result = reinterpret_cast<VirtualCursor*>(
|
||||
+ (reinterpret_cast<char*>(sqlite_cursor) -
|
||||
+ offsetof(VirtualCursor, sqlite_cursor_)));
|
||||
+ CHECK_EQ(sqlite_cursor, &result->sqlite_cursor_);
|
||||
return result;
|
||||
}
|
||||
|
11
srcpkgs/electron24/files/patches/chromium-systypes.patch
Normal file
11
srcpkgs/electron24/files/patches/chromium-systypes.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/base/third_party/symbolize/symbolize.h
|
||||
+++ b/base/third_party/symbolize/symbolize.h
|
||||
@@ -58,6 +58,8 @@
|
||||
#include "config.h"
|
||||
#include "glog/logging.h"
|
||||
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
#ifdef HAVE_SYMBOLIZE
|
||||
|
||||
#if defined(__ELF__) // defined by gcc
|
|
@ -0,0 +1,12 @@
|
|||
diff --git a/build/linux/unbundle/ffmpeg.gn b/build/linux/unbundle/ffmpeg.gn
|
||||
index 16e20744706..6a079b32221 100644
|
||||
--- a/build/linux/unbundle/ffmpeg.gn
|
||||
+++ b/build/linux/unbundle/ffmpeg.gn
|
||||
@@ -12,6 +12,7 @@ pkg_config("system_ffmpeg") {
|
||||
"libavformat",
|
||||
"libavutil",
|
||||
]
|
||||
+ defines = [ "av_stream_get_first_dts(stream)=stream->first_dts" ]
|
||||
}
|
||||
|
||||
buildflag_header("ffmpeg_features") {
|
|
@ -0,0 +1,12 @@
|
|||
--- a/build/toolchain/linux/unbundle/BUILD.gn.orig
|
||||
+++ b/build/toolchain/linux/unbundle/BUILD.gn
|
||||
@@ -35,7 +35,7 @@
|
||||
extra_ldflags = getenv("BUILD_LDFLAGS")
|
||||
|
||||
toolchain_args = {
|
||||
- current_cpu = current_cpu
|
||||
- current_os = current_os
|
||||
+ current_cpu = host_cpu
|
||||
+ current_os = host_os
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
--- a/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h 2020-08-10 20:42:29.000000000 +0200
|
||||
+++ b/third_party/webrtc/modules/audio_processing/aec3/clockdrift_detector.h 2020-09-04 12:47:07.014833633 +0200
|
||||
@@ -12,6 +12,7 @@
|
||||
#define MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_
|
||||
|
||||
#include <array>
|
||||
+#include <cstddef>
|
||||
|
||||
namespace webrtc {
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
From ff4122f236b70c272c746d0c336cdbd588d78cd1 Mon Sep 17 00:00:00 2001
|
||||
From: Elvis Pranskevichus <elvis@magic.io>
|
||||
Date: Thu, 12 Dec 2019 16:12:18 -0500
|
||||
Subject: [PATCH] Add a script to list patch targets
|
||||
|
||||
---
|
||||
script/list_patch_targets.py | 23 +++++++++++++++++++++++
|
||||
1 file changed, 23 insertions(+)
|
||||
create mode 100755 script/list_patch_targets.py
|
||||
|
||||
diff --git a/script/list_patch_targets.py b/script/list_patch_targets.py
|
||||
new file mode 100755
|
||||
index 000000000..55173bac9
|
||||
--- /dev/null
|
||||
+++ b/script/list_patch_targets.py
|
||||
@@ -0,0 +1,23 @@
|
||||
+#!/usr/bin/env python
|
||||
+
|
||||
+import argparse
|
||||
+import json
|
||||
+
|
||||
+
|
||||
+def parse_args():
|
||||
+ parser = argparse.ArgumentParser(description='Apply Electron patches')
|
||||
+ parser.add_argument('config', nargs='+',
|
||||
+ type=argparse.FileType('r'),
|
||||
+ help='patches\' config(s) in the JSON format')
|
||||
+ return parser.parse_args()
|
||||
+
|
||||
+
|
||||
+def main():
|
||||
+ configs = parse_args().config
|
||||
+ for config_json in configs:
|
||||
+ for patch_dir, repo in json.load(config_json).iteritems():
|
||||
+ print(repo)
|
||||
+
|
||||
+
|
||||
+if __name__ == '__main__':
|
||||
+ main()
|
||||
--
|
||||
2.23.0
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
diff --git a/build/npm.gni b/build/npm.gni
|
||||
index a1987d095..fb33a14c3 100644
|
||||
--- a/build/npm.gni
|
||||
+++ b/build/npm.gni
|
||||
@@ -35,7 +35,6 @@ template("npm_action") {
|
||||
if (!defined(deps)) {
|
||||
deps = []
|
||||
}
|
||||
- deps += [ ":npm_pre_flight_" + target_name ]
|
||||
|
||||
script = "//electron/build/npm-run.py"
|
||||
args = [
|
|
@ -0,0 +1,10 @@
|
|||
--- a/script/apply_all_patches.py 2023-05-03 15:27:52.000000000 +0200
|
||||
+++ - 2023-05-04 23:12:01.430619050 +0200
|
||||
@@ -14,6 +14,7 @@
|
||||
if os.path.exists(repo):
|
||||
git.import_patches(repo=repo, patch_data=patch_from_dir(patch_dir),
|
||||
threeway=threeway is not None,
|
||||
+ exclude=['third_party/blink/tools/**', 'test/mjsunit/**', 'content/test/**', 'test/cctest/**', 'test/unittests/**', 'third_party/blink/web_tests/**', '.gitignore'],
|
||||
committer_name="Electron Scripts", committer_email="scripts@electron")
|
||||
|
||||
|
11
srcpkgs/electron24/files/patches/electron-git-stuff.patch
Normal file
11
srcpkgs/electron24/files/patches/electron-git-stuff.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/BUILD.gn 2023-05-03 15:27:52.000000000 +0200
|
||||
+++ - 2023-05-05 00:24:25.483471021 +0200
|
||||
@@ -111,8 +111,6 @@
|
||||
[],
|
||||
"trim string",
|
||||
[
|
||||
- ".git/packed-refs",
|
||||
- ".git/HEAD",
|
||||
"script/lib/get-version.js",
|
||||
])
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
--- a/package.json 2022-07-06 17:31:50.000000000 +0200
|
||||
+++ - 2022-07-08 23:04:43.654812957 +0200
|
||||
@@ -98,7 +98,6 @@
|
||||
"precommit": "lint-staged",
|
||||
"preinstall": "node -e 'process.exit(0)'",
|
||||
"prepack": "check-for-leaks",
|
||||
- "prepare": "husky install",
|
||||
"repl": "node ./script/start.js --interactive",
|
||||
"start": "node ./script/start.js",
|
||||
"test": "node ./script/spec-runner.js",
|
|
@ -0,0 +1,109 @@
|
|||
--- a/patches/chromium/feat_add_data_parameter_to_processsingleton.patch
|
||||
+++ b/patches/chromium/feat_add_data_parameter_to_processsingleton.patch
|
||||
@@ -32,7 +32,7 @@ index 5a64220aaf1309832dc0ad543e353de67fe0a779..e75c4f0d7cf1cac2e5862eb858800359
|
||||
- const base::FilePath& current_directory)>;
|
||||
+ base::RepeatingCallback<bool(const base::CommandLine& command_line,
|
||||
+ const base::FilePath& current_directory,
|
||||
-+ const std::vector<const uint8_t> additional_data)>;
|
||||
++ const std::vector<uint8_t> additional_data)>;
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
ProcessSingleton(const std::string& program_name,
|
||||
@@ -73,7 +73,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..a3e45e9baa09bfc87be5b7ff589ac768
|
||||
// |reader| is for sending back ACK message.
|
||||
void HandleMessage(const std::string& current_dir,
|
||||
const std::vector<std::string>& argv,
|
||||
-+ const std::vector<const uint8_t> additional_data,
|
||||
++ const std::vector<uint8_t> additional_data,
|
||||
SocketReader* reader);
|
||||
|
||||
private:
|
||||
@@ -84,7 +84,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..a3e45e9baa09bfc87be5b7ff589ac768
|
||||
- const std::string& current_dir, const std::vector<std::string>& argv,
|
||||
+ const std::string& current_dir,
|
||||
+ const std::vector<std::string>& argv,
|
||||
-+ const std::vector<const uint8_t> additional_data,
|
||||
++ const std::vector<uint8_t> additional_data,
|
||||
SocketReader* reader) {
|
||||
DCHECK(ui_task_runner_->BelongsToCurrentThread());
|
||||
DCHECK(reader);
|
||||
@@ -114,7 +114,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..a3e45e9baa09bfc87be5b7ff589ac768
|
||||
+ base::StringToSizeT(tokens[0], &num_args);
|
||||
+ std::vector<std::string> command_line(tokens.begin() + 1, tokens.begin() + 1 + num_args);
|
||||
+
|
||||
-+ std::vector<const uint8_t> additional_data;
|
||||
++ std::vector<uint8_t> additional_data;
|
||||
+ if (tokens.size() >= 3 + num_args) {
|
||||
+ size_t additional_data_size;
|
||||
+ base::StringToSizeT(tokens[1 + num_args], &additional_data_size);
|
||||
@@ -123,7 +123,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..a3e45e9baa09bfc87be5b7ff589ac768
|
||||
+ std::string(1, kTokenDelimiter));
|
||||
+ const uint8_t* additional_data_bits =
|
||||
+ reinterpret_cast<const uint8_t*>(remaining_args.c_str());
|
||||
-+ additional_data = std::vector<const uint8_t>(
|
||||
++ additional_data = std::vector<uint8_t>(
|
||||
+ additional_data_bits, additional_data_bits + additional_data_size);
|
||||
+ }
|
||||
+
|
||||
@@ -189,7 +189,7 @@ index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..fe68beb4b2522d27e07dbbb3341f100f
|
||||
base::CommandLine* parsed_command_line,
|
||||
- base::FilePath* current_directory) {
|
||||
+ base::FilePath* current_directory,
|
||||
-+ std::vector<const uint8_t>* parsed_additional_data) {
|
||||
++ std::vector<uint8_t>* parsed_additional_data) {
|
||||
// We should have enough room for the shortest command (min_message_size)
|
||||
// and also be a multiple of wchar_t bytes. The shortest command
|
||||
- // possible is L"START\0\0" (empty current directory and command line).
|
||||
@@ -230,7 +230,7 @@ index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..fe68beb4b2522d27e07dbbb3341f100f
|
||||
+ msg.substr(fourth_null + 1, fifth_null - fourth_null);
|
||||
+ const uint8_t* additional_data_bytes =
|
||||
+ reinterpret_cast<const uint8_t*>(additional_data.c_str());
|
||||
-+ *parsed_additional_data = std::vector<const uint8_t>(additional_data_bytes,
|
||||
++ *parsed_additional_data = std::vector<uint8_t>(additional_data_bytes,
|
||||
+ additional_data_bytes + additional_data_length);
|
||||
+
|
||||
return true;
|
||||
@@ -241,7 +241,7 @@ index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..fe68beb4b2522d27e07dbbb3341f100f
|
||||
base::CommandLine parsed_command_line(base::CommandLine::NO_PROGRAM);
|
||||
base::FilePath current_directory;
|
||||
- if (!ParseCommandLine(cds, &parsed_command_line, ¤t_directory)) {
|
||||
-+ std::vector<const uint8_t> additional_data;
|
||||
++ std::vector<uint8_t> additional_data;
|
||||
+ if (!ParseCommandLine(cds, &parsed_command_line, ¤t_directory, &additional_data)) {
|
||||
*result = TRUE;
|
||||
return true;
|
||||
--- a/shell/browser/api/electron_api_app.cc
|
||||
+++ b/shell/browser/api/electron_api_app.cc
|
||||
@@ -519,10 +519,10 @@ bool NotificationCallbackWrapper(
|
||||
const base::RepeatingCallback<
|
||||
void(const base::CommandLine& command_line,
|
||||
const base::FilePath& current_directory,
|
||||
- const std::vector<const uint8_t> additional_data)>& callback,
|
||||
+ const std::vector<uint8_t> additional_data)>& callback,
|
||||
const base::CommandLine& cmd,
|
||||
const base::FilePath& cwd,
|
||||
- const std::vector<const uint8_t> additional_data) {
|
||||
+ const std::vector<uint8_t> additional_data) {
|
||||
// Make sure the callback is called after app gets ready.
|
||||
if (Browser::Get()->is_ready()) {
|
||||
callback.Run(cmd, cwd, std::move(additional_data));
|
||||
@@ -1083,7 +1083,7 @@ std::string App::GetLocaleCountryCode() {
|
||||
|
||||
void App::OnSecondInstance(const base::CommandLine& cmd,
|
||||
const base::FilePath& cwd,
|
||||
- const std::vector<const uint8_t> additional_data) {
|
||||
+ const std::vector<uint8_t> additional_data) {
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::Locker locker(isolate);
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
--- a/shell/browser/api/electron_api_app.h
|
||||
+++ b/shell/browser/api/electron_api_app.h
|
||||
@@ -195,7 +195,7 @@ class App : public ElectronBrowserClient::Delegate,
|
||||
std::string GetLocaleCountryCode();
|
||||
void OnSecondInstance(const base::CommandLine& cmd,
|
||||
const base::FilePath& cwd,
|
||||
- const std::vector<const uint8_t> additional_data);
|
||||
+ const std::vector<uint8_t> additional_data);
|
||||
bool HasSingleInstanceLock() const;
|
||||
bool RequestSingleInstanceLock(gin::Arguments* args);
|
||||
void ReleaseSingleInstanceLock();
|
148
srcpkgs/electron24/files/sndio-files/audio_manager_openbsd.cc
Normal file
148
srcpkgs/electron24/files/sndio-files/audio_manager_openbsd.cc
Normal file
|
@ -0,0 +1,148 @@
|
|||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
|
||||
#include "media/audio/openbsd/audio_manager_openbsd.h"
|
||||
|
||||
#include "media/audio/audio_device_description.h"
|
||||
#include "media/audio/audio_output_dispatcher.h"
|
||||
#include "media/audio/sndio/sndio_input.h"
|
||||
#include "media/audio/sndio/sndio_output.h"
|
||||
#include "media/base/limits.h"
|
||||
#include "media/base/media_switches.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
// Maximum number of output streams that can be open simultaneously.
|
||||
static const int kMaxOutputStreams = 4;
|
||||
|
||||
// Default sample rate for input and output streams.
|
||||
static const int kDefaultSampleRate = 48000;
|
||||
|
||||
void AddDefaultDevice(AudioDeviceNames* device_names) {
|
||||
DCHECK(device_names->empty());
|
||||
device_names->push_front(AudioDeviceName::CreateDefault());
|
||||
}
|
||||
|
||||
bool AudioManagerOpenBSD::HasAudioOutputDevices() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioManagerOpenBSD::HasAudioInputDevices() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioManagerOpenBSD::GetAudioInputDeviceNames(
|
||||
AudioDeviceNames* device_names) {
|
||||
DCHECK(device_names->empty());
|
||||
AddDefaultDevice(device_names);
|
||||
}
|
||||
|
||||
void AudioManagerOpenBSD::GetAudioOutputDeviceNames(
|
||||
AudioDeviceNames* device_names) {
|
||||
AddDefaultDevice(device_names);
|
||||
}
|
||||
|
||||
const char* AudioManagerOpenBSD::GetName() {
|
||||
return "SNDIO";
|
||||
}
|
||||
|
||||
AudioParameters AudioManagerOpenBSD::GetInputStreamParameters(
|
||||
const std::string& device_id) {
|
||||
static const int kDefaultInputBufferSize = 1024;
|
||||
|
||||
int user_buffer_size = GetUserBufferSize();
|
||||
int buffer_size = user_buffer_size ?
|
||||
user_buffer_size : kDefaultInputBufferSize;
|
||||
|
||||
return AudioParameters(
|
||||
AudioParameters::AUDIO_PCM_LOW_LATENCY, CHANNEL_LAYOUT_STEREO,
|
||||
kDefaultSampleRate, buffer_size);
|
||||
}
|
||||
|
||||
AudioManagerOpenBSD::AudioManagerOpenBSD(std::unique_ptr<AudioThread> audio_thread,
|
||||
AudioLogFactory* audio_log_factory)
|
||||
: AudioManagerBase(std::move(audio_thread),
|
||||
audio_log_factory) {
|
||||
DLOG(WARNING) << "AudioManagerOpenBSD";
|
||||
SetMaxOutputStreamsAllowed(kMaxOutputStreams);
|
||||
}
|
||||
|
||||
AudioManagerOpenBSD::~AudioManagerOpenBSD() {
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
AudioOutputStream* AudioManagerOpenBSD::MakeLinearOutputStream(
|
||||
const AudioParameters& params,
|
||||
const LogCallback& log_callback) {
|
||||
DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
|
||||
return MakeOutputStream(params);
|
||||
}
|
||||
|
||||
AudioOutputStream* AudioManagerOpenBSD::MakeLowLatencyOutputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) {
|
||||
DLOG_IF(ERROR, !device_id.empty()) << "Not implemented!";
|
||||
DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
|
||||
return MakeOutputStream(params);
|
||||
}
|
||||
|
||||
AudioInputStream* AudioManagerOpenBSD::MakeLinearInputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) {
|
||||
DCHECK_EQ(AudioParameters::AUDIO_PCM_LINEAR, params.format());
|
||||
return MakeInputStream(params);
|
||||
}
|
||||
|
||||
AudioInputStream* AudioManagerOpenBSD::MakeLowLatencyInputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) {
|
||||
DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
|
||||
return MakeInputStream(params);
|
||||
}
|
||||
|
||||
AudioParameters AudioManagerOpenBSD::GetPreferredOutputStreamParameters(
|
||||
const std::string& output_device_id,
|
||||
const AudioParameters& input_params) {
|
||||
// TODO(tommi): Support |output_device_id|.
|
||||
DLOG_IF(ERROR, !output_device_id.empty()) << "Not implemented!";
|
||||
static const int kDefaultOutputBufferSize = 2048;
|
||||
|
||||
ChannelLayout channel_layout = CHANNEL_LAYOUT_STEREO;
|
||||
int sample_rate = kDefaultSampleRate;
|
||||
int buffer_size = kDefaultOutputBufferSize;
|
||||
if (input_params.IsValid()) {
|
||||
sample_rate = input_params.sample_rate();
|
||||
channel_layout = input_params.channel_layout();
|
||||
buffer_size = std::min(buffer_size, input_params.frames_per_buffer());
|
||||
}
|
||||
|
||||
int user_buffer_size = GetUserBufferSize();
|
||||
if (user_buffer_size)
|
||||
buffer_size = user_buffer_size;
|
||||
|
||||
return AudioParameters(
|
||||
AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout,
|
||||
sample_rate, buffer_size);
|
||||
}
|
||||
|
||||
AudioInputStream* AudioManagerOpenBSD::MakeInputStream(
|
||||
const AudioParameters& params) {
|
||||
DLOG(WARNING) << "MakeInputStream";
|
||||
return new SndioAudioInputStream(this,
|
||||
AudioDeviceDescription::kDefaultDeviceId, params);
|
||||
}
|
||||
|
||||
AudioOutputStream* AudioManagerOpenBSD::MakeOutputStream(
|
||||
const AudioParameters& params) {
|
||||
DLOG(WARNING) << "MakeOutputStream";
|
||||
return new SndioAudioOutputStream(params, this);
|
||||
}
|
||||
|
||||
} // namespace media
|
65
srcpkgs/electron24/files/sndio-files/audio_manager_openbsd.h
Normal file
65
srcpkgs/electron24/files/sndio-files/audio_manager_openbsd.h
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef MEDIA_AUDIO_OPENBSD_AUDIO_MANAGER_OPENBSD_H_
|
||||
#define MEDIA_AUDIO_OPENBSD_AUDIO_MANAGER_OPENBSD_H_
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "media/audio/audio_manager_base.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
class MEDIA_EXPORT AudioManagerOpenBSD : public AudioManagerBase {
|
||||
public:
|
||||
AudioManagerOpenBSD(std::unique_ptr<AudioThread> audio_thread,
|
||||
AudioLogFactory* audio_log_factory);
|
||||
~AudioManagerOpenBSD() override;
|
||||
|
||||
// Implementation of AudioManager.
|
||||
bool HasAudioOutputDevices() override;
|
||||
bool HasAudioInputDevices() override;
|
||||
void GetAudioInputDeviceNames(AudioDeviceNames* device_names) override;
|
||||
void GetAudioOutputDeviceNames(AudioDeviceNames* device_names) override;
|
||||
AudioParameters GetInputStreamParameters(
|
||||
const std::string& device_id) override;
|
||||
const char* GetName() override;
|
||||
|
||||
// Implementation of AudioManagerBase.
|
||||
AudioOutputStream* MakeLinearOutputStream(
|
||||
const AudioParameters& params,
|
||||
const LogCallback& log_callback) override;
|
||||
AudioOutputStream* MakeLowLatencyOutputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) override;
|
||||
AudioInputStream* MakeLinearInputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) override;
|
||||
AudioInputStream* MakeLowLatencyInputStream(
|
||||
const AudioParameters& params,
|
||||
const std::string& device_id,
|
||||
const LogCallback& log_callback) override;
|
||||
|
||||
protected:
|
||||
AudioParameters GetPreferredOutputStreamParameters(
|
||||
const std::string& output_device_id,
|
||||
const AudioParameters& input_params) override;
|
||||
|
||||
private:
|
||||
// Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
|
||||
AudioOutputStream* MakeOutputStream(const AudioParameters& params);
|
||||
AudioInputStream* MakeInputStream(const AudioParameters& params);
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AudioManagerOpenBSD);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
|
||||
#endif // MEDIA_AUDIO_OPENBSD_AUDIO_MANAGER_OPENBSD_H_
|
200
srcpkgs/electron24/files/sndio-files/sndio_input.cc
Normal file
200
srcpkgs/electron24/files/sndio-files/sndio_input.cc
Normal file
|
@ -0,0 +1,200 @@
|
|||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "media/base/audio_timestamp_helper.h"
|
||||
#include "media/audio/openbsd/audio_manager_openbsd.h"
|
||||
#include "media/audio/audio_manager.h"
|
||||
#include "media/audio/sndio/sndio_input.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
static const SampleFormat kSampleFormat = kSampleFormatS16;
|
||||
|
||||
void SndioAudioInputStream::OnMoveCallback(void *arg, int delta)
|
||||
{
|
||||
SndioAudioInputStream* self = static_cast<SndioAudioInputStream*>(arg);
|
||||
|
||||
self->hw_delay += delta;
|
||||
}
|
||||
|
||||
void *SndioAudioInputStream::ThreadEntry(void *arg) {
|
||||
SndioAudioInputStream* self = static_cast<SndioAudioInputStream*>(arg);
|
||||
|
||||
self->ThreadLoop();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SndioAudioInputStream::SndioAudioInputStream(AudioManagerBase* manager,
|
||||
const std::string& device_name,
|
||||
const AudioParameters& params)
|
||||
: manager(manager),
|
||||
params(params),
|
||||
audio_bus(AudioBus::Create(params)),
|
||||
state(kClosed) {
|
||||
}
|
||||
|
||||
SndioAudioInputStream::~SndioAudioInputStream() {
|
||||
if (state != kClosed)
|
||||
Close();
|
||||
}
|
||||
|
||||
bool SndioAudioInputStream::Open() {
|
||||
struct sio_par par;
|
||||
int sig;
|
||||
|
||||
if (state != kClosed)
|
||||
return false;
|
||||
|
||||
if (params.format() != AudioParameters::AUDIO_PCM_LINEAR &&
|
||||
params.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) {
|
||||
LOG(WARNING) << "Unsupported audio format.";
|
||||
return false;
|
||||
}
|
||||
|
||||
sio_initpar(&par);
|
||||
par.rate = params.sample_rate();
|
||||
par.rchan = params.channels();
|
||||
par.bits = SampleFormatToBitsPerChannel(kSampleFormat);
|
||||
par.bps = par.bits / 8;
|
||||
par.sig = sig = par.bits != 8 ? 1 : 0;
|
||||
par.le = SIO_LE_NATIVE;
|
||||
par.appbufsz = params.frames_per_buffer();
|
||||
|
||||
hdl = sio_open(SIO_DEVANY, SIO_REC, 0);
|
||||
|
||||
if (hdl == NULL) {
|
||||
LOG(ERROR) << "Couldn't open audio device.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
|
||||
LOG(ERROR) << "Couldn't set audio parameters.";
|
||||
goto bad_close;
|
||||
}
|
||||
|
||||
if (par.rate != (unsigned int)params.sample_rate() ||
|
||||
par.rchan != (unsigned int)params.channels() ||
|
||||
par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) ||
|
||||
par.sig != (unsigned int)sig ||
|
||||
(par.bps > 1 && par.le != SIO_LE_NATIVE) ||
|
||||
(par.bits != par.bps * 8)) {
|
||||
LOG(ERROR) << "Unsupported audio parameters.";
|
||||
goto bad_close;
|
||||
}
|
||||
state = kStopped;
|
||||
buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)];
|
||||
sio_onmove(hdl, &OnMoveCallback, this);
|
||||
return true;
|
||||
bad_close:
|
||||
sio_close(hdl);
|
||||
return false;
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::Start(AudioInputCallback* cb) {
|
||||
|
||||
StartAgc();
|
||||
|
||||
state = kRunning;
|
||||
hw_delay = 0;
|
||||
callback = cb;
|
||||
sio_start(hdl);
|
||||
if (pthread_create(&thread, NULL, &ThreadEntry, this) != 0) {
|
||||
LOG(ERROR) << "Failed to create real-time thread for recording.";
|
||||
sio_stop(hdl);
|
||||
state = kStopped;
|
||||
}
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::Stop() {
|
||||
|
||||
if (state == kStopped)
|
||||
return;
|
||||
|
||||
state = kStopWait;
|
||||
pthread_join(thread, NULL);
|
||||
sio_stop(hdl);
|
||||
state = kStopped;
|
||||
|
||||
StopAgc();
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::Close() {
|
||||
|
||||
if (state == kClosed)
|
||||
return;
|
||||
|
||||
if (state == kRunning)
|
||||
Stop();
|
||||
|
||||
state = kClosed;
|
||||
delete [] buffer;
|
||||
sio_close(hdl);
|
||||
|
||||
manager->ReleaseInputStream(this);
|
||||
}
|
||||
|
||||
double SndioAudioInputStream::GetMaxVolume() {
|
||||
// Not supported
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::SetVolume(double volume) {
|
||||
// Not supported. Do nothing.
|
||||
}
|
||||
|
||||
double SndioAudioInputStream::GetVolume() {
|
||||
// Not supported.
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool SndioAudioInputStream::IsMuted() {
|
||||
// Not supported.
|
||||
return false;
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::SetOutputDeviceForAec(
|
||||
const std::string& output_device_id) {
|
||||
// Not supported.
|
||||
}
|
||||
|
||||
void SndioAudioInputStream::ThreadLoop(void) {
|
||||
size_t todo, n;
|
||||
char *data;
|
||||
unsigned int nframes;
|
||||
double normalized_volume = 0.0;
|
||||
|
||||
nframes = audio_bus->frames();
|
||||
|
||||
while (state == kRunning && !sio_eof(hdl)) {
|
||||
|
||||
GetAgcVolume(&normalized_volume);
|
||||
|
||||
// read one block
|
||||
todo = nframes * params.GetBytesPerFrame(kSampleFormat);
|
||||
data = buffer;
|
||||
while (todo > 0) {
|
||||
n = sio_read(hdl, data, todo);
|
||||
if (n == 0)
|
||||
return; // unrecoverable I/O error
|
||||
todo -= n;
|
||||
data += n;
|
||||
}
|
||||
hw_delay -= nframes;
|
||||
|
||||
// convert frames count to TimeDelta
|
||||
const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay,
|
||||
params.sample_rate());
|
||||
|
||||
// push into bus
|
||||
audio_bus->FromInterleaved(buffer, nframes, SampleFormatToBytesPerChannel(kSampleFormat));
|
||||
|
||||
// invoke callback
|
||||
callback->OnData(audio_bus.get(), base::TimeTicks::Now() - delay, 1.);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace media
|
91
srcpkgs/electron24/files/sndio-files/sndio_input.h
Normal file
91
srcpkgs/electron24/files/sndio-files/sndio_input.h
Normal file
|
@ -0,0 +1,91 @@
|
|||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
||||
#define MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <sndio.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/time/time.h"
|
||||
#include "media/audio/agc_audio_stream.h"
|
||||
#include "media/audio/audio_io.h"
|
||||
#include "media/audio/audio_device_description.h"
|
||||
#include "media/base/audio_parameters.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
class AudioManagerBase;
|
||||
|
||||
// Implementation of AudioOutputStream using sndio(7)
|
||||
class SndioAudioInputStream : public AgcAudioStream<AudioInputStream> {
|
||||
public:
|
||||
// Pass this to the constructor if you want to attempt auto-selection
|
||||
// of the audio recording device.
|
||||
static const char kAutoSelectDevice[];
|
||||
|
||||
// Create a PCM Output stream for the SNDIO device identified by
|
||||
// |device_name|. If unsure of what to use for |device_name|, use
|
||||
// |kAutoSelectDevice|.
|
||||
SndioAudioInputStream(AudioManagerBase* audio_manager,
|
||||
const std::string& device_name,
|
||||
const AudioParameters& params);
|
||||
|
||||
~SndioAudioInputStream() override;
|
||||
|
||||
// Implementation of AudioInputStream.
|
||||
bool Open() override;
|
||||
void Start(AudioInputCallback* callback) override;
|
||||
void Stop() override;
|
||||
void Close() override;
|
||||
double GetMaxVolume() override;
|
||||
void SetVolume(double volume) override;
|
||||
double GetVolume() override;
|
||||
bool IsMuted() override;
|
||||
void SetOutputDeviceForAec(const std::string& output_device_id) override;
|
||||
|
||||
private:
|
||||
|
||||
enum StreamState {
|
||||
kClosed, // Not opened yet
|
||||
kStopped, // Device opened, but not started yet
|
||||
kRunning, // Started, device playing
|
||||
kStopWait // Stopping, waiting for the real-time thread to exit
|
||||
};
|
||||
|
||||
// C-style call-backs
|
||||
static void OnMoveCallback(void *arg, int delta);
|
||||
static void* ThreadEntry(void *arg);
|
||||
|
||||
// Continuously moves data from the device to the consumer
|
||||
void ThreadLoop();
|
||||
// Our creator, the audio manager needs to be notified when we close.
|
||||
AudioManagerBase* manager;
|
||||
// Parameters of the source
|
||||
AudioParameters params;
|
||||
// We store data here for consumer
|
||||
std::unique_ptr<AudioBus> audio_bus;
|
||||
// Call-back that consumes recorded data
|
||||
AudioInputCallback* callback; // Valid during a recording session.
|
||||
// Handle of the audio device
|
||||
struct sio_hdl* hdl;
|
||||
// Current state of the stream
|
||||
enum StreamState state;
|
||||
// High priority thread running ThreadLoop()
|
||||
pthread_t thread;
|
||||
// Number of frames buffered in the hardware
|
||||
int hw_delay;
|
||||
// Temporary buffer where data is stored sndio-compatible format
|
||||
char* buffer;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SndioAudioInputStream);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
|
||||
#endif // MEDIA_AUDIO_SNDIO_SNDIO_INPUT_H_
|
183
srcpkgs/electron24/files/sndio-files/sndio_output.cc
Normal file
183
srcpkgs/electron24/files/sndio-files/sndio_output.cc
Normal file
|
@ -0,0 +1,183 @@
|
|||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/time/default_tick_clock.h"
|
||||
#include "media/audio/audio_manager_base.h"
|
||||
#include "media/base/audio_timestamp_helper.h"
|
||||
#include "media/audio/sndio/sndio_output.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
static const SampleFormat kSampleFormat = kSampleFormatS16;
|
||||
|
||||
void SndioAudioOutputStream::OnMoveCallback(void *arg, int delta) {
|
||||
SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
|
||||
self->hw_delay -= delta;
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::OnVolCallback(void *arg, unsigned int vol) {
|
||||
SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
|
||||
self->vol = vol;
|
||||
}
|
||||
|
||||
void *SndioAudioOutputStream::ThreadEntry(void *arg) {
|
||||
SndioAudioOutputStream* self = static_cast<SndioAudioOutputStream*>(arg);
|
||||
|
||||
self->ThreadLoop();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SndioAudioOutputStream::SndioAudioOutputStream(const AudioParameters& params,
|
||||
AudioManagerBase* manager)
|
||||
: manager(manager),
|
||||
params(params),
|
||||
audio_bus(AudioBus::Create(params)),
|
||||
state(kClosed),
|
||||
mutex(PTHREAD_MUTEX_INITIALIZER) {
|
||||
}
|
||||
|
||||
SndioAudioOutputStream::~SndioAudioOutputStream() {
|
||||
if (state != kClosed)
|
||||
Close();
|
||||
}
|
||||
|
||||
bool SndioAudioOutputStream::Open() {
|
||||
struct sio_par par;
|
||||
int sig;
|
||||
|
||||
if (params.format() != AudioParameters::AUDIO_PCM_LINEAR &&
|
||||
params.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) {
|
||||
LOG(WARNING) << "Unsupported audio format.";
|
||||
return false;
|
||||
}
|
||||
sio_initpar(&par);
|
||||
par.rate = params.sample_rate();
|
||||
par.pchan = params.channels();
|
||||
par.bits = SampleFormatToBitsPerChannel(kSampleFormat);
|
||||
par.bps = par.bits / 8;
|
||||
par.sig = sig = par.bits != 8 ? 1 : 0;
|
||||
par.le = SIO_LE_NATIVE;
|
||||
par.appbufsz = params.frames_per_buffer();
|
||||
|
||||
hdl = sio_open(SIO_DEVANY, SIO_PLAY, 0);
|
||||
if (hdl == NULL) {
|
||||
LOG(ERROR) << "Couldn't open audio device.";
|
||||
return false;
|
||||
}
|
||||
if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par)) {
|
||||
LOG(ERROR) << "Couldn't set audio parameters.";
|
||||
goto bad_close;
|
||||
}
|
||||
if (par.rate != (unsigned int)params.sample_rate() ||
|
||||
par.pchan != (unsigned int)params.channels() ||
|
||||
par.bits != (unsigned int)SampleFormatToBitsPerChannel(kSampleFormat) ||
|
||||
par.sig != (unsigned int)sig ||
|
||||
(par.bps > 1 && par.le != SIO_LE_NATIVE) ||
|
||||
(par.bits != par.bps * 8)) {
|
||||
LOG(ERROR) << "Unsupported audio parameters.";
|
||||
goto bad_close;
|
||||
}
|
||||
state = kStopped;
|
||||
volpending = 0;
|
||||
vol = 0;
|
||||
buffer = new char[audio_bus->frames() * params.GetBytesPerFrame(kSampleFormat)];
|
||||
sio_onmove(hdl, &OnMoveCallback, this);
|
||||
sio_onvol(hdl, &OnVolCallback, this);
|
||||
return true;
|
||||
bad_close:
|
||||
sio_close(hdl);
|
||||
return false;
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::Close() {
|
||||
if (state == kClosed)
|
||||
return;
|
||||
if (state == kRunning)
|
||||
Stop();
|
||||
state = kClosed;
|
||||
delete [] buffer;
|
||||
sio_close(hdl);
|
||||
manager->ReleaseOutputStream(this); // Calls the destructor
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::Start(AudioSourceCallback* callback) {
|
||||
state = kRunning;
|
||||
hw_delay = 0;
|
||||
source = callback;
|
||||
sio_start(hdl);
|
||||
if (pthread_create(&thread, NULL, &ThreadEntry, this) != 0) {
|
||||
LOG(ERROR) << "Failed to create real-time thread.";
|
||||
sio_stop(hdl);
|
||||
state = kStopped;
|
||||
}
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::Stop() {
|
||||
if (state == kStopped)
|
||||
return;
|
||||
state = kStopWait;
|
||||
pthread_join(thread, NULL);
|
||||
sio_stop(hdl);
|
||||
state = kStopped;
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::SetVolume(double v) {
|
||||
pthread_mutex_lock(&mutex);
|
||||
vol = v * SIO_MAXVOL;
|
||||
volpending = 1;
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void SndioAudioOutputStream::GetVolume(double* v) {
|
||||
pthread_mutex_lock(&mutex);
|
||||
*v = vol * (1. / SIO_MAXVOL);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
// This stream is always used with sub second buffer sizes, where it's
|
||||
// sufficient to simply always flush upon Start().
|
||||
void SndioAudioOutputStream::Flush() {}
|
||||
|
||||
void SndioAudioOutputStream::ThreadLoop(void) {
|
||||
int avail, count, result;
|
||||
|
||||
while (state == kRunning) {
|
||||
// Update volume if needed
|
||||
pthread_mutex_lock(&mutex);
|
||||
if (volpending) {
|
||||
volpending = 0;
|
||||
sio_setvol(hdl, vol);
|
||||
}
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
// Get data to play
|
||||
const base::TimeDelta delay = AudioTimestampHelper::FramesToTime(hw_delay,
|
||||
params.sample_rate());
|
||||
count = source->OnMoreData(delay, base::TimeTicks::Now(), 0, audio_bus.get());
|
||||
audio_bus->ToInterleaved(count, SampleFormatToBytesPerChannel(kSampleFormat), buffer);
|
||||
if (count == 0) {
|
||||
// We have to submit something to the device
|
||||
count = audio_bus->frames();
|
||||
memset(buffer, 0, count * params.GetBytesPerFrame(kSampleFormat));
|
||||
LOG(WARNING) << "No data to play, running empty cycle.";
|
||||
}
|
||||
|
||||
// Submit data to the device
|
||||
avail = count * params.GetBytesPerFrame(kSampleFormat);
|
||||
result = sio_write(hdl, buffer, avail);
|
||||
if (result == 0) {
|
||||
LOG(WARNING) << "Audio device disconnected.";
|
||||
break;
|
||||
}
|
||||
|
||||
// Update hardware pointer
|
||||
hw_delay += count;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace media
|
86
srcpkgs/electron24/files/sndio-files/sndio_output.h
Normal file
86
srcpkgs/electron24/files/sndio-files/sndio_output.h
Normal file
|
@ -0,0 +1,86 @@
|
|||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
||||
#define MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sndio.h>
|
||||
|
||||
#include "base/time/tick_clock.h"
|
||||
#include "base/time/time.h"
|
||||
#include "media/audio/audio_io.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
class AudioManagerBase;
|
||||
|
||||
// Implementation of AudioOutputStream using sndio(7)
|
||||
class SndioAudioOutputStream : public AudioOutputStream {
|
||||
public:
|
||||
// The manager is creating this object
|
||||
SndioAudioOutputStream(const AudioParameters& params,
|
||||
AudioManagerBase* manager);
|
||||
virtual ~SndioAudioOutputStream();
|
||||
|
||||
// Implementation of AudioOutputStream.
|
||||
bool Open() override;
|
||||
void Close() override;
|
||||
void Start(AudioSourceCallback* callback) override;
|
||||
void Stop() override;
|
||||
void SetVolume(double volume) override;
|
||||
void GetVolume(double* volume) override;
|
||||
void Flush() override;
|
||||
|
||||
friend void sndio_onmove(void *arg, int delta);
|
||||
friend void sndio_onvol(void *arg, unsigned int vol);
|
||||
friend void *sndio_threadstart(void *arg);
|
||||
|
||||
private:
|
||||
enum StreamState {
|
||||
kClosed, // Not opened yet
|
||||
kStopped, // Device opened, but not started yet
|
||||
kRunning, // Started, device playing
|
||||
kStopWait // Stopping, waiting for the real-time thread to exit
|
||||
};
|
||||
|
||||
// C-style call-backs
|
||||
static void OnMoveCallback(void *arg, int delta);
|
||||
static void OnVolCallback(void *arg, unsigned int vol);
|
||||
static void* ThreadEntry(void *arg);
|
||||
|
||||
// Continuously moves data from the producer to the device
|
||||
void ThreadLoop(void);
|
||||
|
||||
// Our creator, the audio manager needs to be notified when we close.
|
||||
AudioManagerBase* manager;
|
||||
// Parameters of the source
|
||||
AudioParameters params;
|
||||
// Source stores data here
|
||||
std::unique_ptr<AudioBus> audio_bus;
|
||||
// Call-back that produces data to play
|
||||
AudioSourceCallback* source;
|
||||
// Handle of the audio device
|
||||
struct sio_hdl* hdl;
|
||||
// Current state of the stream
|
||||
enum StreamState state;
|
||||
// High priority thread running ThreadLoop()
|
||||
pthread_t thread;
|
||||
// Protects vol, volpending and hw_delay
|
||||
pthread_mutex_t mutex;
|
||||
// Current volume in the 0..SIO_MAXVOL range
|
||||
int vol;
|
||||
// Set to 1 if volumes must be refreshed in the realtime thread
|
||||
int volpending;
|
||||
// Number of frames buffered in the hardware
|
||||
int hw_delay;
|
||||
// Temporary buffer where data is stored sndio-compatible format
|
||||
char* buffer;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(SndioAudioOutputStream);
|
||||
};
|
||||
|
||||
} // namespace media
|
||||
|
||||
#endif // MEDIA_AUDIO_SNDIO_SNDIO_OUTPUT_H_
|
|
@ -0,0 +1,43 @@
|
|||
diff --git a/chromium/media/audio/linux/audio_manager_linux.cc b/chromium/media/audio/linux/audio_manager_linux.cc
|
||||
index 5d703549372..9e60b40c749 100644
|
||||
--- media/audio/linux/audio_manager_linux.cc
|
||||
+++ media/audio/linux/audio_manager_linux.cc
|
||||
@@ -20,6 +20,10 @@
|
||||
#include "media/audio/pulse/audio_manager_pulse.h"
|
||||
#include "media/audio/pulse/pulse_util.h"
|
||||
#endif
|
||||
+#if defined(USE_SNDIO)
|
||||
+#include <sndio.h>
|
||||
+#include "media/audio/openbsd/audio_manager_openbsd.h"
|
||||
+#endif
|
||||
|
||||
namespace media {
|
||||
|
||||
@@ -27,7 +31,8 @@ enum LinuxAudioIO {
|
||||
kPulse,
|
||||
kAlsa,
|
||||
kCras,
|
||||
- kAudioIOMax = kCras // Must always be equal to largest logged entry.
|
||||
+ kSndio,
|
||||
+ kAudioIOMax = kSndio // Must always be equal to largest logged entry.
|
||||
};
|
||||
|
||||
std::unique_ptr<media::AudioManager> CreateAudioManager(
|
||||
@@ -41,6 +46,17 @@ std::unique_ptr<media::AudioManager> CreateAudioManager(
|
||||
}
|
||||
#endif
|
||||
|
||||
+#if defined(USE_SNDIO)
|
||||
+ struct sio_hdl * hdl = NULL;
|
||||
+ if ((hdl=sio_open(SIO_DEVANY, SIO_PLAY, 1)) != NULL) {
|
||||
+ sio_close(hdl);
|
||||
+ UMA_HISTOGRAM_ENUMERATION("Media.LinuxAudioIO", kSndio, kAudioIOMax +1);
|
||||
+ return std::make_unique<AudioManagerOpenBSD>(std::move(audio_thread),
|
||||
+ audio_log_factory);
|
||||
+ }
|
||||
+ DVLOG(1) << "Sndio is not available on the OS";
|
||||
+#endif
|
||||
+
|
||||
#if defined(USE_PULSEAUDIO)
|
||||
pa_threaded_mainloop* pa_mainloop = nullptr;
|
||||
pa_context* pa_context = nullptr;
|
|
@ -0,0 +1,12 @@
|
|||
--- media/BUILD.gn 2020-03-24 10:16:30.000000000 +0100
|
||||
+++ - 2020-04-06 14:32:27.960817513 +0200
|
||||
@@ -65,6 +65,9 @@
|
||||
if (use_cras) {
|
||||
defines += [ "USE_CRAS" ]
|
||||
}
|
||||
+ if (use_sndio) {
|
||||
+ defines += [ "USE_SNDIO" ]
|
||||
+ }
|
||||
}
|
||||
|
||||
# Internal grouping of the configs necessary to support sub-folders having their
|
|
@ -0,0 +1,23 @@
|
|||
--- media/audio/BUILD.gn 2020-03-24 10:16:30.000000000 +0100
|
||||
+++ - 2020-04-06 14:31:28.871450217 +0200
|
||||
@@ -232,9 +232,19 @@
|
||||
deps += [ "//media/base/android:media_jni_headers" ]
|
||||
}
|
||||
|
||||
- if (is_linux) {
|
||||
+ if (is_linux) {
|
||||
sources += [ "linux/audio_manager_linux.cc" ]
|
||||
}
|
||||
+ if (use_sndio) {
|
||||
+ libs += [ "sndio" ]
|
||||
+ sources += [
|
||||
+ "openbsd/audio_manager_openbsd.cc",
|
||||
+ "sndio/sndio_input.cc",
|
||||
+ "sndio/sndio_input.h",
|
||||
+ "sndio/sndio_output.cc",
|
||||
+ "sndio/sndio_output.h"
|
||||
+ ]
|
||||
+ }
|
||||
|
||||
if (use_alsa) {
|
||||
libs += [ "asound" ]
|
|
@ -0,0 +1,12 @@
|
|||
--- media/media_options.gni 2020-03-24 10:16:30.000000000 +0100
|
||||
+++ - 2020-04-06 14:29:22.958630783 +0200
|
||||
@@ -114,6 +114,9 @@
|
||||
# Enables runtime selection of ALSA library for audio.
|
||||
use_alsa = false
|
||||
|
||||
+ # Enables runtime selection of sndio library for audio.
|
||||
+ use_sndio = false
|
||||
+
|
||||
# Alsa should be used on non-Android, non-Mac POSIX systems.
|
||||
# Alsa should be used on desktop Chromecast and audio-only Chromecast builds.
|
||||
if (is_posix && !is_android && !is_mac &&
|
441
srcpkgs/electron24/template
Normal file
441
srcpkgs/electron24/template
Normal file
|
@ -0,0 +1,441 @@
|
|||
# Template file for 'electron24'
|
||||
pkgname=electron24
|
||||
version=24.2.0
|
||||
revision=1
|
||||
_nodever=18.14.0
|
||||
_chromiumver=112.0.5615.165
|
||||
archs="x86_64* aarch64*"
|
||||
create_wrksrc=yes
|
||||
build_wrksrc="src"
|
||||
hostmakedepends="$(vopt_if clang "clang lld") python pkgconf perl gperf bison ninja nodejs hwids
|
||||
libwebp-devel freetype-devel harfbuzz-devel libpng-devel nss-devel which git libevent-devel
|
||||
pciutils-devel ffmpeg-devel libxml2-devel libglib-devel yarn openjdk libxslt-devel
|
||||
opus-devel libXcursor-devel libXcomposite-devel libXtst-devel libXrandr-devel libXScrnSaver-devel
|
||||
alsa-lib-devel re2-devel snappy-devel mit-krb5-devel $(vopt_if pulseaudio pulseaudio-devel)
|
||||
$(vopt_if sndio sndio-devel) jq"
|
||||
makedepends="libpng-devel gtk+-devel gtk+3-devel nss-devel pciutils-devel
|
||||
libXi-devel libgcrypt-devel libgnome-keyring-devel cups-devel elfutils-devel
|
||||
libXcomposite-devel speech-dispatcher-devel libXrandr-devel mit-krb5-devel
|
||||
libXScrnSaver-devel alsa-lib-devel snappy-devel libdrm-devel
|
||||
libxml2-devel libxslt-devel $(vopt_if pulseaudio pulseaudio-devel) libexif-devel
|
||||
libXcursor-devel libflac-devel speex-devel libmtp-devel libwebp-devel
|
||||
libjpeg-turbo-devel libevent-devel json-c-devel harfbuzz-devel
|
||||
minizip-devel jsoncpp-devel zlib-devel libcap-devel libXdamage-devel
|
||||
re2-devel fontconfig-devel freetype-devel opus-devel libffi-devel
|
||||
$(vopt_if sndio sndio-devel) ffmpeg-devel libva-devel libuv-devel c-ares-devel libnotify-devel
|
||||
$(vopt_if pipewire pipewire-devel) wayland-devel libcurl-devel libxshmfence-devel"
|
||||
short_desc="Cross platform application framework based on web technologies"
|
||||
maintainer="John <me@johnnynator.dev>"
|
||||
license="BSD-3-Clause"
|
||||
homepage="https://electronjs.org"
|
||||
distfiles="https://github.com/electron/electron/archive/v$version.tar.gz>electron-${version}.tar.gz
|
||||
https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$_chromiumver.tar.xz
|
||||
https://github.com/nodejs/node/archive/v$_nodever.tar.gz>node-$_nodever.tar.gz"
|
||||
checksum="0dd1434ff9e6ff8f266d82ff42d922414088b4940f0dfca4d5d22062ff94d3d6
|
||||
168c62fea9f428f99fbf967f36a75ee5da160429e3a5b86bf02188c5fe7c79fd
|
||||
31bbccdff73269baebcc9f32c2ffe428f28be79841527c63e95da93e8c630829"
|
||||
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
ppc64*-musl) makedepends+=" libucontext-devel" ;;
|
||||
esac
|
||||
|
||||
if [ "$XBPS_LIBC" = musl ]; then
|
||||
hostmakedepends+=" musl-legacy-compat"
|
||||
fi
|
||||
|
||||
if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
|
||||
makedepends+=" musl-legacy-compat"
|
||||
fi
|
||||
|
||||
no_generic_pkgconfig_link=yes
|
||||
lib32disabled=yes
|
||||
nopie=yes # contains tools that are not PIE, enables PIE itself
|
||||
|
||||
build_options="pulseaudio sndio clang pipewire"
|
||||
build_options_default="pulseaudio clang pipewire"
|
||||
|
||||
#if [ "$build_option_clang" ]; then
|
||||
nocross="Yes"
|
||||
#elif [ "${XBPS_TARGET_MACHINE%%-musl}" = "aarch64" ]; then
|
||||
# broken="Falls apart at runtime when compiled with gcc"
|
||||
#fi
|
||||
|
||||
_buildtype=Release
|
||||
_is_debug=false
|
||||
|
||||
CFLAGS="-Wno-unknown-warning-option -fPIC"
|
||||
CXXFLAGS="-Wno-unknown-warning-option -fPIC"
|
||||
|
||||
_apply_patch() {
|
||||
local args="$1" pname="$(basename $2)"
|
||||
|
||||
if [ ! -f ".${pname}_done" ]; then
|
||||
if [ -f "${2}.args" ]; then
|
||||
args=$(<"${2}.args")
|
||||
fi
|
||||
msg_normal "$pkgver: patching: ${pname}.\n"
|
||||
patch -N $args -i $2
|
||||
touch .${pname}_done
|
||||
fi
|
||||
}
|
||||
|
||||
_git_am() {
|
||||
local pname="$(basename $1)"
|
||||
|
||||
if [ ! -f ".${pname}_done" ]; then
|
||||
msg_normal "$pkgver: patching: ${pname}.\n"
|
||||
git -c 'user.name=Electron build' -c 'user.email=electron@ebuild' \
|
||||
am --exclude "third_party/blink/tools/**" \
|
||||
--exclude "test/mjsunit/**" --exclude "content/test/**" \
|
||||
--exclude "test/cctest/**" --exclude "test/unittests/**" \
|
||||
--exclude "third_party/blink/web_tests/**" \
|
||||
--exclude "chrome/test/**" \
|
||||
$1
|
||||
touch .${pname}_done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
_get_chromium_arch() {
|
||||
case "$1" in
|
||||
x86_64*) echo x64 ;;
|
||||
i686*) echo x86 ;;
|
||||
arm*) echo arm ;;
|
||||
aarch64*) echo arm64 ;;
|
||||
ppc64*) echo ppc64 ;;
|
||||
ppc*) echo ppc ;;
|
||||
mipsel*) echo mipsel ;;
|
||||
mips*) echo mips ;;
|
||||
*) msg_error "$pkgver: cannot be compiled for ${XBPS_TARGET_MACHINE}.\n" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
post_extract() {
|
||||
mv chromium-${_chromiumver} src
|
||||
mkdir -p src/third_party/
|
||||
mv node-$_nodever src/third_party/electron_node
|
||||
mv electron-${version} src/electron
|
||||
}
|
||||
|
||||
_git_init() {
|
||||
repopath="$1"
|
||||
cd "$wrksrc"/"$repopath"
|
||||
git init -q
|
||||
git config "gc.auto" 0
|
||||
if [ "$repopath" != "src" ]; then
|
||||
echo "/${repopath#src/}" >> "$wrksrc/$build_wrksrc/.gitignore"
|
||||
fi
|
||||
git add .
|
||||
git -c 'user.name=Electron build' -c 'user.email=electron@ebuild' \
|
||||
commit -q -m "." || true
|
||||
|
||||
}
|
||||
|
||||
post_patch() {
|
||||
cd $wrksrc
|
||||
for x in $FILESDIR/patches/*.patch; do
|
||||
case "${x##*/}" in
|
||||
electron*.patch)
|
||||
cd src/electron
|
||||
_apply_patch -p1 "$x"
|
||||
cd "$wrksrc";;
|
||||
esac
|
||||
done
|
||||
|
||||
# Sigh, electron uses git am...
|
||||
if [ ! -f ".electron_patches_done" ]; then
|
||||
mv src/electron/patches/config.json config.json.old
|
||||
jq 'del(."src/electron/patches/Mantle", ."src/electron/patches/ReactiveObjC",
|
||||
."src/electron/patches/squirrel.mac", ."src/electron/patches/nan")' \
|
||||
config.json.old > src/electron/patches/config.json
|
||||
|
||||
python2 src/electron/script/list_patch_targets.py src/electron/patches/config.json | while read -r repopath; do
|
||||
_git_init $repopath
|
||||
done
|
||||
_git_init src/electron
|
||||
cd $wrksrc
|
||||
|
||||
for x in $FILESDIR/chromium-upstream-patches/*.patch; do
|
||||
[ -f $x ] || continue
|
||||
cd src
|
||||
_git_am "$x"
|
||||
cd "$wrksrc"
|
||||
done
|
||||
|
||||
python2 src/electron/script/apply_all_patches.py src/electron/patches/config.json
|
||||
touch .electron_patches_done
|
||||
fi
|
||||
|
||||
for x in $FILESDIR/patches/*; do
|
||||
case "${x##*/}" in
|
||||
chromium*.patch)
|
||||
cd src
|
||||
_apply_patch -p1 "$x"
|
||||
cd "$wrksrc";;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
|
||||
for x in $FILESDIR/musl-patches/*; do
|
||||
case "${x##*/}" in
|
||||
chromium*.patch)
|
||||
cd src
|
||||
_apply_patch -p1 "$x"
|
||||
cd "$wrksrc";;
|
||||
electron*.patch)
|
||||
cd src/electron
|
||||
_apply_patch -p1 "$x"
|
||||
cd "$wrksrc";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
if [ "$build_option_sndio" ]; then
|
||||
mkdir -p ${wrksrc}/${build_wrksrc}/media/audio/{sndio,openbsd}
|
||||
cp ${FILESDIR}/sndio-files/sndio_*put.* \
|
||||
${wrksrc}/${build_wrksrc}/media/audio/sndio
|
||||
cp ${FILESDIR}/sndio-files/audio_manager_openbsd.* \
|
||||
${wrksrc}/${build_wrksrc}/media/audio/openbsd
|
||||
for f in "${FILESDIR}"/sndio-patches/*.patch; do
|
||||
cd src
|
||||
_apply_patch -p0 "$f"
|
||||
cd "$wrksrc"
|
||||
done
|
||||
fi
|
||||
vsed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \
|
||||
src/tools/generate_shim_headers/generate_shim_headers.py
|
||||
}
|
||||
|
||||
pre_configure() {
|
||||
cd "$wrksrc/$build_wrksrc"
|
||||
|
||||
# https://groups.google.com/a/chromium.org/d/topic/chromium-packagers/9JX1N2nf4PU/discussion
|
||||
touch chrome/test/data/webui/i18n_process_css_test.html
|
||||
# Use the file at run time instead of effectively compiling it in
|
||||
sed 's|//third_party/usb_ids/usb.ids|/usr/share/hwdata/usb.ids|g' \
|
||||
-i services/device/public/cpp/usb/BUILD.gn
|
||||
|
||||
vsed -e 's|python3.10|python3.11|g' -i third_party/electron_node/configure
|
||||
vsed -e "s|(3, 10)|(3, 11)|" -i third_party/electron_node/configure
|
||||
|
||||
mkdir -p third_party/node/linux/node-linux-x64/bin
|
||||
ln -sf /usr/bin/node third_party/node/linux/node-linux-x64/bin/
|
||||
rm -f third_party/devtools-frontend/src/third_party/esbuild/esbuild
|
||||
|
||||
# compile gn early, so it can be used to generate gni stuff
|
||||
msg_normal "Bootstrapping GN\n"
|
||||
CC="${CC_FOR_BUILD:-$CC}" CXX="${CXX_FOR_BUILD:-$CXX}" LD="${LD_FOR_BUILD:-$LD}" \
|
||||
CFLAGS="${CFLAGS_FOR_BUILD:-$CFLAGS}" CXXFLAGS="${CXXFLAGS_FOR_BUILD:-$CXXFLAGS}" \
|
||||
LDFLAGS="${XBPS_LDFLAGS}" \
|
||||
python2 tools/gn/bootstrap/bootstrap.py -s -v --skip-generate-buildfiles
|
||||
|
||||
# we need to generate ppc64 stuff for libvpx as it's not shipped
|
||||
# this has to be done before unbundling, but after gn is built
|
||||
# comment out if we switch back to system libvpx again later
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
ppc64*)
|
||||
pushd third_party/libvpx
|
||||
mkdir -p source/config/linux/ppc64
|
||||
# need PATH to find gn
|
||||
PATH="${wrksrc}/${build_wrksrc}/out/Release:$PATH" \
|
||||
./generate_gni.sh || \
|
||||
msg_error "failed to generate libvpx gni"
|
||||
popd
|
||||
;;
|
||||
esac
|
||||
|
||||
# reusable system library settings
|
||||
local use_system="
|
||||
ffmpeg
|
||||
flac
|
||||
fontconfig
|
||||
freetype
|
||||
harfbuzz-ng
|
||||
libdrm
|
||||
libevent
|
||||
libjpeg
|
||||
libpng
|
||||
libwebp
|
||||
libxml
|
||||
libxslt
|
||||
opus
|
||||
re2
|
||||
snappy
|
||||
"
|
||||
for _lib in $use_system libjpeg_turbo; do
|
||||
msg_normal "Removing buildscripts for system provided $_lib\n"
|
||||
find -type f -path "*third_party/$_lib/*" \
|
||||
\! -path "*third_party/$_lib/chromium/*" \
|
||||
\! -path "*third_party/$_lib/google/*" \
|
||||
\! -path './base/third_party/icu/*' \
|
||||
\! -path './third_party/pdfium/third_party/freetype/include/pstables.h' \
|
||||
\! -path './third_party/harfbuzz-ng/utils/hb_scoped.h' \
|
||||
\! -regex '.*\.\(gn\|gni\|isolate\|py\)' \
|
||||
-delete
|
||||
done
|
||||
|
||||
|
||||
msg_normal "Replacing gn files\n"
|
||||
python3 build/linux/unbundle/replace_gn_files.py --system-libraries \
|
||||
$use_system
|
||||
third_party/libaddressinput/chromium/tools/update-strings.py
|
||||
|
||||
# Satisfy some scripts that use git describe to figure out the electron version
|
||||
cd ${wrksrc}/src/electron
|
||||
git tag -f "v${version}"
|
||||
}
|
||||
|
||||
do_configure() {
|
||||
local target_arch="$(_get_chromium_arch ${XBPS_TARGET_MACHINE})"
|
||||
local host_arch="$(_get_chromium_arch ${XBPS_MACHINE})"
|
||||
# the build system will set march for use, adding it to cflags will break builds
|
||||
export CXXFLAGS=$( shopt -s extglob; echo ${CXXFLAGS/-march=*([^ ])} )
|
||||
export CFLAGS=$( shopt -s extglob; echo ${CFLAGS/-march=*([^ ])} )
|
||||
export CFLAGS=${CFLAGS/-g/}
|
||||
export CXXFLAGS=${CXXFLAGS/-g/}
|
||||
local conf=()
|
||||
cd third_party/electron_node
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
conf_args=" --dest-cpu=${target_arch} --cross-compiling"
|
||||
fi
|
||||
./configure --prefix=/usr \
|
||||
--shared-zlib \
|
||||
--shared-libuv \
|
||||
--shared-openssl \
|
||||
--shared-cares \
|
||||
--openssl-use-def-ca-store \
|
||||
--without-npm \
|
||||
--without-dtrace \
|
||||
--without-bundled-v8 \
|
||||
${conf_args}
|
||||
|
||||
cd "$wrksrc/$build_wrksrc"/electron
|
||||
yarn install --frozen-lockfile
|
||||
cd "$wrksrc/$build_wrksrc"
|
||||
|
||||
if [ "$build_option_clang" ]; then
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export HOST_CC=clang
|
||||
export HOST_CXX=clang++
|
||||
else
|
||||
export CXXFLAGS="$CXXFLAGS -fpermissive"
|
||||
export BUILD_CXXFLAGS="$BUILD_CXXFLAGS -fpermissive"
|
||||
export BUILD_AR="$AR_host"
|
||||
export BUILD_NM="$NM_host"
|
||||
fi
|
||||
|
||||
conf+=(
|
||||
'import("//electron/build/args/release.gn")'
|
||||
'blink_symbol_level=0'
|
||||
'clang_use_chrome_plugins=false'
|
||||
'custom_toolchain="//build/toolchain/linux/unbundle:default"'
|
||||
)
|
||||
if [ "$CROSS_BUILD" ]; then
|
||||
conf+=(
|
||||
'host_toolchain="//build/toolchain/linux/unbundle:host"'
|
||||
'v8_snapshot_toolchain="//build/toolchain/linux/unbundle:host"'
|
||||
"host_pkg_config=\"$PKG_CONFIG_FOR_BUILD\""
|
||||
"pkg_config=\"$PKG_CONFIG\""
|
||||
)
|
||||
else
|
||||
conf+=(
|
||||
'host_toolchain="//build/toolchain/linux/unbundle:default"'
|
||||
'v8_snapshot_toolchain="//build/toolchain/linux/unbundle:default"'
|
||||
)
|
||||
fi
|
||||
if [ "$build_option_sndio" ]; then
|
||||
conf+=(
|
||||
'use_sndio=true'
|
||||
)
|
||||
fi
|
||||
if [ -n "$XBPS_DEBUG_PKGS" ]; then
|
||||
conf+=('symbol_level=1')
|
||||
else
|
||||
conf+=('symbol_level=0')
|
||||
fi
|
||||
|
||||
# this does not work on ppc64 yet
|
||||
case "$XBPS_TARGET_MACHINE" in
|
||||
ppc64*) conf+=( "enable_jxl_decoder=false" );;
|
||||
esac
|
||||
|
||||
conf+=(
|
||||
'devtools_skip_typecheck=false'
|
||||
'enable_hangout_services_extension=true'
|
||||
'enable_nacl=false'
|
||||
'enable_precompiled_headers=false'
|
||||
'fatal_linker_warnings=false'
|
||||
'ffmpeg_branding="Chrome"'
|
||||
'gold_path="/usr/bin/ld.gold"'
|
||||
'icu_use_data_file=true'
|
||||
"is_clang=$(vopt_if clang true false)"
|
||||
'clang_base_path="/usr"'
|
||||
|
||||
'is_component_build=false'
|
||||
"is_debug=$_is_debug"
|
||||
'proprietary_codecs=true'
|
||||
'treat_warnings_as_errors=false'
|
||||
'use_cups=true'
|
||||
'use_custom_libcxx=false'
|
||||
'use_gnome_keyring=false'
|
||||
'use_gold=false'
|
||||
"use_lld=$(vopt_if clang true false)"
|
||||
|
||||
'is_cfi=false'
|
||||
'use_thin_lto=false'
|
||||
'use_cfi_icall=false'
|
||||
'chrome_pgo_phase=0'
|
||||
|
||||
"use_pulseaudio=$(vopt_if pulseaudio 'true' 'false')"
|
||||
"rtc_use_pipewire=$(vopt_if pipewire true false)"
|
||||
'use_sysroot=false'
|
||||
'use_system_harfbuzz=true'
|
||||
'use_system_libffi=true'
|
||||
'is_component_ffmpeg=false'
|
||||
"target_cpu=\"$target_arch\""
|
||||
"host_cpu=\"$host_arch\""
|
||||
)
|
||||
|
||||
msg_normal "Configuring build\n"
|
||||
out/Release/gn gen out/$_buildtype --args="${conf[*]}"
|
||||
}
|
||||
|
||||
do_build() {
|
||||
export CXXFLAGS=$( shopt -s extglob; echo ${CXXFLAGS/-march=*([^ ])} )
|
||||
export CFLAGS=$( shopt -s extglob; echo ${CFLAGS/-march=*([^ ])} )
|
||||
export CFLAGS=${CFLAGS/-g/}
|
||||
export CXXFLAGS=${CXXFLAGS/-g/}
|
||||
if [ "$build_option_clang" ]; then
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export HOST_CC=clang
|
||||
export HOST_CXX=clang++
|
||||
else
|
||||
export BUILD_CXXFLAGS="$BUILD_CXXFLAGS -fpermissive"
|
||||
export CXXFLAGS="$CXXFLAGS -fpermissive"
|
||||
export BUILD_AR="$AR_host"
|
||||
export BUILD_NM="$NM_host"
|
||||
fi
|
||||
msg_normal "Ninja turtles GO!\n"
|
||||
ninja ${makejobs} -C out/$_buildtype electron third_party/electron_node:headers
|
||||
# finish rest of the build
|
||||
strip -s out/$_buildtype/electron
|
||||
ninja ${makejobs} -C out/$_buildtype electron_dist_zip
|
||||
}
|
||||
|
||||
do_install() {
|
||||
vmkdir /usr/lib/$pkgname
|
||||
vmkdir /usr/include/$pkgname
|
||||
bsdtar -xf out/$_buildtype/dist.zip -C "$DESTDIR/usr/lib/$pkgname"
|
||||
|
||||
chmod u+s "$DESTDIR/usr/lib/$pkgname/chrome-sandbox"
|
||||
|
||||
cp out/$_buildtype/gen/node_headers.tar.gz "$DESTDIR"/usr/include/$pkgname
|
||||
|
||||
vlicense ${wrksrc}/src/LICENSE chromium.LICENSE
|
||||
vlicense ${wrksrc}/src/electron/LICENSE electron.LICENSE
|
||||
vlicense ${wrksrc}/src/third_party/electron_node/LICENSE node.LICENSE
|
||||
|
||||
vmkdir /usr/bin
|
||||
ln -s ../lib/$pkgname/electron "$DESTDIR"/usr/bin/$pkgname
|
||||
}
|
2
srcpkgs/electron24/update
Normal file
2
srcpkgs/electron24/update
Normal file
|
@ -0,0 +1,2 @@
|
|||
site=https://www.electronjs.org/releases/stable?version=${version%%.*}
|
||||
pattern='tag/v\K[\d\.]+(?=")'
|
Loading…
Add table
Reference in a new issue