mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-14 08:15:02 -05:00
Remove player metadata event timer (use the existing instead)
This commit is contained in:
parent
0397b824a5
commit
99cda05dab
@ -204,10 +204,11 @@ stream_chunk_xcode_cb(int fd, short event, void *arg)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int xcoded;
|
int xcoded;
|
||||||
int ret;
|
int ret;
|
||||||
|
int dummy;
|
||||||
|
|
||||||
st = (struct stream_ctx *)arg;
|
st = (struct stream_ctx *)arg;
|
||||||
|
|
||||||
xcoded = transcode(st->xcode, st->evbuf, STREAM_CHUNK_SIZE);
|
xcoded = transcode(st->xcode, st->evbuf, STREAM_CHUNK_SIZE, &dummy);
|
||||||
if (xcoded <= 0)
|
if (xcoded <= 0)
|
||||||
{
|
{
|
||||||
if (xcoded == 0)
|
if (xcoded == 0)
|
||||||
|
61
src/player.c
61
src/player.c
@ -79,9 +79,6 @@
|
|||||||
#define MAX(a, b) ((a > b) ? a : b)
|
#define MAX(a, b) ((a > b) ? a : b)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Interval between ICY metadata polls for streams, in seconds */
|
|
||||||
#define METADATA_ICY_POLL 5
|
|
||||||
|
|
||||||
enum player_sync_source
|
enum player_sync_source
|
||||||
{
|
{
|
||||||
PLAYER_SYNC_CLOCK,
|
PLAYER_SYNC_CLOCK,
|
||||||
@ -203,7 +200,6 @@ static int cmd_pipe[2];
|
|||||||
static int player_exit;
|
static int player_exit;
|
||||||
static struct event *exitev;
|
static struct event *exitev;
|
||||||
static struct event *cmdev;
|
static struct event *cmdev;
|
||||||
static struct event *metaev;
|
|
||||||
static pthread_t tid_player;
|
static pthread_t tid_player;
|
||||||
|
|
||||||
/* Player status */
|
/* Player status */
|
||||||
@ -725,26 +721,16 @@ metadata_trigger(struct player_source *ps, int startup)
|
|||||||
worker_execute(metadata_prepare_cb, &pmd, sizeof(struct player_metadata), 0);
|
worker_execute(metadata_prepare_cb, &pmd, sizeof(struct player_metadata), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Checks if there is new HTTP ICY metadata, and if so sends updates to clients */
|
||||||
metadata_icy_poll_cb(int fd, short what, void *arg)
|
void
|
||||||
|
metadata_check_icy(void)
|
||||||
{
|
{
|
||||||
struct timeval tv = { METADATA_ICY_POLL, 0 };
|
|
||||||
struct http_icy_metadata *metadata;
|
struct http_icy_metadata *metadata;
|
||||||
int changed;
|
int changed;
|
||||||
|
|
||||||
/* Playback of stream has stopped, so stop polling */
|
|
||||||
if (!cur_streaming || cur_streaming->type != SOURCE_HTTP || !cur_streaming->ctx)
|
|
||||||
{
|
|
||||||
if (metaev)
|
|
||||||
event_free(metaev);
|
|
||||||
|
|
||||||
metaev = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
transcode_metadata(cur_streaming->ctx, &metadata, &changed);
|
transcode_metadata(cur_streaming->ctx, &metadata, &changed);
|
||||||
if (!metadata)
|
if (!metadata)
|
||||||
goto no_metadata;
|
return;
|
||||||
|
|
||||||
if (!changed)
|
if (!changed)
|
||||||
goto no_update;
|
goto no_update;
|
||||||
@ -754,38 +740,18 @@ metadata_icy_poll_cb(int fd, short what, void *arg)
|
|||||||
/* Defer the database update to the worker thread */
|
/* Defer the database update to the worker thread */
|
||||||
worker_execute(update_icy_cb, metadata, sizeof(struct http_icy_metadata), 0);
|
worker_execute(update_icy_cb, metadata, sizeof(struct http_icy_metadata), 0);
|
||||||
|
|
||||||
status_update(player_state);
|
/* Triggers preparing and sending RAOP metadata */
|
||||||
metadata_trigger(cur_streaming, 0);
|
metadata_trigger(cur_streaming, 0);
|
||||||
|
|
||||||
/* Only free the struct, the content must be preserved for update_icy_cb */
|
/* Only free the struct, the content must be preserved for update_icy_cb */
|
||||||
free(metadata);
|
free(metadata);
|
||||||
|
|
||||||
evtimer_add(metaev, &tv);
|
status_update(player_state);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
no_update:
|
no_update:
|
||||||
http_icy_metadata_free(metadata, 0);
|
http_icy_metadata_free(metadata, 0);
|
||||||
|
|
||||||
no_metadata:
|
|
||||||
evtimer_add(metaev, &tv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
metadata_icy_poll_start(void)
|
|
||||||
{
|
|
||||||
struct timeval tv = { METADATA_ICY_POLL, 0 };
|
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_PLAYER, "Starting ICY polling\n");
|
|
||||||
|
|
||||||
if (metaev)
|
|
||||||
return;
|
|
||||||
|
|
||||||
metaev = evtimer_new(evbase_player, metadata_icy_poll_cb, NULL);
|
|
||||||
if (!metaev)
|
|
||||||
return;
|
|
||||||
|
|
||||||
evtimer_add(metaev, &tv);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Audio sources */
|
/* Audio sources */
|
||||||
@ -1415,10 +1381,6 @@ source_open(struct player_source *ps, int no_md)
|
|||||||
mfi->path = url;
|
mfi->path = url;
|
||||||
|
|
||||||
ret = transcode_setup(&ps->ctx, mfi, NULL, 0);
|
ret = transcode_setup(&ps->ctx, mfi, NULL, 0);
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
metadata_icy_poll_start();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
@ -1849,6 +1811,7 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
|
|||||||
int new;
|
int new;
|
||||||
int ret;
|
int ret;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
int icy_timer;
|
||||||
|
|
||||||
if (!cur_streaming)
|
if (!cur_streaming)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1875,9 +1838,15 @@ source_read(uint8_t *buf, int len, uint64_t rtptime)
|
|||||||
{
|
{
|
||||||
switch (cur_streaming->type)
|
switch (cur_streaming->type)
|
||||||
{
|
{
|
||||||
case SOURCE_FILE:
|
|
||||||
case SOURCE_HTTP:
|
case SOURCE_HTTP:
|
||||||
ret = transcode(cur_streaming->ctx, audio_buf, len - nbytes);
|
ret = transcode(cur_streaming->ctx, audio_buf, len - nbytes, &icy_timer);
|
||||||
|
|
||||||
|
if (icy_timer)
|
||||||
|
metadata_check_icy();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SOURCE_FILE:
|
||||||
|
ret = transcode(cur_streaming->ctx, audio_buf, len - nbytes, &icy_timer);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef HAVE_SPOTIFY_H
|
#ifdef HAVE_SPOTIFY_H
|
||||||
|
@ -63,6 +63,8 @@
|
|||||||
# define XCODE_BUFFER_SIZE ((AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2)
|
# define XCODE_BUFFER_SIZE ((AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Interval between ICY metadata checks for streams, in seconds */
|
||||||
|
#define METADATA_ICY_INTERVAL 5
|
||||||
|
|
||||||
struct transcode_ctx {
|
struct transcode_ctx {
|
||||||
AVFormatContext *fmtctx;
|
AVFormatContext *fmtctx;
|
||||||
@ -153,7 +155,7 @@ make_wav_header(struct transcode_ctx *ctx, off_t *est_size)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted)
|
transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted, int *icy_timer)
|
||||||
{
|
{
|
||||||
int16_t *buf;
|
int16_t *buf;
|
||||||
int buflen;
|
int buflen;
|
||||||
@ -393,6 +395,7 @@ transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted)
|
|||||||
av_free(frame);
|
av_free(frame);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
*icy_timer = (ctx->offset % (METADATA_ICY_INTERVAL * 2 * 2 * 44100) < processed);
|
||||||
return processed;
|
return processed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
struct transcode_ctx;
|
struct transcode_ctx;
|
||||||
|
|
||||||
int
|
int
|
||||||
transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted);
|
transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted, int *icy_timer);
|
||||||
|
|
||||||
int
|
int
|
||||||
transcode_seek(struct transcode_ctx *ctx, int ms);
|
transcode_seek(struct transcode_ctx *ctx, int ms);
|
||||||
|
Loading…
Reference in New Issue
Block a user