- Disable EC in sound port when codec is used in sound device
- Added log verbosity in wmme_dev.c
- Tested aps-direct with WMME
git-svn-id: https://svn.pjsip.org/repos/pjproject/branches/projects/aps-direct@2474 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjmedia/src/pjmedia-audiodev/wmme_dev.c b/pjmedia/src/pjmedia-audiodev/wmme_dev.c
index c3b5e17..e1b9215 100644
--- a/pjmedia/src/pjmedia-audiodev/wmme_dev.c
+++ b/pjmedia/src/pjmedia-audiodev/wmme_dev.c
@@ -583,7 +583,7 @@
wmme_strm->timestamp.u64 = 0;
/* Done setting up play device. */
- PJ_LOG(5, (THIS_FILE,
+ PJ_LOG(4, (THIS_FILE,
" WaveAPI Sound player \"%s\" initialized ("
"format=%s, clock_rate=%d, "
"channel_count=%d, samples_per_frame=%d (%dms))",
@@ -663,7 +663,7 @@
wmme_strm->timestamp.u64 = 0;
/* Done setting up play device. */
- PJ_LOG(5,(THIS_FILE,
+ PJ_LOG(4,(THIS_FILE,
" WaveAPI Sound recorder \"%s\" initialized "
"(format=%s, clock_rate=%d, "
"channel_count=%d, samples_per_frame=%d (%dms))",
@@ -788,7 +788,7 @@
}
/* Get frame from application. */
- PJ_LOG(5,(THIS_FILE, "xxx %u play_cb", play_cnt++));
+ //PJ_LOG(5,(THIS_FILE, "xxx %u play_cb", play_cnt++));
status = (*strm->play_cb)(strm->user_data, frame);
if (status != PJ_SUCCESS)
@@ -933,7 +933,7 @@
/* Call callback */
- PJ_LOG(5,(THIS_FILE, "xxx %u rec_cb", rec_cnt++));
+ //PJ_LOG(5,(THIS_FILE, "xxx %u rec_cb", rec_cnt++));
status = (*strm->rec_cb)(strm->user_data, frame);
if (status != PJ_SUCCESS)
break;
@@ -1197,7 +1197,7 @@
if (mr != MMSYSERR_NOERROR) {
return CONVERT_MM_ERROR(mr);
}
- PJ_LOG(5,(THIS_FILE, "WMME playback stream started"));
+ PJ_LOG(4,(THIS_FILE, "WMME playback stream started"));
}
if (stream->rec_strm.hWave.In != NULL)
@@ -1206,7 +1206,7 @@
if (mr != MMSYSERR_NOERROR) {
return CONVERT_MM_ERROR(mr);
}
- PJ_LOG(5,(THIS_FILE, "WMME capture stream started"));
+ PJ_LOG(4,(THIS_FILE, "WMME capture stream started"));
}
return PJ_SUCCESS;
@@ -1226,7 +1226,7 @@
if (mr != MMSYSERR_NOERROR) {
return CONVERT_MM_ERROR(mr);
}
- PJ_LOG(5,(THIS_FILE, "Stopped WMME playback stream"));
+ PJ_LOG(4,(THIS_FILE, "Stopped WMME playback stream"));
}
if (stream->rec_strm.hWave.In != NULL)
@@ -1235,7 +1235,7 @@
if (mr != MMSYSERR_NOERROR) {
return CONVERT_MM_ERROR(mr);
}
- PJ_LOG(5,(THIS_FILE, "Stopped WMME capture stream"));
+ PJ_LOG(4,(THIS_FILE, "Stopped WMME capture stream"));
}
return PJ_SUCCESS;
diff --git a/pjmedia/src/pjmedia/sound_port.c b/pjmedia/src/pjmedia/sound_port.c
index 98b3b72..7117c82 100644
--- a/pjmedia/src/pjmedia/sound_port.c
+++ b/pjmedia/src/pjmedia/sound_port.c
@@ -252,10 +252,11 @@
snd_port->samples_per_frame);
/* Create software EC if parameter specifies EC but device
- * doesn't support EC
+ * doesn't support EC. Only do this if the format is PCM!
*/
if ((snd_port->aud_param.flags & PJMEDIA_AUD_DEV_CAP_EC) &&
- (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC)==0)
+ (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC)==0 &&
+ param_copy.ext_fmt.id == PJMEDIA_FORMAT_PCM)
{
if ((snd_port->aud_param.flags & PJMEDIA_AUD_DEV_CAP_EC_TAIL)==0) {
snd_port->aud_param.flags |= PJMEDIA_AUD_DEV_CAP_EC_TAIL;
@@ -531,9 +532,6 @@
} else {
/* We use software EC */
- /* Sound port must have 16bits per sample */
- PJ_ASSERT_RETURN(snd_port->bits_per_sample == 16,
- PJ_EINVALIDOP);
/* Check if there is change in parameters */
if (tail_ms==snd_port->ec_tail_len && options==snd_port->ec_options) {
@@ -542,22 +540,23 @@
return PJ_SUCCESS;
}
+ status = pjmedia_aud_stream_get_param(snd_port->aud_stream, &prm);
+ if (status != PJ_SUCCESS)
+ return status;
+
+ /* Audio stream must be in PCM format */
+ PJ_ASSERT_RETURN(prm.ext_fmt.id == PJMEDIA_FORMAT_PCM,
+ PJ_EINVALIDOP);
+
/* Destroy AEC */
if (snd_port->ec_state) {
pjmedia_echo_destroy(snd_port->ec_state);
snd_port->ec_state = NULL;
}
- snd_port->ec_options = options;
- snd_port->ec_tail_len = tail_ms;
-
if (tail_ms != 0) {
unsigned delay_ms;
- status = pjmedia_aud_stream_get_param(snd_port->aud_stream, &prm);
- if (status != PJ_SUCCESS)
- prm.input_latency_ms = prm.output_latency_ms = 0;
-
//No need to add input latency in the latency calculation,
//since actual input latency should be zero.
//delay_ms = (si.rec_latency + si.play_latency) * 1000 /
@@ -577,6 +576,9 @@
"sound port"));
status = PJ_SUCCESS;
}
+
+ snd_port->ec_options = options;
+ snd_port->ec_tail_len = tail_ms;
}
return status;