Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Ewout ter Hoeven
VLC-Android
Commits
a45c0972
Commit
a45c0972
authored
Jun 23, 2012
by
Edward Wang
Browse files
Optimize the DirectoryAdapter a bit by not precaching if there are more than 6 subitems
parent
a62f1194
Changes
3
Hide whitespace changes
Inline
Side-by-side
vlc-android/jni/libvlcjni.c
View file @
a45c0972
...
...
@@ -18,8 +18,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include
<dirent.h>
#include
<errno.h>
#include
<string.h>
#include
<pthread.h>
#include
<sys/types.h>
#include
<vlc/vlc.h>
#include
<vlc_common.h>
...
...
@@ -945,3 +948,33 @@ jint Java_org_videolan_vlc_LibVLC_setSpuTrack(JNIEnv *env, jobject thiz, jint in
return
libvlc_video_set_spu
(
mp
,
index
);
return
-
1
;
}
jint
Java_org_videolan_vlc_LibVLC_nativeCountDirectoryContents
(
JNIEnv
*
env
,
jobject
thiz
,
jstring
path
)
{
jboolean
isCopy
;
/* Get C string */
const
char
*
psz_path
=
(
*
env
)
->
GetStringUTFChars
(
env
,
path
,
&
isCopy
);
jint
childrenCount
=
0
;
DIR
*
p_dir
=
opendir
(
psz_path
);
if
(
!
p_dir
)
return
0
;
struct
dirent
*
p_dirent
;
while
(
1
)
{
errno
=
0
;
p_dirent
=
readdir
(
p_dir
);
if
(
p_dirent
==
NULL
)
{
if
(
errno
>
0
)
/* error reading this entry */
continue
;
else
if
(
errno
==
0
)
/* end of stream */
break
;
}
childrenCount
++
;
}
closedir
(
p_dir
);
/* Clean up */
(
*
env
)
->
ReleaseStringUTFChars
(
env
,
path
,
psz_path
);
return
childrenCount
;
}
vlc-android/src/org/videolan/vlc/LibVLC.java
View file @
a45c0972
...
...
@@ -408,6 +408,8 @@ public class LibVLC {
public
native
String
nativeToURI
(
String
path
);
public
native
int
nativeCountDirectoryContents
(
String
path
);
/**
* Return the length of the stream, in milliseconds
*/
...
...
vlc-android/src/org/videolan/vlc/gui/DirectoryAdapter.java
View file @
a45c0972
...
...
@@ -151,10 +151,12 @@ public class DirectoryAdapter extends BaseAdapter {
if
(
files
[
i
].
isFile
())
nss
.
setIsFile
();
/*String mCurrentDir_old = mCurrentDir;
mCurrentDir = MRL;
this.populateNode(nss, MRL + "/" + nss.name);
mCurrentDir = mCurrentDir_old;*/
if
(
nss
.
isFile
()
&&
LibVLC
.
getExistingInstance
().
nativeCountDirectoryContents
(
MRL
+
"/"
+
nss
.
name
)
<
6
)
{
String
mCurrentDir_old
=
mCurrentDir
;
mCurrentDir
=
MRL
;
this
.
populateNode
(
nss
,
MRL
+
"/"
+
nss
.
name
);
mCurrentDir
=
mCurrentDir_old
;
}
n
.
children
.
add
(
nss
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment