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
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show 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 )
...
@@ -79,6 +79,8 @@ AudioStream::stream_state_callback( pa_stream* s, void* user_data UNUSED )
}
}
pa_stream
*
pa_stream
*
AudioStream
::
createStream
(
pa_context
*
c
)
AudioStream
::
createStream
(
pa_context
*
c
)
{
{
...
@@ -100,7 +102,7 @@ AudioStream::createStream( pa_context* c )
...
@@ -100,7 +102,7 @@ AudioStream::createStream( pa_context* c )
attributes
->
prebuf
=
10000
;
attributes
->
prebuf
=
10000
;
attributes
->
minreq
=
940
;
attributes
->
minreq
=
940
;
pa_stream_connect_playback
(
s
,
NULL
,
attributes
,
pa_stream_connect_playback
(
s
,
NULL
,
attributes
,
PA_STREAM_
INTERPOLATE_TIMING
,
PA_STREAM_
START_CORKED
,
&
_volume
,
NULL
);
&
_volume
,
NULL
);
}
}
else
if
(
_streamType
==
CAPTURE_STREAM
){
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 )
...
@@ -30,6 +30,8 @@ static void audioCallback ( pa_stream* s, size_t bytes, void* userdata )
static_cast
<
PulseLayer
*>
(
userdata
)
->
processData
();
static_cast
<
PulseLayer
*>
(
userdata
)
->
processData
();
}
}
PulseLayer
::
PulseLayer
(
ManagerImpl
*
manager
)
PulseLayer
::
PulseLayer
(
ManagerImpl
*
manager
)
:
AudioLayer
(
manager
,
PULSEAUDIO
)
:
AudioLayer
(
manager
,
PULSEAUDIO
)
,
context
(
NULL
)
,
context
(
NULL
)
...
@@ -107,6 +109,7 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data )
...
@@ -107,6 +109,7 @@ void PulseLayer::context_state_callback( pa_context* c, void* user_data )
case
PA_CONTEXT_READY
:
case
PA_CONTEXT_READY
:
pulse
->
createStreams
(
c
);
pulse
->
createStreams
(
c
);
_debug
(
"Connection to PulseAudio server established
\n
"
);
_debug
(
"Connection to PulseAudio server established
\n
"
);
break
;
break
;
case
PA_CONTEXT_TERMINATED
:
case
PA_CONTEXT_TERMINATED
:
_debug
(
"Context terminated
\n
"
);
_debug
(
"Context terminated
\n
"
);
...
@@ -130,22 +133,27 @@ void PulseLayer::disconnectPulseAudioServer( void )
...
@@ -130,22 +133,27 @@ void PulseLayer::disconnectPulseAudioServer( void )
delete
record
;
record
=
NULL
;
delete
record
;
record
=
NULL
;
}
}
void
PulseLayer
::
createStreams
(
pa_context
*
c
)
void
PulseLayer
::
createStreams
(
pa_context
*
c
)
{
{
_debug
(
"PulseLayer::createStreams
\n
"
);
_debug
(
"PulseLayer::createStreams
\n
"
);
playback
=
new
AudioStream
(
c
,
PLAYBACK_STREAM
,
PLAYBACK_STREAM_NAME
,
_manager
->
getSpkrVolume
());
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_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
());
record
=
new
AudioStream
(
c
,
CAPTURE_STREAM
,
CAPTURE_STREAM_NAME
,
_manager
->
getMicVolume
());
pa_stream_set_read_callback
(
record
->
pulseStream
()
,
audioCallback
,
this
);
pa_stream_set_read_callback
(
record
->
pulseStream
()
,
audioCallback
,
this
);
//pa_stream_set_underflow_callback( record->pulseStream() , underflow , 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
);
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
"
);
_debug
(
"PulseLayer::openDevice
\n
"
);
_sampleRate
=
sampleRate
;
_sampleRate
=
sampleRate
;
...
@@ -170,18 +178,15 @@ PulseLayer::openDevice(int indexIn UNUSED, int indexOut UNUSED, int sampleRate,
...
@@ -170,18 +178,15 @@ PulseLayer::openDevice(int indexIn UNUSED, int indexOut UNUSED, int sampleRate,
return
true
;
return
true
;
}
}
void
void
PulseLayer
::
closeCaptureStream
(
void
)
PulseLayer
::
closeCaptureStream
(
void
)
{
{
}
}
void
void
PulseLayer
::
closePlaybackStream
(
void
)
PulseLayer
::
closePlaybackStream
(
void
)
{
{
}
}
int
int
PulseLayer
::
canGetMic
()
PulseLayer
::
canGetMic
()
{
{
if
(
record
)
if
(
record
)
return
_micRingBuffer
.
AvailForGet
();
return
_micRingBuffer
.
AvailForGet
();
...
@@ -189,8 +194,7 @@ PulseLayer::canGetMic()
...
@@ -189,8 +194,7 @@ PulseLayer::canGetMic()
return
0
;
return
0
;
}
}
int
int
PulseLayer
::
getMic
(
void
*
buffer
,
int
toCopy
)
PulseLayer
::
getMic
(
void
*
buffer
,
int
toCopy
)
{
{
if
(
record
){
if
(
record
){
return
_micRingBuffer
.
Get
(
buffer
,
toCopy
,
100
);
return
_micRingBuffer
.
Get
(
buffer
,
toCopy
,
100
);
...
@@ -199,15 +203,14 @@ PulseLayer::getMic(void *buffer, int toCopy)
...
@@ -199,15 +203,14 @@ PulseLayer::getMic(void *buffer, int toCopy)
return
0
;
return
0
;
}
}
void
void
PulseLayer
::
startStream
(
void
)
PulseLayer
::
startStream
(
void
)
{
{
flushMic
();
flushMic
();
_debug
(
"PulseLayer::Start stream
\n
"
);
_debug
(
"PulseLayer::Start stream
\n
"
);
pa_threaded_mainloop_lock
(
m
);
pa_threaded_mainloop_lock
(
m
);
pa_stream_cork
(
playback
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
0
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
0
,
NULL
,
NULL
);
pa_threaded_mainloop_unlock
(
m
);
pa_threaded_mainloop_unlock
(
m
);
...
@@ -220,8 +223,8 @@ PulseLayer::stopStream (void)
...
@@ -220,8 +223,8 @@ PulseLayer::stopStream (void)
pa_stream_flush
(
playback
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_flush
(
playback
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_flush
(
record
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_flush
(
record
->
pulseStream
(),
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
playback
->
pulseStream
(),
1
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
NULL
,
NULL
,
NULL
);
pa_stream_cork
(
record
->
pulseStream
(),
1
,
NULL
,
NULL
);
flushMic
();
flushMic
();
flushMain
();
flushMain
();
...
@@ -230,44 +233,48 @@ PulseLayer::stopStream (void)
...
@@ -230,44 +233,48 @@ PulseLayer::stopStream (void)
void
void
PulseLayer
::
underflow
(
pa_stream
*
s
UNUSED
,
void
*
userdata
UNUSED
)
PulseLayer
::
underflow
(
pa_stream
*
s
UNUSED
,
void
*
userdata
UNUSED
)
{
{
_debug
(
"PulseLayer::Buffer Underflow
\n
"
);
_debug
(
"PulseLayer::Buffer Underflow
\n
"
);
}
}
void
void
PulseLayer
::
overflow
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
PulseLayer
::
overflow
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
{
{
//PulseLayer* pulse = (PulseLayer*) userdata;
//PulseLayer* pulse = (PulseLayer*) userdata;
pa_stream_drop
(
s
);
pa_stream_drop
(
s
);
pa_stream_trigger
(
s
,
NULL
,
NULL
);
pa_stream_trigger
(
s
,
NULL
,
NULL
);
}
}
void
void
PulseLayer
::
stream_suspended_callback
(
pa_stream
*
s
,
void
*
userdata
UNUSED
)
PulseLayer
::
processData
(
void
)
{
}
void
PulseLayer
::
processData
(
void
)
{
{
_debug
(
"PulseLayer::processData()
\n
"
);
// Handle the mic
// Handle the mic
// We check if the stream is ready
// We check if the stream is ready
if
(
(
record
->
pulseStream
())
&&
(
pa_stream_get_state
(
record
->
pulseStream
())
==
PA_STREAM_READY
)
&&
record
)
if
(
(
record
->
pulseStream
())
&&
(
pa_stream_get_state
(
record
->
pulseStream
())
==
PA_STREAM_READY
))
// _debug("PulseLayer::processData() readFromMic() \n");
readFromMic
();
readFromMic
();
// _debug("PulseLayer::processData() playback->pulseStream() \n");
// Handle the data for the speakers
// Handle the data for the speakers
if
(
(
playback
->
pulseStream
())
&&
(
pa_stream_get_state
(
playback
->
pulseStream
())
==
PA_STREAM_READY
)
&&
playback
){
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 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
)
if
(
pa_stream_writable_size
(
playback
->
pulseStream
())
==
0
)
return
;
return
;
// _debug("PulseLayer::processData() writeToSpeaker()\n");
writeToSpeaker
();
writeToSpeaker
();
}
}
}
}
void
void
PulseLayer
::
writeToSpeaker
(
void
)
PulseLayer
::
writeToSpeaker
(
void
)
{
{
/** Bytes available in the urgent ringbuffer ( reserved for DTMF ) */
/** Bytes available in the urgent ringbuffer ( reserved for DTMF ) */
int
urgentAvail
;
int
urgentAvail
;
...
@@ -316,6 +323,7 @@ PulseLayer::writeToSpeaker( void )
...
@@ -316,6 +323,7 @@ PulseLayer::writeToSpeaker( void )
else
{
else
{
bzero
(
out
,
framesPerBuffer
*
sizeof
(
SFLDataFormat
));
bzero
(
out
,
framesPerBuffer
*
sizeof
(
SFLDataFormat
));
}
}
pa_stream_write
(
playback
->
pulseStream
()
,
out
,
toGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_stream_write
(
playback
->
pulseStream
()
,
out
,
toGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
pa_xfree
(
out
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/audio/pulselayer.h
+
4
−
1
View file @
a4c1a0c8
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include
"audiostream.h"
#include
"audiostream.h"
#include
<pulse/pulseaudio.h>
#include
<pulse/pulseaudio.h>
#include
<pulse/stream.h>
#define PLAYBACK_STREAM_NAME "SFLphone out"
#define PLAYBACK_STREAM_NAME "SFLphone out"
#define CAPTURE_STREAM_NAME "SFLphone in"
#define CAPTURE_STREAM_NAME "SFLphone in"
...
@@ -75,6 +76,7 @@ class PulseLayer : public AudioLayer {
...
@@ -75,6 +76,7 @@ class PulseLayer : public AudioLayer {
static
void
underflow
(
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
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
;}
bool
isCaptureActive
(
void
){
return
true
;}
...
@@ -127,6 +129,7 @@ class PulseLayer : public AudioLayer {
...
@@ -127,6 +129,7 @@ class PulseLayer : public AudioLayer {
void
setMicVolume
(
int
value
)
{
micVolume
=
value
;
}
void
setMicVolume
(
int
value
)
{
micVolume
=
value
;
}
void
processData
(
void
);
void
processData
(
void
);
private
:
private
:
// Copy Constructor
// Copy Constructor
PulseLayer
(
const
PulseLayer
&
rh
);
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