Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
37c3eadc
Commit
37c3eadc
authored
Nov 26, 2003
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Merged sort functions
* Added a randomize playlist function
parent
380edbae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
85 deletions
+53
-85
include/vlc_playlist.h
include/vlc_playlist.h
+11
-4
modules/gui/wxwindows/playlist.cpp
modules/gui/wxwindows/playlist.cpp
+12
-4
src/playlist/sort.c
src/playlist/sort.c
+30
-77
No files found.
include/vlc_playlist.h
View file @
37c3eadc
...
...
@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: vlc_playlist.h,v 1.1
6 2003/11/12 08:10
:21 zorglub Exp $
* $Id: vlc_playlist.h,v 1.1
7 2003/11/26 10:45
:21 zorglub Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
...
...
@@ -96,6 +96,11 @@ struct playlist_t
/*@}*/
};
#define SORT_TITLE 0
#define SORT_AUTHOR 1
#define SORT_GROUP 2
#define SORT_RANDOM 3
#define SORT_NORMAL 0
#define SORT_REVERSE 1
...
...
@@ -132,9 +137,11 @@ VLC_EXPORT( int, playlist_DeleteGroup, (playlist_t *, int ) );
VLC_EXPORT
(
char
*
,
playlist_FindGroup
,
(
playlist_t
*
,
int
)
);
VLC_EXPORT
(
int
,
playlist_GroupToId
,
(
playlist_t
*
,
char
*
)
);
VLC_EXPORT
(
int
,
playlist_SortTitle
,
(
playlist_t
*
,
int
)
);
VLC_EXPORT
(
int
,
playlist_SortAuthor
,
(
playlist_t
*
,
int
)
);
VLC_EXPORT
(
int
,
playlist_SortGroup
,
(
playlist_t
*
,
int
)
);
#define playlist_SortTitle(p, i) playlist_Sort( p, SORT_TITLE, i)
#define playlist_SortAuthor(p, i) playlist_Sort( p, SORT_AUTHOR, i)
#define playlist_SortGroup(p, i) playlist_Sort( p, SORT_GROUP, i)
VLC_EXPORT
(
int
,
playlist_Sort
,
(
playlist_t
*
,
int
,
int
)
);
VLC_EXPORT
(
int
,
playlist_Move
,
(
playlist_t
*
,
int
,
int
)
);
VLC_EXPORT
(
int
,
playlist_LoadFile
,
(
playlist_t
*
,
const
char
*
)
);
...
...
modules/gui/wxwindows/playlist.cpp
View file @
37c3eadc
...
...
@@ -2,7 +2,7 @@
* playlist.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: playlist.cpp,v 1.2
6 2003/11/21 18:55:40 gbazin
Exp $
* $Id: playlist.cpp,v 1.2
7 2003/11/26 10:45:21 zorglub
Exp $
*
* Authors: Olivier Teulire <ipkiss@via.ecp.fr>
*
...
...
@@ -59,6 +59,7 @@ enum
RSortAuthor_Event
,
SortGroup_Event
,
RSortGroup_Event
,
Randomize_Event
,
EnableSelection_Event
,
DisableSelection_Event
,
...
...
@@ -99,6 +100,8 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame)
EVT_MENU
(
SortGroup_Event
,
Playlist
::
OnSort
)
EVT_MENU
(
RSortGroup_Event
,
Playlist
::
OnSort
)
EVT_MENU
(
Randomize_Event
,
Playlist
::
OnSort
)
EVT_MENU
(
EnableSelection_Event
,
Playlist
::
OnEnableSelection
)
EVT_MENU
(
DisableSelection_Event
,
Playlist
::
OnDisableSelection
)
EVT_MENU
(
InvertSelection_Event
,
Playlist
::
OnInvertSelection
)
...
...
@@ -180,14 +183,16 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
/* Create our "Sort" menu */
wxMenu
*
sort_menu
=
new
wxMenu
;
sort_menu
->
Append
(
SortTitle_Event
,
wxU
(
_
(
"
&Sort by
title"
))
);
sort_menu
->
Append
(
SortTitle_Event
,
wxU
(
_
(
"
Sort by &
title"
))
);
sort_menu
->
Append
(
RSortTitle_Event
,
wxU
(
_
(
"&Reverse sort by title"
))
);
sort_menu
->
AppendSeparator
();
sort_menu
->
Append
(
SortAuthor_Event
,
wxU
(
_
(
"
&Sort by
author"
))
);
sort_menu
->
Append
(
SortAuthor_Event
,
wxU
(
_
(
"
Sort by &
author"
))
);
sort_menu
->
Append
(
RSortAuthor_Event
,
wxU
(
_
(
"&Reverse sort by author"
))
);
sort_menu
->
AppendSeparator
();
sort_menu
->
Append
(
SortGroup_Event
,
wxU
(
_
(
"
&Sort by
group"
))
);
sort_menu
->
Append
(
SortGroup_Event
,
wxU
(
_
(
"
Sort by &
group"
))
);
sort_menu
->
Append
(
RSortGroup_Event
,
wxU
(
_
(
"&Reverse sort by group"
))
);
sort_menu
->
AppendSeparator
();
sort_menu
->
Append
(
Randomize_Event
,
wxU
(
_
(
"&Randomize Playlist"
))
);
/* Create our "Selection" menu */
wxMenu
*
selection_menu
=
new
wxMenu
;
...
...
@@ -661,6 +666,9 @@ void Playlist::OnSort( wxCommandEvent& event )
case
RSortGroup_Event
:
playlist_SortGroup
(
p_playlist
,
1
);
break
;
case
Randomize_Event
:
playlist_Sort
(
p_playlist
,
SORT_RANDOM
,
SORT_NORMAL
);
break
;
}
vlc_object_release
(
p_playlist
);
...
...
src/playlist/sort.c
View file @
37c3eadc
...
...
@@ -2,7 +2,7 @@
* sort.c : Playlist sorting functions
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: sort.c,v 1.
1 2003/10/29 18:00:46
zorglub Exp $
* $Id: sort.c,v 1.
2 2003/11/26 10:45:21
zorglub Exp $
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
...
...
@@ -31,109 +31,62 @@
#include "vlc_playlist.h"
/**
* Sort the playlist
by title
* Sort the playlist
* \param p_playlist the playlist
* \param i_mode: SORT_TITLE, SORT_GROUP, SORT_AUTHOR, SORT_RANDOM
* \param i_type: SORT_NORMAL or SORT_REVERSE (reversed order)
* \return 0 on success
*/
int
playlist_Sort
Title
(
playlist_t
*
p_playlist
,
int
i_type
)
int
playlist_Sort
(
playlist_t
*
p_playlist
,
int
i_mode
,
int
i_type
)
{
int
i
,
i_small
,
i_position
;
playlist_item_t
*
p_temp
;
vlc_mutex_lock
(
&
p_playlist
->
object_lock
);
for
(
i_position
=
0
;
i_position
<
p_playlist
->
i_size
-
1
;
i_position
++
)
if
(
i_mode
==
SORT_RANDOM
)
{
i_small
=
i_position
;
for
(
i
=
i_position
+
1
;
i
<
p_playlist
->
i_size
;
i
++
)
for
(
i_position
=
0
;
i_position
<
p_playlist
->
i_size
;
i_position
++
)
{
int
i_
test
;
int
i_
new
=
rand
()
%
(
p_playlist
->
i_size
-
1
)
;
i_test
=
strcasecmp
(
p_playlist
->
pp_items
[
i
]
->
psz_name
,
p_playlist
->
pp_items
[
i_small
]
->
psz_name
);
/* Keep the correct current index */
if
(
i_new
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_position
;
else
if
(
i_position
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_new
;
if
(
(
i_type
==
SORT_NORMAL
&&
i_test
<
0
)
||
(
i_type
==
SORT_REVERSE
&&
i_test
>
0
)
)
{
i_small
=
i
;
}
p_temp
=
p_playlist
->
pp_items
[
i_position
];
p_playlist
->
pp_items
[
i_position
]
=
p_playlist
->
pp_items
[
i_new
];
p_playlist
->
pp_items
[
i_new
]
=
p_temp
;
}
/* Keep the correct current index */
if
(
i_small
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_position
;
else
if
(
i_position
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_small
;
vlc_mutex_unlock
(
&
p_playlist
->
object_lock
);
p_temp
=
p_playlist
->
pp_items
[
i_position
];
p_playlist
->
pp_items
[
i_position
]
=
p_playlist
->
pp_items
[
i_small
];
p_playlist
->
pp_items
[
i_small
]
=
p_temp
;
return
0
;
}
vlc_mutex_unlock
(
&
p_playlist
->
object_lock
);
return
0
;
}
/**
* Sort the playlist by author
* \param p_playlist the playlist
* \param i_type: SORT_NORMAL or SORT_REVERSE (reversed order)
* \return 0 on success
*/
int
playlist_SortAuthor
(
playlist_t
*
p_playlist
,
int
i_type
)
{
int
i
,
i_small
,
i_position
;
playlist_item_t
*
p_temp
;
vlc_mutex_lock
(
&
p_playlist
->
object_lock
);
for
(
i_position
=
0
;
i_position
<
p_playlist
->
i_size
-
1
;
i_position
++
)
{
i_small
=
i_position
;
for
(
i
=
i_position
+
1
;
i
<
p_playlist
->
i_size
;
i
++
)
{
int
i_test
;
int
i_test
=
0
;
i_test
=
strcasecmp
(
p_playlist
->
pp_items
[
i
]
->
psz_author
,
p_playlist
->
pp_items
[
i_small
]
->
psz_author
);
if
(
(
i_type
==
SORT_NORMAL
&&
i_test
<
0
)
||
(
i_type
==
SORT_REVERSE
&&
i_test
>
0
)
)
if
(
i_mode
==
SORT_TITLE
)
{
i_small
=
i
;
i_test
=
strcasecmp
(
p_playlist
->
pp_items
[
i
]
->
psz_name
,
p_playlist
->
pp_items
[
i_small
]
->
psz_name
);
}
}
/* Keep the correct current index */
if
(
i_small
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_position
;
else
if
(
i_position
==
p_playlist
->
i_index
)
p_playlist
->
i_index
=
i_small
;
p_temp
=
p_playlist
->
pp_items
[
i_position
];
p_playlist
->
pp_items
[
i_position
]
=
p_playlist
->
pp_items
[
i_small
];
p_playlist
->
pp_items
[
i_small
]
=
p_temp
;
}
vlc_mutex_unlock
(
&
p_playlist
->
object_lock
);
return
0
;
}
int
playlist_SortGroup
(
playlist_t
*
p_playlist
,
int
i_type
)
{
int
i
,
i_small
,
i_position
;
playlist_item_t
*
p_temp
;
vlc_mutex_lock
(
&
p_playlist
->
object_lock
);
for
(
i_position
=
0
;
i_position
<
p_playlist
->
i_size
-
1
;
i_position
++
)
{
i_small
=
i_position
;
for
(
i
=
i_position
+
1
;
i
<
p_playlist
->
i_size
;
i
++
)
{
int
i_test
;
i_test
=
p_playlist
->
pp_items
[
i
]
->
i_group
-
else
if
(
i_mode
==
SORT_GROUP
)
{
i_test
=
p_playlist
->
pp_items
[
i
]
->
i_group
-
p_playlist
->
pp_items
[
i_small
]
->
i_group
;
}
else
if
(
i_mode
==
SORT_AUTHOR
)
{
i_test
=
strcasecmp
(
p_playlist
->
pp_items
[
i
]
->
psz_author
,
p_playlist
->
pp_items
[
i_small
]
->
psz_author
);
}
if
(
(
i_type
==
SORT_NORMAL
&&
i_test
<
0
)
||
(
i_type
==
SORT_REVERSE
&&
i_test
>
0
)
)
...
...
Write
Preview
Markdown
is supported
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