Changeset 2821 for pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp
- Timestamp:
- Jun 30, 2009 1:37:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/symsndtest/app_main.cpp
r2506 r2821 18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 #include <pjmedia-audiodev/audiodev.h> 20 21 #include <pjmedia/delaybuf.h> 21 #include <pj media/sound.h>22 #include <pj/assert.h> 22 23 #include <pj/errno.h> 23 24 #include <pj/os.h> … … 37 38 38 39 static pj_caching_pool cp; 39 static pjmedia_ snd_stream *strm;40 static pjmedia_aud_stream *strm; 40 41 static unsigned rec_cnt, play_cnt; 41 42 static pj_time_val t_start; … … 86 87 87 88 /* Init sound subsystem */ 88 status = pjmedia_ snd_init(&cp.factory);89 status = pjmedia_aud_subsys_init(&cp.factory); 89 90 if (status != PJ_SUCCESS) { 90 91 app_perror("pjmedia_snd_init()", status); … … 94 95 } 95 96 96 count = pjmedia_ snd_get_dev_count();97 count = pjmedia_aud_dev_count(); 97 98 PJ_LOG(3,(THIS_FILE, "Device count: %d", count)); 98 99 for (i=0; i<count; ++i) { 99 const pjmedia_snd_dev_info *info; 100 101 info = pjmedia_snd_get_dev_info(i); 100 pjmedia_aud_dev_info info; 101 pj_status_t status; 102 103 status = pjmedia_aud_dev_get_info(i, &info); 104 pj_assert(status == PJ_SUCCESS); 102 105 PJ_LOG(3, (THIS_FILE, "%d: %s %d/%d %dHz", 103 i, info ->name, info->input_count, info->output_count,104 info ->default_samples_per_sec));106 i, info.name, info.input_count, info.output_count, 107 info.default_samples_per_sec)); 105 108 } 106 109 … … 131 134 /* Sound capture callback */ 132 135 static pj_status_t rec_cb(void *user_data, 133 pj_uint32_t timestamp, 134 void *input, 135 unsigned size) 136 pjmedia_frame *frame) 136 137 { 137 138 PJ_UNUSED_ARG(user_data); 138 PJ_UNUSED_ARG(timestamp); 139 PJ_UNUSED_ARG(size); 140 141 pjmedia_delay_buf_put(delaybuf, (pj_int16_t*)input); 142 143 if (size != SAMPLES_PER_FRAME*2) { 139 140 pjmedia_delay_buf_put(delaybuf, (pj_int16_t*)frame->buf); 141 142 if (frame->size != SAMPLES_PER_FRAME*2) { 144 143 PJ_LOG(3, (THIS_FILE, "Size captured = %u", 145 size));144 frame->size)); 146 145 } 147 146 … … 152 151 /* Play cb */ 153 152 static pj_status_t play_cb(void *user_data, 154 pj_uint32_t timestamp, 155 void *output, 156 unsigned size) 153 pjmedia_frame *frame) 157 154 { 158 155 PJ_UNUSED_ARG(user_data); 159 PJ_UNUSED_ARG(timestamp); 160 PJ_UNUSED_ARG(size);161 162 pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)output);156 157 pjmedia_delay_buf_get(delaybuf, (pj_int16_t*)frame->buf); 158 frame->size = SAMPLES_PER_FRAME*2; 159 frame->type = PJMEDIA_FRAME_TYPE_AUDIO; 163 160 164 161 ++play_cnt; … … 169 166 static pj_status_t snd_start(unsigned flag) 170 167 { 168 pjmedia_aud_param param; 171 169 pj_status_t status; 172 170 … … 176 174 } 177 175 178 if (flag==PJMEDIA_DIR_CAPTURE_PLAYBACK) 179 status = pjmedia_snd_open(-1, -1, CLOCK_RATE, CHANNEL_COUNT, 180 SAMPLES_PER_FRAME, BITS_PER_SAMPLE, 181 &rec_cb, &play_cb, NULL, &strm); 182 else if (flag==PJMEDIA_DIR_CAPTURE) 183 status = pjmedia_snd_open_rec(-1, CLOCK_RATE, CHANNEL_COUNT, 184 SAMPLES_PER_FRAME, BITS_PER_SAMPLE, 185 &rec_cb, NULL, &strm); 186 else 187 status = pjmedia_snd_open_player(-1, CLOCK_RATE, CHANNEL_COUNT, 188 SAMPLES_PER_FRAME, BITS_PER_SAMPLE, 189 &play_cb, NULL, &strm); 190 176 pjmedia_aud_dev_default_param(0, ¶m); 177 param.channel_count = CHANNEL_COUNT; 178 param.clock_rate = CLOCK_RATE; 179 param.samples_per_frame = SAMPLES_PER_FRAME; 180 param.dir = (pjmedia_dir) flag; 181 182 status = pjmedia_aud_stream_create(¶m, &rec_cb, &play_cb, NULL, &strm); 191 183 if (status != PJ_SUCCESS) { 192 184 app_perror("snd open", status); … … 199 191 pjmedia_delay_buf_reset(delaybuf); 200 192 201 status = pjmedia_ snd_stream_start(strm);193 status = pjmedia_aud_stream_start(strm); 202 194 if (status != PJ_SUCCESS) { 203 195 app_perror("snd start", status); 204 pjmedia_ snd_stream_close(strm);196 pjmedia_aud_stream_destroy(strm); 205 197 strm = NULL; 206 198 return status; … … 221 213 } 222 214 223 status = pjmedia_ snd_stream_stop(strm);215 status = pjmedia_aud_stream_stop(strm); 224 216 if (status != PJ_SUCCESS) { 225 217 app_perror("snd failed to stop", status); 226 218 } 227 status = pjmedia_ snd_stream_close(strm);219 status = pjmedia_aud_stream_destroy(strm); 228 220 strm = NULL; 229 221 … … 244 236 snd_stop(); 245 237 246 pjmedia_ snd_deinit();238 pjmedia_aud_subsys_shutdown(); 247 239 pjmedia_delay_buf_destroy(delaybuf); 248 240 pj_pool_release(pool);
Note: See TracChangeset
for help on using the changeset viewer.