#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 [] |
#define ALSA_PCM_NEW_HW_PARAMS_API |
#define ALSA_PCM_NEW_SW_PARAMS_API |
#define ASSERT_CALL_ | ( | expr, | |||
success | ) |
aErr_ = (expr); \ assert( success == aErr_ );
#define ENSURE_ | ( | expr, | |||
code | ) |
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().
enum StreamDirection |
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.
Get the ALSA-lib card index of this stream's input device.
References PaAlsaStream::capture, PA_ENSURE, PA_UNLESS, paDeviceUnavailable, paNoError, and PaAlsaStreamComponent::pcm.
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 | |||
) |
References PaAlsaHostApiRepresentation::allocations, PaAlsaHostApiRepresentation::blockingStreamInterface, PaAlsaHostApiRepresentation::callbackStreamInterface, ENSURE_, PaAlsaHostApiRepresentation::hostApiIndex, PA_ENSURE, PA_UNLESS, paALSA, paInsufficientMemory, paNoError, paUnanticipatedHostError, PaUnixThreading_Initialize(), PaUtil_AllocateMemory(), PaUtil_CreateAllocationGroup(), PaUtil_DestroyAllocationGroup(), PaUtil_DummyGetCpuLoad(), PaUtil_DummyGetReadAvailable(), PaUtil_DummyGetWriteAvailable(), PaUtil_DummyRead(), PaUtil_DummyWrite(), PaUtil_FreeAllAllocations(), PaUtil_FreeMemory(), and PaUtil_InitializeStreamInterface().
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.
numPeriods | The number of periods. |
References paNoError.
{ { "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 } }