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
d5d9b35a
Commit
d5d9b35a
authored
15 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
[#2366] Call pa_xfree explicitely in writeToSpeaker
parent
3a859461
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+45
-11
45 additions, 11 deletions
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
with
45 additions
and
11 deletions
sflphone-common/src/audio/pulseaudio/pulselayer.cpp
+
45
−
11
View file @
d5d9b35a
...
...
@@ -501,7 +501,11 @@ void PulseLayer::writeToSpeaker (void)
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writeableSize
);
_urgentRingBuffer
.
Get
(
out
,
writeableSize
,
100
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
writeableSize
,
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_lock (m);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
writeableSize
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_unlock (m);
pa_xfree
(
out
);
// Consume the regular one as well (same amount of bytes)
getMainBuffer
()
->
discard
(
writeableSize
);
...
...
@@ -524,7 +528,11 @@ void PulseLayer::writeToSpeaker (void)
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writeableSize
);
int
copied
=
tone
->
getNext
(
out
,
writeableSize
/
sizeof
(
SFLDataFormat
),
100
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
copied
*
sizeof
(
SFLDataFormat
),
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_lock (m);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
copied
*
sizeof
(
SFLDataFormat
),
NULL
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_unlock (m);
pa_xfree
(
out
);
}
}
...
...
@@ -536,7 +544,11 @@ void PulseLayer::writeToSpeaker (void)
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writeableSize
);
int
copied
=
file_tone
->
getNext
(
out
,
writeableSize
/
sizeof
(
SFLDataFormat
),
100
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
copied
*
sizeof
(
SFLDataFormat
),
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_lock (m);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
copied
*
sizeof
(
SFLDataFormat
),
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
// pa_threaded_mainloop_unlock (m);
}
...
...
@@ -562,7 +574,6 @@ void PulseLayer::writeToSpeaker (void)
}
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
maxNbBytesToGet
);
normalAvailBytes
=
getMainBuffer
()
->
availForGet
();
byteToGet
=
(
normalAvailBytes
<
(
int
)(
maxNbBytesToGet
))
?
normalAvailBytes
:
maxNbBytesToGet
;
...
...
@@ -574,6 +585,8 @@ void PulseLayer::writeToSpeaker (void)
if
(
(
byteToGet
%
2
)
!=
0
)
byteToGet
=
byteToGet
-
1
;
out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
maxNbBytesToGet
);
getMainBuffer
()
->
getData
(
out
,
byteToGet
,
100
);
// test if resampling is required
...
...
@@ -585,18 +598,23 @@ void PulseLayer::writeToSpeaker (void)
int
nb_sample_down
=
byteToGet
/
sizeof
(
SFLDataFormat
);
int
nbSample
=
_converter
->
upsampleData
((
SFLDataFormat
*
)
out
,
rsmpl_out
,
_mainBufferSampleRate
,
_audioSampleRate
,
nb_sample_down
);
pa_stream_write
(
playback
->
pulseStream
(),
rsmpl_out
,
nbSample
*
sizeof
(
SFLDataFormat
),
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
rsmpl_out
);
pa_xfree
(
out
);
if
((
nbSample
*
sizeof
(
SFLDataFormat
))
>
(
unsigned
int
)
writeableSize
)
_debug
(
"Error: nbsbyte exceed buffer length
\n
"
);
// pa_threaded_mainloop_lock (m);
pa_stream_write
(
playback
->
pulseStream
(),
rsmpl_out
,
nbSample
*
sizeof
(
SFLDataFormat
),
NULL
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_unlock (m);
pa_xfree
(
rsmpl_out
);
}
else
{
pa_stream_write
(
playback
->
pulseStream
(),
out
,
byteToGet
,
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
pa_stream_write
(
playback
->
pulseStream
(),
out
,
byteToGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
}
pa_xfree
(
out
);
}
else
{
if
((
tone
==
0
)
&&
(
file_tone
==
0
))
{
...
...
@@ -604,7 +622,12 @@ void PulseLayer::writeToSpeaker (void)
SFLDataFormat
*
zeros
=
(
SFLDataFormat
*
)
pa_xmalloc
(
writeableSize
);
bzero
(
zeros
,
writeableSize
);
pa_stream_write
(
playback
->
pulseStream
(),
zeros
,
writeableSize
,
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_lock (m);
pa_stream_write
(
playback
->
pulseStream
(),
zeros
,
writeableSize
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
// pa_threaded_mainloop_unlock (m);
pa_xfree
(
zeros
);
}
}
...
...
@@ -623,6 +646,13 @@ void PulseLayer::readFromMic (void)
const
char
*
data
=
NULL
;
size_t
r
;
// if (record->getStreamState()
// pa_threaded_mainloop_lock (m);
int
readableSize
=
pa_stream_readable_size
(
record
->
pulseStream
());
_debug
(
"readableSize: %i
\n
"
,
readableSize
);
if
(
pa_stream_peek
(
record
->
pulseStream
()
,
(
const
void
**
)
&
data
,
&
r
)
<
0
||
!
data
)
{
_debug
(
"pa_stream_peek() failed: %s
\n
"
,
pa_strerror
(
pa_context_errno
(
context
)
));
}
...
...
@@ -635,9 +665,11 @@ void PulseLayer::readFromMic (void)
if
(
_mainBufferSampleRate
&&
((
int
)
_audioSampleRate
!=
_mainBufferSampleRate
))
{
SFLDataFormat
*
rsmpl_out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
framesPerBuffer
*
sizeof
(
SFLDataFormat
));
SFLDataFormat
*
rsmpl_out
=
(
SFLDataFormat
*
)
pa_xmalloc
(
readableSize
);
_debug
(
"Byte read: %i
\n
"
,
r
);
int
nbSample
=
r
/
sizeof
(
SFLDataFormat
);
int
nb_sample_up
=
nbSample
;
...
...
@@ -663,6 +695,8 @@ void PulseLayer::readFromMic (void)
if
(
pa_stream_drop
(
record
->
pulseStream
())
<
0
)
{
//_debug("pa_stream_drop() failed: %s\n" , pa_strerror( pa_context_errno( context) ));
}
// pa_threaded_mainloop_unlock (m);
}
static
void
retrieve_server_info
(
pa_context
*
c
UNUSED
,
const
pa_server_info
*
i
,
void
*
userdata
UNUSED
)
...
...
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