Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
ffmpeg
Commits
4874e76c
Commit
4874e76c
authored
May 28, 2024
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/asubprocess: handle subprocess write errors
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
1bb6f13f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
af_asubprocess.c
libavfilter/af_asubprocess.c
+15
-9
No files found.
libavfilter/af_asubprocess.c
View file @
4874e76c
...
...
@@ -137,7 +137,7 @@ sp_read (SP *sp, char *buffer, int count)
}
}
static
void
static
int
sp_write
(
SP
*
sp
,
char
*
buffer
,
int
count
)
{
int
offset
=
0
;
...
...
@@ -146,6 +146,8 @@ sp_write (SP *sp, char *buffer, int count)
close
(
sp
->
input_pipe
);
sp
->
input_pipe
=
-
1
;
}
if
(
count
&&
sp
->
done
)
return
AVERROR_EXTERNAL
;
do
{
struct
pollfd
fds
[
2
]
=
{
...
...
@@ -185,10 +187,13 @@ sp_write (SP *sp, char *buffer, int count)
waitpid
(
sp
->
pid
,
&
status
,
0
);
printf
(
"wstatus=%d
\n
"
,
WEXITSTATUS
(
status
));
sp
->
done
=
true
;
return
;
if
(
count
)
return
AVERROR_EXTERNAL
;
return
0
;
}
}
}
while
(
count
);
return
0
;
}
static
bool
...
...
@@ -260,12 +265,13 @@ static av_cold void uninit(AVFilterContext *ctx)
#define NB_BUFFER_SAMPLES 4096
static
void
write_wav_header
(
ASubProcessContext
*
s
,
int
nb_channels
,
int
sample_rate
)
static
int
write_wav_header
(
ASubProcessContext
*
s
,
int
nb_channels
,
int
sample_rate
)
{
int
bit_depth
=
s
->
in_bit_depth
;
AVIOContext
*
wav_header
=
NULL
;
uint8_t
*
buffer
=
NULL
;
int
size
;
int
ret
;
avio_open_dyn_buf
(
&
wav_header
);
ffio_wfourcc
(
wav_header
,
"RIFF"
);
...
...
@@ -285,8 +291,9 @@ static void write_wav_header (ASubProcessContext *s, int nb_channels, int sample
ffio_wfourcc
(
wav_header
,
"data"
);
avio_wl32
(
wav_header
,
-
1
);
size
=
avio_close_dyn_buf
(
wav_header
,
&
buffer
);
sp_write
(
s
->
sp
,
buffer
,
size
);
ret
=
sp_write
(
s
->
sp
,
buffer
,
size
);
av_free
(
buffer
);
return
ret
;
}
static
int
config_input
(
AVFilterLink
*
inlink
)
...
...
@@ -356,7 +363,7 @@ static void read_samples(ASubProcessContext *s, int32_t *data, int count)
}
}
static
void
write_samples
(
ASubProcessContext
*
s
,
int32_t
*
data
,
int
count
)
static
int
write_samples
(
ASubProcessContext
*
s
,
int32_t
*
data
,
int
count
)
{
int
sample_size
=
s
->
in_bit_depth
/
8
;
...
...
@@ -364,8 +371,7 @@ static void write_samples(ASubProcessContext *s, int32_t *data, int count)
if
(
s
->
in_bit_depth
==
32
)
{
/* optimized case: on little endian systems we don't need any conversion */
sp_write
(
s
->
sp
,
(
char
*
)
data
,
sample_size
*
count
);
return
;
return
sp_write
(
s
->
sp
,
(
char
*
)
data
,
sample_size
*
count
);
}
#endif
if
(
s
->
in_bit_depth
==
16
)
...
...
@@ -389,7 +395,7 @@ static void write_samples(ASubProcessContext *s, int32_t *data, int count)
for
(
int
k
=
0
;
k
<
count
;
k
++
)
AV_WL32
(
out
+
k
,
data
[
k
]);
}
sp_write
(
s
->
sp
,
s
->
sample_buffer
,
sample_size
*
count
);
return
sp_write
(
s
->
sp
,
s
->
sample_buffer
,
sample_size
*
count
);
}
static
int
write_frame
(
ASubProcessContext
*
s
,
AVFilterLink
*
inlink
,
AVFrame
*
in
)
...
...
@@ -397,7 +403,7 @@ static int write_frame(ASubProcessContext *s, AVFilterLink *inlink, AVFrame *in)
int
ret
=
0
;
av_assert0
(
in
->
nb_samples
<=
NB_BUFFER_SAMPLES
);
write_samples
(
s
,
(
int32_t
*
)
in
->
data
[
0
],
in
->
nb_samples
*
inlink
->
ch_layout
.
nb_channels
);
ret
=
write_samples
(
s
,
(
int32_t
*
)
in
->
data
[
0
],
in
->
nb_samples
*
inlink
->
ch_layout
.
nb_channels
);
av_frame_free
(
&
in
);
return
ret
;
}
...
...
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