GNUnet  0.10.x
Data Structures | Typedefs | Functions
Microphone library

Provides access to hardware microphones. More...

Data Structures

struct  GNUNET_MICROPHONE_Handle
 A microphone is a device that can capture or otherwise produce audio data. More...
 

Typedefs

typedef void(* GNUNET_MICROPHONE_RecordedDataCallback) (void *cls, size_t data_size, const void *data)
 Process recorded audio data. More...
 
typedef int(* GNUNET_MICROPHONE_EnableCallback) (void *cls, GNUNET_MICROPHONE_RecordedDataCallback rdc, void *rdc_cls)
 Enable a microphone. More...
 
typedef void(* GNUNET_MICROPHONE_DisableCallback) (void *cls)
 Function that disables a microphone. More...
 
typedef void(* GNUNET_MICROPHONE_DestroyCallback) (void *cls)
 Function to destroy a microphone. More...
 

Functions

struct GNUNET_MICROPHONE_HandleGNUNET_MICROPHONE_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create a microphone that corresponds to the microphone hardware of our system. More...
 
void GNUNET_MICROPHONE_destroy (struct GNUNET_MICROPHONE_Handle *microphone)
 Destroy a microphone. More...
 

Detailed Description

Provides access to hardware microphones.

Typedef Documentation

◆ GNUNET_MICROPHONE_RecordedDataCallback

typedef void(* GNUNET_MICROPHONE_RecordedDataCallback) (void *cls, size_t data_size, const void *data)

Process recorded audio data.

Parameters
clsclsoure
data_sizenumber of bytes in data
dataaudio data to play

Definition at line 53 of file gnunet_microphone_lib.h.

◆ GNUNET_MICROPHONE_EnableCallback

typedef int(* GNUNET_MICROPHONE_EnableCallback) (void *cls, GNUNET_MICROPHONE_RecordedDataCallback rdc, void *rdc_cls)

Enable a microphone.

Parameters
clsclsoure
rdcfunction to call with recorded data
rdc_clsclosure for dc
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 65 of file gnunet_microphone_lib.h.

◆ GNUNET_MICROPHONE_DisableCallback

typedef void(* GNUNET_MICROPHONE_DisableCallback) (void *cls)

Function that disables a microphone.

Parameters
clsclsoure

Definition at line 74 of file gnunet_microphone_lib.h.

◆ GNUNET_MICROPHONE_DestroyCallback

typedef void(* GNUNET_MICROPHONE_DestroyCallback) (void *cls)

Function to destroy a microphone.

Parameters
clsclsoure

Definition at line 81 of file gnunet_microphone_lib.h.

Function Documentation

◆ GNUNET_MICROPHONE_create_from_hardware()

struct GNUNET_MICROPHONE_Handle* GNUNET_MICROPHONE_create_from_hardware ( const struct GNUNET_CONFIGURATION_Handle cfg)

Create a microphone that corresponds to the microphone hardware of our system.

Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 170 of file microphone.c.

References Microphone::cfg, GNUNET_MICROPHONE_Handle::cls, destroy(), GNUNET_MICROPHONE_Handle::destroy_microphone, disable(), GNUNET_MICROPHONE_Handle::disable_microphone, enable(), GNUNET_MICROPHONE_Handle::enable_microphone, GNUNET_new, mic, and microphone.

Referenced by run().

171 {
173  struct Microphone *mic;
174 
175  mic = GNUNET_new(struct Microphone);
176  mic->cfg = cfg;
177  microphone = GNUNET_new(struct GNUNET_MICROPHONE_Handle);
178  microphone->cls = mic;
179  microphone->enable_microphone = &enable;
180  microphone->disable_microphone = &disable;
181  microphone->destroy_microphone = &destroy;
182  return microphone;
183 }
static int enable(void *cls, GNUNET_MICROPHONE_RecordedDataCallback rdc, void *rdc_cls)
Enable a microphone.
Definition: microphone.c:97
GNUNET_MICROPHONE_DisableCallback disable_microphone
Turn the microphone off.
GNUNET_MICROPHONE_EnableCallback enable_microphone
Turn on the microphone.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void destroy(void *cls)
Function to destroy a microphone.
Definition: microphone.c:153
static struct GNUNET_MICROPHONE_Handle * mic
Our microphone.
GNUNET_MICROPHONE_DestroyCallback destroy_microphone
Destroy the microphone.
void * cls
Closure for the callbacks.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void disable(void *cls)
Function that disables a microphone.
Definition: microphone.c:131
Internal data structures for the microphone.
Definition: microphone.c:37
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: microphone.c:41
A microphone is a device that can capture or otherwise produce audio data.
static struct GNUNET_MICROPHONE_Handle * microphone
Handle to the microphone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_MICROPHONE_destroy()

void GNUNET_MICROPHONE_destroy ( struct GNUNET_MICROPHONE_Handle microphone)

Destroy a microphone.

Parameters
microphonemicrophone to destroy

Definition at line 192 of file microphone.c.

References GNUNET_MICROPHONE_Handle::cls, GNUNET_MICROPHONE_Handle::destroy_microphone, and GNUNET_free.

Referenced by do_shutdown(), and do_stop_task().

193 {
194  microphone->destroy_microphone(microphone->cls);
195  GNUNET_free(microphone);
196 }
GNUNET_MICROPHONE_DestroyCallback destroy_microphone
Destroy the microphone.
void * cls
Closure for the callbacks.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function: