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
58e600f4
Commit
58e600f4
authored
Oct 01, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/recorder: move code to _write_to_file()
parent
d34e55c3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
recorder_output_plugin.c
src/output/recorder_output_plugin.c
+30
-18
No files found.
src/output/recorder_output_plugin.c
View file @
58e600f4
...
...
@@ -120,32 +120,22 @@ recorder_output_finish(struct audio_output *ao)
g_free
(
recorder
);
}
/**
* Writes pending data from the encoder to the output file.
*/
static
bool
recorder_output_encoder_to_file
(
struct
recorder_output
*
recorder
,
recorder_write_to_file
(
struct
recorder_output
*
recorder
,
const
void
*
_data
,
size_t
length
,
GError
**
error_r
)
{
assert
(
recorder
->
fd
>=
0
);
/* read from the encoder */
assert
(
length
>
0
);
size_t
size
=
encoder_read
(
recorder
->
encoder
,
recorder
->
buffer
,
sizeof
(
recorder
->
buffer
));
if
(
size
==
0
)
return
true
;
const
int
fd
=
recorder
->
fd
;
/* write everything into the file */
const
uint8_t
*
data
=
(
const
uint8_t
*
)
_data
,
*
end
=
data
+
length
;
size_t
position
=
0
;
while
(
true
)
{
ssize_t
nbytes
=
write
(
recorder
->
fd
,
recorder
->
buffer
+
position
,
size
-
position
);
ssize_t
nbytes
=
write
(
fd
,
data
,
end
-
data
);
if
(
nbytes
>
0
)
{
position
+=
(
size_t
)
nbytes
;
if
(
position
>=
size
)
data
+=
nbytes
;
if
(
data
==
end
)
return
true
;
}
else
if
(
nbytes
==
0
)
{
/* shouldn't happen for files */
...
...
@@ -161,6 +151,28 @@ recorder_output_encoder_to_file(struct recorder_output *recorder,
}
}
/**
* Writes pending data from the encoder to the output file.
*/
static
bool
recorder_output_encoder_to_file
(
struct
recorder_output
*
recorder
,
GError
**
error_r
)
{
assert
(
recorder
->
fd
>=
0
);
/* read from the encoder */
size_t
size
=
encoder_read
(
recorder
->
encoder
,
recorder
->
buffer
,
sizeof
(
recorder
->
buffer
));
if
(
size
==
0
)
return
true
;
/* write everything into the file */
return
recorder_write_to_file
(
recorder
,
recorder
->
buffer
,
size
,
error_r
);
}
static
bool
recorder_output_open
(
struct
audio_output
*
ao
,
struct
audio_format
*
audio_format
,
...
...
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