#include <message_port.h>
#include <chrono>
+#include <atomic>
#include "service_common.h"
#include "service_main.h"
#include "service_ipc_dbus.h"
-size_t gAudioDataMileage{0};
+std::atomic_size_t gAudioDataMileage{0};
int CServiceIpcDbus::reconnect()
{
MAS_LOGE("Buffer overflow : %zu %zu", new_size, total_size);
return -1;
}
+ gAudioDataMileage.fetch_add(data_size);
const long long minimum_flush_interval = 20;
static long long last_flush_time = get_current_milliseconds_after_epoch();
if (0 == header.streaming_data_serial % 50 || MAS_SPEECH_STREAMING_EVENT_CONTINUE != event) {
last_serial_waiting_for_flush = header.streaming_data_serial;
MAS_LOGE("queueing streaming data, serial : %d %d %zu",
- last_serial_waiting_for_flush, event, gAudioDataMileage);
+ last_serial_waiting_for_flush, event, gAudioDataMileage.load());
}
if (pending_buffer_size + total_size > STREAMING_BUFFER_SIZE ||
MAS_SPEECH_STREAMING_EVENT_FINISH == event ||
if (-1 != last_serial_waiting_for_flush) {
MAS_LOGE("flushing streaming data, serial : %d %zu",
- last_serial_waiting_for_flush, gAudioDataMileage);
+ last_serial_waiting_for_flush, gAudioDataMileage.load());
last_serial_waiting_for_flush = -1;
}
}
if (MAS_SPEECH_STREAMING_EVENT_FINISH == event) {
- MAS_LOGE("Sending FINISH event : %zu", gAudioDataMileage);
+ MAS_LOGE("Sending FINISH event : %zu", gAudioDataMileage.load());
bundle *b = bundle_create();
if (b) {
bundle_add_byte(b, "content", buffer, total_size);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_START_STREAMING_AUDIO_DATA)) {
/* Reset mileage data for logging */
- gAudioDataMileage = 0;
+ gAudioDataMileage.store(0);
dispatcher->on_start_streaming_audio_data(mConnectionListener, msg);
} else if (dbus_message_is_method_call(msg, MA_SERVER_SERVICE_INTERFACE, MA_METHOD_STOP_STREAMING_AUDIO_DATA)) {