mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-19 08:36:27 +00:00
Use an AtomicBool for the seekable variable as is_seekable() can be called at any time from any thread
This commit is contained in:
parent
5cc890cc04
commit
84c0d4c74c
1 changed files with 8 additions and 7 deletions
|
@ -24,6 +24,7 @@ use hyper::client::response::Response;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use utils::*;
|
use utils::*;
|
||||||
use rssource::*;
|
use rssource::*;
|
||||||
|
@ -33,7 +34,7 @@ pub struct HttpSrc {
|
||||||
url: Mutex<Option<Url>>,
|
url: Mutex<Option<Url>>,
|
||||||
client: Client,
|
client: Client,
|
||||||
response: Option<Response>,
|
response: Option<Response>,
|
||||||
seekable: bool,
|
seekable: AtomicBool,
|
||||||
position: u64,
|
position: u64,
|
||||||
size: u64,
|
size: u64,
|
||||||
start: u64,
|
start: u64,
|
||||||
|
@ -45,7 +46,7 @@ unsafe impl Send for HttpSrc {}
|
||||||
|
|
||||||
impl HttpSrc {
|
impl HttpSrc {
|
||||||
fn new() -> HttpSrc {
|
fn new() -> HttpSrc {
|
||||||
HttpSrc { url: Mutex::new(None), client: Client::new(), response: None, seekable: false, position: 0, size: u64::MAX, start: 0, stop: u64::MAX }
|
HttpSrc { url: Mutex::new(None), client: Client::new(), response: None, seekable: AtomicBool::new(false), position: 0, size: u64::MAX, start: 0, stop: u64::MAX }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new_source() -> Box<Source> {
|
fn new_source() -> Box<Source> {
|
||||||
|
@ -58,7 +59,7 @@ impl HttpSrc {
|
||||||
|
|
||||||
pub fn do_request(&mut self, start: u64, stop: u64) -> bool {
|
pub fn do_request(&mut self, start: u64, stop: u64) -> bool {
|
||||||
self.response = None;
|
self.response = None;
|
||||||
self.seekable = false;
|
self.seekable.store(false, Ordering::Relaxed);
|
||||||
self.position = 0;
|
self.position = 0;
|
||||||
self.size = u64::MAX;
|
self.size = u64::MAX;
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ impl HttpSrc {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
self.seekable = self.size != u64::MAX && accept_byte_ranges;
|
self.seekable.store(self.size != u64::MAX && accept_byte_ranges, Ordering::Relaxed);
|
||||||
|
|
||||||
self.start = start;
|
self.start = start;
|
||||||
self.stop = stop;
|
self.stop = stop;
|
||||||
|
@ -170,7 +171,7 @@ impl Source for HttpSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_seekable(&self) -> bool {
|
fn is_seekable(&self) -> bool {
|
||||||
self.seekable
|
self.seekable.load(Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_size(&self) -> u64 {
|
fn get_size(&self) -> u64 {
|
||||||
|
@ -178,12 +179,12 @@ impl Source for HttpSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&mut self) -> bool {
|
fn start(&mut self) -> bool {
|
||||||
self.seekable = false;
|
self.seekable.store(false, Ordering::Relaxed);
|
||||||
return self.do_request(0, u64::MAX);
|
return self.do_request(0, u64::MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&mut self) -> bool {
|
fn stop(&mut self) -> bool {
|
||||||
self.seekable = false;
|
self.seekable.store(false, Ordering::Relaxed);
|
||||||
self.position = 0;
|
self.position = 0;
|
||||||
self.size = u64::MAX;
|
self.size = u64::MAX;
|
||||||
match self.response {
|
match self.response {
|
||||||
|
|
Loading…
Reference in a new issue