Commit d6347f62 authored by Ali Abdallah's avatar Ali Abdallah

Properly handle WriteReady callback.

parent fab9e65f
......@@ -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;
}
......
......@@ -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,8 @@ 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
wrotebytes += fwrite (buffer, 1, MAX (len, STREAMBUFSIZE), cache);
//g_debug ("Wrotebytes=%d offset=%d data=%s", wrotebytes, offset, (gchar*)buffer);
#endif
}
if ( wrotebytes >= 0 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment