Commit 197dcf82 authored by Clément Stenac's avatar Clément Stenac

Preliminary work for better audio visualization handling

parent c9f5dbcf
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "components/video_widget.hpp" #include "components/video_widget.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include "input_manager.hpp"
#include <QHBoxLayout> #include <QHBoxLayout>
#define ICON_SIZE 128 #define ICON_SIZE 128
...@@ -57,6 +58,10 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i, bool _always ) : QFrame( NULL ), ...@@ -57,6 +58,10 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i, bool _always ) : QFrame( NULL ),
if( always ) if( always )
{ {
DrawBackground(); DrawBackground();
connect( THEMIM->getIM(), SIGNAL( audioStarted() ),
this, SLOT( hasAudio() ) );
connect( THEMIM->getIM(), SIGNAL( audioStarted() ),
this, SLOT( hasVideo() ) );
} }
need_update = false; need_update = false;
} }
...@@ -117,6 +122,19 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y, ...@@ -117,6 +122,19 @@ void *VideoWidget::Request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
} }
p_vout = p_nvout; p_vout = p_nvout;
// if( THEMIM->getIM()->b_has_video )
// {
// We are really running a video
// Close the existing vout
// Set visual to disabled
// }
// else
// {
// We are getting a request for visual
// Just go on.
// }
// Check THEMIM->b_has_audio. If true, hide audio.
setMinimumSize( 1,1 ); setMinimumSize( 1,1 );
p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height ); p_intf->p_sys->p_mi->videoSize = QSize( *pi_width, *pi_height );
updateGeometry(); updateGeometry();
...@@ -149,6 +167,25 @@ void VideoWidget::Release( void *p_win ) ...@@ -149,6 +167,25 @@ void VideoWidget::Release( void *p_win )
} }
} }
void VideoWidget::hasAudio()
{
/* We have video already, do nothing */
if( THEMIM->getIM()->b_has_video )
{
}
else
{
/* Show the panel to the user */
fprintf( stderr, "Showing panel\n" );
}
}
void VideoWidget::hasVideo()
{
// if panel is shown, hide it
}
static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a ) static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
{ {
return p_intf->p_sys->p_video->Control( p_win, i_q, a ); return p_intf->p_sys->p_video->Control( p_win, i_q, a );
......
...@@ -64,6 +64,8 @@ private: ...@@ -64,6 +64,8 @@ private:
vlc_mutex_t lock; vlc_mutex_t lock;
private slots: private slots:
void update(); void update();
void hasAudio();
void hasVideo();
}; };
#endif #endif
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "qt4.hpp" #include "qt4.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 );
/********************************************************************** /**********************************************************************
* InputManager implementation * InputManager implementation
**********************************************************************/ **********************************************************************/
...@@ -48,6 +53,21 @@ void InputManager::setInput( input_thread_t *_p_input ) ...@@ -48,6 +53,21 @@ void InputManager::setInput( input_thread_t *_p_input )
{ {
p_input = _p_input; p_input = _p_input;
emit positionUpdated( 0.0,0,0 ); emit positionUpdated( 0.0,0,0 );
b_had_audio = b_had_video = b_has_audio = b_has_video = false;
if( p_input )
{
var_AddCallback( p_input, "audio-es", ChangeAudio, this );
var_AddCallback( p_input, "video-es", ChangeVideo, this );
}
}
void InputManager::delInput()
{
if( p_input )
{
var_DelCallback( p_input, "audio-es", ChangeAudio, this );
var_DelCallback( p_input, "video-es", ChangeVideo, this );
}
} }
void InputManager::update() void InputManager::update()
...@@ -62,6 +82,11 @@ void InputManager::update() ...@@ -62,6 +82,11 @@ void InputManager::update()
emit statusChanged( 0 ); // 0 = STOPPED, 1 = PLAY, 2 = PAUSE emit statusChanged( 0 ); // 0 = STOPPED, 1 = PLAY, 2 = PAUSE
} }
if( !b_had_audio && b_has_audio )
emit audioStarted();
if( !b_had_video && b_has_video )
emit videoStarted();
/* Update position */ /* Update position */
mtime_t i_length, i_time; mtime_t i_length, i_time;
float f_pos; float f_pos;
...@@ -78,7 +103,7 @@ void InputManager::update() ...@@ -78,7 +103,7 @@ void InputManager::update()
vlc_value_t val; vlc_value_t val;
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL ); var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
if( val.i_int > 0 ) if( val.i_int > 0 )
emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 3 = NO emit navigationChanged( 1 ); // 1 = chapter, 2 = title, 0 = NO
else else
emit navigationChanged( 2 ); emit navigationChanged( 2 );
} }
...@@ -167,6 +192,7 @@ void MainInputManager::updateInput() ...@@ -167,6 +192,7 @@ void MainInputManager::updateInput()
if( p_input && p_input->b_dead ) if( p_input && p_input->b_dead )
{ {
vlc_object_release( p_input ); vlc_object_release( p_input );
getIM()->delInput();
p_input = NULL; p_input = NULL;
emit inputChanged( NULL ); emit inputChanged( NULL );
} }
...@@ -198,3 +224,17 @@ void MainInputManager::togglePlayPause() ...@@ -198,3 +224,17 @@ void MainInputManager::togglePlayPause()
} }
getIM()->togglePlayPause(); getIM()->togglePlayPause();
} }
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;
}
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;
}
...@@ -34,6 +34,8 @@ public: ...@@ -34,6 +34,8 @@ public:
InputManager( QObject *, intf_thread_t *); InputManager( QObject *, intf_thread_t *);
virtual ~InputManager(); virtual ~InputManager();
void delInput();
bool b_has_audio, b_has_video, b_had_audio, b_had_video;
private: private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
input_thread_t *p_input; input_thread_t *p_input;
...@@ -50,6 +52,8 @@ signals: ...@@ -50,6 +52,8 @@ signals:
void nameChanged( QString ); void nameChanged( QString );
void navigationChanged( int ); void navigationChanged( int );
void statusChanged( int ); void statusChanged( int );
void audioStarted();
void videoStarted();
}; };
class MainInputManager : public QObject class MainInputManager : public QObject
......
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