Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
savoirfairelinux
jami-daemon
Commits
6094c0d6
Commit
6094c0d6
authored
Apr 05, 2005
by
llea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ALSA
parent
2cfb4ef4
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
55 additions
and
161 deletions
+55
-161
CHANGES
CHANGES
+2
-2
src/Makefile
src/Makefile
+2
-2
src/audiobuffer.cpp
src/audiobuffer.cpp
+1
-0
src/audiocodec.cpp
src/audiocodec.cpp
+0
-63
src/audiocodec.h
src/audiocodec.h
+0
-1
src/audiodriversalsa.cpp
src/audiodriversalsa.cpp
+35
-74
src/audiodriversalsa.h
src/audiodriversalsa.h
+1
-5
src/audiortp.cpp
src/audiortp.cpp
+2
-6
src/configurationpanelui.cpp
src/configurationpanelui.cpp
+1
-1
src/configurationpanelui.h
src/configurationpanelui.h
+1
-1
src/manager.cpp
src/manager.cpp
+1
-0
src/phonebookui.cpp
src/phonebookui.cpp
+1
-1
src/phonebookui.h
src/phonebookui.h
+1
-1
src/qtGUImainwindow.cpp
src/qtGUImainwindow.cpp
+2
-0
src/sip.cpp
src/sip.cpp
+1
-2
src/tonegenerator.cpp
src/tonegenerator.cpp
+2
-0
src/url_inputui.cpp
src/url_inputui.cpp
+1
-1
src/url_inputui.h
src/url_inputui.h
+1
-1
No files found.
CHANGES
View file @
6094c0d6
SFLphone (0.3) / 2005-0
2-10
* ALSA driver support added
(not yet operationnal)
SFLphone (0.3) / 2005-0
4-05
* ALSA driver support added
* GSM audio codec support added
* Rings support (just ulaw format) added
* Notification incoming call added
...
...
src/Makefile
View file @
6094c0d6
...
...
@@ -66,8 +66,8 @@ OBJS = \
volumecontrol.o volumecontrol.moc.o
\
stun.o udp.o
start
:
check prereq all
#
start: check all
#
start: check prereq all
start
:
check all
check
:
ifeq
($(CONFIGURE_CONF),../configure.conf)
...
...
src/audiobuffer.cpp
View file @
6094c0d6
...
...
@@ -52,6 +52,7 @@ void AudioBuffer::resize (size_t newsize)
void
AudioBuffer
::
setData
(
short
*
buf
,
int
vol
)
{
short
*
databuf
=
(
short
*
)
data
;
for
(
int
i
=
0
;
i
<
(
int
)
size
;
i
++
)
{
databuf
[
i
]
=
buf
[
i
]
*
vol
/
100
;
}
...
...
src/audiocodec.cpp
View file @
6094c0d6
...
...
@@ -26,12 +26,6 @@
#include <string>
#define swab16(x) \
((unsigned short)( \
(((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \
(((unsigned short)(x) & (unsigned short)0xff00U) >> 8) ))
using
namespace
std
;
...
...
@@ -138,40 +132,7 @@ AudioCodec::codecEncode (int pt, unsigned char *dst, short *src, unsigned int si
break
;
case
PAYLOAD_CODEC_GSM
:
#if 0
{
gsm_frame gsmdata; // dst
int iii;
bzero (gsmdata, sizeof(gsm_frame));
printf ("Before gsm_encode: ");
for (iii = 0; iii < 33; iii++) {
unsigned char *ptr = gsmdata;
printf ("%02X ", ptr[iii]);
}
gsm_signal sample[160];
for (iii = 0; iii < 160; iii++) {
unsigned short dat;
dat = (unsigned short) src[iii];
//dat = (unsigned short) sample[iii];
//sample[iii] = (short) swab16(dat);
sample[iii] = src[iii];
}
gsm_encode(encode_gsmhandle, sample, gsmdata);
printf ("\nAfter gsm_encode: ");
for (iii = 0; iii < 33; iii++) {
unsigned char *ptr = gsmdata;
printf ("%02X ", ptr[iii]);
dst[iii] = ptr[iii];
}
printf ("\n------\n");
}
#endif
#if 1
gsm_encode
(
encode_gsmhandle
,
(
gsm_signal
*
)
src
,
(
gsm_byte
*
)
dst
);
#endif
return
33
;
break
;
...
...
@@ -208,28 +169,4 @@ AudioCodec::gsmDestroy (void) {
gsm_destroy
(
encode_gsmhandle
);
}
int
AudioCodec
::
getSizeByPayload
(
int
pt
){
switch
(
pt
)
{
case
PAYLOAD_CODEC_ULAW
:
case
PAYLOAD_CODEC_ALAW
:
return
320
;
break
;
case
PAYLOAD_CODEC_GSM
:
return
320
;
break
;
case
PAYLOAD_CODEC_ILBC
:
// TODO
break
;
case
PAYLOAD_CODEC_SPEEX
:
// TODO
break
;
default:
break
;
}
return
0
;
}
src/audiocodec.h
View file @
6094c0d6
...
...
@@ -56,7 +56,6 @@ public:
static
int
codecEncode
(
int
,
unsigned
char
*
,
short
*
,
unsigned
int
);
static
void
gsmCreate
(
void
);
static
void
gsmDestroy
(
void
);
static
int
getSizeByPayload
(
int
);
};
#endif // __CODEC_AUDIO_H__
src/audiodriversalsa.cpp
View file @
6094c0d6
...
...
@@ -43,9 +43,16 @@ AudioDriversALSA::AudioDriversALSA(DeviceMode mode) : AudioDrivers () {
AudioDriversALSA
::~
AudioDriversALSA
(
void
)
{
/* Close the audio handle */
if
(
audio_hdl
!=
NULL
)
snd_pcm_close
(
audio_hdl
);
this
->
closeDevice
(
);
}
void
AudioDriversALSA
::
closeDevice
(
void
)
{
if
(
audio_hdl
!=
NULL
)
{
snd_pcm_close
(
audio_hdl
);
audio_hdl
=
(
snd_pcm_t
*
)
NULL
;
}
}
int
AudioDriversALSA
::
initDevice
(
DeviceMode
mode
)
{
...
...
@@ -57,16 +64,17 @@ AudioDriversALSA::initDevice (DeviceMode mode) {
}
// Open the audio device
// Flags : blocking (else have to OR omode with SND_PCM_NONBLOCK).
switch
(
mode
)
{
case
ReadOnly
:
/* Only read sound from the device */
err
=
snd_pcm_open
(
&
audio_hdl
,
ALSA_DEVICE
,
SND_PCM_STREAM_CAPTURE
,
SND_PCM_NONBLOCK
);
err
=
snd_pcm_open
(
&
audio_hdl
,
ALSA_DEVICE
,
SND_PCM_STREAM_CAPTURE
,
SND_PCM_NONBLOCK
);
break
;
case
WriteOnly
:
/* Only write sound to the device */
err
=
snd_pcm_open
(
&
audio_hdl
,
ALSA_DEVICE
,
SND_PCM_STREAM_PLAYBACK
,
SND_PCM_NONBLOCK
);
err
=
snd_pcm_open
(
&
audio_hdl
,
ALSA_DEVICE
,
SND_PCM_STREAM_PLAYBACK
,
SND_PCM_NONBLOCK
);
break
;
default:
break
;
...
...
@@ -132,7 +140,7 @@ AudioDriversALSA::initDevice (DeviceMode mode) {
printf
(
"Cannot set channel count (%s)
\n
"
,
snd_strerror
(
err
));
return
-
1
;
}
// Apply previously setup parameters
err
=
snd_pcm_hw_params
(
audio_hdl
,
hw_params
);
if
(
err
<
0
)
{
...
...
@@ -142,6 +150,7 @@ AudioDriversALSA::initDevice (DeviceMode mode) {
// Free temp variable used for configuration.
snd_pcm_hw_params_free
(
hw_params
);
////////////////////////////////////////////////////////////////////////////
// END DEVICE SETUP
////////////////////////////////////////////////////////////////////////////
...
...
@@ -157,75 +166,24 @@ AudioDriversALSA::writeBuffer (void) {
printf
(
"ALSA: writeBuffer(): Device Not Open
\n
"
);
return
-
1
;
}
#if 1
int
rc
;
size_t
count
=
audio_buf
.
getSize
()
/
2
;
short
*
buf
=
(
short
*
)
audio_buf
.
getData
();
while
(
count
>
0
)
{
rc
=
snd_pcm_writei
(
audio_hdl
,
buf
,
count
);
snd_pcm_wait
(
audio_hdl
,
1
);
if
(
rc
==
-
EPIPE
)
{
snd_pcm_prepare
(
audio_hdl
);
}
else
if
(
rc
==
-
EAGAIN
)
{
continue
;
}
else
if
(
rc
<
0
)
{
printf
(
"ALSA: write(): %s
\n
"
,
strerror
(
errno
));
break
;
}
printf
(
"rc = %d
\n
"
,
rc
);
buf
+=
rc
;
count
-=
rc
;
}
return
rc
;
#endif
}
unsigned
int
AudioDriversALSA
::
readableBytes
(
void
)
{
audio_buf_info
info
;
#if 0
struct timeval timeout;
fd_set read_fds;
if (devstate != DeviceOpened) {
return 0;
}
timeout.tv_sec = 0;
timeout.tv_usec = 0;
FD_ZERO (&read_fds);
FD_SET (audio_fd, &read_fds);
if (select (audio_fd + 1, &read_fds, NULL, NULL, &timeout) == -1) {
return 0;
}
if (!FD_ISSET ( audio_fd, &read_fds)) {
return 0;
}
if (ioctl (audio_fd, SNDCTL_DSP_GETISPACE, &info) == -1) {
printf ("ERROR: readableBytes %s\n", strerror(errno));
return 0;
}
#endif
return
info
.
bytes
;
}
int
AudioDriversALSA
::
readBuffer
(
int
bytes
)
{
/* if (devstate != DeviceOpened) {
printf ("Device Not Open\n");
return false;
}
audio_buf.resize (bytes);
size_t count = bytes;
void *buf;
buf = audio_buf.getData ();
size_t rc = read (audio_fd, buf, count);
if (rc != count) {
printf ("warning: asked microphone for %d got %d\n", count, rc);
}*/
return
true
;
}
int
...
...
@@ -234,34 +192,37 @@ AudioDriversALSA::readBuffer (void *ptr, int bytes) {
printf
(
"ALSA: readBuffer(): Device Not Open
\n
"
);
return
-
1
;
}
#if 1
ssize_t
count
=
bytes
/
2
;
ssize_t
count
=
bytes
;
ssize_t
rc
;
do
{
rc
=
snd_pcm_readi
(
audio_hdl
,
(
short
*
)
ptr
,
count
);
}
while
(
rc
==
-
EAGAIN
);
if
(
rc
==
-
EBADFD
)
printf
(
"Read: PCM is not in the right state
\n
"
);
if
(
rc
==
-
ESTRPIPE
)
printf
(
"Read: a suspend event occurred
\n
"
);
if
(
rc
==
-
EPIPE
)
{
printf
(
"Read: -EPIPE %d
\n
"
,
rc
);
snd_pcm_prepare
(
audio_hdl
);
bzero
(
ptr
,
bytes
);
rc
=
320
;
}
if
(
rc
>
0
&&
rc
!=
count
)
{
printf
(
"Read: warning: asked microphone for %d frames but got %d
\n
"
,
count
,
rc
);
}
if
(
rc
!=
320
)
rc
=
rc
*
2
;
return
rc
;
#endif
}
int
AudioDriversALSA
::
resetDevice
(
void
)
{
/* printf ("ALSA: Resetting device.\n");
snd_pcm_drop(audio_hdl);
snd_pcm_drain(audio_hdl);*/
int
err
;
printf
(
"Resetting...
\n
"
);
if
((
err
=
snd_pcm_drop
(
audio_hdl
))
<
0
)
{
printf
(
"ALSA: drop() error: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
}
if
((
err
=
snd_pcm_prepare
(
audio_hdl
))
<
0
)
{
printf
(
"ALSA: prepare() error: %s
\n
"
,
snd_strerror
(
err
));
return
-
1
;
}
return
0
;
}
...
...
src/audiodriversalsa.h
View file @
6094c0d6
...
...
@@ -45,15 +45,11 @@ public:
int
initDevice
(
DeviceMode
);
int
resetDevice
(
void
);
int
writeBuffer
(
void
);
int
readBuffer
(
int
);
int
readBuffer
(
void
*
,
int
);
unsigned
int
readableBytes
(
void
);
int
audio_fd
;
private:
snd_pcm_t
*
audio_hdl
;
void
closeDevice
(
void
);
};
#endif // _AUDIO_DRIVERS_ALSA_H_
src/audiortp.cpp
View file @
6094c0d6
...
...
@@ -93,9 +93,7 @@ AudioRtp::closeRtpSession (SipCall *ca) {
ca
->
enable_audio
=
-
1
;
if
(
RTXThread
!=
NULL
)
{
// Wait for them...and delete.
//RTXThread->join();
qDebug
(
"DELETED"
);
qDebug
(
"RTXThread DELETED"
);
delete
RTXThread
;
RTXThread
=
NULL
;
}
...
...
@@ -262,7 +260,6 @@ AudioRtpRTX::run (void) {
////////////////////////////
// Send session
////////////////////////////
//int size = AudioCodec::getSizeByPayload(ca->payload);
int
size
=
320
;
if
(
!
manager
->
mute
)
{
#ifdef ALSA
...
...
@@ -283,9 +280,9 @@ AudioRtpRTX::run (void) {
if
(
!
manager
->
useAlsa
)
i
=
audioDevice
->
readBuffer
(
data_mute
,
size
);
}
//qDebug("read i = %d", i);
// TODO : return an error because no sound
if
(
i
<
0
)
{
qDebug
(
"audiortp.cpp: No sound"
);
break
;
}
for
(
int
j
=
0
;
j
<
i
;
j
++
)
...
...
@@ -303,7 +300,6 @@ AudioRtpRTX::run (void) {
}
else
{
session
->
putData
(
timestamp
,
data_to_send
,
compSize
);
}
//timestamp += compSize;
timestamp
+=
160
;
////////////////////////////
...
...
src/configurationpanelui.cpp
View file @
6094c0d6
/****************************************************************************
** Form implementation generated from reading ui file 'configurationpanel.ui'
**
** Created: Thu Mar 31 1
1:43:54
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
src/configurationpanelui.h
View file @
6094c0d6
/****************************************************************************
** Form interface generated from reading ui file 'configurationpanel.ui'
**
** Created: Thu Mar 31 1
1:43:54
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
src/manager.cpp
View file @
6094c0d6
...
...
@@ -199,6 +199,7 @@ Manager::ring (bool var) {
if
(
this
->
b_ringing
!=
var
)
{
this
->
b_ringing
=
var
;
}
tonezone
=
ringing
();
if
(
sip
->
getNumberPendingCalls
()
==
1
)
...
...
src/phonebookui.cpp
View file @
6094c0d6
/****************************************************************************
** Form implementation generated from reading ui file 'phonebook.ui'
**
** Created: Thu Mar 31 1
1:43:53
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
src/phonebookui.h
View file @
6094c0d6
/****************************************************************************
** Form interface generated from reading ui file 'phonebook.ui'
**
** Created: Thu Mar 31 1
1:43:53
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
src/qtGUImainwindow.cpp
View file @
6094c0d6
...
...
@@ -1132,8 +1132,10 @@ QtGUIMainWindow::pressedKeySlot (int id) {
callmanager
->
audiodriver
->
audio_buf
.
resize
(
SAMPLING_RATE
);
callmanager
->
audiodriver
->
audio_buf
.
setData
(
buf
,
callmanager
->
getSpkrVolume
());
pulselen
=
Config
::
get
(
"Signalisations"
,
"DTMF.pulseLength"
,
250
);
callmanager
->
audiodriver
->
audio_buf
.
resize
(
pulselen
*
(
OCTETS
/
1000
));
// callmanager->audiodriver->resetDevice();
a
=
callmanager
->
audiodriver
->
writeBuffer
();
if
(
a
==
1
)
{
pressedKeySlot
(
id
);
...
...
src/sip.cpp
View file @
6094c0d6
...
...
@@ -908,8 +908,7 @@ SIP::getEvent (void) {
// The remote peer closed the phone call(we received BYE).
case
EXOSIP_CALL_CLOSED
:
qDebug
(
"<- (%i %i) BYE from: %s"
,
event
->
cid
,
event
->
did
,
event
->
remote_uri
);
qDebug
(
"<- (%i %i) BYE"
,
event
->
cid
,
event
->
did
);
call
[
theline
]
->
usehold
=
false
;
theline
=
findLineNumber
(
event
);
...
...
src/tonegenerator.cpp
View file @
6094c0d6
...
...
@@ -241,6 +241,7 @@ ToneGenerator::toneHandle (int idr) {
}
if
(
!
manager
->
tonezone
)
{
manager
->
audiodriver
->
resetDevice
();
if
(
tonethread
!=
NULL
)
{
delete
tonethread
;
tonethread
=
NULL
;
...
...
@@ -292,6 +293,7 @@ ToneGenerator::playRing (const char *fileName) {
tonethread
->
start
();
}
if
(
!
manager
->
tonezone
)
{
manager
->
audiodriver
->
resetDevice
();
if
(
tonethread
!=
NULL
)
{
delete
tonethread
;
tonethread
=
NULL
;
...
...
src/url_inputui.cpp
View file @
6094c0d6
/****************************************************************************
** Form implementation generated from reading ui file 'url_input.ui'
**
** Created: Thu Mar 31 1
1:43:53
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
src/url_inputui.h
View file @
6094c0d6
/****************************************************************************
** Form interface generated from reading ui file 'url_input.ui'
**
** Created: Thu Mar 31 1
1:43:53
2005
** Created: Thu Mar 31 1
2:04:22
2005
** by: The User Interface Compiler ($Id$)
**
** WARNING! All changes made in this file will be lost!
...
...
Write
Preview
Markdown
is supported
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