Changeset 1041 for pjproject


Ignore:
Timestamp:
Mar 5, 2007 1:13:22 PM (18 years ago)
Author:
bennylp
Message:

Allow pjmedia_snd_init()/deinit() to be called more than once

Location:
pjproject/trunk/pjmedia/src/pjmedia
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/dsound.c

    r974 r1041  
    5757static unsigned dev_count; 
    5858static struct dsound_dev_info dev_info[MAX_HARDWARE]; 
    59  
     59static int snd_init_count; 
    6060 
    6161 
     
    638638    unsigned i; 
    639639 
     640    if (++snd_init_count != 1) 
     641        return PJ_SUCCESS; 
     642 
    640643    pool_factory = factory; 
    641644 
     
    667670PJ_DEF(pj_status_t) pjmedia_snd_deinit(void) 
    668671{ 
     672    --snd_init_count; 
    669673    return PJ_SUCCESS; 
    670674} 
  • pjproject/trunk/pjmedia/src/pjmedia/pasound.c

    r974 r1041  
    2929#define THIS_FILE       "pasound.c" 
    3030 
     31static int snd_init_count; 
     32 
    3133static struct snd_mgr 
    3234{ 
     
    194196PJ_DEF(pj_status_t) pjmedia_snd_init(pj_pool_factory *factory) 
    195197{ 
    196     int err; 
    197  
    198     snd_mgr.factory = factory; 
    199     err = Pa_Initialize(); 
    200  
    201     PJ_LOG(4,(THIS_FILE, "PortAudio sound library initialized, status=%d", err)); 
    202     PJ_LOG(4,(THIS_FILE, "PortAudio host api count=%d", 
    203                          Pa_GetHostApiCount())); 
    204     PJ_LOG(4,(THIS_FILE, "Sound device count=%d", 
    205                          pjmedia_snd_get_dev_count())); 
    206  
    207     return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS; 
     198    if (++snd_init_count == 1) { 
     199        int err; 
     200 
     201        snd_mgr.factory = factory; 
     202        err = Pa_Initialize(); 
     203 
     204        PJ_LOG(4,(THIS_FILE,  
     205                  "PortAudio sound library initialized, status=%d", err)); 
     206        PJ_LOG(4,(THIS_FILE, "PortAudio host api count=%d", 
     207                             Pa_GetHostApiCount())); 
     208        PJ_LOG(4,(THIS_FILE, "Sound device count=%d", 
     209                             pjmedia_snd_get_dev_count())); 
     210 
     211        return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS; 
     212    } else { 
     213        return PJ_SUCCESS; 
     214    } 
    208215} 
    209216 
     
    805812PJ_DEF(pj_status_t) pjmedia_snd_deinit(void) 
    806813{ 
    807     int err; 
    808  
    809     PJ_LOG(4,(THIS_FILE, "PortAudio sound library shutting down..")); 
    810  
    811     err = Pa_Terminate(); 
    812  
    813     return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS; 
     814    if (--snd_init_count == 0) { 
     815        int err; 
     816 
     817        PJ_LOG(4,(THIS_FILE, "PortAudio sound library shutting down..")); 
     818 
     819        err = Pa_Terminate(); 
     820 
     821        return err ? PJMEDIA_ERRNO_FROM_PORTAUDIO(err) : PJ_SUCCESS; 
     822    } else { 
     823        return PJ_SUCCESS; 
     824    } 
    814825} 
    815826 
Note: See TracChangeset for help on using the changeset viewer.