Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
a4c1a0c8
Commit
a4c1a0c8
authored
16 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
Pulse Audio PA_STREAM_START_CORKED mode now working
parent
d893a4dd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/audio/audiostream.cpp
+3
-1
3 additions, 1 deletion
src/audio/audiostream.cpp
src/audio/pulselayer.cpp
+44
-36
44 additions, 36 deletions
src/audio/pulselayer.cpp
src/audio/pulselayer.h
+4
-1
4 additions, 1 deletion
src/audio/pulselayer.h
with
51 additions
and
38 deletions
src/audio/audiostream.cpp
+
3
−
1
View file @
a4c1a0c8
...
...
@@ -79,6 +79,8 @@ AudioStream::stream_state_callback( pa_stream* s, void* user_data UNUSED )
}
pa_stream
*
AudioStream
::
createStream
(
pa_context
*
c
)
{
...
...
@@ -100,7 +102,7 @@ AudioStream::createStream( pa_context* c )
attributes
->
prebuf
=
10000
;
attributes
->
minreq
=
940
;
pa_stream_connect_playback
(
s
,
NULL
,
attributes
,
PA_STREAM_
INTERPOLATE_TIMING
,
PA_STREAM_
START_CORKED
,
&
_volume
,
NULL
);
}
else
if
(
_streamType
==
CAPTURE_STREAM
){
...
...
This diff is collapsed.
Click to expand it.
src/audio/pulselayer.cpp
+
44
−
36
View file @
a4c1a0c8
...
...
@@ -30,6 +30,8 @@ static void audioCallback ( pa_stream* s, size_t bytes, void* userdata )
static_cast
<
PulseLayer
*>
(
userdata
)
->
processData
();
}
PulseLayer
::
PulseLayer
(
ManagerImpl
*
manager
)
:
AudioLayer
(
manager
,
PULSEAUDIO
)
,
context
(
NULL
)
...
...
@@ -106,7 +108,8 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data )
break
;
case
PA_CONTEXT_READY
:
pulse
->
createStreams
(
c
);
_debug
(
"Connection to PulseAudio server established
\n
"
);
_debug
(
"Connection to PulseAudio server established
\n
"
);
break
;
case
PA_CONTEXT_TERMINATED
:
_debug
(
"Context terminated
\n
"
);
...
...
@@ -130,22 +133,27 @@ void PulseLayer::disconnectPulseAudioServer( void )
delete
record
;
record
=
NULL
;
}
void
PulseLayer
::
createStreams
(
pa_context
*
c
)
void
PulseLayer
::
createStreams
(
pa_context
*
c
)
{
_debug
(
"PulseLayer::createStreams
\n
"
);
playback
=
new
AudioStream
(
c
,
PLAYBACK_STREAM
,
PLAYBACK_STREAM_NAME
,
_manager
->
getSpkrVolume
());
pa_stream_set_write_callback
(
playback
->
pulseStream
()
,
audioCallback
,
this
);
pa_stream_set_write_callback
(
playback
->
pulseStream
(),
audioCallback
,
this
);
//pa_stream_set_overflow_callback( playback->pulseStream() , overflow , this);
// pa_stream_set_suspended_callback( playback->pulseStream(), stream_suspended_callback, this);
record
=
new
AudioStream
(
c
,
CAPTURE_STREAM
,
CAPTURE_STREAM_NAME
,
_manager
->
getMicVolume
());
pa_stream_set_read_callback
(
record
->
pulseStream
()
,
audioCallback
,
this
);
//pa_stream_set_underflow_callback( record->pulseStream() , underflow , this);
// pa_stream_set_suspended_callback(record->pulseStream(), stream_suspended_callback, this);
pa_threaded_mainloop_signal
(
m
,
0
);
}
bool
PulseLayer
::
openDevice
(
int
indexIn
UNUSED
,
int
indexOut
UNUSED
,
int
sampleRate
,
int
frameSize
,
int
stream
UNUSED
,
std
::
string
plugin
UNUSED
)
bool
PulseLayer
::
openDevice
(
int
indexIn
UNUSED
,
int
indexOut
UNUSED
,
int
sampleRate
,
int
frameSize
,
int
stream
UNUSED
,
std
::
string
plugin
UNUSED
)
{
_debug
(
"PulseLayer::openDevice
\n
"
);
_sampleRate
=
sampleRate
;
...
...
@@ -170,18 +178,15 @@ PulseLayer::openDevice(int indexIn UNUSED, int indexOut UNUSED, int sampleRate,
return
true
;
}
void
PulseLayer
::
closeCaptureStream
(
void
)
void
PulseLayer
::
closeCaptureStream
(
void
)
{
}
void
PulseLayer
::
closePlaybackStream
(
void
)
void
PulseLayer
::
closePlaybackStream
(
void
)
{
}
int
PulseLayer
::
canGetMic
()
int
PulseLayer
::
canGetMic
()
{
if
(
record
)
return
_micRingBuffer
.
AvailForGet
();
...
...
@@ -189,8 +194,7 @@ PulseLayer::canGetMic()
return
0
;
}
int
PulseLayer
::
getMic
(
void
*
buffer
,
int
toCopy
)
int
PulseLayer
::
getMic
(
void
*
buffer
,
int
toCopy
)
{
if
(
record
){
return
_micRingBuffer
.
Get
(
buffer
,
toCopy
,
100
);
...
...
@@ -199,15 +203,14 @@ PulseLayer::getMic(void *buffer, int toCopy)
return
0
;
}
void
PulseLayer
::
startStream
(
void
)
void
PulseLayer
::
startStream
(
void
)
{
flushMic
();
_debug
(
"PulseLayer::Start stream
\n
"
);
pa_threaded_mainloop_lock
(
m
);
pa_stream_cork
(
playback
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
0
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
0
,
NULL
,
NULL
);
pa_threaded_mainloop_unlock
(
m
);
...
...
@@ -220,8 +223,8 @@ PulseLayer::stopStream (void)
pa_stream_flush
(
playback
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_flush
(
record
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
1
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
1
,
NULL
,
NULL
);
flushMic
();
flushMain
();
...
...
@@ -230,44 +233,48 @@ PulseLayer::stopStream (void)
void
PulseLayer
::
underflow
(
pa_stream
*
s
UNUSED
,
void
*
userdata
UNUSED
)
void
PulseLayer
::
underflow
(
pa_stream
*
s
UNUSED
,
void
*
userdata
UNUSED
)
{
_debug
(
"PulseLayer::Buffer Underflow
\n
"
);
}
void
PulseLayer
::
overflow
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
void
PulseLayer
::
overflow
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
{
//PulseLayer* pulse = (PulseLayer*) userdata;
pa_stream_drop
(
s
);
pa_stream_trigger
(
s
,
NULL
,
NULL
);
}
void
PulseLayer
::
processData
(
void
)
void
PulseLayer
::
stream_suspended_callback
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
{
// Handle the mic
// We check if the stream is ready
if
(
(
record
->
pulseStream
())
&&
(
pa_stream_get_state
(
record
->
pulseStream
())
==
PA_STREAM_READY
)
&&
record
)
// _debug("PulseLayer::processData() readFromMic() \n");
readFromMic
();
}
// Handle the data for the speakers
if
(
(
playback
->
pulseStream
())
&&
(
pa_stream_get_state
(
playback
->
pulseStream
())
==
PA_STREAM_READY
)
&&
playback
){
void
PulseLayer
::
processData
(
void
)
{
_debug
(
"PulseLayer::processData()
\n
"
);
// Handle the mic
// We check if the stream is ready
if
(
(
record
->
pulseStream
())
&&
(
pa_stream_get_state
(
record
->
pulseStream
())
==
PA_STREAM_READY
))
readFromMic
();
// _debug("PulseLayer::processData() playback->pulseStream() \n");
// Handle the data for the speakers
if
(
(
playback
->
pulseStream
())
&&
(
pa_stream_get_state
(
playback
->
pulseStream
())
==
PA_STREAM_READY
)){
// If the playback buffer is full, we don't overflow it; wait for it to have free space
if
(
pa_stream_writable_size
(
playback
->
pulseStream
())
==
0
)
return
;
// _debug("PulseLayer::processData() writeToSpeaker()\n");
writeToSpeaker
();
}
}
void
PulseLayer
::
writeToSpeaker
(
void
)
void
PulseLayer
::
writeToSpeaker
(
void
)
{
/** Bytes available in the urgent ringbuffer ( reserved for DTMF ) */
int
urgentAvail
;
...
...
@@ -316,6 +323,7 @@ PulseLayer::writeToSpeaker( void )
else
{
bzero
(
out
,
framesPerBuffer
*
sizeof
(
SFLDataFormat
));
}
pa_stream_write
(
playback
->
pulseStream
()
,
out
,
toGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
}
...
...
This diff is collapsed.
Click to expand it.
src/audio/pulselayer.h
+
4
−
1
View file @
a4c1a0c8
...
...
@@ -24,6 +24,7 @@
#include
"audiostream.h"
#include
<pulse/pulseaudio.h>
#include
<pulse/stream.h>
#define PLAYBACK_STREAM_NAME "SFLphone out"
#define CAPTURE_STREAM_NAME "SFLphone in"
...
...
@@ -74,7 +75,8 @@ class PulseLayer : public AudioLayer {
static
void
overflow
(
pa_stream
*
s
,
void
*
userdata
);
static
void
underflow
(
pa_stream
*
s
,
void
*
userdata
);
static
void
stream_state_callback
(
pa_stream
*
s
,
void
*
user_data
);
static
void
context_state_callback
(
pa_context
*
c
,
void
*
user_data
);
static
void
context_state_callback
(
pa_context
*
c
,
void
*
user_data
);
static
void
stream_suspended_callback
(
pa_stream
*
s
,
void
*
userdata
);
bool
isCaptureActive
(
void
){
return
true
;}
...
...
@@ -127,6 +129,7 @@ class PulseLayer : public AudioLayer {
void
setMicVolume
(
int
value
)
{
micVolume
=
value
;
}
void
processData
(
void
);
private
:
// Copy Constructor
PulseLayer
(
const
PulseLayer
&
rh
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment