mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-05 13:29:57 -05:00
sndfile-util: Check return value of sf_command for errors
It's better to show a message what the error is, instead of just asserting that no errors happen in an external library call.
This commit is contained in:
parent
55fdb0162c
commit
e04d592a47
1 changed files with 16 additions and 6 deletions
|
|
@ -34,12 +34,16 @@
|
|||
|
||||
int pa_sndfile_read_sample_spec(SNDFILE *sf, pa_sample_spec *ss) {
|
||||
SF_INFO sfi;
|
||||
int sf_errno;
|
||||
|
||||
pa_assert(sf);
|
||||
pa_assert(ss);
|
||||
|
||||
pa_zero(sfi);
|
||||
pa_assert_se(sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)) == 0);
|
||||
if ((sf_errno = sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)))) {
|
||||
pa_log_error("sndfile: %s", sf_error_number(sf_errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (sfi.format & SF_FORMAT_SUBMASK) {
|
||||
|
||||
|
|
@ -175,6 +179,7 @@ int pa_sndfile_read_channel_map(SNDFILE *sf, pa_channel_map *cm) {
|
|||
};
|
||||
|
||||
SF_INFO sfi;
|
||||
int sf_errno;
|
||||
int *channels;
|
||||
unsigned c;
|
||||
|
||||
|
|
@ -182,12 +187,13 @@ int pa_sndfile_read_channel_map(SNDFILE *sf, pa_channel_map *cm) {
|
|||
pa_assert(cm);
|
||||
|
||||
pa_zero(sfi);
|
||||
pa_assert_se(sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)) == 0);
|
||||
if ((sf_errno = sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)))) {
|
||||
pa_log_error("sndfile: %s", sf_error_number(sf_errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
channels = pa_xnew(int, sfi.channels);
|
||||
if (!sf_command(sf, SFC_GET_CHANNEL_MAP_INFO,
|
||||
channels, sizeof(channels[0]) * sfi.channels)) {
|
||||
|
||||
if (!sf_command(sf, SFC_GET_CHANNEL_MAP_INFO, channels, sizeof(channels[0]) * sfi.channels)) {
|
||||
pa_xfree(channels);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -325,6 +331,7 @@ void pa_sndfile_init_proplist(SNDFILE *sf, pa_proplist *p) {
|
|||
|
||||
SF_INFO sfi;
|
||||
SF_FORMAT_INFO fi;
|
||||
int sf_errno;
|
||||
unsigned c;
|
||||
|
||||
pa_assert(sf);
|
||||
|
|
@ -346,7 +353,10 @@ void pa_sndfile_init_proplist(SNDFILE *sf, pa_proplist *p) {
|
|||
}
|
||||
|
||||
pa_zero(sfi);
|
||||
pa_assert_se(sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)) == 0);
|
||||
if ((sf_errno = sf_command(sf, SFC_GET_CURRENT_SF_INFO, &sfi, sizeof(sfi)))) {
|
||||
pa_log_error("sndfile: %s", sf_error_number(sf_errno));
|
||||
return;
|
||||
}
|
||||
|
||||
pa_zero(fi);
|
||||
fi.format = sfi.format;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue