- Timestamp:
- Jan 14, 2013 10:08:20 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-audiodev/bb10_dev.c
r4230 r4316 124 124 /* Playback */ 125 125 snd_pcm_t *pb_pcm; 126 unsigned int pb_audio_manager_handle; 126 127 unsigned long pb_frames; /* samples_per_frame */ 127 128 pjmedia_aud_play_cb pb_cb; … … 132 133 /* Capture */ 133 134 snd_pcm_t *ca_pcm; 135 unsigned int ca_audio_manager_handle; 134 136 unsigned long ca_frames; /* samples_per_frame */ 135 137 pjmedia_aud_rec_cb ca_cb; … … 179 181 TRACE_((THIS_FILE, "bb10_add_dev Enter")); 180 182 181 #if PJ_BBSDK_VER >= 0x100006 182 if ((pb_result = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VOICE, 183 if ((pb_result = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VIDEO_CHAT, 183 184 &pcm_handle, 184 185 &handle, … … 186 187 SND_PCM_OPEN_PLAYBACK)) 187 188 >= 0) 188 #else189 PJ_UNUSED_ARG(handle);190 if ((pb_result = snd_pcm_open_preferred (&pcm_handle, &card, &dev,191 SND_PCM_OPEN_PLAYBACK)) >= 0)192 #endif193 189 { 194 TRACE_((THIS_FILE, "Try to open the device for playback - success")); 195 snd_pcm_close (pcm_handle); 190 if ((pb_result = snd_pcm_plugin_set_disable (pcm_handle, PLUGIN_DISABLE_MMAP)) < 0) { 191 TRACE_((THIS_FILE, "snd_pcm_plugin_set_disable ret = %d", pb_result)); 192 }else{ 193 TRACE_((THIS_FILE, "Try to open the device for playback - success")); 194 } 195 snd_pcm_close (pcm_handle); 196 audio_manager_free_handle(handle); 196 197 } else { 197 198 TRACE_((THIS_FILE, "Try to open the device for playback - failure")); 198 199 } 199 200 200 #if PJ_BBSDK_VER >= 0x100006 201 if ((ca_result = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VOICE, 201 if ((ca_result = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VIDEO_CHAT, 202 202 &pcm_handle, 203 203 &handle, … … 205 205 SND_PCM_OPEN_CAPTURE)) 206 206 >= 0) 207 #else208 if ((ca_result = snd_pcm_open_preferred (&pcm_handle, &card, &dev,209 SND_PCM_OPEN_CAPTURE)) >=0)210 #endif211 207 { 212 TRACE_((THIS_FILE, "Try to open the device for capture - success")); 208 if ((ca_result = snd_pcm_plugin_set_disable (pcm_handle, PLUGIN_DISABLE_MMAP)) < 0) { 209 TRACE_((THIS_FILE, "snd_pcm_plugin_set_disable ret = %d", ca_result)); 210 }else{ 211 TRACE_((THIS_FILE, "Try to open the device for capture - success")); 212 } 213 213 snd_pcm_close (pcm_handle); 214 audio_manager_free_handle(handle); 215 214 216 } else { 215 217 TRACE_((THIS_FILE, "Try to open the device for capture - failure")); … … 395 397 snd_pcm_close(stream->pb_pcm); 396 398 stream->pb_pcm = NULL; 399 if(stream->pb_audio_manager_handle != 0){ 400 audio_manager_free_handle(stream->pb_audio_manager_handle); 401 stream->pb_audio_manager_handle = 0; 402 } 397 403 } 398 404 } … … 410 416 snd_pcm_close(stream->ca_pcm); 411 417 stream->ca_pcm = NULL; 418 if(stream->ca_audio_manager_handle != 0){ 419 audio_manager_free_handle(stream->ca_audio_manager_handle); 420 stream->ca_audio_manager_handle = 0; 421 } 412 422 } 413 423 } … … 608 618 unsigned int rate; 609 619 unsigned long tmp_buf_size; 610 unsigned int handle;611 620 612 621 if (param->play_id < 0 || param->play_id >= stream->af->dev_cnt) { … … 614 623 } 615 624 616 #if PJ_BBSDK_VER >= 0x100006 617 if ((ret = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VOICE, 618 &stream->pb_pcm, &handle, 625 if ((ret = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VIDEO_CHAT, 626 &stream->pb_pcm, &stream->pb_audio_manager_handle, 619 627 "/dev/snd/voicep", 620 628 SND_PCM_OPEN_PLAYBACK)) < 0) … … 623 631 return PJMEDIA_EAUD_SYSERR; 624 632 } 625 626 #else 627 if ((ret = snd_pcm_open_preferred (&stream->pb_pcm, &card, &dev, 628 SND_PCM_OPEN_PLAYBACK)) < 0) 629 { 630 TRACE_((THIS_FILE, "snd_pcm_open_preferred ret = %d", ret)); 633 ret = audio_manager_set_handle_type(stream->pb_audio_manager_handle, AUDIO_TYPE_VIDEO_CHAT, AUDIO_DEVICE_HANDSET , AUDIO_DEVICE_HANDSET); 634 if (ret==0) { 635 ret = audio_manager_set_handle_routing_conditions(stream->pb_audio_manager_handle, SETTINGS_RESET_ON_DEVICE_CONNECTION); 636 if(ret != 0){ 637 TRACE_((THIS_FILE, "audio_manager_set_handle_routing_conditions ret = %d", ret)); 638 return PJMEDIA_EAUD_SYSERR; 639 } 640 }else{ 641 TRACE_((THIS_FILE, "audio_manager_set_handle_type ret = %d", ret)); 631 642 return PJMEDIA_EAUD_SYSERR; 632 643 } 633 #endif 634 644 645 if ((ret = snd_pcm_plugin_set_disable (stream->pb_pcm, PLUGIN_DISABLE_MMAP)) < 0) { 646 TRACE_((THIS_FILE, "snd_pcm_plugin_set_disable ret = %d", ret)); 647 return PJMEDIA_EAUD_SYSERR; 648 } 635 649 /* TODO PJ_ZERO */ 636 650 memset (&pi, 0, sizeof (pi)); … … 718 732 snd_pcm_channel_params_t pp; 719 733 snd_pcm_channel_setup_t setup; 720 unsigned int handle;721 734 722 735 if (param->rec_id < 0 || param->rec_id >= stream->af->dev_cnt) 723 736 return PJMEDIA_EAUD_INVDEV; 724 737 725 #if PJ_BBSDK_VER >= 0x100006 726 if ((ret = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VOICE, 738 if ((ret = audio_manager_snd_pcm_open_name(AUDIO_TYPE_VIDEO_CHAT, 727 739 &stream->ca_pcm, 728 & handle,740 &stream->ca_audio_manager_handle, 729 741 "/dev/snd/voicec", 730 742 SND_PCM_OPEN_CAPTURE)) < 0) … … 733 745 return PJMEDIA_EAUD_SYSERR; 734 746 } 735 #else 736 /* BB10 Audio init here (not prepare) */ 737 PJ_UNUSED_ARG(handle); 738 if ((ret = snd_pcm_open_preferred (&stream->ca_pcm, &card, &dev, 739 SND_PCM_OPEN_CAPTURE)) < 0) 740 { 741 TRACE_((THIS_FILE, "snd_pcm_open_preferred ret = %d", ret)); 747 if ((ret = snd_pcm_plugin_set_disable (stream->ca_pcm, PLUGIN_DISABLE_MMAP)) < 0) { 748 TRACE_(("snd_pcm_plugin_set_disable failed: %d",ret)); 742 749 return PJMEDIA_EAUD_SYSERR; 743 750 } 744 #endif745 751 746 752 /* sample reads the capabilities of the capture */
Note: See TracChangeset
for help on using the changeset viewer.