[SCM] libgroove/upstream: playlist: correct generation of the sink map
andrewrk-guest at users.alioth.debian.org
andrewrk-guest at users.alioth.debian.org
Wed May 14 02:26:58 UTC 2014
The following commit has been merged in the upstream branch:
commit 315a36a8463fb296937b6ac3707d236b7971d62e
Author: Andrew Kelley <superjoe30 at gmail.com>
Date: Tue May 13 14:54:56 2014 -0700
playlist: correct generation of the sink map
* fixes potential error when adding multiple sinks
* optimizes some cases where sinks can share filter graph chain
* dummy player now uses disable_resample optimization
diff --git a/groove/playlist.c b/groove/playlist.c
index 4e887fc..5cb1383 100644
--- a/groove/playlist.c
+++ b/groove/playlist.c
@@ -316,7 +316,7 @@ static int create_volume_filter(struct GroovePlaylistPrivate *p, AVFilterContext
}
// abuffer -> volume -> asplit for each audio format
-// -> aformat -> abuffersink
+// -> volume -> aformat -> abuffersink
// if the volume gain is > 1.0, we use a compand filter instead
// for soft limiting.
static int init_filter_graph(struct GroovePlaylist *playlist, struct GrooveFile *file) {
@@ -710,18 +710,18 @@ static void *decode_thread(void *arg) {
}
static int sink_formats_equal(const struct GrooveSink *a, const struct GrooveSink *b) {
- if (a->buffer_sample_count != b->buffer_sample_count)
+ if (b->buffer_sample_count != 0 && a->buffer_sample_count != b->buffer_sample_count)
return 0;
if (a->gain != b->gain)
return 0;
- if (a->disable_resample) {
- return b->disable_resample;
- } else {
- return b->disable_resample ? 0 :
- (a->audio_format.sample_rate == b->audio_format.sample_rate &&
- a->audio_format.channel_layout == b->audio_format.channel_layout &&
- a->audio_format.sample_fmt == b->audio_format.sample_fmt);
+ if (!b->disable_resample &&
+ (a->audio_format.sample_rate != b->audio_format.sample_rate ||
+ a->audio_format.channel_layout != b->audio_format.channel_layout ||
+ a->audio_format.sample_fmt != b->audio_format.sample_fmt))
+ {
+ return 0;
}
+ return 1;
}
static int remove_sink_from_map(struct GrooveSink *sink) {
@@ -782,6 +782,13 @@ static int add_sink_to_map(struct GroovePlaylist *playlist, struct GrooveSink *s
// push our sink onto the stack and we're done
struct GrooveSink *example_sink = map_item->stack_head->sink;
if (sink_formats_equal(example_sink, sink)) {
+ stack_entry->next = map_item->stack_head->next;
+ map_item->stack_head->next = stack_entry;
+ return 0;
+ }
+ // maybe we need to swap the example sink with the new sink to make
+ // it work
+ if (sink_formats_equal(sink, example_sink)) {
stack_entry->next = map_item->stack_head;
map_item->stack_head = stack_entry;
return 0;
diff --git a/grooveplayer/player.c b/grooveplayer/player.c
index d0d4576..4d76db2 100644
--- a/grooveplayer/player.c
+++ b/grooveplayer/player.c
@@ -380,6 +380,7 @@ int groove_player_attach(struct GroovePlayer *player, struct GroovePlaylist *pla
// dummy device
player->actual_audio_format = player->target_audio_format;
p->sink->audio_format = player->actual_audio_format;
+ p->sink->disable_resample = 1;
} else {
SDL_AudioSpec wanted_spec, spec;
wanted_spec.format = groove_fmt_to_sdl_fmt(player->target_audio_format.sample_fmt);
--
libgroove packaging
More information about the pkg-multimedia-commits
mailing list