summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2008-05-27 10:53:55 +0000
committerLennart Poettering <lennart@poettering.net>2008-05-27 10:53:55 +0000
commit7ac8038c3690eb5547cfdff83235f3636f87c303 (patch)
tree0854e5d007b5142095b57d0e00fd7aaaba17fc5e /src
parent6a75b780762a8695a83e0e94e6fcbce4d2f73573 (diff)
add acx_pthread to the build
git-svn-id: file:///home/lennart/svn/public/libcanberra/trunk@14 01b60673-d06a-42c0-afdd-89cb8e0f78ac
Diffstat (limited to 'src')
-rw-r--r--src/pulse.c20
-rw-r--r--src/read-sound-file.c16
-rw-r--r--src/read-vorbis.c28
-rw-r--r--src/read-vorbis.h2
-rw-r--r--src/read-wav.c36
-rw-r--r--src/sound-theme-spec.c13
6 files changed, 62 insertions, 53 deletions
diff --git a/src/pulse.c b/src/pulse.c
index bb92bba..fcf8148 100644
--- a/src/pulse.c
+++ b/src/pulse.c
@@ -831,7 +831,8 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
char *name = NULL;
pa_sample_spec ss;
ca_cache_control_t cache_control = CA_CACHE_CONTROL_NEVER;
- struct outstanding out;
+ struct outstanding *out;
+ int ret;
ca_return_val_if_fail(c, CA_ERROR_INVALID);
ca_return_val_if_fail(proplist, CA_ERROR_INVALID);
@@ -860,7 +861,7 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
}
if (!(name = ca_strdup(n))) {
- ret = PA_ERROR_OOM;
+ ret = CA_ERROR_OOM;
goto finish;
}
@@ -879,7 +880,7 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
/* Let's stream the sample directly */
if ((ret = ca_lookup_sound(&out->file, &p->theme, proplist)) < 0)
- goto fail;
+ goto finish;
ss.channels = sample_type_table[ca_sound_file_get_sample_type(out->file)];
ss.channels = ca_sound_file_get_nchannels(out->file);
@@ -890,21 +891,20 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
if (!(out->stream = pa_stream_new_with_proplist(p->context, name, &ss, NULL, l))) {
ret = translate_error(pa_context_errno(p->context));
pa_threaded_mainloop_unlock(p->mainloop);
- goto fail;
+ goto finish;
}
- pa_stream_set_userdata(out->stream, out);
pa_stream_set_state_callback(out->stream, stream_state_cb, out);
- pa_stream_set_write_callback(out->stream, stream_request_cb, out);
+ pa_stream_set_write_callback(out->stream, stream_write_cb, out);
- if (pa_stream_connect_upload(s, ca_sound_file_get_size(out->file)) < 0) {
+ if (pa_stream_connect_upload(out->stream, ca_sound_file_get_size(out->file)) < 0) {
ret = translate_error(pa_context_errno(p->context));
pa_threaded_mainloop_unlock(p->mainloop);
- goto fail;
+ goto finish;
}
for (;;) {
- pa_stream_state state = pa_stream_get_state(s);
+ pa_stream_state_t state = pa_stream_get_state(out->stream);
/* Stream sucessfully created and uploaded */
if (state == PA_STREAM_TERMINATED)
@@ -914,7 +914,7 @@ int driver_cache(ca_context *c, ca_proplist *proplist) {
if (state == PA_STREAM_FAILED) {
ret = translate_error(pa_context_errno(p->context));
pa_threaded_mainloop_unlock(p->mainloop);
- goto fail;
+ goto finish;
}
pa_threaded_mainloop_wait(p->mainloop);
diff --git a/src/read-sound-file.c b/src/read-sound-file.c
index eb2acbd..b753e6f 100644
--- a/src/read-sound-file.c
+++ b/src/read-sound-file.c
@@ -68,7 +68,7 @@ int ca_sound_file_open(ca_sound_file **_f, const char *fn) {
f->nchannels = ca_wav_get_nchannels(f->wav);
f->rate = ca_wav_get_rate(f->wav);
f->type = ca_wav_get_sample_type(f->wav);
- *f = f;
+ *_f = f;
return CA_SUCCESS;
}
@@ -83,7 +83,7 @@ int ca_sound_file_open(ca_sound_file **_f, const char *fn) {
f->nchannels = ca_vorbis_get_nchannels(f->vorbis);
f->rate = ca_vorbis_get_rate(f->vorbis);
f->type = CA_SAMPLE_S16NE;
- *f = f;
+ *_f = f;
return CA_SUCCESS;
}
}
@@ -100,9 +100,9 @@ void ca_sound_file_close(ca_sound_file *f) {
ca_assert(f);
if (f->wav)
- ca_wav_free(f->wav);
+ ca_wav_close(f->wav);
if (f->vorbis)
- ca_vorbis_free(f->vorbis);
+ ca_vorbis_close(f->vorbis);
ca_free(f);
}
@@ -132,10 +132,10 @@ int ca_sound_file_read_int16(ca_sound_file *f, int16_t *d, unsigned *n) {
if (f->wav)
return ca_wav_read_s16le(f->wav, d, n);
else
- return ca_vorbis_read_s16ne(f->wav, d, n);
+ return ca_vorbis_read_s16ne(f->vorbis, d, n);
}
-int ca_sound_file_read_uint8(ca_sound_file *fn, uint8_t *d, unsigned *n) {
+int ca_sound_file_read_uint8(ca_sound_file *f, uint8_t *d, unsigned *n) {
ca_return_val_if_fail(f, CA_ERROR_INVALID);
ca_return_val_if_fail(d, CA_ERROR_INVALID);
ca_return_val_if_fail(n, CA_ERROR_INVALID);
@@ -145,6 +145,8 @@ int ca_sound_file_read_uint8(ca_sound_file *fn, uint8_t *d, unsigned *n) {
if (f->wav)
return ca_wav_read_u8(f->wav, d, n);
+
+ return CA_ERROR_STATE;
}
int ca_sound_file_read_arbitrary(ca_sound_file *f, void *d, size_t *n) {
@@ -168,7 +170,7 @@ int ca_sound_file_read_arbitrary(ca_sound_file *f, void *d, size_t *n) {
break;
}
- case CA_SAMPLE_S16RE: {
+ case CA_SAMPLE_U8: {
unsigned k;
k = *n;
diff --git a/src/read-vorbis.c b/src/read-vorbis.c
index f54e271..34d33a0 100644
--- a/src/read-vorbis.c
+++ b/src/read-vorbis.c
@@ -27,8 +27,10 @@
#include <vorbis/vorbisfile.h>
#include <vorbis/codec.h>
+#include "canberra.h"
#include "read-vorbis.h"
#include "macro.h"
+#include "malloc.h"
#define FILE_SIZE_MAX (64U*1024U*1024U)
@@ -43,13 +45,13 @@ static int convert_error(int or) {
case OV_EBADLINK:
case OV_EFAULT:
case OV_EREAD:
- case OV_EHOLE:
+ case OV_HOLE:
return CA_ERROR_IO;
case OV_EIMPL:
case OV_EVERSION:
- case OV_ENOTAUDIO
- return CA_ERROR_NOT_SUPPORTED;
+ case OV_ENOTAUDIO:
+ return CA_ERROR_NOTSUPPORTED;
case OV_ENOTVORBIS:
case OV_EBADHEADER:
@@ -60,7 +62,7 @@ static int convert_error(int or) {
return CA_ERROR_INVALID;
default:
- return CA_ERROR_INTERNAL;
+ return CA_ERROR_IO;
}
}
@@ -80,7 +82,7 @@ int ca_vorbis_open(ca_vorbis **_v, FILE *f) {
goto fail;
}
- if ((n = ov_pcm_total(&ovf, -1)) < 0) {
+ if ((n = ov_pcm_total(&v->ovf, -1)) < 0) {
ret = convert_error(or);
ov_clear(&v->ovf);
goto fail;
@@ -110,33 +112,33 @@ void ca_vorbis_close(ca_vorbis *v) {
}
unsigned ca_vorbis_get_nchannels(ca_vorbis *v) {
- vorbis_info *vi;
+ const vorbis_info *vi;
ca_assert(v);
- ca_assert_se(vi = ov_info(&vf, -1));
+ ca_assert_se(vi = ov_info(&v->ovf, -1));
return vi->channels;
}
unsigned ca_vorbis_get_rate(ca_vorbis *v) {
- vorbis_info *vi;
+ const vorbis_info *vi;
ca_assert(v);
- ca_assert_se(vi = ov_info(&vf, -1));
+ ca_assert_se(vi = ov_info(&v->ovf, -1));
return (unsigned) vi->rate;
}
-int ca_vorbis_read_int16ne(ca_vorbis *v, int16_t *d, unsigned *n){
+int ca_vorbis_read_s16ne(ca_vorbis *v, int16_t *d, unsigned *n){
long r;
int section;
- ca_return_val_if_fail(w, CA_ERROR_INVALID);
+ ca_return_val_if_fail(v, CA_ERROR_INVALID);
ca_return_val_if_fail(d, CA_ERROR_INVALID);
ca_return_val_if_fail(n, CA_ERROR_INVALID);
ca_return_val_if_fail(*n > 0, CA_ERROR_INVALID);
- r = ov_read(&v->ovf, d, *n * sizeof(float),
+ r = ov_read(&v->ovf, (char*) d, *n * sizeof(float),
#ifdef WORDS_BIGENDIAN
1,
#else
@@ -145,7 +147,7 @@ int ca_vorbis_read_int16ne(ca_vorbis *v, int16_t *d, unsigned *n){
2, 1, &section);
if (r < 0)
- return convert_error(or);
+ return convert_error(r);
/* We only read the first section */
if (section != 0)
diff --git a/src/read-vorbis.h b/src/read-vorbis.h
index d9b5ade..ebf7df3 100644
--- a/src/read-vorbis.h
+++ b/src/read-vorbis.h
@@ -28,7 +28,7 @@
typedef struct ca_vorbis ca_vorbis;
-int ca_vorbis_open(ca_vorbis *v, FILE *f);
+int ca_vorbis_open(ca_vorbis **v, FILE *f);
void ca_vorbis_close(ca_vorbis *v);
unsigned ca_vorbis_get_nchannels(ca_vorbis *v);
diff --git a/src/read-wav.c b/src/read-wav.c
index e96e8ae..8c64c0a 100644
--- a/src/read-wav.c
+++ b/src/read-wav.c
@@ -24,8 +24,10 @@
#include <config.h>
#endif
+#include "canberra.h"
#include "read-wav.h"
#include "macro.h"
+#include "malloc.h"
#define FILE_SIZE_MAX (64U*1024U*1024U)
@@ -38,16 +40,16 @@ struct ca_wav {
unsigned depth;
};
-static int skip_to_chunk(ca_wav *v, uint32_t id, uint32_t *size) {
+static int skip_to_chunk(ca_wav *w, uint32_t id, uint32_t *size) {
- ca_return_val_if_fail(v, CA_ERROR_INVALID);
+ ca_return_val_if_fail(w, CA_ERROR_INVALID);
ca_return_val_if_fail(size, CA_ERROR_INVALID);
for (;;) {
uint32_t chunk[2];
size_t s;
- if (fread(chunk, sizeof(uint32), CA_ELEMENTSOF(chunk), w->file) != CA_ELEMENTSOF(chunk))
+ if (fread(chunk, sizeof(uint32_t), CA_ELEMENTSOF(chunk), w->file) != CA_ELEMENTSOF(chunk))
goto fail_io;
s = PA_UINT32_FROM_LE(chunk[1]);
@@ -68,9 +70,9 @@ static int skip_to_chunk(ca_wav *v, uint32_t id, uint32_t *size) {
fail_io:
- if (feof(f))
+ if (feof(w->file))
return CA_ERROR_CORRUPT;
- else if (ferror(f))
+ else if (ferror(w->file))
return CA_ERROR_SYSTEM;
ca_assert_not_reached();
@@ -80,7 +82,7 @@ int ca_wav_open(ca_wav **_w, FILE *f) {
uint32_t header[3], fmt_chunk[4];
int ret;
ca_wav *w;
- uint32_t file_size, fmt_size, data_size;
+ uint32_t file_size, fmt_size;
ca_return_val_if_fail(_w, CA_ERROR_INVALID);
ca_return_val_if_fail(f, CA_ERROR_INVALID);
@@ -88,9 +90,9 @@ int ca_wav_open(ca_wav **_w, FILE *f) {
if (!(w = ca_new(ca_wav, 1)))
return CA_ERROR_OOM;
- v->file = f;
+ w->file = f;
- if (fread(header, sizeof(uint32), CA_ELEMENTSOF(header), f) != CA_ELEMENTSOF(header))
+ if (fread(header, sizeof(uint32_t), CA_ELEMENTSOF(header), f) != CA_ELEMENTSOF(header))
goto fail_io;
if (PA_UINT32_FROM_LE(header[0]) != 0x46464952U ||
@@ -111,15 +113,15 @@ int ca_wav_open(ca_wav **_w, FILE *f) {
goto fail;
if (fmt_size != 16) {
- ret = CA_ERROR_NOT_SUPPORTED;
+ ret = CA_ERROR_NOTSUPPORTED;
goto fail;
}
- if (fread(fmt_chunk, sizeof(uint32), CA_ELEMENTSOF(fmt_chunk), f) != CA_ELEMENTSOF(fmt_chunk))
+ if (fread(fmt_chunk, sizeof(uint32_t), CA_ELEMENTSOF(fmt_chunk), f) != CA_ELEMENTSOF(fmt_chunk))
goto fail_io;
- if (PA_UINT32_FROM_LE(fmt_chunk[0]) & 0xFFFF != 1) {
- ret = CA_ERROR_NOT_SUPPORTED;
+ if ((PA_UINT32_FROM_LE(fmt_chunk[0]) & 0xFFFF) != 1) {
+ ret = CA_ERROR_NOTSUPPORTED;
goto fail;
}
@@ -127,13 +129,13 @@ int ca_wav_open(ca_wav **_w, FILE *f) {
w->rate = PA_UINT32_FROM_LE(fmt_chunk[1]);
w->depth = PA_UINT32_FROM_LE(fmt_chunk[3]) >> 16;
- if (w->nchannels <= 0 || w->nrate <= 0) {
+ if (w->nchannels <= 0 || w->rate <= 0) {
ret = CA_ERROR_CORRUPT;
goto fail;
}
if (w->depth != 16 && w->depth != 8) {
- ret = CA_ERROR_NOT_SUPPORTED;
+ ret = CA_ERROR_NOTSUPPORTED;
goto fail;
}
@@ -148,7 +150,7 @@ int ca_wav_open(ca_wav **_w, FILE *f) {
*_w = w;
- return PA_SUCCESS;
+ return CA_SUCCESS;
fail_io:
@@ -185,7 +187,7 @@ unsigned ca_wav_get_rate(ca_wav *w) {
return w->rate;
}
-ca_sample_type_t ca_wav_get_sample_type(ca_wav *f) {
+ca_sample_type_t ca_wav_get_sample_type(ca_wav *w) {
ca_assert(w);
return w->depth == 16 ?
@@ -224,7 +226,7 @@ int ca_wav_read_s16le(ca_wav *w, int16_t *d, unsigned *n) {
return CA_SUCCESS;
}
-int ca_wav_read_u(ca_wav *w, uint8_t *d, unsigned *n) {
+int ca_wav_read_u8(ca_wav *w, uint8_t *d, unsigned *n) {
unsigned remaining;
ca_return_val_if_fail(w, CA_ERROR_INVALID);
diff --git a/src/sound-theme-spec.c b/src/sound-theme-spec.c
index 11f15d8..274fe26 100644
--- a/src/sound-theme-spec.c
+++ b/src/sound-theme-spec.c
@@ -24,7 +24,10 @@
#include <config.h>
#endif
+#include <errno.h>
+
#include "sound-theme-spec.h"
+#include "malloc.h"
#include "llist.h"
#define DEFAULT_THEME "freedesktop"
@@ -45,7 +48,7 @@ struct ca_theme_data {
char *name;
CA_LLIST_HEAD(ca_data_dir, data_dirs);
- ca_theme_dir *last_dir;
+ ca_data_dir *last_dir;
unsigned n_theme_dir;
ca_bool_t loaded_fallback_theme;
@@ -76,11 +79,11 @@ static int get_data_home(char **e) {
static ca_bool_t data_dir_matches(ca_data_dir *d, const char*output_profile) {
ca_assert(d);
- ca_assert(profile);
+ ca_assert(output_profile);
/* We might want to add more elaborate matching here eventually */
- return streq(d->profile, output_profile);
+ return streq(d->output_profile, output_profile);
}
static ca_data_dir* find_data_dir(ca_theme_data *t, const char *name) {
@@ -103,7 +106,7 @@ static int add_data_dir(ca_theme_data *t, const char *name) {
ca_return_val_if_fail(name, CA_ERROR_INVALID);
if (find_data_dir(t, name))
- return;
+ return CA_SUCCESS;
if (!(d = ca_new0(ca_data_dir, 1)))
return CA_ERROR_OOM;
@@ -146,7 +149,7 @@ static int load_theme_path(ca_theme_data *t, const char *prefix, const char *nam
for (;;) {
char ln[1024];
- if (!(fgets(ln, f))) {
+ if (!(fgets(ln, sizeof(ln), f))) {
if (feof(f))
break;