#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <stdint.h>
#include <semaphore.h>
#include "audio_loopback.h"
#include "utility.h"
Go to the source code of this file.
Data Structures | |
struct | audio_loopback_ts |
Enumerations | |
enum | audio_loopback_thread_state_te { AUDIO_LOOPBACK_STOP, AUDIO_LOOPBACK_RUN } |
Functions | |
static void | audio_loopback_thr (void *param) |
static void | audio_loopback_convert_thr (void *param) |
static void | audio_loopback_trigger (void) |
int32_t | audio_loopback_start (te_audio_device_types device_type, const char *device_name, uint32_t segment_size, int32_t sample_frequency) |
int32_t | audio_loopback_stop (void) |
void | audio_loopback_feed (const double *src) |
Variables | |
static audio_loopback_ts | loopback |
static pthread_cond_t | write_segment_cond [AUDIO_BUFFER_SEGMENTS] = {PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER} |
static pthread_mutex_t | write_segment_mutex [AUDIO_BUFFER_SEGMENTS] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER} |
static sem_t | loopback_trigger |
Audio loopback thread states.
Definition at line 38 of file audio_loopback.c.
static void audio_loopback_convert_thr | ( | void * | param | ) | [static] |
Definition at line 159 of file audio_loopback.c.
References AUDIO_BUFFER_SEGMENTS, audio_loopback_ts::audio_data, audio_data, audio_loopback_ts::audio_device, audio_double2raw(), AUDIO_LOOPBACK_RUN, audio_loopback_trigger(), BUFFER_SEGMENT_1, audio_loopback_ts::dst_samples, audio_loopback_ts::run, write_segment_cond, and write_segment_mutex.
Referenced by audio_loopback_start().
void audio_loopback_feed | ( | const double * | src | ) |
Used to copy audio data (sound) to the loopback device
src | Pointer to the source audio data (usually filtered). |
Definition at line 121 of file audio_loopback.c.
References AUDIO_BUFFER_SEGMENTS, audio_loopback_ts::audio_data, BUFFER_SEGMENT_1, audio_loopback_ts::dst_samples, and write_segment_cond.
int32_t audio_loopback_start | ( | te_audio_device_types | device_type, | |
const char * | device_name, | |||
uint32_t | segment_size, | |||
int32_t | sample_frequency | |||
) |
Starts the audio loopback device.
device_type | Audio device type | |
device_name | Audio device name | |
segment_size | Number of samples per segment | |
sample_frequency | Sample frequency in Hertz |
Definition at line 82 of file audio_loopback.c.
References AUDIO_BUFFER_SEGMENTS, audio_create(), audio_loopback_ts::audio_data, audio_loopback_ts::audio_device, AUDIO_DEVICE_PLAY, audio_device_samples_get(), audio_init(), audio_loopback_convert_thr(), AUDIO_LOOPBACK_RUN, audio_loopback_thr(), audio_open(), audio_loopback_ts::convert_id, audio_loopback_ts::dst_samples, loopback_trigger, audio_loopback_ts::play_id, audio_loopback_ts::run, and audio_loopback_ts::src_samples.
int32_t audio_loopback_stop | ( | void | ) |
Stop and frees the audio loopback device
Definition at line 110 of file audio_loopback.c.
References audio_loopback_ts::audio_data, audio_destroy(), audio_loopback_ts::audio_device, AUDIO_LOOPBACK_STOP, audio_loopback_ts::convert_id, audio_loopback_ts::play_id, and audio_loopback_ts::run.
static void audio_loopback_thr | ( | void * | param | ) | [static] |
Definition at line 137 of file audio_loopback.c.
References AUDIO_BUFFER_SEGMENTS, audio_loopback_ts::audio_device, AUDIO_LOOPBACK_RUN, audio_play(), BUFFER_SEGMENT_1, loopback_trigger, audio_loopback_ts::run, and write_segment_cond.
Referenced by audio_loopback_start().
static void audio_loopback_trigger | ( | void | ) | [static] |
Definition at line 105 of file audio_loopback.c.
References loopback_trigger.
Referenced by audio_loopback_convert_thr().
audio_loopback_ts loopback [static] |
Definition at line 66 of file audio_loopback.c.
sem_t loopback_trigger [static] |
Definition at line 69 of file audio_loopback.c.
Referenced by audio_loopback_start(), audio_loopback_thr(), and audio_loopback_trigger().
pthread_cond_t write_segment_cond[AUDIO_BUFFER_SEGMENTS] = {PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER} [static] |
Definition at line 67 of file audio_loopback.c.
Referenced by audio_loopback_convert_thr(), audio_loopback_feed(), and audio_loopback_thr().
pthread_mutex_t write_segment_mutex[AUDIO_BUFFER_SEGMENTS] = {PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER} [static] |