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
98a3cdb9
Commit
98a3cdb9
authored
12 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #9832: AudioRecord: cleanup logging
parent
1c8b3e48
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
+29
-29
29 additions, 29 deletions
daemon/src/audio/audiorecord.cpp
with
29 additions
and
29 deletions
daemon/src/audio/audiorecord.cpp
+
29
−
29
View file @
98a3cdb9
...
...
@@ -102,12 +102,12 @@ void AudioRecord::initFilename(const std::string &peerNumber)
if
(
fileType_
==
FILE_RAW
)
{
if
(
filename_
.
find
(
".raw"
)
==
std
::
string
::
npos
)
{
DEBUG
(
"
AudioRecord: c
oncatenate .raw file extension: name : %s"
,
filename_
.
c_str
());
DEBUG
(
"
C
oncatenate .raw file extension: name : %s"
,
filename_
.
c_str
());
fName
.
append
(
".raw"
);
}
}
else
if
(
fileType_
==
FILE_WAV
)
{
if
(
filename_
.
find
(
".wav"
)
==
std
::
string
::
npos
)
{
DEBUG
(
"
AudioRecord: c
oncatenate .wav file extension: name : %s"
,
filename_
.
c_str
());
DEBUG
(
"
C
oncatenate .wav file extension: name : %s"
,
filename_
.
c_str
());
fName
.
append
(
".wav"
);
}
}
...
...
@@ -125,7 +125,7 @@ bool AudioRecord::openFile()
bool
result
=
false
;
if
(
not
fileExists
())
{
DEBUG
(
"
AudioRecord:
Filename does not exist, creating one"
);
DEBUG
(
"Filename does not exist, creating one"
);
byteCounter_
=
0
;
if
(
fileType_
==
FILE_RAW
)
...
...
@@ -133,7 +133,7 @@ bool AudioRecord::openFile()
else
if
(
fileType_
==
FILE_WAV
)
result
=
setWavFile
();
}
else
{
DEBUG
(
"
AudioRecord:
Filename already exists, opening it"
);
DEBUG
(
"Filename already exists, opening it"
);
if
(
fileType_
==
FILE_RAW
)
result
=
openExistingRawFile
();
else
if
(
fileType_
==
FILE_WAV
)
...
...
@@ -180,7 +180,7 @@ void AudioRecord::setRecording()
void
AudioRecord
::
stopRecording
()
{
DEBUG
(
"
AudioRecording:
Stop recording"
);
DEBUG
(
"Stop recording"
);
recordingEnabled_
=
false
;
}
...
...
@@ -227,7 +227,7 @@ void AudioRecord::createFilename()
out
<<
timeinfo
->
tm_sec
;
filename_
=
out
.
str
();
DEBUG
(
"
AudioRecord:
Generate filename for this call %s "
,
filename_
.
c_str
());
DEBUG
(
"Generate filename for this call %s "
,
filename_
.
c_str
());
}
bool
AudioRecord
::
setRawFile
()
...
...
@@ -235,11 +235,11 @@ bool AudioRecord::setRawFile()
fileHandle_
=
fopen
(
savePath_
.
c_str
(),
"wb"
);
if
(
!
fileHandle_
)
{
WARN
(
"
AudioRecord:
Could not create RAW file!"
);
WARN
(
"Could not create RAW file!"
);
return
false
;
}
DEBUG
(
"
AudioRecord:setRawFile() :
created RAW file."
);
DEBUG
(
"created RAW file."
);
return
true
;
}
...
...
@@ -267,12 +267,12 @@ namespace {
bool
AudioRecord
::
setWavFile
()
{
DEBUG
(
"
AudioRecord:
Create new wave file %s, sampling rate: %d"
,
savePath_
.
c_str
(),
sndSmplRate_
);
DEBUG
(
"Create new wave file %s, sampling rate: %d"
,
savePath_
.
c_str
(),
sndSmplRate_
);
fileHandle_
=
fopen
(
savePath_
.
c_str
(),
"wb"
);
if
(
!
fileHandle_
)
{
WARN
(
"
AudioRecord: Error: c
ould not create WAV file."
);
WARN
(
"
C
ould not create WAV file."
);
return
false
;
}
...
...
@@ -297,11 +297,11 @@ bool AudioRecord::setWavFile()
hdr
.
bytes_per_sec
=
hdr
.
sample_rate
*
hdr
.
bytes_per_samp
;
if
(
fwrite
(
&
hdr
,
4
,
11
,
fileHandle_
)
!=
11
)
{
WARN
(
"
AudioRecord: Error: c
ould not write WAV header for file. "
);
WARN
(
"
C
ould not write WAV header for file. "
);
return
false
;
}
DEBUG
(
"
AudioRecord:
Wrote wave header
\"
%s
\"
"
,
header_to_string
(
hdr
).
c_str
());
DEBUG
(
"Wrote wave header
\"
%s
\"
"
,
header_to_string
(
hdr
).
c_str
());
return
true
;
}
...
...
@@ -310,7 +310,7 @@ bool AudioRecord::openExistingRawFile()
fileHandle_
=
fopen
(
filename_
.
c_str
(),
"ab+"
);
if
(
!
fileHandle_
)
{
WARN
(
"
AudioRecord:
could not create RAW file!"
);
WARN
(
"could not create RAW file!"
);
return
false
;
}
...
...
@@ -324,32 +324,32 @@ bool AudioRecord::openExistingWavFile()
fileHandle_
=
fopen
(
filename_
.
c_str
(),
"rb+"
);
if
(
!
fileHandle_
)
{
WARN
(
"
AudioRecord: Error: c
ould not open WAV file!"
);
WARN
(
"
C
ould not open WAV file!"
);
return
false
;
}
if
(
fseek
(
fileHandle_
,
40
,
SEEK_SET
)
!=
0
)
// jump to data length
WARN
(
"
AudioRecord: Error:
Couldn't seek offset 40 in the file "
);
WARN
(
"Couldn't seek offset 40 in the file "
);
if
(
fread
(
&
byteCounter_
,
4
,
1
,
fileHandle_
))
WARN
(
"
AudioRecord: Error:
bytecounter Read successfully "
);
WARN
(
"bytecounter Read successfully "
);
if
(
fseek
(
fileHandle_
,
0
,
SEEK_END
)
!=
0
)
WARN
(
"
AudioRecord: Error:
Couldn't seek at the en of the file "
);
WARN
(
"Couldn't seek at the en of the file "
);
if
(
fclose
(
fileHandle_
)
!=
0
)
WARN
(
"
AudioRecord: Error:
Can't close file r+ "
);
WARN
(
"Can't close file r+ "
);
fileHandle_
=
fopen
(
filename_
.
c_str
(),
"ab+"
);
if
(
!
fileHandle_
)
{
WARN
(
"
AudioRecord: Error:
Could not createopen WAV file ab+!"
);
WARN
(
"Could not createopen WAV file ab+!"
);
return
false
;
}
if
(
fseek
(
fileHandle_
,
4
,
SEEK_END
)
!=
0
)
WARN
(
"
AudioRecord: Error:
Couldn't seek at the en of the file "
);
WARN
(
"Couldn't seek at the en of the file "
);
return
true
;
...
...
@@ -358,50 +358,50 @@ bool AudioRecord::openExistingWavFile()
void
AudioRecord
::
closeWavFile
()
{
if
(
fileHandle_
==
0
)
{
DEBUG
(
"
AudioRecord:
Can't closeWavFile, a file has not yet been opened!"
);
DEBUG
(
"Can't closeWavFile, a file has not yet been opened!"
);
return
;
}
DEBUG
(
"
AudioRecord:
Close wave file"
);
DEBUG
(
"Close wave file"
);
SINT32
bytes
=
byteCounter_
*
channels_
;
fseek
(
fileHandle_
,
40
,
SEEK_SET
);
// jump to data length
if
(
ferror
(
fileHandle_
))
WARN
(
"
AudioRecord: Error: c
an't reach offset 40 while closing"
);
WARN
(
"
C
an't reach offset 40 while closing"
);
fwrite
(
&
bytes
,
sizeof
(
SINT32
),
1
,
fileHandle_
);
if
(
ferror
(
fileHandle_
))
WARN
(
"
AudioRecord: Error: c
an't write bytes for data length "
);
WARN
(
"
C
an't write bytes for data length "
);
bytes
=
byteCounter_
*
channels_
+
44
;
// + 44 for the wave header
fseek
(
fileHandle_
,
4
,
SEEK_SET
);
// jump to file size
if
(
ferror
(
fileHandle_
))
WARN
(
"
AudioRecord: Error: c
an't reach offset 4"
);
WARN
(
"
C
an't reach offset 4"
);
fwrite
(
&
bytes
,
4
,
1
,
fileHandle_
);
if
(
ferror
(
fileHandle_
))
WARN
(
"
AudioRecord: Error: c
an't reach offset 4"
);
WARN
(
"
C
an't reach offset 4"
);
if
(
fclose
(
fileHandle_
)
!=
0
)
WARN
(
"
AudioRecord: Error: c
an't close file"
);
WARN
(
"
C
an't close file"
);
}
void
AudioRecord
::
recData
(
SFLDataFormat
*
buffer
,
size_t
nSamples
)
{
if
(
recordingEnabled_
)
{
if
(
fileHandle_
==
0
)
{
DEBUG
(
"
AudioRecord:
Can't record data, a file has not yet been opened!"
);
DEBUG
(
"Can't record data, a file has not yet been opened!"
);
return
;
}
if
(
fwrite
(
buffer
,
sizeof
(
SFLDataFormat
),
nSamples
,
fileHandle_
)
!=
nSamples
)
WARN
(
"
AudioRecord:
Could not record data! "
);
WARN
(
"Could not record data! "
);
else
{
fflush
(
fileHandle_
);
byteCounter_
+=
nSamples
*
sizeof
(
SFLDataFormat
);
...
...
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