mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Merge pull request #1187 from jokester/fix/prevent-overwrite-to-unchanged-cred
do not overwrite unchanged cached Credentials (#1168)
This commit is contained in:
commit
8e43c3f097
3 changed files with 10 additions and 4 deletions
|
@ -27,7 +27,7 @@ impl From<AuthenticationError> for Error {
|
|||
}
|
||||
|
||||
/// The credentials are used to log into the Spotify API.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Credentials {
|
||||
pub username: String,
|
||||
|
||||
|
|
|
@ -176,9 +176,15 @@ impl Session {
|
|||
self.set_username(&reusable_credentials.username);
|
||||
if let Some(cache) = self.cache() {
|
||||
if store_credentials {
|
||||
let cred_changed = cache
|
||||
.credentials()
|
||||
.map(|c| c != reusable_credentials)
|
||||
.unwrap_or(true);
|
||||
if cred_changed {
|
||||
cache.save_credentials(&reusable_credentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (tx_connection, rx_connection) = mpsc::unbounded_channel();
|
||||
self.0
|
||||
|
|
|
@ -47,8 +47,8 @@ impl Open for JackSink {
|
|||
let client_name = client_name.unwrap_or_else(|| "librespot".to_string());
|
||||
let (client, _status) =
|
||||
Client::new(&client_name[..], ClientOptions::NO_START_SERVER).unwrap();
|
||||
let ch_r = client.register_port("out_0", AudioOut::default()).unwrap();
|
||||
let ch_l = client.register_port("out_1", AudioOut::default()).unwrap();
|
||||
let ch_r = client.register_port("out_0", AudioOut).unwrap();
|
||||
let ch_l = client.register_port("out_1", AudioOut).unwrap();
|
||||
// buffer for samples from librespot (~10ms)
|
||||
let (tx, rx) = sync_channel::<f32>(NUM_CHANNELS as usize * 1024 * AudioFormat::F32.size());
|
||||
let jack_data = JackData {
|
||||
|
|
Loading…
Reference in a new issue