Changeset 1456


Ignore:
Timestamp:
Sep 28, 2007 1:12:15 PM (17 years ago)
Author:
bennylp
Message:

Ticket #384: Prefer to use Direct Sound as the sound device backend on Windows

Location:
pjproject/trunk/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/config.h

    r1393 r1456  
    7474 
    7575/** 
     76 * Specify whether we prefer to use DirectSound on Windows. 
     77 * 
     78 * Say yes! 
     79 */ 
     80#ifndef PJMEDIA_PREFER_DIRECT_SOUND 
     81#   define PJMEDIA_PREFER_DIRECT_SOUND      1 
     82#endif 
     83 
     84 
     85/** 
    7686 * Specify number of sound buffers. Larger number is better for sound 
    7787 * stability and to accomodate sound devices that are unable to send frames 
  • pjproject/trunk/pjmedia/src/pjmedia/pasound.c

    r1266 r1456  
    266266    int i, count; 
    267267 
     268    /* Special for Windows - try to use the DirectSound implementation 
     269     * first since it provides better latency. 
     270     */ 
     271#if PJMEDIA_PREFER_DIRECT_SOUND 
     272    if (Pa_HostApiTypeIdToHostApiIndex(paDirectSound) >= 0) { 
     273        const PaHostApiInfo *pHI; 
     274        int index = Pa_HostApiTypeIdToHostApiIndex(paDirectSound); 
     275        pHI = Pa_GetHostApiInfo(index); 
     276        if (pHI) { 
     277            const PaDeviceInfo *paDevInfo = NULL; 
     278            paDevInfo = Pa_GetDeviceInfo(pHI->defaultInputDevice); 
     279            if (paDevInfo && paDevInfo->maxInputChannels >= channel_count) 
     280                return pHI->defaultInputDevice; 
     281        } 
     282    } 
     283#endif 
     284 
    268285    /* Enumerate the host api's for the default devices, and return 
    269286     * the device with suitable channels. 
     
    305322    int i, count; 
    306323 
     324    /* Special for Windows - try to use the DirectSound implementation 
     325     * first since it provides better latency. 
     326     */ 
     327#if PJMEDIA_PREFER_DIRECT_SOUND 
     328    if (Pa_HostApiTypeIdToHostApiIndex(paDirectSound) >= 0) { 
     329        const PaHostApiInfo *pHI; 
     330        int index = Pa_HostApiTypeIdToHostApiIndex(paDirectSound); 
     331        pHI = Pa_GetHostApiInfo(index); 
     332        if (pHI) { 
     333            const PaDeviceInfo *paDevInfo = NULL; 
     334            paDevInfo = Pa_GetDeviceInfo(pHI->defaultOutputDevice); 
     335            if (paDevInfo && paDevInfo->maxOutputChannels >= channel_count) 
     336                return pHI->defaultOutputDevice; 
     337        } 
     338    } 
     339#endif 
     340 
    307341    /* Enumerate the host api's for the default devices, and return 
    308342     * the device with suitable channels. 
     
    335369            return i; 
    336370    } 
    337      
     371 
    338372    return -1; 
    339373} 
Note: See TracChangeset for help on using the changeset viewer.