mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
sndfile: big rework of libsndfile interfacing code
This adds proper channel map handling when reading/writing audio files. This allows surround .WAV files to be played with the right channel setup automatically. This also merges paplay into pacat and adds recording into formatted files to pacat.
This commit is contained in:
parent
759a9d0cc5
commit
5c10b84e0f
11 changed files with 1259 additions and 921 deletions
|
|
@ -219,11 +219,14 @@ int pa_scache_add_file(pa_core *c, const char *name, const char *filename, uint3
|
|||
pa_assert(name);
|
||||
pa_assert(filename);
|
||||
|
||||
if (pa_sound_file_load(c->mempool, filename, &ss, &map, &chunk) < 0)
|
||||
return -1;
|
||||
|
||||
p = pa_proplist_new();
|
||||
pa_proplist_sets(p, PA_PROP_MEDIA_FILENAME, filename);
|
||||
|
||||
if (pa_sound_file_load(c->mempool, filename, &ss, &map, &chunk, p) < 0) {
|
||||
pa_proplist_free(p);
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = pa_scache_add_item(c, name, &ss, &map, &chunk, p, idx);
|
||||
pa_memblock_unref(chunk.memblock);
|
||||
pa_proplist_free(p);
|
||||
|
|
@ -311,11 +314,14 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t
|
|||
if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE)))
|
||||
return -1;
|
||||
|
||||
merged = pa_proplist_new();
|
||||
pa_proplist_setf(merged, PA_PROP_MEDIA_NAME, "Sample %s", name);
|
||||
|
||||
if (e->lazy && !e->memchunk.memblock) {
|
||||
pa_channel_map old_channel_map = e->channel_map;
|
||||
|
||||
if (pa_sound_file_load(c->mempool, e->filename, &e->sample_spec, &e->channel_map, &e->memchunk) < 0)
|
||||
return -1;
|
||||
if (pa_sound_file_load(c->mempool, e->filename, &e->sample_spec, &e->channel_map, &e->memchunk, merged) < 0)
|
||||
goto fail;
|
||||
|
||||
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE|PA_SUBSCRIPTION_EVENT_CHANGE, e->index);
|
||||
|
||||
|
|
@ -328,7 +334,7 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t
|
|||
}
|
||||
|
||||
if (!e->memchunk.memblock)
|
||||
return -1;
|
||||
goto fail;
|
||||
|
||||
pa_log_debug("Playing sample \"%s\" on \"%s\"", name, sink->name);
|
||||
|
||||
|
|
@ -344,17 +350,13 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t
|
|||
else
|
||||
pass_volume = FALSE;
|
||||
|
||||
merged = pa_proplist_new();
|
||||
pa_proplist_setf(merged, PA_PROP_MEDIA_NAME, "Sample %s", name);
|
||||
pa_proplist_update(merged, PA_UPDATE_REPLACE, e->proplist);
|
||||
|
||||
if (p)
|
||||
pa_proplist_update(merged, PA_UPDATE_REPLACE, p);
|
||||
|
||||
if (pa_play_memchunk(sink, &e->sample_spec, &e->channel_map, &e->memchunk, pass_volume ? &r : NULL, merged, sink_input_idx) < 0) {
|
||||
pa_proplist_free(merged);
|
||||
return -1;
|
||||
}
|
||||
if (pa_play_memchunk(sink, &e->sample_spec, &e->channel_map, &e->memchunk, pass_volume ? &r : NULL, merged, sink_input_idx) < 0)
|
||||
goto fail;
|
||||
|
||||
pa_proplist_free(merged);
|
||||
|
||||
|
|
@ -362,6 +364,10 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t
|
|||
time(&e->last_used_time);
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
pa_proplist_free(merged);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue