Skip to content

DB_EV_SONGSTARTED and DB_EV_SONGFINISHED firing multiple times #3180

@EDT4

Description

@EDT4

If I let a song finish by itself and it jumps to the next one in the playlist, the DB_EV_SONGSTARTED and DB_EV_SONGFINISHED events are fired multiple times in succession.

Tested using deadbeef-static-devel nightly build from 2025-04-10, default settings and plugins + the following plugin to print the events:

#include <deadbeef/deadbeef.h>

DB_functions_t *deadbeef;
DB_misc_t plugin;

static int on_message(uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2){
	switch(id){
		case DB_EV_SONGSTARTED: {
			ddb_playItem_t *item = ((ddb_event_track_t *)ctx)->track;
			const char* uri = deadbeef->pl_find_meta(item,":URI");
			printf("SONG STARTED: %s\n",uri);
			break;
		}
		case DB_EV_SONGFINISHED: {
			ddb_playItem_t *item = ((ddb_event_track_t *)ctx)->track;
			const char* uri = deadbeef->pl_find_meta(item,":URI");
			printf("SONG FINISHED: %s\n",uri);
			break;
		}
	}
	return 0;
}

DB_misc_t plugin = {
	.plugin.api_vmajor = DB_API_VERSION_MAJOR,
	.plugin.api_vminor = DB_API_VERSION_MINOR,
	.plugin.version_major = 1,
	.plugin.version_minor = 0,
	.plugin.type = DB_PLUGIN_MISC,
	.plugin.name = "print_events",
	.plugin.descr = "Test.",
	.plugin.copyright = "",
	.plugin.website = "",
	.plugin.message = on_message,
	.plugin.flags = DDB_PLUGIN_FLAG_LOGGING,
};

DB_plugin_t *ddb_print_events_load(DB_functions_t *api){
	deadbeef = api;
	return DB_PLUGIN(&plugin);
}

With two songs in a playlist, a.mp3 and b.mp3, when a.mp3 ends and b.mp3 starts the following is printed:

SONG FINISHED: a.mp3
SONG STARTED: b.mp3
SONG FINISHED: b.mp3
SONG STARTED: b.mp3
SONG FINISHED: b.mp3
SONG STARTED: b.mp3

Expected output:

SONG FINISHED: a.mp3
SONG STARTED: b.mp3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions