Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a3112933
Commit
a3112933
authored
Dec 26, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/recorder: move functions into the struct
parent
2983c2a2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
25 deletions
+40
-25
RecorderOutputPlugin.cxx
src/output/plugins/RecorderOutputPlugin.cxx
+40
-25
No files found.
src/output/plugins/RecorderOutputPlugin.cxx
View file @
a3112933
...
...
@@ -66,6 +66,9 @@ struct RecorderOutput {
bool
Configure
(
const
config_param
&
param
,
Error
&
error
);
bool
Open
(
AudioFormat
&
audio_format
,
Error
&
error
);
void
Close
();
bool
WriteToFile
(
const
void
*
data
,
size_t
length
,
Error
&
error
);
/**
...
...
@@ -176,56 +179,68 @@ RecorderOutput::EncoderToFile(Error &error)
}
}
static
bool
recorder_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
,
Error
&
error
)
inline
bool
RecorderOutput
::
Open
(
AudioFormat
&
audio_format
,
Error
&
error
)
{
RecorderOutput
*
recorder
=
(
RecorderOutput
*
)
ao
;
/* create the output file */
recorder
->
fd
=
open_cloexec
(
recorder
->
path
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
0666
);
if
(
recorder
->
fd
<
0
)
{
error
.
FormatErrno
(
"Failed to create '%s'"
,
recorder
->
path
);
fd
=
open_cloexec
(
path
,
O_CREAT
|
O_WRONLY
|
O_TRUNC
|
O_BINARY
,
0666
);
if
(
fd
<
0
)
{
error
.
FormatErrno
(
"Failed to create '%s'"
,
path
);
return
false
;
}
/* open the encoder */
if
(
!
encoder_open
(
recorder
->
encoder
,
audio_format
,
error
))
{
close
(
recorder
->
fd
);
unlink
(
recorder
->
path
);
if
(
!
encoder_open
(
encoder
,
audio_format
,
error
))
{
close
(
fd
);
unlink
(
path
);
return
false
;
}
if
(
!
recorder
->
EncoderToFile
(
error
))
{
encoder_close
(
recorder
->
encoder
);
close
(
recorder
->
fd
);
unlink
(
recorder
->
path
);
if
(
!
EncoderToFile
(
error
))
{
encoder_close
(
encoder
);
close
(
fd
);
unlink
(
path
);
return
false
;
}
return
true
;
}
static
void
recorder_output_close
(
AudioOutput
*
ao
)
static
bool
recorder_output_open
(
AudioOutput
*
ao
,
AudioFormat
&
audio_format
,
Error
&
error
)
{
RecorderOutput
*
recorder
=
(
RecorderOutput
*
)
ao
;
RecorderOutput
&
recorder
=
*
(
RecorderOutput
*
)
ao
;
return
recorder
.
Open
(
audio_format
,
error
);
}
inline
void
RecorderOutput
::
Close
()
{
/* flush the encoder and write the rest to the file */
if
(
encoder_end
(
recorder
->
encoder
,
IgnoreError
()))
recorder
->
EncoderToFile
(
IgnoreError
());
if
(
encoder_end
(
encoder
,
IgnoreError
()))
EncoderToFile
(
IgnoreError
());
/* now really close everything */
encoder_close
(
recorder
->
encoder
);
encoder_close
(
encoder
);
close
(
fd
);
}
static
void
recorder_output_close
(
AudioOutput
*
ao
)
{
RecorderOutput
&
recorder
=
*
(
RecorderOutput
*
)
ao
;
close
(
recorder
->
fd
);
recorder
.
Close
(
);
}
static
size_t
...
...
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