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
30415c38
Commit
30415c38
authored
16 years ago
by
Emmanuel Milou
Browse files
Options
Downloads
Patches
Plain Diff
Fix memory leak in the pulseaudio callback
parent
a360c591
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/audio/pulselayer.cpp
+14
-13
14 additions, 13 deletions
src/audio/pulselayer.cpp
src/audio/pulselayer.h
+2
-2
2 additions, 2 deletions
src/audio/pulselayer.h
with
16 additions
and
15 deletions
src/audio/pulselayer.cpp
+
14
−
13
View file @
30415c38
...
...
@@ -21,7 +21,14 @@
int
framesPerBuffer
=
2048
;
PulseLayer
::
PulseLayer
(
ManagerImpl
*
manager
)
static
void
audioCallback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
)
{
assert
(
s
&&
bytes
);
assert
(
bytes
>
0
);
static_cast
<
PulseLayer
*>
(
userdata
)
->
processData
();
}
PulseLayer
::
PulseLayer
(
ManagerImpl
*
manager
)
:
AudioLayer
(
manager
,
PULSEAUDIO
)
,
_mainSndRingBuffer
(
SIZEBUF
)
,
_urgentRingBuffer
(
SIZEBUF
)
...
...
@@ -125,7 +132,7 @@ PulseLayer::createStreams( pa_context* c )
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);
cache
=
new
AudioStream
(
c
,
UPLOAD_STREAM
,
"Cache samples"
,
_manager
->
getSpkrVolume
());
//
cache = new AudioStream(c, UPLOAD_STREAM, "Cache samples", _manager->getSpkrVolume());
pa_threaded_mainloop_signal
(
m
,
0
);
}
...
...
@@ -240,14 +247,7 @@ PulseLayer::stopStream (void)
flushMic
();
}
void
PulseLayer
::
audioCallback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
)
{
PulseLayer
*
pulse
=
(
PulseLayer
*
)
userdata
;
assert
(
s
&&
bytes
);
assert
(
bytes
>
0
);
pulse
->
processData
();
}
void
PulseLayer
::
underflow
(
pa_stream
*
s
UNUSED
,
void
*
userdata
UNUSED
)
...
...
@@ -292,8 +292,9 @@ void PulseLayer::writeToSpeaker( void )
int
toGet
;
int
toPlay
;
SFLDataFormat
*
out
;
SFLDataFormat
*
out
;
// = (SFLDataFormat*)pa_xmalloc(framesPerBuffer);
urgentAvail
=
_urgentRingBuffer
.
AvailForGet
();
if
(
urgentAvail
>
0
)
{
// Urgent data (dtmf, incoming call signal) come first.
//_debug("Play urgent!: %i\n" , urgentAvail);
...
...
@@ -331,11 +332,11 @@ void PulseLayer::writeToSpeaker( void )
else
{
bzero
(
out
,
framesPerBuffer
*
sizeof
(
SFLDataFormat
));
}
pa_stream_write
(
playback
->
pulseStream
()
,
out
,
toGet
,
pa_xfree
,
0
,
PA_SEEK_RELATIVE
);
pa_stream_write
(
playback
->
pulseStream
()
,
out
,
toGet
,
NULL
,
0
,
PA_SEEK_RELATIVE
);
pa_xfree
(
out
);
}
}
//if(out) pa_xfree(out);
}
void
PulseLayer
::
readFromMic
(
void
)
...
...
This diff is collapsed.
Click to expand it.
src/audio/pulselayer.h
+
2
−
2
View file @
30415c38
...
...
@@ -103,7 +103,7 @@ class PulseLayer : public AudioLayer {
*/
int
playSamples
(
void
*
buffer
,
int
toCopy
,
bool
isTalking
)
;
static
void
audioCallback
(
pa_stream
*
s
,
size_t
bytes
,
void
*
userdata
);
//
static void audioCallback ( pa_stream* s, size_t bytes, void* userdata );
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
);
...
...
@@ -172,6 +172,7 @@ class PulseLayer : public AudioLayer {
int
getMicVolume
(
void
)
{
return
micVolume
;
}
void
setMicVolume
(
int
value
)
{
micVolume
=
value
;
}
void
processData
(
void
);
private
:
// Copy Constructor
PulseLayer
(
const
PulseLayer
&
rh
);
...
...
@@ -188,7 +189,6 @@ class PulseLayer : public AudioLayer {
/**
* Write data from the ring buffer to the harware and read data from the hardware
*/
void
processData
(
void
);
void
readFromMic
(
void
);
void
writeToSpeaker
(
void
);
...
...
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