mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-30 14:16:40 +00:00
librespot: depends on libvorbis built with -fPIC, use proposed upstream commit to disable audio cache
This commit is contained in:
parent
5bdb65cffa
commit
4002953f19
@ -24,7 +24,7 @@ PKG_ARCH="any"
|
|||||||
PKG_LICENSE="prop."
|
PKG_LICENSE="prop."
|
||||||
PKG_SITE="https://github.com/plietar/$PKG_NAME/"
|
PKG_SITE="https://github.com/plietar/$PKG_NAME/"
|
||||||
PKG_URL="https://github.com/plietar/$PKG_NAME/archive/$PKG_VERSION.zip"
|
PKG_URL="https://github.com/plietar/$PKG_NAME/archive/$PKG_VERSION.zip"
|
||||||
PKG_DEPENDS_TARGET="toolchain avahi pyalsaaudio rust"
|
PKG_DEPENDS_TARGET="toolchain avahi libvorbis pyalsaaudio rust"
|
||||||
PKG_SECTION="service"
|
PKG_SECTION="service"
|
||||||
PKG_LONGDESC="Librespot ($PKG_VERSION) plays Spotify through LibreELEC using the opensource librespot library using a Spotify app as a remote."
|
PKG_LONGDESC="Librespot ($PKG_VERSION) plays Spotify through LibreELEC using the opensource librespot library using a Spotify app as a remote."
|
||||||
PKG_AUTORECONF="no"
|
PKG_AUTORECONF="no"
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
From 031cc0a420db9d3ae8dd3543d07ff8503bdc508d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Michael Herger <michael@herger.net>
|
||||||
|
Date: Tue, 20 Jun 2017 12:31:55 +0200
|
||||||
|
Subject: [PATCH] Add --disable-audio-cache startup parameter
|
||||||
|
|
||||||
|
Disable caching of downloaded audio files at runtime. Comes in handy when running librespot on a small device with SD card or other small storage.
|
||||||
|
---
|
||||||
|
src/audio_file.rs | 24 +++++++++++++-----------
|
||||||
|
src/main.rs | 2 ++
|
||||||
|
src/session.rs | 2 ++
|
||||||
|
3 files changed, 17 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/audio_file.rs b/src/audio_file.rs
|
||||||
|
index 369d5ca..d014ba2 100644
|
||||||
|
--- a/src/audio_file.rs
|
||||||
|
+++ b/src/audio_file.rs
|
||||||
|
@@ -151,17 +151,19 @@ impl AudioFileManager {
|
||||||
|
complete_tx: Some(complete_tx),
|
||||||
|
};
|
||||||
|
|
||||||
|
- let session = self.session();
|
||||||
|
- self.session().spawn(move |_| {
|
||||||
|
- complete_rx.map(move |mut file| {
|
||||||
|
- if let Some(cache) = session.cache() {
|
||||||
|
- cache.save_file(file_id, &mut file);
|
||||||
|
- debug!("File {} complete, saving to cache", file_id);
|
||||||
|
- } else {
|
||||||
|
- debug!("File {} complete", file_id);
|
||||||
|
- }
|
||||||
|
- }).or_else(|oneshot::Canceled| Ok(()))
|
||||||
|
- });
|
||||||
|
+ if self.session().config().use_audio_cache {
|
||||||
|
+ let session = self.session();
|
||||||
|
+ self.session().spawn(move |_| {
|
||||||
|
+ complete_rx.map(move |mut file| {
|
||||||
|
+ if let Some(cache) = session.cache() {
|
||||||
|
+ cache.save_file(file_id, &mut file);
|
||||||
|
+ debug!("File {} complete, saving to cache", file_id);
|
||||||
|
+ } else {
|
||||||
|
+ debug!("File {} complete", file_id);
|
||||||
|
+ }
|
||||||
|
+ }).or_else(|oneshot::Canceled| Ok(()))
|
||||||
|
+ });
|
||||||
|
+ }
|
||||||
|
|
||||||
|
AudioFileOpen::Streaming(open)
|
||||||
|
}
|
||||||
|
diff --git a/src/main.rs b/src/main.rs
|
||||||
|
index 38c57fd..8a31a44 100644
|
||||||
|
--- a/src/main.rs
|
||||||
|
+++ b/src/main.rs
|
||||||
|
@@ -86,6 +86,7 @@ struct Setup {
|
||||||
|
fn setup(args: &[String]) -> Setup {
|
||||||
|
let mut opts = getopts::Options::new();
|
||||||
|
opts.optopt("c", "cache", "Path to a directory where files will be cached.", "CACHE")
|
||||||
|
+ .optflag("", "disable-audio-cache", "Disable caching of the audio data.")
|
||||||
|
.reqopt("n", "name", "Device name", "NAME")
|
||||||
|
.optopt("b", "bitrate", "Bitrate (96, 160 or 320). Defaults to 160", "BITRATE")
|
||||||
|
.optopt("", "onstart", "Run PROGRAM when playback is about to begin.", "PROGRAM")
|
||||||
|
@@ -152,6 +153,7 @@ fn setup(args: &[String]) -> Setup {
|
||||||
|
bitrate: bitrate,
|
||||||
|
onstart: matches.opt_str("onstart"),
|
||||||
|
onstop: matches.opt_str("onstop"),
|
||||||
|
+ use_audio_cache: !matches.opt_present("disable-audio-cache"),
|
||||||
|
};
|
||||||
|
|
||||||
|
let device = matches.opt_str("device");
|
||||||
|
diff --git a/src/session.rs b/src/session.rs
|
||||||
|
index 86162bd..a5d397e 100644
|
||||||
|
--- a/src/session.rs
|
||||||
|
+++ b/src/session.rs
|
||||||
|
@@ -49,6 +49,7 @@ pub struct Config {
|
||||||
|
pub bitrate: Bitrate,
|
||||||
|
pub onstart: Option<String>,
|
||||||
|
pub onstop: Option<String>,
|
||||||
|
+ pub use_audio_cache: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
@@ -60,6 +61,7 @@ impl Default for Config {
|
||||||
|
bitrate: Bitrate::Bitrate160,
|
||||||
|
onstart: None,
|
||||||
|
onstop: None,
|
||||||
|
+ use_audio_cache: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,48 +0,0 @@
|
|||||||
diff -Naur librespot/src/audio_file.rs librespot.nocache/src/audio_file.rs
|
|
||||||
--- librespot/src/audio_file.rs 2017-06-14 00:14:21.000000000 +0200
|
|
||||||
+++ librespot.nocache/src/audio_file.rs 2017-06-20 00:35:14.060020000 +0200
|
|
||||||
@@ -3,7 +3,7 @@
|
|
||||||
use futures::Stream;
|
|
||||||
use futures::sync::{oneshot, mpsc};
|
|
||||||
use futures::{Poll, Async, Future};
|
|
||||||
-use futures::future::{self, FutureResult};
|
|
||||||
+use futures::future::FutureResult;
|
|
||||||
use std::cmp::min;
|
|
||||||
use std::fs;
|
|
||||||
use std::io::{self, Read, Write, Seek, SeekFrom};
|
|
||||||
@@ -129,15 +129,9 @@
|
|
||||||
|
|
||||||
impl AudioFileManager {
|
|
||||||
pub fn open(&self, file_id: FileId) -> AudioFileOpen {
|
|
||||||
- let cache = self.session().cache().cloned();
|
|
||||||
-
|
|
||||||
- if let Some(file) = cache.as_ref().and_then(|cache| cache.file(file_id)) {
|
|
||||||
- debug!("File {} already in cache", file_id);
|
|
||||||
- return AudioFileOpen::Cached(future::ok(file));
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
debug!("Downloading file {}", file_id);
|
|
||||||
|
|
||||||
+ #[allow(unused_variables)]
|
|
||||||
let (complete_tx, complete_rx) = oneshot::channel();
|
|
||||||
let (headers, data) = request_chunk(&self.session(), file_id, 0).split();
|
|
||||||
|
|
||||||
@@ -151,18 +145,6 @@
|
|
||||||
complete_tx: Some(complete_tx),
|
|
||||||
};
|
|
||||||
|
|
||||||
- let session = self.session();
|
|
||||||
- self.session().spawn(move |_| {
|
|
||||||
- complete_rx.map(move |mut file| {
|
|
||||||
- if let Some(cache) = session.cache() {
|
|
||||||
- cache.save_file(file_id, &mut file);
|
|
||||||
- debug!("File {} complete, saving to cache", file_id);
|
|
||||||
- } else {
|
|
||||||
- debug!("File {} complete", file_id);
|
|
||||||
- }
|
|
||||||
- }).or_else(|oneshot::Canceled| Ok(()))
|
|
||||||
- });
|
|
||||||
-
|
|
||||||
AudioFileOpen::Streaming(open)
|
|
||||||
}
|
|
||||||
}
|
|
@ -95,5 +95,6 @@ esac
|
|||||||
librespot $bitrate \
|
librespot $bitrate \
|
||||||
--cache "$ADDON_HOME/cache" \
|
--cache "$ADDON_HOME/cache" \
|
||||||
$device \
|
$device \
|
||||||
|
--disable-audio-cache \
|
||||||
$discovery \
|
$discovery \
|
||||||
--name "Librespot@$HOSTNAME"
|
--name "Librespot@$HOSTNAME"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user