mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: make method to pause/resume stream
Make a method to pause and resume a stream and keep track of the paused state of the stream. Use this function instead of setting the stream inactive/active so that we get nice logging for each state change.
This commit is contained in:
parent
4c3f56fca1
commit
fc159be9c6
3 changed files with 21 additions and 4 deletions
|
|
@ -1241,7 +1241,7 @@ static void stream_param_changed(void *data, uint32_t id, const struct spa_pod *
|
|||
SPA_PROP_mute, 1, &val, 0);
|
||||
}
|
||||
if (stream->corked)
|
||||
pw_stream_set_active(stream->stream, false);
|
||||
stream_set_paused(stream, true, "cork after create");
|
||||
|
||||
/* if peer exists, reply immediately, otherwise reply when the link is created */
|
||||
peer = find_linked(stream->client->manager, stream->id, stream->direction);
|
||||
|
|
@ -1524,7 +1524,7 @@ static void stream_drained(void *data)
|
|||
reply_simple_ack(stream->client, stream->drain_tag);
|
||||
stream->drain_tag = 0;
|
||||
|
||||
pw_stream_set_active(stream->stream, true);
|
||||
stream_set_paused(stream, false, "complete drain");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2702,7 +2702,7 @@ static int do_cork_stream(struct client *client, uint32_t command, uint32_t tag,
|
|||
return -ENOENT;
|
||||
|
||||
stream->corked = cork;
|
||||
pw_stream_set_active(stream->stream, !cork);
|
||||
stream_set_paused(stream, cork, "cork request");
|
||||
if (cork) {
|
||||
stream->is_underrun = true;
|
||||
} else {
|
||||
|
|
@ -3462,7 +3462,7 @@ static int do_drain_stream(struct client *client, uint32_t command, uint32_t tag
|
|||
|
||||
stream->drain_tag = tag;
|
||||
stream->draining = true;
|
||||
pw_stream_set_active(stream->stream, true);
|
||||
stream_set_paused(stream, false, "drain start");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,6 +207,20 @@ uint32_t stream_pop_missing(struct stream *stream)
|
|||
return missing;
|
||||
}
|
||||
|
||||
void stream_set_paused(struct stream *stream, bool paused, const char *reason)
|
||||
{
|
||||
if (stream->is_paused == paused)
|
||||
return;
|
||||
|
||||
if (reason && stream->client)
|
||||
pw_log_info("%p: [%s] %s because of %s",
|
||||
stream, stream->client->name,
|
||||
paused ? "paused" : "resumed", reason);
|
||||
|
||||
stream->is_paused = paused;
|
||||
pw_stream_set_active(stream->stream, !paused);
|
||||
}
|
||||
|
||||
int stream_send_underflow(struct stream *stream, int64_t offset)
|
||||
{
|
||||
struct client *client = stream->client;
|
||||
|
|
|
|||
|
|
@ -115,6 +115,7 @@ struct stream {
|
|||
unsigned int in_prebuf:1;
|
||||
unsigned int killed:1;
|
||||
unsigned int pending:1;
|
||||
unsigned int is_paused:1;
|
||||
};
|
||||
|
||||
struct stream *stream_new(struct client *client, enum stream_type type, uint32_t create_tag,
|
||||
|
|
@ -124,6 +125,8 @@ void stream_free(struct stream *stream);
|
|||
void stream_flush(struct stream *stream);
|
||||
uint32_t stream_pop_missing(struct stream *stream);
|
||||
|
||||
void stream_set_paused(struct stream *stream, bool paused, const char *reason);
|
||||
|
||||
int stream_send_underflow(struct stream *stream, int64_t offset);
|
||||
int stream_send_overflow(struct stream *stream);
|
||||
int stream_send_killed(struct stream *stream);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue