- Timestamp:
- Jun 12, 2008 4:54:48 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/dsound.c
r2007 r2010 44 44 #define BYTES_PER_SAMPLE (BITS_PER_SAMPLE/8) 45 45 46 #define MAX_PACKET_BUFFER_COUNT PJMEDIA_SOUND_BUFFER_COUNT47 #define DEFAULT_BUFFER_COUNT PJMEDIA_SOUND_BUFFER_COUNT46 #define MAX_PACKET_BUFFER_COUNT 50 47 #define MIN_PACKET_BUFFER_COUNT 2 48 48 49 49 #define MAX_HARDWARE 16 … … 88 88 DWORD dwDsBufferSize; 89 89 pj_timestamp timestamp; 90 unsigned latency; 90 91 }; 91 92 … … 239 240 ds_strm->dwDsBufferSize = buffer_count * bytes_per_frame; 240 241 ds_strm->timestamp.u64 = 0; 241 242 ds_strm->latency = buffer_count * samples_per_frame * 1000 / clock_rate / 243 channel_count; 242 244 243 245 /* Done setting up play device. */ … … 345 347 ds_strm->timestamp.u64 = 0; 346 348 ds_strm->dwDsBufferSize = buffer_count * bytes_per_frame; 349 ds_strm->latency = buffer_count * samples_per_frame * 1000 / clock_rate / 350 channel_count; 347 351 348 352 /* Done setting up recorder device. */ … … 727 731 pjmedia_snd_stream *strm; 728 732 pj_status_t status; 729 730 733 731 734 /* Make sure sound subsystem has been initialized with … … 762 765 /* Create player stream */ 763 766 if (dir & PJMEDIA_DIR_PLAYBACK) { 767 unsigned buffer_count; 768 769 /* Calculate buffer count, in frame unit */ 770 buffer_count = clock_rate * snd_output_latency / samples_per_frame / 771 1000; 772 if (buffer_count < MIN_PACKET_BUFFER_COUNT) 773 buffer_count = MIN_PACKET_BUFFER_COUNT; 774 if (buffer_count > MAX_PACKET_BUFFER_COUNT) 775 buffer_count = MAX_PACKET_BUFFER_COUNT; 776 764 777 status = init_player_stream( &strm->play_strm, play_id, clock_rate, 765 778 channel_count, samples_per_frame, 766 DEFAULT_BUFFER_COUNT);779 buffer_count ); 767 780 if (status != PJ_SUCCESS) { 768 781 pjmedia_snd_stream_close(strm); … … 773 786 /* Create capture stream */ 774 787 if (dir & PJMEDIA_DIR_CAPTURE) { 788 unsigned buffer_count; 789 790 /* Calculate buffer count, in frame unit */ 791 buffer_count = clock_rate * snd_input_latency / samples_per_frame / 792 1000; 793 if (buffer_count < MIN_PACKET_BUFFER_COUNT) 794 buffer_count = MIN_PACKET_BUFFER_COUNT; 795 if (buffer_count > MAX_PACKET_BUFFER_COUNT) 796 buffer_count = MAX_PACKET_BUFFER_COUNT; 797 775 798 status = init_capture_stream( &strm->rec_strm, rec_id, clock_rate, 776 799 channel_count, samples_per_frame, 777 DEFAULT_BUFFER_COUNT);800 buffer_count); 778 801 if (status != PJ_SUCCESS) { 779 802 pjmedia_snd_stream_close(strm); … … 872 895 pi->samples_per_frame = strm->samples_per_frame; 873 896 pi->bits_per_sample = strm->bits_per_sample; 874 pi->rec_latency = 0;875 pi->play_latency = 0;897 pi->rec_latency = strm->rec_strm.latency; 898 pi->play_latency = strm->play_strm.latency; 876 899 877 900 return PJ_SUCCESS; … … 997 1020 unsigned output_latency) 998 1021 { 999 PJ_TODO(APPLY_LATENCY_SETTINGS_ON_DSOUND);1000 1001 1022 snd_input_latency = (input_latency == 0)? 1002 1023 PJMEDIA_SND_DEFAULT_REC_LATENCY : input_latency;
Note: See TracChangeset
for help on using the changeset viewer.