1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef SPEECH_SPEECH_INSTANCE_H_
6 #define SPEECH_SPEECH_INSTANCE_H_
9 #include <thread> // NOLINT
13 #include "common/extension.h"
14 #include "common/picojson.h"
16 class SpeechInstance : public common::Instance {
19 virtual ~SpeechInstance();
22 static gboolean IOWatchCb(GIOChannel* source,
23 GIOCondition condition,
25 static gboolean ProcessPendingRequestsCb(gpointer data);
26 static gboolean ProcessPendingRepliesCb(gpointer data);
29 // common::Instance implementation.
30 virtual void HandleMessage(const char* msg);
31 virtual void HandleSyncMessage(const char* message);
33 void QueueReply(const std::string& reply);
34 void QueueRequest(const std::string& req);
35 bool SendRequest(const char* message);
36 uint32_t ReadReply(char** reply);
38 static void SetupMainloop(void *data);
39 GMainLoop* main_loop_;
43 std::queue<std::string> pending_replies_;
44 std::queue<std::string> pending_requests_;
48 guint pending_request_timer_;
49 guint pending_reply_timer_;
51 #endif // SPEECH_SPEECH_INSTANCE_H_