<div dir="ltr" class="gmail_msg">Hi,</div><span>
</span><p dir="ltr" class="gmail_msg">Thank you for the review. Today I'll fix it and send it merged with my old package and correct the remaining code duplication. </p><p dir="ltr" class="gmail_msg">Best regards,</p><p dir="ltr" class="gmail_msg"><span style="font-size:13px">Andrei</span></p><span>
</span><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Mon, 27 Feb 2017, 07:49 Filip Roséen, <<a href="mailto:filip@atch.se" class="gmail_msg" target="_blank">filip@atch.se</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex" id="gmail_block_quote0"><u class="gmail_msg"></u>
<div class="gmail_msg">
<p class="gmail_msg">Hi Andrei,</p>
<p class="gmail_msg">Please see the <a href="https://mailman.videolan.org/pipermail/vlc-devel/2017-February/111777.html" class="gmail_msg" target="_blank">comment expressed by <em class="gmail_msg">Jean-Baptiste Kempf</em></a>, and keep in mind that I expressed the exact same thing earlier.</p>
<p class="gmail_msg">In either case, you are still suffering from code-duplication - I would advise you to introduce variables holding the information that differs between the two implementations; there is no need to have the same function called in two places, only with statically different arguments.</p>
<p class="gmail_msg">In other words, in order to avoid code-duplication one can simply replace usage of <code class="gmail_msg">"audio-es"</code> and <code class="gmail_msg">"video-es"</code> with a variable that is conditionally initialized to refer to one of the strings (and the same goes for other entities).</p>
<p class="gmail_msg">Best Regards,<br class="gmail_msg">
Filip</p></div><div class="gmail_msg">
<p class="gmail_msg">On 2017-02-27 04:06, Andrei Ciurea wrote:</p>
</div><div class="gmail_msg"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050" class="gmail_msg"><pre class="gmail_msg"><code class="gmail_msg"> ---
modules/control/hotkeys.c | 60 ++++++++++++++++-------------------------------
1 file changed, 20 insertions(+), 40 deletions(-)
diff --git a/modules/control/hotkeys.c b/modules/control/hotkeys.c
index 2c25d0c..d1b5727 100644
--- a/modules/control/hotkeys.c
+++ b/modules/control/hotkeys.c
@@ -700,17 +700,26 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
}
break;
}
-
+ case ACTIONID_VIDEO_TRACK:
case ACTIONID_AUDIO_TRACK:
- if( p_input )
+ if( p_input )
{
vlc_value_t val, list, list2;
int i_count, i;
+
+ if(i_action == ACTIONID_VIDEO_TRACK){
+ var_Get( p_input, "video-es", &val );
+ var_Change( p_input, "video-es", VLC_VAR_GETCHOICES,
+ &list, &list2 );
+
+ }
+ else{
var_Get( p_input, "audio-es", &val );
var_Change( p_input, "audio-es", VLC_VAR_GETCHOICES,
&list, &list2 );
+ }
i_count = list.p_list->i_count;
- if( i_count > 1 )
+ if( (i_count = list.p_list->i_count) > 1 )
{
for( i = 0; i < i_count; i++ )
{
@@ -719,7 +728,7 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
break;
}
}
- /* value of audio-es was not in choices list */
+ /* value of audio-es / video-es was not in choices list */
if( i == i_count )
{
msg_Warn( p_input,
@@ -730,49 +739,20 @@ static int PutAction( intf_thread_t *p_intf, input_thread_t *p_input,
i = 1;
else
i++;
+ if(i_action == ACTIONID_VIDEO_TRACK){
+ var_Set( p_input, "video-es", list.p_list->p_values[i] );
+ DisplayMessage( p_vout, _("Video track: %s"),
+ list2.p_list->p_values[i].psz_string );
+ }
+ else{
var_Set( p_input, "audio-es", list.p_list->p_values[i] );
DisplayMessage( p_vout, _("Audio track: %s"),
list2.p_list->p_values[i].psz_string );
}
- var_FreeList( &list, &list2 );
- }
- break;
- case ACTIONID_VIDEO_TRACK:
- if( p_input )
- {
- vlc_value_t val, list, list2;
- int i_count, i;
- var_Get( p_input, "video-es", &val );
- var_Change( p_input, "video-es", VLC_VAR_GETCHOICES,
- &list, &list2 );
-
- if( (i_count = list.p_list->i_count) > 1 )
- {
- for( i = 0; i < i_count; i++ )
- {
- if( val.i_int == list.p_list->p_values[i].i_int )
- {
- break;
- }
- }
- /* value of video-es was not in choices list */
- if( i == i_count )
- {
- msg_Warn( p_input,
- "invalid current video track, selecting 0" );
- i = 0;
- }
- else if( i == i_count - 1 )
- i = 1;
- else
- i++;
- var_Set( p_input, "video-es", list.p_list->p_values[i] );
- DisplayMessage( p_vout, _("Video track: %s"),
- list2.p_list->p_values[i].psz_</code></pre></blockquote></div><div class="gmail_msg"><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050" class="gmail_msg"><pre class="gmail_msg"><code class="gmail_msg">string );
}
var_FreeList( &list, &list2 );
}
- break;
+ break;
case ACTIONID_SUBTITLE_TRACK:
if( p_input )
{
--
2.10.2
_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
<a href="https://mailman.videolan.org/listinfo/vlc-devel" class="gmail_msg" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></code></pre>
</blockquote>
</div>
_______________________________________________<br class="gmail_msg">
vlc-devel mailing list<br class="gmail_msg">
To unsubscribe or modify your subscription options:<br class="gmail_msg">
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" class="gmail_msg" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></blockquote></div>