pa_linux_alsa.c File Reference

#include <alsa/asoundlib.h>
#include <sys/poll.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <pthread.h>
#include <signal.h>
#include <time.h>
#include <sys/mman.h>
#include "portaudio.h"
#include "pa_util.h"
#include "pa_unix_util.h"
#include "pa_allocation.h"
#include "pa_hostapi.h"
#include "pa_stream.h"
#include "pa_cpuload.h"
#include "pa_process.h"
#include "pa_endianness.h"
#include "pa_debugprint.h"
#include "pa_linux_alsa.h"

Data Structures

struct  PaAlsaStreamComponent
struct  PaAlsaStream
struct  PaAlsaHostApiRepresentation
struct  PaAlsaDeviceInfo
struct  HwDevInfo

Defines

#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#define ENSURE_(expr, code)
#define ASSERT_CALL_(expr, success)

Enumerations

enum  StreamDirection { StreamDirection_In, StreamDirection_Out }

Functions

int PaAlsa_SetNumPeriods (int numPeriods)
PaError PaAlsa_Initialize (PaUtilHostApiRepresentation **hostApi, PaHostApiIndex hostApiIndex)
void PaAlsa_InitializeStreamInfo (PaAlsaStreamInfo *info)
void PaAlsa_EnableRealtimeScheduling (PaStream *s, int enable)
PaError PaAlsa_GetStreamInputCard (PaStream *s, int *card)
PaError PaAlsa_GetStreamOutputCard (PaStream *s, int *card)

Variables

HwDevInfo predefinedNames []

Detailed Description


Define Documentation

#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#define ASSERT_CALL_ ( expr,
success   ) 
Value:
aErr_ = (expr); \
    assert( success == aErr_ );
#define ENSURE_ ( expr,
code   ) 
Value:
do { \
        if( UNLIKELY( (aErr_ = (expr)) < 0 ) ) \
        { \
            /* PaUtil_SetLastHostErrorInfo should only be used in the main thread */ \
            if( (code) == paUnanticipatedHostError && pthread_equal( pthread_self(), paUnixMainThread) ) \
            { \
                PaUtil_SetLastHostErrorInfo( paALSA, aErr_, snd_strerror( aErr_ ) ); \
            } \
            PaUtil_DebugPrint( "Expression '" #expr "' failed in '" __FILE__ "', line: " STRINGIZE( __LINE__ ) "\n" ); \
            if( (code) == paUnanticipatedHostError ) \
                PA_DEBUG(( "Host error description: %s\n", snd_strerror( aErr_ ) )); \
            result = (code); \
            goto error; \
        } \
    } while( 0 );

Referenced by PaAlsa_Initialize().


Enumeration Type Documentation

Enumerator:
StreamDirection_In 
StreamDirection_Out 

Function Documentation

void PaAlsa_EnableRealtimeScheduling ( PaStream s,
int  enable 
)

Instruct whether to enable real-time priority when starting the audio thread.

If this is turned on by the stream is started, the audio callback thread will be created with the FIFO scheduling policy, which is suitable for realtime operation.

References PaAlsaStream::rtSched.

PaError PaAlsa_GetStreamInputCard ( PaStream s,
int *  card 
)

Get the ALSA-lib card index of this stream's input device.

References PaAlsaStream::capture, PA_ENSURE, PA_UNLESS, paDeviceUnavailable, paNoError, and PaAlsaStreamComponent::pcm.

PaError PaAlsa_GetStreamOutputCard ( PaStream s,
int *  card 
)

Get the ALSA-lib card index of this stream's output device.

References PA_ENSURE, PA_UNLESS, paDeviceUnavailable, paNoError, PaAlsaStreamComponent::pcm, and PaAlsaStream::playback.

PaError PaAlsa_Initialize ( PaUtilHostApiRepresentation **  hostApi,
PaHostApiIndex  hostApiIndex 
)
void PaAlsa_InitializeStreamInfo ( PaAlsaStreamInfo info  ) 

Initialize host API specific structure, call this before setting relevant attributes.

References PaAlsaStreamInfo::deviceString, PaAlsaStreamInfo::hostApiType, paALSA, PaAlsaStreamInfo::size, and PaAlsaStreamInfo::version.

int PaAlsa_SetNumPeriods ( int  numPeriods  ) 

Set the number of periods (buffer fragments) to configure devices with.

By default the number of periods is 4, this is the lowest number of periods that works well on the author's soundcard.

Parameters:
numPeriods The number of periods.

References paNoError.


Variable Documentation

Initial value:
 {
    { "center_lfe", NULL, 0, 1, 0 },




    { "front", NULL, 0, 1, 0 },
    { "iec958", NULL, 0, 1, 0 },

    { "rear", NULL, 0, 1, 0 },
    { "side", NULL, 0, 1, 0 },

    { "surround40", NULL, 0, 1, 0 },
    { "surround41", NULL, 0, 1, 0 },
    { "surround50", NULL, 0, 1, 0 },
    { "surround51", NULL, 0, 1, 0 },
    { "surround71", NULL, 0, 1, 0 },
    { NULL, NULL, 0, 1, 0 }
}

Generated for PortAudio by  doxygen1.6.1