Skip to content

Commit

Permalink
Move Opus lib loading
Browse files Browse the repository at this point in the history
  • Loading branch information
pmdevita committed May 19, 2024
1 parent 73482d1 commit dfec4f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 10 additions & 0 deletions beatrice/sound_manager/bot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import asyncio
import multiprocessing.connection
import os
import traceback
# We need to bootstrap this before the bot loads Nextcord
# Some platforms (Alpine) need to provide a path because
# find_library will fail on them (musl).
# https://github.com/python/cpython/pull/18380
from nextcord import opus
opus_path = os.getenv("OPUS_PATH", None)
if opus_path:
opus.load_opus(opus_path)

from nextcord.ext import commands
from beatrice.util.background_tasks import BackgroundTasks
try:
Expand Down
11 changes: 0 additions & 11 deletions beatrice/sound_manager/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,6 @@ async def send_audio_packet(self, data: bytes, *, encode: bool = True) -> None:

class AsyncEncoder(Encoder):
def __init__(self, executor, loop: asyncio.AbstractEventLoop):
# Some platforms (Alpine) need to provide a path because
# find_library will fail on them (musl).
# https://github.com/python/cpython/pull/18380
try:
_OpusStruct.get_opus_version()
except OpusNotLoaded as e:
opus_path = os.getenv("OPUS_PATH", None)
if opus_path:
opus.load_opus(opus_path)
else:
raise e
super().__init__()
self.executor = executor
self.loop = loop
Expand Down

0 comments on commit dfec4f2

Please sign in to comment.