Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
eee8d6b0
Commit
eee8d6b0
authored
May 14, 2010
by
Alexandre Savard
Browse files
[#1962] Open a different stream for SFLphone ringtone in pulseaudio
parent
ea419fec
Changes
4
Hide whitespace changes
Inline
Side-by-side
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
View file @
eee8d6b0
...
...
@@ -41,6 +41,15 @@ static void capture_callback (pa_stream* s, size_t bytes, void* userdata)
}
static
void
ringtone_callback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
)
{
assert
(
s
&&
bytes
);
assert
(
bytes
>
0
);
static_cast
<
PulseLayer
*>
(
userdata
)
->
processRingtoneData
();
}
/*
static void stream_suspended_callback (pa_stream *s UNUSED, void *userdata UNUSED)
{
...
...
@@ -278,7 +287,7 @@ bool PulseLayer::createStreams (pa_context* c)
// pa_stream_set_suspended_callback(record->pulseStream(), stream_suspended_callback, this);
// pa_stream_set_moved_callback(record->pulseStream(), stream_moved_callback, this);
delete
recordParam
;
PulseLayerType
*
ringtoneParam
=
new
PulseLayerType
();
ringtoneParam
->
context
=
c
;
ringtoneParam
->
type
=
RINGTONE_STREAM
;
...
...
@@ -288,7 +297,7 @@ bool PulseLayer::createStreams (pa_context* c)
ringtone
=
new
AudioStream
(
ringtoneParam
,
_audioSampleRate
);
ringtone
->
connectStream
();
pa_stream_set_write_callback
(
ringtone
->
pulseStream
(),
playback
_callback
,
this
);
pa_stream_set_write_callback
(
ringtone
->
pulseStream
(),
ringtone
_callback
,
this
);
delete
ringtoneParam
;
pa_threaded_mainloop_signal
(
m
,
0
);
...
...
@@ -329,6 +338,13 @@ void PulseLayer::closePlaybackStream (void)
delete
playback
;
playback
=
NULL
;
}
if
(
ringtone
)
{
delete
ringtone
;
ringtone
=
NULL
;
}
_debug
(
"ringtone is dead"
);
}
...
...
@@ -353,8 +369,8 @@ int PulseLayer::getMic (void *buffer, int toCopy)
void
PulseLayer
::
startStream
(
void
)
{
// Create Streams
if
(
!
playback
||
!
record
)
createStreams
(
context
);
if
(
!
playback
||
!
record
)
createStreams
(
context
);
// Flush outside the if statement: every time start stream is
// called is to notify a new event
...
...
@@ -411,6 +427,19 @@ void PulseLayer::processCaptureData (void)
}
void
PulseLayer
::
processRingtoneData
(
void
)
{
// handle ringtone playback
if
(
ringtone
&&
(
ringtone
)
->
pulseStream
()
&&
(
pa_stream_get_state
(
ringtone
->
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
(
ringtone
->
pulseStream
())
==
0
)
return
;
ringtoneToSpeaker
();
}
}
void
PulseLayer
::
processData
(
void
)
{
...
...
@@ -487,10 +516,11 @@ void PulseLayer::writeToSpeaker (void)
pa_xfree
(
out
);
}
}
//
}
else
if
(
file_tone
!=
0
)
{
//
else if (file_tone != 0) {
/*
if (playback->getStreamState() == PA_STREAM_READY) {
out = (SFLDataFormat*) pa_xmalloc (writeableSize);
...
...
@@ -501,6 +531,7 @@ void PulseLayer::writeToSpeaker (void)
pa_xfree (out);
}
*/
}
else
{
...
...
@@ -641,6 +672,43 @@ void PulseLayer::readFromMic (void)
}
void
PulseLayer
::
ringtoneToSpeaker
(
void
)
{
int
availBytes
;
AudioLoop
*
file_tone
=
_manager
->
getTelephoneFile
();
SFLDataFormat
*
out
;
int
writableSize
=
pa_stream_writable_size
(
ringtone
->
pulseStream
());
_debug
(
"writable size: %d"
,
writableSize
);
if
(
file_tone
)
{
if
(
ringtone
->
getStreamState
()
==
PA_STREAM_READY
)
{
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writableSize
);
int
copied
=
file_tone
->
getNext
(
out
,
writableSize
/
sizeof
(
SFLDataFormat
),
100
);
pa_stream_write
(
ringtone
->
pulseStream
(),
out
,
copied
*
sizeof
(
SFLDataFormat
),
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
}
}
else
{
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writableSize
);
memset
(
out
,
0
,
writableSize
);
pa_stream_write
(
ringtone
->
pulseStream
(),
out
,
writableSize
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
}
}
static
void
retrieve_server_info
(
pa_context
*
c
UNUSED
,
const
pa_server_info
*
i
,
void
*
userdata
UNUSED
)
{
_debug
(
"Server Info: Process owner : %s"
,
i
->
user_name
);
...
...
sflphone-common/src/audio/pulseaudio/pulselayer.h
View file @
eee8d6b0
...
...
@@ -140,6 +140,8 @@ class PulseLayer : public AudioLayer {
void
processCaptureData
(
void
);
void
processRingtoneData
(
void
);
void
processData
(
void
);
private:
...
...
@@ -160,6 +162,7 @@ class PulseLayer : public AudioLayer {
*/
void
readFromMic
(
void
);
void
writeToSpeaker
(
void
);
void
ringtoneToSpeaker
(
void
);
/**
* Create the audio streams into the given context
...
...
sflphone-common/src/managerimpl.cpp
View file @
eee8d6b0
...
...
@@ -3864,15 +3864,19 @@ void ManagerImpl::unloadAccountMap () {
while
(
iter
!=
_accountMap
.
end
())
{
_debug
(
"Unloading account %s
\n
"
,
iter
->
first
.
c_str
());
_debug
(
"Unloading account %s"
,
iter
->
first
.
c_str
());
delete
iter
->
second
;
iter
->
second
=
0
;
iter
->
second
=
NULL
;
iter
++
;
}
_debug
(
"Manager: Clear account map"
);
_accountMap
.
clear
();
_debug
(
"Manager: Unload account map"
);
}
bool
ManagerImpl
::
accountExists
(
const
AccountID
&
accountID
)
{
...
...
sflphone-common/src/sip/sipvoiplink.cpp
View file @
eee8d6b0
...
...
@@ -332,6 +332,8 @@ SIPVoIPLink::terminate()
}
initDone
(
false
);
_debug
(
"Terminating"
);
}
void
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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