Ignore:
Timestamp:
Mar 11, 2011 6:57:24 AM (11 years ago)
Author:
ming
Message:

Fixed #1204: Support for refreshing audio device list.

File:
1 edited

Legend:

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

    r3115 r3438  
    4949    unsigned             samples_per_frame; 
    5050    unsigned             bits_per_sample; 
     51    unsigned             options; 
    5152 
    5253    /* software ec */ 
     
    278279 
    279280    /* Start sound stream. */ 
    280     status = pjmedia_aud_stream_start(snd_port->aud_stream); 
     281    if (!(snd_port->options & PJMEDIA_SND_PORT_NO_AUTO_START)) { 
     282        status = pjmedia_aud_stream_start(snd_port->aud_stream); 
     283    } 
    281284    if (status != PJ_SUCCESS) { 
    282285        pjmedia_aud_stream_destroy(snd_port->aud_stream); 
     
    325328                                             pjmedia_snd_port **p_port) 
    326329{ 
    327     pjmedia_aud_param param; 
     330    pjmedia_snd_port_param param; 
    328331    pj_status_t status; 
    329332 
    330333    PJ_UNUSED_ARG(options); 
    331334 
    332     status = pjmedia_aud_dev_default_param(rec_id, &param); 
     335    status = pjmedia_aud_dev_default_param(rec_id, &param.base); 
    333336    if (status != PJ_SUCCESS) 
    334337        return status; 
    335338 
    336     param.dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 
    337     param.rec_id = rec_id; 
    338     param.play_id = play_id; 
    339     param.clock_rate = clock_rate; 
    340     param.channel_count = channel_count; 
    341     param.samples_per_frame = samples_per_frame; 
    342     param.bits_per_sample = bits_per_sample; 
     339    param.base.dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 
     340    param.base.rec_id = rec_id; 
     341    param.base.play_id = play_id; 
     342    param.base.clock_rate = clock_rate; 
     343    param.base.channel_count = channel_count; 
     344    param.base.samples_per_frame = samples_per_frame; 
     345    param.base.bits_per_sample = bits_per_sample; 
     346    param.options = options; 
    343347 
    344348    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    357361                                                 pjmedia_snd_port **p_port) 
    358362{ 
    359     pjmedia_aud_param param; 
     363    pjmedia_snd_port_param param; 
    360364    pj_status_t status; 
    361365 
    362366    PJ_UNUSED_ARG(options); 
    363367 
    364     status = pjmedia_aud_dev_default_param(dev_id, &param); 
     368    status = pjmedia_aud_dev_default_param(dev_id, &param.base); 
    365369    if (status != PJ_SUCCESS) 
    366370        return status; 
    367371 
    368     param.dir = PJMEDIA_DIR_CAPTURE; 
    369     param.rec_id = dev_id; 
    370     param.clock_rate = clock_rate; 
    371     param.channel_count = channel_count; 
    372     param.samples_per_frame = samples_per_frame; 
    373     param.bits_per_sample = bits_per_sample; 
     372    param.base.dir = PJMEDIA_DIR_CAPTURE; 
     373    param.base.rec_id = dev_id; 
     374    param.base.clock_rate = clock_rate; 
     375    param.base.channel_count = channel_count; 
     376    param.base.samples_per_frame = samples_per_frame; 
     377    param.base.bits_per_sample = bits_per_sample; 
     378    param.options = options; 
    374379 
    375380    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    389394                                                    pjmedia_snd_port **p_port) 
    390395{ 
    391     pjmedia_aud_param param; 
     396    pjmedia_snd_port_param param; 
    392397    pj_status_t status; 
    393398 
    394399    PJ_UNUSED_ARG(options); 
    395400 
    396     status = pjmedia_aud_dev_default_param(dev_id, &param); 
     401    status = pjmedia_aud_dev_default_param(dev_id, &param.base); 
    397402    if (status != PJ_SUCCESS) 
    398403        return status; 
    399404 
    400     param.dir = PJMEDIA_DIR_PLAYBACK; 
    401     param.play_id = dev_id; 
    402     param.clock_rate = clock_rate; 
    403     param.channel_count = channel_count; 
    404     param.samples_per_frame = samples_per_frame; 
    405     param.bits_per_sample = bits_per_sample; 
     405    param.base.dir = PJMEDIA_DIR_PLAYBACK; 
     406    param.base.play_id = dev_id; 
     407    param.base.clock_rate = clock_rate; 
     408    param.base.channel_count = channel_count; 
     409    param.base.samples_per_frame = samples_per_frame; 
     410    param.base.bits_per_sample = bits_per_sample; 
     411    param.options = options; 
    406412 
    407413    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    413419 */ 
    414420PJ_DEF(pj_status_t) pjmedia_snd_port_create2(pj_pool_t *pool, 
    415                                              const pjmedia_aud_param *prm, 
     421                                             const pjmedia_snd_port_param *prm, 
    416422                                             pjmedia_snd_port **p_port) 
    417423{ 
     
    424430    PJ_ASSERT_RETURN(snd_port, PJ_ENOMEM); 
    425431 
    426     snd_port->dir = prm->dir; 
    427     snd_port->rec_id = prm->rec_id; 
    428     snd_port->play_id = prm->play_id; 
     432    snd_port->dir = prm->base.dir; 
     433    snd_port->rec_id = prm->base.rec_id; 
     434    snd_port->play_id = prm->base.play_id; 
    429435    snd_port->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 
    430     snd_port->clock_rate = prm->clock_rate; 
    431     snd_port->channel_count = prm->channel_count; 
    432     snd_port->samples_per_frame = prm->samples_per_frame; 
    433     snd_port->bits_per_sample = prm->bits_per_sample; 
    434     pj_memcpy(&snd_port->aud_param, prm, sizeof(*prm)); 
     436    snd_port->clock_rate = prm->base.clock_rate; 
     437    snd_port->channel_count = prm->base.channel_count; 
     438    snd_port->samples_per_frame = prm->base.samples_per_frame; 
     439    snd_port->bits_per_sample = prm->base.bits_per_sample; 
     440    pj_memcpy(&snd_port->aud_param, prm, sizeof(snd_port->aud_param)); 
     441    snd_port->options = prm->options; 
    435442     
    436443    /* Start sound device immediately. 
Note: See TracChangeset for help on using the changeset viewer.