Commit Graph

39 Commits

Author SHA1 Message Date
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
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
ea2d972666 Make global log variable in modules private 2021-08-22 02:33:51 -04:00
5acea453cc Type-hint voice_client / player 2021-06-28 00:59:14 -04:00
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
99fc950510 Use f-strings in more places that were missed. 2021-04-08 06:02:47 -04:00
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
69bdc3a184 Change copyright year to present 2021-01-15 05:28:11 -05:00
f9b5cead31 Suppress the creation of a command window from ffmpeg on Windows
Fix #6038
2020-11-21 23:12:15 -05:00
2552a268cb Add double backticks for some parameter mentions in the documentation. 2020-07-22 23:15:16 -04:00
b4b953bfc6 Fix various inconsistencies within the documentation (#5067) 2020-06-28 03:45:58 -04:00
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
032a866fec Fix an FFmpegOpusAudio documentation detail, and some capitalization 2020-04-14 03:24:46 -04:00
02397306b2 Drop superfluous zero in version related changes in the documentation 2020-01-21 03:47:56 -05:00
6071607176 Bump copyright year to 2020
Closes #2510
2020-01-19 20:03:00 -05:00
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
bc147ea37b Fix FFmpegAudio._process not existing if _spawn_process raises 2019-08-27 19:53:44 -04:00
12343c1422 Add versionadded tags to new ffmpeg related classes. 2019-07-27 23:17:06 -04:00
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
3c9bcc2851 Improve documentation 2019-06-07 19:27:46 -04:00
919dbcafb3 Consistent use of __all__ to prevent merge conflicts. 2019-04-20 17:20:58 -04:00
fb02191b80 Organise documentation 2019-03-19 08:24:42 -04:00
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
9656a21ebe Bumped copyright years to 2019. 2019-01-28 22:22:50 -05:00
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
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
5c24e69cf2 Fix up the Sphinx strings causing warnings. 2018-09-15 09:54:00 -04:00
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
ceb82ecc7b Fix self._process not existing during cleanup() in case of error 2017-11-21 17:51:34 -05:00
b532da7906 Fix waiting for resume when calling stop() on AudioPlayer 2017-07-21 18:37:22 -04:00
5d75c44651 Call cleanup on AudioSource.__del__. 2017-07-19 05:58:20 -04:00
eda903f6b1 Add some logging for when ffmpeg processes get terminated. 2017-07-18 18:46:56 -04:00
daf066dd39 Log when a player's after function fails. 2017-06-02 06:43:33 -04:00
34c60002bf Allow setting a default volume in PCMVolumeTransformer. 2017-04-19 17:33:16 -04:00
f5cfc96aaf Add PCMVolumeTransformer to augment volume of a PCM stream.
This also introduces the idea of replacing the VoiceClient.source on
the fly. Note that this internally pauses and resumes the audio
stream.
2017-04-19 17:23:39 -04:00
07d5328873 Add VoiceClient.is_paused to query pause state. 2017-04-19 16:06:45 -04:00
efd6d11e9a Fix static cut-off when playing. 2017-04-18 22:20:40 -04:00
b4bc4dfd12 Fix FFmpegPCMAudio not working with spaces in filename. 2017-04-18 16:05:32 -04:00
3b1b26ffb1 Re-implement voice sending.
This is a complete redesign of the old voice code.

A list of major changes is as follows:

* The voice websocket will now automatically reconnect with
  exponential back-off just like the regular Client does.
* Removal of the stream player concept.
* Audio now gracefully pauses and resumes when a disconnect is found.
* Introduce a discord.AudioSource concept to abstract streams
* Flatten previous stream player functionality with the
  VoiceClient, e.g. player.stop() is now voice_client.stop()
* With the above re-coupling this means you no longer have to
  store players anywhere.
* The after function now requires a single parameter, the error,
  if any existed. This will typically be None.

A lot of this design is experimental.
2017-04-18 03:49:48 -04:00