GNUnet  0.11.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 158 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().

160 {
162  struct Speaker *spe;
163 
164  spe = GNUNET_new (struct Speaker);
165  spe->cfg = cfg;
166  speaker = GNUNET_new (struct GNUNET_SPEAKER_Handle);
167  speaker->cls = spe;
168  speaker->enable_speaker = &enable;
169  speaker->play = &play;
170  speaker->disable_speaker = &disable;
171  speaker->destroy_speaker = &destroy;
172  return speaker;
173 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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:57
GNUNET_SPEAKER_EnableCallback enable_speaker
Turn on the speaker.
void * cls
Closure for the callbacks.
static void destroy(void *cls)
Function to destroy a speaker.
Definition: speaker.c:108
static void disable(void *cls)
Function that disables a speaker.
Definition: speaker.c:86
static void play(void *cls, size_t data_size, const void *data)
Function to cause a speaker to play audio data.
Definition: speaker.c:126
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 182 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().

183 {
184  speaker->destroy_speaker (speaker->cls);
185  GNUNET_free (speaker);
186 }
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: