Audio null playback/capture: error instead of assert

Do not assume that initialization of null device must succeed - eg. in
some errorneous setup there may be API mismatch leading to init failed.
This commit is contained in:
Martin Pulec
2021-09-23 11:57:04 +02:00
parent 36e15e66e1
commit e59b6574ee
2 changed files with 8 additions and 4 deletions

View File

@@ -100,9 +100,11 @@ error:
struct state_audio_capture *audio_capture_init_null_device()
{
struct state_audio_capture *device;
struct state_audio_capture *device = NULL;
int ret = audio_capture_init("none", NULL, &device);
assert(ret == 0);
if (ret != 0) {
log_msg(LOG_LEVEL_ERROR, "Unable to initialize null audio capture: %d\n", ret);
}
return device;
}

View File

@@ -104,9 +104,11 @@ error:
struct state_audio_playback *audio_playback_init_null_device(void)
{
struct state_audio_playback *device;
struct state_audio_playback *device = NULL;
int ret = audio_playback_init("none", NULL, &device);
assert(ret == 0);
if (ret != 0) {
log_msg(LOG_LEVEL_ERROR, "Unable to initialize null audio playback: %d\n", ret);
}
return device;
}