| // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #include <iostream> |
| #include <errno.h> |
| #include <stdlib.h> |
| #include <sys/types.h> |
| #include <unistd.h> |
| |
| #include <base/basictypes.h> |
| #include <base/command_line.h> |
| #include <chromeos/dbus/dbus.h> |
| #include <chromeos/glib/object.h> |
| |
| #include "base/logging.h" |
| #include "speech_synthesizer_service.h" |
| |
| // Starts the speech synthesis DBus service. |
| namespace speech_synthesis { |
| |
| static const char kLogFile[] = "log-file"; |
| static const char kDefaultLogFile[] = "/tmp/speech_synthesizer"; |
| |
| } // namespace speech_synthesis |
| |
| int main(int argc, char* argv[]) { |
| CommandLine::Init(argc, argv); |
| CommandLine *cl = CommandLine::ForCurrentProcess(); |
| std::string log_file = cl->GetSwitchValueASCII(speech_synthesis::kLogFile); |
| if (log_file.empty()) |
| log_file.assign(speech_synthesis::kDefaultLogFile); |
| logging::InitLogging(log_file.c_str(), |
| logging::LOG_TO_BOTH_FILE_AND_SYSTEM_DEBUG_LOG, |
| logging::DONT_LOCK_LOG_FILE, |
| logging::APPEND_TO_OLD_LOG_FILE); |
| |
| LOG(INFO) << "Starting speech_synthesizer service."; |
| ::g_type_init(); |
| speech_synthesis::SpeechSynthesizerService service; |
| if (!service.Initialize()) { |
| LOG(ERROR) << "Failed to initialize."; |
| return -1; |
| } |
| if (!service.Register(chromeos::dbus::GetSystemBusConnection())) { |
| LOG(ERROR) << "Failed to register"; |
| return -1; |
| } |
| if (!service.Run()) { |
| LOG(ERROR) << "Failed to run"; |
| return -1; |
| } |
| LOG(INFO) << "Started speech_synthesizer service."; |
| return 0; |
| } |
| |