Skip to content

Avoid setting channel variable #1948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions av/audio/layout.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ cdef class AudioLayout:

@property
def channels(self):
cdef lib.AVChannel channel
cdef char buf[16]
cdef char buf2[128]

results = []

for index in range(self.layout.nb_channels):
channel = lib.av_channel_layout_channel_from_index(&self.layout, index);
size = lib.av_channel_name(buf, sizeof(buf), channel) - 1
size2 = lib.av_channel_description(buf2, sizeof(buf2), channel) - 1
size = lib.av_channel_name(buf, sizeof(buf), lib.av_channel_layout_channel_from_index(&self.layout, index)) - 1
size2 = lib.av_channel_description(buf2, sizeof(buf2), lib.av_channel_layout_channel_from_index(&self.layout, index)) - 1
results.append(
AudioChannel(
PyBytes_FromStringAndSize(buf, size).decode("utf-8"),
Expand Down
19 changes: 0 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,6 @@
old_embed_signature = EmbedSignature._embed_signature


def insert_enum_in_generated_files(source):
# Work around Cython failing to add `enum` to `AVChannel` type.
# TODO: Make Cython bug report
if source.endswith(".c"):
with open(source, "r") as file:
content = file.read()

# Replace "AVChannel __pyx_v_channel;" with "enum AVChannel __pyx_v_channel;"
modified_content = re.sub(
r"\b(?<!enum\s)(AVChannel\s+__pyx_v_\w+;)", r"enum \1", content
)
with open(source, "w") as file:
file.write(modified_content)


def new_embed_signature(self, sig, doc):
# Strip any `self` parameters from the front.
sig = re.sub(r"\(self(,\s+)?", "(", sig)
Expand Down Expand Up @@ -206,10 +191,6 @@ def parse_cflags(raw_flags):
include_path=["include"],
)

for ext in ext_modules:
for cfile in ext.sources:
insert_enum_in_generated_files(cfile)


package_folders = pathlib.Path(IMPORT_NAME).glob("**/")
package_data = {
Expand Down
Loading