[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-472-g08800c3

Lennart Poettering gitmailer-noreply at 0pointer.de
Mon Feb 2 18:14:29 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  e47d03dea446d0387a7c07a470c9c680537d9c34 (commit)

- Log -----------------------------------------------------------------
08800c3... make a couple of functions return proper error codes
162e43b... make a few functions return void where the retval isn't used/never != 0
50bfa77... add new error code PA_ERR_NOTIMPLEMENTED
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-combine.c      |    2 +-
 src/modules/module-ladspa-sink.c  |    2 +-
 src/modules/module-remap-sink.c   |    2 +-
 src/modules/module-sine.c         |    2 +-
 src/modules/rtp/module-rtp-recv.c |    2 +-
 src/modules/rtp/module-rtp-send.c |    2 +-
 src/pulse/def.h                   |    1 +
 src/pulse/error.c                 |    4 +-
 src/pulsecore/play-memblockq.c    |    2 +-
 src/pulsecore/protocol-esound.c   |    4 +-
 src/pulsecore/protocol-native.c   |   26 ++++++---
 src/pulsecore/protocol-simple.c   |    4 +-
 src/pulsecore/sink-input.c        |  103 ++++++++++++++++++-------------------
 src/pulsecore/sink-input.h        |    5 +-
 src/pulsecore/sink.c              |    3 +-
 src/pulsecore/sound-file-stream.c |    2 +-
 src/pulsecore/source-output.c     |   85 +++++++++++++++---------------
 src/pulsecore/source-output.h     |    3 +-
 18 files changed, 132 insertions(+), 122 deletions(-)

-----------------------------------------------------------------------

commit 50bfa774f69cd3ee62477f3d21f2b2b25e8d82c6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Feb 3 03:08:14 2009 +0100

    add new error code PA_ERR_NOTIMPLEMENTED

diff --git a/src/pulse/def.h b/src/pulse/def.h
index 85ac701..1acf19a 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -364,6 +364,7 @@ enum {
     PA_ERR_UNKNOWN,                /**< The error code was unknown to the client */
     PA_ERR_NOEXTENSION,            /**< Extension does not exist. \since 0.9.12 */
     PA_ERR_OBSOLETE,               /**< Obsolete functionality. \since 0.9.15 */
+    PA_ERR_NOTIMPLEMENTED,         /**< Missing implementation. \since 0.9.15 */
     PA_ERR_MAX                     /**< Not really an error but the first invalid error code */
 };
 
diff --git a/src/pulse/error.c b/src/pulse/error.c
index d9d0a8c..d37084b 100644
--- a/src/pulse/error.c
+++ b/src/pulse/error.c
@@ -61,7 +61,9 @@ const char*pa_strerror(int error) {
         [PA_ERR_TOOLARGE] = N_("Too large"),
         [PA_ERR_NOTSUPPORTED] = N_("Not supported"),
         [PA_ERR_UNKNOWN] = N_("Unknown error code"),
-        [PA_ERR_NOEXTENSION] = N_("No such extension")
+        [PA_ERR_NOEXTENSION] = N_("No such extension"),
+        [PA_ERR_OBSOLETE] = N_("Obsolete functionality"),
+        [PA_ERR_NOTIMPLEMENTED] = N_("Missing implementation")
     };
 
     pa_init_i18n();

commit 162e43b306eb28749f2ae1f9c51818e9ad427996
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Feb 3 03:11:31 2009 +0100

    make a few functions return void where the retval isn't used/never != 0

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 8bc434e..cc3e108 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -351,7 +351,7 @@ static void update_n_corked(pa_sink_input *i, pa_sink_input_state_t state) {
 }
 
 /* Called from main context */
-static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
+static void sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
     pa_sink_input *ssync;
     pa_assert(i);
 
@@ -359,7 +359,7 @@ static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
         state = PA_SINK_INPUT_RUNNING;
 
     if (i->state == state)
-        return 0;
+        return;
 
     pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
 
@@ -386,8 +386,6 @@ static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
     }
 
     pa_sink_update_status(i->sink);
-
-    return 0;
 }
 
 /* Called from main context */
@@ -553,7 +551,7 @@ pa_usec_t pa_sink_input_get_latency(pa_sink_input *i, pa_usec_t *sink_latency) {
 }
 
 /* Called from thread context */
-int pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa_memchunk *chunk, pa_cvolume *volume) {
+void pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa_memchunk *chunk, pa_cvolume *volume) {
     pa_bool_t do_volume_adj_here;
     pa_bool_t volume_is_norm;
     size_t block_size_max_sink, block_size_max_sink_input;
@@ -567,9 +565,6 @@ int pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa
 
 /*     pa_log_debug("peek"); */
 
-    if (!i->pop)
-        return -1;
-
     pa_assert(i->thread_info.state == PA_SINK_INPUT_RUNNING ||
               i->thread_info.state == PA_SINK_INPUT_CORKED ||
               i->thread_info.state == PA_SINK_INPUT_DRAINED);
@@ -696,8 +691,6 @@ int pa_sink_input_peek(pa_sink_input *i, size_t slength /* in sink frames */, pa
         pa_cvolume_mute(volume, i->sink->sample_spec.channels);
     else
         *volume = i->thread_info.soft_volume;
-
-    return 0;
 }
 
 /* Called from thread context */
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index a3b6b14..0c297ec 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -584,8 +584,7 @@ static unsigned fill_mix_info(pa_sink *s, size_t *length, pa_mix_info *info, uns
     while ((i = pa_hashmap_iterate(s->thread_info.inputs, &state, NULL)) && maxinfo > 0) {
         pa_sink_input_assert_ref(i);
 
-        if (pa_sink_input_peek(i, *length, &info->chunk, &info->volume) < 0)
-            continue;
+        pa_sink_input_peek(i, *length, &info->chunk, &info->volume);
 
         if (mixlength == 0 || info->chunk.length < mixlength)
             mixlength = info->chunk.length;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 9ef9b50..0204e30 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -265,11 +265,11 @@ static void update_n_corked(pa_source_output *o, pa_source_output_state_t state)
 }
 
 /* Called from main context */
-static int source_output_set_state(pa_source_output *o, pa_source_output_state_t state) {
+static void source_output_set_state(pa_source_output *o, pa_source_output_state_t state) {
     pa_assert(o);
 
     if (o->state == state)
-        return 0;
+        return;
 
     pa_assert_se(pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o), PA_SOURCE_OUTPUT_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) == 0);
 
@@ -280,8 +280,6 @@ static int source_output_set_state(pa_source_output *o, pa_source_output_state_t
         pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], o);
 
     pa_source_update_status(o->source);
-
-    return 0;
 }
 
 /* Called from main context */

commit 08800c35b072820ba485a5a0a211ce91a1656390
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Feb 3 03:14:20 2009 +0100

    make a couple of functions return proper error codes

diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 82c8871..7f1ef24 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -799,7 +799,7 @@ static int output_create_sink_input(struct output *o) {
     data.module = o->userdata->module;
     data.resample_method = o->userdata->resample_method;
 
-    o->sink_input = pa_sink_input_new(o->userdata->core, &data, PA_SINK_INPUT_VARIABLE_RATE|PA_SINK_INPUT_DONT_MOVE);
+    pa_sink_input_new(&o->sink_input, o->userdata->core, &data, PA_SINK_INPUT_VARIABLE_RATE|PA_SINK_INPUT_DONT_MOVE);
 
     pa_sink_input_new_data_done(&data);
 
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index e746f34..a4007b1 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -732,7 +732,7 @@ int pa__init(pa_module*m) {
     pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
     pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
 
-    u->sink_input = pa_sink_input_new(m->core, &sink_input_data, PA_SINK_INPUT_DONT_MOVE);
+    pa_sink_input_new(&u->sink_input, m->core, &sink_input_data, PA_SINK_INPUT_DONT_MOVE);
     pa_sink_input_new_data_done(&sink_input_data);
 
     if (!u->sink_input)
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index e17fef0..89ddf95 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -381,7 +381,7 @@ int pa__init(pa_module*m) {
     pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
     pa_sink_input_new_data_set_channel_map(&sink_input_data, &stream_map);
 
-    u->sink_input = pa_sink_input_new(m->core, &sink_input_data, PA_SINK_INPUT_DONT_MOVE | (remix ? 0 : PA_SINK_INPUT_NO_REMIX));
+    pa_sink_input_new(&u->sink_input, m->core, &sink_input_data, PA_SINK_INPUT_DONT_MOVE | (remix ? 0 : PA_SINK_INPUT_NO_REMIX));
     pa_sink_input_new_data_done(&sink_input_data);
 
     if (!u->sink_input)
diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
index b0782c3..ce08c01 100644
--- a/src/modules/module-sine.c
+++ b/src/modules/module-sine.c
@@ -163,7 +163,7 @@ int pa__init(pa_module*m) {
     pa_proplist_setf(data.proplist, "sine.hz", "%u", frequency);
     pa_sink_input_new_data_set_sample_spec(&data, &ss);
 
-    u->sink_input = pa_sink_input_new(m->core, &data, 0);
+    pa_sink_input_new(&u->sink_input, m->core, &data, 0);
     pa_sink_input_new_data_done(&data);
 
     if (!u->sink_input)
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index 00d2125..baf3532 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -453,7 +453,7 @@ static struct session *session_new(struct userdata *u, const pa_sdp_info *sdp_in
     data.module = u->module;
     pa_sink_input_new_data_set_sample_spec(&data, &sdp_info->sample_spec);
 
-    s->sink_input = pa_sink_input_new(u->module->core, &data, 0);
+    pa_sink_input_new(&s->sink_input, u->module->core, &data, 0);
     pa_sink_input_new_data_done(&data);
 
     if (!s->sink_input) {
diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index a6d682b..762cdc1 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -321,7 +321,7 @@ int pa__init(pa_module*m) {
     pa_source_output_new_data_set_sample_spec(&data, &ss);
     pa_source_output_new_data_set_channel_map(&data, &cm);
 
-    o = pa_source_output_new(m->core, &data, PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND);
+    pa_source_output_new(&o, m->core, &data, PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND);
     pa_source_output_new_data_done(&data);
 
     if (!o) {
diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c
index eac21de..d163126 100644
--- a/src/pulsecore/play-memblockq.c
+++ b/src/pulsecore/play-memblockq.c
@@ -200,7 +200,7 @@ pa_sink_input* pa_memblockq_sink_input_new(
     pa_sink_input_new_data_set_virtual_volume(&data, volume);
     pa_proplist_update(data.proplist, PA_UPDATE_REPLACE, p);
 
-    u->sink_input = pa_sink_input_new(sink->core, &data, 0);
+    pa_sink_input_new(&u->sink_input, sink->core, &data, 0);
     pa_sink_input_new_data_done(&data);
 
     if (!u->sink_input)
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 1311e67..e1643cb 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -424,7 +424,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void
     sdata.sink = sink;
     pa_sink_input_new_data_set_sample_spec(&sdata, &ss);
 
-    c->sink_input = pa_sink_input_new(c->protocol->core, &sdata, 0);
+    pa_sink_input_new(&c->sink_input, c->protocol->core, &sdata, 0);
     pa_sink_input_new_data_done(&sdata);
 
     CHECK_VALIDITY(c->sink_input, "Failed to create sink input.");
@@ -526,7 +526,7 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi
     sdata.source = source;
     pa_source_output_new_data_set_sample_spec(&sdata, &ss);
 
-    c->source_output = pa_source_output_new(c->protocol->core, &sdata, 0);
+    pa_source_output_new(&c->source_output, c->protocol->core, &sdata, 0);
     pa_source_output_new_data_done(&sdata);
 
     CHECK_VALIDITY(c->source_output, "Failed to create source output.");
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index e8080bf..21a2cfb 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -591,7 +591,8 @@ static record_stream* record_stream_new(
         pa_proplist *p,
         pa_bool_t adjust_latency,
         pa_sink_input *direct_on_input,
-        pa_bool_t early_requests) {
+        pa_bool_t early_requests,
+        int *ret) {
 
     record_stream *s;
     pa_source_output *source_output;
@@ -602,6 +603,7 @@ static record_stream* record_stream_new(
     pa_assert(ss);
     pa_assert(maxlength);
     pa_assert(p);
+    pa_assert(ret);
 
     pa_source_output_new_data_init(&data);
 
@@ -616,7 +618,7 @@ static record_stream* record_stream_new(
     if (peak_detect)
         data.resample_method = PA_RESAMPLER_PEAKS;
 
-    source_output = pa_source_output_new(c->protocol->core, &data, flags);
+    *ret = pa_source_output_new(&source_output, c->protocol->core, &data, flags);
 
     pa_source_output_new_data_done(&data);
 
@@ -965,7 +967,8 @@ static playback_stream* playback_stream_new(
         pa_sink_input_flags_t flags,
         pa_proplist *p,
         pa_bool_t adjust_latency,
-        pa_bool_t early_requests) {
+        pa_bool_t early_requests,
+        int *ret) {
 
     playback_stream *s, *ssync;
     pa_sink_input *sink_input;
@@ -982,6 +985,7 @@ static playback_stream* playback_stream_new(
     pa_assert(minreq);
     pa_assert(missing);
     pa_assert(p);
+    pa_assert(ret);
 
     /* Find syncid group */
     for (ssync = pa_idxset_first(c->output_streams, &idx); ssync; ssync = pa_idxset_next(c->output_streams, &idx)) {
@@ -998,8 +1002,10 @@ static playback_stream* playback_stream_new(
 
         if (!sink)
             sink = ssync->sink_input->sink;
-        else if (sink != ssync->sink_input->sink)
+        else if (sink != ssync->sink_input->sink) {
+            *ret = PA_ERR_INVALID;
             return NULL;
+        }
     }
 
     pa_sink_input_new_data_init(&data);
@@ -1017,7 +1023,7 @@ static playback_stream* playback_stream_new(
         pa_sink_input_new_data_set_muted(&data, muted);
     data.sync_base = ssync ? ssync->sink_input : NULL;
 
-    sink_input = pa_sink_input_new(c->protocol->core, &data, flags);
+    *ret = pa_sink_input_new(&sink_input, c->protocol->core, &data, flags);
 
     pa_sink_input_new_data_done(&data);
 
@@ -1696,6 +1702,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
     pa_sink_input_flags_t flags = 0;
     pa_proplist *p;
     pa_bool_t volume_set = TRUE;
+    int ret = PA_ERR_INVALID;
 
     pa_native_connection_assert_ref(c);
     pa_assert(t);
@@ -1822,10 +1829,10 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
      * flag. For older versions we synthesize it here */
     muted_set = muted_set || muted;
 
-    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, muted_set, syncid, &missing, flags, p, adjust_latency, early_requests);
+    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, muted_set, syncid, &missing, flags, p, adjust_latency, early_requests, &ret);
     pa_proplist_free(p);
 
-    CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, s, tag, ret);
 
     reply = reply_new(tag);
     pa_tagstruct_putu32(reply, s->index);
@@ -1950,6 +1957,7 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
     pa_proplist *p;
     uint32_t direct_on_input_idx = PA_INVALID_INDEX;
     pa_sink_input *direct_on_input = NULL;
+    int ret = PA_ERR_INVALID;
 
     pa_native_connection_assert_ref(c);
     pa_assert(t);
@@ -2071,10 +2079,10 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         (dont_inhibit_auto_suspend ? PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND : 0) |
         (fail_on_suspend ? PA_SOURCE_OUTPUT_FAIL_ON_SUSPEND : 0);
 
-    s = record_stream_new(c, source, &ss, &map, peak_detect, &maxlength, &fragment_size, flags, p, adjust_latency, direct_on_input, early_requests);
+    s = record_stream_new(c, source, &ss, &map, peak_detect, &maxlength, &fragment_size, flags, p, adjust_latency, direct_on_input, early_requests, &ret);
     pa_proplist_free(p);
 
-    CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
+    CHECK_VALIDITY(c->pstream, s, tag, ret);
 
     reply = reply_new(tag);
     pa_tagstruct_putu32(reply, s->index);
diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c
index dd8002a..e149c40 100644
--- a/src/pulsecore/protocol-simple.c
+++ b/src/pulsecore/protocol-simple.c
@@ -539,7 +539,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
         pa_proplist_update(data.proplist, PA_UPDATE_MERGE, c->client->proplist);
         pa_sink_input_new_data_set_sample_spec(&data, &o->sample_spec);
 
-        c->sink_input = pa_sink_input_new(p->core, &data, 0);
+        pa_sink_input_new(&c->sink_input, p->core, &data, 0);
         pa_sink_input_new_data_done(&data);
 
         if (!c->sink_input) {
@@ -591,7 +591,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp
         pa_proplist_update(data.proplist, PA_UPDATE_MERGE, c->client->proplist);
         pa_source_output_new_data_set_sample_spec(&data, &o->sample_spec);
 
-        c->source_output = pa_source_output_new(p->core, &data, 0);
+        pa_source_output_new(&c->source_output, p->core, &data, 0);
         pa_source_output_new_data_done(&data);
 
         if (!c->source_output) {
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index cc3e108..a3a29e9 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -120,7 +120,8 @@ static void reset_callbacks(pa_sink_input *i) {
 }
 
 /* Called from main context */
-pa_sink_input* pa_sink_input_new(
+int pa_sink_input_new(
+        pa_sink_input **_i,
         pa_core *core,
         pa_sink_input_new_data *data,
         pa_sink_input_flags_t flags) {
@@ -129,32 +130,31 @@ pa_sink_input* pa_sink_input_new(
     pa_resampler *resampler = NULL;
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
     pa_channel_map original_cm;
+    int r;
 
+    pa_assert(_i);
     pa_assert(core);
     pa_assert(data);
 
-    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data) < 0)
-        return NULL;
+    if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data)) < 0)
+        return r;
 
-    pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
+    pa_return_val_if_fail(!data->driver || pa_utf8_valid(data->driver), -PA_ERR_INVALID);
 
     if (!data->sink) {
         data->sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK);
         data->save_sink = FALSE;
     }
 
-    pa_return_null_if_fail(data->sink);
-    pa_return_null_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)));
-    pa_return_null_if_fail(!data->sync_base || (data->sync_base->sink == data->sink && pa_sink_input_get_state(data->sync_base) == PA_SINK_INPUT_CORKED));
-
-    if ((flags & PA_SINK_INPUT_FAIL_ON_SUSPEND) &&
-        pa_sink_get_state(data->sink) == PA_SINK_SUSPENDED)
-        return NULL;
+    pa_return_val_if_fail(data->sink, -PA_ERR_NOENTITY);
+    pa_return_val_if_fail(PA_SINK_IS_LINKED(pa_sink_get_state(data->sink)), -PA_ERR_BADSTATE);
+    pa_return_val_if_fail(!data->sync_base || (data->sync_base->sink == data->sink && pa_sink_input_get_state(data->sync_base) == PA_SINK_INPUT_CORKED), -PA_ERR_INVALID);
+    pa_return_val_if_fail(!(flags & PA_SINK_INPUT_FAIL_ON_SUSPEND) || pa_sink_get_state(data->sink) != PA_SINK_SUSPENDED, -PA_ERR_BADSTATE);
 
     if (!data->sample_spec_is_set)
         data->sample_spec = data->sink->sample_spec;
 
-    pa_return_null_if_fail(pa_sample_spec_valid(&data->sample_spec));
+    pa_return_val_if_fail(pa_sample_spec_valid(&data->sample_spec), -PA_ERR_INVALID);
 
     if (!data->channel_map_is_set) {
         if (pa_channel_map_compatible(&data->sink->channel_map, &data->sample_spec))
@@ -163,8 +163,8 @@ pa_sink_input* pa_sink_input_new(
             pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
-    pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
-    pa_return_null_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec));
+    pa_return_val_if_fail(pa_channel_map_valid(&data->channel_map), -PA_ERR_INVALID);
+    pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID);
 
     if (!data->virtual_volume_is_set) {
 
@@ -187,14 +187,14 @@ pa_sink_input* pa_sink_input_new(
         }
     }
 
-    pa_return_null_if_fail(pa_cvolume_valid(&data->virtual_volume));
-    pa_return_null_if_fail(pa_cvolume_compatible(&data->virtual_volume, &data->sample_spec));
+    pa_return_val_if_fail(pa_cvolume_valid(&data->virtual_volume), -PA_ERR_INVALID);
+    pa_return_val_if_fail(pa_cvolume_compatible(&data->virtual_volume, &data->sample_spec), -PA_ERR_INVALID);
 
     if (!data->soft_volume_is_set)
         data->soft_volume = data->virtual_volume;
 
-    pa_return_null_if_fail(pa_cvolume_valid(&data->soft_volume));
-    pa_return_null_if_fail(pa_cvolume_compatible(&data->soft_volume, &data->sample_spec));
+    pa_return_val_if_fail(pa_cvolume_valid(&data->soft_volume), -PA_ERR_INVALID);
+    pa_return_val_if_fail(pa_cvolume_compatible(&data->soft_volume, &data->sample_spec), -PA_ERR_INVALID);
 
     if (!data->muted_is_set)
         data->muted = FALSE;
@@ -222,17 +222,17 @@ pa_sink_input* pa_sink_input_new(
     if (data->resample_method == PA_RESAMPLER_INVALID)
         data->resample_method = core->resample_method;
 
-    pa_return_null_if_fail(data->resample_method < PA_RESAMPLER_MAX);
+    pa_return_val_if_fail(data->resample_method < PA_RESAMPLER_MAX, -PA_ERR_INVALID);
 
     if (data->client)
         pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
 
-    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], data) < 0)
-        return NULL;
+    if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], data)) < 0)
+        return r;
 
     if (pa_idxset_size(data->sink->inputs) >= PA_MAX_INPUTS_PER_SINK) {
         pa_log_warn("Failed to create sink input: too many inputs per sink.");
-        return NULL;
+        return -PA_ERR_TOOLARGE;
     }
 
     if ((flags & PA_SINK_INPUT_VARIABLE_RATE) ||
@@ -249,7 +249,7 @@ pa_sink_input* pa_sink_input_new(
                       (core->disable_remixing || (flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
                       (core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
             pa_log_warn("Unsupported resampling operation.");
-            return NULL;
+            return -PA_ERR_NOTSUPPORTED;
         }
     }
 
@@ -334,7 +334,8 @@ pa_sink_input* pa_sink_input_new(
 
     /* Don't forget to call pa_sink_input_put! */
 
-    return i;
+    *_i = i;
+    return 0;
 }
 
 /* Called from main context */
@@ -957,7 +958,7 @@ void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b) {
 int pa_sink_input_set_rate(pa_sink_input *i, uint32_t rate) {
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
-    pa_return_val_if_fail(i->thread_info.resampler, -1);
+    pa_return_val_if_fail(i->thread_info.resampler, -PA_ERR_BADSTATE);
 
     if (i->sample_spec.rate == rate)
         return 0;
@@ -1045,16 +1046,17 @@ pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) {
 int pa_sink_input_start_move(pa_sink_input *i) {
     pa_source_output *o, *p = NULL;
     pa_sink *origin;
+    int r;
 
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
     pa_assert(i->sink);
 
     if (!pa_sink_input_may_move(i))
-        return -1;
+        return -PA_ERR_NOTSUPPORTED;
 
-    if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], i) < 0)
-        return -1;
+    if ((r = pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], i)) < 0)
+        return r;
 
     origin = i->sink;
 
@@ -1096,14 +1098,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
     pa_sink_assert_ref(dest);
 
     if (!pa_sink_input_may_move_to(i, dest))
-        return -1;
-
-    i->sink = dest;
-    i->save_sink = save;
-    pa_idxset_put(dest->inputs, i, NULL);
-
-    if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED)
-        i->sink->n_corked++;
+        return -PA_ERR_NOTSUPPORTED;
 
     if (i->thread_info.resampler &&
         pa_sample_spec_equal(pa_resampler_output_sample_spec(i->thread_info.resampler), &dest->sample_spec) &&
@@ -1127,11 +1122,18 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
                       ((i->flags & PA_SINK_INPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
                       (i->core->disable_remixing || (i->flags & PA_SINK_INPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0)))) {
             pa_log_warn("Unsupported resampling operation.");
-            return -1;
+            return -PA_ERR_NOTSUPPORTED;
         }
     } else
         new_resampler = NULL;
 
+    i->sink = dest;
+    i->save_sink = save;
+    pa_idxset_put(dest->inputs, i, NULL);
+
+    if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED)
+        i->sink->n_corked++;
+
     /* Replace resampler and render queue */
     if (new_resampler != i->thread_info.resampler) {
 
@@ -1177,6 +1179,8 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
 
 /* Called from main context */
 int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
+    int r;
+
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
     pa_assert(i->sink);
@@ -1186,13 +1190,13 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
         return 0;
 
     if (!pa_sink_input_may_move_to(i, dest))
-        return -1;
+        return -PA_ERR_NOTSUPPORTED;
 
-    if (pa_sink_input_start_move(i) < 0)
-        return -1;
+    if ((r = pa_sink_input_start_move(i)) < 0)
+        return r;
 
-    if (pa_sink_input_finish_move(i, dest, save) < 0)
-        return -1;
+    if ((r = pa_sink_input_finish_move(i, dest, save)) < 0)
+        return r;
 
     return 0;
 }
@@ -1307,7 +1311,7 @@ int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t
         }
     }
 
-    return -1;
+    return -PA_ERR_NOTIMPLEMENTED;
 }
 
 /* Called from main thread */
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index c27f625..d82a3a6 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -257,7 +257,8 @@ void pa_sink_input_new_data_done(pa_sink_input_new_data *data);
 
 /* To be called by the implementing module only */
 
-pa_sink_input* pa_sink_input_new(
+int pa_sink_input_new(
+        pa_sink_input **i,
         pa_core *core,
         pa_sink_input_new_data *data,
         pa_sink_input_flags_t flags);
@@ -313,7 +314,7 @@ pa_usec_t pa_sink_input_get_requested_latency(pa_sink_input *i);
 
 /* To be used exclusively by the sink driver IO thread */
 
-int pa_sink_input_peek(pa_sink_input *i, size_t length, pa_memchunk *chunk, pa_cvolume *volume);
+void pa_sink_input_peek(pa_sink_input *i, size_t length, pa_memchunk *chunk, pa_cvolume *volume);
 void pa_sink_input_drop(pa_sink_input *i, size_t length);
 void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in the sink's sample spec */);
 void pa_sink_input_update_max_rewind(pa_sink_input *i, size_t nbytes  /* in the sink's sample spec */);
diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c
index 1be421f..67b072b 100644
--- a/src/pulsecore/sound-file-stream.c
+++ b/src/pulsecore/sound-file-stream.c
@@ -326,7 +326,7 @@ int pa_play_file(
     pa_proplist_sets(data.proplist, PA_PROP_MEDIA_NAME, pa_path_get_filename(fname));
     pa_proplist_sets(data.proplist, PA_PROP_MEDIA_FILENAME, fname);
 
-    u->sink_input = pa_sink_input_new(sink->core, &data, 0);
+    pa_sink_input_new(&u->sink_input, sink->core, &data, 0);
     pa_sink_input_new_data_done(&data);
 
     if (!u->sink_input)
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 0204e30..c5cb16d 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -95,7 +95,8 @@ static void reset_callbacks(pa_source_output *o) {
 }
 
 /* Called from main context */
-pa_source_output* pa_source_output_new(
+int pa_source_output_new(
+        pa_source_output**_o,
         pa_core *core,
         pa_source_output_new_data *data,
         pa_source_output_flags_t flags) {
@@ -103,32 +104,31 @@ pa_source_output* pa_source_output_new(
     pa_source_output *o;
     pa_resampler *resampler = NULL;
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+    int r;
 
+    pa_assert(_o);
     pa_assert(core);
     pa_assert(data);
 
-    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], data) < 0)
-        return NULL;
+    if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], data)) < 0)
+        return r;
 
-    pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
+    pa_return_val_if_fail(!data->driver || pa_utf8_valid(data->driver), -PA_ERR_INVALID);
 
     if (!data->source) {
         data->source = pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE);
         data->save_source = FALSE;
     }
 
-    pa_return_null_if_fail(data->source);
-    pa_return_null_if_fail(PA_SOURCE_IS_LINKED(pa_source_get_state(data->source)));
-    pa_return_null_if_fail(!data->direct_on_input || data->direct_on_input->sink == data->source->monitor_of);
-
-    if ((flags & PA_SOURCE_OUTPUT_FAIL_ON_SUSPEND) &&
-        pa_source_get_state(data->source) == PA_SOURCE_SUSPENDED)
-        return NULL;
+    pa_return_val_if_fail(data->source, -PA_ERR_NOENTITY);
+    pa_return_val_if_fail(PA_SOURCE_IS_LINKED(pa_source_get_state(data->source)), -PA_ERR_BADSTATE);
+    pa_return_val_if_fail(!data->direct_on_input || data->direct_on_input->sink == data->source->monitor_of, -PA_ERR_INVALID);
+    pa_return_val_if_fail(!(flags & PA_SOURCE_OUTPUT_FAIL_ON_SUSPEND) || pa_source_get_state(data->source) != PA_SOURCE_SUSPENDED, -PA_ERR_BADSTATE);
 
     if (!data->sample_spec_is_set)
         data->sample_spec = data->source->sample_spec;
 
-    pa_return_null_if_fail(pa_sample_spec_valid(&data->sample_spec));
+    pa_return_val_if_fail(pa_sample_spec_valid(&data->sample_spec), -PA_ERR_INVALID);
 
     if (!data->channel_map_is_set) {
         if (pa_channel_map_compatible(&data->source->channel_map, &data->sample_spec))
@@ -137,8 +137,8 @@ pa_source_output* pa_source_output_new(
             pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
-    pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
-    pa_return_null_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec));
+    pa_return_val_if_fail(pa_channel_map_valid(&data->channel_map), -PA_ERR_INVALID);
+    pa_return_val_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec), -PA_ERR_INVALID);
 
     if (flags & PA_SOURCE_OUTPUT_FIX_FORMAT)
         data->sample_spec.format = data->source->sample_spec.format;
@@ -157,17 +157,17 @@ pa_source_output* pa_source_output_new(
     if (data->resample_method == PA_RESAMPLER_INVALID)
         data->resample_method = core->resample_method;
 
-    pa_return_null_if_fail(data->resample_method < PA_RESAMPLER_MAX);
+    pa_return_val_if_fail(data->resample_method < PA_RESAMPLER_MAX, -PA_ERR_INVALID);
 
     if (data->client)
         pa_proplist_update(data->proplist, PA_UPDATE_MERGE, data->client->proplist);
 
-    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], data) < 0)
-        return NULL;
+    if ((r = pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE], data)) < 0)
+        return r;
 
     if (pa_idxset_size(data->source->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
         pa_log("Failed to create source output: too many outputs per source.");
-        return NULL;
+        return -PA_ERR_TOOLARGE;
     }
 
     if ((flags & PA_SOURCE_OUTPUT_VARIABLE_RATE) ||
@@ -184,7 +184,7 @@ pa_source_output* pa_source_output_new(
                       (core->disable_remixing || (flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0) |
                       (core->disable_lfe_remixing ? PA_RESAMPLER_NO_LFE : 0)))) {
             pa_log_warn("Unsupported resampling operation.");
-            return NULL;
+            return -PA_ERR_NOTSUPPORTED;
         }
     }
 
@@ -248,7 +248,8 @@ pa_source_output* pa_source_output_new(
 
     /* Don't forget to call pa_source_output_put! */
 
-    return o;
+    *_o = o;
+    return 0;
 }
 
 /* Called from main context */
@@ -576,7 +577,7 @@ void pa_source_output_cork(pa_source_output *o, pa_bool_t b) {
 int pa_source_output_set_rate(pa_source_output *o, uint32_t rate) {
     pa_source_output_assert_ref(o);
     pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
-    pa_return_val_if_fail(o->thread_info.resampler, -1);
+    pa_return_val_if_fail(o->thread_info.resampler, -PA_ERR_BADSTATE);
 
     if (o->sample_spec.rate == rate)
         return 0;
@@ -676,16 +677,17 @@ pa_bool_t pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) {
 /* Called from main context */
 int pa_source_output_start_move(pa_source_output *o) {
     pa_source *origin;
+    int r;
 
     pa_source_output_assert_ref(o);
     pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
     pa_assert(o->source);
 
     if (!pa_source_output_may_move(o))
-        return -1;
+        return -PA_ERR_NOTSUPPORTED;
 
-    if (pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START], o) < 0)
-        return -1;
+    if ((r = pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START], o)) < 0)
+        return r;
 
     origin = o->source;
 
@@ -714,13 +716,6 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
     if (!pa_source_output_may_move_to(o, dest))
         return -1;
 
-    o->source = dest;
-    o->save_source = save;
-    pa_idxset_put(o->source->outputs, o, NULL);
-
-    if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED)
-        o->source->n_corked++;
-
     if (o->thread_info.resampler &&
         pa_sample_spec_equal(pa_resampler_input_sample_spec(o->thread_info.resampler), &dest->sample_spec) &&
         pa_channel_map_equal(pa_resampler_input_channel_map(o->thread_info.resampler), &dest->channel_map))
@@ -743,11 +738,18 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
                       ((o->flags & PA_SOURCE_OUTPUT_NO_REMAP) ? PA_RESAMPLER_NO_REMAP : 0) |
                       (o->core->disable_remixing || (o->flags & PA_SOURCE_OUTPUT_NO_REMIX) ? PA_RESAMPLER_NO_REMIX : 0)))) {
             pa_log_warn("Unsupported resampling operation.");
-            return -1;
+            return -PA_ERR_NOTSUPPORTED;
         }
     } else
         new_resampler = NULL;
 
+    o->source = dest;
+    o->save_source = save;
+    pa_idxset_put(o->source->outputs, o, NULL);
+
+    if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED)
+        o->source->n_corked++;
+
     /* Replace resampler */
     if (new_resampler != o->thread_info.resampler) {
         if (o->thread_info.resampler)
@@ -784,6 +786,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
 
 /* Called from main context */
 int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t save) {
+    int r;
 
     pa_source_output_assert_ref(o);
     pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
@@ -794,13 +797,13 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest, pa_bool_t sav
         return 0;
 
     if (!pa_source_output_may_move_to(o, dest))
-        return -1;
+        return -PA_ERR_NOTSUPPORTED;
 
-    if (pa_source_output_start_move(o) < 0)
-        return -1;
+    if ((r = pa_source_output_start_move(o)) < 0)
+        return r;
 
-    if (pa_source_output_finish_move(o, dest, save) < 0)
-        return -1;
+    if ((r = pa_source_output_finish_move(o, dest, save)) < 0)
+        return r;
 
     return 0;
 }
@@ -864,5 +867,5 @@ int pa_source_output_process_msg(pa_msgobject *mo, int code, void *userdata, int
         }
     }
 
-    return -1;
+    return -PA_ERR_NOTIMPLEMENTED;
 }
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index f4f9462..91f28f9 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -205,7 +205,8 @@ void pa_source_output_new_data_done(pa_source_output_new_data *data);
 
 /* To be called by the implementing module only */
 
-pa_source_output* pa_source_output_new(
+int pa_source_output_new(
+        pa_source_output**o,
         pa_core *core,
         pa_source_output_new_data *data,
         pa_source_output_flags_t flags);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list