diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-06-11 12:08:37 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-06-11 12:08:37 +0000 |
commit | 00da37f2c448096cdd54481b072db47b2f253141 (patch) | |
tree | cb6c51231fa498831b3e63660105ec00ea98d8f5 /src/pulsecore/sound-file.c | |
parent | 6aeec56708f4af2da0b83fdd65a0d153b9bed272 (diff) |
Merge HUGE set of changes temporarily into a branch, to allow me to move them from one machine to another (lock-free and stuff)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1469 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/sound-file.c')
-rw-r--r-- | src/pulsecore/sound-file.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pulsecore/sound-file.c b/src/pulsecore/sound-file.c index 69b543ab..6e93f8aa 100644 --- a/src/pulsecore/sound-file.c +++ b/src/pulsecore/sound-file.c @@ -42,7 +42,11 @@ int pa_sound_file_load(pa_mempool *pool, const char *fname, pa_sample_spec *ss, int ret = -1; size_t l; sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t frames) = NULL; - assert(fname && ss && chunk); + void *ptr = NULL; + + assert(fname); + assert(ss); + assert(chunk); chunk->memblock = NULL; chunk->index = chunk->length = 0; @@ -99,8 +103,10 @@ int pa_sound_file_load(pa_mempool *pool, const char *fname, pa_sample_spec *ss, chunk->index = 0; chunk->length = l; - if ((readf_function && readf_function(sf, chunk->memblock->data, sfinfo.frames) != sfinfo.frames) || - (!readf_function && sf_read_raw(sf, chunk->memblock->data, l) != l)) { + ptr = pa_memblock_acquire(chunk->memblock); + + if ((readf_function && readf_function(sf, ptr, sfinfo.frames) != sfinfo.frames) || + (!readf_function && sf_read_raw(sf, ptr, l) != l)) { pa_log("Premature file end"); goto finish; } @@ -112,6 +118,9 @@ finish: if (sf) sf_close(sf); + if (ptr) + pa_memblock_release(chunk->memblock); + if (ret != 0 && chunk->memblock) pa_memblock_unref(chunk->memblock); |