- Timestamp:
- Dec 28, 2016 3:40:07 AM (8 years ago)
- Location:
- pjproject/branches/projects/uwp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/uwp
- Property svn:mergeinfo changed
/pjproject/trunk (added) merged: 5209,5212-5234,5237-5253,5255,5257-5292,5294-5297,5299-5332,5334-5394,5396-5438,5440-5469,5471-5496,5498-5510
- Property svn:mergeinfo changed
-
pjproject/branches/projects/uwp/pjmedia/src/pjmedia-audiodev/android_jni_dev.c
r5157 r5513 60 60 pjmedia_dir dir; 61 61 pjmedia_aud_param param; 62 62 63 63 int bytes_per_sample; 64 64 pj_uint32_t samples_per_sec; … … 77 77 pj_thread_t *rec_thread; 78 78 pj_sem_t *rec_sem; 79 pj_timestamp rec_timestamp;80 79 pj_timestamp rec_timestamp; 80 81 81 /* Track */ 82 82 jobject track; … … 87 87 pj_thread_t *play_thread; 88 88 pj_sem_t *play_sem; 89 pj_timestamp 89 pj_timestamp play_timestamp; 90 90 }; 91 91 … … 484 484 pj_ansi_strcpy(info->name, "Android JNI"); 485 485 info->default_samples_per_sec = 8000; 486 info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING; 486 info->caps = PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING | 487 PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE; 487 488 info->input_count = 1; 488 489 info->output_count = 1; 490 info->routes = PJMEDIA_AUD_DEV_ROUTE_CUSTOM; 489 491 490 492 return PJ_SUCCESS; … … 566 568 stream->pool = pool; 567 569 pj_strdup2_with_null(pool, &stream->name, "JNI stream"); 568 stream->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;570 stream->dir = param->dir; 569 571 pj_memcpy(&stream->param, param, sizeof(*param)); 570 572 stream->user_data = user_data; … … 664 666 if (stream->dir & PJMEDIA_DIR_CAPTURE) { 665 667 jthrowable exc; 668 jobject record_obj; 666 669 int mic_source = 0; /* DEFAULT: default audio source */ 670 671 if ((param->flags & PJMEDIA_AUD_DEV_CAP_INPUT_SOURCE) && 672 (param->input_route & PJMEDIA_AUD_DEV_ROUTE_CUSTOM)) 673 { 674 mic_source = param->input_route & ~PJMEDIA_AUD_DEV_ROUTE_CUSTOM; 675 } 667 676 668 677 /* Get pointer to the constructor */ … … 695 704 696 705 do { 697 stream->record= (*jni_env)->NewObject(jni_env,698 699 700 701 702 703 704 705 if ( stream->record== 0) {706 record_obj = (*jni_env)->NewObject(jni_env, 707 stream->record_class, 708 constructor_method, 709 mic_source, 710 param->clock_rate, 711 channelInCfg, 712 sampleFormat, 713 inputBuffSizeRec); 714 if (record_obj == 0) { 706 715 PJ_LOG(3, (THIS_FILE, "Unable to create audio record object")); 707 716 status = PJMEDIA_EAUD_INIT; … … 732 741 goto on_error; 733 742 } 734 state = (*jni_env)->CallIntMethod(jni_env, stream->record, 735 method_id); 743 state = (*jni_env)->CallIntMethod(jni_env, record_obj, method_id); 736 744 if (state == 0) { /* STATE_UNINITIALIZED */ 737 745 PJ_LOG(3, (THIS_FILE, "Failure in initializing audio record.")); … … 745 753 } while (state == 0); 746 754 747 stream->record = (*jni_env)->NewGlobalRef(jni_env, stream->record);755 stream->record = (*jni_env)->NewGlobalRef(jni_env, record_obj); 748 756 if (stream->record == 0) { 749 PJ_LOG(3, (THIS_FILE, "Unable to create audio record global ref.")); 757 jmethodID release_method=0; 758 759 PJ_LOG(3, (THIS_FILE, "Unable to create audio record global ref.")); 760 release_method = (*jni_env)->GetMethodID(jni_env, 761 stream->record_class, 762 "release", "()V"); 763 (*jni_env)->CallVoidMethod(jni_env, record_obj, release_method); 764 750 765 status = PJMEDIA_EAUD_INIT; 751 766 goto on_error; … … 767 782 if (stream->dir & PJMEDIA_DIR_PLAYBACK) { 768 783 jthrowable exc; 784 jobject track_obj; 769 785 770 786 /* Get pointer to the constructor */ … … 778 794 } 779 795 780 stream->track= (*jni_env)->NewObject(jni_env,781 782 783 784 785 786 787 788 789 if ( stream->track== 0) {796 track_obj = (*jni_env)->NewObject(jni_env, 797 stream->track_class, 798 constructor_method, 799 0, /* STREAM_VOICE_CALL */ 800 param->clock_rate, 801 channelOutCfg, 802 sampleFormat, 803 inputBuffSizePlay, 804 1 /* MODE_STREAM */); 805 if (track_obj == 0) { 790 806 PJ_LOG(3, (THIS_FILE, "Unable to create audio track object.")); 791 807 status = PJMEDIA_EAUD_INIT; … … 802 818 } 803 819 804 stream->track = (*jni_env)->NewGlobalRef(jni_env, stream->track);820 stream->track = (*jni_env)->NewGlobalRef(jni_env, track_obj); 805 821 if (stream->track == 0) { 822 jmethodID release_method=0; 823 824 release_method = (*jni_env)->GetMethodID(jni_env, 825 stream->track_class, 826 "release", "()V"); 827 (*jni_env)->CallVoidMethod(jni_env, track_obj, release_method); 828 806 829 PJ_LOG(3, (THIS_FILE, "Unable to create audio track's global ref")); 807 830 status = PJMEDIA_EAUD_INIT; … … 973 996 974 997 PJ_LOG(4,(THIS_FILE, "Destroying Android JNI stream...")); 975 998 976 999 stream->quit_flag = PJ_TRUE; 977 1000 … … 980 1003 981 1004 attached = attach_jvm(&jni_env); 982 1005 983 1006 if (stream->record){ 984 1007 if (stream->rec_thread) { … … 993 1016 stream->rec_sem = NULL; 994 1017 } 995 996 release_method = (*jni_env)->GetMethodID(jni_env, stream->record_class, 997 "release", "()V"); 998 (*jni_env)->CallVoidMethod(jni_env, stream->record, release_method); 999 1018 if (stream->record_class) { 1019 release_method = (*jni_env)->GetMethodID(jni_env, 1020 stream->record_class, 1021 "release", "()V"); 1022 (*jni_env)->CallVoidMethod(jni_env, stream->record, 1023 release_method); 1024 } 1000 1025 (*jni_env)->DeleteGlobalRef(jni_env, stream->record); 1001 (*jni_env)->DeleteGlobalRef(jni_env, stream->record_class);1002 1026 stream->record = NULL; 1003 stream->record_class = NULL;1004 1027 PJ_LOG(4, (THIS_FILE, "Audio record released")); 1028 } 1029 if (stream->record_class) { 1030 (*jni_env)->DeleteGlobalRef(jni_env, stream->record_class); 1031 stream->record_class = NULL; 1005 1032 } 1006 1033 … … 1017 1044 stream->play_sem = NULL; 1018 1045 } 1019 1020 release_method = (*jni_env)->GetMethodID(jni_env, stream->track_class, 1021 "release", "()V"); 1022 (*jni_env)->CallVoidMethod(jni_env, stream->track, release_method); 1023 1046 if (stream->track_class) { 1047 release_method = (*jni_env)->GetMethodID(jni_env, 1048 stream->track_class, 1049 "release", "()V"); 1050 (*jni_env)->CallVoidMethod(jni_env, stream->track, 1051 release_method); 1052 } 1024 1053 (*jni_env)->DeleteGlobalRef(jni_env, stream->track); 1025 (*jni_env)->DeleteGlobalRef(jni_env, stream->track_class); 1026 stream->track = NULL; 1027 stream->track_class = NULL; 1028 PJ_LOG(3, (THIS_FILE, "Audio track released")); 1054 stream->track = NULL; 1055 PJ_LOG(4, (THIS_FILE, "Audio track released")); 1056 } 1057 if (stream->track_class) { 1058 (*jni_env)->DeleteGlobalRef(jni_env, stream->track_class); 1059 stream->track_class = NULL; 1029 1060 } 1030 1061
Note: See TracChangeset
for help on using the changeset viewer.