History

demux/stheader: use atomic types for mp_codec_params names

Notably they are exchanged between demux and decode thread. It's fine because we know those pointers will be alive as long as avctx is alive. And only the value may change during decoding in rare situations. Make those pointers atomic for the sake of it. It shouldn't change anything, except some codegen. From https://www.gnu.org/software/libc/manual/html_node/Atomic-Types.html#Atomic-Types: In practice, you can assume that int is atomic. You can also assume that pointer types are atomic; that is very convenient. Both of these assumptions are true on all of the machines that the GNU C Library supports and on all POSIX systems we know of.

Kacper Michajłow committed 1 year ago

Commit 6294e481 parent e9c895f2 files · +7 −6Browse files

Unified · Split

2 files
  1. demux/stheader.h +6 −5
  2. sub/sd_ass.c +1 −1
demux/stheader.h+6−5
@@ -18,6 +18,7 @@ · 17 unmodified lines
18#ifndef MPLAYER_STHEADER_H18#ifndef MPLAYER_STHEADER_H
19#define MPLAYER_STHEADER_H19#define MPLAYER_STHEADER_H
20 20
21#include <stdatomic.h>
21#include <stdbool.h>22#include <stdbool.h>
22 23
23#include "common/common.h"24#include "common/common.h"
@@ -70,19 +71,19 @@ struct mp_codec_params { · 46 unmodified lines
70 enum stream_type type;71 enum stream_type type;
71 72
72 // E.g. "h264" (usually corresponds to AVCodecDescriptor.name)73 // E.g. "h264" (usually corresponds to AVCodecDescriptor.name)
73 const char *codec;74 const char *_Atomic codec;
74 75
75 // Usually corresponds to AVCodecDescriptor.long_name76 // Usually corresponds to AVCodecDescriptor.long_name
76 const char *codec_desc;77 const char *_Atomic codec_desc;
77 78
78 // Corresponding codec profile79 // Corresponding codec profile
79 const char *codec_profile;80 const char *_Atomic codec_profile;
80 81
81 // E.g. "h264" (usually corresponds to AVCodec.name)82 // E.g. "h264" (usually corresponds to AVCodec.name)
82 const char *decoder;83 const char *_Atomic decoder;
83 84
84 // Usually corresponds to AVCodec.long_name85 // Usually corresponds to AVCodec.long_name
85 const char *decoder_desc;86 const char *_Atomic decoder_desc;
86 87
87 // Usually a FourCC, exact meaning depends on codec.88 // Usually a FourCC, exact meaning depends on codec.
88 unsigned int codec_tag;89 unsigned int codec_tag;
sub/sd_ass.c+1−1
@@ -316,7 +316,7 @@ static int init(struct sd *sd) · 315 unmodified lines
316 ctx->packer = mp_ass_packer_alloc(ctx);316 ctx->packer = mp_ass_packer_alloc(ctx);
317 317
318 // Subtitles does not have any profile value, so put the converted type as a profile.318 // Subtitles does not have any profile value, so put the converted type as a profile.
319 const char **desc = ctx->converter ? &sd->codec->codec_profile : &sd->codec->codec_desc;319 const char *_Atomic *desc = ctx->converter ? &sd->codec->codec_profile : &sd->codec->codec_desc;
320 switch (ctx->ass_track->track_type) {320 switch (ctx->ass_track->track_type) {
321 case TRACK_TYPE_ASS:321 case TRACK_TYPE_ASS:
322 *desc = "Advanced Sub Station Alpha";322 *desc = "Advanced Sub Station Alpha";

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t