Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
3b47cbd7
Commit
3b47cbd7
authored
13 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #8968: audiorecord: added debug, clarified wave header creation
parent
6ec86926
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
daemon/src/audio/audiorecord.cpp
+38
-11
38 additions, 11 deletions
daemon/src/audio/audiorecord.cpp
with
38 additions
and
11 deletions
daemon/src/audio/audiorecord.cpp
+
38
−
11
View file @
3b47cbd7
...
...
@@ -245,6 +245,27 @@ bool AudioRecord::setRawFile()
return
true
;
}
namespace
{
std
::
string
header_to_string
(
const
wavhdr
&
hdr
)
{
std
::
stringstream
ss
;
ss
<<
hdr
.
riff
<<
"
\0
"
<<
hdr
.
file_size
<<
" "
<<
hdr
.
wave
<<
"
\0
"
<<
hdr
.
fmt
<<
"
\0
"
<<
hdr
.
chunk_size
<<
" "
<<
hdr
.
format_tag
<<
" "
<<
hdr
.
num_chans
<<
" "
<<
hdr
.
sample_rate
<<
" "
<<
hdr
.
bytes_per_sec
<<
" "
<<
hdr
.
bytes_per_samp
<<
" "
<<
hdr
.
bits_per_samp
<<
" "
<<
hdr
.
data
<<
"
\0
"
<<
hdr
.
data_length
;
return
ss
.
str
();
}
}
bool
AudioRecord
::
setWavFile
()
{
DEBUG
(
"AudioRecord: Create new wave file %s, sampling rate: %d"
,
savePath_
.
c_str
(),
sndSmplRate_
);
...
...
@@ -259,23 +280,29 @@ bool AudioRecord::setWavFile()
/* The text fields are NOT supposed to be null terminated, so we have to
* write them as arrays since strings enclosed in quotes include a
* null character */
wavhdr
hdr
=
{{
'R'
,
'I'
,
'F'
,
'F'
},
44
,
{
'W'
,
'A'
,
'V'
,
'E'
},
{
'f'
,
'm'
,
't'
,
' '
},
16
,
1
,
1
,
sndSmplRate_
,
0
,
2
,
16
,
{
'd'
,
'a'
,
't'
,
'a'
},
0
};
hdr
.
num_chans
=
channels_
;
hdr
.
bits_per_samp
=
16
;
hdr
.
bytes_per_samp
=
static_cast
<
SINT16
>
(
channels_
*
hdr
.
bits_per_samp
/
8
);
hdr
.
bytes_per_sec
=
static_cast
<
SINT32
>
(
hdr
.
sample_rate
*
hdr
.
bytes_per_samp
);
wavhdr
hdr
=
{{
'R'
,
'I'
,
'F'
,
'F'
},
44
,
{
'W'
,
'A'
,
'V'
,
'E'
},
{
'f'
,
'm'
,
't'
,
' '
},
16
,
1
,
channels_
,
sndSmplRate_
,
-
1
,
/* initialized below */
-
1
,
/* initialized below */
16
,
{
'd'
,
'a'
,
't'
,
'a'
},
0
};
hdr
.
bytes_per_samp
=
channels_
*
hdr
.
bits_per_samp
/
8
;
hdr
.
bytes_per_sec
=
hdr
.
sample_rate
*
hdr
.
bytes_per_samp
;
if
(
fwrite
(
&
hdr
,
4
,
11
,
fileHandle_
)
!=
11
)
{
WARN
(
"AudioRecord: Error: could not write WAV header for file. "
);
return
false
;
}
DEBUG
(
"AudioRecord: created WAV file successfully, file size=%d,"
"chunk size=%d, fmt=%d, data length=%d"
,
hdr
.
file_size
,
hdr
.
chunk_size
,
hdr
.
format_tag
,
hdr
.
data_length
);
DEBUG
(
"AudioRecord: Wrote wave header
\"
%s
\"
"
,
header_to_string
(
hdr
).
c_str
());
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment