mirror of
https://github.com/pion/webrtc.git
synced 2025-10-28 09:41:35 +08:00
Gstreamer: avoid lock contention with pipeline
Stop one pipeline from preventing others from sending data if it wasn't being serviced
This commit is contained in:
@@ -22,8 +22,8 @@ func init() {
|
|||||||
|
|
||||||
// Pipeline is a wrapper for a GStreamer Pipeline
|
// Pipeline is a wrapper for a GStreamer Pipeline
|
||||||
type Pipeline struct {
|
type Pipeline struct {
|
||||||
Pipeline *C.GstElement
|
Pipeline *C.GstElement
|
||||||
in chan<- media.RTCSample
|
in chan<- media.RTCSample
|
||||||
// stop acts as a signal that this pipeline is stopped
|
// stop acts as a signal that this pipeline is stopped
|
||||||
// any pending sends to Pipeline.in should be cancelled
|
// any pending sends to Pipeline.in should be cancelled
|
||||||
stop chan interface{}
|
stop chan interface{}
|
||||||
@@ -93,9 +93,10 @@ const (
|
|||||||
//export goHandlePipelineBuffer
|
//export goHandlePipelineBuffer
|
||||||
func goHandlePipelineBuffer(buffer unsafe.Pointer, bufferLen C.int, duration C.int, pipelineID C.int) {
|
func goHandlePipelineBuffer(buffer unsafe.Pointer, bufferLen C.int, duration C.int, pipelineID C.int) {
|
||||||
pipelinesLock.Lock()
|
pipelinesLock.Lock()
|
||||||
defer pipelinesLock.Unlock()
|
pipeline, ok := pipelines[int(pipelineID)]
|
||||||
|
pipelinesLock.Unlock()
|
||||||
|
|
||||||
if pipeline, ok := pipelines[int(pipelineID)]; ok {
|
if ok {
|
||||||
var samples uint32
|
var samples uint32
|
||||||
if pipeline.codecName == webrtc.Opus {
|
if pipeline.codecName == webrtc.Opus {
|
||||||
samples = uint32(audioClockRate * (float32(duration) / 1000000000))
|
samples = uint32(audioClockRate * (float32(duration) / 1000000000))
|
||||||
|
|||||||
Reference in New Issue
Block a user