Commit ce6df37a authored by conrad's avatar conrad

pass return value from OggzReadCallbacks back to caller, in case of no

input data being read


git-svn-id: http://svn.annodex.net/liboggz/trunk@513 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent aa57a60c
......@@ -1161,6 +1161,7 @@ long oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence);
long oggz_serialno_new (OGGZ * oggz);
#include <oggz/oggz_io.h>
#include <oggz/oggz_deprecated.h>
#ifdef __cplusplus
}
......
......@@ -122,8 +122,13 @@ enum OggzError {
/** Seeking operation is not possible for this OGGZ */
OGGZ_ERR_NOSEEK = -13,
/** Reading stopped by user before any input bytes were consumed */
OGGZ_ERR_USER_STOPPED = -14,
/** Reading was stopped by an OggzReadCallback returning OGGZ_STOP_OK
* before any input bytes were consumed */
OGGZ_ERR_READ_STOP_OK = -14,
/** Reading was stopped by an OggzReadCallback returning OGGZ_STOP_ERR
* before any input bytes were consumed */
OGGZ_ERR_READ_STOP_ERR = -15,
/** The requested serialno does not exist in this OGGZ */
OGGZ_ERR_BAD_SERIALNO = -20,
......
/*
Copyright (C) 2003 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OGGZ_DEPRECATED_H__
#define __OGGZ_DEPRECATED_H__
/**
* DEPRECATED CONSTANT.
* OGGZ_ERR_USER_STOPPED was introduced during development (post 0.8.3),
* and is similar in functionality to and numerically equal to (ie. ABI
* compatible with) OGGZ_ERR_READ_STOP_OK in <oggz/oggz_constants.h>.
* It was badly named, as the preferred functionality distinguishes between
* a user's OggzReadCallback returning OGGZ_STOP_OK or OGGZ_STOP_ERR; your
* code should distinguish between these two too :-) Hence, don't use this
* (unreleased) name in new code.
*/
#define OGGZ_ERR_USER_STOPPED OGGZ_ERR_READ_STOP_OK
#endif __OGGZ_DEPRECATED_H__
......@@ -370,11 +370,16 @@ oggz_read (OGGZ * oggz, long n)
cb_ret = oggz_read_sync (oggz);
}
if (cb_ret == -1) oggz_purge (oggz);
if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz);
/* Don't return 0 unless it's actually an EOF condition */
if (nread == 0 && (cb_ret == OGGZ_STOP_OK || cb_ret == OGGZ_STOP_ERR))
return OGGZ_ERR_USER_STOPPED;
if (nread == 0) {
switch (cb_ret) {
case OGGZ_CONTINUE: return 0; break;
case OGGZ_STOP_ERR: return OGGZ_ERR_READ_STOP_ERR; break;
case OGGZ_STOP_OK: default: return OGGZ_ERR_READ_STOP_OK; break;
}
}
return nread;
}
......@@ -414,11 +419,16 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n)
cb_ret = oggz_read_sync (oggz);
}
if (cb_ret == -1) oggz_purge (oggz);
if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz);
/* Don't return 0 unless it's actually an EOF condition */
if (nread == 0 && (cb_ret == OGGZ_STOP_OK || cb_ret == OGGZ_STOP_ERR))
return OGGZ_ERR_USER_STOPPED;
if (nread == 0) {
switch (cb_ret) {
case OGGZ_CONTINUE: return 0; break;
case OGGZ_STOP_ERR: return OGGZ_ERR_READ_STOP_ERR; break;
case OGGZ_STOP_OK: default: return OGGZ_ERR_READ_STOP_OK; break;
}
}
return nread;
}
......
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