mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-20 17:40:12 +00:00
Check if Pa_GetDeviceInfo isn't NULL
* TODO - more serious problem is that portaudio gives sometimes different indices in different situations (eg. help and actual driver instantiation). It is rather Portaudio bug caused by some general state initialization in help (ALSA etc.)
This commit is contained in:
@@ -68,6 +68,8 @@
|
||||
#define CHANNELS 2
|
||||
#define SECONDS 5
|
||||
|
||||
#define MODULE_NAME "[Portaudio capture] "
|
||||
|
||||
struct state_portaudio_capture {
|
||||
struct audio_frame frame;
|
||||
PaStream *stream;
|
||||
@@ -230,6 +232,15 @@ void * portaudio_capture_init(char *cfg)
|
||||
device_info = Pa_GetDeviceInfo(input_device);
|
||||
}
|
||||
|
||||
if(device_info == NULL) {
|
||||
fprintf(stderr, MODULE_NAME "Couldn't obtain requested portaudio device.\n"
|
||||
MODULE_NAME "Follows list of available Portaudio devices.\n");
|
||||
portaudio_playback_help(NULL);
|
||||
free(s);
|
||||
Pa_Terminate();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(CHANNELS <= device_info->maxInputChannels)
|
||||
inputParameters.channelCount = CHANNELS;
|
||||
else
|
||||
|
||||
@@ -60,6 +60,8 @@
|
||||
#include "debug.h"
|
||||
#include "utils/fs_lock.h"
|
||||
|
||||
#define MODULE_NAME "[Portaudio playback] "
|
||||
|
||||
struct state_portaudio_playback {
|
||||
audio_frame frame;
|
||||
int samples;
|
||||
@@ -194,10 +196,19 @@ void * portaudio_playback_init(char *cfg)
|
||||
assert(output_device >= -1);
|
||||
s->device = output_device;
|
||||
const PaDeviceInfo *device_info;
|
||||
if(output_device >= 0)
|
||||
if(output_device >= 0) {
|
||||
device_info = Pa_GetDeviceInfo(output_device);
|
||||
else
|
||||
} else {
|
||||
device_info = Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice());
|
||||
}
|
||||
if(device_info == NULL) {
|
||||
fprintf(stderr, MODULE_NAME "Couldn't obtain requested portaudio device.\n"
|
||||
MODULE_NAME "Follows list of available Portaudio devices.\n");
|
||||
portaudio_playback_help(NULL);
|
||||
free(s);
|
||||
Pa_Terminate();
|
||||
return NULL;
|
||||
}
|
||||
s->max_output_channels = device_info->maxOutputChannels;
|
||||
|
||||
portaudio_reconfigure(s, 16, 2, 48000);
|
||||
|
||||
Reference in New Issue
Block a user