Some minor cleanup

This commit is contained in:
Sebastian Dröge 2016-05-15 16:15:58 +03:00
parent aeefcefe09
commit 87bd914cad
4 changed files with 11 additions and 14 deletions

View file

@ -20,7 +20,7 @@ use rssink::Sink;
use rsfilesink::FileSink;
use std::os::raw::c_void;
use libc::{c_char};
use libc::c_char;
use std::ffi::CString;
extern "C" {

View file

@ -67,10 +67,10 @@ impl Source for FileSrc {
}
fn get_uri(&self) -> Option<String> {
match self.location {
None => None,
Some(ref location) => Url::from_file_path(&location).map(|u| u.into_string()).ok()
}
self.location.as_ref()
.map(|l| Url::from_file_path(l).ok())
.and_then(|i| i) // join()
.map(|u| u.into_string())
}
fn is_seekable(&self) -> bool {
@ -78,12 +78,11 @@ impl Source for FileSrc {
}
fn get_size(&self) -> u64 {
match self.file {
None => return u64::MAX,
Some(ref f) => {
return f.metadata().map(|m| m.len()).unwrap_or(u64::MAX);
},
}
self.file.as_ref()
.map(|f| f.metadata().ok())
.and_then(|i| i) // join()
.map(|m| m.len())
.unwrap_or(u64::MAX)
}
fn start(&mut self) -> bool {

View file

@ -142,7 +142,7 @@ impl Source for HttpSrc {
}
fn get_uri(&self) -> Option<String> {
self.url.clone().map(|u| u.into_string())
self.url.as_ref().map(|u| String::from(u.as_str()))
}
fn is_seekable(&self) -> bool {

View file

@ -4,7 +4,6 @@
#include <stdint.h>
typedef struct {
gchar *name;
gchar *long_name;
gchar *description;
gchar *classification;
@ -305,7 +304,6 @@ gst_rs_source_register (GstPlugin * plugin, const gchar *name, const gchar * lon
ElementData *data;
data = g_new0 (ElementData, 1);
data->name = g_strdup (name);
data->long_name = g_strdup (long_name);
data->description = g_strdup (description);
data->classification = g_strdup (classification);