]> code.delx.au - pulseaudio/commitdiff
when loading sound files, initialize channel map data properly
authorLennart Poettering <lennart@poettering.net>
Sat, 22 Apr 2006 21:50:15 +0000 (21:50 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 22 Apr 2006 21:50:15 +0000 (21:50 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@777 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/polypcore/core-scache.c
src/polypcore/sound-file.c
src/polypcore/sound-file.h

index 394bdab4108067d35e1b7738d69ec39766008b58..6632a1710bdf52fabd7661b6950bfafa89367764 100644 (file)
@@ -157,6 +157,7 @@ int pa_scache_add_item(pa_core *c, const char *name, const pa_sample_spec *ss, c
 
 int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint32_t *idx) {
     pa_sample_spec ss;
+    pa_channel_map map;
     pa_memchunk chunk;
     int r;
 
@@ -167,10 +168,10 @@ int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint3
         filename = buf;
 #endif
 
-    if (pa_sound_file_load(filename, &ss, &chunk, c->memblock_stat) < 0)
+    if (pa_sound_file_load(filename, &ss, &map, &chunk, c->memblock_stat) < 0)
         return -1;
         
-    r = pa_scache_add_item(c, name, &ss, NULL, &chunk, idx);
+    r = pa_scache_add_item(c, name, &ss, &map, &chunk, idx);
     pa_memblock_unref(chunk.memblock);
 
     return r;
@@ -252,7 +253,7 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, const pa_cv
         return -1;
 
     if (e->lazy && !e->memchunk.memblock) {
-        if (pa_sound_file_load(e->filename, &e->sample_spec, &e->memchunk, c->memblock_stat) < 0)
+        if (pa_sound_file_load(e->filename, &e->sample_spec, &e->channel_map, &e->memchunk, c->memblock_stat) < 0)
             return -1;
 
         pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_CHANGE, e->index);
index d86141ce463dac0ae2a29ca3b659cbd63ab4b905..7a4ef07555d81bd8c6b643a5dee2e587b1e0f77b 100644 (file)
@@ -35,7 +35,7 @@
 
 #define MAX_FILE_SIZE (1024*1024)
 
-int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_memchunk *chunk, pa_memblock_stat *s) {
+int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_channel_map *map, pa_memchunk *chunk, pa_memblock_stat *s) {
     SNDFILE*sf = NULL;
     SF_INFO sfinfo;
     int ret = -1;
@@ -74,6 +74,9 @@ int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_memchunk *chunk
         pa_log(__FILE__": Unsupported sample format in file %s", fname);
         goto finish;
     }
+
+    if (map)
+        pa_channel_map_init_auto(map, ss->channels);
     
     if ((l = pa_frame_size(ss)*sfinfo.frames) > MAX_FILE_SIZE) {
         pa_log(__FILE__": File too large");
index ffa551b528f54159a6d9cd0339fa525276c4007f..9d687f90e37c2d06ffc82201fed8b196592bc87a 100644 (file)
 ***/
 
 #include <polyp/sample.h>
+#include <polyp/channelmap.h>
 #include <polypcore/memchunk.h>
 
-int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_memchunk *chunk, pa_memblock_stat *s);
+int pa_sound_file_load(const char *fname, pa_sample_spec *ss, pa_channel_map *map, pa_memchunk *chunk, pa_memblock_stat *s);
 
 int pa_sound_file_too_big_to_cache(const char *fname);