Merge branch 'pulse-samplefix' into 'master'

pulse-server: use timeout also for creating sample-play streams

See merge request pipewire/pipewire!2680
This commit is contained in:
P V 2026-02-02 11:25:04 +00:00
commit 4fc294edd8
4 changed files with 29 additions and 1 deletions

View file

@ -39,6 +39,8 @@
#define MODULE_INDEX_MASK 0xfffffffu #define MODULE_INDEX_MASK 0xfffffffu
#define MODULE_FLAG (1u << 29) #define MODULE_FLAG (1u << 29)
#define STREAM_CREATE_TIMEOUT (35 * SPA_NSEC_PER_SEC)
#define DEFAULT_SINK "@DEFAULT_SINK@" #define DEFAULT_SINK "@DEFAULT_SINK@"
#define DEFAULT_SOURCE "@DEFAULT_SOURCE@" #define DEFAULT_SOURCE "@DEFAULT_SOURCE@"
#define DEFAULT_MONITOR "@DEFAULT_MONITOR@" #define DEFAULT_MONITOR "@DEFAULT_MONITOR@"

View file

@ -17,10 +17,12 @@
#include <pipewire/properties.h> #include <pipewire/properties.h>
#include <pipewire/stream.h> #include <pipewire/stream.h>
#include "defs.h"
#include "format.h" #include "format.h"
#include "log.h" #include "log.h"
#include "sample.h" #include "sample.h"
#include "sample-play.h" #include "sample-play.h"
#include "internal.h"
static void sample_play_stream_state_changed(void *data, enum pw_stream_state old, static void sample_play_stream_state_changed(void *data, enum pw_stream_state old,
enum pw_stream_state state, const char *error) enum pw_stream_state state, const char *error)
@ -30,17 +32,32 @@ static void sample_play_stream_state_changed(void *data, enum pw_stream_state ol
switch (state) { switch (state) {
case PW_STREAM_STATE_UNCONNECTED: case PW_STREAM_STATE_UNCONNECTED:
case PW_STREAM_STATE_ERROR: case PW_STREAM_STATE_ERROR:
pw_timer_queue_cancel(&p->timer);
sample_play_emit_done(p, -EIO); sample_play_emit_done(p, -EIO);
break; break;
case PW_STREAM_STATE_PAUSED: case PW_STREAM_STATE_PAUSED:
p->id = pw_stream_get_node_id(p->stream); p->id = pw_stream_get_node_id(p->stream);
sample_play_emit_ready(p, p->id); sample_play_emit_ready(p, p->id);
break; break;
case PW_STREAM_STATE_STREAMING:
pw_timer_queue_cancel(&p->timer);
break;
default: default:
break; break;
} }
} }
static void sample_play_start_timeout(void *user_data)
{
struct sample_play *p = user_data;
pw_log_info("timeout on sample %s", p->sample->name);
if (p->stream)
pw_stream_set_active(p->stream, false);
sample_play_emit_done(p, -ETIMEDOUT);
}
static void sample_play_stream_destroy(void *data) static void sample_play_stream_destroy(void *data)
{ {
struct sample_play *p = data; struct sample_play *p = data;
@ -163,6 +180,10 @@ struct sample_play *sample_play_new(struct pw_core *core,
if (res < 0) if (res < 0)
goto error_cleanup; goto error_cleanup;
/* Time out if we don't get a link; same timeout as for normal streams */
pw_timer_queue_add(sample->impl->timer_queue, &p->timer, NULL,
STREAM_CREATE_TIMEOUT, sample_play_start_timeout, p);
return p; return p;
error_cleanup: error_cleanup:
@ -181,6 +202,8 @@ void sample_play_destroy(struct sample_play *p)
spa_hook_list_clean(&p->hooks); spa_hook_list_clean(&p->hooks);
pw_timer_queue_cancel(&p->timer);
free(p); free(p);
} }

View file

@ -11,6 +11,8 @@
#include <spa/utils/list.h> #include <spa/utils/list.h>
#include <spa/utils/hook.h> #include <spa/utils/hook.h>
#include <pipewire/pipewire.h>
struct sample; struct sample;
struct pw_core; struct pw_core;
struct pw_loop; struct pw_loop;
@ -41,6 +43,7 @@ struct sample_play {
uint32_t offset; uint32_t offset;
uint32_t stride; uint32_t stride;
struct spa_hook_list hooks; struct spa_hook_list hooks;
struct pw_timer timer;
void *user_data; void *user_data;
}; };

View file

@ -107,7 +107,7 @@ struct stream *stream_new(struct client *client, enum stream_type type, uint32_t
/* Time out if we don't get a link and can't send a reply to create in 35s. Client will time out in /* Time out if we don't get a link and can't send a reply to create in 35s. Client will time out in
* 30s and clean up its stream anyway. */ * 30s and clean up its stream anyway. */
pw_timer_queue_add(stream->impl->timer_queue, &stream->timer, NULL, pw_timer_queue_add(stream->impl->timer_queue, &stream->timer, NULL,
35 * SPA_NSEC_PER_SEC, create_stream_timeout, stream); STREAM_CREATE_TIMEOUT, create_stream_timeout, stream);
return stream; return stream;