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
073bfc05
Commit
073bfc05
authored
Aug 29, 2011
by
Rafaël Carré
Browse files
* #6629 : remove unused and unconfigurable frameSize from audiolayer
parent
3ddc5dbd
Changes
12
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/alsa/alsalayer.cpp
View file @
073bfc05
...
...
@@ -133,7 +133,7 @@ AlsaLayer::closeLayer()
}
void
AlsaLayer
::
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
frameSize
,
int
stream
,
const
std
::
string
&
plugin
)
AlsaLayer
::
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
stream
,
const
std
::
string
&
plugin
)
{
/* Close the devices before open it */
if
(
stream
==
SFL_PCM_BOTH
and
is_capture_open_
and
is_playback_open_
)
{
...
...
@@ -149,13 +149,11 @@ AlsaLayer::openDevice (int indexIn, int indexOut, int indexRing, int sampleRate,
indexRing_
=
indexRing
;
audioSampleRate_
=
sampleRate
;
frameSize_
=
frameSize
;
audioPlugin_
=
plugin
;
_debug
(
" Setting AlsaLayer: device in=%2d, out=%2d, ring=%2d"
,
indexIn_
,
indexOut_
,
indexRing_
);
_debug
(
" : alsa plugin=%s"
,
audioPlugin_
.
c_str
());
_debug
(
" : nb channel in=%2d, out=%2d"
,
inChannel_
,
outChannel_
);
_debug
(
" : sample rate=%5d, format=%s"
,
audioSampleRate_
,
SFLDataFormatString
);
audioThread_
=
NULL
;
...
...
daemon/src/audio/alsa/alsalayer.h
View file @
073bfc05
...
...
@@ -64,14 +64,13 @@ class AlsaLayer : public AudioLayer
* @param indexIn The number of the card chosen for capture
* @param indexOut The number of the card chosen for playback
* @param sampleRate The sample rate
* @param frameSize The frame size
* @param stream To indicate which kind of stream you want to open
* SFL_PCM_CAPTURE
* SFL_PCM_PLAYBACK
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
frameSize
,
int
stream
,
const
std
::
string
&
plugin
);
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
stream
,
const
std
::
string
&
plugin
);
/**
* Start the capture stream and prepare the playback stream.
...
...
daemon/src/audio/audiolayer.cpp
View file @
073bfc05
...
...
@@ -42,9 +42,6 @@ AudioLayer::AudioLayer (int type)
,
indexOut_
(
0
)
,
indexRing_
(
0
)
,
audioSampleRate_
(
0
)
,
frameSize_
(
0
)
,
inChannel_
(
1
)
,
outChannel_
(
1
)
,
mutex_
()
,
audioPref
(
Manager
::
instance
().
audioPreference
)
,
layerType_
(
type
)
...
...
daemon/src/audio/audiolayer.h
View file @
073bfc05
...
...
@@ -78,14 +78,13 @@ class AudioLayer
* @param indexIn The number of the card chosen for capture
* @param indexOut The number of the card chosen for playback
* @param sampleRate The sample rate
* @param frameSize The frame size
* @param stream To indicate which kind of stream you want to open
* SFL_PCM_CAPTURE
* SFL_PCM_PLAYBACK
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
virtual
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
frameSize
,
int
stream
,
const
std
::
string
&
plugin
)
=
0
;
virtual
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
stream
,
const
std
::
string
&
plugin
)
=
0
;
/**
* Start the capture stream and prepare the playback stream.
...
...
@@ -151,15 +150,6 @@ class AudioLayer
return
audioSampleRate_
;
}
/**
* Get the frame size of the audio layer
* @return unsigned int The frame size
* default: 20 ms
*/
unsigned
int
getFrameSize
()
const
{
return
frameSize_
;
}
/**
* Get the layer type for this instance (either Alsa or PulseAudio)
* @return unsigned int The layer type
...
...
@@ -252,22 +242,6 @@ class AudioLayer
*/
unsigned
int
audioSampleRate_
;
/**
* Length of the sound frame we capture or read in ms
* The value can be set in the user config file - now: 20ms
*/
unsigned
int
frameSize_
;
/**
* Input channel (mic) should be 1 mono
*/
unsigned
int
inChannel_
;
/**
* Output channel (stereo) should be 1 mono
*/
unsigned
int
outChannel_
;
/**
* Lock for the entire audio layer
*/
...
...
daemon/src/audio/pulseaudio/pulselayer.cpp
View file @
073bfc05
...
...
@@ -370,12 +370,9 @@ void PulseLayer::context_state_callback (pa_context* c, void* user_data)
}
}
void
PulseLayer
::
openDevice
(
int
indexIn
UNUSED
,
int
indexOut
UNUSED
,
int
indexRing
UNUSED
,
int
sampleRate
,
int
frameSize
,
int
stream
UNUSED
,
const
std
::
string
&
plugin
UNUSED
)
void
PulseLayer
::
openDevice
(
int
indexIn
UNUSED
,
int
indexOut
UNUSED
,
int
indexRing
UNUSED
,
int
sampleRate
,
int
stream
UNUSED
,
const
std
::
string
&
plugin
UNUSED
)
{
_debug
(
"Audio: Open device sampling rate %d, frame size %d"
,
audioSampleRate_
,
frameSize_
);
audioSampleRate_
=
sampleRate
;
frameSize_
=
frameSize
;
flushUrgent
();
...
...
daemon/src/audio/pulseaudio/pulselayer.h
View file @
073bfc05
...
...
@@ -62,14 +62,13 @@ class PulseLayer : public AudioLayer
* @param indexIn The number of the card chosen for capture
* @param indexOut The number of the card chosen for playback
* @param sampleRate The sample rate
* @param frameSize The frame size
* @param stream To indicate which kind of stream you want to open
* SFL_PCM_CAPTURE
* SFL_PCM_PLAYBACK
* SFL_PCM_BOTH
* @param plugin The alsa plugin ( dmix , default , front , surround , ...)
*/
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
frameSize
,
int
stream
,
const
std
::
string
&
plugin
)
;
void
openDevice
(
int
indexIn
,
int
indexOut
,
int
indexRing
,
int
sampleRate
,
int
stream
,
const
std
::
string
&
plugin
)
;
DeviceList
*
getSinkList
(
void
)
{
return
&
sinkList_
;
...
...
daemon/src/iax/iaxvoiplink.cpp
View file @
073bfc05
...
...
@@ -713,7 +713,7 @@ IAXVoIPLink::iaxHandleVoiceEvent (iax_event* event, IAXCall* call)
unsigned
int
size
=
event
->
datalen
;
// Decode data with relevant codec
unsigned
int
max
=
audioCodec
->
getClockRate
()
*
audiolayer_
->
getFrameSize
()
/
1000
;
unsigned
int
max
=
audioCodec
->
getClockRate
()
*
20
/
1000
;
if
(
size
>
max
)
{
_debug
(
"The size %d is bigger than expected %d. Packet cropped. Ouch!"
,
size
,
max
);
...
...
daemon/src/managerimpl.cpp
View file @
073bfc05
...
...
@@ -2056,7 +2056,7 @@ void ManagerImpl::setAudioPlugin (const std::string& audioPlugin)
if
(
_audiodriver
->
getLayerType
()
==
ALSA
)
{
_audiodriver
->
openDevice
(
_audiodriver
->
getIndexIn
(),
_audiodriver
->
getIndexOut
(),
_audiodriver
->
getIndexRing
(),
_audiodriver
->
getSampleRate
(),
_audiodriver
->
getFrameSize
(),
SFL_PCM_BOTH
,
audioPlugin
);
SFL_PCM_BOTH
,
audioPlugin
);
}
audioLayerMutexUnlock
();
}
...
...
@@ -2089,22 +2089,19 @@ void ManagerImpl::setAudioDevice (const int index, int streamType)
case
SFL_PCM_PLAYBACK
:
_debug
(
"Manager: Set output device"
);
_audiodriver
->
openDevice
(
_audiodriver
->
getIndexIn
(),
index
,
_audiodriver
->
getIndexRing
(),
_audiodriver
->
getSampleRate
(),
_audiodriver
->
getFrameSize
(),
SFL_PCM_PLAYBACK
,
alsaplugin
);
_audiodriver
->
getSampleRate
(),
SFL_PCM_PLAYBACK
,
alsaplugin
);
audioPreference
.
setCardout
(
index
);
break
;
case
SFL_PCM_CAPTURE
:
_debug
(
"Manager: Set input device"
);
_audiodriver
->
openDevice
(
index
,
_audiodriver
->
getIndexOut
(),
_audiodriver
->
getIndexRing
(),
_audiodriver
->
getSampleRate
(),
_audiodriver
->
getFrameSize
(),
SFL_PCM_CAPTURE
,
alsaplugin
);
_audiodriver
->
getSampleRate
(),
SFL_PCM_CAPTURE
,
alsaplugin
);
audioPreference
.
setCardin
(
index
);
break
;
case
SFL_PCM_RINGTONE
:
_debug
(
"Manager: Set ringtone device"
);
_audiodriver
->
openDevice
(
_audiodriver
->
getIndexOut
(),
_audiodriver
->
getIndexOut
(),
index
,
_audiodriver
->
getSampleRate
(),
_audiodriver
->
getFrameSize
(),
SFL_PCM_RINGTONE
,
alsaplugin
);
_audiodriver
->
getSampleRate
(),
SFL_PCM_RINGTONE
,
alsaplugin
);
audioPreference
.
setCardring
(
index
);
break
;
default:
...
...
@@ -2491,7 +2488,6 @@ void ManagerImpl::selectAudioDriver (void)
int
numCardRing
=
audioPreference
.
getCardring
();
int
sampleRate
=
getMainBuffer
()
->
getInternalSamplingRate
();
int
frameSize
=
audioPreference
.
getFramesize
();
/* Only for the ALSA layer, we check the sound card information */
...
...
@@ -2518,8 +2514,7 @@ void ManagerImpl::selectAudioDriver (void)
}
/* Open the audio devices */
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
sampleRate
,
frameSize
,
SFL_PCM_BOTH
,
alsaPlugin
);
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
sampleRate
,
SFL_PCM_BOTH
,
alsaPlugin
);
audioLayerMutexUnlock
();
}
...
...
@@ -2540,9 +2535,6 @@ void ManagerImpl::switchAudioManager (void)
int
type
=
_audiodriver
->
getLayerType
();
int
samplerate
=
_mainBuffer
.
getInternalSamplingRate
();
int
framesize
=
audioPreference
.
getFramesize
();
_debug
(
"Manager: samplerate: %d, framesize %d"
,
samplerate
,
framesize
);
std
::
string
alsaPlugin
(
audioPreference
.
getPlugin
());
...
...
@@ -2558,8 +2550,7 @@ void ManagerImpl::switchAudioManager (void)
else
_audiodriver
=
new
AlsaLayer
();
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
framesize
,
SFL_PCM_BOTH
,
alsaPlugin
);
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
SFL_PCM_BOTH
,
alsaPlugin
);
_debug
(
"Manager: Current device: %d "
,
type
);
...
...
@@ -2591,9 +2582,8 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
_debug
(
"Manager: Audio sampling rate changed"
);
int
type
=
_audiodriver
->
getLayerType
();
int
framesize
=
audioPreference
.
getFramesize
();
_debug
(
"Manager: New samplerate:
%d, New framesize
%d"
,
samplerate
,
framesize
);
_debug
(
"Manager: New samplerate: %d"
,
samplerate
);
std
::
string
alsaPlugin
(
audioPreference
.
getPlugin
());
...
...
@@ -2611,8 +2601,7 @@ void ManagerImpl::audioSamplingRateChanged (int samplerate)
else
_audiodriver
=
new
PulseLayer
;
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
framesize
,
SFL_PCM_BOTH
,
alsaPlugin
);
_audiodriver
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
samplerate
,
SFL_PCM_BOTH
,
alsaPlugin
);
_debug
(
"Manager: Current device: %d "
,
type
);
...
...
daemon/src/preferences.cpp
View file @
073bfc05
...
...
@@ -39,7 +39,6 @@ namespace {
static
const
char
*
const
DFT_PULSE_LENGTH_STR
=
"250"
;
/** Default DTMF lenght */
static
const
char
*
const
ZRTP_ZIDFILE
=
"zidFile"
;
/** The filename used for storing ZIDs */
static
const
char
*
const
ALSA_DFT_CARD
=
"0"
;
/** Default sound card index */
static
const
char
*
const
DFT_FRAME_SIZE
=
"20"
;
/** Default frame size in millisecond */
static
const
char
*
const
DFT_VOL_SPKR_STR
=
"100"
;
/** Default speaker volume */
static
const
char
*
const
DFT_VOL_MICRO_STR
=
"100"
;
/** Default mic volume */
}
// end anonymous namespace
...
...
@@ -282,7 +281,6 @@ void HookPreference::unserialize (Conf::MappingNode *map)
AudioPreference
::
AudioPreference
()
:
_cardin
(
atoi
(
ALSA_DFT_CARD
))
// ALSA_DFT_CARD
,
_cardout
(
atoi
(
ALSA_DFT_CARD
))
// ALSA_DFT_CARD
,
_cardring
(
atoi
(
ALSA_DFT_CARD
))
// ALSA_DFT_CARD
,
_framesize
(
atoi
(
DFT_FRAME_SIZE
))
// DFT_FRAME_SIZE
,
_plugin
(
"default"
)
// PCM_DEFAULT
,
_smplrate
(
44100
)
// DFT_SAMPLE_RATE
,
_devicePlayback
(
""
)
...
...
@@ -318,9 +316,6 @@ void AudioPreference::serialize (Conf::YamlEmitter *emitter)
std
::
stringstream
ringstr
;
ringstr
<<
_cardring
;
Conf
::
ScalarNode
cardring
(
ringstr
.
str
());
// 0
std
::
stringstream
framestr
;
framestr
<<
_framesize
;
Conf
::
ScalarNode
framesize
(
framestr
.
str
());
// 20
Conf
::
ScalarNode
plugin
(
_plugin
);
// default
std
::
stringstream
ratestr
;
...
...
@@ -361,7 +356,6 @@ void AudioPreference::serialize (Conf::YamlEmitter *emitter)
alsapreferencemap
.
setKeyValue
(
cardinKey
,
&
cardin
);
alsapreferencemap
.
setKeyValue
(
cardoutKey
,
&
cardout
);
alsapreferencemap
.
setKeyValue
(
cardringKey
,
&
cardring
);
alsapreferencemap
.
setKeyValue
(
framesizeKey
,
&
framesize
);
alsapreferencemap
.
setKeyValue
(
pluginKey
,
&
plugin
);
alsapreferencemap
.
setKeyValue
(
smplrateKey
,
&
smplrate
);
...
...
@@ -395,7 +389,6 @@ void AudioPreference::unserialize (Conf::MappingNode *map)
alsamap
->
getValue
(
cardinKey
,
&
_cardin
);
alsamap
->
getValue
(
cardoutKey
,
&
_cardout
);
alsamap
->
getValue
(
cardringKey
,
&
_cardring
);
alsamap
->
getValue
(
framesizeKey
,
&
_framesize
);
alsamap
->
getValue
(
smplrateKey
,
&
_smplrate
);
alsamap
->
getValue
(
pluginKey
,
&
_plugin
);
}
...
...
daemon/src/preferences.h
View file @
073bfc05
...
...
@@ -76,7 +76,6 @@ const std::string pulsemapKey ("pulse");
const
std
::
string
cardinKey
(
"cardIn"
);
// : 0
const
std
::
string
cardoutKey
(
"cardOut"
);
// 0
const
std
::
string
cardringKey
(
"cardRing"
);
// : 0
const
std
::
string
framesizeKey
(
"frameSize"
);
// : 20
const
std
::
string
pluginKey
(
"plugin"
);
//: default
const
std
::
string
smplrateKey
(
"smplRate"
);
//: 44100
const
std
::
string
devicePlaybackKey
(
"devicePlayback"
);
//:
...
...
@@ -444,13 +443,6 @@ class AudioPreference : public Serializable
_cardring
=
c
;
}
int
getFramesize
(
void
)
const
{
return
_framesize
;
}
void
setFramesize
(
int
f
)
{
_framesize
=
f
;
}
std
::
string
getPlugin
(
void
)
const
{
return
_plugin
;
}
...
...
@@ -555,7 +547,6 @@ class AudioPreference : public Serializable
int
_cardin
;
// 0
int
_cardout
;
// 0
int
_cardring
;
// 0
int
_framesize
;
// 20
std
::
string
_plugin
;
// default
int
_smplrate
;
// 44100
...
...
daemon/test/audiolayertest.cpp
View file @
073bfc05
...
...
@@ -44,7 +44,6 @@ void AudioLayerTest::testAudioLayerConfig()
_debug
(
"-------------------- AudioLayerTest::testAudioLayerConfig --------------------
\n
"
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getSmplrate
()
==
44100
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getFramesize
()
==
20
);
// alsa preferences
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getCardin
()
==
0
);
...
...
@@ -62,8 +61,6 @@ void AudioLayerTest::testAudioLayerConfig()
// TODO: Fix tests
//CPPUNIT_ASSERT ( (int) Manager::instance().getAudioDriver()->getSampleRate() == sampling_rate);
//CPPPUNIT_ASSERT ( (int) Manager::instance().getAudioDriver()->getFrameSize() == frame_size);
}
void
AudioLayerTest
::
testAudioLayerSwitch
()
...
...
@@ -104,21 +101,15 @@ void AudioLayerTest::testPulseConnect()
CPPUNIT_ASSERT
(
_pulselayer
->
getLayerType
()
==
PULSEAUDIO
);
std
::
string
alsaPlugin
;
int
numCardIn
,
numCardOut
,
numCardRing
,
sampleRate
,
frameSize
;
int
sampleRate
;
alsaPlugin
=
manager
->
audioPreference
.
getPlugin
();
numCardIn
=
manager
->
audioPreference
.
getCardin
();
numCardOut
=
manager
->
audioPreference
.
getCardout
();
numCardRing
=
manager
->
audioPreference
.
getCardring
();
sampleRate
=
manager
->
audioPreference
.
getSmplrate
();
frameSize
=
manager
->
audioPreference
.
getFramesize
();
CPPUNIT_ASSERT
(
_pulselayer
->
getPlaybackStream
()
==
NULL
);
CPPUNIT_ASSERT
(
_pulselayer
->
getRecordStream
()
==
NULL
);
try
{
_pulselayer
->
openDevice
(
numCardIn
,
numCardOut
,
numCardRing
,
sampleRate
,
frameSize
,
SFL_PCM_BOTH
,
alsaPlugin
);
_pulselayer
->
openDevice
(
sampleRate
);
}
catch
(...)
{
_debug
(
"Exception occured wile opening device! "
);
}
...
...
daemon/test/configurationtest.cpp
View file @
073bfc05
...
...
@@ -44,7 +44,6 @@ void ConfigurationTest::testDefaultValueAudio()
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getCardin
()
==
0
);
// ALSA_DFT_CARD);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getCardout
()
==
0
);
// ALSA_DFT_CARD);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getSmplrate
()
==
44100
);
// DFT_SAMPLE_RATE);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getFramesize
()
==
20
);
// DFT_FRAME_SIZE);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getPlugin
()
==
PCM_DEFAULT
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getVolumespkr
()
==
100
);
CPPUNIT_ASSERT
(
Manager
::
instance
().
audioPreference
.
getVolumemic
()
==
100
);
...
...
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