Ignore:
Timestamp:
Feb 21, 2009 2:21:59 PM (15 years ago)
Author:
bennylp
Message:

Updated libraries and applications to use the new Audio Device API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/aps-direct/pjmedia/src/pjmedia/conf_switch.c

    r2460 r2468  
    114114    unsigned              port_cnt;     /**< Current number of ports.       */ 
    115115    unsigned              connect_cnt;  /**< Total number of connections    */ 
    116     pjmedia_snd_port     *snd_dev_port; /**< Sound device port.             */ 
    117116    pjmedia_port         *master_port;  /**< Port zero's port.              */ 
    118117    char                  master_name_buf[80]; /**< Port0 name buffer.      */ 
     
    188187    pj_status_t status; 
    189188 
    190  
    191189    status = create_conf_port(pool, conf, conf->master_port, &name, &conf_port); 
    192190    if (status != PJ_SUCCESS) 
    193191        return status; 
    194  
    195  
    196     /* Create sound device port: */ 
    197  
    198     if ((conf->options & PJMEDIA_CONF_NO_DEVICE) == 0) { 
    199         pjmedia_snd_stream *strm; 
    200         pjmedia_snd_stream_info si; 
    201         pjmedia_port_info *master_port_info = (pjmedia_port_info*) 
    202                                               &conf->master_port->info; 
    203  
    204         /* 
    205          * If capture is disabled then create player only port. 
    206          * Otherwise create bidirectional sound device port. 
    207          */ 
    208         if (conf->options & PJMEDIA_CONF_NO_MIC)  { 
    209             status = pjmedia_snd_port_create_player( 
    210                                         pool, -1,  
    211                                         master_port_info->clock_rate, 
    212                                         master_port_info->channel_count, 
    213                                         master_port_info->samples_per_frame, 
    214                                         master_port_info->bits_per_sample,  
    215                                         0,      /* options */ 
    216                                         &conf->snd_dev_port); 
    217  
    218         } else { 
    219             status = pjmedia_snd_port_create(  
    220                                         pool, -1, -1,  
    221                                         master_port_info->clock_rate,  
    222                                         master_port_info->channel_count,  
    223                                         master_port_info->samples_per_frame, 
    224                                         master_port_info->bits_per_sample, 
    225                                         0,    /* Options */ 
    226                                         &conf->snd_dev_port); 
    227         } 
    228  
    229         if (status != PJ_SUCCESS) 
    230             return status; 
    231  
    232         strm = pjmedia_snd_port_get_snd_stream(conf->snd_dev_port); 
    233         status = pjmedia_snd_stream_get_info(strm, &si); 
    234         if (status == PJ_SUCCESS) { 
    235             const pjmedia_snd_dev_info *snd_dev_info; 
    236             if (conf->options & PJMEDIA_CONF_NO_MIC) 
    237                 snd_dev_info = pjmedia_snd_get_dev_info(si.play_id); 
    238             else 
    239                 snd_dev_info = pjmedia_snd_get_dev_info(si.rec_id); 
    240             pj_strdup2_with_null(pool, &conf_port->name, snd_dev_info->name); 
    241         } 
    242     } 
    243  
    244192 
    245193     /* Add the port to the bridge */ 
     
    247195    conf->ports[0] = conf_port; 
    248196    conf->port_cnt++; 
    249  
    250197 
    251198    PJ_LOG(5,(THIS_FILE, "Sound device successfully created for port 0")); 
     
    312259        return status; 
    313260 
    314     /* If sound device was created, connect sound device to the 
    315      * master port. 
    316      */ 
    317     if (conf->snd_dev_port) { 
    318         status = pjmedia_snd_port_connect( conf->snd_dev_port,  
    319                                            conf->master_port ); 
    320         if (status != PJ_SUCCESS) { 
    321             pjmedia_conf_destroy(conf); 
    322             return status; 
    323         } 
    324     } 
    325  
    326261    /* Done */ 
    327262 
     
    359294{ 
    360295    PJ_ASSERT_RETURN(conf != NULL, PJ_EINVAL); 
    361  
    362     /* Destroy sound device port. */ 
    363     if (conf->snd_dev_port) { 
    364         pjmedia_snd_port_destroy(conf->snd_dev_port); 
    365         conf->snd_dev_port = NULL; 
    366     } 
    367296 
    368297    /* Destroy mutex */ 
Note: See TracChangeset for help on using the changeset viewer.