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
5acee73f
Commit
5acee73f
authored
Apr 05, 2012
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
encoder/vorbis: generate end-of-stream packet when playback ends
Add the encoder_plugin method end(). This is important for the recorder plugin.
parent
466c337b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
45 additions
and
6 deletions
+45
-6
NEWS
NEWS
+1
-0
flac_encoder.c
src/encoder/flac_encoder.c
+1
-0
twolame_encoder.c
src/encoder/twolame_encoder.c
+1
-0
vorbis_encoder.c
src/encoder/vorbis_encoder.c
+1
-0
encoder_plugin.h
src/encoder_plugin.h
+37
-2
recorder_output_plugin.c
src/output/recorder_output_plugin.c
+1
-1
shout_plugin.c
src/output/shout_plugin.c
+1
-1
run_encoder.c
test/run_encoder.c
+1
-1
test_vorbis_encoder.c
test/test_vorbis_encoder.c
+1
-1
No files found.
NEWS
View file @
5acee73f
...
...
@@ -5,6 +5,7 @@ ver 0.16.8 (2012/??/??)
- ffmpeg: read the "year" tag
* encoder:
- vorbis: generate end-of-stream packet before tag
- vorbis: generate end-of-stream packet when playback ends
* output:
- jack: check for connection failure before starting playback
- jack: workaround for libjack1 crash bug
...
...
src/encoder/flac_encoder.c
View file @
5acee73f
...
...
@@ -354,6 +354,7 @@ const struct encoder_plugin flac_encoder_plugin = {
.
finish
=
flac_encoder_finish
,
.
open
=
flac_encoder_open
,
.
close
=
flac_encoder_close
,
.
end
=
flac_encoder_flush
,
.
flush
=
flac_encoder_flush
,
.
write
=
flac_encoder_write
,
.
read
=
flac_encoder_read
,
...
...
src/encoder/twolame_encoder.c
View file @
5acee73f
...
...
@@ -300,6 +300,7 @@ const struct encoder_plugin twolame_encoder_plugin = {
.
finish
=
twolame_encoder_finish
,
.
open
=
twolame_encoder_open
,
.
close
=
twolame_encoder_close
,
.
end
=
twolame_encoder_flush
,
.
flush
=
twolame_encoder_flush
,
.
write
=
twolame_encoder_write
,
.
read
=
twolame_encoder_read
,
...
...
src/encoder/vorbis_encoder.c
View file @
5acee73f
...
...
@@ -405,6 +405,7 @@ const struct encoder_plugin vorbis_encoder_plugin = {
.
finish
=
vorbis_encoder_finish
,
.
open
=
vorbis_encoder_open
,
.
close
=
vorbis_encoder_close
,
.
end
=
vorbis_encoder_pre_tag
,
.
flush
=
vorbis_encoder_flush
,
.
pre_tag
=
vorbis_encoder_pre_tag
,
.
tag
=
vorbis_encoder_tag
,
...
...
src/encoder_plugin.h
View file @
5acee73f
...
...
@@ -35,7 +35,7 @@ struct encoder {
const
struct
encoder_plugin
*
plugin
;
#ifndef NDEBUG
bool
open
,
pre_tag
,
tag
;
bool
open
,
pre_tag
,
tag
,
end
;
#endif
};
...
...
@@ -53,6 +53,8 @@ struct encoder_plugin {
void
(
*
close
)(
struct
encoder
*
encoder
);
bool
(
*
end
)(
struct
encoder
*
encoder
,
GError
**
error
);
bool
(
*
flush
)(
struct
encoder
*
encoder
,
GError
**
error
);
bool
(
*
pre_tag
)(
struct
encoder
*
encoder
,
GError
**
error
);
...
...
@@ -132,7 +134,7 @@ encoder_open(struct encoder *encoder, struct audio_format *audio_format,
bool
success
=
encoder
->
plugin
->
open
(
encoder
,
audio_format
,
error
);
#ifndef NDEBUG
encoder
->
open
=
success
;
encoder
->
pre_tag
=
encoder
->
tag
=
false
;
encoder
->
pre_tag
=
encoder
->
tag
=
encoder
->
end
=
false
;
#endif
return
success
;
}
...
...
@@ -157,6 +159,35 @@ encoder_close(struct encoder *encoder)
}
/**
* Ends the stream: flushes the encoder object, generate an
* end-of-stream marker (if applicable), make everything which might
* currently be buffered available by encoder_read().
*
* After this function has been called, the encoder may not be usable
* for more data, and only encoder_read() and encoder_close() can be
* called.
*
* @param encoder the encoder
* @param error location to store the error occuring, or NULL to ignore errors.
* @return true on success
*/
static
inline
bool
encoder_end
(
struct
encoder
*
encoder
,
GError
**
error
)
{
assert
(
encoder
->
open
);
assert
(
!
encoder
->
end
);
#ifndef NDEBUG
encoder
->
end
=
true
;
#endif
/* this method is optional */
return
encoder
->
plugin
->
end
!=
NULL
?
encoder
->
plugin
->
end
(
encoder
,
error
)
:
true
;
}
/**
* Flushes an encoder object, make everything which might currently be
* buffered available by encoder_read().
*
...
...
@@ -170,6 +201,7 @@ encoder_flush(struct encoder *encoder, GError **error)
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
assert
(
!
encoder
->
tag
);
assert
(
!
encoder
->
end
);
/* this method is optional */
return
encoder
->
plugin
->
flush
!=
NULL
...
...
@@ -193,6 +225,7 @@ encoder_pre_tag(struct encoder *encoder, GError **error)
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
assert
(
!
encoder
->
tag
);
assert
(
!
encoder
->
end
);
/* this method is optional */
bool
success
=
encoder
->
plugin
->
pre_tag
!=
NULL
...
...
@@ -222,6 +255,7 @@ encoder_tag(struct encoder *encoder, const struct tag *tag, GError **error)
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
assert
(
encoder
->
tag
);
assert
(
!
encoder
->
end
);
#ifndef NDEBUG
encoder
->
tag
=
false
;
...
...
@@ -249,6 +283,7 @@ encoder_write(struct encoder *encoder, const void *data, size_t length,
assert
(
encoder
->
open
);
assert
(
!
encoder
->
pre_tag
);
assert
(
!
encoder
->
tag
);
assert
(
!
encoder
->
end
);
return
encoder
->
plugin
->
write
(
encoder
,
data
,
length
,
error
);
}
...
...
src/output/recorder_output_plugin.c
View file @
5acee73f
...
...
@@ -191,7 +191,7 @@ recorder_output_close(void *data)
/* flush the encoder and write the rest to the file */
if
(
encoder_
flush
(
recorder
->
encoder
,
NULL
))
if
(
encoder_
end
(
recorder
->
encoder
,
NULL
))
recorder_output_encoder_to_file
(
recorder
,
NULL
);
/* now really close everything */
...
...
src/output/shout_plugin.c
View file @
5acee73f
...
...
@@ -358,7 +358,7 @@ static void close_shout_conn(struct shout_data * sd)
sd
->
buf
.
len
=
0
;
if
(
sd
->
encoder
!=
NULL
)
{
if
(
encoder_
flush
(
sd
->
encoder
,
NULL
))
if
(
encoder_
end
(
sd
->
encoder
,
NULL
))
write_page
(
sd
,
NULL
);
encoder_close
(
sd
->
encoder
);
...
...
test/run_encoder.c
View file @
5acee73f
...
...
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
encoder_to_stdout
(
encoder
);
}
ret
=
encoder_
flush
(
encoder
,
&
error
);
ret
=
encoder_
end
(
encoder
,
&
error
);
if
(
!
ret
)
{
g_printerr
(
"encoder_flush() failed: %s
\n
"
,
error
->
message
);
...
...
test/test_vorbis_encoder.c
View file @
5acee73f
...
...
@@ -99,7 +99,7 @@ main(G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv)
/* finish */
success
=
encoder_
flush
(
encoder
,
NULL
);
success
=
encoder_
end
(
encoder
,
NULL
);
assert
(
success
);
encoder_to_stdout
(
encoder
);
...
...
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