Crossfire Client, Trunk  R18666
Defines | Functions | Variables
/home/leaf/crossfire/client/trunk/sound-src/alsa9.c File Reference
#include <config.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include "newclient.h"
#include "client-types.h"
#include "def_sounds.h"
#include "sndproto.h"
#include "common.h"
#include <alsa/asoundlib.h>
#include <alsa/pcm_plugin.h>
Include dependency graph for alsa9.c:

Go to the source code of this file.

Defines

#define SOUND_DEBUG
#define ALSA_PCM_NEW_HW_PARAMS_API
#define AUDIODEV   "default:0,0"
#define ALSA9_ERROR(str, err)
#define SOUND_DECREASE   0.1

Functions

void alsa_audio_close (void)
int init_audio (void)
void alsa_recover (int e)
int audio_play (int buffer, int off)
void play_sound (int soundnum, int soundtype, int x, int y)
void play_music (const char *name)
int main (int argc, char *argv[])

Variables

snd_pcm_t * handle = NULL
int sndbuf_pos = 0
int * sounds_in_buffer = NULL
int current_buffer = 0
int first_free_buffer = 0
int soundfd = 0
sound_settings settings = { 0, 1, 0, 8000, 200, 2048, 4, AUDIODEV }
snd_pcm_hw_params_t * params
int err = 0

Detailed Description

Used only for alsa 0.9 and later sound. Alsa sound code is sufficiently different from the rest that trying to keep it common didn't make much sense.

Definition in file alsa9.c.


Define Documentation

#define ALSA9_ERROR (   str,
  err 
)
Value:
{ \
                fprintf(stderr,"ALSA9 Error: %s %s\n",str,snd_strerror(err)); }

Definition at line 88 of file alsa9.c.

Definition at line 83 of file alsa9.c.

#define AUDIODEV   "default:0,0"

Definition at line 84 of file alsa9.c.

#define SOUND_DEBUG

Definition at line 32 of file alsa9.c.

#define SOUND_DECREASE   0.1

Definition at line 91 of file alsa9.c.


Function Documentation

void alsa_audio_close ( void  )

Definition at line 106 of file alsa9.c.

Here is the caller graph for this function:

void alsa_recover ( int  e)

Definition at line 230 of file alsa9.c.

Here is the caller graph for this function:

int audio_play ( int  buffer,
int  off 
)

Play a sound using the Alsa9 sound system.

Does the actual task of writing the data to the socket. The ALSA write logic is a bit odd, in that the count you pass in is not the number of bytes you are writing, but the number of samples you are writing. Thus, if you have stereo with 1 byte/channel, you'd divide the number by 2. If you have 16 bit audio with stereo, you'd divide the number by 4.

Parameters:
buffer
off
Returns:

Definition at line 268 of file alsa9.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int init_audio ( void  )

Initialize the Alsa9 sound system.

Returns:
Zero if audio initialized successfully, otherwise -1.

Definition at line 113 of file alsa9.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

The client entry point.

Parameters:
argc
argv
Returns:

Definition at line 489 of file alsa9.c.

Here is the call graph for this function:

void play_music ( const char *  name)

Stub for playing music with the Alsa 9 sound system.

Parameters:
nameA name of a song to play that does not include anything like path or file extensions. It is up to this function to map the name to a file.

Definition at line 479 of file alsa9.c.

Here is the caller graph for this function:

void play_sound ( int  soundnum,
int  soundtype,
int  x,
int  y 
)

Definition at line 302 of file alsa9.c.

Here is the caller graph for this function:


Variable Documentation

int current_buffer = 0

Definition at line 95 of file alsa9.c.

int err = 0

Definition at line 104 of file alsa9.c.

Definition at line 96 of file alsa9.c.

snd_pcm_t* handle = NULL

Definition at line 85 of file alsa9.c.

snd_pcm_hw_params_t* params

Definition at line 102 of file alsa9.c.

sound_settings settings = { 0, 1, 0, 8000, 200, 2048, 4, AUDIODEV }

Definition at line 100 of file alsa9.c.

int sndbuf_pos = 0

Definition at line 86 of file alsa9.c.

int soundfd = 0

Definition at line 98 of file alsa9.c.

int* sounds_in_buffer = NULL

Definition at line 94 of file alsa9.c.