Browse Source

Rationalise not found error codes

We don't need 4 different codes for essentially the same thing, which
is that a certain thing could not be found.
pull/127/head
Rémi Denis-Courmont 5 years ago
parent
commit
f32f289264
  1. 4
      doc/browsing.txt
  2. 10
      include/vlc_common.h
  3. 2
      include/vlc_variables.h
  4. 2
      modules/access/dvb/access.c
  5. 4
      modules/access/dvb/scan.c
  6. 2
      modules/codec/avcodec/d3d11va.c
  7. 4
      modules/codec/avcodec/dxva2.c
  8. 20
      modules/control/cli/player.c
  9. 2
      modules/control/cli/playlist.c
  10. 4
      modules/gui/macosx/library/VLCInputItem.m
  11. 2
      modules/gui/macosx/library/VLCLibraryController.m
  12. 2
      modules/gui/macosx/playlist/VLCPlayerController.m
  13. 4
      modules/lua/libs/misc.c
  14. 2
      modules/lua/libs/playlist.c
  15. 2
      modules/stream_out/sdi/DBMSDIOutput.cpp
  16. 2
      modules/video_filter/opencv_wrapper.c
  17. 10
      src/misc/variables.c
  18. 2
      src/playlist/preparse.c
  19. 6
      test/src/misc/variables.c

4
doc/browsing.txt

@ -28,11 +28,11 @@ A call to pf_readdir has 3 possible results:
case, pf_readdir MUST return VLC_SUCCESS and info.b_eof MUST be set to true.
This callback must NOT be called again.
* An unrecoverable error has occurred and no input_item_t was added to the node.
The callback returns a VLC_ENOITEM error code, and sets info.b_eof to true.
The callback returns a VLC_ENOENT error code, and sets info.b_eof to true.
This error SHOULD be propagated by the calling code (stream/demux/...)
This callback must NOT be called again.
* A recoverable error has occurred. The callback MUST return an error code
that is not VLC_SUCCESS or VLC_ENOITEM (e.g. VLC_EGENERIC, VLC_ENOMEM, ...).
that is not VLC_SUCCESS or VLC_ENOENT (e.g. VLC_EGENERIC, VLC_ENOMEM, ...).
Some input_item_t objects might have been added to the node; they are
owned by the node which is owned by the access. This callback CAN be
called again.

10
include/vlc_common.h

@ -476,16 +476,10 @@ typedef union
#define VLC_ENOMEM (-2)
/** Timeout */
#define VLC_ETIMEOUT (-3)
/** Module not found */
#define VLC_ENOMOD (-4)
/** Object not found */
#define VLC_ENOOBJ (-5)
/** Variable not found */
#define VLC_ENOVAR (-6)
/** Not found */
#define VLC_ENOENT (-4)
/** Bad variable value */
#define VLC_EINVAL (-7)
/** Item not found */
#define VLC_ENOITEM (-8)
/** Operation forbidden */
#define VLC_EACCES (-9)
/** Operation not supported */

2
include/vlc_variables.h

@ -188,7 +188,7 @@ VLC_API int var_GetChecked( vlc_object_t *, const char *, int, vlc_value_t * );
* (see \ref vlc_var_atomic_op)
* \param value value of the variable after the modification
* \retval VLC_SUCCESS Operation successful
* \retval VLC_ENOVAR Variable not found
* \retval VLC_ENOENT Variable not found
*
* \bug The modified value is returned rather than the original value.
* As such, the original value cannot be known in the case of non-reversible

2
modules/access/dvb/access.c

@ -322,7 +322,7 @@ static int ScanReadCallback( scan_t *p_scan, void *p_privdata,
}
else if( i_ret == 0 )
{
return VLC_ENOITEM;
return VLC_ENOENT;
}
if( ufds[1].revents )

4
modules/access/dvb/scan.c

@ -790,7 +790,7 @@ static int Scan_GetNextTunerConfig( scan_t *p_scan, scan_tuner_config_t *p_cfg,
}
}
return VLC_ENOITEM;
return VLC_ENOENT;
}
static int scan_Next( scan_t *p_scan, scan_tuner_config_t *p_cfg )
@ -852,7 +852,7 @@ int scan_Run( scan_t *p_scan )
{
scan_tuner_config_t cfg;
if( scan_Next( p_scan, &cfg ) )
return VLC_ENOITEM;
return VLC_ENOENT;
scan_session_t *session = scan_session_New( p_scan, &cfg );
if( unlikely(session == NULL) )

2
modules/codec/avcodec/d3d11va.c

@ -199,7 +199,7 @@ static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame
vlc_va_sys_t *sys = va->sys;
vlc_va_surface_t *va_surface = va_pool_Get(sys->va_pool);
if (unlikely(va_surface == NULL))
return VLC_ENOITEM;
return VLC_ENOENT;
pic->context = NewSurfacePicContext(va, va_surface);
if (unlikely(pic->context == NULL))
{

4
modules/codec/avcodec/dxva2.c

@ -208,13 +208,13 @@ static int Get(vlc_va_t *va, picture_t *pic, AVCodecContext *ctx, AVFrame *frame
vlc_va_surface_t *va_surface = va_pool_Get(sys->va_pool);
if (unlikely(va_surface==NULL))
return VLC_ENOITEM;
return VLC_ENOENT;
pic->context = NewSurfacePicContext(va, va_surface);
if (unlikely(pic->context == NULL))
{
va_surface_Release(va_surface);
return VLC_ENOITEM;
return VLC_ENOENT;
}
frame->data[3] = (uint8_t*)DXVA2_PICCONTEXT_FROM_PICCTX(pic->context)->ctx.picsys.surface;
return VLC_SUCCESS;

20
modules/control/cli/player.c

@ -366,7 +366,7 @@ static int PlayerSetChapter(struct cli_client *cl, const char *const *args,
else
{
cli_printf(cl, "No chapter selected.");
ret = VLC_ENOITEM;
ret = VLC_ENOENT;
}
}
vlc_player_Unlock(player);
@ -401,7 +401,7 @@ static int PlayerSetTitle(struct cli_client *cl, const char *const *args,
else
{
cli_printf(cl, "No title selected.");
ret = VLC_ENOITEM;
ret = VLC_ENOENT;
}
}
vlc_player_Unlock(player);
@ -527,7 +527,7 @@ static int PlayerItemInfo(struct cli_client *cl, const char *const *args,
cli_printf(cl, "no input");
vlc_player_Unlock(player);
(void) args; (void) count;
return (item != NULL) ? 0 : VLC_ENOITEM;
return (item != NULL) ? 0 : VLC_ENOENT;
}
static int PlayerGetTime(struct cli_client *cl, const char *const *args,
@ -540,7 +540,7 @@ static int PlayerGetTime(struct cli_client *cl, const char *const *args,
t = vlc_player_GetTime(player);
vlc_player_Unlock(player);
if (t == VLC_TICK_INVALID)
return VLC_ENOITEM;
return VLC_ENOENT;
cli_printf(cl, "%"PRIu64, SEC_FROM_VLC_TICK(t));
(void) args; (void) count;
@ -558,7 +558,7 @@ static int PlayerGetLength(struct cli_client *cl, const char *const *args,
vlc_player_Unlock(player);
if (l == VLC_TICK_INVALID)
return VLC_ENOITEM;
return VLC_ENOENT;
cli_printf(cl, "%"PRIu64, SEC_FROM_VLC_TICK(l));
(void) args; (void) count;
@ -576,7 +576,7 @@ static int PlayerGetTitle(struct cli_client *cl, const char *const *args,
cli_printf(cl, "%s", (title != NULL) ? title->name : "");
vlc_player_Unlock(player);
(void) args; (void) count;
return (title != NULL) ? 0 : VLC_ENOITEM;
return (title != NULL) ? 0 : VLC_ENOENT;
}
static int PlayerVoutSnapshot(struct cli_client *cl, const char *const *args,
@ -707,7 +707,7 @@ static int VideoConfig(struct cli_client *cl, const char *const *args,
if( psz_value == NULL )
{
vout_Release(p_vout);
return VLC_ENOVAR;
return VLC_ENOENT;
}
}
@ -772,7 +772,7 @@ static int AudioDevice(struct cli_client *cl, const char *const *args,
int ret = 0;
if (aout == NULL)
return VLC_ENOOBJ;
return VLC_ENOENT;
char **ids, **names;
int n = aout_DevicesList(aout, &ids, &names);
@ -836,7 +836,7 @@ static int AudioChannel(struct cli_client *cl, const char *const *args,
int ret = 0;
if ( p_aout == NULL )
return VLC_ENOOBJ;
return VLC_ENOENT;
if ( !*arg )
{
@ -933,7 +933,7 @@ static int Statistics(struct cli_client *cl, const char *const *args,
}
vlc_player_Unlock(player);
(void) args; (void) count;
return (item != NULL) ? 0 : VLC_ENOITEM;
return (item != NULL) ? 0 : VLC_ENOENT;
}
static int IsPlaying(struct cli_client *cl, const char *const *args,

2
modules/control/cli/playlist.c

@ -483,7 +483,7 @@ static int PlaylistMove(struct cli_client *cl, const char *const *args,
cli_printf(cl, vlc_ngettext("Playlist has only %zu element",
"Playlist has only %zu elements", size),
size);
ret = VLC_ENOITEM;
ret = VLC_ENOENT;
}
vlc_playlist_Unlock(playlist);
return ret;

4
modules/gui/macosx/library/VLCInputItem.m

@ -537,7 +537,7 @@ static const struct input_preparser_callbacks_t preparseCallbacks = {
- (int)preparseInputItem
{
if (!_vlcInputItem) {
return VLC_ENOVAR;
return VLC_ENOENT;
}
return libvlc_MetadataRequest(vlc_object_instance(getIntf()),
@ -558,7 +558,7 @@ static const struct input_preparser_callbacks_t preparseCallbacks = {
- (int)writeMetadataToFile
{
if (!_vlcInputItem) {
return VLC_ENOVAR;
return VLC_ENOENT;
}
return input_item_WriteMeta(VLC_OBJECT(getIntf()), _vlcInputItem);
}

2
modules/gui/macosx/library/VLCLibraryController.m

@ -90,7 +90,7 @@
input_item_t *p_inputItem = vlc_ml_get_input_item(_p_libraryInstance, mediaItem.libraryID);
if (!p_inputItem) {
msg_Err(getIntf(), "No input item found for media id %lli", mediaItem.libraryID);
return VLC_ENOITEM;
return VLC_ENOENT;
}
int ret = [[[VLCMain sharedInstance] playlistController] addInputItem:p_inputItem atPosition:-1 startPlayback:playImmediately];
input_item_Release(p_inputItem);

2
modules/gui/macosx/playlist/VLCPlayerController.m

@ -746,7 +746,7 @@ static int BossCallback(vlc_object_t *p_this,
- (int)setCurrentMedia:(VLCInputItem *)currentMedia
{
if (currentMedia == NULL) {
return VLC_ENOITEM;
return VLC_ENOENT;
}
vlc_player_Lock(_p_player);
int ret = vlc_player_SetCurrentMedia(_p_player, currentMedia.vlcInputItem);

4
modules/lua/libs/misc.c

@ -100,9 +100,7 @@ int vlclua_push_ret( lua_State *L, int i_error )
case VLC_ENOMEM: err = ENOMEM; break;
case VLC_ETIMEOUT: err = ETIMEDOUT; break;
case VLC_EINVAL: err = EINVAL; break;
case VLC_ENOMOD: err = ENOENT; break;
case VLC_ENOOBJ: err = ENOENT; break;
case VLC_ENOVAR: err = ENOENT; break;
case VLC_ENOENT: err = ENOENT; break;
case VLC_EGENERIC:
lua_pushstring( L, "generic error" );
return 2;

2
modules/lua/libs/playlist.c

@ -270,7 +270,7 @@ static int vlclua_playlist_gotoitem(lua_State *L)
vlc_playlist_Lock(playlist);
ssize_t index = vlc_playlist_IndexOfId(playlist, id);
if (index == -1)
ret = VLC_ENOITEM;
ret = VLC_ENOENT;
else
{
vlc_playlist_GoTo(playlist, index);

2
modules/stream_out/sdi/DBMSDIOutput.cpp

@ -651,7 +651,7 @@ int DBMSDIOutput::doSchedule()
StartPlayback();
}
return (bufferedFramesCount < bufferedFramesTarget) ? VLC_ENOITEM : VLC_SUCCESS;
return (bufferedFramesCount < bufferedFramesTarget) ? VLC_EGENERIC : VLC_SUCCESS;
}
int DBMSDIOutput::ProcessAudio(block_t *p_block)

2
modules/video_filter/opencv_wrapper.c

@ -182,7 +182,7 @@ static int Create( filter_t* p_filter )
vlc_object_delete(p_sys->p_opencv);
free( p_sys );
return VLC_ENOMOD;
return VLC_ENOENT;
}
assert( p_sys->p_opencv->ops != NULL );

10
src/misc/variables.c

@ -438,7 +438,7 @@ int (var_Change)(vlc_object_t *p_this, const char *psz_name, int i_action, ...)
if( p_var == NULL )
{
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR;
return VLC_ENOENT;
}
va_start(ap, i_action);
@ -608,7 +608,7 @@ int (var_GetAndSet)(vlc_object_t *p_this, const char *psz_name, int i_action,
if( p_var == NULL )
{
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR;
return VLC_ENOENT;
}
WaitUnused( p_this, p_var );
@ -689,7 +689,7 @@ int (var_SetChecked)(vlc_object_t *p_this, const char *psz_name,
if( p_var == NULL )
{
vlc_mutex_unlock( &p_priv->var_lock );
return VLC_ENOVAR;
return VLC_ENOENT;
}
assert( expected_type == 0 ||
@ -748,7 +748,7 @@ int (var_GetChecked)(vlc_object_t *p_this, const char *psz_name,
p_var->ops->pf_dup( p_val );
}
else
err = VLC_ENOVAR;
err = VLC_ENOENT;
vlc_mutex_unlock( &p_priv->var_lock );
return err;
@ -1067,7 +1067,7 @@ int var_Inherit( vlc_object_t *p_this, const char *psz_name, int i_type,
default:
vlc_assert_unreachable();
case VLC_VAR_ADDRESS:
return VLC_ENOOBJ;
return VLC_ENOENT;
}
return VLC_SUCCESS;
}

2
src/playlist/preparse.c

@ -70,7 +70,7 @@ vlc_playlist_ExpandItemFromNode(vlc_playlist_t *playlist,
input_item_t *media = subitems->p_item;
ssize_t index = vlc_playlist_IndexOfMedia(playlist, media);
if (index == -1)
return VLC_ENOITEM;
return VLC_ENOENT;
/* replace the item by its flatten subtree */
return vlc_playlist_ExpandItem(playlist, index, subitems);

6
test/src/misc/variables.c

@ -421,7 +421,7 @@ static void test_creation_and_type( libvlc_int_t *p_libvlc )
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOENT );
var_Create( p_libvlc, "program", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
assert( var_Type( p_libvlc, "program" ) == (VLC_VAR_INTEGER) );
@ -432,7 +432,7 @@ static void test_creation_and_type( libvlc_int_t *p_libvlc )
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOENT );
var_Create( p_libvlc, "bla", VLC_VAR_INTEGER );
assert( var_Create( p_libvlc, "bla", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ) == VLC_SUCCESS );
@ -441,7 +441,7 @@ static void test_creation_and_type( libvlc_int_t *p_libvlc )
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
var_Destroy( p_libvlc, "bla" );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOVAR );
assert( var_Get( p_libvlc, "bla", &val ) == VLC_ENOENT );
}
static void test_variables( libvlc_instance_t *p_vlc )

Loading…
Cancel
Save