[Xfce4-commits] <parole:0.2.2> Properly handle WriteReady callback.

Ali Abdallah noreply at xfce.org
Thu Jan 14 10:04:03 CET 2010


Updating branch refs/heads/0.2.2
         to 3c88414b3b0edf3ed4620e62df9c69e39c05c67f (commit)
       from f6b28fc169ba66d48c179df355804d258fbf40bd (commit)

commit 3c88414b3b0edf3ed4620e62df9c69e39c05c67f
Author: Ali Abdallah <aliov at xfce.org>
Date:   Wed Jan 13 21:24:57 2010 +0100

    Properly handle WriteReady callback.
    
    Conflicts:
    
    	browser-plugin/plugin.cpp

 browser-plugin/npp_gate.cpp |    2 --
 browser-plugin/plugin.cpp   |   28 ++++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/browser-plugin/npp_gate.cpp b/browser-plugin/npp_gate.cpp
index 3fbb03b..90c1d00 100644
--- a/browser-plugin/npp_gate.cpp
+++ b/browser-plugin/npp_gate.cpp
@@ -71,7 +71,6 @@ NPError NPP_New(NPMIMEType pluginType,
 
     NPError rv = NPERR_NO_ERROR;
 
-    printf("NPP_New called\n");
     CPlugin *pPlugin = new CPlugin(instance);
     if (pPlugin == NULL)
         return NPERR_OUT_OF_MEMORY_ERROR;
@@ -132,7 +131,6 @@ NPError NPP_SetWindow(NPP instance, NPWindow * pNPWindow)
 
     // window resized
     if (pPlugin->isInitialized() && (pNPWindow->window != NULL)) {
-        printf("Window resized\n");
         pPlugin->SetWindow(pNPWindow);
         return NPERR_NO_ERROR;
     }
diff --git a/browser-plugin/plugin.cpp b/browser-plugin/plugin.cpp
index 365af6f..43372f0 100644
--- a/browser-plugin/plugin.cpp
+++ b/browser-plugin/plugin.cpp
@@ -407,6 +407,23 @@ NPError CPlugin::NewStream (NPMIMEType type, NPStream * stream, NPBool seekable,
 
 NPError CPlugin::DestroyStream(NPStream * stream, NPError reason)
 {
+    /*
+    g_debug ("DestroyStream reason = %i for %s\n", reason, stream->url);
+    
+    if ( reason == NPRES_DONE )
+    {
+	g_debug ("NPRES_DONE");
+    }
+    else if ( reason == NPRES_USER_BREAK )
+    {
+	g_debug ("NPRES_USER_BREAK");
+	
+    }
+    else if ( reason == NPRES_NETWORK_ERR )
+    {
+	g_debug ("NPRES_NETWORK_ERR");
+    }
+    */
     return NPERR_NO_ERROR;
 }
 
@@ -424,6 +441,12 @@ int32_t CPlugin::WriteReady (NPStream * stream)
 {
     g_debug ("WriteReady url=%s", stream->url);
     
+    if ( mode != NP_FULL )
+    {
+	NPN_DestroyStream (mInstance, stream, NPRES_DONE);
+	return -1;
+    }
+    
     return  player_ready ? STREAMBUFSIZE  : 0;
 }
     
@@ -464,10 +487,7 @@ int32_t CPlugin::Write (NPStream * stream, int32_t offset, int32_t len, void *bu
 	if ( cache )
 	{
 	    fseek (cache, offset, SEEK_SET);
-	    wrotebytes += fwrite (buffer, 1, len, cache);
-#ifdef DEBUG
-	    g_debug ("Wrotebytes=%d offset=%d data=%s", wrotebytes, offset, (gchar*)buffer);
-#endif
+	    wrotebytes += fwrite (buffer, 1, MAX (len, STREAMBUFSIZE), cache);
 	}
 	
 	if ( wrotebytes >= 0 )



More information about the Xfce4-commits mailing list