Skip to content

Commit

Permalink
Add raw_ptr_exclusion annontations on raw pointers to support compili…
Browse files Browse the repository at this point in the history
…ng debug builds

Patch-Filename: add_raw_ptr_exclusion_annontations_on_raw_pointers_to_support.patch
  • Loading branch information
markh-discord authored and CI Bot committed Jan 17, 2024
1 parent e562414 commit cebec4c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
11 changes: 7 additions & 4 deletions discord/discord_video_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class DiscordVideoDecoderMediaThread {
void OnOutput(scoped_refptr<::media::VideoFrame> frame);

ElectronPointer<IElectronVideoFormat> format_;
void* user_data_;
::media::GpuVideoAcceleratorFactories* gpu_factories_{};
DISCORD_RAW_PTR_EXCLUSION void* user_data_;
DISCORD_RAW_PTR_EXCLUSION ::media::GpuVideoAcceleratorFactories*
gpu_factories_{};
std::unique_ptr<::media::MediaLog> media_log_;
std::unique_ptr<::media::VideoDecoder> video_decoder_;
scoped_refptr<base::SequencedTaskRunner> media_task_runner_;
Expand Down Expand Up @@ -260,11 +261,13 @@ void DiscordVideoDecoderMediaThread::DecodeOnMediaThread() {
}
}

void DiscordVideoDecoderMediaThread::OnDecodeDone(::media::DecoderStatus status) {
void DiscordVideoDecoderMediaThread::OnDecodeDone(
::media::DecoderStatus status) {
DCHECK(media_task_runner_->RunsTasksInCurrentSequence());
outstanding_decode_requests_--;

if (!status.is_ok() && status.code() != ::media::DecoderStatus::Codes::kAborted) {
if (!status.is_ok() &&
status.code() != ::media::DecoderStatus::Codes::kAborted) {
base::AutoLock auto_lock(lock_);

has_error_ = true;
Expand Down
3 changes: 2 additions & 1 deletion discord/discord_video_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class DiscordVideoDecoder : public ElectronObject<IElectronVideoDecoder> {
uint32_t timestamp) override;

private:
DiscordVideoDecoderMediaThread* media_thread_state_{};
DISCORD_RAW_PTR_EXCLUSION DiscordVideoDecoderMediaThread*
media_thread_state_{};
bool started_initialize_{false};
bool initialized_{false};
};
Expand Down
2 changes: 1 addition & 1 deletion discord/discord_video_source.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MediaStreamDiscordVideoSource::VideoSourceDelegate
// |frame_callback_| is accessed on the IO thread.
VideoCaptureDeliverFrameCB frame_callback_;

media::GpuVideoAcceleratorFactories* gpu_factories_;
DISCORD_RAW_PTR_EXCLUSION media::GpuVideoAcceleratorFactories* gpu_factories_;
std::unique_ptr<gpu::GpuMemoryBufferSupport> gpu_memory_buffer_support_;
};

Expand Down
7 changes: 6 additions & 1 deletion discord/overlay.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#include <cstddef>
#include <cstdint>

// Support for Electron debug builds that enable checks for rawptr.
// Use our own definition to avoid conflicts with Chromium's PA
// RAW_PTR_EXCLUSION macro
#define DISCORD_RAW_PTR_EXCLUSION __attribute__((annotate("raw_ptr_exclusion")))

namespace discord {

class Overlay {
Expand All @@ -12,7 +17,7 @@ class Overlay {
uint32_t process_id_ = 0;

bool send_function_loaded_ = false;
const void* send_function_ = nullptr;
DISCORD_RAW_PTR_EXCLUSION const void* send_function_ = nullptr;
};

} // namespace discord
2 changes: 1 addition & 1 deletion discord/overlay_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct OverlayFrameData {
uint32_t process_id;
uint32_t width;
uint32_t height;
void* data;
DISCORD_RAW_PTR_EXCLUSION void* data;
size_t length;
};

Expand Down
13 changes: 9 additions & 4 deletions discord/public/electron_video_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
#define ELECTRON_VIDEO_EXPORT
#endif

// Support for Electron debug builds that enable checks for rawptr.
// Use our own definition to avoid conflicts with Chromium's PA
// RAW_PTR_EXCLUSION macro
#define DISCORD_RAW_PTR_EXCLUSION __attribute__((annotate("raw_ptr_exclusion")))

namespace webrtc {
class I420BufferInterface;
class I420BufferInterface;
}

namespace discord {
Expand Down Expand Up @@ -163,7 +168,7 @@ class ElectronPointer final {
}
}

T* electronObject_;
DISCORD_RAW_PTR_EXCLUSION T* electronObject_;
};

template <typename T>
Expand Down Expand Up @@ -438,9 +443,9 @@ struct DiscordFrame {
union {
DiscordYUVFrame yuv;
#if defined(_WIN32)
void* texture_handle;
DISCORD_RAW_PTR_EXCLUSION void* texture_handle;
#endif
IElectronVideoFrame* electron;
DISCORD_RAW_PTR_EXCLUSION IElectronVideoFrame* electron;
} frame;
int32_t width;
int32_t height;
Expand Down

0 comments on commit cebec4c

Please sign in to comment.