61 Commits

Author SHA1 Message Date
Michael H
d08fd59434
Avoid returning in finally
Specifically reraise KeyboardInterrupt, SystemExit
Swallow other BaseExceptions due to the way the standard library uses
them and the intent of this function
2024-10-30 08:08:45 -04:00
Imayhaveborkedit
b8c29b0790
More voice fixes
* More voice fixes

* Start socket reader paused and wait for socket creation

* Fix issues handling 4014 closures

Fixes code not handling disconnects from discord's end properly.  The
4014 code is shared between being disconnected and moved, so it has to
account for the uncertainty.  Also properly stops the voice_client audio
player when disconnecting.

* Fix sending (dropped) silence packets when not connected
2024-04-18 03:36:18 -04:00
Rapptz
9345a2a1be Add warning for FFmpeg spawning classes executable parameter 2024-02-11 05:55:25 -05:00
Imayhaveborkedit
44284ae107
Rewrite voice connection internals 2023-09-28 17:51:22 -04:00
Imayhaveborkedit
48b4ea84c9
Add silence padding after transmission breaks
Prevents unwanted interpolation/distortion of audio by sending silence
packets after pausing or ending the audio stream.
2023-09-22 03:38:42 -04:00
Imayhaveborkedit
dacf3cfe86
Fix possible FFmpegAudio AttributeError in __del__ 2023-09-20 17:13:50 -04:00
Imayhaveborkedit
7bdfd454be
Normalize thread names
Every thread now has a name and either a contextually relevant
identifier or their in hex to disambiguate multiple threads of the same
type.  Also finally gets rid of that old python 2 style init call.
2023-09-03 02:41:16 -04:00
Imayhaveborkedit
b276f3f5a2
Split ffmpeg args
FFmpeg is actually capable of parsing this correctly but we split it for
consistency's sake.
2023-08-23 17:47:48 -04:00
Imayhaveborkedit
62c1ab21b2
Fixes/improvements to FFmpegAudio and subclasses 2023-08-23 07:49:55 -04:00
kairi
a8882f7cb2
Fix Piped Audio Input Ends Prematurely
Co-authored-by: Danny <1695103+Rapptz@users.noreply.github.com>
2023-05-29 04:47:59 -04:00
Rapptz
54541ba6f0 Ensure FFmpeg players have a _process attribute set even during errors 2022-08-15 10:32:07 -04:00
Rapptz
3802780f77 Change a lot of logging INFO calls to be less verbose
Some of the logs were only useful for debug scenarios, so they have
been downgraded to DEBUG. Others were in INFO but supposed to be in
WARNING so those were upgraded.
2022-08-15 10:21:36 -04:00
mniip
1be36c9c3e
Change View, Modal, and AudioPlayer to use logger instead of stderr 2022-06-22 02:10:02 -04:00
jack1142
5ffa3e85de
Update comments after # type: ignore to be compatible with PEP 484 2022-03-27 22:26:34 -04:00
Stocker
5aa696ccfa
Fix typing issues and improve typing completeness across the library
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
Co-authored-by: Josh <josh.ja.butt@gmail.com>
2022-03-13 23:52:10 -04:00
Han Seung Min - 한승민
93af158b0c
Refactor loop code to allow usage of asyncio.run 2022-03-13 04:54:14 -04:00
Haruka
c403fb49d1
Fix potential audio delay during source cleanup 2022-03-06 18:31:53 -05:00
Josh
147948af9b
Use typing.Self throughout library 2022-03-01 07:53:24 -05:00
Josh
a315786869
Handle type-errors in upcoming pyright release 2022-02-22 08:51:11 -05:00
Josh
70b577e94b
Fix typing in voice related files 2022-02-22 02:37:22 -05:00
Rapptz
88b520b5ab Reformat code using black
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.
2022-02-20 08:04:58 -05:00
Rapptz
2c89202214 Fix some minor typing issues 2022-02-17 09:38:12 -05:00
Imayhaveborkedit
12dcc7c44b
Rearrange player cleanup code
Since apparently closing stdin and later calling communicate() is no bueno, 
we're just going to rearrange the process finalization code so both cleanup()
and the pipe loop exit conditions point to it.
2021-08-27 19:40:31 -04:00
Imayhaveborkedit
3561ce9d5a
Fix FFmpeg based audiosource input piping
Due to an oversight that has existed since the very beginning, the pipe
argument has been broken since there was nothing to actually write 
the data to the process's stdin.  Now there is.

Also josh made me add typings blegh
2021-08-23 21:05:31 -04:00
Rapptz
ea2d972666 Make global log variable in modules private 2021-08-22 02:33:51 -04:00
Josh
5acea453cc
Type-hint voice_client / player 2021-06-28 00:59:14 -04:00
Josh
3864fb37a0
Fix various reference issues in documentation
Co-Authored-By: Riley Shaw <30989490+ShineyDev@users.noreply.github.com>
2021-05-06 07:51:07 -04:00
Rapptz
99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -04:00
Rapptz
9d39b135f4 Modernize code to use f-strings
This also removes the encoding on the top, since Python 3 does it by
default. It also changes some methods to use `yield from`.
2021-04-04 07:03:53 -04:00
Nihaal Sangha
69bdc3a184
Change copyright year to present 2021-01-15 05:28:11 -05:00
Rapptz
f9b5cead31 Suppress the creation of a command window from ffmpeg on Windows
Fix #6038
2020-11-21 23:12:15 -05:00
Skezza
2552a268cb Add double backticks for some parameter mentions in the documentation. 2020-07-22 23:15:16 -04:00
Sebastian Law
b4b953bfc6
Fix various inconsistencies within the documentation (#5067) 2020-06-28 03:45:58 -04:00
Terrance
017591dc9e player: Close ffmpeg stdin during streaming
A `stdin` of `None` means the ffmpeg subprocess input inherits from the
parent process, which may cause undesired control from a terminal (e.g.
`C` causes ffmpeg to prompt for a command).  It also closes the parent's
stdin when the subprocess exits.

This commit switches to `subprocess.DEVNULL`, which provides a separate
pre-closed stdin for ffmpeg subprocesses.
2020-05-23 21:43:26 -04:00
Austin Lasher
032a866fec Fix an FFmpegOpusAudio documentation detail, and some capitalization 2020-04-14 03:24:46 -04:00
Rapptz
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
Rapptz
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
Imayhaveborkedit
839afce178 Print exception tracebacks in voice threads
Errors occurring within `AudioSource.read()` and `after()` functions will now display their tracebacks as if they were unhandled exceptions.
2019-11-26 05:16:53 -05:00
Imayhaveborkedit
bc147ea37b
Fix FFmpegAudio._process not existing if _spawn_process raises 2019-08-27 19:53:44 -04:00
Rapptz
12343c1422 Add versionadded tags to new ffmpeg related classes. 2019-07-27 23:17:06 -04:00
Imayhaveborkedit
fedf26bf3e Add FFmpegOpusAudio and other voice improvements
Rework FFmpeg player and add FFmpegOpusAudio

I have extracted some of the base FFmpeg source code into its own
base class and reimplemented the PCM and the new Opus variants.

Support avconv probing

Also fix a few things

Update `__all__`

Fix the bugs

Rework probe functions and add factory function

Probing involves subprocess so it has been reworked into an async
factory function.

Add docs + a few tweaks

* Removed unnecessary read() and is_opus() functions from FFmpegAudio
* Clear self._stdout in cleanup()
* Add 20 second process communication timeout to probe functions
* Capped probe function bitrate values at 512

Change AudioPlayer to use more accurate, monotonic time.perf_counter()

Add lazy opus loading

The library now no longer loads libopus on import, only on
opus.Encoder creation or manually.

Fix review nits
2019-07-22 20:46:40 -04:00
NCPlayz
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
Rapptz
919dbcafb3 Consistent use of __all__ to prevent merge conflicts. 2019-04-20 17:20:58 -04:00
NCPlayz
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
Imayhaveborkedit
9c5259afd7 Update voice code to vws V4
- Update internals to be compatible with v4
- Adds multiple encryption mode support.  Previously only `xsalsa20_poly1305` was supported.  Now `xsalsa20_poly1305_suffix` is also supported.
  Note: There is no (nice) way to manually select a mode.  The user needn't worry about this however.
- Fixed speaking state bug.  When you disconnected from a voice channel while a bot was playing, upon reconnect you would be unable to hear the bot.  This was caused by bots not sending their speaking state while transmitting.  Bots will now set their speaking state properly when transmitting.  
  Note: This does not account for sending actual silence, the speaking indicator will still be active.
2019-01-28 22:22:52 -05:00
Dante Dam
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
Hornwitser
fa46b07db1 [lint] Rename exception variables to exc
Use the more explicit (and common) exc instead of e as the variable
holding the exception in except handlers.
2018-11-24 22:17:57 -05:00
Hornwitser
a71b3b5fa0 [lint] Limit unneccessarily broad except clauses
Add exception qualifier(s) to bare except clauses swallowing exceptions.
2018-11-24 22:17:57 -05:00
Rapptz
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -04:00
Hornwitser
c8b49d37be [lint] Fix incorrect and inconsistent whitespace
Adjust whitespace to be consistent with the rest of the library.
2018-08-22 21:43:53 -04:00