4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Seungbae Shin <seungbae.shin@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <sys/types.h>
35 #include <mm_message.h>
38 #include <mm_sound_private.h>
40 #define KEYTONE_PATH "/tmp/keytone" /* Keytone pipe path */
41 #define FILE_FULL_PATH 1024 /* File path lenth */
48 int mm_sound_play_keysound(const char *filename, const volume_type_t vol_type)
50 int err = MM_ERROR_NONE;
56 return MM_ERROR_SOUND_INVALID_FILE;
58 fd = open(filename, O_RDONLY);
61 debug_error("file open failed with %s\n", strerror(errno));
65 return MM_ERROR_SOUND_FILE_NOT_FOUND;
68 return MM_ERROR_SOUND_INVALID_STATE;
70 return MM_ERROR_SOUND_INTERNAL;
75 fd = open(KEYTONE_PATH, O_WRONLY | O_NONBLOCK);
78 debug_error("Fail to open pipe\n");
79 return MM_ERROR_SOUND_FILE_NOT_FOUND;
81 data.vol_type = vol_type;
83 strncpy(data.filename, filename, FILE_FULL_PATH);
84 debug_msg("The file name [%s]\n", data.filename);
86 err = write(fd, &data, size);
89 debug_error("Fail to write data: %s\n", strerror(err));
91 return MM_ERROR_SOUND_INTERNAL;