[vlc-devel] commit: Remove audio-es/ video-es callbacks and replace it with a better solution by using directly vlc variables . Also change ChangeSPU to send event for customevent-handler in callback, and do the signal emiting in there so we don' t need to be in callback that long. (Ilkka Ollakka )
git version control
git at videolan.org
Fri Jun 20 09:51:17 CEST 2008
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Fri Jun 20 00:17:57 2008 +0300| [82744463caf51fafbab6a52215cb6d88e735aa1c]
Remove audio-es/video-es callbacks and replace it with a better solution by using directly vlc variables. Also change ChangeSPU to send event for customevent-handler in callback, and do the signal emiting in there so we don't need to be in callback that long.
Patch fixed up by me.
Signed-off-by: Jean-Paul Saman <jpsaman at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=82744463caf51fafbab6a52215cb6d88e735aa1c
---
modules/gui/qt4/input_manager.cpp | 95 ++++++++++++++++++-------------------
modules/gui/qt4/input_manager.hpp | 8 ++--
2 files changed, 50 insertions(+), 53 deletions(-)
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index f2dbd23..57774c4 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -30,10 +30,6 @@
#include "input_manager.hpp"
#include "dialogs_provider.hpp"
-static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
- vlc_value_t n, void *param );
-static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
- vlc_value_t n, void *param );
static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param );
static int ItemChanged( vlc_object_t *, const char *,
@@ -62,8 +58,6 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf )
{
i_old_playing_status = END_S;
- b_had_audio = b_had_video = b_has_audio = b_has_video = false;
- b_has_subs = false;
old_name = "";
artUrl = "";
p_input = NULL;
@@ -83,15 +77,14 @@ void InputManager::setInput( input_thread_t *_p_input )
{
delInput();
p_input = _p_input;
- b_had_audio = b_had_video = b_has_audio = b_has_video = false;
if( p_input && !( p_input->b_dead || p_input->b_die ) )
{
vlc_object_yield( p_input );
emit statusChanged( PLAYING_S );
UpdateMeta();
- UpdateTracks();
UpdateNavigation();
UpdateArt();
+ UpdateSPU();
addCallbacks();
i_input_id = input_GetItem( p_input )->i_id;
}
@@ -123,6 +116,7 @@ void InputManager::delInput()
emit rateChanged( INPUT_RATE_DEFAULT );
vlc_object_release( p_input );
p_input = NULL;
+ UpdateSPU();
}
}
@@ -130,7 +124,6 @@ void InputManager::delInput()
void InputManager::addCallbacks()
{
/* We don't care about:
- - spu-es
- chapter
- programs
- audio-delay
@@ -140,10 +133,6 @@ void InputManager::addCallbacks()
*/
/* src/input/input.c:1629 */
var_AddCallback( p_input, "state", ItemStateChanged, this );
- /* src/input/es-out.c:550 */
- var_AddCallback( p_input, "audio-es", ChangeAudio, this );
- /* src/input/es-out.c:551 */
- var_AddCallback( p_input, "video-es", ChangeVideo, this );
/* src/input/es-out.c:552 */
var_AddCallback( p_input, "spu-es", ChangeSPU, this );
/* src/input/input.c:1765 */
@@ -158,8 +147,6 @@ void InputManager::addCallbacks()
void InputManager::delCallbacks()
{
var_DelCallback( p_input, "spu-es", ChangeSPU, this );
- var_DelCallback( p_input, "audio-es", ChangeAudio, this );
- var_DelCallback( p_input, "video-es", ChangeVideo, this );
var_DelCallback( p_input, "state", ItemStateChanged, this );
var_DelCallback( p_input, "rate-change", ItemRateChanged, this );
var_DelCallback( p_input, "title", ItemTitleChanged, this );
@@ -176,6 +163,7 @@ void InputManager::customEvent( QEvent *event )
type != ItemChanged_Type &&
type != ItemRateChanged_Type &&
type != ItemTitleChanged_Type &&
+ type != ItemSpuChanged_Type &&
type != ItemStateChanged_Type )
return;
@@ -183,6 +171,7 @@ void InputManager::customEvent( QEvent *event )
if( ( type != PositionUpdate_Type &&
type != ItemRateChanged_Type &&
+ type != ItemSpuChanged_Type &&
type != ItemStateChanged_Type
)
&& ( i_input_id != ple->i_id ) )
@@ -200,7 +189,6 @@ void InputManager::customEvent( QEvent *event )
case ItemChanged_Type:
UpdateMeta();
UpdateNavigation();
- UpdateTracks();
UpdateStatus();
UpdateArt();
break;
@@ -212,8 +200,9 @@ void InputManager::customEvent( QEvent *event )
UpdateMeta();
break;
case ItemStateChanged_Type:
- UpdateTracks();
UpdateStatus();
+ case ItemSpuChanged_Type:
+ UpdateSPU();
break;
}
}
@@ -311,21 +300,46 @@ void InputManager::UpdateMeta()
}
}
-void InputManager::UpdateTracks()
+bool InputManager::hasAudio()
{
- /* Has Audio, has Video Tracks ? */
- vlc_value_t val;
- var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
- b_has_audio = val.i_int > 0;
- var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
- b_has_video = val.i_int > 0;
- var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
- b_has_subs = val.i_int > 0;
+ if( hasInput() )
+ {
+ vlc_value_t val;
+ var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
+ return val.i_int > 0;
+ }
+ return false;
+}
+
+bool InputManager::hasVideo()
+{
+ if( hasInput() )
+ {
+ vlc_value_t val;
+ var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
+ return val.i_int > 0;
+ }
+ return false;
- /* Update ZVBI status */
+}
+
+void InputManager::UpdateSPU()
+{
#ifdef ZVBI_COMPILED
- /* Update teletext status*/
- emit teletextEnabled( b_has_subs );/* FIXME */
+ if( hasInput() )
+ {
+ vlc_value_t val;
+ var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
+
+ /* Update teletext status*/
+ emit teletextEnabled( val.i_int > 0 );/* FIXME */
+ telexToggle( true );
+ }
+ else
+ {
+ emit teletextEnabled( false );
+ telexToggle( false );
+ }
#endif
}
@@ -650,31 +664,14 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS;
}
-static int ChangeAudio( vlc_object_t *p_this, const char *var, vlc_value_t o,
- vlc_value_t n, void *param )
-{
- InputManager *im = (InputManager*)param;
- im->b_has_audio = true;
- return VLC_SUCCESS;
-}
-
-static int ChangeVideo( vlc_object_t *p_this, const char *var, vlc_value_t o,
- vlc_value_t n, void *param )
-{
- InputManager *im = (InputManager*)param;
- im->b_has_video = true;
- return VLC_SUCCESS;
-}
-
static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param )
{
InputManager *im = (InputManager*)param;
- im->b_has_subs = true;
-#ifdef ZVBI_COMPILED
- im->telexToggle( im->b_has_subs );
-#endif
+ IMEvent *event = new IMEvent( ItemSpuChanged_Type, 0 );
+ QApplication::postEvent( im, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
+
}
/* MIM */
diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp
index 07a2126..3c4f351 100644
--- a/modules/gui/qt4/input_manager.hpp
+++ b/modules/gui/qt4/input_manager.hpp
@@ -45,6 +45,7 @@ static int const VolumeChanged_Type = QEvent::User + IMEventType + 6;
static int const FullscreenControlShow_Type = QEvent::User + IMEventType + 7;
static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 8;
static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 9;
+static int const ItemSpuChanged_Type = QEvent::User + IMEventType + 10;
class IMEvent : public QEvent
{
@@ -65,9 +66,8 @@ public:
void delInput();
bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
- bool hasAudio() { return b_has_audio; }
- bool hasVideo() { return b_has_video; }
- bool b_has_audio, b_has_video, b_had_audio, b_had_video, b_has_subs;
+ bool hasAudio();
+ bool hasVideo();
private:
intf_thread_t *p_intf;
@@ -86,7 +86,7 @@ private:
void UpdateStatus();
void UpdateNavigation();
void UpdatePosition();
- void UpdateTracks();
+ void UpdateSPU();
void UpdateArt();
public slots:
More information about the vlc-devel
mailing list