summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-05-27 22:15:35 +0000
committerLennart Poettering <lennart@poettering.net>2008-05-27 22:15:35 +0000
commitec862ec7607f28902c568d5dca8eaca32f3d1537 (patch)
treeca4033b82a5cb33f1bab9e2ae53429f1f0f57af3
parent9c0cc6bf6146dd71286c5ae7e3cf069024860ceb (diff)
properly strip canberra props from proplist, fix upload
git-svn-id: file:///home/lennart/svn/public/libcanberra/trunk@29 01b60673-d06a-42c0-afdd-89cb8e0f78ac
-rw-r--r--src/pulse.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/pulse.c b/src/pulse.c
index 2c9f1cd..9837e53 100644
--- a/src/pulse.c
+++ b/src/pulse.c
@@ -126,7 +126,7 @@ static pa_proplist *strip_canberra_data(pa_proplist *l) {
ca_assert(l);
while ((key = pa_proplist_iterate(l, &state)))
- if (strncmp(key, "canberra.", 12) == 0)
+ if (strncmp(key, "canberra.", 9) == 0)
pa_proplist_unset(l, key);
return l;
@@ -539,45 +539,47 @@ static void stream_write_cb(pa_stream *s, size_t bytes, void *userdata) {
if ((ret = ca_sound_file_read_arbitrary(out->file, data, &rbytes)) < 0)
goto finish;
- if (rbytes > 0) {
- ca_assert(rbytes <= bytes);
+ if (rbytes <= 0)
+ break;
- if ((ret = pa_stream_write(s, data, rbytes, free, 0, PA_SEEK_RELATIVE)) < 0) {
- ret = translate_error(ret);
- goto finish;
- }
+ ca_assert(rbytes <= bytes);
- bytes -= rbytes;
+ if ((ret = pa_stream_write(s, data, rbytes, free, 0, PA_SEEK_RELATIVE)) < 0) {
+ ret = translate_error(ret);
+ goto finish;
+ }
- } else {
- /* We reached EOF */
+ bytes -= rbytes;
+ fprintf(stderr, "writing %lu bytes\n", (unsigned long) rbytes);
+ }
- if (out->type == OUTSTANDING_UPLOAD) {
+ if (ca_sound_file_get_size(out->file) <= 0) {
- if (pa_stream_finish_upload(s) < 0) {
- ret = translate_error(pa_context_errno(p->context));
- goto finish;
- }
+ /* We reached EOF */
- /* Let's just signal driver_cache() which has been waiting for us */
- pa_threaded_mainloop_signal(p->mainloop, FALSE);
+ if (out->type == OUTSTANDING_UPLOAD) {
- } else {
- pa_operation *o;
- ca_assert(out->type == OUTSTANDING_STREAM);
+ if (pa_stream_finish_upload(s) < 0) {
+ ret = translate_error(pa_context_errno(p->context));
+ goto finish;
+ }
- if (!(o = pa_stream_drain(s, stream_drain_cb, out))) {
- ret = translate_error(pa_context_errno(p->context));
- goto finish;
- }
+ /* Let's just signal driver_cache() which has been waiting for us */
+ pa_threaded_mainloop_signal(p->mainloop, FALSE);
- pa_operation_unref(o);
- }
+ } else {
+ pa_operation *o;
+ ca_assert(out->type == OUTSTANDING_STREAM);
- pa_stream_set_write_callback(s, NULL, NULL);
+ if (!(o = pa_stream_drain(s, stream_drain_cb, out))) {
+ ret = translate_error(pa_context_errno(p->context));
+ goto finish;
+ }
- break;
+ pa_operation_unref(o);
}
+
+ pa_stream_set_write_callback(s, NULL, NULL);
}
return;
@@ -910,7 +912,7 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
if ((ret = ca_lookup_sound(&out->file, &p->theme, c->props, proplist)) < 0)
goto finish;
- ss.channels = sample_type_table[ca_sound_file_get_sample_type(out->file)];
+ ss.format = sample_type_table[ca_sound_file_get_sample_type(out->file)];
ss.channels = ca_sound_file_get_nchannels(out->file);
ss.rate = ca_sound_file_get_rate(out->file);