GNUnet  0.10.x
Data Structures | Typedefs | Functions
Speaker service

Access hardware audio speakers. More...

Data Structures

struct  GNUNET_SPEAKER_Handle
 A speaker is a device that can play or record audio data. More...
 

Typedefs

typedef int(* GNUNET_SPEAKER_EnableCallback) (void *cls)
 Function that enables a speaker. More...
 
typedef void(* GNUNET_SPEAKER_DisableCallback) (void *cls)
 Function that disables a speaker. More...
 
typedef void(* GNUNET_SPEAKER_DestroyCallback) (void *cls)
 Function to destroy a speaker. More...
 
typedef void(* GNUNET_SPEAKER_PlayCallback) (void *cls, size_t data_size, const void *data)
 Function to cause a speaker to play audio data. More...
 

Functions

struct GNUNET_SPEAKER_HandleGNUNET_SPEAKER_create_from_hardware (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Create a speaker that corresponds to the speaker hardware of our system. More...
 
void GNUNET_SPEAKER_destroy (struct GNUNET_SPEAKER_Handle *speaker)
 Destroy a speaker. More...
 

Detailed Description

Access hardware audio speakers.

Typedef Documentation

◆ GNUNET_SPEAKER_EnableCallback

typedef int(* GNUNET_SPEAKER_EnableCallback) (void *cls)

Function that enables a speaker.

Parameters
clsclosure
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 52 of file gnunet_speaker_lib.h.

◆ GNUNET_SPEAKER_DisableCallback

typedef void(* GNUNET_SPEAKER_DisableCallback) (void *cls)

Function that disables a speaker.

Parameters
clsclosure

Definition at line 59 of file gnunet_speaker_lib.h.

◆ GNUNET_SPEAKER_DestroyCallback

typedef void(* GNUNET_SPEAKER_DestroyCallback) (void *cls)

Function to destroy a speaker.

Parameters
clsclosure

Definition at line 66 of file gnunet_speaker_lib.h.

◆ GNUNET_SPEAKER_PlayCallback

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

Function to cause a speaker to play audio data.

Parameters
clsclosure
data_sizenumber of bytes in data
dataaudio data to play, format is opaque to the API but should be OPUS.

Definition at line 76 of file gnunet_speaker_lib.h.

Function Documentation

◆ GNUNET_SPEAKER_create_from_hardware()

struct GNUNET_SPEAKER_Handle* GNUNET_SPEAKER_create_from_hardware ( const struct GNUNET_CONFIGURATION_Handle cfg)

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

Parameters
cfgconfiguration to use
Returns
NULL on error

Definition at line 160 of file speaker.c.

References Speaker::cfg, GNUNET_SPEAKER_Handle::cls, destroy(), GNUNET_SPEAKER_Handle::destroy_speaker, disable(), GNUNET_SPEAKER_Handle::disable_speaker, enable(), GNUNET_SPEAKER_Handle::enable_speaker, GNUNET_new, GNUNET_SPEAKER_Handle::play, play(), and speaker.

Referenced by run().

161 {
163  struct Speaker *spe;
164 
165  spe = GNUNET_new (struct Speaker);
166  spe->cfg = cfg;
167  speaker = GNUNET_new (struct GNUNET_SPEAKER_Handle);
168  speaker->cls = spe;
169  speaker->enable_speaker = &enable;
170  speaker->play = &play;
171  speaker->disable_speaker = &disable;
172  speaker->destroy_speaker = &destroy;
173  return speaker;
174 }
GNUNET_SPEAKER_PlayCallback play
Play audio.
GNUNET_SPEAKER_DisableCallback disable_speaker
Turn the speaker off.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Internal data structures for the speaker.
Definition: speaker.c:36
static int enable(void *cls)
Function that enables a speaker.
Definition: speaker.c:58
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
void * cls
Closure for the callbacks.
static void destroy(void *cls)
Function to destroy a speaker.
Definition: speaker.c:110
static void disable(void *cls)
Function that disables a speaker.
Definition: speaker.c:88
static void play(void *cls, size_t data_size, const void *data)
Function to cause a speaker to play audio data.
Definition: speaker.c:128
A speaker is a device that can play or record audio data.
static struct GNUNET_SPEAKER_Handle * speaker
Handle to the speaker.
GNUNET_SPEAKER_DestroyCallback destroy_speaker
Destroy the speaker.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: speaker.c:41
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SPEAKER_destroy()

void GNUNET_SPEAKER_destroy ( struct GNUNET_SPEAKER_Handle speaker)

Destroy a speaker.

Parameters
speakerspeaker to destroy

Definition at line 183 of file speaker.c.

References GNUNET_SPEAKER_Handle::cls, GNUNET_SPEAKER_Handle::destroy_speaker, and GNUNET_free.

Referenced by do_shutdown(), and do_stop_task().

184 {
185  speaker->destroy_speaker (speaker->cls);
186  GNUNET_free (speaker);
187 }
void * cls
Closure for the callbacks.
#define GNUNET_free(ptr)
Wrapper around free.
GNUNET_SPEAKER_DestroyCallback destroy_speaker
Destroy the speaker.
Here is the caller graph for this function: