亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pa_unix.c

?? 一個任天堂掌上游戲機NDS的源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*
 * PortAudio Portable Real-Time Audio Library
 * Latest Version at: http://www.portaudio.com
 * Linux OSS Implementation by douglas repetto and Phil Burk
 *
 * Copyright (c) 1999-2000 Phil Burk
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files
 * (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * Any person wishing to distribute modifications to the Software is
 * requested to send the modifications to the original developer so that
 * they can be incorporated into the canonical version.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

/*
Modification History
  1/2001 - Phil Burk - initial hack for Linux
  2/2001 - Douglas Repetto - many improvements, initial query support
  4/2/2001 - Phil - stop/abort thread control, separate in/out native buffers
  5/28/2001 - Phil - use pthread_create() instead of clone(). Thanks Stephen Brandon!
       use pthread_join() after thread shutdown.
  5/29/2001 - Phil - query for multiple devices, multiple formats,
                     input mode and input+output mode working,
       Pa_GetCPULoad() implemented.
  PLB20010817 - Phil & Janos Haber - don't halt if test of sample rate fails.
  SB20010904 - Stephen Brandon - mods needed for GNUSTEP and SndKit
  JH20010905 - Janos Haber - FreeBSD mods
  2001-09-22 - Heiko - (i.e. Heiko Purnhagen <purnhage@tnt.uni-hannover.de> ;-)
                       added 24k and 16k to ratesToTry[]
         fixed Pa_GetInternalDevice()
         changed DEVICE_NAME_BASE from /dev/audio to /dev/dsp
         handled SNDCTL_DSP_SPEED in Pq_QueryDevice() more graceful
         fixed Pa_StreamTime() for paqa_errs.c
         fixed numCannel=2 oddity and error handling in Pa_SetupDeviceFormat()
         grep also for HP20010922 ...
  PLB20010924 - Phil - merged Heiko's changes
                       removed sNumDevices and potential related bugs,
         use getenv("PA_MIN_LATENCY_MSEC") to set desired latency,
         simplify CPU Load calculation by comparing real-time to framesPerBuffer,
         always close device when querying even if error occurs,
  PLB20010927 - Phil - Improved negotiation for numChannels.
  SG20011005 - Stewart Greenhill - set numChannels back to reasonable value after query.
  DH20010115 - David Herring - fixed uninitialized handle.

  DM20020218 - Dominic Mazzoni - Try to open in nonblocking mode first, in case
                                 the device is already open.  New implementation of
                                 Pa_StreamTime that uses SNDCTL_DSP_GETOPTR but
                                 uses our own counter to avoid wraparound.
  PLB20020222 - Phil Burk - Added WatchDog proc if audio running at high priority.
                      Check error return from read() and write().
                      Check CPU endianness instead of assuming Little Endian.
  20020621 - pa_unix_oss.c split into pa_unix.c, pa_unix.h, pa_unix_oss.c by
         Augustus Saunders. Return values from usleep() ignored by Sam Bayer
         because not cross-platform compatible (at least until we get configure
         going). Pa_SetupDeviceFormat split into input and output sides to
         reflect capabilities of Solaris.

  20030206 - Martin Rohrbach - various mods for Solaris
  
  20030410 - Bjorn Dittmer-Roche - fixed numerous problems associated with pthread_t
  
  20030630 - Thomas Richter - eliminated unused variable warnings.

TODO
O- put semaphore lock around shared data?
O- handle native formats better
O- handle stereo-only device better ???
O- what if input and output of a device capabilities differ (e.g. es1371) ???
*/


#include "pa_unix.h"

typedef void *(*pthread_function_t)(void *);

/************************************************* Shared Data ********/
/* FIXME - put Mutex around this shared data. */
static internalPortAudioDevice *sDeviceList = NULL;
static int sDefaultInputDeviceID = paNoDevice;
static int sDefaultOutputDeviceID = paNoDevice;
static int sPaHostError = 0;

/********************************* BEGIN CPU UTILIZATION MEASUREMENT ****/
static void Pa_StartUsageCalculation( internalPortAudioStream   *past )
{
    PaHostSoundControl *pahsc = (PaHostSoundControl *) past->past_DeviceData;
    if( pahsc == NULL ) return;
    /* Query system timer for usage analysis and to prevent overuse of CPU. */
    gettimeofday( &pahsc->pahsc_EntryTime, NULL );
}

static long SubtractTime_AminusB( struct timeval *timeA, struct timeval *timeB )
{
    long secs = timeA->tv_sec - timeB->tv_sec;
    long usecs = secs * 1000000;
    usecs += (timeA->tv_usec - timeB->tv_usec);
    return usecs;
}

/******************************************************************************
** Measure fractional CPU load based on real-time it took to calculate
** buffers worth of output.
*/
static void Pa_EndUsageCalculation( internalPortAudioStream   *past )
{
    struct timeval currentTime;
    long  usecsElapsed;
    double newUsage;

#define LOWPASS_COEFFICIENT_0   (0.95)
#define LOWPASS_COEFFICIENT_1   (0.99999 - LOWPASS_COEFFICIENT_0)

    PaHostSoundControl *pahsc = (PaHostSoundControl *) past->past_DeviceData;
    if( pahsc == NULL ) return;

    if( gettimeofday( &currentTime, NULL ) == 0 )
    {
        usecsElapsed = SubtractTime_AminusB( &currentTime, &pahsc->pahsc_EntryTime );
        /* Use inverse because it is faster than the divide. */
        newUsage =  usecsElapsed * pahsc->pahsc_InverseMicrosPerBuffer;

        past->past_Usage = (LOWPASS_COEFFICIENT_0 * past->past_Usage) +
                           (LOWPASS_COEFFICIENT_1 * newUsage);

    }
}
/****************************************** END CPU UTILIZATION *******/

/*********************************************************************
 * Determines the number of available devices by trying to open
 * each "/dev/dsp#" or "/dsp/audio#" in order until it fails.
 * Add each working device to a singly linked list of devices.
 */
PaError Pa_QueryDevices( void )
{
    internalPortAudioDevice *pad, *lastPad;
    int      go = 1;
    int      numDevices = 0;
    PaError  testResult;
    PaError  result = paNoError;
    char     *envdev;

    sDefaultInputDeviceID = paNoDevice;
    sDefaultOutputDeviceID = paNoDevice;

    lastPad = NULL;

    while( go )
    {
        /* Allocate structure to hold device info. */
        pad = (internalPortAudioDevice *)
              PaHost_AllocateFastMemory( sizeof(internalPortAudioDevice) );
        if( pad == NULL ) return paInsufficientMemory;
        memset( pad, 0, sizeof(internalPortAudioDevice) );

        /* Build name for device. */
        if( numDevices == 0 )
        {
            sprintf( pad->pad_DeviceName, DEVICE_NAME_BASE);
        }
        else
        {
            sprintf( pad->pad_DeviceName, DEVICE_NAME_BASE "%d", numDevices );
        }

        DBUG(("Try device %s\n", pad->pad_DeviceName ));
        testResult = Pa_QueryDevice( pad->pad_DeviceName, pad );
        DBUG(("Pa_QueryDevice returned %d\n", testResult ));
        if( testResult != paNoError )
        {
            if( lastPad == NULL )
            {
                result = testResult; /* No good devices! */
            }
            go = 0;
            PaHost_FreeFastMemory( pad, sizeof(internalPortAudioDevice) );
        }
        else
        {
            numDevices += 1;
            /* Add to linked list of devices. */
            if( lastPad )
            {
                lastPad->pad_Next = pad;
            }
            else
            {
                sDeviceList = pad; /* First element in linked list. */
            }
            lastPad = pad;
        }
    }

    /* I'm sitting at a SunRay1 and I neither have /dev/audio# nor /dev/dsp#.
       Instead, the correct audio device is stored in the environment variable
       AUDIODEV and/or UTAUDIODEV, so check these devices as well if we haven't
       checked them yet above  - MR */

    DBUG(("Checking for AUDIODEV and UTAUDIODEV\n"));
    envdev = getenv("AUDIODEV");
    if (envdev != NULL && !strstr(envdev, DEVICE_NAME_BASE)) {
        result = paNoError;

        /* Allocate structure to hold device info. */
        pad = (internalPortAudioDevice *)
              PaHost_AllocateFastMemory( sizeof(internalPortAudioDevice) );
        if( pad == NULL ) return paInsufficientMemory;
        memset( pad, 0, sizeof(internalPortAudioDevice) );

        /* Build name for device. */
        strcpy(pad->pad_DeviceName, envdev);

        DBUG(("Try device %s\n", pad->pad_DeviceName ));
        testResult = Pa_QueryDevice( pad->pad_DeviceName, pad );
        DBUG(("Pa_QueryDevice returned %d\n", testResult ));
        if( testResult != paNoError )
        {
            if( lastPad == NULL )
            {
                result = testResult; /* No good devices! */
            }
            PaHost_FreeFastMemory( pad, sizeof(internalPortAudioDevice) );
        }
        else
        {
            numDevices += 1;
            /* Add to linked list of devices. */
            if( lastPad )
            {
                lastPad->pad_Next = pad;
            }
            else
            {
                sDeviceList = pad; /* First element in linked list. */
            }
            lastPad = pad;
        }
    }

    envdev = getenv("UTAUDIODEV");
    if (envdev != NULL && !strstr(envdev, DEVICE_NAME_BASE) && getenv("AUDIODEV") != NULL && strcmp(envdev, getenv("AUDIODEV"))) {
        result = paNoError;

        /* Allocate structure to hold device info. */
        pad = (internalPortAudioDevice *)
              PaHost_AllocateFastMemory( sizeof(internalPortAudioDevice) );
        if( pad == NULL ) return paInsufficientMemory;
        memset( pad, 0, sizeof(internalPortAudioDevice) );

        /* Build name for device. */
        strcpy(pad->pad_DeviceName, envdev);

        DBUG(("Try device %s\n", pad->pad_DeviceName ));
        testResult = Pa_QueryDevice( pad->pad_DeviceName, pad );
        DBUG(("Pa_QueryDevice returned %d\n", testResult ));
        if( testResult != paNoError )
        {
            if( lastPad == NULL )
            {
                result = testResult; /* No good devices! */
            }
            PaHost_FreeFastMemory( pad, sizeof(internalPortAudioDevice) );
        }
        else
        {
            numDevices += 1;
            /* Add to linked list of devices. */
            if( lastPad )
            {
                lastPad->pad_Next = pad;
            }
            else
            {
                sDeviceList = pad; /* First element in linked list. */
            }
            lastPad = pad;
        }
    }

    return result;
}

/*************************************************************************/
int Pa_CountDevices()
{
    int numDevices = 0;
    internalPortAudioDevice *pad;

    if( sDeviceList == NULL ) Pa_Initialize();
    /* Count devices in list. */
    pad = sDeviceList;
    while( pad != NULL )
    {
        pad = pad->pad_Next;
        numDevices++;
    }

    return numDevices;
}

/*************************************************************************/
internalPortAudioDevice *Pa_GetInternalDevice( PaDeviceID id )
{
    internalPortAudioDevice *pad;
    if( (id < 0) || ( id >= Pa_CountDevices()) ) return NULL;
    pad = sDeviceList;
    while( id > 0 )
    {
        pad = pad->pad_Next;
        id--;
    }
    return pad;
}

/*************************************************************************/
const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID id )
{
    internalPortAudioDevice *pad;
    if( (id < 0) || ( id >= Pa_CountDevices()) ) return NULL;
    pad = Pa_GetInternalDevice( id );
    return  &pad->pad_Info ;
}

static PaError Pa_MaybeQueryDevices( void )
{
    if( sDeviceList == NULL )
    {
        return Pa_QueryDevices();
    }
    return 0;
}

PaDeviceID Pa_GetDefaultInputDeviceID( void )
{
    /* return paNoDevice; */
    return 0;
}

PaDeviceID Pa_GetDefaultOutputDeviceID( void )
{
    return 0;
}

/**********************************************************************
** Make sure that we have queried the device capabilities.
*/

PaError PaHost_Init( void )
{
    return Pa_MaybeQueryDevices();
}

/*******************************************************************************************
 * The ol' Canary in a Coal Mine trick.
 * Just update the time periodically.
 * Runs at low priority so if audio thread runs wild, this thread will get starved
 * and the watchdog will detect it.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品在线观看免费| 精品99久久久久久| 麻豆国产一区二区| 极品少妇xxxx偷拍精品少妇| 国产精品一区二区视频| 色综合久久久久久久久久久| 精品精品欲导航| 天天操天天色综合| 色婷婷激情综合| 自拍偷拍亚洲欧美日韩| 成人精品电影在线观看| 国产日韩av一区| 国产一区欧美日韩| 精品美女在线播放| 精品一区二区三区免费| 日韩一级二级三级| 老司机精品视频导航| 欧美一级理论性理论a| 日一区二区三区| 91超碰这里只有精品国产| 亚洲成av人综合在线观看| 精品视频在线免费| 日韩和欧美一区二区三区| 91精品中文字幕一区二区三区| 亚洲综合色婷婷| 欧美一区二区三区在线| 免费成人你懂的| 久久综合色综合88| 粗大黑人巨茎大战欧美成人| 自拍偷拍亚洲激情| 欧美日韩视频专区在线播放| 久久不见久久见中文字幕免费| 久久一日本道色综合| 成人精品一区二区三区四区| 有码一区二区三区| 欧美精品丝袜中出| 国产精品白丝av| 夜夜嗨av一区二区三区四季av| 91精品在线观看入口| 成人午夜免费视频| 日本中文在线一区| 国产精品免费视频一区| 欧美日韩一区二区三区四区| 国产精品18久久久久久vr| 国产精品久线在线观看| 欧美日韩国产美| 成人午夜碰碰视频| 日韩黄色免费电影| 亚洲人成亚洲人成在线观看图片| 欧美一区二区视频在线观看| 9色porny自拍视频一区二区| 午夜精品一区在线观看| 中文字幕中文在线不卡住| 6080日韩午夜伦伦午夜伦| 色香蕉久久蜜桃| 国产成人亚洲综合a∨婷婷图片| 五月天亚洲精品| 亚洲男人的天堂av| 中国av一区二区三区| 精品久久99ma| 精品少妇一区二区三区在线播放| 在线观看免费一区| 色综合久久久久久久久| 国产成人av一区二区| 激情欧美一区二区| 日韩电影一区二区三区四区| 亚洲小说欧美激情另类| 亚洲精品亚洲人成人网| 国产精品国产精品国产专区不蜜| 久久久亚洲午夜电影| 久久婷婷国产综合国色天香| 欧美大片在线观看一区二区| 欧美精品一级二级| 日韩一区二区三区电影| 日韩欧美一区在线| 欧美电影免费提供在线观看| 日韩一级片在线播放| 精品处破学生在线二十三| 26uuu成人网一区二区三区| 国产婷婷色一区二区三区在线| 久久九九全国免费| 精品不卡在线视频| 中文字幕+乱码+中文字幕一区| 一区二区中文字幕在线| 亚洲一区二区三区三| 无吗不卡中文字幕| 国模一区二区三区白浆| 成人av综合在线| 欧美色手机在线观看| 日韩精品专区在线影院观看| 中文字幕乱码日本亚洲一区二区 | 欧美成人精精品一区二区频| 久久久久久毛片| 精品综合久久久久久8888| 午夜精品久久久久| 久久se这里有精品| 成人av网站免费观看| 欧美日本韩国一区| 国产婷婷色一区二区三区四区| 一区二区三区四区不卡在线 | 久久精品视频免费| 亚洲午夜三级在线| 国产福利精品一区二区| 色综合久久久久综合体桃花网| 88在线观看91蜜桃国自产| 国产精品三级av| 久久99精品国产.久久久久久| 91蝌蚪porny| 久久蜜桃av一区二区天堂| 亚洲一区二区三区四区中文字幕| 国产一区福利在线| 日韩一卡二卡三卡| 亚洲国产三级在线| 91蝌蚪porny九色| 国产女人18水真多18精品一级做| 蜜桃视频一区二区| 欧美乱妇23p| 亚洲午夜在线电影| 日本韩国精品一区二区在线观看| 国产视频一区在线观看| 久久99精品一区二区三区| 欧美久久免费观看| 亚洲成人av一区二区| 91成人免费在线视频| 亚洲精品一二三| 91黄色激情网站| 亚洲精品乱码久久久久久黑人| 国产91色综合久久免费分享| 日韩精品中文字幕在线不卡尤物| 欧美aaaaaa午夜精品| 在线综合视频播放| 日本在线播放一区二区三区| 精品视频全国免费看| 视频在线观看一区| 91精品国产麻豆| 精品一区二区三区的国产在线播放 | 亚洲一区二区视频在线观看| 精品国产三级电影在线观看| 久久激情五月激情| 国产午夜久久久久| 91在线看国产| 亚洲国产精品视频| 欧美一级二级在线观看| 国产精品自在在线| 中文字幕一区二区三中文字幕| 欧洲国内综合视频| 美腿丝袜亚洲一区| 国产精品成人免费在线| 色偷偷88欧美精品久久久 | 在线区一区二视频| 丝袜美腿亚洲一区| 国产视频亚洲色图| 91蜜桃在线免费视频| 性久久久久久久久久久久| 3751色影院一区二区三区| 国产剧情一区在线| 中文字幕色av一区二区三区| 91论坛在线播放| 精品无人码麻豆乱码1区2区| 国产精品成人免费精品自在线观看| 色综合久久综合网97色综合| 青青草视频一区| 欧美区视频在线观看| 粉嫩av一区二区三区在线播放| 一区二区三区国产精品| 日韩精品一区二区三区中文不卡 | 亚洲r级在线视频| 国产色91在线| 欧美日韩中文国产| 国产福利一区二区三区视频在线| 亚洲精品国产品国语在线app| 欧美日韩在线播放| proumb性欧美在线观看| 亚洲成国产人片在线观看| 国产精品久久久久久久久免费樱桃| 欧美视频一区二| 99国产精品一区| 国内成+人亚洲+欧美+综合在线| 一区av在线播放| 国产精品你懂的在线| 久久综合久久综合亚洲| 成人高清免费观看| 粗大黑人巨茎大战欧美成人| 日韩福利电影在线| 亚洲成人tv网| 亚洲综合清纯丝袜自拍| 欧美激情一区二区三区在线| 日韩一级在线观看| 欧美午夜精品免费| 国产91高潮流白浆在线麻豆 | 国产综合久久久久久久久久久久| 天堂精品中文字幕在线| 日韩精品欧美精品| 日日嗨av一区二区三区四区| 亚洲最新在线观看| 婷婷丁香激情综合| 天堂午夜影视日韩欧美一区二区| 一区二区三区中文在线| 日韩精品亚洲专区| 久久99最新地址|