mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
pulse-server: move parts of stream creation
Move some portions of the client creation logic into stream.c so that it is easier to keep it in sync with `stream_free()`, etc.
This commit is contained in:
parent
6d2e6fde75
commit
cc12188763
3 changed files with 60 additions and 54 deletions
|
|
@ -44,6 +44,51 @@
|
|||
#include "reply.h"
|
||||
#include "stream.h"
|
||||
|
||||
struct stream *stream_new(struct client *client, enum stream_type type, uint32_t create_tag,
|
||||
const struct sample_spec *ss, const struct channel_map *map,
|
||||
const struct buffer_attr *attr)
|
||||
{
|
||||
int res;
|
||||
|
||||
struct stream *stream = calloc(1, sizeof(*stream));
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
stream->channel = pw_map_insert_new(&client->streams, stream);
|
||||
if (stream->channel == SPA_ID_INVALID)
|
||||
goto error_errno;
|
||||
|
||||
stream->impl = client->impl;
|
||||
stream->client = client;
|
||||
stream->type = type;
|
||||
stream->create_tag = create_tag;
|
||||
stream->ss = *ss;
|
||||
stream->map = *map;
|
||||
stream->attr = *attr;
|
||||
spa_ringbuffer_init(&stream->ring);
|
||||
|
||||
switch (type) {
|
||||
case STREAM_TYPE_RECORD:
|
||||
stream->direction = PW_DIRECTION_INPUT;
|
||||
break;
|
||||
case STREAM_TYPE_PLAYBACK:
|
||||
case STREAM_TYPE_UPLOAD:
|
||||
stream->direction = PW_DIRECTION_OUTPUT;
|
||||
break;
|
||||
default:
|
||||
spa_assert_not_reached();
|
||||
}
|
||||
|
||||
return stream;
|
||||
|
||||
error_errno:
|
||||
res = errno;
|
||||
free(stream);
|
||||
errno = res;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void stream_free(struct stream *stream)
|
||||
{
|
||||
struct client *client = stream->client;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue