[MPlayer-cvslog] r30124 - trunk/command.c

reimar subversion at mplayerhq.hu
Sun Dec 27 15:13:06 CET 2009


Author: reimar
Date: Sun Dec 27 15:13:06 2009
New Revision: 30124

Log:
Return the actually playing audio/video id for get_property, not the one
selected e.g. via commandline (which resulted in -1 being returned most of
the time).

Modified:
   trunk/command.c

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Sun Dec 27 15:09:38 2009	(r30123)
+++ trunk/command.c	Sun Dec 27 15:13:06 2009	(r30124)
@@ -795,21 +795,22 @@ static int mp_property_balance(m_option_
 static int mp_property_audio(m_option_t * prop, int action, void *arg,
 			     MPContext * mpctx)
 {
-    int current_id = -1, tmp;
+    int current_id, tmp;
     if (!mpctx->demuxer || !mpctx->demuxer->audio)
         return M_PROPERTY_UNAVAILABLE;
+    current_id = mpctx->demuxer->audio->id;
 
     switch (action) {
     case M_PROPERTY_GET:
 	if (!arg)
 	    return M_PROPERTY_ERROR;
-	*(int *) arg = audio_id;
+	*(int *) arg = current_id;
 	return M_PROPERTY_OK;
     case M_PROPERTY_PRINT:
 	if (!arg)
 	    return M_PROPERTY_ERROR;
 
-	if (audio_id < 0)
+	if (current_id < 0)
 	    *(char **) arg = strdup(MSGTR_Disabled);
 	else {
 	    char lang[40] = MSGTR_Unknown;
@@ -818,7 +819,7 @@ static int mp_property_audio(m_option_t 
                 av_strlcpy(lang, sh->lang, 40);
 #ifdef CONFIG_DVDREAD
 	    else if (mpctx->stream->type == STREAMTYPE_DVD) {
-		int code = dvd_lang_from_aid(mpctx->stream, audio_id);
+		int code = dvd_lang_from_aid(mpctx->stream, current_id);
 		if (code) {
 		    lang[0] = code >> 8;
 		    lang[1] = code;
@@ -829,10 +830,10 @@ static int mp_property_audio(m_option_t 
 
 #ifdef CONFIG_DVDNAV
 	    else if (mpctx->stream->type == STREAMTYPE_DVDNAV)
-		mp_dvdnav_lang_from_aid(mpctx->stream, audio_id, lang);
+		mp_dvdnav_lang_from_aid(mpctx->stream, current_id, lang);
 #endif
 	    *(char **) arg = malloc(64);
-	    snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang);
+	    snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang);
 	}
 	return M_PROPERTY_OK;
 
@@ -842,7 +843,6 @@ static int mp_property_audio(m_option_t 
 	    tmp = *((int *) arg);
 	else
 	    tmp = -1;
-	current_id = mpctx->demuxer->audio->id;
 	audio_id = demuxer_switch_audio(mpctx->demuxer, tmp);
 	if (audio_id == -2
 	    || (audio_id > -1
@@ -869,26 +869,27 @@ static int mp_property_audio(m_option_t 
 static int mp_property_video(m_option_t * prop, int action, void *arg,
 			     MPContext * mpctx)
 {
-    int current_id = -1, tmp;
+    int current_id, tmp;
     if (!mpctx->demuxer || !mpctx->demuxer->video)
         return M_PROPERTY_UNAVAILABLE;
+    current_id = mpctx->demuxer->video->id;
 
     switch (action) {
     case M_PROPERTY_GET:
 	if (!arg)
 	    return M_PROPERTY_ERROR;
-	*(int *) arg = video_id;
+	*(int *) arg = current_id;
 	return M_PROPERTY_OK;
     case M_PROPERTY_PRINT:
 	if (!arg)
 	    return M_PROPERTY_ERROR;
 
-	if (video_id < 0)
+	if (current_id < 0)
 	    *(char **) arg = strdup(MSGTR_Disabled);
 	else {
 	    char lang[40] = MSGTR_Unknown;
 	    *(char **) arg = malloc(64);
-	    snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang);
+	    snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang);
 	}
 	return M_PROPERTY_OK;
 
@@ -898,7 +899,6 @@ static int mp_property_video(m_option_t 
 	    tmp = *((int *) arg);
 	else
 	    tmp = -1;
-	current_id = mpctx->demuxer->video->id;
 	video_id = demuxer_switch_video(mpctx->demuxer, tmp);
 	if (video_id == -2
 	    || (video_id > -1 && mpctx->demuxer->video->id != current_id


More information about the MPlayer-cvslog mailing list