Piano / src / player /
piano-impl-player.c
- /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- #include "player/piano-player.h"
- #include "logger.h"
- #include "config.h"
- #include "piano-structs.h"
- void piano_note_player_init(void *data)
- {
- RETM_IF(!data, "data is NULL");
- note_struct *note = (note_struct *)data;
- player_create(&(note->player));
- }
- void piano_players_destroy(void *data)
- {
- RETM_IF(!data, "data is NULL");
- app_data *ad = (app_data *)data;
- Eina_List *l = NULL;
- note_struct *note = NULL;
- EINA_LIST_FOREACH(ad->buttonList, l, note) {
- player_unprepare(note->player);
- player_destroy(note->player);
- note->player = NULL;
- }
- }
- void piano_player_play(void *data)
- {
- RETM_IF(!data, "data is NULL");
- note_struct *note = (note_struct *) data;
- piano_player_stop(note);
- player_start(note->player);
- }
- void piano_player_stop(void *data)
- {
- RETM_IF(!data, "data is NULL");
- note_struct *note = (note_struct *) data;
- player_state_e state;
- player_get_state(note->player, &state);
- if (state == PLAYER_STATE_PLAYING) {
- player_stop(note->player);
- }
- }
- void piano_note_player_prepare(void *data)
- {
- RETM_IF(!data, "data is NULL");
- note_struct *note = (note_struct *) data;
- char sound_path[PATH_MAX] = {'\0'};
- snprintf(sound_path, PATH_MAX, "%s/%s", get_path(SNDPATH), note->sound_name);
- int ret = player_set_uri(note->player, sound_path);
- RETM_IF(ret != PLAYER_ERROR_NONE, "ret=%d, note->player=%p", ret, note->player);
- player_prepare(note->player);
- }