fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
audio.c File Reference

Audio system implementation. More...

#include "audio.h"
#include <assert.h>
#include <stdio.h>
#include <AL/alut.h>
#include "std2/errcode.h"
Include dependency graph for audio.c:

Functions

static void perror_al (const char *const msg)
 Prints the last OpenAL error to stderr with the given message.
 
static void perror_alut (const char *const msg)
 Prints the last ALUT error to stderr with the given message.
 
static int audioInit (void)
 Initializes the audio system if it has not been initialized yet.
 
static void audioStopPlayback (void)
 Stops the current audio playback, if any. The last allocated AL buffer is then detached from the source and deleted. The source is retained.
 
void Audio_exit (void)
 Exits the audio system and frees all resources. This function should be called before the program exits, or when the audio system is no longer needed. This function is safe to call even if the audio system has not been initialized.
 
bool Audio_isPlaying (void)
 Checks the playback status of the audio system.
 
int Audio_play (const char *const fp)
 Attempts to play the audio file at the given file path. This function initializes the audio system if it has not been initialized yet. If the audio system is already playing audio, the current audio playback is stopped before the new audio file is played.
 

Variables

struct { 
 
   bool   init 
 True if the audio system has been initialized. More...
 
   ALuint   sid 
 Allocated source id for audio playback. More...
 
   ALuint   bid 
 Allocated buffer id for audio data. More...
 
gAudio 
 Global audio system state.
 

Detailed Description

Audio system implementation.

Function Documentation

◆ Audio_exit()

void Audio_exit ( void )

Exits the audio system and frees all resources. This function should be called before the program exits, or when the audio system is no longer needed. This function is safe to call even if the audio system has not been initialized.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Audio_isPlaying()

bool Audio_isPlaying ( void )

Checks the playback status of the audio system.

Returns
true if the audio system is playing audio, false otherwise (e.g. the audio system has completed playback or failed to start playback)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Audio_play()

int Audio_play ( const char * fp)

Attempts to play the audio file at the given file path. This function initializes the audio system if it has not been initialized yet. If the audio system is already playing audio, the current audio playback is stopped before the new audio file is played.

Parameters
fpthe file path of the audio file to play
Returns
0 on success, a negative error code on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ audioInit()

static int audioInit ( void )
static

Initializes the audio system if it has not been initialized yet.

Returns
0 on success, a negative error code on failure
Here is the caller graph for this function:

◆ audioStopPlayback()

static void audioStopPlayback ( void )
static

Stops the current audio playback, if any. The last allocated AL buffer is then detached from the source and deleted. The source is retained.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ perror_al()

static void perror_al ( const char *const msg)
static

Prints the last OpenAL error to stderr with the given message.

Parameters
msgmessage to print before the error message
Note
If no OpenAL error has occurred, this function does nothing.
Here is the caller graph for this function:

◆ perror_alut()

static void perror_alut ( const char *const msg)
static

Prints the last ALUT error to stderr with the given message.

Parameters
msgmessage to print before the error message
Note
If no ALUT error has occurred, this function does nothing.
Here is the caller graph for this function:

Variable Documentation

◆ bid

ALuint bid

Allocated buffer id for audio data.

◆ [struct]

struct { ... } gAudio

Global audio system state.

◆ init

bool init

True if the audio system has been initialized.

◆ sid

ALuint sid

Allocated source id for audio playback.