|
|
@@ -448,7 +448,7 @@ static void stream_write_request_cb(pa_stream* s, size_t length, void* data)
|
|
|
void* audiodata;
|
|
|
while ((nbytes = pa_stream_writable_size(s)) != (size_t)-1)
|
|
|
{
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_writable_size nbytes = %d.", __FUNCTION__, __LINE__, nbytes);
|
|
|
+ //audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_writable_size nbytes = %d.", __FUNCTION__, __LINE__, nbytes);
|
|
|
get_play_latency(s);
|
|
|
if (0 == nbytes){
|
|
|
return;
|
|
|
@@ -457,7 +457,7 @@ static void stream_write_request_cb(pa_stream* s, size_t length, void* data)
|
|
|
/*write to stream*/
|
|
|
if (PA_OK == pa_stream_begin_write(s, &audiodata, &nbytes))
|
|
|
{
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_begin_write nbytes = %d, audio_ctx->uaudio_len = %d.", __FUNCTION__, __LINE__, nbytes, audio_ctx->uaudio_len);
|
|
|
+ //audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_begin_write nbytes = %d, audio_ctx->uaudio_len = %d.", __FUNCTION__, __LINE__, nbytes, audio_ctx->uaudio_len);
|
|
|
while (audio_ctx->uaudio_len < nbytes)
|
|
|
{
|
|
|
char delaybuffer[RVC_DELAY_AUDIO_LEN] = { 0 };
|
|
|
@@ -477,12 +477,12 @@ static void stream_write_request_cb(pa_stream* s, size_t length, void* data)
|
|
|
if (audio_ctx->uaudio_len + RVC_DELAY_AUDIO_LEN <= RVC_MAX_AUDIO_BUFFER_LEN) {
|
|
|
memcpy(audio_ctx->paudio_buffer + audio_ctx->uaudio_len, delaybuffer, RVC_DELAY_AUDIO_LEN);
|
|
|
audio_ctx->uaudio_len += RVC_DELAY_AUDIO_LEN;
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio_ctx->uaudio_len = %d.", __FUNCTION__, __LINE__, audio_ctx->uaudio_len);
|
|
|
+ //audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio_ctx->uaudio_len = %d.", __FUNCTION__, __LINE__, audio_ctx->uaudio_len);
|
|
|
}
|
|
|
else {
|
|
|
memcpy(audio_ctx->paudio_buffer + audio_ctx->uaudio_len, delaybuffer, RVC_MAX_AUDIO_BUFFER_LEN - audio_ctx->uaudio_len);
|
|
|
audio_ctx->uaudio_len = RVC_MAX_AUDIO_BUFFER_LEN;
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio_ctx->uaudio_len = %d and break.", __FUNCTION__, __LINE__, audio_ctx->uaudio_len);
|
|
|
+ //audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio_ctx->uaudio_len = %d and break.", __FUNCTION__, __LINE__, audio_ctx->uaudio_len);
|
|
|
break;
|
|
|
}
|
|
|
//}
|
|
|
@@ -492,7 +492,7 @@ static void stream_write_request_cb(pa_stream* s, size_t length, void* data)
|
|
|
}
|
|
|
|
|
|
int ileft = audio_ctx->uaudio_len - nbytes;
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d ileft = %d.", __FUNCTION__, __LINE__, ileft);
|
|
|
+ //audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d ileft = %d.", __FUNCTION__, __LINE__, ileft);
|
|
|
if (ileft >= 0) {
|
|
|
memcpy(audiodata, audio_ctx->paudio_buffer, nbytes);
|
|
|
if (ileft > 0) {
|
|
|
@@ -511,9 +511,9 @@ static void stream_write_request_cb(pa_stream* s, size_t length, void* data)
|
|
|
audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_write failed.", __FUNCTION__, __LINE__);
|
|
|
break;
|
|
|
}
|
|
|
- else {
|
|
|
- audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_write(%d) success.", __FUNCTION__, __LINE__, nbytes);
|
|
|
- }
|
|
|
+ //else {
|
|
|
+ // audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_write(%d) success.", __FUNCTION__, __LINE__, nbytes);
|
|
|
+ //}
|
|
|
}
|
|
|
else {
|
|
|
audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pa_stream_begin_write failed for %s.", __FUNCTION__, __LINE__, pa_strerror(pa_context_errno(audio_ctx)));
|
|
|
@@ -914,15 +914,10 @@ int audio_stop_playaudio(audio_context_t* audio_ctx)
|
|
|
/*assertions*/
|
|
|
assert(audio_ctx != NULL);
|
|
|
if (AUDIO_STRM_ON == audio_ctx->play_stream_flag){
|
|
|
+ audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d set play_stream_flag to off.", __FUNCTION__, __LINE__);
|
|
|
audio_ctx->play_stream_flag = AUDIO_STRM_OFF;
|
|
|
if (0 != audio_ctx->writethreadid) {
|
|
|
if (0 == pthread_join(audio_ctx->writethreadid, NULL)) {
|
|
|
- //struct timespec ts;
|
|
|
- //clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
- //long unsec = ts.tv_nsec + (1000 * 1000 * 1000);
|
|
|
- //ts.tv_sec += (unsec / 1000000000);
|
|
|
- //ts.tv_nsec = (unsec % 1000000000);
|
|
|
- //if (0 == pthread_timedjoin_np(audio_ctx->writethreadid, NULL, &ts)) {
|
|
|
audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pulse audio write thread %u joined success.", __FUNCTION__, __LINE__, audio_ctx->writethreadid);
|
|
|
audio_ctx->writethreadid = 0;
|
|
|
}
|
|
|
@@ -931,6 +926,9 @@ int audio_stop_playaudio(audio_context_t* audio_ctx)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio play stream flag is alreay off.", __FUNCTION__, __LINE__);
|
|
|
+ }
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -943,12 +941,6 @@ int audio_stop_pulseaudio(audio_context_t* audio_ctx)
|
|
|
audio_ctx->stream_flag = AUDIO_STRM_OFF;
|
|
|
if (0 != audio_ctx->readthreadid){
|
|
|
if (0 == pthread_join(audio_ctx->readthreadid, NULL)) {
|
|
|
- //struct timespec ts;
|
|
|
- //clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
- //long unsec = ts.tv_nsec + (1000 * 1000 * 1000);
|
|
|
- //ts.tv_sec += (unsec / 1000000000);
|
|
|
- //ts.tv_nsec = (unsec % 1000000000);
|
|
|
- //if (0 == pthread_timedjoin_np(audio_ctx->readthreadid, NULL, &ts)) {
|
|
|
audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d pulse audio read thread %u joined success.", __FUNCTION__, __LINE__, audio_ctx->readthreadid);
|
|
|
audio_ctx->readthreadid = 0;
|
|
|
}
|
|
|
@@ -957,6 +949,9 @@ int audio_stop_pulseaudio(audio_context_t* audio_ctx)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else {
|
|
|
+ audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d audio read stream flag is alreay off.", __FUNCTION__, __LINE__);
|
|
|
+ }
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -1315,12 +1310,12 @@ apr_status_t audiomicspkpulse_create(apr_pool_t* pool,
|
|
|
|
|
|
do {
|
|
|
struct timespec ts;
|
|
|
- int ivalue = -1;
|
|
|
+ //int ivalue = -1;
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
|
long unsec = ts.tv_nsec + (1000 * 1000 * 10);
|
|
|
ts.tv_sec += (unsec / 1000000000);
|
|
|
ts.tv_nsec = (unsec % 1000000000);
|
|
|
- sem_getvalue(micspk->audio_device_started_sem, &ivalue);
|
|
|
+ //sem_getvalue(micspk->audio_device_started_sem, &ivalue);
|
|
|
//audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d current sem value is %d.", __FUNCTION__, __LINE__, ivalue);
|
|
|
if (-1 == sem_timedwait(micspk->audio_device_started_sem, &ts)) {
|
|
|
if (ETIMEDOUT == errno) {
|
|
|
@@ -1365,6 +1360,7 @@ void audiomicspkpulse_destroy(audiomicspkpulse_t* micspk)
|
|
|
audio_close_pulseaudio(micspk->audio_ctx);
|
|
|
}
|
|
|
|
|
|
+ audio_log_v(AUDIO_LOG_LEVEL_INFO, "%s:%d sem post audio_device_started_sem.", __FUNCTION__, __LINE__);
|
|
|
sem_post(micspk->audio_device_started_sem);
|
|
|
|
|
|
if (NULL != micspk->audio_work_thread){
|