[pulseaudio-commits] r1250 - in /trunk/src: modules/rtp/module-rtp-send.c pulsecore/cli-text.c pulsecore/protocol-esound.c pulsecore/protocol-native.c pulsecore/protocol-simple.c pulsecore/sink-input.h pulsecore/source-output.c pulsecore/source-output.h
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun Aug 13 12:55:18 PDT 2006
Author: lennart
Date: Sun Aug 13 21:55:17 2006
New Revision: 1250
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1250&root=pulseaudio&view=rev
Log:
implement hook_source_ouput_new. For this I modified the pa_source_output_new constructor to take a struct similar to what I already did for pa_sink_input_new()
Modified:
trunk/src/modules/rtp/module-rtp-send.c
trunk/src/pulsecore/cli-text.c
trunk/src/pulsecore/protocol-esound.c
trunk/src/pulsecore/protocol-native.c
trunk/src/pulsecore/protocol-simple.c
trunk/src/pulsecore/sink-input.h
trunk/src/pulsecore/source-output.c
trunk/src/pulsecore/source-output.h
Modified: trunk/src/modules/rtp/module-rtp-send.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/rtp/module-rtp-send.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/modules/rtp/module-rtp-send.c (original)
+++ trunk/src/modules/rtp/module-rtp-send.c Sun Aug 13 21:55:17 2006
@@ -168,6 +168,7 @@
struct timeval tv;
char hn[128], *n;
int loop = 0;
+ pa_source_output_new_data data;
assert(c);
assert(m);
@@ -263,8 +264,15 @@
pa_log(__FILE__": IP_MULTICAST_LOOP failed: %s", pa_cstrerror(errno));
goto fail;
}
-
- if (!(o = pa_source_output_new(s, __FILE__, "RTP Monitor Stream", &ss, &cm, PA_RESAMPLER_INVALID))) {
+
+ pa_source_output_new_data_init(&data);
+ data.name = "RTP Monitor Stream";
+ data.driver = __FILE__;
+ data.module = m;
+ pa_source_output_new_data_set_sample_spec(&data, &ss);
+ pa_source_output_new_data_set_channel_map(&data, &cm);
+
+ if (!(o = pa_source_output_new(c, &data, 0))) {
pa_log(__FILE__": failed to create source output.");
goto fail;
}
@@ -272,7 +280,6 @@
o->push = source_output_push;
o->kill = source_output_kill;
o->get_latency = source_output_get_latency;
- o->owner = m;
u = pa_xnew(struct userdata, 1);
m->userdata = u;
Modified: trunk/src/pulsecore/cli-text.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/cli-text.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/cli-text.c (original)
+++ trunk/src/pulsecore/cli-text.c Sun Aug 13 21:55:17 2006
@@ -204,8 +204,8 @@
pa_sample_spec_snprint(ss, sizeof(ss), &o->sample_spec),
pa_channel_map_snprint(cm, sizeof(cm), &o->channel_map),
pa_resample_method_to_string(pa_source_output_get_resample_method(o)));
- if (o->owner)
- pa_strbuf_printf(s, "\towner module: <%u>\n", o->owner->index);
+ if (o->module)
+ pa_strbuf_printf(s, "\towner module: <%u>\n", o->module->index);
if (o->client)
pa_strbuf_printf(s, "\tclient: <%u> '%s'\n", o->client->index, o->client->name);
}
Modified: trunk/src/pulsecore/protocol-esound.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-esound.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-esound.c (original)
+++ trunk/src/pulsecore/protocol-esound.c Sun Aug 13 21:55:17 2006
@@ -349,9 +349,11 @@
strncpy(name, data, sizeof(name));
name[sizeof(name)-1] = 0;
+
utf8_name = pa_utf8_filter(name);
-
pa_client_set_name(c->client, utf8_name);
+ pa_xfree(utf8_name);
+
c->original_name = pa_xstrdup(name);
assert(!c->sink_input && !c->input_memblockq);
@@ -359,15 +361,12 @@
pa_sink_input_new_data_init(&sdata);
sdata.sink = sink;
sdata.driver = __FILE__;
- sdata.name = utf8_name;
+ sdata.name = c->client->name;
pa_sink_input_new_data_set_sample_spec(&sdata, &ss);
sdata.module = c->protocol->module;
sdata.client = c->client;
c->sink_input = pa_sink_input_new(c->protocol->core, &sdata, 0);
-
- pa_xfree(utf8_name);
-
CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
l = (size_t) (pa_bytes_per_second(&ss)*PLAYBACK_BUFFER_SECONDS);
@@ -402,6 +401,7 @@
pa_source *source;
pa_sample_spec ss;
size_t l;
+ pa_source_output_new_data sdata;
assert(c && length == (sizeof(int32_t)*2+ESD_NAME_MAX));
@@ -450,10 +450,16 @@
assert(!c->output_memblockq && !c->source_output);
- if (!(c->source_output = pa_source_output_new(source, __FILE__, c->client->name, &ss, NULL, -1))) {
- pa_log(__FILE__": failed to create source output");
- return -1;
- }
+ pa_source_output_new_data_init(&sdata);
+ sdata.source = source;
+ sdata.driver = __FILE__;
+ sdata.name = c->client->name;
+ pa_source_output_new_data_set_sample_spec(&sdata, &ss);
+ sdata.module = c->protocol->module;
+ sdata.client = c->client;
+
+ c->source_output = pa_source_output_new(c->protocol->core, &sdata, 9);
+ CHECK_VALIDITY(c->sink_input, "Failed to create source_output.");
l = (size_t) (pa_bytes_per_second(&ss)*RECORD_BUFFER_SECONDS);
c->output_memblockq = pa_memblockq_new(
@@ -467,8 +473,6 @@
c->protocol->core->memblock_stat);
pa_iochannel_socket_set_sndbuf(c->io, l/RECORD_BUFFER_FRAGMENTS*2);
- c->source_output->owner = c->protocol->module;
- c->source_output->client = c->client;
c->source_output->push = source_output_push_cb;
c->source_output->kill = source_output_kill_cb;
c->source_output->get_latency = source_output_get_latency_cb;
Modified: trunk/src/pulsecore/protocol-native.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-native.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-native.c (original)
+++ trunk/src/pulsecore/protocol-native.c Sun Aug 13 21:55:17 2006
@@ -317,9 +317,20 @@
struct record_stream *s;
pa_source_output *source_output;
size_t base;
+ pa_source_output_new_data data;
+
assert(c && source && ss && name && maxlength);
- if (!(source_output = pa_source_output_new(source, __FILE__, name, ss, map, -1)))
+ pa_source_output_new_data_init(&data);
+ data.source = source;
+ data.driver = __FILE__;
+ data.name = name;
+ pa_source_output_new_data_set_sample_spec(&data, ss);
+ pa_source_output_new_data_set_channel_map(&data, map);
+ data.module = c->protocol->module;
+ data.client = c->client;
+
+ if (!(source_output = pa_source_output_new(source->core, &data, 0)))
return NULL;
s = pa_xnew(struct record_stream, 1);
@@ -329,8 +340,6 @@
s->source_output->kill = source_output_kill_cb;
s->source_output->get_latency = source_output_get_latency_cb;
s->source_output->userdata = s;
- s->source_output->owner = c->protocol->module;
- s->source_output->client = c->client;
s->memblockq = pa_memblockq_new(
0,
@@ -1356,7 +1365,7 @@
assert(t && s);
pa_tagstruct_putu32(t, s->index);
pa_tagstruct_puts(t, s->name);
- pa_tagstruct_putu32(t, s->owner ? s->owner->index : PA_INVALID_INDEX);
+ pa_tagstruct_putu32(t, s->module ? s->module->index : PA_INVALID_INDEX);
pa_tagstruct_putu32(t, s->client ? s->client->index : PA_INVALID_INDEX);
pa_tagstruct_putu32(t, s->source->index);
pa_tagstruct_put_sample_spec(t, &s->sample_spec);
Modified: trunk/src/pulsecore/protocol-simple.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/protocol-simple.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/protocol-simple.c (original)
+++ trunk/src/pulsecore/protocol-simple.c Sun Aug 13 21:55:17 2006
@@ -379,22 +379,20 @@
}
if (p->mode & RECORD) {
- pa_source *source;
+ pa_source_output_new_data data;
size_t l;
- if (!(source = pa_namereg_get(p->core, p->source_name, PA_NAMEREG_SOURCE, 1))) {
- pa_log(__FILE__": Failed to get source.");
- goto fail;
- }
-
- c->source_output = pa_source_output_new(source, __FILE__, c->client->name, &p->sample_spec, NULL, -1);
- if (!c->source_output) {
+ pa_source_output_new_data_init(&data);
+ data.driver = __FILE__;
+ data.name = c->client->name;
+ pa_source_output_new_data_set_sample_spec(&data, &p->sample_spec);
+ data.module = p->module;
+ data.client = c->client;
+
+ if (!(c->source_output = pa_source_output_new(p->core, &data, 0))) {
pa_log(__FILE__": Failed to create source output.");
goto fail;
}
- c->source_output->owner = p->module;
- c->source_output->client = c->client;
-
c->source_output->push = source_output_push_cb;
c->source_output->kill = source_output_kill_cb;
c->source_output->get_latency = source_output_get_latency_cb;
@@ -411,6 +409,7 @@
NULL,
p->core->memblock_stat);
pa_iochannel_socket_set_sndbuf(io, l/RECORD_BUFFER_FRAGMENTS*2);
+ pa_source_notify(c->source_output->source);
}
pa_iochannel_set_callback(c->io, io_callback, c);
Modified: trunk/src/pulsecore/sink-input.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/sink-input.h?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/sink-input.h (original)
+++ trunk/src/pulsecore/sink-input.h Sun Aug 13 21:55:17 2006
@@ -106,7 +106,10 @@
void pa_sink_input_new_data_set_channel_map(pa_sink_input_new_data *data, const pa_channel_map *map);
void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cvolume *volume);
-pa_sink_input* pa_sink_input_new(pa_core *core, pa_sink_input_new_data *data, pa_sink_input_flags_t flags);
+pa_sink_input* pa_sink_input_new(
+ pa_core *core,
+ pa_sink_input_new_data *data,
+ pa_sink_input_flags_t flags);
void pa_sink_input_unref(pa_sink_input* i);
pa_sink_input* pa_sink_input_ref(pa_sink_input* i);
Modified: trunk/src/pulsecore/source-output.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/source-output.c?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/source-output.c (original)
+++ trunk/src/pulsecore/source-output.c Sun Aug 13 21:55:17 2006
@@ -33,6 +33,7 @@
#include <pulsecore/core-subscribe.h>
#include <pulsecore/log.h>
+#include <pulsecore/namereg.h>
#include "source-output.h"
@@ -42,44 +43,82 @@
return NULL; \
} while (0)
+pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output_new_data *data) {
+ assert(data);
+
+ memset(data, 0, sizeof(*data));
+ data->resample_method = PA_RESAMPLER_INVALID;
+ return data;
+}
+
+void pa_source_output_new_data_set_channel_map(pa_source_output_new_data *data, const pa_channel_map *map) {
+ assert(data);
+
+ if ((data->channel_map_is_set = !!map))
+ data->channel_map = *map;
+}
+
+void pa_source_output_new_data_set_sample_spec(pa_source_output_new_data *data, const pa_sample_spec *spec) {
+ assert(data);
+
+ if ((data->sample_spec_is_set = !!spec))
+ data->sample_spec = *spec;
+}
+
pa_source_output* pa_source_output_new(
- pa_source *s,
- const char *driver,
- const char *name,
- const pa_sample_spec *spec,
- const pa_channel_map *map,
- int resample_method) {
+ pa_core *core,
+ pa_source_output_new_data *data,
+ pa_source_output_flags_t flags) {
pa_source_output *o;
pa_resampler *resampler = NULL;
int r;
- char st[256];
- pa_channel_map tmap;
-
- assert(s);
- assert(spec);
- assert(s->state == PA_SOURCE_RUNNING);
-
- CHECK_VALIDITY_RETURN_NULL(pa_sample_spec_valid(spec));
-
- if (!map)
- map = pa_channel_map_init_auto(&tmap, spec->channels, PA_CHANNEL_MAP_DEFAULT);
-
- CHECK_VALIDITY_RETURN_NULL(map && pa_channel_map_valid(map));
- CHECK_VALIDITY_RETURN_NULL(map->channels == spec->channels);
- CHECK_VALIDITY_RETURN_NULL(!driver || pa_utf8_valid(driver));
- CHECK_VALIDITY_RETURN_NULL(pa_utf8_valid(name));
-
- if (pa_idxset_size(s->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
+ char st[PA_SAMPLE_SPEC_SNPRINT_MAX];
+
+ assert(core);
+ assert(data);
+
+ if (!(flags & PA_SOURCE_OUTPUT_NO_HOOKS))
+ if (pa_hook_fire(&core->hook_source_output_new, data) < 0)
+ return NULL;
+
+ CHECK_VALIDITY_RETURN_NULL(!data->driver || pa_utf8_valid(data->driver));
+ CHECK_VALIDITY_RETURN_NULL(!data->name || pa_utf8_valid(data->name));
+
+ if (!data->source)
+ data->source = pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE, 1);
+
+ CHECK_VALIDITY_RETURN_NULL(data->source);
+ CHECK_VALIDITY_RETURN_NULL(data->source->state == PA_SOURCE_RUNNING);
+
+ if (!data->sample_spec_is_set)
+ data->sample_spec = data->source->sample_spec;
+
+ CHECK_VALIDITY_RETURN_NULL(pa_sample_spec_valid(&data->sample_spec));
+
+ if (!data->channel_map_is_set)
+ pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
+
+ CHECK_VALIDITY_RETURN_NULL(pa_channel_map_valid(&data->channel_map));
+ CHECK_VALIDITY_RETURN_NULL(data->channel_map.channels == data->sample_spec.channels);
+
+ if (data->resample_method == PA_RESAMPLER_INVALID)
+ data->resample_method = core->resample_method;
+
+ CHECK_VALIDITY_RETURN_NULL(data->resample_method < PA_RESAMPLER_MAX);
+
+ if (pa_idxset_size(data->source->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
pa_log(__FILE__": Failed to create source output: too many outputs per source.");
return NULL;
}
- if (resample_method == PA_RESAMPLER_INVALID)
- resample_method = s->core->resample_method;
-
- if (!pa_sample_spec_equal(&s->sample_spec, spec) || !pa_channel_map_equal(&s->channel_map, map))
- if (!(resampler = pa_resampler_new(&s->sample_spec, &s->channel_map, spec, map, s->core->memblock_stat, resample_method))) {
+ if (!pa_sample_spec_equal(&data->sample_spec, &data->source->sample_spec) ||
+ !pa_channel_map_equal(&data->channel_map, &data->source->channel_map))
+ if (!(resampler = pa_resampler_new(
+ &data->source->sample_spec, &data->source->channel_map,
+ &data->sample_spec, &data->channel_map,
+ core->memblock_stat,
+ data->resample_method))) {
pa_log_warn(__FILE__": Unsupported resampling operation.");
return NULL;
}
@@ -87,14 +126,14 @@
o = pa_xnew(pa_source_output, 1);
o->ref = 1;
o->state = PA_SOURCE_OUTPUT_RUNNING;
- o->name = pa_xstrdup(name);
- o->driver = pa_xstrdup(driver);
- o->owner = NULL;
- o->source = s;
- o->client = NULL;
-
- o->sample_spec = *spec;
- o->channel_map = *map;
+ o->name = pa_xstrdup(data->name);
+ o->driver = pa_xstrdup(data->driver);
+ o->module = data->module;
+ o->source = data->source;
+ o->client = data->client;
+
+ o->sample_spec = data->sample_spec;
+ o->channel_map = data->channel_map;
o->push = NULL;
o->kill = NULL;
@@ -102,18 +141,20 @@
o->userdata = NULL;
o->resampler = resampler;
- o->resample_method = resample_method;
-
- assert(s->core);
- r = pa_idxset_put(s->core->source_outputs, o, &o->index);
- assert(r == 0 && o->index != PA_IDXSET_INVALID);
- r = pa_idxset_put(s->outputs, o, NULL);
+ o->resample_method = data->resample_method;
+
+ r = pa_idxset_put(core->source_outputs, o, &o->index);
assert(r == 0);
-
- pa_sample_spec_snprint(st, sizeof(st), spec);
- pa_log_info(__FILE__": created %u \"%s\" on %u with sample spec \"%s\"", o->index, o->name, s->index, st);
-
- pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
+ r = pa_idxset_put(o->source->outputs, o, NULL);
+ assert(r == 0);
+
+ pa_log_info(__FILE__": created %u \"%s\" on %s with sample spec %s",
+ o->index,
+ o->name,
+ o->source->name,
+ pa_sample_spec_snprint(st, sizeof(st), &o->sample_spec));
+
+ pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
/* We do not call pa_source_notify() here, because the virtual
* functions have not yet been initialized */
Modified: trunk/src/pulsecore/source-output.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/source-output.h?rev=1250&root=pulseaudio&r1=1249&r2=1250&view=diff
==============================================================================
--- trunk/src/pulsecore/source-output.h (original)
+++ trunk/src/pulsecore/source-output.h Sun Aug 13 21:55:17 2006
@@ -39,13 +39,17 @@
PA_SOURCE_OUTPUT_DISCONNECTED
} pa_source_output_state_t;
+typedef enum pa_source_output_flags {
+ PA_SOURCE_OUTPUT_NO_HOOKS = 1
+} pa_source_output_flags_t;
+
struct pa_source_output {
int ref;
uint32_t index;
pa_source_output_state_t state;
char *name, *driver; /* may be NULL */
- pa_module *owner; /* may be NULL */
+ pa_module *module; /* may be NULL */
pa_source *source;
pa_client *client; /* may be NULL */
@@ -63,13 +67,30 @@
void *userdata;
};
+typedef struct pa_source_output_new_data {
+ const char *name, *driver;
+ pa_module *module;
+ pa_client *client;
+
+ pa_source *source;
+
+ pa_sample_spec sample_spec;
+ int sample_spec_is_set;
+ pa_channel_map channel_map;
+ int channel_map_is_set;
+
+ pa_resample_method_t resample_method;
+} pa_source_output_new_data;
+
+pa_source_output_new_data* pa_source_output_new_data_init(pa_source_output_new_data *data);
+void pa_source_output_new_data_set_sample_spec(pa_source_output_new_data *data, const pa_sample_spec *spec);
+void pa_source_output_new_data_set_channel_map(pa_source_output_new_data *data, const pa_channel_map *map);
+void pa_source_output_new_data_set_volume(pa_source_output_new_data *data, const pa_cvolume *volume);
+
pa_source_output* pa_source_output_new(
- pa_source *s,
- const char *driver,
- const char *name,
- const pa_sample_spec *spec,
- const pa_channel_map *map,
- int resample_method);
+ pa_core *core,
+ pa_source_output_new_data *data,
+ pa_source_output_flags_t flags);
void pa_source_output_unref(pa_source_output* o);
pa_source_output* pa_source_output_ref(pa_source_output *o);
More information about the pulseaudio-commits
mailing list