[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - avmedia/source sal/inc sal/osl sal/qa sal/rtl

Herbert Dürr hdu at apache.org
Thu May 15 03:08:01 PDT 2014


 avmedia/source/macavf/macavf_player.cxx |    5 
 sal/inc/osl/diagnose.hxx                |   14 --
 sal/inc/rtl/allocator.hxx               |  171 --------------------------------
 sal/osl/all/debugbase.cxx               |    2 
 sal/osl/w32/path_helper.hxx             |    1 
 sal/osl/w32/procimpl.cxx                |   10 -
 sal/qa/osl/process/osl_process.cxx      |    4 
 sal/rtl/source/bootstrap.cxx            |   11 --
 sal/rtl/source/hash.cxx                 |    5 
 sal/rtl/source/unload.cxx               |   18 +--
 10 files changed, 20 insertions(+), 221 deletions(-)

New commits:
commit c6e0325df6efce45dbb2616a32b7745c449c6c58
Author: Herbert Dürr <hdu at apache.org>
Date:   Thu May 15 09:59:27 2014 +0000

    #i124896# remove obsoleted sal-module-internal custom STL allocator
    
    The SAL module avoided the heavy dependency on the stlport4-libraries by using
    a custom allocator for its internal STL containers. With stlport4 removed these
    dependencies are gone and the SAL-internal custom allocator is obsoleted. Since
    the custom allocator results in build problems with clang>=3.4 or xcode>=5.1 it
    is time to remove it for good.

diff --git a/sal/inc/osl/diagnose.hxx b/sal/inc/osl/diagnose.hxx
index 9d887aa..5cab379 100644
--- a/sal/inc/osl/diagnose.hxx
+++ b/sal/inc/osl/diagnose.hxx
@@ -23,21 +23,10 @@
 #if ! defined(OSL_DIAGNOSE_HXX_INCLUDED)
 #define OSL_DIAGNOSE_HXX_INCLUDED
 
-#if ! defined(_OSL_DIAGNOSE_H_)
 #include "osl/diagnose.h"
-#endif
-#if ! defined(_OSL_INTERLOCK_H_)
 #include "osl/interlck.h"
-#endif
-#if ! defined(_OSL_MUTEX_HXX_)
 #include "osl/mutex.hxx"
-#endif
-#if ! defined(INCLUDED_RTL_ALLOCATOR_HXX)
-#include "rtl/allocator.hxx"
-#endif
-#if ! defined(_RTL_INSTANCE_HXX_)
 #include "rtl/instance.hxx"
-#endif
 #include <hash_set>
 #include <functional>
 #include <typeinfo>
@@ -91,8 +80,7 @@ struct VoidPtrHash : ::std::unary_function<void const*, ::std::size_t> {
     }
 };
 
-typedef ::std::hash_set<void const*, VoidPtrHash, ::std::equal_to<void const*>,
-                        ::rtl::Allocator<void const*> > VoidPointerSet;
+typedef ::std::hash_set<void const*, VoidPtrHash, ::std::equal_to<void const*> > VoidPointerSet;
 
 struct ObjectRegistryData {
     ObjectRegistryData( ::std::type_info const& rTypeInfo )
diff --git a/sal/inc/rtl/allocator.hxx b/sal/inc/rtl/allocator.hxx
deleted file mode 100644
index d4c1d47..0000000
--- a/sal/inc/rtl/allocator.hxx
+++ /dev/null
@@ -1,171 +0,0 @@
-/**************************************************************
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- *************************************************************/
-
-
-#if !defined INCLUDED_RTL_ALLOCATOR_HXX
-#define INCLUDED_RTL_ALLOCATOR_HXX
-
-#if ! defined(_SAL_TYPES_H_)
-#include "sal/types.h"
-#endif
-#if ! defined(_RTL_ALLOC_H_)
-#include "rtl/alloc.h"
-#endif
-
-#include <cstddef>
-
-//######################################################
-// This is no general purpose STL allocator but one
-// necessary to use STL for some implementation but
-// avoid linking sal against the STLPort library!!!
-// For more information on when and how to define a
-// custom stl allocator have a look at Scott Meyers:
-// "Effective STL", Nicolai M. Josuttis:
-// "The C++ Standard Library - A Tutorial and Reference"
-// and at http://www.josuttis.com/cppcode/allocator.html
-
-namespace rtl {
-
-/** @internal */
-template<class T>
-class Allocator
-{
-public:
-    typedef T value_type;
-    typedef T* pointer;
-    typedef const T* const_pointer;
-    typedef T& reference;
-    typedef const T& const_reference;
-    typedef ::std::size_t size_type;
-    typedef ::std::ptrdiff_t difference_type;
-
-    //-----------------------------------------
-    template<class U>
-    struct rebind
-    {
-        typedef Allocator<U> other;
-    };
-
-    //-----------------------------------------
-    pointer address (reference value) const
-    {
-        return &value;
-    }
-
-    //-----------------------------------------
-    const_pointer address (const_reference value) const
-    {
-        return &value;
-    }
-
-    //-----------------------------------------
-    Allocator() SAL_THROW(())
-    {}
-
-    //-----------------------------------------
-    template<class U>
-    Allocator (const Allocator<U>&) SAL_THROW(())
-    {}
-
-    //-----------------------------------------
-    Allocator(const Allocator&) SAL_THROW(())
-    {}
-
-    //-----------------------------------------
-    ~Allocator() SAL_THROW(())
-    {}
-
-    //-----------------------------------------
-    size_type max_size() const SAL_THROW(())
-    {
-        return size_type(-1)/sizeof(T);
-    }
-
-    //-----------------------------------------
-    /* Normally the code for allocate should
-       throw a std::bad_alloc exception if the
-       requested memory could not be allocated:
-       (C++ standard 20.4.1.1):
-
-       pointer allocate (size_type n, const void* hint = 0)
-       {
-         pointer p = reinterpret_cast<pointer>(
-             rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
-
-         if (NULL == p)
-             throw ::std::bad_alloc();
-
-         return p;
-       }
-
-       but some compilers do not compile it if exceptions
-       are not enabled, e.g. GCC under Linux and it is
-       in general not desired to compile sal with exceptions
-       enabled. */
-    pointer allocate (size_type n, const void* hint = 0)
-    {
-        hint = hint; /* avoid warnings */
-        return reinterpret_cast<pointer>(
-            rtl_allocateMemory(sal_uInt32(n * sizeof(T))));
-    }
-
-    //-----------------------------------------
-    void deallocate (pointer p, size_type /* n */)
-    {
-        rtl_freeMemory(p);
-    }
-
-    //-----------------------------------------
-    void construct (pointer p, const T& value)
-    {
-        new ((void*)p)T(value);
-    }
-
-    //-----------------------------------------
-    void destroy (pointer p)
-    {
-        p->~T();
-    }
-};
-
-//######################################################
-// Custom STL allocators must be stateless (see
-// references above) that's why the operators below
-// return always true or false
-
-/** @internal */
-template<class T, class U>
-inline bool operator== (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
-{
-    return true;
-}
-
-/** @internal */
-template<class T, class U>
-inline bool operator!= (const Allocator<T>&, const Allocator<U>&) SAL_THROW(())
-{
-    return false;
-}
-
-} /* namespace rtl */
-
-#endif /* INCLUDED_RTL_ALLOCATOR_HXX */
-
diff --git a/sal/osl/all/debugbase.cxx b/sal/osl/all/debugbase.cxx
index 1315a87..6234a5b 100644
--- a/sal/osl/all/debugbase.cxx
+++ b/sal/osl/all/debugbase.cxx
@@ -44,7 +44,7 @@
 
 namespace {
 
-typedef std::vector<rtl::OString, rtl::Allocator<rtl::OString> > OStringVec;
+typedef std::vector<rtl::OString> OStringVec;
 
 struct StaticDebugBaseAddressFilter
     : rtl::StaticWithInit<OStringVec const, StaticDebugBaseAddressFilter> {
diff --git a/sal/osl/w32/path_helper.hxx b/sal/osl/w32/path_helper.hxx
index 3e11371..481be6d 100644
--- a/sal/osl/w32/path_helper.hxx
+++ b/sal/osl/w32/path_helper.hxx
@@ -30,7 +30,6 @@
 
 #include "path_helper.h"
 #include <rtl/ustring.hxx>
-#include <rtl/allocator.hxx>
 
 namespace osl
 {
diff --git a/sal/osl/w32/procimpl.cxx b/sal/osl/w32/procimpl.cxx
index 4d696e0..822a681 100644
--- a/sal/osl/w32/procimpl.cxx
+++ b/sal/osl/w32/procimpl.cxx
@@ -43,7 +43,6 @@
 #include <rtl/ustring.hxx>
 #include <rtl/ustrbuf.hxx>
 #include "secimpl.h"
-#include "rtl/allocator.hxx"
 #include <osl/file.hxx>
 
 #include <list>
@@ -63,11 +62,11 @@ const rtl::OUString QUOTE = rtl::OUString::createFromAscii("\"");
 namespace /* private */
 {
     //#################################################
-    typedef std::list<rtl::OUString, rtl::Allocator<rtl::OUString> > string_container_t;
+    typedef std::list<rtl::OUString> string_container_t;
     typedef string_container_t::iterator string_container_iterator_t;
     typedef string_container_t::const_iterator string_container_const_iterator_t;
     typedef std::pair<string_container_iterator_t, string_container_iterator_t> iterator_pair_t;
-    typedef std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > environment_container_t;
+    typedef std::vector<sal_Unicode > environment_container_t;
 
     //#################################################
     /* Function object that compares two strings that are
@@ -307,7 +306,7 @@ namespace /* private */
         rtl::OUString ret(path);
         if (path.getLength() > 260)
         {
-            std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec(path.getLength() + 1);
+            std::vector<sal_Unicode> vec(path.getLength() + 1);
             //GetShortPathNameW only works if the file can be found!
             const DWORD len = GetShortPathNameW(
                 reinterpret_cast<LPCWSTR>(path.getStr()), reinterpret_cast<LPWSTR>(&vec[0]), path.getLength() + 1);
@@ -316,8 +315,7 @@ namespace /* private */
                 && extension.getLength())
             {
                 const rtl::OUString extPath(path + extension);
-                std::vector<sal_Unicode, rtl::Allocator<sal_Unicode> > vec2(
-                    extPath.getLength() + 1);
+                std::vector<sal_Unicode > vec2( extPath.getLength() + 1);
                 const DWORD len2 = GetShortPathNameW(
                     reinterpret_cast<LPCWSTR>(extPath.getStr()), reinterpret_cast<LPWSTR>(&vec2[0]), extPath.getLength() + 1);
                 ret = rtl::OUString(&vec2[0], len2);
diff --git a/sal/qa/osl/process/osl_process.cxx b/sal/qa/osl/process/osl_process.cxx
index 5dfd829..be19ef0 100644
--- a/sal/qa/osl/process/osl_process.cxx
+++ b/sal/qa/osl/process/osl_process.cxx
@@ -44,8 +44,6 @@
 #include <tools/postwin.h>
 #endif
 
-#include "rtl/allocator.hxx"
-
 #include <iostream>
 #include <fstream>
 #include <vector>
@@ -296,7 +294,7 @@ public:
 
 //#########################################################
 
-typedef std::vector<std::string, rtl::Allocator<std::string> >  string_container_t;
+typedef std::vector<std::string>  string_container_t;
 typedef string_container_t::const_iterator string_container_const_iter_t;
 typedef string_container_t::iterator       string_container_iter_t;
 
diff --git a/sal/rtl/source/bootstrap.cxx b/sal/rtl/source/bootstrap.cxx
index 2c93d98..b219c5c 100644
--- a/sal/rtl/source/bootstrap.cxx
+++ b/sal/rtl/source/bootstrap.cxx
@@ -41,7 +41,6 @@
 #include <rtl/instance.hxx>
 #include <rtl/malformeduriexception.hxx>
 #include <rtl/uri.hxx>
-#include "rtl/allocator.hxx"
 
 #include "macro.hxx"
 
@@ -134,10 +133,7 @@ struct rtl_bootstrap_NameValue
         {}
 };
 
-typedef std::list<
-    rtl_bootstrap_NameValue,
-    rtl::Allocator< rtl_bootstrap_NameValue >
-> NameValueList;
+typedef std::list<rtl_bootstrap_NameValue> NameValueList;
 
 bool find(
     NameValueList const & list, rtl::OUString const & key,
@@ -605,10 +601,7 @@ void Bootstrap_Impl::expandValue(
 namespace {
 
 struct bootstrap_map {
-    typedef std::hash_map<
-        rtl::OUString, Bootstrap_Impl *,
-        rtl::OUStringHash, std::equal_to< rtl::OUString >,
-        rtl::Allocator< OUString > > t;
+    typedef std::hash_map< const rtl::OUString, Bootstrap_Impl*, rtl::OUStringHash > t;
 
     // get and release must only be called properly synchronized via some mutex
     // (e.g., osl::Mutex::getGlobalMutex()):
diff --git a/sal/rtl/source/hash.cxx b/sal/rtl/source/hash.cxx
index 6d22c3d..db7243b 100644
--- a/sal/rtl/source/hash.cxx
+++ b/sal/rtl/source/hash.cxx
@@ -23,12 +23,10 @@
 
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_sal.hxx"
-#include "rtl/allocator.hxx"
 
 #include "hash.h"
 #include "strimp.h"
 
-
 #include <hash_set>
 
 namespace {
@@ -53,8 +51,7 @@ struct UStringEqual
     }
 };
 
-typedef std::hash_set< rtl_uString *, UStringHash, UStringEqual,
-                       rtl::Allocator<rtl_uString *> > StringHashTable;
+typedef std::hash_set< rtl_uString *, UStringHash, UStringEqual > StringHashTable;
 
 StringHashTable *
 getHashTable ()
diff --git a/sal/rtl/source/unload.cxx b/sal/rtl/source/unload.cxx
index 072ba6d..f33d34d 100644
--- a/sal/rtl/source/unload.cxx
+++ b/sal/rtl/source/unload.cxx
@@ -28,7 +28,6 @@
 #include <rtl/ustring.hxx>
 #include <osl/mutex.hxx>
 #include <hash_map>
-#include "rtl/allocator.hxx"
 
 #include <functional>
 #include <list>
@@ -153,11 +152,10 @@ struct hashModule
 };
 
 typedef std::hash_map<
-    oslModule,
+    const oslModule,
     std::pair<sal_uInt32, component_canUnloadFunc>,
     hashModule,
-    std::equal_to<oslModule>,
-    rtl::Allocator<oslModule>
+    std::equal_to<oslModule>
 > ModuleMap;
 
 typedef ModuleMap::iterator Mod_IT;
@@ -243,7 +241,7 @@ extern "C" void SAL_CALL rtl_unloadUnusedModules( TimeValue* libUnused)
 {
     MutexGuard guard( getUnloadingMutex());
 
-    typedef std::list< oslModule, rtl::Allocator<oslModule> > list_type;
+    typedef std::list< oslModule > list_type;
     list_type unloadedModulesList;
 
     ModuleMap& moduleMap= getModuleMap();
@@ -302,11 +300,10 @@ struct hashListener
 };
 
 typedef std::hash_map<
-    sal_Int32,
+    const sal_Int32,
     std::pair<rtl_unloadingListenerFunc, void*>,
     hashListener,
-    std::equal_to<sal_Int32>,
-    rtl::Allocator<sal_Int32>
+    std::equal_to<sal_Int32>
 > ListenerMap;
 
 typedef ListenerMap::iterator Lis_IT;
@@ -333,10 +330,7 @@ static ListenerMap& getListenerMap()
 // available. Otherwise a new cookie will be provided.
 // not a new value is returned.
 
-typedef std::deque<
-    sal_Int32,
-    rtl::Allocator<sal_Int32>
-> queue_type;
+typedef std::deque< sal_Int32 > queue_type;
 
 static queue_type& getCookieQueue()
 {
commit d3ebac9e8edd91dd3248cd210cba7220414f501a
Author: Herbert Dürr <hdu at apache.org>
Date:   Thu May 15 09:46:26 2014 +0000

    #i124875# use AVAsset's best guess duration if AVPlayerItem isn't ready yet
    
    in AV Foundation the most accurate media asset duration is available when the
    AVPlayerItem's status changes to AVPlayerItemStatusReadyToPlay. There already
    is an observer for this, but the upper layers expect getDuration() to be
    synchronous and to return within a reasonable time. Since returning an
    approximation is sufficient using the AVAsset's duration as fallback is fine.

diff --git a/avmedia/source/macavf/macavf_player.cxx b/avmedia/source/macavf/macavf_player.cxx
index 26bc07a..3a1882a 100644
--- a/avmedia/source/macavf/macavf_player.cxx
+++ b/avmedia/source/macavf/macavf_player.cxx
@@ -218,7 +218,10 @@ double SAL_CALL Player::getDuration()
     if( mpPlayer )
     {
         AVPlayerItem* pItem = [mpPlayer currentItem];
-        duration = CMTimeGetSeconds( [pItem duration] );
+        if( [pItem status] == AVPlayerItemStatusReadyToPlay )
+            duration = CMTimeGetSeconds( [pItem duration] );
+        else // fall back to AVAsset's best guess
+            duration = CMTimeGetSeconds( [[pItem asset] duration] );
     }
 
     return duration;


More information about the Libreoffice-commits mailing list