3 Commity 22185b9328 ... 1d1fa3b97c

Autor SHA1 Wiadomość Data
  Frans Bergman 1d1fa3b97c Do not count bot user when voting to skip 10 miesięcy temu
  Frans Bergman 4b11202152 Update serenity to 0.12 10 miesięcy temu
  Frans Bergman 22185b9328 WIP: Update serenity to 0.12 10 miesięcy temu
5 zmienionych plików z 116 dodań i 13 usunięć
  1. 104 0
      Cargo.lock
  2. 6 2
      Cargo.toml
  3. 1 1
      src/audio/audio.rs
  4. 2 4
      src/audio/audio_state.rs
  5. 3 6
      src/audio/subprocess.rs

+ 104 - 0
Cargo.lock

@@ -520,6 +520,12 @@ dependencies = [
  "version_check",
 ]
 
+[[package]]
+name = "extended"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
+
 [[package]]
 name = "fastrand"
 version = "2.1.1"
@@ -1180,6 +1186,7 @@ dependencies = [
  "serde_json",
  "serenity",
  "songbird",
+ "symphonia",
  "symphonia-core",
  "tokio",
 ]
@@ -2198,10 +2205,60 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "815c942ae7ee74737bb00f965fa5b5a2ac2ce7b6c01c0cc169bbeaf7abd5f5a9"
 dependencies = [
  "lazy_static",
+ "symphonia-bundle-flac",
+ "symphonia-codec-adpcm",
+ "symphonia-codec-pcm",
+ "symphonia-codec-vorbis",
  "symphonia-core",
+ "symphonia-format-mkv",
+ "symphonia-format-ogg",
+ "symphonia-format-riff",
  "symphonia-metadata",
 ]
 
+[[package]]
+name = "symphonia-bundle-flac"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72e34f34298a7308d4397a6c7fbf5b84c5d491231ce3dd379707ba673ab3bd97"
+dependencies = [
+ "log",
+ "symphonia-core",
+ "symphonia-metadata",
+ "symphonia-utils-xiph",
+]
+
+[[package]]
+name = "symphonia-codec-adpcm"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c94e1feac3327cd616e973d5be69ad36b3945f16b06f19c6773fc3ac0b426a0f"
+dependencies = [
+ "log",
+ "symphonia-core",
+]
+
+[[package]]
+name = "symphonia-codec-pcm"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f395a67057c2ebc5e84d7bb1be71cce1a7ba99f64e0f0f0e303a03f79116f89b"
+dependencies = [
+ "log",
+ "symphonia-core",
+]
+
+[[package]]
+name = "symphonia-codec-vorbis"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a98765fb46a0a6732b007f7e2870c2129b6f78d87db7987e6533c8f164a9f30"
+dependencies = [
+ "log",
+ "symphonia-core",
+ "symphonia-utils-xiph",
+]
+
 [[package]]
 name = "symphonia-core"
 version = "0.5.4"
@@ -2215,6 +2272,43 @@ dependencies = [
  "log",
 ]
 
+[[package]]
+name = "symphonia-format-mkv"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1bb43471a100f7882dc9937395bd5ebee8329298e766250b15b3875652fe3d6f"
+dependencies = [
+ "lazy_static",
+ "log",
+ "symphonia-core",
+ "symphonia-metadata",
+ "symphonia-utils-xiph",
+]
+
+[[package]]
+name = "symphonia-format-ogg"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ada3505789516bcf00fc1157c67729eded428b455c27ca370e41f4d785bfa931"
+dependencies = [
+ "log",
+ "symphonia-core",
+ "symphonia-metadata",
+ "symphonia-utils-xiph",
+]
+
+[[package]]
+name = "symphonia-format-riff"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05f7be232f962f937f4b7115cbe62c330929345434c834359425e043bfd15f50"
+dependencies = [
+ "extended",
+ "log",
+ "symphonia-core",
+ "symphonia-metadata",
+]
+
 [[package]]
 name = "symphonia-metadata"
 version = "0.5.4"
@@ -2227,6 +2321,16 @@ dependencies = [
  "symphonia-core",
 ]
 
+[[package]]
+name = "symphonia-utils-xiph"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "484472580fa49991afda5f6550ece662237b00c6f562c7d9638d1b086ed010fe"
+dependencies = [
+ "symphonia-core",
+ "symphonia-metadata",
+]
+
 [[package]]
 name = "syn"
 version = "1.0.109"

+ 6 - 2
Cargo.toml

@@ -11,7 +11,11 @@ futures = "0.3.5"
 lazy_static = "1.4.0"
 rand = "0.8.3"
 serenity = {version = "0.12", features = ["standard_framework", "voice", "rustls_backend", "cache", "framework"] }
-songbird = {version = "0.4.3", features = ["serenity", "driver"]}
-symphonia-core = "0.5.4"
+songbird = {version = "0.4.3", features = ["serenity", "driver", "builtin-queue"]}
 tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "time", "sync"] }
 serde_json = "1.0.81"
+symphonia-core = "0.5"
+
+[dependencies.symphonia]
+version = "0.5"
+features = ["pcm"]

+ 1 - 1
src/audio/audio.rs

@@ -192,7 +192,7 @@ async fn skip(ctx: &Context, msg: &Message) -> CommandResult {
         let guild = msg.guild(&ctx.cache).ok_or("aaa".to_string())?;
         let state = guild.voice_states.get(&msg.author.id).ok_or("aaa")?;
         let channel = guild.channels.get(&state.channel_id.unwrap());
-        channel.unwrap().members(&ctx.cache).unwrap().len()
+        channel.unwrap().members(&ctx.cache).unwrap().len() - 1 // Do not count bot user
     };
 
     if let Err(why) = AudioState::vote_skip(audio_state, msg.author.clone(), total_users).await {

+ 2 - 4
src/audio/audio_state.rs

@@ -8,7 +8,7 @@ use serenity::{
     prelude::Mutex as SerenityMutex,
 };
 use songbird::{
-    input::{Input, RawAdapter},
+    input::RawAdapter,
     tracks::TrackHandle,
     Call, Event, EventContext, EventHandler as VoiceEventHandler, TrackEvent,
 };
@@ -102,13 +102,11 @@ impl AudioState {
             }
         };
         let source = RawAdapter::new(source, 48000, 2);
-        let input: Input = source.into();
-        let input = input.make_live_async().await.expect("Should work?");
 
         let handler = state.handler.clone();
         let mut handler = handler.lock().await;
 
-        let handle = handler.play_input(input);
+        let handle = handler.play_input(source.into());
         if let Err(e) = handle.set_volume(state.volume) {
             println!("{}", e);
         }

+ 3 - 6
src/audio/subprocess.rs

@@ -1,9 +1,6 @@
 use serde_json::Value;
 use symphonia_core::io::{MediaSourceStream, MediaSourceStreamOptions};
-use std::{
-    io::BufReader,
-    process::{Command, Stdio},
-};
+use std::process::{Command, Stdio};
 use symphonia_core::io::ReadOnlySource;
 use tokio::process::Command as TokioCommand;
 
@@ -54,8 +51,8 @@ pub async fn ffmpeg_pcm(url: &str) -> Result<MediaSourceStream, String> {
         .arg("pcm_f32le")
         .arg("pipe:1")
         .stdout(Stdio::piped())
-        .stderr(Stdio::inherit());
-    println!("{:?}", cmd.get_args());
+        .stderr(Stdio::null());
+
     let child = match cmd.spawn() {
         Ok(child) => child,
         Err(error) => {