Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
layeh
gumble
Commits
3d25acf4
Commit
3d25acf4
authored
8 years ago
by
Fahid Jarmache
Committed by
Fahid Jarmash
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Final commit
parent
e251bee1
github/fork/fouf/jitterbuffer
1 merge request
!34
Static jitter buffer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gumble/jitterbuffer.go
+4
-18
gumble/jitterbuffer.go
with
4 additions
and
18 deletions
+4
-18
gumble/jitterbuffer.go
+
4
-
18
View file @
3d25acf4
...
...
@@ -13,7 +13,7 @@ import (
const
(
// JitterStartDelay is the starting delay we will start our buffer with
jitterStartDelay
=
1
00
*
time
.
Millisecond
jitterStartDelay
=
2
00
*
time
.
Millisecond
)
// jbAudioPacket holds pre-decoded audio samples
...
...
@@ -50,10 +50,8 @@ func (h *jitterBufferHeap) Pop() interface{} {
// jitterBuffer struct holds all information to run the jitter buffer
// seq is the current sequence number of the audio packets we have sent to be played
//...
type
jitterBuffer
struct
{
seq
int64
delay
*
time
.
Timer
jitter
time
.
Duration
heap
jitterBufferHeap
bufferSamples
int64
...
...
@@ -65,7 +63,7 @@ type jitterBuffer struct {
RunningLock
*
sync
.
Mutex
}
// Creates a new jitterBuffer
, starts the go routine to handle all packets
// Creates a new jitterBuffer
func
newJitterBuffer
()
*
jitterBuffer
{
jb
:=
&
jitterBuffer
{
running
:
false
,
...
...
@@ -74,8 +72,6 @@ func newJitterBuffer() *jitterBuffer {
HeapLock
:
&
sync
.
Mutex
{},
RunningLock
:
&
sync
.
Mutex
{},
}
//heap.Init(jb.heap)
//jb.process() ???
return
jb
}
...
...
@@ -83,7 +79,6 @@ func newJitterBuffer() *jitterBuffer {
func
(
j
*
jitterBuffer
)
AddPacket
(
ap
*
jbAudioPacket
)
error
{
samples
,
err
:=
j
.
user
.
decoder
.
SampleSize
(
ap
.
Opus
)
if
err
!=
nil
{
//fmt.Fprintf(os.Stderr, "%s %v\n", err, ap.Opus)
return
err
}
ap
.
Samples
=
samples
...
...
@@ -105,8 +100,7 @@ func (j *jitterBuffer) AddPacket(ap *jbAudioPacket) error {
return
nil
}
// TODO Kill stream if no audio for X seconds, don't depend on is last
// Should only be called once internally, handles all packets.
// TODO don't depend on is last
func
(
j
*
jitterBuffer
)
process
()
{
time
.
Sleep
(
j
.
jitter
)
var
chans
[]
chan
*
AudioPacket
...
...
@@ -128,16 +122,8 @@ func (j *jitterBuffer) process() {
}
j
.
client
.
volatileLock
.
Unlock
()
for
{
// Handle jitter buffer/*|| float64((j.bufferSamples/(AudioSampleRate/1000))) < j.delayMs.Seconds()*1000*/
/*if len(j.heap) == 0 {
j.RunningLock.Lock()
j.running = false
j.RunningLock.Unlock()
break // TODO handle better (could run out w/ more audio on the way)
}*/
if
len
(
j
.
heap
)
==
0
{
continue
// TODO Not right? :\
continue
}
j
.
HeapLock
.
Lock
()
if
j
.
target
!=
j
.
heap
[
0
]
.
Target
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment