mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 19:41:09 +00:00
utils/streamproducer: Index hashmap by appsrc instance instead of pointer
This behaves the same but requires a little bit less code.
This commit is contained in:
parent
a51235048d
commit
e82d388410
1 changed files with 4 additions and 8 deletions
|
@ -56,11 +56,7 @@ impl StreamProducer {
|
||||||
/// Add an appsrc to dispatch data to
|
/// Add an appsrc to dispatch data to
|
||||||
pub fn add_consumer(&self, consumer: &gst_app::AppSrc) {
|
pub fn add_consumer(&self, consumer: &gst_app::AppSrc) {
|
||||||
let mut consumers = self.consumers.lock().unwrap();
|
let mut consumers = self.consumers.lock().unwrap();
|
||||||
if consumers
|
if consumers.consumers.contains_key(consumer) {
|
||||||
.consumers
|
|
||||||
.get(&(consumer.as_ptr() as usize))
|
|
||||||
.is_some()
|
|
||||||
{
|
|
||||||
gst::error!(CAT, obj: &self.appsink, "Consumer already added");
|
gst::error!(CAT, obj: &self.appsink, "Consumer already added");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +85,7 @@ impl StreamProducer {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
consumers.consumers.insert(
|
consumers.consumers.insert(
|
||||||
consumer.as_ptr() as usize,
|
consumer.clone(),
|
||||||
StreamConsumer::new(consumer, fku_probe_id),
|
StreamConsumer::new(consumer, fku_probe_id),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +98,7 @@ impl StreamProducer {
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.consumers
|
.consumers
|
||||||
.remove(&(consumer.as_ptr() as usize))
|
.remove(consumer)
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
gst::debug!(CAT, obj: &self.appsink, "Removed consumer {}", name);
|
gst::debug!(CAT, obj: &self.appsink, "Removed consumer {}", name);
|
||||||
|
@ -274,7 +270,7 @@ struct StreamConsumers {
|
||||||
/// Whether the consumers' appsrc latency needs updating
|
/// Whether the consumers' appsrc latency needs updating
|
||||||
latency_updated: bool,
|
latency_updated: bool,
|
||||||
/// The consumers, AppSrc pointer value -> consumer
|
/// The consumers, AppSrc pointer value -> consumer
|
||||||
consumers: HashMap<usize, StreamConsumer>,
|
consumers: HashMap<gst_app::AppSrc, StreamConsumer>,
|
||||||
/// Whether appsrc samples should be forwarded to consumers yet
|
/// Whether appsrc samples should be forwarded to consumers yet
|
||||||
discard: bool,
|
discard: bool,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue