From 8b6212777016404ce265631136bc4cccc9bc842c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 29 Aug 2014 23:03:29 +0200 Subject: decoder/gme: fix song duration The unit of gme_info_t::length is milliseconds, not centiseconds. --- src/decoder/GmeDecoderPlugin.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/decoder/GmeDecoderPlugin.cxx b/src/decoder/GmeDecoderPlugin.cxx index d67ee4b42..9c9b19478 100644 --- a/src/decoder/GmeDecoderPlugin.cxx +++ b/src/decoder/GmeDecoderPlugin.cxx @@ -235,7 +235,7 @@ gme_scan_file(const char *path_fs, if (ti->length > 0) tag_handler_invoke_duration(handler, handler_ctx, - ti->length / 100); + ti->length / 1000); if (ti->song != nullptr) { if (gme_track_count(emu) > 1) { -- cgit v1.2.3 From af260b5a64b038c61d987d9ca7e3a3e96c656cde Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 31 Aug 2014 14:00:09 +0200 Subject: output/{alsa,oss}: add assertions --- src/output/AlsaOutputPlugin.cxx | 2 ++ src/output/OssOutputPlugin.cxx | 4 ++++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/output/AlsaOutputPlugin.cxx b/src/output/AlsaOutputPlugin.cxx index 6668c920f..76eea5bd6 100644 --- a/src/output/AlsaOutputPlugin.cxx +++ b/src/output/AlsaOutputPlugin.cxx @@ -802,6 +802,7 @@ alsa_play(struct audio_output *ao, const void *chunk, size_t size, { AlsaOutput *ad = (AlsaOutput *)ao; + assert(size > 0); assert(size % ad->in_frame_size == 0); if (ad->must_prepare) { @@ -819,6 +820,7 @@ alsa_play(struct audio_output *ao, const void *chunk, size_t size, assert(size % ad->out_frame_size == 0); size /= ad->out_frame_size; + assert(size > 0); while (true) { snd_pcm_sframes_t ret = ad->writei(ad->pcm, chunk, size); diff --git a/src/output/OssOutputPlugin.cxx b/src/output/OssOutputPlugin.cxx index 68f2a38aa..cdde6d562 100644 --- a/src/output/OssOutputPlugin.cxx +++ b/src/output/OssOutputPlugin.cxx @@ -727,6 +727,8 @@ oss_output_play(struct audio_output *ao, const void *chunk, size_t size, OssOutput *od = (OssOutput *)ao; ssize_t ret; + assert(size > 0); + /* reopen the device since it was closed by dropBufferedAudio */ if (od->fd < 0 && !oss_reopen(od, error)) return 0; @@ -735,6 +737,8 @@ oss_output_play(struct audio_output *ao, const void *chunk, size_t size, chunk = od->pcm_export->Export(chunk, size, size); #endif + assert(size > 0); + while (true) { ret = write(od->fd, chunk, size); if (ret > 0) { -- cgit v1.2.3 From 2406152576b512c6fedb4eb3b6d3849448d84e6b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 31 Aug 2014 13:58:04 +0200 Subject: output/alsa: fix endless loop at end of file in dsd_usb mode --- src/output/AlsaOutputPlugin.cxx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/output/AlsaOutputPlugin.cxx b/src/output/AlsaOutputPlugin.cxx index 76eea5bd6..f8aae13a1 100644 --- a/src/output/AlsaOutputPlugin.cxx +++ b/src/output/AlsaOutputPlugin.cxx @@ -815,7 +815,16 @@ alsa_play(struct audio_output *ao, const void *chunk, size_t size, } } + const size_t original_size = size; chunk = ad->pcm_export->Export(chunk, size, size); + if (size == 0) + /* the DoP (DSD over PCM) filter converts two frames + at a time and ignores the last odd frame; if there + was only one frame (e.g. the last frame in the + file), the result is empty; to avoid an endless + loop, bail out here, and pretend the one frame has + been played */ + return original_size; assert(size % ad->out_frame_size == 0); -- cgit v1.2.3 From 704be54c3a96c7a6bebdaa67711f7debe410a13f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 31 Aug 2014 14:23:06 +0200 Subject: PlaylistControl: move code to new method SeekSongOrder() --- src/Playlist.hxx | 4 ++++ src/PlaylistControl.cxx | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/Playlist.hxx b/src/Playlist.hxx index b660ecb40..582b3648a 100644 --- a/src/Playlist.hxx +++ b/src/Playlist.hxx @@ -234,6 +234,10 @@ public: void PlayPrevious(PlayerControl &pc); + PlaylistResult SeekSongOrder(PlayerControl &pc, + unsigned song_order, + float seek_time); + PlaylistResult SeekSongPosition(PlayerControl &pc, unsigned song_position, float seek_time); diff --git a/src/PlaylistControl.cxx b/src/PlaylistControl.cxx index 58971a4b4..df0496e7c 100644 --- a/src/PlaylistControl.cxx +++ b/src/PlaylistControl.cxx @@ -190,17 +190,12 @@ playlist::PlayPrevious(PlayerControl &pc) } PlaylistResult -playlist::SeekSongPosition(PlayerControl &pc, unsigned song, float seek_time) +playlist::SeekSongOrder(PlayerControl &pc, unsigned i, float seek_time) { - if (!queue.IsValidPosition(song)) - return PlaylistResult::BAD_RANGE; + assert(queue.IsValidOrder(i)); const Song *queued_song = GetQueuedSong(); - unsigned i = queue.random - ? queue.PositionToOrder(song) - : song; - pc.ClearError(); stop_on_error = true; error_count = 0; @@ -228,6 +223,19 @@ playlist::SeekSongPosition(PlayerControl &pc, unsigned song, float seek_time) return PlaylistResult::SUCCESS; } +PlaylistResult +playlist::SeekSongPosition(PlayerControl &pc, unsigned song, float seek_time) +{ + if (!queue.IsValidPosition(song)) + return PlaylistResult::BAD_RANGE; + + unsigned i = queue.random + ? queue.PositionToOrder(song) + : song; + + return SeekSongOrder(pc, i, seek_time); +} + PlaylistResult playlist::SeekSongId(PlayerControl &pc, unsigned id, float seek_time) { -- cgit v1.2.3 From a26ead035a4574bf2cae6b7fad661a1354ee8641 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 31 Aug 2014 14:44:20 +0200 Subject: PlaylistControl: use SeekSongOrder(current) to keep current song The "current" attribute is a "song order", not a "song position". This is usually the same - except in random mode. Fixes Mantis ticket 0004073. --- src/PlaylistControl.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/PlaylistControl.cxx b/src/PlaylistControl.cxx index df0496e7c..b0ff03a7e 100644 --- a/src/PlaylistControl.cxx +++ b/src/PlaylistControl.cxx @@ -265,5 +265,5 @@ playlist::SeekCurrent(PlayerControl &pc, float seek_time, bool relative) if (seek_time < 0) seek_time = 0; - return SeekSongPosition(pc, current, seek_time); + return SeekSongOrder(pc, current, seek_time); } -- cgit v1.2.3