Changeset 1243 for pjproject/trunk/pjmedia/src/pjmedia/nullsound.c
- Timestamp:
- May 2, 2007 1:19:33 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/nullsound.c
r974 r1243 20 20 #include <pjmedia/errno.h> 21 21 #include <pj/assert.h> 22 #include <pj/pool.h> 22 23 23 24 #if PJMEDIA_SOUND_IMPLEMENTATION==PJMEDIA_SOUND_NULL_SOUND … … 31 32 }; 32 33 34 static pj_pool_factory *pool_factory; 35 36 struct pjmedia_snd_stream 37 { 38 pj_pool_t *pool; 39 pjmedia_dir dir; 40 int rec_id; 41 int play_id; 42 unsigned clock_rate; 43 unsigned channel_count; 44 unsigned samples_per_frame; 45 unsigned bits_per_sample; 46 pjmedia_snd_rec_cb rec_cb; 47 pjmedia_snd_play_cb play_cb; 48 void *user_data; 49 }; 50 33 51 34 52 PJ_DEF(pj_status_t) pjmedia_snd_init(pj_pool_factory *factory) 35 53 { 36 PJ_UNUSED_ARG(factory); 54 pool_factory = factory; 55 return PJ_SUCCESS; 56 } 57 58 PJ_DEF(pj_status_t) pjmedia_snd_deinit(void) 59 { 37 60 return PJ_SUCCESS; 38 61 } … … 58 81 pjmedia_snd_stream **p_snd_strm) 59 82 { 60 PJ_UNUSED_ARG(index); 61 PJ_UNUSED_ARG(clock_rate); 62 PJ_UNUSED_ARG(channel_count); 63 PJ_UNUSED_ARG(samples_per_frame); 64 PJ_UNUSED_ARG(bits_per_sample); 65 PJ_UNUSED_ARG(rec_cb); 66 PJ_UNUSED_ARG(user_data); 67 68 *p_snd_strm = (void*)1; 69 70 return PJ_SUCCESS; 83 return pjmedia_snd_open(index, -2, clock_rate, channel_count, 84 samples_per_frame, bits_per_sample, 85 rec_cb, NULL, user_data, p_snd_strm); 71 86 } 72 87 … … 80 95 pjmedia_snd_stream **p_snd_strm ) 81 96 { 82 PJ_UNUSED_ARG(index); 83 PJ_UNUSED_ARG(clock_rate); 84 PJ_UNUSED_ARG(channel_count); 85 PJ_UNUSED_ARG(samples_per_frame); 86 PJ_UNUSED_ARG(bits_per_sample); 87 PJ_UNUSED_ARG(play_cb); 88 PJ_UNUSED_ARG(user_data); 89 90 *p_snd_strm = (void*)1; 91 92 return PJ_SUCCESS; 97 return pjmedia_snd_open(-2, index, clock_rate, channel_count, 98 samples_per_frame, bits_per_sample, 99 NULL, play_cb, user_data, p_snd_strm); 93 100 } 94 101 … … 104 111 pjmedia_snd_stream **p_snd_strm) 105 112 { 106 PJ_UNUSED_ARG(rec_id); 107 PJ_UNUSED_ARG(play_id); 108 PJ_UNUSED_ARG(clock_rate); 109 PJ_UNUSED_ARG(channel_count); 110 PJ_UNUSED_ARG(samples_per_frame); 111 PJ_UNUSED_ARG(bits_per_sample); 112 PJ_UNUSED_ARG(rec_cb); 113 PJ_UNUSED_ARG(play_cb); 114 PJ_UNUSED_ARG(user_data); 113 pj_pool_t *pool; 114 pjmedia_snd_stream *snd_strm; 115 115 116 *p_snd_strm = (void*)1; 116 pool = pj_pool_create(pool_factory, NULL, 128, 128, NULL); 117 snd_strm = PJ_POOL_ZALLOC_T(pool, pjmedia_snd_stream); 118 119 snd_strm->pool = pool; 120 121 if (rec_id == -1) rec_id = 0; 122 if (play_id == -1) play_id = 0; 123 124 if (rec_id != -2 && play_id != -2) 125 snd_strm->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK; 126 else if (rec_id != -2) 127 snd_strm->dir = PJMEDIA_DIR_CAPTURE; 128 else if (play_id != -2) 129 snd_strm->dir = PJMEDIA_DIR_PLAYBACK; 130 131 snd_strm->rec_id = rec_id; 132 snd_strm->play_id = play_id; 133 snd_strm->clock_rate = clock_rate; 134 snd_strm->channel_count = channel_count; 135 snd_strm->samples_per_frame = samples_per_frame; 136 snd_strm->bits_per_sample = bits_per_sample; 137 snd_strm->rec_cb = rec_cb; 138 snd_strm->play_cb = play_cb; 139 snd_strm->user_data = user_data; 140 141 *p_snd_strm = snd_strm; 117 142 118 143 return PJ_SUCCESS; … … 136 161 { 137 162 138 PJ_ASSERT_RETURN(strm && pi, PJ_EINVAL); 139 return PJ_EINVALIDOP; 163 pj_bzero(pi, sizeof(pjmedia_snd_stream_info)); 164 pi->dir = strm->dir; 165 pi->play_id = strm->play_id; 166 pi->rec_id = strm->rec_id; 167 pi->clock_rate = strm->clock_rate; 168 pi->channel_count = strm->channel_count; 169 pi->samples_per_frame = strm->samples_per_frame; 170 pi->bits_per_sample = strm->bits_per_sample; 171 pi->rec_latency = 0; 172 pi->play_latency = 0; 173 174 return PJ_SUCCESS; 140 175 } 141 176 … … 143 178 PJ_DEF(pj_status_t) pjmedia_snd_stream_close(pjmedia_snd_stream *stream) 144 179 { 145 PJ_UNUSED_ARG(stream);180 pj_pool_release(stream->pool); 146 181 return PJ_SUCCESS; 147 182 } 148 183 149 PJ_DEF(pj_status_t) pjmedia_snd_deinit(void)150 {151 return PJ_SUCCESS;152 }153 154 155 184 #endif /* PJMEDIA_SOUND_IMPLEMENTATION */
Note: See TracChangeset
for help on using the changeset viewer.