Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
b05965c8
提交
b05965c8
authored
3月 19, 2011
作者:
Moises Silva
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mod_portaudio: update to support multiple io buffers
上级
df43e51c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
37 行增加
和
42 行删除
+37
-42
mod_portaudio.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
+17
-22
pablio.c
src/mod/endpoints/mod_portaudio/pablio.c
+18
-18
pablio.h
src/mod/endpoints/mod_portaudio/pablio.h
+2
-2
没有找到文件。
src/mod/endpoints/mod_portaudio/mod_portaudio.c
浏览文件 @
b05965c8
...
...
@@ -98,41 +98,36 @@ struct private_object {
typedef
struct
private_object
private_t
;
struct
audio_stream
{
/*! Sampling rate */
int
sample_rate
;
/*! Buffer packetization (and therefore timing) */
int
codec_ms
;
/*! The PA input device */
int
indev
;
/*! The PA output device */
int
outdev
;
/*! The io stream helper to buffer audio */
PABLIO_Stream
*
stream
;
/*! How often to write */
switch_timer_t
write_timer
;
/*! Next stream */
struct
audio_stream
*
next
;
};
typedef
struct
audio_stream
audio_stream_t
;
typedef
struct
_pa_shared_device
{
/*! Sampling rate */
int
sample_rate
;
/*! */
int
codec_ms
;
/*! Device number */
int
devno
;
/*! Running stream (if a stream is already running for devno) */
audio_stream_t
*
stream
;
/*! The actual portaudio device number */
/*! It's a shared device after all */
switch_mutex_t
*
mutex
;
}
pa_shared_device_t
;
typedef
struct
_pa_endpoint
{
/*! Input device for this endpoint */
pa_shared_device_t
*
indev
;
typedef
struct
audio_endpoint
{
/*! Input stream for this endpoint */
audio_stream_t
*
in_stream
;
/*! Output
device
for this endpoint */
pa_shared_device_t
*
outdev
;
/*! Output
stream
for this endpoint */
audio_stream_t
*
out_stream
;
/*! Channel index within the input
device stream
*/
/*! Channel index within the input
stream where we get the audio for this endpoint
*/
int
inchan
;
/*! Channel index within the
input device stream
*/
/*! Channel index within the
output stream where we get the audio for this endpoint
*/
int
outchan
;
}
pa
_endpoint_t
;
}
audio
_endpoint_t
;
static
struct
{
int
debug
;
...
...
src/mod/endpoints/mod_portaudio/pablio.c
浏览文件 @
b05965c8
...
...
@@ -83,9 +83,9 @@ static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
/* This may get called with NULL inputBuffer during initial setup. */
if
(
inputBuffer
!=
NULL
)
{
if
(
PaUtil_WriteRingBuffer
(
&
data
->
inFIFO
,
inputBuffer
,
numBytes
)
!=
numBytes
)
{
PaUtil_FlushRingBuffer
(
&
data
->
inFIFO
);
PaUtil_WriteRingBuffer
(
&
data
->
inFIFO
,
inputBuffer
,
numBytes
);
if
(
PaUtil_WriteRingBuffer
(
&
data
->
inFIFO
s
[
0
]
,
inputBuffer
,
numBytes
)
!=
numBytes
)
{
PaUtil_FlushRingBuffer
(
&
data
->
inFIFO
s
[
0
]
);
PaUtil_WriteRingBuffer
(
&
data
->
inFIFO
s
[
0
]
,
inputBuffer
,
numBytes
);
}
}
...
...
@@ -100,7 +100,7 @@ static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer,
if
(
outputBuffer
!=
NULL
)
{
int
i
;
int
numRead
=
PaUtil_ReadRingBuffer
(
&
data
->
outFIFO
,
outputBuffer
,
numBytes
);
int
numRead
=
PaUtil_ReadRingBuffer
(
&
data
->
outFIFO
s
[
0
]
,
outputBuffer
,
numBytes
);
/* Zero out remainder of buffer if we run out of data. */
for
(
i
=
numRead
;
i
<
numBytes
;
i
++
)
{
((
char
*
)
outputBuffer
)[
i
]
=
0
;
...
...
@@ -151,12 +151,12 @@ long WriteAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switc
switch_core_timer_next
(
timer
);
bytesWritten
=
PaUtil_WriteRingBuffer
(
&
aStream
->
outFIFO
,
p
,
numBytes
);
bytesWritten
=
PaUtil_WriteRingBuffer
(
&
aStream
->
outFIFO
s
[
0
]
,
p
,
numBytes
);
numBytes
-=
bytesWritten
;
p
+=
bytesWritten
;
if
(
numBytes
>
0
)
{
PaUtil_FlushRingBuffer
(
&
aStream
->
outFIFO
);
PaUtil_FlushRingBuffer
(
&
aStream
->
outFIFO
s
[
0
]
);
return
0
;
}
return
numFrames
;
...
...
@@ -177,17 +177,17 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
while
(
totalBytes
<
neededBytes
&&
--
max
>
0
)
{
avail
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFO
);
avail
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFO
s
[
0
]
);
//printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max);
if
(
avail
>=
neededBytes
*
6
)
{
PaUtil_FlushRingBuffer
(
&
aStream
->
inFIFO
);
PaUtil_FlushRingBuffer
(
&
aStream
->
inFIFO
s
[
0
]
);
avail
=
0
;
}
else
{
bytesRead
=
0
;
if
(
totalBytes
<
neededBytes
&&
avail
>=
neededBytes
)
{
bytesRead
=
PaUtil_ReadRingBuffer
(
&
aStream
->
inFIFO
,
p
,
neededBytes
);
bytesRead
=
PaUtil_ReadRingBuffer
(
&
aStream
->
inFIFO
s
[
0
]
,
p
,
neededBytes
);
totalBytes
+=
bytesRead
;
}
...
...
@@ -208,7 +208,7 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
*/
long
GetAudioStreamWriteable
(
PABLIO_Stream
*
aStream
)
{
int
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
);
int
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
s
[
0
]
);
return
bytesEmpty
/
aStream
->
bytesPerFrame
;
}
...
...
@@ -218,7 +218,7 @@ long GetAudioStreamWriteable(PABLIO_Stream * aStream)
*/
long
GetAudioStreamReadable
(
PABLIO_Stream
*
aStream
)
{
int
bytesFull
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFO
);
int
bytesFull
=
PaUtil_GetRingBufferReadAvailable
(
&
aStream
->
inFIFO
s
[
0
]
);
return
bytesFull
/
aStream
->
bytesPerFrame
;
}
...
...
@@ -274,7 +274,7 @@ PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
/* Initialize Ring Buffers */
if
(
inputParameters
)
{
err
=
PABLIO_InitFIFO
(
&
aStream
->
inFIFO
,
numFrames
,
aStream
->
bytesPerFrame
);
err
=
PABLIO_InitFIFO
(
&
aStream
->
inFIFO
s
[
0
]
,
numFrames
,
aStream
->
bytesPerFrame
);
if
(
err
!=
paNoError
)
{
goto
error
;
}
...
...
@@ -282,7 +282,7 @@ PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
}
if
(
outputParameters
)
{
err
=
PABLIO_InitFIFO
(
&
aStream
->
outFIFO
,
numFrames
,
aStream
->
bytesPerFrame
);
err
=
PABLIO_InitFIFO
(
&
aStream
->
outFIFO
s
[
0
]
,
numFrames
,
aStream
->
bytesPerFrame
);
if
(
err
!=
paNoError
)
{
goto
error
;
}
...
...
@@ -355,15 +355,15 @@ PaError CloseAudioStream(PABLIO_Stream * aStream)
int
byteSize
;
byteSize
=
aStream
->
outFIFO
.
bufferSize
;
byteSize
=
aStream
->
outFIFO
s
[
0
]
.
bufferSize
;
if
(
aStream
->
has_out
)
{
/* If we are writing data, make sure we play everything written. */
if
(
byteSize
>
0
)
{
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
);
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
s
[
0
]
);
while
(
bytesEmpty
<
byteSize
)
{
Pa_Sleep
(
10
);
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
);
bytesEmpty
=
PaUtil_GetRingBufferWriteAvailable
(
&
aStream
->
outFIFO
s
[
0
]
);
}
}
}
...
...
@@ -399,11 +399,11 @@ PaError CloseAudioStream(PABLIO_Stream * aStream)
}
if
(
aStream
->
has_in
)
{
PABLIO_TermFIFO
(
&
aStream
->
inFIFO
);
PABLIO_TermFIFO
(
&
aStream
->
inFIFO
s
[
0
]
);
}
if
(
aStream
->
has_out
)
{
PABLIO_TermFIFO
(
&
aStream
->
outFIFO
);
PABLIO_TermFIFO
(
&
aStream
->
outFIFO
s
[
0
]
);
}
free
(
aStream
);
...
...
src/mod/endpoints/mod_portaudio/pablio.h
浏览文件 @
b05965c8
...
...
@@ -65,8 +65,8 @@ typedef struct {
int
do_dual
;
int
has_in
;
int
has_out
;
PaUtilRingBuffer
inFIFOs
[
2
]
PaUtilRingBuffer
outFIFOs
[
2
]
PaUtilRingBuffer
inFIFOs
[
2
]
;
PaUtilRingBuffer
outFIFOs
[
2
]
;
int
channelCount
;
}
PABLIO_Stream
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论