mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-21 23:40:26 +00:00
added audio_cap_jack_should_exit
Added audio_cap_jack_should_exit in order to prevent freeze if waiting on semaphore but jack callbacks are not triggered (no data).
This commit is contained in:
@@ -323,7 +323,7 @@ struct state_audio * audio_cfg_init(struct module *parent,
|
||||
cfg = delim + 1;
|
||||
}
|
||||
|
||||
int ret = audio_capture_init(device, cfg, &s->audio_capture_device);
|
||||
int ret = audio_capture_init(s->audio_sender_module.get(), device, cfg, &s->audio_capture_device);
|
||||
free(device);
|
||||
|
||||
if(ret != 0) {
|
||||
|
||||
@@ -64,7 +64,7 @@ struct state_audio_capture {
|
||||
void *state;
|
||||
};
|
||||
|
||||
int audio_capture_init(const char *driver, const char *cfg, struct state_audio_capture **state)
|
||||
int audio_capture_init(struct module *parent, const char *driver, const char *cfg, struct state_audio_capture **state)
|
||||
{
|
||||
assert(cfg != NULL);
|
||||
struct state_audio_capture *s = calloc(1, sizeof(struct state_audio_capture));
|
||||
@@ -79,7 +79,7 @@ int audio_capture_init(const char *driver, const char *cfg, struct state_audio_c
|
||||
|
||||
strncpy(s->name, driver, sizeof s->name - 1);
|
||||
|
||||
s->state = s->funcs->init(cfg);
|
||||
s->state = s->funcs->init(parent, cfg);
|
||||
|
||||
if(!s->state) {
|
||||
log_msg(LOG_LEVEL_ERROR, "Error initializing audio capture.\n");
|
||||
@@ -102,7 +102,7 @@ error:
|
||||
struct state_audio_capture *audio_capture_init_null_device()
|
||||
{
|
||||
struct state_audio_capture *device = NULL;
|
||||
int ret = audio_capture_init("none", "", &device);
|
||||
int ret = audio_capture_init(NULL, "none", "", &device);
|
||||
if (ret != 0) {
|
||||
log_msg(LOG_LEVEL_ERROR, "Unable to initialize null audio capture: %d\n", ret);
|
||||
}
|
||||
|
||||
@@ -41,12 +41,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AUDIO_CAPTURE_ABI_VERSION 3
|
||||
struct module;
|
||||
|
||||
#define AUDIO_CAPTURE_ABI_VERSION 4
|
||||
|
||||
struct audio_capture_info {
|
||||
void (*probe)(struct device_info **available_devices, int *count);
|
||||
void (*help)(const char *driver_name);
|
||||
void *(*init)(const char *cfg); ///< @param cfg is not NULL
|
||||
void *(*init)(struct module *parent, const char *cfg); ///< @param cfg is not NULL
|
||||
struct audio_frame *(*read)(void *state);
|
||||
void (*done)(void *state);
|
||||
};
|
||||
@@ -62,7 +64,7 @@ void audio_capture_print_help(bool);
|
||||
/**
|
||||
* @see display_init
|
||||
*/
|
||||
int audio_capture_init(const char *driver, const char *cfg,
|
||||
int audio_capture_init(struct module *parent, const char *driver, const char *cfg,
|
||||
struct state_audio_capture **);
|
||||
struct state_audio_capture *audio_capture_init_null_device(void);
|
||||
struct audio_frame *audio_capture_read(struct state_audio_capture * state);
|
||||
|
||||
@@ -101,8 +101,9 @@ static const int bps_preference[] = { 2, 4, 3, 1 };
|
||||
|
||||
#define DEFAULT_SAMPLE_RATE 48000
|
||||
|
||||
static void * audio_cap_alsa_init(const char *cfg)
|
||||
static void * audio_cap_alsa_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
if(cfg && strcmp(cfg, "help") == 0) {
|
||||
printf("Usage\n");
|
||||
color_printf(TERM_BOLD TERM_FG_RED "\t-s alsa\n" TERM_RESET);
|
||||
|
||||
@@ -200,8 +200,9 @@ static void (^cb)(BOOL) = ^void(BOOL granted) {
|
||||
};
|
||||
#endif // defined __MAC_10_14
|
||||
|
||||
static void * audio_cap_ca_init(const char *cfg)
|
||||
static void * audio_cap_ca_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
if(cfg && strcmp(cfg, "help") == 0) {
|
||||
printf("Available Core Audio capture devices:\n");
|
||||
audio_cap_ca_help(NULL);
|
||||
|
||||
@@ -73,6 +73,7 @@ struct state_jack_capture {
|
||||
sem_t data_sem;
|
||||
struct ring_buffer *data;
|
||||
bool can_process;
|
||||
bool should_exit;
|
||||
|
||||
long int first_channel;
|
||||
};
|
||||
@@ -135,7 +136,14 @@ static void audio_cap_jack_help(const char *client_name)
|
||||
free(available_devices);
|
||||
}
|
||||
|
||||
static void * audio_cap_jack_init(const char *cfg)
|
||||
static void audio_cap_jack_should_exit(void *state)
|
||||
{
|
||||
struct state_jack_capture *s = state;
|
||||
s->should_exit = true;
|
||||
platform_sem_post(&s->data_sem);
|
||||
}
|
||||
|
||||
static void * audio_cap_jack_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
struct state_jack_capture *s;
|
||||
jack_status_t status;
|
||||
@@ -258,6 +266,7 @@ static void * audio_cap_jack_init(const char *cfg)
|
||||
}
|
||||
|
||||
free(ports);
|
||||
register_should_exit_callback(parent, audio_cap_jack_should_exit, s);
|
||||
|
||||
s->can_process = true;
|
||||
|
||||
|
||||
@@ -76,8 +76,9 @@ static void audio_cap_none_help(const char *driver_name)
|
||||
UNUSED(driver_name);
|
||||
}
|
||||
|
||||
static void * audio_cap_none_init(const char *cfg)
|
||||
static void * audio_cap_none_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
struct state_audio_capture_none *s;
|
||||
|
||||
s = (struct state_audio_capture_none *) malloc(sizeof(struct state_audio_capture_none));
|
||||
|
||||
@@ -132,8 +132,9 @@ static void portaudio_close(PaStream * stream) // closes and frees all audio res
|
||||
/*
|
||||
* capture funcitons
|
||||
*/
|
||||
static void * audio_cap_portaudio_init(const char *cfg)
|
||||
static void * audio_cap_portaudio_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
portaudio_print_version();
|
||||
|
||||
if(cfg && strcmp(cfg, "help") == 0) {
|
||||
|
||||
@@ -110,8 +110,9 @@ static void audio_cap_sdi_probe_analog(struct device_info **available_devices, i
|
||||
audio_cap_sdi_probe_common(available_devices, count, "", "Analog audio through capture card");
|
||||
}
|
||||
|
||||
static void * audio_cap_sdi_init(const char *cfg)
|
||||
static void * audio_cap_sdi_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
if(cfg && strcmp(cfg, "help") == 0) {
|
||||
printf("Available vidcap audio devices:\n");
|
||||
audio_cap_sdi_help("embedded");
|
||||
|
||||
@@ -145,8 +145,9 @@ static const char *load_song1() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
static void * audio_cap_sdl_mixer_init(const char *cfg)
|
||||
static void * audio_cap_sdl_mixer_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
|
||||
struct state_sdl_mixer_capture *s = calloc(1, sizeof *s);
|
||||
|
||||
@@ -173,8 +173,9 @@ static char *get_ebu_signal(int sample_rate, int bps, int channels, int frequenc
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void * audio_cap_testcard_init(const char *cfg)
|
||||
static void * audio_cap_testcard_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
string wav_file;
|
||||
char *item, *save_ptr;
|
||||
|
||||
|
||||
@@ -220,8 +220,9 @@ static void show_help() {
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
static void * audio_cap_wasapi_init(const char *cfg)
|
||||
static void * audio_cap_wasapi_init(struct module *parent, const char *cfg)
|
||||
{
|
||||
UNUSED(parent);
|
||||
wchar_t deviceID[1024] = L"";
|
||||
WAVEFORMATEX *pwfx = NULL;
|
||||
int index = -1;
|
||||
|
||||
Reference in New Issue
Block a user