Commit 82744463 authored by Ilkka Ollakka's avatar Ilkka Ollakka Committed by Jean-Paul Saman

Remove audio-es/video-es callbacks and replace it with a better solution by...

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: default avatarJean-Paul Saman <jpsaman@videolan.org>
parent ac08060e
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
#include "input_manager.hpp" #include "input_manager.hpp"
#include "dialogs_provider.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, static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param ); vlc_value_t n, void *param );
static int ItemChanged( vlc_object_t *, const char *, static int ItemChanged( vlc_object_t *, const char *,
...@@ -62,8 +58,6 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) : ...@@ -62,8 +58,6 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf ) QObject( parent ), p_intf( _p_intf )
{ {
i_old_playing_status = END_S; 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 = ""; old_name = "";
artUrl = ""; artUrl = "";
p_input = NULL; p_input = NULL;
...@@ -83,15 +77,14 @@ void InputManager::setInput( input_thread_t *_p_input ) ...@@ -83,15 +77,14 @@ void InputManager::setInput( input_thread_t *_p_input )
{ {
delInput(); delInput();
p_input = _p_input; 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 ) ) if( p_input && !( p_input->b_dead || p_input->b_die ) )
{ {
vlc_object_yield( p_input ); vlc_object_yield( p_input );
emit statusChanged( PLAYING_S ); emit statusChanged( PLAYING_S );
UpdateMeta(); UpdateMeta();
UpdateTracks();
UpdateNavigation(); UpdateNavigation();
UpdateArt(); UpdateArt();
UpdateSPU();
addCallbacks(); addCallbacks();
i_input_id = input_GetItem( p_input )->i_id; i_input_id = input_GetItem( p_input )->i_id;
} }
...@@ -123,6 +116,7 @@ void InputManager::delInput() ...@@ -123,6 +116,7 @@ void InputManager::delInput()
emit rateChanged( INPUT_RATE_DEFAULT ); emit rateChanged( INPUT_RATE_DEFAULT );
vlc_object_release( p_input ); vlc_object_release( p_input );
p_input = NULL; p_input = NULL;
UpdateSPU();
} }
} }
...@@ -130,7 +124,6 @@ void InputManager::delInput() ...@@ -130,7 +124,6 @@ void InputManager::delInput()
void InputManager::addCallbacks() void InputManager::addCallbacks()
{ {
/* We don't care about: /* We don't care about:
- spu-es
- chapter - chapter
- programs - programs
- audio-delay - audio-delay
...@@ -140,10 +133,6 @@ void InputManager::addCallbacks() ...@@ -140,10 +133,6 @@ void InputManager::addCallbacks()
*/ */
/* src/input/input.c:1629 */ /* src/input/input.c:1629 */
var_AddCallback( p_input, "state", ItemStateChanged, this ); 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 */ /* src/input/es-out.c:552 */
var_AddCallback( p_input, "spu-es", ChangeSPU, this ); var_AddCallback( p_input, "spu-es", ChangeSPU, this );
/* src/input/input.c:1765 */ /* src/input/input.c:1765 */
...@@ -158,8 +147,6 @@ void InputManager::addCallbacks() ...@@ -158,8 +147,6 @@ void InputManager::addCallbacks()
void InputManager::delCallbacks() void InputManager::delCallbacks()
{ {
var_DelCallback( p_input, "spu-es", ChangeSPU, this ); 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, "state", ItemStateChanged, this );
var_DelCallback( p_input, "rate-change", ItemRateChanged, this ); var_DelCallback( p_input, "rate-change", ItemRateChanged, this );
var_DelCallback( p_input, "title", ItemTitleChanged, this ); var_DelCallback( p_input, "title", ItemTitleChanged, this );
...@@ -176,6 +163,7 @@ void InputManager::customEvent( QEvent *event ) ...@@ -176,6 +163,7 @@ void InputManager::customEvent( QEvent *event )
type != ItemChanged_Type && type != ItemChanged_Type &&
type != ItemRateChanged_Type && type != ItemRateChanged_Type &&
type != ItemTitleChanged_Type && type != ItemTitleChanged_Type &&
type != ItemSpuChanged_Type &&
type != ItemStateChanged_Type ) type != ItemStateChanged_Type )
return; return;
...@@ -183,6 +171,7 @@ void InputManager::customEvent( QEvent *event ) ...@@ -183,6 +171,7 @@ void InputManager::customEvent( QEvent *event )
if( ( type != PositionUpdate_Type && if( ( type != PositionUpdate_Type &&
type != ItemRateChanged_Type && type != ItemRateChanged_Type &&
type != ItemSpuChanged_Type &&
type != ItemStateChanged_Type type != ItemStateChanged_Type
) )
&& ( i_input_id != ple->i_id ) ) && ( i_input_id != ple->i_id ) )
...@@ -200,7 +189,6 @@ void InputManager::customEvent( QEvent *event ) ...@@ -200,7 +189,6 @@ void InputManager::customEvent( QEvent *event )
case ItemChanged_Type: case ItemChanged_Type:
UpdateMeta(); UpdateMeta();
UpdateNavigation(); UpdateNavigation();
UpdateTracks();
UpdateStatus(); UpdateStatus();
UpdateArt(); UpdateArt();
break; break;
...@@ -212,8 +200,9 @@ void InputManager::customEvent( QEvent *event ) ...@@ -212,8 +200,9 @@ void InputManager::customEvent( QEvent *event )
UpdateMeta(); UpdateMeta();
break; break;
case ItemStateChanged_Type: case ItemStateChanged_Type:
UpdateTracks();
UpdateStatus(); UpdateStatus();
case ItemSpuChanged_Type:
UpdateSPU();
break; break;
} }
} }
...@@ -311,21 +300,46 @@ void InputManager::UpdateMeta() ...@@ -311,21 +300,46 @@ void InputManager::UpdateMeta()
} }
} }
void InputManager::UpdateTracks() bool InputManager::hasAudio()
{ {
/* Has Audio, has Video Tracks ? */ if( hasInput() )
{
vlc_value_t val; vlc_value_t val;
var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL ); var_Change( p_input, "audio-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
b_has_audio = val.i_int > 0; 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 ); var_Change( p_input, "video-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
b_has_video = val.i_int > 0; return val.i_int > 0;
var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &val, NULL ); }
b_has_subs = val.i_int > 0; return false;
/* Update ZVBI status */ }
void InputManager::UpdateSPU()
{
#ifdef ZVBI_COMPILED #ifdef ZVBI_COMPILED
if( hasInput() )
{
vlc_value_t val;
var_Change( p_input, "spu-es", VLC_VAR_CHOICESCOUNT, &val, NULL );
/* Update teletext status*/ /* Update teletext status*/
emit teletextEnabled( b_has_subs );/* FIXME */ emit teletextEnabled( val.i_int > 0 );/* FIXME */
telexToggle( true );
}
else
{
emit teletextEnabled( false );
telexToggle( false );
}
#endif #endif
} }
...@@ -650,31 +664,14 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var, ...@@ -650,31 +664,14 @@ static int ItemChanged( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS; 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, static int ChangeSPU( vlc_object_t *p_this, const char *var, vlc_value_t o,
vlc_value_t n, void *param ) vlc_value_t n, void *param )
{ {
InputManager *im = (InputManager*)param; InputManager *im = (InputManager*)param;
im->b_has_subs = true; IMEvent *event = new IMEvent( ItemSpuChanged_Type, 0 );
#ifdef ZVBI_COMPILED QApplication::postEvent( im, static_cast<QEvent*>(event) );
im->telexToggle( im->b_has_subs );
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/* MIM */ /* MIM */
......
...@@ -45,6 +45,7 @@ static int const VolumeChanged_Type = QEvent::User + IMEventType + 6; ...@@ -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 FullscreenControlShow_Type = QEvent::User + IMEventType + 7;
static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 8; static int const FullscreenControlHide_Type = QEvent::User + IMEventType + 8;
static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 9; static int const FullscreenControlPlanHide_Type = QEvent::User + IMEventType + 9;
static int const ItemSpuChanged_Type = QEvent::User + IMEventType + 10;
class IMEvent : public QEvent class IMEvent : public QEvent
{ {
...@@ -65,9 +66,8 @@ public: ...@@ -65,9 +66,8 @@ public:
void delInput(); void delInput();
bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; } bool hasInput() { return p_input && !p_input->b_dead && !p_input->b_die; }
bool hasAudio() { return b_has_audio; } bool hasAudio();
bool hasVideo() { return b_has_video; } bool hasVideo();
bool b_has_audio, b_has_video, b_had_audio, b_had_video, b_has_subs;
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
...@@ -86,7 +86,7 @@ private: ...@@ -86,7 +86,7 @@ private:
void UpdateStatus(); void UpdateStatus();
void UpdateNavigation(); void UpdateNavigation();
void UpdatePosition(); void UpdatePosition();
void UpdateTracks(); void UpdateSPU();
void UpdateArt(); void UpdateArt();
public slots: public slots:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment