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),
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();
72 //--------------------------------------------------------------------------
75 * initialize to sound a operation
77 * @param[in] homescreen_config configuration instance
79 * @retval true success
82 //--------------------------------------------------------------------------
84 CicoSound::Initialize(CicoGKeyFileConfig *hsConfig)
86 if (true == m_initialized) {
90 m_command = hsConfig->ConfigGetString(ICO_CONFIG_SOUND,
92 ICO_SOUND_DEFAULT_COMMAND);
94 m_operationSFile = hsConfig->ConfigGetFilePath(
95 ICO_CONFIG_SOUND, ICO_CONFIG_OPERATION,
96 ICO_SYC_CONFIGPATH_HOME_SOUND,
97 ICO_SYC_PACKAGE_HOMESCREEN
98 "/" ICO_SYC_CONFIGPATH_PACKAGE_SOUND,
99 ICO_SOUND_DEFAULT_OPERATION);
101 m_successSFile = hsConfig->ConfigGetFilePath(
102 ICO_CONFIG_SOUND, ICO_CONFIG_SUCCESS,
103 ICO_SYC_CONFIGPATH_HOME_SOUND,
104 ICO_SYC_PACKAGE_HOMESCREEN
105 "/" ICO_SYC_CONFIGPATH_PACKAGE_SOUND,
106 ICO_SOUND_DEFAULT_SUCCESS);
108 m_failureSFile = hsConfig->ConfigGetFilePath(
109 ICO_CONFIG_SOUND, ICO_CONFIG_FAILURE,
110 ICO_SYC_CONFIGPATH_HOME_SOUND,
111 ICO_SYC_PACKAGE_HOMESCREEN
112 "/" ICO_SYC_CONFIGPATH_PACKAGE_SOUND,
113 ICO_SOUND_DEFAULT_FAILURE);
115 ICO_DBG("CicoSound(command=%s operation=%s success=%s failure=%s",
116 m_command.c_str(), m_operationSFile.c_str(),
117 m_successSFile.c_str(), m_failureSFile.c_str())
119 m_initialized = true;
124 /*--------------------------------------------------------------------------*/
126 * @brief CicoSound::PlayOperationSound
127 * play the given sound file(.wav).
130 * @retval true success
131 * @retval false error
133 /*--------------------------------------------------------------------------*/
135 CicoSound::PlayOperationSound(void)
137 return PlaySound(m_operationSFile);
140 /*--------------------------------------------------------------------------*/
142 * @brief CicoSound::PlaySuccessSound
145 * @retval true success
146 * @retval false error
148 /*--------------------------------------------------------------------------*/
150 CicoSound::PlaySuccessSound(void)
152 return PlaySound(m_successSFile);
155 /*--------------------------------------------------------------------------*/
157 * @brief CicoSound::PlaySuccessSound
160 * @retval true success
161 * @retval false error
163 /*--------------------------------------------------------------------------*/
165 CicoSound::PlayFailureSound(void)
167 return PlaySound(m_failureSFile);
170 /*--------------------------------------------------------------------------*/
172 * @brief CicoSound::PlaySound
173 * play the given sound file(.wav).
176 * @retval true success
177 * @retval false error
179 /*--------------------------------------------------------------------------*/
181 CicoSound::PlaySound(std::string & soundFile)
186 if (false == m_initialized) {
190 if (true == m_operationSFile.empty()) {
191 ICO_WRN("CicoSound::PlaySound: Leave(error file name is empty)");
195 if (m_operationSFile.at(0) != '/') {
196 ICO_WRN("CicoSound::PlaySound: Leave(file name not absolute path");
200 /* given by full file path */
201 snprintf(command, sizeof(command), "%s %s",
202 m_command.c_str(), soundFile.c_str());
204 ICO_DBG("PlaySound:system(%s)", command);
213 // vim: set expandtab ts=4 sw=4: