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
0a2c6006
Commit
0a2c6006
authored
Nov 28, 2019
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use new style errors for new streams.
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
57ce3979
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
21 deletions
+18
-21
audiowmark.cc
src/audiowmark.cc
+6
-4
sfinputstream.cc
src/sfinputstream.cc
+4
-4
sfinputstream.hh
src/sfinputstream.hh
+1
-6
stdoutwavoutputstream.cc
src/stdoutwavoutputstream.cc
+3
-4
stdoutwavoutputstream.hh
src/stdoutwavoutputstream.hh
+1
-1
teststream.cc
src/teststream.cc
+3
-2
No files found.
src/audiowmark.cc
View file @
0a2c6006
...
...
@@ -1096,9 +1096,10 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
auto
bitvec_b
=
randomize_bit_order
(
conv_encode
(
ConvBlockType
::
b
,
bitvec
),
/* encode */
true
);
auto
in_stream
=
std
::
make_unique
<
SFInputStream
>
();
// FIXME: need virtual constructor
if
(
!
in_stream
->
open
(
infile
))
Error
err
=
in_stream
->
open
(
infile
);
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
in_stream
->
error_blurb
());
fprintf
(
stderr
,
"audiowmark: error opening %s: %s
\n
"
,
infile
.
c_str
(),
err
.
message
());
return
1
;
}
int
orig_seconds
=
in_stream
->
n_frames
()
/
in_stream
->
sample_rate
();
...
...
@@ -1112,9 +1113,10 @@ add_watermark (const string& infile, const string& outfile, const string& bits)
{
StdoutWavOutputStream
*
swstream
=
new
StdoutWavOutputStream
();
out_stream
.
reset
(
swstream
);
if
(
!
swstream
->
open
(
in_stream
->
n_channels
(),
in_stream
->
sample_rate
(),
out_bit_depth
,
in_stream
->
n_frames
()))
err
=
swstream
->
open
(
in_stream
->
n_channels
(),
in_stream
->
sample_rate
(),
out_bit_depth
,
in_stream
->
n_frames
());
if
(
err
)
{
fprintf
(
stderr
,
"audiowmark: error writing to -
\n
"
);
//%s: %s\n", outfile.c_str(), out_wav_data.error_blurb()); FIXME
error
(
"audiowmark: error writing to -: %s
\n
"
,
err
.
message
());
return
1
;
}
}
...
...
src/sfinputstream.cc
View file @
0a2c6006
...
...
@@ -10,7 +10,7 @@ SFInputStream::~SFInputStream()
close
();
}
bool
Error
SFInputStream
::
open
(
const
string
&
filename
)
{
assert
(
m_state
==
State
::
NEW
);
...
...
@@ -22,13 +22,13 @@ SFInputStream::open (const string& filename)
int
error
=
sf_error
(
m_sndfile
);
if
(
error
)
{
m_error_blurb
=
sf_strerror
(
m_sndfile
);
Error
err
(
sf_strerror
(
m_sndfile
)
);
if
(
m_sndfile
)
{
m_sndfile
=
nullptr
;
sf_close
(
m_sndfile
);
}
return
false
;
return
err
;
}
m_n_channels
=
sfinfo
.
channels
;
...
...
@@ -64,7 +64,7 @@ SFInputStream::open (const string& filename)
}
m_state
=
State
::
OPEN
;
return
true
;
return
Error
::
Code
::
NONE
;
}
int
...
...
src/sfinputstream.hh
View file @
0a2c6006
...
...
@@ -10,7 +10,6 @@
class
SFInputStream
:
public
AudioInputStream
{
SNDFILE
*
m_sndfile
=
nullptr
;
std
::
string
m_error_blurb
;
int
m_n_channels
=
0
;
int
m_n_values
=
0
;
int
m_bit_depth
=
0
;
...
...
@@ -26,7 +25,7 @@ class SFInputStream : public AudioInputStream
public
:
~
SFInputStream
();
bool
open
(
const
std
::
string
&
filename
);
Error
open
(
const
std
::
string
&
filename
);
Error
read_frames
(
std
::
vector
<
float
>&
samples
,
size_t
count
);
void
close
();
...
...
@@ -47,10 +46,6 @@ public:
{
return
m_n_values
/
m_n_channels
;
}
const
char
*
error_blurb
()
const
{
return
m_error_blurb
.
c_str
();
}
};
#endif
/* AUDIOWMARK_SF_INPUT_STREAM_HH */
src/stdoutwavoutputstream.cc
View file @
0a2c6006
...
...
@@ -47,15 +47,14 @@ header_append_u16 (vector<unsigned char>& bytes, uint16_t u)
bytes
.
push_back
(
u
>>
8
);
}
bool
Error
StdoutWavOutputStream
::
open
(
int
n_channels
,
int
sample_rate
,
int
bit_depth
,
size_t
n_frames
)
{
assert
(
m_state
==
State
::
NEW
);
if
(
bit_depth
!=
16
&&
bit_depth
!=
24
)
{
m_error_blurb
=
"StdoutWavOutputStream::open: unsupported bit depth"
;
return
false
;
return
Error
(
"StdoutWavOutputStream::open: unsupported bit depth"
);
}
vector
<
unsigned
char
>
header_bytes
;
...
...
@@ -88,7 +87,7 @@ StdoutWavOutputStream::open (int n_channels, int sample_rate, int bit_depth, siz
m_n_frames
=
n_frames
;
m_state
=
State
::
OPEN
;
return
true
;
return
Error
::
Code
::
NONE
;
}
template
<
int
BIT_DEPTH
>
void
...
...
src/stdoutwavoutputstream.hh
View file @
0a2c6006
...
...
@@ -23,7 +23,7 @@ class StdoutWavOutputStream : public AudioOutputStream
public
:
~
StdoutWavOutputStream
();
bool
open
(
int
n_channels
,
int
sample_rate
,
int
bit_depth
,
size_t
n_frames
);
Error
open
(
int
n_channels
,
int
sample_rate
,
int
bit_depth
,
size_t
n_frames
);
Error
write_frames
(
const
std
::
vector
<
float
>&
frames
)
override
;
void
close
();
int
sample_rate
()
const
override
;
...
...
src/teststream.cc
View file @
0a2c6006
...
...
@@ -18,9 +18,10 @@ main (int argc, char **argv)
StdoutWavOutputStream
out
;
std
::
string
filename
=
(
argc
>=
2
)
?
argv
[
1
]
:
"-"
;
if
(
!
in
.
open
(
filename
.
c_str
()))
Error
err
=
in
.
open
(
filename
.
c_str
());
if
(
err
)
{
fprintf
(
stderr
,
"teststream: open input failed: %s
\n
"
,
in
.
error_blurb
());
fprintf
(
stderr
,
"teststream: open input failed: %s
\n
"
,
err
.
message
());
return
1
;
}
if
(
!
out
.
open
(
in
.
n_channels
(),
in
.
sample_rate
(),
16
,
in
.
n_frames
()))
...
...
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