Changes between Version 6 and Version 7 of Audio_Dev_API


Ignore:
Timestamp:
Feb 20, 2009 4:19:58 PM (15 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Audio_Dev_API

    v6 v7  
    9696    a. I have changed my application to use the new API 
    9797       - also use setting 3 
     98 
     99[[BR]] 
     100 
     101== Porting applications to new API == 
     102 
     103As stated above, existing applications should build fine with the new changes. However, it will still be beneficial to port the application to use the new API since the old sound API has been deprecated, and also to make use of the new features in the new Audio Device API. 
     104 
     105This section describes how to port applications to use the new Audio Device API. 
     106 
     107=== PJSUA-LIB applications === 
     108 
     109PJSUA-LIB applications that only make use of the API in {{{<pjsua.h>}}} should require minimum changes. 
     110 
     111 1. Change in {{{pjsua_enum_snd_devs()}}} signature. Old API: 
     112    {{{ 
     113PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_snd_dev_info info[], unsigned *count); 
     114    }}} 
     115 New API (notice the type difference in the ''info'' argument): 
     116    {{{ 
     117PJ_DECL(pj_status_t) pjsua_enum_snd_devs(pjmedia_aud_dev_info info[], unsigned *count); 
     118    }}} 
     119 
     120 2. Add '''pjmedia-audiodev''' library to the link specifications of your application. 
     121 
     122 
     123=== PJMEDIA applications === 
     124 
     125Below are list of changes for applications that directly uses the old sound API as declared in {{{<pjmedia/sound.h>}}}. 
     126 
     127 1. Change the header file to include. Old code: 
     128    {{{ 
     129#include <pjmedia/sound.h> 
     130    }}} 
     131    New code: 
     132    {{{ 
     133#include <pjmedia_audiodev.h> 
     134    }}} 
     135 2. Add '''pjmedia-audiodev''' library to the link specifications of your application. 
     136 3. Sound device subsystem startup and shutdown. Old code: 
     137    {{{ 
     138pjmedia_snd_init(pf); 
     139 ... 
     140pjmedia_snd_deinit(); 
     141    }}} 
     142    New code: 
     143    {{{ 
     144pjmedia_aud_subsys_init(pf); 
     145 ... 
     146pjmedia_aud_subsys_shutdown(); 
     147    }}} 
     148 4. Device enumeration. Old code: 
     149    {{{ 
     150unsigned i, dev_count; 
     151 
     152dev_count = pjmedia_snd_get_dev_count(); 
     153for (i=0; i<dev_count; ++i) { 
     154    const pjmedia_snd_dev_info *dev_info = pjmedia_snd_get_dev_info(i); 
     155} 
     156    }}} 
     157    New code: 
     158    {{{ 
     159unsigned i, dev_count; 
     160 
     161dev_count = pjmedia_aud_dev_count(); 
     162for (i=0; i<dev_count; ++i) { 
     163    pjmedia_aud_dev_info dev_info; 
     164    pj_status_t status; 
     165 
     166    status = pjmedia_aud_dev_get_info(i, &info); 
     167} 
     168    }}} 
     169 5. Opening sound device. Old code: 
     170    {{{ 
     171pjmedia_snd_stream *stream; 
     172pj_status_t status; 
     173 
     174status = pjmedia_snd_open(-1,       // default capture device ID 
     175                          -1,       // default playback device ID 
     176                          8000,     // clock rate 
     177                          1,        // channel count 
     178                          160,      // samples per frame 
     179                          16,       // bits per sample 
     180                          &rec_cb,  // capture callback 
     181                          &play_cb, // playback callback 
     182                          user_data, 
     183                          &stream); 
     184if (status != PJ_SUCCESS) 
     185   .. 
     186    }}} 
     187    New code: 
     188    {{{ 
     189pjmedia_aud_dev_param param; 
     190pjmedia_aud_stream *stream; 
     191pj_status_t status; 
     192 
     193status = pjmedia_aud_dev_default_param(PJMEDIA_AUD_DEV_DEFAULT, &param); 
     194if (status != PJ_SUCCESS) 
     195   .. 
     196 
     197param.dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 
     198param.rec_id = PJMEDIA_AUD_DEV_DEFAULT; 
     199param.play_id = PJMEDIA_AUD_DEV_DEFAULT; 
     200param.clock_rate = 8000; 
     201param.channel_count = 1; 
     202param.samples_per_frame = 160; 
     203param.bits_per_sample = 16; 
     204.. // put additional settings here 
     205 
     206status = pjmedia_aud_stream_create(&param, 
     207                                   &rec_cb, 
     208                                   &play_cb, 
     209                                   user_data, 
     210                                   &stream); 
     211if (status != PJ_SUCCESS) 
     212   .. 
     213    }}} 
     214 6. .. and so on 
     215 
     216 
     217