[prev in list] [next in list] [prev in thread] [next in thread] 

List:       helix-datatype-dev
Subject:    Re: [datatype-dev] CR-Client: add null writer capability to binwrtr
From:       Greg Wright <gwright () real ! com>
Date:       2007-04-26 20:17:23
Message-ID: 463108D3.6080806 () real ! com
[Download RAW message or body]

Looks good.
--greg.

Eric Hyche wrote:
> Description
> ---------------------------------------
> I wanted some way to test transcoding performance
> in dtdrive without having to include the cost of
> writing out to disk. I could have written a null
> file writer (the IHXFileWriter analog to the null
> renderer), but since there was already a "binary
> writer" (which writes out packets to a raw file),
> then the easiest way to get a null writer was simply
> to make changes to the binwrtr so that if 
> the "BinWriterDisableWrites" pref is set to 1, then
> binwrtr receives packets but just throws them away
> and doesn't write anything out to disk.
> 
> Most of the changes just involved getting
> the context into the constructor of CBNSaveFile
> so that we could check the pref.
> 
> Files Modified
> ---------------------------------------
> datatype/tools/binwrtr/binarch.cpp
> datatype/tools/binwrtr/bnsavefl.cpp
> datatype/tools/binwrtr/bnsavefl.h
> 
> Branches
> ---------------------------------------
> HEAD only
> 
> Index: binarch.cpp
> ===================================================================
> RCS file: /cvsroot/datatype/tools/binwrtr/binarch.cpp,v
> retrieving revision 1.3
> diff -u -w -u -w -r1.3 binarch.cpp
> --- binarch.cpp 14 Mar 2005 19:24:54 -0000      1.3
> +++ binarch.cpp 26 Apr 2007 14:45:17 -0000
> @@ -500,7 +500,7 @@
>      CBNSaveFile*   pSaveFile     = NULL;
>      UINT32         ulLogicalStreamIndex = m_ulNumTempFiles;
> 
> -    pSaveFile = CBNSaveFile::CreateBNSaveFile(pFileObject);
> +    pSaveFile = CBNSaveFile::CreateBNSaveFile(m_pContext, pFileObject);
>      if (!pSaveFile)
>      {
>         return HXR_OUTOFMEMORY;
> Index: bnsavefl.cpp
> ===================================================================
> RCS file: /cvsroot/datatype/tools/binwrtr/bnsavefl.cpp,v
> retrieving revision 1.1
> diff -u -w -u -w -r1.1 bnsavefl.cpp
> --- bnsavefl.cpp        24 May 2004 18:02:29 -0000      1.1
> +++ bnsavefl.cpp        26 Apr 2007 14:45:17 -0000
> @@ -52,14 +52,15 @@
>  #include "hxstrutl.h"
>  #include "hxassert.h"
>  #include "chxpckts.h"
> +#include "hxprefutil.h"
> 
> 
>  CBNSaveFile*
> -CBNSaveFile::CreateBNSaveFile(IHXFileObject* pFileObject)
> +CBNSaveFile::CreateBNSaveFile(IUnknown* pContext, IHXFileObject*
> pFileObject)
>  {
>      CBNSaveFile * pSaveFile;
> 
> -    pSaveFile = new CBNSaveFile(pFileObject);
> +    pSaveFile = new CBNSaveFile(pContext, pFileObject);
> 
>      if (pSaveFile)
>      {
> @@ -77,13 +78,22 @@
>  // Private constructor - Use CreateBNSaveFile() to get instance of
> CBNSaveFile
>  CBNSaveFile::CBNSaveFile
>  (
> +    IUnknown* pContext,
>      IHXFileObject* pFileObject
>  ) : m_pFileObject(pFileObject)
>    , m_ulFileSize(0)
>    , m_LastFileStatus(HXR_OK)
> +  , m_bDisableWrites(FALSE)
>    , m_bFileBusy(FALSE)
>    , m_lRefCount(0)
>  {
> +    ReadPrefBOOL(pContext, "BinWriterDisableWrites", m_bDisableWrites);
> +    if (m_bDisableWrites)
> +    {
> +        // If writes are disabled, then just NULL out the file object
> member.
> +        // This will effectively disable all writes.
> +        m_pFileObject = NULL;
> +    }
>      if (m_pFileObject)
>      {
>         m_pFileObject->AddRef();
> @@ -107,7 +117,7 @@
>  HX_RESULT
>  CBNSaveFile::Abort(void)
>  {
> -    HX_RESULT retVal = HXR_FAIL;
> +    HX_RESULT retVal = (m_bDisableWrites ? HXR_OK : HXR_FAIL);
> 
>      if (m_pFileObject)
>      {
> @@ -138,7 +148,7 @@
>      IHXBuffer* pBuffer
>  )
>  {
> -    HX_RESULT retVal = HXR_FAIL;
> +    HX_RESULT retVal = (m_bDisableWrites ? HXR_OK : HXR_FAIL);
> 
>      if (m_pFileObject && (!m_bFileBusy))
>      {
> Index: bnsavefl.h
> ===================================================================
> RCS file: /cvsroot/datatype/tools/binwrtr/bnsavefl.h,v
> retrieving revision 1.2
> diff -u -w -u -w -r1.2 bnsavefl.h
> --- bnsavefl.h  14 Mar 2005 19:24:54 -0000      1.2
> +++ bnsavefl.h  26 Apr 2007 14:45:17 -0000
> @@ -45,7 +45,7 @@
>  class CBNSaveFile : public IHXFileResponse
>  {
>  public:
> -    static CBNSaveFile*        CreateBNSaveFile(IHXFileObject*
> pFileObject);
> +    static CBNSaveFile*        CreateBNSaveFile(IUnknown* pContext,
> IHXFileObject* pFileObject);
> 
>      /*
>       * IUnknown methods
> @@ -86,12 +86,13 @@
>      ULONG32    FileSize(void);
> 
>  private:
> -    CBNSaveFile(IHXFileObject* pFileObject);
> +    CBNSaveFile(IUnknown* pContext, IHXFileObject* pFileObject);
> 
>      IHXFileObject* m_pFileObject;
>      ULONG32 m_ulFileSize;
>      HXBOOL m_bFileBusy;
>      HX_RESULT m_LastFileStatus;
> +    HXBOOL    m_bDisableWrites;
> 
>      LONG32 m_lRefCount;
>  };
> 
> 
> =============================================
> Eric Hyche (ehyche@real.com)
> Technical Lead
> RealNetworks, Inc. 
> 
> 
> _______________________________________________
> Datatype-dev mailing list
> Datatype-dev@helixcommunity.org
> http://lists.helixcommunity.org/mailman/listinfo/datatype-dev



_______________________________________________
Datatype-dev mailing list
Datatype-dev@helixcommunity.org
http://lists.helixcommunity.org/mailman/listinfo/datatype-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic