From e291f3d257360667e12754154acac9ba3fe3316a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Aug 2012 00:29:38 +0200 Subject: decoder/fluidsynth: remove throttle (requires libfluidsynth 1.1) The libfluidsynth API is now sane, and does not require real-time decoding. --- NEWS | 2 ++ 1 file changed, 2 insertions(+) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 27817a27..2cb2c04c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ ver 0.17.2 (2012/??/??) * protocol: - fix crash in local file check +* decoder: + - fluidsynth: remove throttle (requires libfluidsynth 1.1) * output: - httpd: use monotonic clock, avoid hiccups after system clock adjustment - httpd: fix throttling bug after resuming playback -- cgit v1.2.3 From c8ec85d649e46df87d1b526fde2d8234428925c0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Aug 2012 00:35:56 +0200 Subject: decoder/fluidsynth: check if file is really a MIDI Use fluid_is_midifile() to verify the file format. --- NEWS | 1 + src/decoder/fluidsynth_decoder_plugin.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 2cb2c04c..0dfa92b6 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ ver 0.17.2 (2012/??/??) - fix crash in local file check * decoder: - fluidsynth: remove throttle (requires libfluidsynth 1.1) + - fluidsynth: check MIDI file format while scanning * output: - httpd: use monotonic clock, avoid hiccups after system clock adjustment - httpd: fix throttling bug after resuming playback diff --git a/src/decoder/fluidsynth_decoder_plugin.c b/src/decoder/fluidsynth_decoder_plugin.c index 9e2511d3..8cb524c9 100644 --- a/src/decoder/fluidsynth_decoder_plugin.c +++ b/src/decoder/fluidsynth_decoder_plugin.c @@ -208,10 +208,7 @@ fluidsynth_scan_file(const char *file, G_GNUC_UNUSED const struct tag_handler *handler, G_GNUC_UNUSED void *handler_ctx) { - /* to be implemented */ - (void)file; - - return true; + return fluid_is_midifile(file); } static const char *const fluidsynth_suffixes[] = { -- cgit v1.2.3 From b1bbd70f0f956e9829158ee80a42f1bafde67347 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Aug 2012 00:47:10 +0200 Subject: decoder/fluidsynth: stop playback at end of file Use libfluidsynth's new function fluid_player_get_status(). --- NEWS | 1 + src/decoder/fluidsynth_decoder_plugin.c | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index 0dfa92b6..a1aee15b 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ ver 0.17.2 (2012/??/??) - fix crash in local file check * decoder: - fluidsynth: remove throttle (requires libfluidsynth 1.1) + - fluidsynth: stop playback at end of file - fluidsynth: check MIDI file format while scanning * output: - httpd: use monotonic clock, avoid hiccups after system clock adjustment diff --git a/src/decoder/fluidsynth_decoder_plugin.c b/src/decoder/fluidsynth_decoder_plugin.c index b55c1db5..a8c148c8 100644 --- a/src/decoder/fluidsynth_decoder_plugin.c +++ b/src/decoder/fluidsynth_decoder_plugin.c @@ -168,7 +168,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) decoder_initialized(decoder, &audio_format, false, -1); - do { + while (fluid_player_get_status(player) == FLUID_PLAYER_PLAYING) { int16_t buffer[2048]; const unsigned max_frames = G_N_ELEMENTS(buffer) / 2; @@ -178,15 +178,14 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) ret = fluid_synth_write_s16(synth, max_frames, buffer, 0, 2, buffer, 1, 2); - /* XXX how do we see whether the player is done? We - can't access the private attribute - player->status */ if (ret != 0) break; cmd = decoder_data(decoder, NULL, buffer, sizeof(buffer), 0); - } while (cmd == DECODE_COMMAND_NONE); + if (cmd != DECODE_COMMAND_NONE) + break; + } /* clean up */ -- cgit v1.2.3 From 4a993cd79ec4149c3b52b383a8f751be26c2bac5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 15 Aug 2012 00:57:32 +0200 Subject: decoder/fluidsynth: add "sample_rate" setting --- NEWS | 1 + doc/user.xml | 9 +++++++++ src/decoder/fluidsynth_decoder_plugin.c | 20 ++++++++++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) (limited to 'NEWS') diff --git a/NEWS b/NEWS index a1aee15b..4aaa75ca 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ ver 0.17.2 (2012/??/??) - fluidsynth: remove throttle (requires libfluidsynth 1.1) - fluidsynth: stop playback at end of file - fluidsynth: check MIDI file format while scanning + - fluidsynth: add sample rate setting * output: - httpd: use monotonic clock, avoid hiccups after system clock adjustment - httpd: fix throttling bug after resuming playback diff --git a/doc/user.xml b/doc/user.xml index bb83674d..13a2c738 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -834,6 +834,15 @@ systemctl start mpd.socket + + + sample_rate + + + The sample rate that shall be synthesized by the + plugin. Defaults to 48000. + + soundfont diff --git a/src/decoder/fluidsynth_decoder_plugin.c b/src/decoder/fluidsynth_decoder_plugin.c index ed0efdd9..894b2d35 100644 --- a/src/decoder/fluidsynth_decoder_plugin.c +++ b/src/decoder/fluidsynth_decoder_plugin.c @@ -19,6 +19,7 @@ #include "config.h" #include "decoder_api.h" +#include "audio_check.h" #include "conf.h" #include @@ -28,6 +29,7 @@ #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "fluidsynth" +static unsigned sample_rate; static const char *soundfont_path; /** @@ -69,6 +71,15 @@ fluidsynth_mpd_log_function(int level, char *message, G_GNUC_UNUSED void *data) static bool fluidsynth_init(const struct config_param *param) { + GError *error = NULL; + + sample_rate = config_get_block_unsigned(param, "sample_rate", 48000); + if (!audio_check_sample_rate(sample_rate, &error)) { + g_warning("%s\n", error->message); + g_error_free(error); + return false; + } + soundfont_path = config_get_block_string(param, "soundfont", "/usr/share/sounds/sf2/FluidR3_GM.sf2"); @@ -82,11 +93,6 @@ fluidsynth_init(const struct config_param *param) static void fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) { - static const struct audio_format audio_format = { - .sample_rate = 48000, - .format = SAMPLE_FORMAT_S16, - .channels = 2, - }; char setting_sample_rate[] = "synth.sample-rate"; /* char setting_verbose[] = "synth.verbose"; @@ -104,7 +110,7 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) if (settings == NULL) return; - fluid_settings_setnum(settings, setting_sample_rate, 48000); + fluid_settings_setnum(settings, setting_sample_rate, sample_rate); /* fluid_settings_setstr(settings, setting_verbose, setting_yes); @@ -158,6 +164,8 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) /* initialization complete - announce the audio format to the MPD core */ + struct audio_format audio_format; + audio_format_init(&audio_format, sample_rate, SAMPLE_FORMAT_S16, 2); decoder_initialized(decoder, &audio_format, false, -1); while (fluid_player_get_status(player) == FLUID_PLAYER_PLAYING) { -- cgit v1.2.3