2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 //==========================================================================
14 * @brief This file is implimention of CicoSound class
16 //==========================================================================
25 #include "CicoResourceConfig.h"
26 #include "CicoGKeyFileConfig.h"
28 #include "CicoSound.h"
31 CicoSound *CicoSound::m_myInstance = NULL;
33 /*--------------------------------------------------------------------------*/
35 * @brief default constructor
37 /*--------------------------------------------------------------------------*/
38 CicoSound::CicoSound()
39 : m_initialized(false),
40 m_command(ICO_SOUND_DEFAULT_COMMAND),
41 m_operationSFile(ICO_SOUND_DEFAULT_OPERATION),
42 m_successSFile(ICO_SOUND_DEFAULT_SUCCESS),
43 m_failureSFile(ICO_SOUND_DEFAULT_FAILURE)
47 /*--------------------------------------------------------------------------*/
51 /*--------------------------------------------------------------------------*/
52 CicoSound::~CicoSound()
56 /*--------------------------------------------------------------------------*/
60 * @return CicoSound instance
62 /*--------------------------------------------------------------------------*/
64 CicoSound::GetInstance(void)
66 if (NULL == m_myInstance) {
67 m_myInstance = new CicoSound();
73 //--------------------------------------------------------------------------
76 * initialize to sound a operation
78 * @param[in] homescreen_config configuration instance
80 * @retval true success
83 //--------------------------------------------------------------------------
85 CicoSound::Initialize(CicoGKeyFileConfig *hsConfig)
87 if (true == m_initialized) {
91 m_command = hsConfig->ConfigGetString(ICO_CONFIG_SOUND,
93 ICO_SOUND_DEFAULT_COMMAND);
95 m_operationSFile = hsConfig->ConfigGetString(ICO_CONFIG_SOUND,
97 ICO_SOUND_DEFAULT_OPERATION);
99 m_successSFile = hsConfig->ConfigGetString(ICO_CONFIG_SOUND,
101 ICO_SOUND_DEFAULT_SUCCESS);
103 m_failureSFile = hsConfig->ConfigGetString(ICO_CONFIG_SOUND,
105 ICO_SOUND_DEFAULT_FAILURE);
107 ICO_DBG("CicoSound(command=%s operation=%s success=%s failure=%s",
108 m_command.c_str(), m_operationSFile.c_str(),
109 m_successSFile.c_str(), m_failureSFile.c_str())
111 m_initialized = true;
116 /*--------------------------------------------------------------------------*/
118 * @brief CicoSound::PlayOperationSound
119 * play the given sound file(.wav).
122 * @retval true success
123 * @retval false error
125 /*--------------------------------------------------------------------------*/
127 CicoSound::PlayOperationSound(void)
129 return PlaySound(m_operationSFile);
132 /*--------------------------------------------------------------------------*/
134 * @brief CicoSound::PlaySuccessSound
137 * @retval true success
138 * @retval false error
140 /*--------------------------------------------------------------------------*/
142 CicoSound::PlaySuccessSound(void)
144 return PlaySound(m_successSFile);
147 /*--------------------------------------------------------------------------*/
149 * @brief CicoSound::PlaySuccessSound
152 * @retval true success
153 * @retval false error
155 /*--------------------------------------------------------------------------*/
157 CicoSound::PlayFailureSound(void)
159 return PlaySound(m_failureSFile);
162 /*--------------------------------------------------------------------------*/
164 * @brief CicoSound::PlaySound
165 * play the given sound file(.wav).
168 * @retval true success
169 * @retval false error
171 /*--------------------------------------------------------------------------*/
173 CicoSound::PlaySound(std::string & soundFile)
178 if (false == m_initialized) {
182 if (true == m_operationSFile.empty()) {
183 ICO_WRN("CicoSound::PlaySound: Leave(error file name is empty)");
187 if (m_operationSFile.at(0) != '/') {
188 ICO_WRN("CicoSound::PlaySound: Leave(file name not absolute path");
192 /* given by full file path */
193 snprintf(command, sizeof(command), "%s %s",
194 m_command.c_str(), soundFile.c_str());
196 ICO_DBG("PlaySound:system(%s)", command);
199 (void) system(command);
205 // vim: set expandtab ts=4 sw=4: