Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
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
audiowmark
Commits
c7e2aa41
Commit
c7e2aa41
authored
May 16, 2022
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'pipe-drain'
parents
bf8035ca
e96a9f37
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
1 deletion
+26
-1
sfinputstream.cc
src/sfinputstream.cc
+25
-1
sfinputstream.hh
src/sfinputstream.hh
+1
-0
No files found.
src/sfinputstream.cc
View file @
c7e2aa41
...
...
@@ -19,6 +19,7 @@
#include <assert.h>
#include <string.h>
#include <unistd.h>
using
std
::
string
;
using
std
::
vector
;
...
...
@@ -32,7 +33,15 @@ Error
SFInputStream
::
open
(
const
string
&
filename
)
{
return
open
([
&
]
(
SF_INFO
*
sfinfo
)
{
return
sf_open
(
filename
.
c_str
(),
SFM_READ
,
sfinfo
);
if
(
filename
==
"-"
)
{
m_is_stdin
=
true
;
return
sf_open_fd
(
STDIN_FILENO
,
SFM_READ
,
sfinfo
,
/* close fd */
SF_FALSE
);
}
else
{
return
sf_open
(
filename
.
c_str
(),
SFM_READ
,
sfinfo
);
}
});
}
...
...
@@ -163,6 +172,21 @@ SFInputStream::close()
m_sndfile
=
nullptr
;
m_state
=
State
::
CLOSED
;
if
(
m_is_stdin
)
{
/* WAV files can contain additional RIFF chunks after the end of the 'data' chunk (issue #19).
* -> skip the rest of stdin to avoid SIGPIPE for the process writing to the pipe
*/
ssize_t
count
;
do
{
char
junk
[
16
*
1024
];
count
=
read
(
STDIN_FILENO
,
junk
,
sizeof
(
junk
))
;
}
while
(
count
>
0
||
(
count
==
-
1
&&
errno
==
EINTR
));
}
}
}
...
...
src/sfinputstream.hh
View file @
c7e2aa41
...
...
@@ -46,6 +46,7 @@ private:
int
m_bit_depth
=
0
;
int
m_sample_rate
=
0
;
bool
m_read_float_data
=
false
;
bool
m_is_stdin
=
false
;
enum
class
State
{
NEW
,
...
...
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