]> git.sesse.net Git - vlc/blobdiff - modules/demux/mkv/demux.cpp
Removed one vlc_object_find(INPUT, PARENT) in mkv.
[vlc] / modules / demux / mkv / demux.cpp
index 87e5b340ee31cd1484a09f1d04f0e1342263741a..76049f49728e97764bc0e297e2d70df844a27d14 100644 (file)
@@ -51,7 +51,6 @@ demux_sys_t::~demux_sys_t()
 matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial )
 {
     int i_upper_lvl = 0;
-    size_t i;
     EbmlElement *p_l0, *p_l1, *p_l2;
     bool b_keep_stream = false, b_keep_segment;
 
@@ -67,7 +66,7 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
     p_l0->Read(*p_estream, EbmlHead::ClassInfos.Context, i_upper_lvl, p_l0, true);
 
     EDocType doc_type = GetChild<EDocType>(*static_cast<EbmlHead*>(p_l0));
-    if (std::string(doc_type) != "matroska")
+    if (std::string(doc_type) != "matroska" && std::string(doc_type) != "webm" )
     {
         msg_Err( p_demux, "Not a Matroska file : DocType = %s ", std::string(doc_type).c_str());
         return NULL;
@@ -112,7 +111,7 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
                     KaxInfo *p_info = static_cast<KaxInfo*>(p_l1);
 
                     p_info->Read(*p_estream, KaxInfo::ClassInfos.Context, i_upper_lvl, p_l2, true);
-                    for( i = 0; i < p_info->ListSize(); i++ )
+                    for( size_t i = 0; i < p_info->ListSize(); i++ )
                     {
                         EbmlElement *l = (*p_info)[i];
 
@@ -160,7 +159,9 @@ matroska_stream_c *demux_sys_t::AnalyseAllSegmentsFound( demux_t *p_demux, EbmlS
             p_l0 = p_estream->FindNextID(KaxSegment::ClassInfos, 0xFFFFFFFFL);
         }
         else
-            p_l0 = p_l0->SkipData(*p_estream, KaxSegment_Context);
+        {
+            p_l0 = NULL;
+        }
     }
 
     if ( !b_keep_stream )
@@ -180,7 +181,7 @@ void demux_sys_t::StartUiThread()
         b_ui_hooked = true;
         /* FIXME hack hack hack hack FIXME */
         /* Get p_input and create variable */
-        p_input = (input_thread_t *) vlc_object_find( &demuxer, VLC_OBJECT_INPUT, FIND_PARENT );
+        p_input = demux_GetParentInput( &demuxer );
         var_Create( p_input, "x-start", VLC_VAR_INTEGER );
         var_Create( p_input, "y-start", VLC_VAR_INTEGER );
         var_Create( p_input, "x-end", VLC_VAR_INTEGER );
@@ -196,7 +197,7 @@ void demux_sys_t::StartUiThread()
         p_ev->b_die = false;
         vlc_mutex_init( &p_ev->lock );
         vlc_thread_create( p_ev, "mkv event thread handler", EventThread,
-                        VLC_THREAD_PRIORITY_LOW, false );
+                        VLC_THREAD_PRIORITY_LOW );
     }
 }
 
@@ -284,8 +285,6 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
         /* KEY part */
         if( p_ev->i_key_action )
         {
-            int i;
-
             msg_Dbg( p_ev->p_demux, "Handle Key Event");
 
             vlc_mutex_lock( &p_ev->lock );
@@ -415,12 +414,11 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
         /* MOUSE part */
         if( p_vout && ( p_ev->b_moved || p_ev->b_clicked ) )
         {
-            vlc_value_t valx, valy;
+            int x, y;
 
+            var_GetCoords( p_vout, "mouse-moved", &x, &y );
             vlc_mutex_lock( &p_ev->lock );
             pci_t *pci = (pci_t *) &p_sys->pci_packet;
-            var_Get( p_vout, "mouse-x", &valx );
-            var_Get( p_vout, "mouse-y", &valy );
 
             if( p_ev->b_clicked )
             {
@@ -428,7 +426,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
                 int32_t best,dist,d;
                 int32_t mx,my,dx,dy;
 
-                msg_Dbg( p_ev->p_demux, "Handle Mouse Event: Mouse clicked x(%d)*y(%d)", (unsigned)valx.i_int, (unsigned)valy.i_int);
+                msg_Dbg( p_ev->p_demux, "Handle Mouse Event: Mouse clicked x(%d)*y(%d)", x, y);
 
                 b_activated = true;
                 // get current button
@@ -438,15 +436,15 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
                 {
                     btni_t *button_ptr = &(pci->hli.btnit[button-1]);
 
-                    if(((unsigned)valx.i_int >= button_ptr->x_start)
-                     && ((unsigned)valx.i_int <= button_ptr->x_end)
-                     && ((unsigned)valy.i_int >= button_ptr->y_start)
-                     && ((unsigned)valy.i_int <= button_ptr->y_end))
+                    if(((unsigned)x >= button_ptr->x_start)
+                     && ((unsigned)x <= button_ptr->x_end)
+                     && ((unsigned)y >= button_ptr->y_start)
+                     && ((unsigned)y <= button_ptr->y_end))
                     {
                         mx = (button_ptr->x_start + button_ptr->x_end)/2;
                         my = (button_ptr->y_start + button_ptr->y_end)/2;
-                        dx = mx - valx.i_int;
-                        dy = my - valy.i_int;
+                        dx = mx - x;
+                        dy = my - y;
                         d = (dx*dx) + (dy*dy);
                         /* If the mouse is within the button and the mouse is closer
                         * to the center of this button then it is the best choice. */
@@ -519,7 +517,7 @@ void * demux_sys_t::EventThread( vlc_object_t *p_this )
             }
             else if( p_ev->b_moved )
             {
-//                dvdnav_mouse_select( NULL, pci, valx.i_int, valy.i_int );
+//                dvdnav_mouse_select( NULL, pci, x, y );
             }
 
             p_ev->b_moved = false;
@@ -604,7 +602,6 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
         p_seg = used_segments[i];
         if ( p_seg->p_editions != NULL )
         {
-            std::string sz_name;
             input_title_t *p_title = vlc_input_title_New();
             p_seg->i_sys_title = i;
             int i_chapters;
@@ -614,9 +611,9 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
             {
                 if ( p_title->psz_name == NULL )
                 {
-                    sz_name = (*p_seg->p_editions)[j]->GetMainName();
-                    if ( sz_name != "" )
-                        p_title->psz_name = strdup( sz_name.c_str() );
+                    const char* psz_tmp = (*p_seg->p_editions)[j]->GetMainName().c_str();
+                    if( *psz_tmp != '\0' )
+                        p_title->psz_name = strdup( psz_tmp );
                 }
 
                 chapter_edition_c *p_edition = (*p_seg->p_editions)[j];
@@ -628,11 +625,8 @@ void demux_sys_t::PreloadLinked( matroska_segment_c *p_segment )
             // create a name if there is none
             if ( p_title->psz_name == NULL )
             {
-                sz_name = N_("Segment");
-                char psz_str[6];
-                sprintf( psz_str, " %d", (int)i );
-                sz_name += psz_str;
-                p_title->psz_name = strdup( sz_name.c_str() );
+                if( asprintf(&(p_title->psz_name), "%s %d", N_("Segment"), (int)i) == -1 )
+                    p_title->psz_name = NULL;
             }
 
             titles.push_back( p_title );