Skip to content

Commit 2c20d39

Browse files
committed
Avoid setting channel variable
1 parent 2186a38 commit 2c20d39

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

av/audio/layout.pyx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,14 @@ cdef class AudioLayout:
5252

5353
@property
5454
def channels(self):
55-
cdef lib.AVChannel channel
5655
cdef char buf[16]
5756
cdef char buf2[128]
5857

5958
results = []
6059

6160
for index in range(self.layout.nb_channels):
62-
channel = lib.av_channel_layout_channel_from_index(&self.layout, index);
63-
size = lib.av_channel_name(buf, sizeof(buf), channel) - 1
64-
size2 = lib.av_channel_description(buf2, sizeof(buf2), channel) - 1
61+
size = lib.av_channel_name(buf, sizeof(buf), lib.av_channel_layout_channel_from_index(&self.layout, index)) - 1
62+
size2 = lib.av_channel_description(buf2, sizeof(buf2), lib.av_channel_layout_channel_from_index(&self.layout, index)) - 1
6563
results.append(
6664
AudioChannel(
6765
PyBytes_FromStringAndSize(buf, size).decode("utf-8"),

setup.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@
2626
old_embed_signature = EmbedSignature._embed_signature
2727

2828

29-
def insert_enum_in_generated_files(source):
30-
# Work around Cython failing to add `enum` to `AVChannel` type.
31-
# TODO: Make Cython bug report
32-
if source.endswith(".c"):
33-
with open(source, "r") as file:
34-
content = file.read()
35-
36-
# Replace "AVChannel __pyx_v_channel;" with "enum AVChannel __pyx_v_channel;"
37-
modified_content = re.sub(
38-
r"\b(?<!enum\s)(AVChannel\s+__pyx_v_\w+;)", r"enum \1", content
39-
)
40-
with open(source, "w") as file:
41-
file.write(modified_content)
42-
43-
4429
def new_embed_signature(self, sig, doc):
4530
# Strip any `self` parameters from the front.
4631
sig = re.sub(r"\(self(,\s+)?", "(", sig)
@@ -206,10 +191,6 @@ def parse_cflags(raw_flags):
206191
include_path=["include"],
207192
)
208193

209-
for ext in ext_modules:
210-
for cfile in ext.sources:
211-
insert_enum_in_generated_files(cfile)
212-
213194

214195
package_folders = pathlib.Path(IMPORT_NAME).glob("**/")
215196
package_data = {

0 commit comments

Comments
 (0)