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 rsfilesink::FileSink;
use std::os::raw::c_void; use std::os::raw::c_void;
use libc::{c_char}; use libc::c_char;
use std::ffi::CString; use std::ffi::CString;
extern "C" { extern "C" {

View file

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

View file

@ -142,7 +142,7 @@ impl Source for HttpSrc {
} }
fn get_uri(&self) -> Option<String> { 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 { fn is_seekable(&self) -> bool {

View file

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