audio_stream.channel_mask = a_buffer->channel_mask;
audio_stream.data_size = a_buffer->data_size;
audio_stream.data = a_buffer->pcm_data;
+ audio_stream.pcm_format = a_buffer->pcm_format;
/* LOGD("[%"G_GUINT64_FORMAT"] send data size:%d, %p", audio_stream.channel_mask, audio_stream.data_size, player->audio_decoded_cb_user_param); */
player->audio_decoded_cb(&audio_stream, player->audio_decoded_cb_user_param);
}
}
- /* create new audio stream data */
+ /* create new audio stream data for newly found audio channel */
a_buffer = (mmplayer_audio_stream_buff_t *)g_try_malloc0(sizeof(mmplayer_audio_stream_buff_t));
if (a_buffer == NULL) {
LOGE("failed to alloc data.");
if (player->build_audio_offload) { /* skip all the audio filters */
LOGD("create audio offload sink : %s", player->ini.audio_offload_sink_element);
+
MMPLAYER_CREATE_ELEMENT(audiobin, MMPLAYER_A_SINK, player->ini.audio_offload_sink_element, "audiosink", element_bucket, player);
- g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE, NULL);
+ g_object_set(G_OBJECT(audiobin[MMPLAYER_A_SINK].gst), "sync", TRUE,
+ "volume", player->sound.volume, "mute", player->sound.mute, NULL);
+
__mmplayer_add_sink(player, audiobin[MMPLAYER_A_SINK].gst);
goto DONE;
}
return MM_ERROR_NONE;
}
-
-int
-_mmplayer_set_volume(MMHandleType hplayer, mmplayer_volume_type_t volume)
+static int
+__mmplayer_gst_set_volume_property(mmplayer_t *player, const char *prop_name)
{
- mmplayer_t *player = (mmplayer_t *)hplayer;
GstElement *vol_element = NULL;
- int i = 0;
+ enum audio_element_id volume_elem_id = MMPLAYER_A_VOL;
MMPLAYER_FENTER();
-
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
-
- LOGD("volume [L]=%f:[R]=%f",
- volume.level[MM_VOLUME_CHANNEL_LEFT], volume.level[MM_VOLUME_CHANNEL_RIGHT]);
-
- /* invalid factor range or not */
- for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++) {
- if (volume.level[i] < MM_VOLUME_FACTOR_MIN || volume.level[i] > MM_VOLUME_FACTOR_MAX) {
- LOGE("Invalid factor!(valid factor:0~1.0)");
- return MM_ERROR_INVALID_ARGUMENT;
- }
- }
-
- /* not support to set other value into each channel */
- if ((volume.level[MM_VOLUME_CHANNEL_LEFT] != volume.level[MM_VOLUME_CHANNEL_RIGHT]))
- return MM_ERROR_INVALID_ARGUMENT;
-
- /* Save volume to handle. Currently the first array element will be saved. */
- player->sound.volume = volume.level[MM_VOLUME_CHANNEL_LEFT];
+ MMPLAYER_RETURN_VAL_IF_FAIL(prop_name, MM_ERROR_INVALID_ARGUMENT);
/* check pipeline handle */
if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("audiobin is not created yet");
- LOGD("but, current stored volume will be set when it's created.");
+ LOGD("'%s' will be applied when audiobin is created", prop_name);
- /* NOTE : stored volume will be used in create_audiobin
+ /* NOTE : stored value will be used in create_audiobin
* returning MM_ERROR_NONE here makes application to able to
- * set volume at anytime.
+ * set audio volume or mute at anytime.
*/
return MM_ERROR_NONE;
}
- /* setting volume to volume element */
- vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
+ if (player->build_audio_offload) {
+ LOGD("offload pipeline");
+ volume_elem_id = MMPLAYER_A_SINK;
+ }
+
+ vol_element = player->pipeline->audiobin[volume_elem_id].gst;
+ if (!vol_element) {
+ LOGE("failed to get vol element %d", volume_elem_id);
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
- if (vol_element) {
- LOGD("volume is set [%f]", player->sound.volume);
- g_object_set(vol_element, "volume", player->sound.volume, NULL);
+ LOGD("set '%s' property to element[%s]", prop_name, GST_ELEMENT_NAME(vol_element));
+
+ if (!g_object_class_find_property(G_OBJECT_GET_CLASS(vol_element), prop_name)) {
+ LOGE("there is no '%s' property", prop_name);
+ return MM_ERROR_PLAYER_INTERNAL;
}
- MMPLAYER_FLEAVE();
+ if (!strcmp(prop_name, "volume")) {
+ g_object_set(vol_element, "volume", player->sound.volume, NULL);
+ } else if (!strcmp(prop_name, "mute")) {
+ g_object_set(vol_element, "mute", player->sound.mute, NULL);
+ } else {
+ LOGE("invalid property %s", prop_name);
+ return MM_ERROR_PLAYER_INTERNAL;
+ }
return MM_ERROR_NONE;
}
int
-_mmplayer_get_volume(MMHandleType hplayer, mmplayer_volume_type_t *volume)
+_mmplayer_set_volume(MMHandleType hplayer, float volume)
{
+ int ret = MM_ERROR_NONE;
mmplayer_t *player = (mmplayer_t *)hplayer;
- int i = 0;
MMPLAYER_FENTER();
-
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
- /* returning stored volume */
- for (i = 0; i < MM_VOLUME_CHANNEL_NUM; i++)
- volume->level[i] = player->sound.volume;
+ LOGD("volume = %f", volume);
- MMPLAYER_FLEAVE();
+ /* invalid factor range or not */
+ if (volume < MM_VOLUME_FACTOR_MIN || volume > MM_VOLUME_FACTOR_MAX) {
+ LOGE("Invalid volume value");
+ return MM_ERROR_INVALID_ARGUMENT;
+ }
- return MM_ERROR_NONE;
+ player->sound.volume = volume;
+
+ ret = __mmplayer_gst_set_volume_property(player, "volume");
+
+ MMPLAYER_FLEAVE();
+ return ret;
}
int
-_mmplayer_set_mute(MMHandleType hplayer, int mute)
+_mmplayer_get_volume(MMHandleType hplayer, float *volume)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
- GstElement *vol_element = NULL;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+ MMPLAYER_RETURN_VAL_IF_FAIL(volume, MM_ERROR_INVALID_ARGUMENT);
- /* mute value shoud 0 or 1 */
- if (mute != 0 && mute != 1) {
- LOGE("bad mute value");
+ *volume = player->sound.volume;
- /* FIXIT : definitly, we need _BAD_PARAM error code */
- return MM_ERROR_INVALID_ARGUMENT;
- }
+ LOGD("current vol = %f", *volume);
- player->sound.mute = mute;
+ MMPLAYER_FLEAVE();
+ return MM_ERROR_NONE;
+}
- /* just hold mute value if pipeline is not ready */
- if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("pipeline is not ready. holding mute value");
- return MM_ERROR_NONE;
- }
+int
+_mmplayer_set_mute(MMHandleType hplayer, bool mute)
+{
+ int ret = MM_ERROR_NONE;
+ mmplayer_t *player = (mmplayer_t *)hplayer;
- vol_element = player->pipeline->audiobin[MMPLAYER_A_VOL].gst;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- /* NOTE : volume will only created when the bt is enabled */
- if (vol_element) {
- LOGD("mute : %d", mute);
- g_object_set(vol_element, "mute", mute, NULL);
- } else
- LOGD("volume elemnet is not created. using volume in audiosink");
+ LOGD("mute = %d", mute);
- MMPLAYER_FLEAVE();
+ player->sound.mute = mute;
- return MM_ERROR_NONE;
+ ret = __mmplayer_gst_set_volume_property(player, "mute");
+
+ MMPLAYER_FLEAVE();
+ return ret;
}
int
-_mmplayer_get_mute(MMHandleType hplayer, int *pmute)
+_mmplayer_get_mute(MMHandleType hplayer, bool *mute)
{
mmplayer_t *player = (mmplayer_t *)hplayer;
MMPLAYER_FENTER();
MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
- MMPLAYER_RETURN_VAL_IF_FAIL(pmute, MM_ERROR_INVALID_ARGUMENT);
+ MMPLAYER_RETURN_VAL_IF_FAIL(mute, MM_ERROR_INVALID_ARGUMENT);
- /* just hold mute value if pipeline is not ready */
- if (!player->pipeline || !player->pipeline->audiobin) {
- LOGD("pipeline is not ready. returning stored value");
- *pmute = player->sound.mute;
- return MM_ERROR_NONE;
- }
+ *mute = player->sound.mute;
- *pmute = player->sound.mute;
+ LOGD("current mute = %d", *mute);
MMPLAYER_FLEAVE();
mmplayer_t *player = (mmplayer_t *)hplayer;
gint64 pos_nsec = 0;
int ret = MM_ERROR_NONE;
- int mute = FALSE;
+ bool mute = false;
signed long long start = 0, stop = 0;
mmplayer_state_e current_state = MM_PLAYER_STATE_NONE;
MMPLAYER_FENTER();
/* The sound of video is not supported under 0.0 and over 2.0. */
if (rate >= TRICK_PLAY_MUTE_THRESHOLD_MAX || rate < TRICK_PLAY_MUTE_THRESHOLD_MIN) {
if (player->can_support_codec & FOUND_PLUGIN_VIDEO)
- mute = TRUE;
+ mute = true;
}
_mmplayer_set_mute(hplayer, mute);