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
c42b7219
Commit
c42b7219
authored
Oct 12, 2011
by
Tristan Matthews
Browse files
* #7131: cleanup in audiolayer
parent
35dae9e9
Changes
8
Show whitespace changes
Inline
Side-by-side
daemon/src/audio/alsa/alsalayer.cpp
View file @
c42b7219
...
...
@@ -44,7 +44,7 @@ class AlsaThread : public ost::Thread {
terminate
();
}
virtual
void
run
(
void
);
virtual
void
run
();
private:
AlsaThread
(
const
AlsaThread
&
at
);
...
...
@@ -62,7 +62,7 @@ AlsaThread::AlsaThread(AlsaLayer *alsa)
/**
* Reimplementation of run()
*/
void
AlsaThread
::
run
(
void
)
void
AlsaThread
::
run
()
{
while
(
!
testCancel
())
{
alsa_
->
audioCallback
();
...
...
@@ -91,7 +91,7 @@ AlsaLayer::AlsaLayer()
}
// Destructor
AlsaLayer
::~
AlsaLayer
(
void
)
AlsaLayer
::~
AlsaLayer
()
{
delete
audioThread_
;
...
...
@@ -127,7 +127,7 @@ bool AlsaLayer::openDevice(snd_pcm_t **pcm, const std::string &dev, snd_pcm_stre
}
void
AlsaLayer
::
startStream
(
void
)
AlsaLayer
::
startStream
()
{
dcblocker_
.
reset
();
...
...
@@ -184,7 +184,7 @@ AlsaLayer::startStream(void)
}
void
AlsaLayer
::
stopStream
(
void
)
AlsaLayer
::
stopStream
()
{
isStarted_
=
false
;
...
...
@@ -222,7 +222,7 @@ AlsaLayer::stopStream(void)
err_code; \
})
void
AlsaLayer
::
stopCaptureStream
(
void
)
void
AlsaLayer
::
stopCaptureStream
()
{
if
(
captureHandle_
&&
ALSA_CALL
(
snd_pcm_drop
(
captureHandle_
),
"couldn't stop capture"
)
>=
0
)
{
is_capture_running_
=
false
;
...
...
@@ -230,7 +230,7 @@ void AlsaLayer::stopCaptureStream(void)
}
}
void
AlsaLayer
::
closeCaptureStream
(
void
)
void
AlsaLayer
::
closeCaptureStream
()
{
if
(
is_capture_prepared_
and
is_capture_running_
)
stopCaptureStream
();
...
...
@@ -239,14 +239,14 @@ void AlsaLayer::closeCaptureStream(void)
is_capture_open_
=
false
;
}
void
AlsaLayer
::
startCaptureStream
(
void
)
void
AlsaLayer
::
startCaptureStream
()
{
if
(
captureHandle_
and
not
is_capture_running_
)
if
(
ALSA_CALL
(
snd_pcm_start
(
captureHandle_
),
"Couldn't start capture"
)
>=
0
)
is_capture_running_
=
true
;
}
void
AlsaLayer
::
stopPlaybackStream
(
void
)
void
AlsaLayer
::
stopPlaybackStream
()
{
if
(
ringtoneHandle_
and
is_playback_running_
)
ALSA_CALL
(
snd_pcm_drop
(
ringtoneHandle_
),
"Couldn't stop ringtone"
);
...
...
@@ -260,7 +260,7 @@ void AlsaLayer::stopPlaybackStream(void)
}
void
AlsaLayer
::
closePlaybackStream
(
void
)
void
AlsaLayer
::
closePlaybackStream
()
{
if
(
is_playback_prepared_
and
is_playback_running_
)
stopPlaybackStream
();
...
...
@@ -275,21 +275,21 @@ void AlsaLayer::closePlaybackStream(void)
}
void
AlsaLayer
::
startPlaybackStream
(
void
)
void
AlsaLayer
::
startPlaybackStream
()
{
if
(
playbackHandle_
and
not
is_playback_running_
)
if
(
ALSA_CALL
(
snd_pcm_start
(
playbackHandle_
),
"Couldn't start playback"
)
>=
0
)
is_playback_running_
=
true
;
}
void
AlsaLayer
::
prepareCaptureStream
(
void
)
void
AlsaLayer
::
prepareCaptureStream
()
{
if
(
is_capture_open_
and
not
is_capture_prepared_
)
if
(
ALSA_CALL
(
snd_pcm_prepare
(
captureHandle_
),
"Couldn't prepare capture"
)
>=
0
)
is_capture_prepared_
=
true
;
}
void
AlsaLayer
::
preparePlaybackStream
(
void
)
void
AlsaLayer
::
preparePlaybackStream
()
{
if
(
is_playback_open_
and
not
is_playback_prepared_
)
if
(
ALSA_CALL
(
snd_pcm_prepare
(
playbackHandle_
),
"Couldn't prepare playback"
)
>=
0
)
...
...
@@ -523,7 +523,7 @@ void adjustVolume(SFLDataFormat *src , int samples, int volumePercentage)
}
}
void
AlsaLayer
::
capture
(
void
)
void
AlsaLayer
::
capture
()
{
unsigned
int
mainBufferSampleRate
=
Manager
::
instance
().
getMainBuffer
()
->
getInternalSamplingRate
();
bool
resample
=
audioSampleRate_
!=
mainBufferSampleRate
;
...
...
@@ -628,7 +628,7 @@ void AlsaLayer::playback(int maxSamples)
free
(
out
);
}
void
AlsaLayer
::
audioCallback
(
void
)
void
AlsaLayer
::
audioCallback
()
{
if
(
!
playbackHandle_
or
!
captureHandle_
)
return
;
...
...
daemon/src/audio/audiolayer.cpp
View file @
c42b7219
...
...
@@ -52,14 +52,14 @@ AudioLayer::~AudioLayer()
delete
converter_
;
}
void
AudioLayer
::
flushMain
(
void
)
void
AudioLayer
::
flushMain
()
{
ost
::
MutexLock
guard
(
mutex_
);
// should pass call id
Manager
::
instance
().
getMainBuffer
()
->
flushAllBuffers
();
}
void
AudioLayer
::
flushUrgent
(
void
)
void
AudioLayer
::
flushUrgent
()
{
ost
::
MutexLock
guard
(
mutex_
);
urgentRingBuffer_
.
flushAll
();
...
...
daemon/src/audio/audiorecorder.cpp
View file @
c42b7219
...
...
@@ -30,56 +30,45 @@
#include "audiorecorder.h"
#include "mainbuffer.h"
#include <assert
.h
>
#include <
c
assert>
int
AudioRecorder
::
count
=
0
;
int
AudioRecorder
::
count
_
=
0
;
AudioRecorder
::
AudioRecorder
(
AudioRecord
*
arec
,
MainBuffer
*
mb
)
:
Thread
()
AudioRecorder
::
AudioRecorder
(
AudioRecord
*
arec
,
MainBuffer
*
mb
)
:
Thread
()
,
mbuffer_
(
mb
),
arecord_
(
arec
)
{
assert
(
mb
);
setCancel
(
cancelDeferred
);
++
count
;
++
count
_
;
std
::
string
id
(
"processid_"
);
// convert count into string
std
::
string
s
;
std
::
stringstream
out
;
out
<<
count
;
out
<<
count
_
;
s
=
out
.
str
();
recorderId
=
id
.
append
(
s
);
arecord
=
arec
;
mbuffer
=
mb
;
recorderId_
=
id
.
append
(
s
);
}
/**
* Reimplementation of run()
*/
void
AudioRecorder
::
run
()
{
int
bufferLength
=
10000
;
SFLDataFormat
buffer
[
bufferLength
];
while
(
true
)
{
int
availBytes
=
mbuffer
->
availForGet
(
recorderId
);
int
availBytes
=
mbuffer_
->
availForGet
(
recorderId_
);
int
toGet
=
(
availBytes
<
bufferLength
)
?
availBytes
:
bufferLength
;
mbuffer
->
getData
(
buffer
,
toGet
,
recorderId
);
mbuffer
_
->
getData
(
buffer
,
toGet
,
recorderId
_
);
if
(
availBytes
>
0
)
{
arecord
->
recData
(
buffer
,
availBytes
/
sizeof
(
SFLDataFormat
));
}
if
(
availBytes
>
0
)
arecord_
->
recData
(
buffer
,
availBytes
/
sizeof
(
SFLDataFormat
));
sleep
(
20
);
}
}
daemon/src/audio/audiorecorder.h
View file @
c42b7219
...
...
@@ -42,14 +42,14 @@ class AudioRecorder : public ost::Thread {
public:
AudioRecorder
(
AudioRecord
*
arec
,
MainBuffer
*
mb
);
~
AudioRecorder
(
void
)
{
~
AudioRecorder
()
{
terminate
();
}
static
int
count
;
static
int
count
_
;
std
::
string
getRecorderID
()
{
return
recorderId
;
std
::
string
getRecorderID
()
const
{
return
recorderId
_
;
}
virtual
void
run
();
...
...
@@ -58,11 +58,11 @@ class AudioRecorder : public ost::Thread {
AudioRecorder
(
const
AudioRecorder
&
ar
);
AudioRecorder
&
operator
=
(
const
AudioRecorder
&
ar
);
std
::
string
recorderId
;
std
::
string
recorderId
_
;
MainBuffer
*
mbuffer
;
MainBuffer
*
mbuffer
_
;
AudioRecord
*
arecord
;
AudioRecord
*
arecord
_
;
};
#endif
daemon/src/audio/codecs/g722.cpp
View file @
c42b7219
...
...
@@ -83,7 +83,7 @@ class G722 : public sfl::AudioCodec {
}
void
g722_encode_init
(
void
)
{
void
g722_encode_init
()
{
encode_s
->
itu_test_mode
=
FALSE
;
// 8 => 64 kbps; 7 => 56 kbps; 6 => 48 kbps
...
...
@@ -108,7 +108,7 @@ class G722 : public sfl::AudioCodec {
decode_s
->
out_bits
=
0
;
}
void
g722_decode_init
(
void
)
{
void
g722_decode_init
()
{
decode_s
->
itu_test_mode
=
FALSE
;
...
...
daemon/src/audio/codecs/gsmcodec.cpp
View file @
c42b7219
...
...
@@ -64,7 +64,7 @@ class Gsm : public sfl::AudioCodec {
Gsm
&
operator
=
(
const
Gsm
&
);
virtual
~
Gsm
(
void
)
{
virtual
~
Gsm
()
{
gsm_destroy
(
decode_gsmhandle_
);
gsm_destroy
(
encode_gsmhandle_
);
}
...
...
daemon/src/audio/noisesuppress.cpp
View file @
c42b7219
...
...
@@ -32,37 +32,37 @@
#include "noisesuppress.h"
NoiseSuppress
::
NoiseSuppress
(
int
smplPerFrame
,
int
samplingRate
)
:
_
smplPerFrame
(
smplPerFrame
)
:
smplPerFrame
_
(
smplPerFrame
)
{
_
noiseState
=
speex_preprocess_state_init
(
_
smplPerFrame
,
samplingRate
);
noiseState
_
=
speex_preprocess_state_init
(
smplPerFrame
_
,
samplingRate
);
int
i
=
1
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_DENOISE
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_DENOISE
,
&
i
);
i
=-
20
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_NOISE_SUPPRESS
,
&
i
);
i
=
0
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_AGC
,
&
i
);
i
=
8000
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_AGC_TARGET
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_AGC_TARGET
,
&
i
);
i
=
16000
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_AGC_LEVEL
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_AGC_LEVEL
,
&
i
);
i
=
0
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_DEREVERB
,
&
i
);
float
f
=
0.0
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB_DECAY
,
&
f
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_DEREVERB_DECAY
,
&
f
);
f
=
0.0
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_DEREVERB_LEVEL
,
&
f
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_DEREVERB_LEVEL
,
&
f
);
i
=
0
;
speex_preprocess_ctl
(
_
noiseState
,
SPEEX_PREPROCESS_SET_VAD
,
&
i
);
speex_preprocess_ctl
(
noiseState
_
,
SPEEX_PREPROCESS_SET_VAD
,
&
i
);
}
NoiseSuppress
::~
NoiseSuppress
()
{
speex_preprocess_state_destroy
(
_
noiseState
);
speex_preprocess_state_destroy
(
noiseState
_
);
}
void
NoiseSuppress
::
process
(
SFLDataFormat
*
data
,
int
samples
)
{
assert
(
_
smplPerFrame
==
samples
);
speex_preprocess_run
(
_
noiseState
,
data
);
assert
(
smplPerFrame
_
==
samples
);
speex_preprocess_run
(
noiseState
_
,
data
);
}
daemon/src/audio/noisesuppress.h
View file @
c42b7219
...
...
@@ -36,18 +36,14 @@
class
NoiseSuppress
{
public:
NoiseSuppress
(
int
smplPerFrame
,
int
samplingRate
);
~
NoiseSuppress
(
void
);
~
NoiseSuppress
();
void
process
(
SFLDataFormat
*
data
,
int
samples
);
private:
SpeexPreprocessState
*
_noiseState
;
int
_smplPerFrame
;
SpeexPreprocessState
*
noiseState_
;
int
smplPerFrame_
;
};
#endif
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