]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwidgets/dialogs/wizard.cpp
Use pl_Locked and pl_Unlocked.
[vlc] / modules / gui / wxwidgets / dialogs / wizard.cpp
index 19171b1ef144ed5a4d69726fa7d399cf0389c014..07f559dd5a2bc10b166080a529de5aed09647812 100644 (file)
@@ -30,8 +30,8 @@
 
 #include <wx/listctrl.h>
 #include <wx/statline.h>
-#include <network.h>
-#include <charset.h>
+#include <vlc_network.h>
+#include <vlc_charset.h>
 
 class wizHelloPage;
 class wizInputPage;
@@ -208,7 +208,7 @@ class wizInputPage : public wxWizardPage
 {
     public:
         wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);
-        wizInputPage::~wizInputPage();
+        ~wizInputPage();
         void OnWizardPageChanging(wxWizardEvent& event);
         void OnInputChange( wxCommandEvent& event );
         void OnEnablePartial(wxCommandEvent& event);
@@ -262,7 +262,7 @@ class wizTranscodeCodecPage : public wxWizardPage
 public:
     wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);
     ~wizTranscodeCodecPage();
-    void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);
+    void OnWizardPageChanging(wxWizardEvent& event);
     virtual wxWizardPage *GetPrev() const;
     virtual wxWizardPage *GetNext() const;
     void SetPrev( wxWizardPage *page);
@@ -339,7 +339,7 @@ class wizEncapPage : public wxWizardPage
 {
 public:
     wizEncapPage( wxWizard *parent);
-    wizEncapPage::~wizEncapPage();
+    ~wizEncapPage();
     void OnWizardPageChanging(wxWizardEvent& event);
     virtual wxWizardPage *GetPrev() const;
     virtual wxWizardPage *GetNext() const;
@@ -387,7 +387,7 @@ public:
     void OnWizardPageChanging( wxWizardEvent& event );
 protected:
     DECLARE_EVENT_TABLE()
-    void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);
+    void OnSelectFile(wxCommandEvent&);
     wxTextCtrl *file_text;
     WizardDialog *p_parent;
     wxWizardPage *p_prev;
@@ -550,7 +550,7 @@ wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t
                                wxU( INPUT_OPEN ) );
     radioSizer->Add( input_radios[0], 0, wxALL, 5 );
     input_radios[1] = new wxRadioButton( radio_panel, InputRadio1_Event ,
-                               wxU( INPUT_PL ) );  
+                               wxU( INPUT_PL ) );
     radioSizer->Add( input_radios[1], 0, wxALL, 5 );
 
     radio_panel->SetSizer( radioSizer );
@@ -577,9 +577,7 @@ wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t
     openSizer->Fit(open_panel);
     mainSizer->Add( open_panel );
 
-    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
-                                       VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-
+    playlist_t *p_playlist = pl_Yield( p_intf );
     if( p_playlist )
     {
         if( !playlist_IsEmpty( p_playlist ) )
@@ -601,7 +599,7 @@ wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t
         {
             input_radios[1]->Disable();
         }
-        vlc_object_release( p_playlist );
+        pl_Release( p_playlist );
     }
     else
     {
@@ -707,7 +705,7 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
         }
         else
         {
-            p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );
+            p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str(wxConvUTF8) );
         }
     }
     else
@@ -717,17 +715,19 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
         if( i != -1 )
         {
             long data = listview->GetItemData( i );
-            playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
-                                      VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
+            playlist_t *p_playlist = pl_Yield( p_intf );
             if( p_playlist )
             {
-                playlist_item_t * p_item = playlist_ItemGetById(                                                   p_playlist, (int)data, VLC_FALSE );
+                playlist_item_t * p_item = playlist_ItemGetById( p_playlist, (int)data, false );
                 if( p_item )
                 {
-                    p_parent->SetMrl( (const char*)p_item->p_input->psz_uri );
+                    const char *psz_uri = input_item_GetURI( p_item->p_input );
+                    p_parent->SetMrl( psz_uri );
+                    free( psz_uri );
                 }
                 else
                     event.Veto();
+                pl_Release( p_playlist );
             }
             else
                 event.Veto();
@@ -735,8 +735,8 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)
     }
     if( enable_checkbox->IsChecked() )
     {
-        int i_from = atoi( from_text->GetValue().mb_str() );
-        int i_to = atoi( to_text->GetValue().mb_str() );
+        int i_from = atoi( from_text->GetValue().mb_str(wxConvUTF8) );
+        int i_to = atoi( to_text->GetValue().mb_str(wxConvUTF8) );
         p_parent->SetPartial( i_from, i_to );
     }
     return;
@@ -819,7 +819,7 @@ wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
     /* Line 2 : codec */
     video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);
     video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),
-                                  wxDefaultPosition, wxSize(200,25), 0, NULL, 
+                                  wxDefaultPosition, wxSize(200,25), 0, NULL,
                                   wxCB_DROPDOWN| wxCB_READONLY );
     for( i= 0; vcodecs_array[i].psz_display != NULL; i++ )
     {
@@ -859,7 +859,7 @@ wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
     /* Line 2 : codec */
     audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);
     audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),
-                                  wxDefaultPosition, wxSize(200,25), 0, NULL, 
+                                  wxDefaultPosition, wxSize(200,25), 0, NULL,
                                   wxCB_DROPDOWN| wxCB_READONLY );
     for( i= 0; acodecs_array[i].psz_display != NULL; i++ )
     {
@@ -897,8 +897,8 @@ wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,
 
 wizTranscodeCodecPage::~wizTranscodeCodecPage()
 {
-    if( acodec ) free( acodec );
-    if( vcodec ) free( vcodec );
+    free( acodec );
+    free( vcodec );
 }
 
 void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)
@@ -980,12 +980,12 @@ void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)
                                        audio_combo->GetSelection() : i_audio_codec ));
     acodec = strdup(c->psz_codec);
 
-    int vb = atoi(vb_combo->GetValue().mb_str() );
+    int vb = atoi(vb_combo->GetValue().mb_str(wxConvUTF8) );
     if( vb == 0 )
     {
          vb = 1024;
     }
-    int ab = atoi(ab_combo->GetValue().mb_str() );
+    int ab = atoi(ab_combo->GetValue().mb_str(wxConvUTF8) );
     if( ab == 0)
     {
         ab = 192;
@@ -1077,16 +1077,7 @@ void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
     if( !event.GetDirection() ) return;
 
     /* Check valid address */
-    if( i_method == 1
-     && !net_AddressIsMulticast( (vlc_object_t *)p_intf,
-                                 address_txtctrl->GetValue().mb_str()) )
-    {
-        wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),
-                      wxICON_WARNING | wxOK, this->p_parent );
-        event.Veto();
-
-    }
-    else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
+    if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )
     {
         wxMessageBox( wxU( NO_ADDRESS_TEXT ) , wxU( ERROR_MSG ),
                       wxICON_WARNING | wxOK, this->p_parent );
@@ -1104,7 +1095,7 @@ void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)
         }
     }
     p_parent->SetStream( methods_array[i_method].psz_access ,
-                         address_txtctrl->GetValue().mb_str() );
+                         address_txtctrl->GetValue().mb_str(wxConvUTF8) );
 
     /* Set the action for the muxer page */
     ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );
@@ -1279,7 +1270,7 @@ void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)
 
     if( file_dialog && file_dialog->ShowModal() == wxID_OK )
     {
-        if( file_dialog->GetFilename().mb_str() )
+        if( file_dialog->GetFilename().mb_str(wxConvUTF8) )
         {
             file_text->SetValue( file_dialog->GetPath() );
         }
@@ -1363,7 +1354,7 @@ void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)
         else
         {
             p_parent->SetSAP( true,
-                             (const char *)sap_text->GetValue().mb_str() );
+                             (const char *)sap_text->GetValue().mb_str(wxConvUTF8) );
         }
     }
     else
@@ -1609,14 +1600,13 @@ void WizardDialog::Run()
             /* Add brackets automatically for IPv6 if they are missing */
             v6 = ( address[0] != '[' ) && ( strchr( address, ':' ) != NULL );
             asprintf( &psz_opt,
-                      ":sout=#standard{mux=%s,dst=%s%s%s,access=%s%s}",
-                      mux, v6 ? "[" : "", address, v6 ? "]" : "", method,
+                      ":sout=#%smux=%s,dst=%s%s%s%s}", method,
+                      mux, v6 ? "[" : "", address, v6 ? "]" : "",
                       psz_sap_option ?: "" );
-            if( psz_sap_option ) free( psz_sap_option );
+            free( psz_sap_option );
         }
 
-        playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
-                            VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);
+        playlist_t *p_playlist = pl_Yield( p_intf );
         if( p_playlist )
         {
             input_item_t *p_input = input_ItemNew( p_playlist, mrl,
@@ -1639,9 +1629,11 @@ void WizardDialog::Run()
             snprintf( psz_ttl, 20, "ttl=%i",i_ttl );
             input_ItemAddOption( p_input, psz_ttl );
 
+            /* FIXME: playlist_AddInput() can fail */
             playlist_AddInput( p_playlist, p_input,
-                               PLAYLIST_GO, PLAYLIST_END, VLC_TRUE );
-            vlc_object_release(p_playlist);
+                               PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
+            vlc_gc_decref( p_input );
+            pl_Release( p_playlist );
         }
         else
         {