Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
739ff9d3
提交
739ff9d3
authored
3月 20, 2011
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_portaudio: implement endpoint writes and multiplex read/writes in pablio streams
上级
fbce9061
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
27 行删除
+43
-27
mod_portaudio.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
+23
-7
pablio.c
src/mod/endpoints/mod_portaudio/pablio.c
+11
-11
pablio.h
src/mod/endpoints/mod_portaudio/pablio.h
+9
-9
没有找到文件。
src/mod/endpoints/mod_portaudio/mod_portaudio.c
浏览文件 @
739ff9d3
...
...
@@ -389,7 +389,7 @@ static switch_status_t channel_on_routing(switch_core_session_t *session)
if
(
globals
.
ring_stream
&&
(
!
switch_test_flag
(
globals
.
call_list
,
TFLAG_MASTER
)
||
(
!
globals
.
no_ring_during_call
&&
globals
.
main_stream
!=
globals
.
ring_stream
))
)
{
//if there is a ring stream and not an active call or if there is an active call and we are allowed to ring during it AND the ring stream is not the main stream
WriteAudioStream
(
globals
.
ring_stream
->
stream
,
abuf
,
(
long
)
olen
,
&
globals
.
ring_stream
->
write_timer
);
WriteAudioStream
(
globals
.
ring_stream
->
stream
,
abuf
,
(
long
)
olen
,
0
,
&
globals
.
ring_stream
->
write_timer
);
}
}
else
{
switch_yield
(
10000
);
...
...
@@ -814,7 +814,7 @@ static switch_status_t channel_endpoint_read(audio_endpoint_t *endpoint, switch_
samples
=
ReadAudioStream
(
endpoint
->
in_stream
->
stream
,
endpoint
->
read_frame
.
data
,
STREAM_SAMPLES_PER_PACKET
(
endpoint
->
in_stream
),
&
endpoint
->
read_timer
);
endpoint
->
inchan
,
&
endpoint
->
read_timer
);
if
(
!
samples
)
{
*
frame
=
&
globals
.
cng_frame
;
...
...
@@ -900,7 +900,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
}
switch_mutex_lock
(
globals
.
device_lock
);
samples
=
ReadAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
globals
.
read_codec
.
implementation
->
samples_per_packet
,
&
globals
.
read_timer
);
samples
=
ReadAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
globals
.
read_codec
.
implementation
->
samples_per_packet
,
0
,
&
globals
.
read_timer
);
switch_mutex_unlock
(
globals
.
device_lock
);
if
(
samples
)
{
...
...
@@ -931,12 +931,28 @@ normal_return:
}
static
switch_status_t
channel_endpoint_write
(
audio_endpoint_t
*
endpoint
,
switch_frame_t
*
frame
)
{
if
(
!
endpoint
->
out_stream
)
{
switch_core_timer_next
(
&
endpoint
->
write_timer
);
return
SWITCH_STATUS_SUCCESS
;
}
WriteAudioStream
(
endpoint
->
out_stream
->
stream
,
(
short
*
)
frame
->
data
,
(
int
)(
frame
->
datalen
/
sizeof
(
SAMPLE
)),
endpoint
->
outchan
,
&
(
endpoint
->
write_timer
));
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
channel_write_frame
(
switch_core_session_t
*
session
,
switch_frame_t
*
frame
,
switch_io_flag_t
flags
,
int
stream_id
)
{
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
private_t
*
tech_pvt
=
switch_core_session_get_private
(
session
);
switch_assert
(
tech_pvt
!=
NULL
);
if
(
tech_pvt
->
audio_endpoint
)
{
return
channel_endpoint_write
(
tech_pvt
->
audio_endpoint
,
frame
);
}
if
(
!
globals
.
main_stream
)
{
return
SWITCH_STATUS_FALSE
;
}
...
...
@@ -951,7 +967,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
if
(
globals
.
main_stream
)
{
if
(
switch_test_flag
((
&
globals
),
GFLAG_EAR
))
{
WriteAudioStream
(
globals
.
main_stream
->
stream
,
(
short
*
)
frame
->
data
,
(
int
)
(
frame
->
datalen
/
sizeof
(
SAMPLE
)),
&
(
globals
.
main_stream
->
write_timer
));
WriteAudioStream
(
globals
.
main_stream
->
stream
,
(
short
*
)
frame
->
data
,
(
int
)
(
frame
->
datalen
/
sizeof
(
SAMPLE
)),
0
,
&
(
globals
.
main_stream
->
write_timer
));
}
status
=
SWITCH_STATUS_SUCCESS
;
}
...
...
@@ -1876,7 +1892,7 @@ static switch_status_t play_dev(switch_stream_handle_t *stream, int outdev, char
break
;
}
WriteAudioStream
(
audio_stream
->
stream
,
abuf
,
(
long
)
olen
,
&
(
audio_stream
->
write_timer
));
WriteAudioStream
(
audio_stream
->
stream
,
abuf
,
(
long
)
olen
,
0
,
&
(
audio_stream
->
write_timer
));
wrote
+=
(
int
)
olen
;
if
(
samples
)
{
samples
-=
(
int
)
olen
;
...
...
@@ -2555,8 +2571,8 @@ static switch_status_t looptest(char **argv, int argc, switch_stream_handle_t *s
if
(
globals
.
destroying_streams
||
!
globals
.
main_stream
->
stream
)
{
break
;
}
if
((
samples
=
ReadAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
globals
.
read_codec
.
implementation
->
samples_per_packet
,
&
globals
.
read_timer
)))
{
WriteAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
(
long
)
samples
,
&
(
globals
.
main_stream
->
write_timer
));
if
((
samples
=
ReadAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
globals
.
read_codec
.
implementation
->
samples_per_packet
,
0
,
&
globals
.
read_timer
)))
{
WriteAudioStream
(
globals
.
main_stream
->
stream
,
globals
.
read_frame
.
data
,
(
long
)
samples
,
0
,
&
(
globals
.
main_stream
->
write_timer
));
success
=
1
;
}
switch_yield
(
10000
);
...
...
src/mod/endpoints/mod_portaudio/pablio.c
浏览文件 @
739ff9d3
...
...
@@ -143,7 +143,7 @@ static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf)
* Write data to ring buffer.
* Will not return until all the data has been written.
*/
long
WriteAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
switch_timer_t
*
timer
)
long
WriteAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
int
chan
,
switch_timer_t
*
timer
)
{
long
bytesWritten
;
char
*
p
=
(
char
*
)
data
;
...
...
@@ -151,12 +151,12 @@ long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switc
switch_core_timer_next
(
timer
);
bytesWritten
=
PaUtil_WriteRingBuffer
(
&
aStream
->
outFIFOs
[
0
],
p
,
numBytes
);
bytesWritten
=
PaUtil_WriteRingBuffer
(
&
aStream
->
outFIFOs
[
chan
],
p
,
numBytes
);
numBytes
-=
bytesWritten
;
p
+=
bytesWritten
;
if
(
numBytes
>
0
)
{
PaUtil_FlushRingBuffer
(
&
aStream
->
outFIFOs
[
0
]);
PaUtil_FlushRingBuffer
(
&
aStream
->
outFIFOs
[
chan
]);
return
0
;
}
return
numFrames
;
...
...
@@ -166,7 +166,7 @@ long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switc
* Read data from ring buffer.
* Will not return until all the data has been read.
*/
long
ReadAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
switch_timer_t
*
timer
)
long
ReadAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
int
chan
,
switch_timer_t
*
timer
)
{
long
bytesRead
=
0
;
char
*
p
=
(
char
*
)
data
;
...
...
@@ -177,17 +177,17 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
while
(
totalBytes
<
neededBytes
&&
--
max
>
0
)
{
avail
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFOs
[
0
]);
avail
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFOs
[
chan
]);
//printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max);
if
(
avail
>=
neededBytes
*
6
)
{
PaUtil_FlushRingBuffer
(
&
aStream
->
inFIFOs
[
0
]);
PaUtil_FlushRingBuffer
(
&
aStream
->
inFIFOs
[
chan
]);
avail
=
0
;
}
else
{
bytesRead
=
0
;
if
(
totalBytes
<
neededBytes
&&
avail
>=
neededBytes
)
{
bytesRead
=
PaUtil_ReadRingBuffer
(
&
aStream
->
inFIFOs
[
0
],
p
,
neededBytes
);
bytesRead
=
PaUtil_ReadRingBuffer
(
&
aStream
->
inFIFOs
[
chan
],
p
,
neededBytes
);
totalBytes
+=
bytesRead
;
}
...
...
@@ -206,9 +206,9 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
* Return the number of frames that could be written to the stream without
* having to wait.
*/
long
GetAudioStreamWriteable
(
PABLIO_Stream
*
aStream
)
long
GetAudioStreamWriteable
(
PABLIO_Stream
*
aStream
,
int
chan
)
{
int
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFOs
[
0
]);
int
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFOs
[
chan
]);
return
bytesEmpty
/
aStream
->
bytesPerFrame
;
}
...
...
@@ -216,9 +216,9 @@ long GetAudioStreamWriteable(PABLIO_Stream * aStream)
* Return the number of frames that are available to be read from the
* stream without having to wait.
*/
long
GetAudioStreamReadable
(
PABLIO_Stream
*
aStream
)
long
GetAudioStreamReadable
(
PABLIO_Stream
*
aStream
,
int
chan
)
{
int
bytesFull
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFOs
[
0
]);
int
bytesFull
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFOs
[
chan
]);
return
bytesFull
/
aStream
->
bytesPerFrame
;
}
...
...
src/mod/endpoints/mod_portaudio/pablio.h
浏览文件 @
739ff9d3
...
...
@@ -81,25 +81,25 @@ typedef struct {
* Write data to ring buffer.
* Will not return until all the data has been written.
*/
long
WriteAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
switch_timer_t
*
timer
);
long
WriteAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
int
chan
,
switch_timer_t
*
timer
);
/************************************************************
* Read data from ring buffer.
* Will not return until all the data has been read.
*/
long
ReadAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
switch_timer_t
*
timer
);
long
ReadAudioStream
(
PABLIO_Stream
*
aStream
,
void
*
data
,
long
numFrames
,
int
chan
,
switch_timer_t
*
timer
);
/************************************************************
* Return the number of frames that could be written to the stream without
* having to wait.
*/
long
GetAudioStreamWriteable
(
PABLIO_Stream
*
aStream
);
long
GetAudioStreamWriteable
(
PABLIO_Stream
*
aStream
,
int
chan
);
/************************************************************
* Return the number of frames that are available to be read from the
* stream without having to wait.
*/
long
GetAudioStreamReadable
(
PABLIO_Stream
*
aStream
);
long
GetAudioStreamReadable
(
PABLIO_Stream
*
aStream
,
int
chan
);
/************************************************************
* Opens a PortAudio stream with default characteristics.
...
...
@@ -109,12 +109,12 @@ typedef struct {
* PABLIO_READ, PABLIO_WRITE, or PABLIO_READ_WRITE,
* and either PABLIO_MONO or PABLIO_STEREO
*/
PaError
OpenAudioStream
(
PABLIO_Stream
**
rwblPtr
,
const
PaStreamParameters
*
inputParameters
,
const
PaStreamParameters
*
outputParameters
,
double
sampleRate
,
PaStreamCallbackFlags
statusFlags
,
long
samples_per_packet
,
int
do_dual
);
PaError
OpenAudioStream
(
PABLIO_Stream
**
rwblPtr
,
const
PaStreamParameters
*
inputParameters
,
const
PaStreamParameters
*
outputParameters
,
double
sampleRate
,
PaStreamCallbackFlags
statusFlags
,
long
samples_per_packet
,
int
do_dual
);
PaError
CloseAudioStream
(
PABLIO_Stream
*
aStream
);
PaError
CloseAudioStream
(
PABLIO_Stream
*
aStream
);
#ifdef __cplusplus
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论