mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-06 13:29:56 -05:00
format: Expose pa_format_info<->pa_sample_spec conversion functions
These utility functions could be handy to clients. pa_format_info_to_sample_spec_fake() isn't made public, but the return value is changed to keep in sync with pa_format_info_to_sample_spec().
This commit is contained in:
parent
63429b67c7
commit
c60f698f1e
5 changed files with 19 additions and 14 deletions
|
|
@ -219,10 +219,10 @@ pa_format_info* pa_format_info_from_sample_spec(pa_sample_spec *ss, pa_channel_m
|
|||
}
|
||||
|
||||
/* For PCM streams */
|
||||
pa_bool_t pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
|
||||
int pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, pa_channel_map *map) {
|
||||
char *sf = NULL, *m = NULL;
|
||||
int rate, channels;
|
||||
pa_bool_t ret = FALSE;
|
||||
int ret = -PA_ERR_INVALID;
|
||||
|
||||
pa_assert(f);
|
||||
pa_assert(ss);
|
||||
|
|
@ -249,7 +249,7 @@ pa_bool_t pa_format_info_to_sample_spec(pa_format_info *f, pa_sample_spec *ss, p
|
|||
goto out;
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
ret = 0;
|
||||
|
||||
out:
|
||||
if (sf)
|
||||
|
|
@ -261,23 +261,23 @@ out:
|
|||
}
|
||||
|
||||
/* For compressed streams */
|
||||
pa_bool_t pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss) {
|
||||
int pa_format_info_to_sample_spec_fake(pa_format_info *f, pa_sample_spec *ss) {
|
||||
int rate;
|
||||
|
||||
pa_assert(f);
|
||||
pa_assert(ss);
|
||||
pa_return_val_if_fail(f->encoding != PA_ENCODING_PCM, FALSE);
|
||||
pa_return_val_if_fail(f->encoding != PA_ENCODING_PCM, -PA_ERR_INVALID);
|
||||
|
||||
ss->format = PA_SAMPLE_S16LE;
|
||||
ss->channels = 2;
|
||||
|
||||
pa_return_val_if_fail(pa_format_info_get_prop_int(f, PA_PROP_FORMAT_RATE, &rate) == 0, FALSE);
|
||||
pa_return_val_if_fail(pa_format_info_get_prop_int(f, PA_PROP_FORMAT_RATE, &rate) == 0, -PA_ERR_INVALID);
|
||||
ss->rate = (uint32_t) rate;
|
||||
|
||||
if (f->encoding == PA_ENCODING_EAC3_IEC61937)
|
||||
ss->rate *= 4;
|
||||
|
||||
return TRUE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void pa_format_info_set_sample_format(pa_format_info *f, pa_sample_format_t sf) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue