Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Strogin
flac
Commits
81b3cae6
Commit
81b3cae6
authored
Dec 30, 2004
by
Josh Coalson
Browse files
revamp plugin_common to use utf-8 instead of wchar_t as the internal comment format
parent
d56ac595
Changes
11
Hide whitespace changes
Inline
Side-by-side
build/config.mk
View file @
81b3cae6
...
...
@@ -42,7 +42,7 @@ all default: $(DEFAULT_BUILD)
VERSION
=
\"
1.1.1
\"
CONFIG_CFLAGS
=
-D_GNU_SOURCE
-DHAVE_INTTYPES_H
-DHAVE_WCSDUP
-DHAVE_WCSCASECMP
-DFLAC__HAS_OGG
CONFIG_CFLAGS
=
-D_GNU_SOURCE
-DHAVE_INTTYPES_H
-DFLAC__HAS_OGG
OGG_INCLUDE_DIR
=
$(HOME)
/local/include
OGG_LIB_DIR
=
$(HOME)
/local/lib
configure.in
View file @
81b3cae6
...
...
@@ -21,9 +21,6 @@
AC_INIT(src/flac/main.c)
AM_INIT_AUTOMAKE(flac, 1.1.1)
dnl In order to have access to any available wcsdup() and wcscasecmp()
AC_GNU_SOURCE
# Don't automagically regenerate autoconf/automake generated files unless
# explicitly requested. Eases autobuilding -mdz
AM_MAINTAINER_MODE
...
...
@@ -43,9 +40,6 @@ dnl check for getopt in standard library
dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
AC_CHECK_FUNCS(getopt_long, [], [])
dnl Check for uncommon wide char functions
AC_CHECK_FUNCS(wcsdup, wcscasecmp, [], [])
AC_CANONICAL_HOST
case "$host_cpu" in
i*86) cpu_ia32=true ; AC_DEFINE(FLAC__CPU_IA32) ;;
...
...
include/FLAC/format.h
View file @
81b3cae6
...
...
@@ -585,13 +585,8 @@ typedef struct {
/** Vorbis comment entry structure used in VORBIS_COMMENT blocks. (c.f. <A HREF="../format.html#metadata_block_vorbis_comment">format specification</A>)
*
* For convenience, the APIs maintain a trailing NUL character at the end of
* \a entry which is not counted toward \a length or stored in the stream,
* i.e.
* \a entry which is not counted toward \a length, i.e.
* \code strlen(entry) == length \endcode
*
* It's recommended but not required for users to follow this convention as
* well when dealing directly with FLAC__StreamMetadata_VorbisComment_Entry
* as it makes dealing with plain strings easier.
*/
typedef
struct
{
FLAC__uint32
length
;
...
...
src/plugin_common/Makefile.am
View file @
81b3cae6
...
...
@@ -23,18 +23,16 @@ noinst_LTLIBRARIES = libplugin_common.la
noinst_HEADERS
=
\
all.h
\
canonical_tag.h
\
charset.h
\
defs.h
\
dither.h
\
locale_hack.h
\
vorbiscomment
.h
tags
.h
libplugin_common_la_SOURCES
=
\
canonical_tag.c
\
charset.c
\
dither.c
\
vorbiscomment
.c
tags
.c
EXTRA_DIST
=
\
Makefile.lite
\
...
...
src/plugin_common/Makefile.lite
View file @
81b3cae6
...
...
@@ -26,10 +26,9 @@ INCLUDES = -I$(topdir)/include -I$(HOME)/local/include
DEFINES
=
SRCS_C
=
\
canonical_tag.c
\
charset.c
\
dither.c
\
vorbiscomment
.c
tags
.c
include
$(topdir)/build/lib.mk
...
...
src/plugin_common/all.h
View file @
81b3cae6
...
...
@@ -19,10 +19,9 @@
#ifndef FLAC__PLUGIN_COMMON__ALL_H
#define FLAC__PLUGIN_COMMON__ALL_H
#include
"canonical_tag.h"
#include
"charset.h"
#include
"dither.h"
#include
"locale_hack.h"
#include
"
vorbiscomment
.h"
#include
"
tags
.h"
#endif
src/plugin_common/plugin_common_static.dsp
View file @
81b3cae6
...
...
@@ -85,10 +85,6 @@ LIB32=link.exe -lib
# PROP Default_Filter "cpp"
# Begin Source File
SOURCE=.\canonical_tag.c
# End Source File
# Begin Source File
SOURCE=.\charset.c
# End Source File
# Begin Source File
...
...
@@ -97,7 +93,7 @@ SOURCE=.\dither.c
# End Source File
# Begin Source File
SOURCE=.\
vorbiscomment
.c
SOURCE=.\
tags
.c
# End Source File
# End Group
# Begin Group "Public Header Files"
...
...
@@ -109,10 +105,6 @@ SOURCE=.\all.h
# End Source File
# Begin Source File
SOURCE=.\canonical_tag.h
# End Source File
# Begin Source File
SOURCE=.\charset.h
# End Source File
# Begin Source File
...
...
@@ -125,7 +117,7 @@ SOURCE=.\locale_hack.h
# End Source File
# Begin Source File
SOURCE=.\
vorbiscomment
.h
SOURCE=.\
tags
.h
# End Source File
# End Group
# End Target
...
...
src/plugin_winamp2/in_flac.c
View file @
81b3cae6
...
...
@@ -267,20 +267,20 @@ static DWORD WINAPI DecodeThread(void *unused)
static
const
T_CHAR
*
get_tag
(
const
T_CHAR
*
tag
,
void
*
param
)
{
FLAC_
Plugin__CanonicalTag
*
t
=
(
FLAC_Plugin__CanonicalTag
*
)
param
;
const
T_CHAR
*
val
=
FLAC_plugin__
canonical_get
(
t
,
tag
);
FLAC_
_StreamMetadata
*
tags
=
(
FLAC__StreamMetadata
*
)
param
;
const
T_CHAR
*
val
=
FLAC_plugin__
tags_get_tag_ucs2
(
tags
,
tag
);
/* some "user friendly cheavats" */
if
(
!
val
)
{
if
(
!
wcsicmp
(
tag
,
L"ARTIST"
))
{
val
=
FLAC_plugin__
canonical_get
(
t
,
L
"PERFORMER"
);
if
(
!
val
)
val
=
FLAC_plugin__
canonical_get
(
t
,
L"COMPOSER"
);
val
=
FLAC_plugin__
tags_get_tag_ucs2
(
tags
,
"PERFORMER"
);
if
(
!
val
)
val
=
FLAC_plugin__
tags_get_tag_ucs2
(
tags
,
L"COMPOSER"
);
}
else
if
(
!
wcsicmp
(
tag
,
L"YEAR"
)
||
!
wcsicmp
(
tag
,
L"DATE"
))
{
val
=
FLAC_plugin__
canonical_get
(
t
,
L"YEAR_RECORDED"
);
if
(
!
val
)
val
=
FLAC_plugin__
canonical_get
(
t
,
L"YEAR_PERFORMED"
);
val
=
FLAC_plugin__
tags_get_tag_ucs2
(
tags
,
L"YEAR_RECORDED"
);
if
(
!
val
)
val
=
FLAC_plugin__
tags_get_tag_ucs2
(
tags
,
L"YEAR_PERFORMED"
);
}
}
...
...
@@ -289,13 +289,13 @@ static const T_CHAR *get_tag(const T_CHAR *tag, void *param)
static
void
format_title
(
const
char
*
filename
,
WCHAR
*
title
,
unsigned
max_size
)
{
FLAC_
Plugin__CanonicalTag
tag
;
FLAC_
_StreamMetadata
*
tag
s
;
ReadTags
(
filename
,
&
tag
,
true
);
ReadTags
(
filename
,
&
tag
s
,
/*forDisplay=*/
true
);
tagz_format
(
flac_cfg
.
title
.
tag_format_w
,
get_tag
,
NULL
,
&
tag
,
title
,
max_size
);
tagz_format
(
flac_cfg
.
title
.
tag_format_w
,
get_tag
,
free
,
tag
s
,
title
,
max_size
);
FLAC_plugin__
canonical_tag_clear
(
&
tag
);
FLAC_plugin__
tags_destroy
(
&
tag
s
);
}
static
void
getfileinfo
(
char
*
filename
,
char
*
title
,
int
*
length_in_msec
)
...
...
src/plugin_winamp2/infobox.c
View file @
81b3cae6
...
...
@@ -28,10 +28,10 @@
typedef
struct
{
char
filename
[
MAX_PATH
];
FLAC_
Plugin__CanonicalTag
tag
;
FLAC_
_StreamMetadata
tag
s
;
}
LOCALDATA
;
static
char
buffer
[
1024
];
static
char
buffer
[
8192
];
static
char
*
genres
=
NULL
;
static
DWORD
genresSize
=
0
,
genresCount
=
0
;
static
BOOL
genresChanged
=
FALSE
,
isNT
;
...
...
@@ -174,27 +174,46 @@ static void DeinitGenres(HWND hwnd, BOOL final)
}
}
static
wchar_t
*
AnsiToWide
(
const
char
*
src
)
{
int
len
;
wchar_t
*
dest
;
FLAC__ASSERT
(
0
!=
src
);
len
=
strlen
(
src
)
+
1
;
/* copy */
dest
=
malloc
(
len
*
sizeof
(
wchar_t
));
if
(
dest
)
mbstowcs
(
dest
,
src
,
len
);
return
dest
;
}
/*
* Infobox helpers
*/
#define SetText(x,y) WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, FLAC_plugin__canonical_get(&data->tag, y), -1, buffer, sizeof(buffer), NULL, NULL); \
#define SetText(x,y) ucs2 = FLAC_plugin__tags_get_tag_ucs2(data->tags, y); \
WideCharToMultiByte
(
CP_ACP
,
WC_COMPOSITECHECK
,
ucs2
,
-
1
,
buffer
,
sizeof
(
buffer
),
NULL
,
NULL
);
\
if
(
ucs2
)
free
(
ucs2
);
\
SetDlgItemText
(
hwnd
,
x
,
buffer
)
#define GetText(x,y) GetDlgItemText(hwnd, x, buffer, sizeof(buffer)); \
if
(
*
buffer
)
FLAC_plugin__canonical_set_ansi
(
&
data
->
tag
,
y
,
buffer
);
\
else
FLAC_plugin__
canonical_remove_all
(
&
data
->
tag
,
y
)
if
(
*
buffer
)
{
ucs2
=
AnsiToWide
(
buffer
);
FLAC_plugin__tags_set_tag_ucs2
(
data
->
tag
s
,
y
,
ucs2
,
/*replace_all=*/
false
);
free
(
ucs2
);
}
\
else
FLAC_plugin__
tags_delete_tag
(
data
->
tag
s
,
y
)
#define SetTextW(x,y) SetDlgItemTextW(hwnd, x, FLAC_plugin__canonical_get(&data->tag, y))
#define SetTextW(x,y) ucs2 = FLAC_plugin__tags_get_tag_ucs2(data->tags, y))
;
\
SetDlgItemTextW
(
hwnd
,
x
,
ucs2
);
\
free
(
ucs2
)
#define GetTextW(x,y) GetDlgItemTextW(hwnd, x, (WCHAR*)buffer, sizeof(buffer)/2); \
if
(
*
(
WCHAR
*
)
buffer
)
FLAC_plugin__
canonical_set
(
&
data
->
tag
,
y
,
(
WCHAR
*
)
buffer
);
\
else
FLAC_plugin__
canonical_remove_all
(
&
data
->
tag
,
y
)
if
(
*
(
WCHAR
*
)
buffer
)
FLAC_plugin__
tags_set_tag_ucs2
(
data
->
tag
s
,
y
,
(
WCHAR
*
)
buffer
,
/*replace_all=*/
false
);
\
else
FLAC_plugin__
tags_delete_tag
(
data
->
tag
s
,
y
)
static
BOOL
InitInfoboxInfo
(
HWND
hwnd
,
const
char
*
file
)
{
LOCALDATA
*
data
=
LocalAlloc
(
LPTR
,
sizeof
(
LOCALDATA
));
wchar_t
*
ucs2
;
FLAC__StreamMetadata
streaminfo
;
DWORD
length
,
bps
,
ratio
,
rg
;
LONGLONG
filesize
;
...
...
@@ -208,13 +227,13 @@ static BOOL InitInfoboxInfo(HWND hwnd, const char *file)
if
(
!
filesize
)
return
FALSE
;
if
(
!
FLAC__metadata_get_streaminfo
(
file
,
&
streaminfo
))
return
FALSE
;
ReadTags
(
file
,
&
data
->
tag
,
false
);
ReadTags
(
file
,
&
data
->
tag
s
,
false
);
length
=
(
DWORD
)(
streaminfo
.
data
.
stream_info
.
total_samples
/
streaminfo
.
data
.
stream_info
.
sample_rate
);
bps
=
(
DWORD
)(
filesize
/
(
125
*
streaminfo
.
data
.
stream_info
.
total_samples
/
streaminfo
.
data
.
stream_info
.
sample_rate
));
ratio
=
bps
*
1000000
/
(
streaminfo
.
data
.
stream_info
.
sample_rate
*
streaminfo
.
data
.
stream_info
.
channels
*
streaminfo
.
data
.
stream_info
.
bits_per_sample
);
rg
=
FLAC_plugin__
canonical_get
(
&
data
->
tag
,
L"REPLAYGAIN_TRACK_GAIN"
)
?
1
:
0
;
rg
|=
FLAC_plugin__
canonical_get
(
&
data
->
tag
,
L"REPLAYGAIN_ALBUM_GAIN"
)
?
2
:
0
;
rg
=
FLAC_plugin__
tags_get_tag_utf8
(
data
->
tag
s
,
L"REPLAYGAIN_TRACK_GAIN"
)
?
1
:
0
;
rg
|=
FLAC_plugin__
tags_get_tag_utf8
(
data
->
tag
s
,
L"REPLAYGAIN_ALBUM_GAIN"
)
?
2
:
0
;
sprintf
(
buffer
,
"Sample rate: %d Hz
\n
Channels: %d
\n
Bits per sample: %d
\n
Min block size: %d
\n
Max block size: %d
\n
"
"File size: %I64d bytes
\n
Total samples: %I64d
\n
Length: %d:%02d
\n
Avg. bitrate: %d
\n
Compression ratio: %d.%d%%
\n
"
...
...
@@ -228,33 +247,33 @@ static BOOL InitInfoboxInfo(HWND hwnd, const char *file)
/* tag */
if
(
isNT
)
{
SetTextW
(
IDC_TITLE
,
L
"TITLE"
);
SetTextW
(
IDC_ARTIST
,
L
"ARTIST"
);
SetTextW
(
IDC_ALBUM
,
L
"ALBUM"
);
SetTextW
(
IDC_COMMENT
,
L
"COMMENT"
);
SetTextW
(
IDC_YEAR
,
L
"DATE"
);
SetTextW
(
IDC_TRACK
,
L
"TRACKNUMBER"
);
SetTextW
(
IDC_GENRE
,
L
"GENRE"
);
SetTextW
(
IDC_TITLE
,
"TITLE"
);
SetTextW
(
IDC_ARTIST
,
"ARTIST"
);
SetTextW
(
IDC_ALBUM
,
"ALBUM"
);
SetTextW
(
IDC_COMMENT
,
"COMMENT"
);
SetTextW
(
IDC_YEAR
,
"DATE"
);
SetTextW
(
IDC_TRACK
,
"TRACKNUMBER"
);
SetTextW
(
IDC_GENRE
,
"GENRE"
);
}
else
{
SetText
(
IDC_TITLE
,
L
"TITLE"
);
SetText
(
IDC_ARTIST
,
L
"ARTIST"
);
SetText
(
IDC_ALBUM
,
L
"ALBUM"
);
SetText
(
IDC_COMMENT
,
L
"COMMENT"
);
SetText
(
IDC_YEAR
,
L
"DATE"
);
SetText
(
IDC_TRACK
,
L
"TRACKNUMBER"
);
SetText
(
IDC_GENRE
,
L
"GENRE"
);
SetText
(
IDC_TITLE
,
"TITLE"
);
SetText
(
IDC_ARTIST
,
"ARTIST"
);
SetText
(
IDC_ALBUM
,
"ALBUM"
);
SetText
(
IDC_COMMENT
,
"COMMENT"
);
SetText
(
IDC_YEAR
,
"DATE"
);
SetText
(
IDC_TRACK
,
"TRACKNUMBER"
);
SetText
(
IDC_GENRE
,
"GENRE"
);
}
return
TRUE
;
}
static
void
__inline
SetTag
(
HWND
hwnd
,
const
char
*
filename
,
FLAC_
Plugin__CanonicalTag
*
tag
)
static
void
__inline
SetTag
(
HWND
hwnd
,
const
char
*
filename
,
FLAC_
_StreamMetadata
*
tag
s
)
{
strcpy
(
buffer
,
infoTitle
);
if
(
FLAC_plugin__
vorbiscomment
_set
(
filename
,
tag
))
if
(
FLAC_plugin__
tags
_set
(
filename
,
tag
s
))
strcat
(
buffer
,
" [Updated]"
);
else
strcat
(
buffer
,
" [Failed]"
);
...
...
@@ -264,42 +283,45 @@ static void __inline SetTag(HWND hwnd, const char *filename, FLAC_Plugin__Canoni
static
void
UpdateTag
(
HWND
hwnd
)
{
LOCALDATA
*
data
=
(
LOCALDATA
*
)
GetWindowLong
(
hwnd
,
GWL_USERDATA
);
wchar_t
*
ucs2
;
/* get fields */
if
(
isNT
)
{
GetTextW
(
IDC_TITLE
,
L"TITLE"
);
GetTextW
(
IDC_ARTIST
,
L"ARTIST"
);
GetTextW
(
IDC_ALBUM
,
L"ALBUM"
);
GetTextW
(
IDC_COMMENT
,
L"COMMENT"
);
GetTextW
(
IDC_YEAR
,
L"DATE"
);
GetTextW
(
IDC_TRACK
,
L"TRACKNUMBER"
);
GetTextW
(
IDC_GENRE
,
L"GENRE"
);
WideCharToMultiByte
(
CP_ACP
,
WC_COMPOSITECHECK
,
FLAC_plugin__canonical_get
(
&
data
->
tag
,
L"GENRE"
),
-
1
,
buffer
,
sizeof
(
buffer
),
NULL
,
NULL
);
GetTextW
(
IDC_TITLE
,
"TITLE"
);
GetTextW
(
IDC_ARTIST
,
"ARTIST"
);
GetTextW
(
IDC_ALBUM
,
"ALBUM"
);
GetTextW
(
IDC_COMMENT
,
"COMMENT"
);
GetTextW
(
IDC_YEAR
,
"DATE"
);
GetTextW
(
IDC_TRACK
,
"TRACKNUMBER"
);
GetTextW
(
IDC_GENRE
,
"GENRE"
);
ucs2
=
FLAC_plugin__tags_get_tag_ucs2
(
data
->
tags
,
"GENRE"
);
WideCharToMultiByte
(
CP_ACP
,
WC_COMPOSITECHECK
,
ucs2
,
-
1
,
buffer
,
sizeof
(
buffer
),
NULL
,
NULL
);
free
(
ucs2
);
}
else
{
GetText
(
IDC_TITLE
,
L
"TITLE"
);
GetText
(
IDC_ARTIST
,
L
"ARTIST"
);
GetText
(
IDC_ALBUM
,
L
"ALBUM"
);
GetText
(
IDC_COMMENT
,
L
"COMMENT"
);
GetText
(
IDC_YEAR
,
L
"DATE"
);
GetText
(
IDC_TRACK
,
L
"TRACKNUMBER"
);
GetText
(
IDC_GENRE
,
L
"GENRE"
);
GetText
(
IDC_TITLE
,
"TITLE"
);
GetText
(
IDC_ARTIST
,
"ARTIST"
);
GetText
(
IDC_ALBUM
,
"ALBUM"
);
GetText
(
IDC_COMMENT
,
"COMMENT"
);
GetText
(
IDC_YEAR
,
"DATE"
);
GetText
(
IDC_TRACK
,
"TRACKNUMBER"
);
GetText
(
IDC_GENRE
,
"GENRE"
);
}
/* update genres list (buffer should contain genre) */
if
(
buffer
[
0
])
AddGenre
(
hwnd
,
buffer
);
/* write tag */
SetTag
(
hwnd
,
data
->
filename
,
&
data
->
tag
);
SetTag
(
hwnd
,
data
->
filename
,
data
->
tag
s
);
}
static
void
RemoveTag
(
HWND
hwnd
)
{
LOCALDATA
*
data
=
(
LOCALDATA
*
)
GetWindowLong
(
hwnd
,
GWL_USERDATA
);
FLAC_plugin__
canonical_tag_clear
(
&
data
->
tag
);
FLAC_plugin__
tags_delete_all
(
data
->
tag
s
);
SetDlgItemText
(
hwnd
,
IDC_TITLE
,
""
);
SetDlgItemText
(
hwnd
,
IDC_ARTIST
,
""
);
...
...
@@ -309,7 +331,7 @@ static void RemoveTag(HWND hwnd)
SetDlgItemText
(
hwnd
,
IDC_TRACK
,
""
);
SetDlgItemText
(
hwnd
,
IDC_GENRE
,
""
);
SetTag
(
hwnd
,
data
->
filename
,
&
data
->
tag
);
SetTag
(
hwnd
,
data
->
filename
,
data
->
tag
s
);
}
...
...
@@ -329,7 +351,7 @@ static INT_PTR CALLBACK InfoProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
case
WM_DESTROY
:
{
LOCALDATA
*
data
=
(
LOCALDATA
*
)
GetWindowLong
(
hwnd
,
GWL_USERDATA
);
FLAC_plugin__
canonical_tag_clear
(
&
data
->
tag
);
FLAC_plugin__
tags_destroy
(
&
data
->
tag
s
);
LocalFree
(
data
);
DeinitGenres
(
hwnd
,
FALSE
);
}
...
...
@@ -390,20 +412,25 @@ static __inline char *GetFileName(const char *fullname)
return
(
char
*
)
c
;
}
void
ReadTags
(
const
char
*
fileName
,
FLAC_
Plugin__CanonicalTag
*
tag
,
BOOL
forDisplay
)
void
ReadTags
(
const
char
*
fileName
,
FLAC_
_StreamMetadata
*
*
tag
s
,
BOOL
forDisplay
)
{
FLAC_plugin__canonical_tag_init
(
tag
);
FLAC_plugin__vorbiscomment_get
(
fileName
,
tag
,
forDisplay
?
flac_cfg
.
title
.
sep
:
NULL
);
if
(
FLAC_plugin__tags_get
(
fileName
,
tags
,
forDisplay
?
flac_cfg
.
title
.
sep
:
NULL
))
{
/* add file name */
if
(
forDisplay
)
{
char
*
c
;
FLAC_plugin__canonical_set_ansi
(
tag
,
L"filepath"
,
fileName
);
strcpy
(
buffer
,
GetFileName
(
fileName
));
if
(
c
=
strrchr
(
buffer
,
'.'
))
*
c
=
0
;
FLAC_plugin__canonical_set_ansi
(
tag
,
L"filename"
,
buffer
);
/* add file name */
if
(
forDisplay
)
{
char
*
c
;
wchar_t
*
ucs2
;
ucs2
=
AnsiToWide
(
fileName
);
FLAC_plugin__tags_set_tag_ucs2
(
*
tags
,
"filepath"
,
ucs2
);
free
(
ucs2
);
strcpy
(
buffer
,
GetFileName
(
fileName
));
if
(
c
=
strrchr
(
buffer
,
'.'
))
*
c
=
0
;
ucs2
=
AnsiToWide
(
buffer
);
FLAC_plugin__tags_set_tag_ucs2
(
*
tags
,
"filename"
,
ucs2
);
free
(
ucs2
);
}
}
}
...
...
src/plugin_xmms/fileinfo.c
View file @
81b3cae6
...
...
@@ -29,7 +29,7 @@
#include
"FLAC/metadata.h"
#include
"charset.h"
#include
"configure.h"
#include
"plugin_common/
vorbiscomment
.h"
#include
"plugin_common/
tags
.h"
#include
"plugin_common/locale_hack.h"
static
GtkWidget
*
window
=
NULL
;
...
...
@@ -40,7 +40,7 @@ static GtkWidget *genre_combo;
static
GtkWidget
*
flac_samplerate
,
*
flac_channels
,
*
flac_bits_per_sample
,
*
flac_blocksize
,
*
flac_filesize
,
*
flac_samples
,
*
flac_bitrate
;
static
gchar
*
current_filename
=
NULL
;
static
FLAC_
Plugin__CanonicalTag
*
canonical_
tag
=
NULL
;
static
FLAC_
_StreamMetadata
*
tag
s_
=
NULL
;
static
const
gchar
*
vorbis_genres
[]
=
{
...
...
@@ -102,20 +102,16 @@ static void label_set_text(GtkWidget * label, char *str, ...)
g_free
(
tempstr
);
}
static
void
set_entry_tag
(
GtkEntry
*
entry
,
const
w
char
_t
*
tag
)
static
void
set_entry_tag
(
GtkEntry
*
entry
,
const
char
*
utf8
)
{
if
(
tag
)
{
char
*
utf8
=
FLAC_plugin__convert_ucs2_to_utf8
(
tag
);
if
(
utf8
)
{
if
(
flac_cfg
.
title
.
convert_char_set
)
{
char
*
text
=
convert_from_utf8_to_user
(
utf8
);
gtk_entry_set_text
(
entry
,
text
);
free
(
text
);
}
else
{
else
gtk_entry_set_text
(
entry
,
utf8
);
}
free
(
utf8
);
}
else
gtk_entry_set_text
(
entry
,
""
);
...
...
@@ -134,7 +130,7 @@ static void get_entry_tag(GtkEntry * entry, const char *name)
else
utf8
=
text
;
FLAC_plugin__
canonical
_add_utf8
(
canonical_
tag
,
name
,
utf8
,
(
unsigned
)(
-
1
),
(
unsigned
)(
-
1
),
/*sep
=*/
0
);
FLAC_plugin__
tags
_add_
tag_
utf8
(
tag
s_
,
name
,
utf8
,
/*separator
=*/
0
);
if
(
flac_cfg
.
title
.
convert_char_set
)
free
(
utf8
);
...
...
@@ -142,13 +138,13 @@ static void get_entry_tag(GtkEntry * entry, const char *name)
static
void
show_tag
()
{
set_entry_tag
(
GTK_ENTRY
(
title_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"TITLE"
));
set_entry_tag
(
GTK_ENTRY
(
artist_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"ARTIST"
));
set_entry_tag
(
GTK_ENTRY
(
album_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"ALBUM"
));
set_entry_tag
(
GTK_ENTRY
(
date_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"DATE"
));
set_entry_tag
(
GTK_ENTRY
(
tracknum_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"TRACKNUMBER"
));
set_entry_tag
(
GTK_ENTRY
(
comment_entry
)
,
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"DESCRIPTION"
));
set_entry_tag
(
GTK_ENTRY
(
GTK_COMBO
(
genre_combo
)
->
entry
),
FLAC_plugin__
canonical_get
(
canonical_
tag
,
L
"GENRE"
));
set_entry_tag
(
GTK_ENTRY
(
title_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"TITLE"
));
set_entry_tag
(
GTK_ENTRY
(
artist_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"ARTIST"
));
set_entry_tag
(
GTK_ENTRY
(
album_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"ALBUM"
));
set_entry_tag
(
GTK_ENTRY
(
date_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"DATE"
));
set_entry_tag
(
GTK_ENTRY
(
tracknum_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"TRACKNUMBER"
));
set_entry_tag
(
GTK_ENTRY
(
comment_entry
)
,
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"DESCRIPTION"
));
set_entry_tag
(
GTK_ENTRY
(
GTK_COMBO
(
genre_combo
)
->
entry
),
FLAC_plugin__
tags_get_tag_utf8
(
tag
s_
,
"GENRE"
));
}
static
void
save_tag
(
GtkWidget
*
w
,
gpointer
data
)
...
...
@@ -156,13 +152,13 @@ static void save_tag(GtkWidget * w, gpointer data)
(
void
)
w
;
(
void
)
data
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"TITLE"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"ARTIST"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"ALBUM"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"DATE"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_
tag
,
L
"TRACKNUMBER"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_
tag
,
L
"DESCRIPTION"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"GENRE"
)
)
;
FLAC_plugin__
tags_delete_tag
(
tags_
,
"TITLE"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"ARTIST"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"ALBUM"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"DATE"
);
FLAC_plugin__
tags_delete_tag
(
tag
s_
,
"TRACKNUMBER"
);
FLAC_plugin__
tags_delete_tag
(
tag
s_
,
"DESCRIPTION"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"GENRE"
);
get_entry_tag
(
GTK_ENTRY
(
title_entry
)
,
"TITLE"
);
get_entry_tag
(
GTK_ENTRY
(
artist_entry
)
,
"ARTIST"
);
...
...
@@ -172,7 +168,7 @@ static void save_tag(GtkWidget * w, gpointer data)
get_entry_tag
(
GTK_ENTRY
(
comment_entry
)
,
"DESCRIPTION"
);
get_entry_tag
(
GTK_ENTRY
(
GTK_COMBO
(
genre_combo
)
->
entry
),
"GENRE"
);
FLAC_plugin__
vorbiscomment
_set
(
current_filename
,
canonical_
tag
);
FLAC_plugin__
tags
_set
(
current_filename
,
tag
s_
);
gtk_widget_destroy
(
window
);
}
...
...
@@ -181,15 +177,15 @@ static void remove_tag(GtkWidget * w, gpointer data)
(
void
)
w
;
(
void
)
data
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"TITLE"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"ARTIST"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"ALBUM"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"DATE"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_
tag
,
L
"TRACKNUMBER"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_
tag
,
L
"DESCRIPTION"
)
)
;
while
(
FLAC_plugin__
canonical_remove
(
canonical_tag
,
L
"GENRE"
)
)
;
FLAC_plugin__
vorbiscomment
_set
(
current_filename
,
canonical_
tag
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"TITLE"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"ARTIST"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"ALBUM"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"DATE"
);
FLAC_plugin__
tags_delete_tag
(
tag
s_
,
"TRACKNUMBER"
);
FLAC_plugin__
tags_delete_tag
(
tag
s_
,
"DESCRIPTION"
);
FLAC_plugin__
tags_delete_tag
(
tags_
,
"GENRE"
);
FLAC_plugin__
tags
_set
(
current_filename
,
tag
s_
);
gtk_widget_destroy
(
window
);
}
...
...
@@ -416,12 +412,10 @@ void FLAC_XMMS__file_info_box(char *filename)
gtk_entry_set_text
(
GTK_ENTRY
(
filename_entry
),
filename
);
gtk_editable_set_position
(
GTK_EDITABLE
(
filename_entry
),
-
1
);
if
(
canonical_tag
)
FLAC_plugin__canonical_tag_clear
(
canonical_tag
);
else
canonical_tag
=
FLAC_plugin__canonical_tag_new
();
if
(
tags_
)
FLAC_plugin__tags_destroy
(
&
tags_
);
FLAC_plugin__
vorbiscomment
_get
(
current_filename
,
canonical_tag
,
/*sep=*/
0
);
FLAC_plugin__
tags
_get
(
current_filename
,
&
tags_
);
show_tag
();
show_file_info
();
...
...
src/plugin_xmms/tag.c
View file @
81b3cae6
...
...
@@ -29,8 +29,7 @@
#include
<xmms/titlestring.h>
#include
"FLAC/metadata.h"
#include
"plugin_common/canonical_tag.h"
#include
"plugin_common/vorbiscomment.h"
#include
"plugin_common/tags.h"
#include
"charset.h"
#include
"configure.h"
...
...
@@ -65,21 +64,19 @@ static int local__getnum(char* str)
return
0
;
}
static
char
*
local__getfield
(
FLAC_Plugin__CanonicalTag
*
tag
,
const
w
char
_t
*
name
)
static
char
*
local__getfield
(
const
FLAC__StreamMetadata
*
tag
s
,
const
char
*
name
)
{
const
wchar_t
*
ucs2
=
FLAC_plugin__canonical_get
(
tag
,
name
);
if
(
0
!=
ucs2
)
{
char
*
utf8
=
FLAC_plugin__convert_ucs2_to_utf8
(
FLAC_plugin__canonical_get
(
tag
,
name
));
if
(
flac_cfg
.
title
.
convert_char_set
)
{
char
*
user
=
convert_from_utf8_to_user
(
utf8
);
free
(
utf8
);
return
user
;
if
(
0
!=
tags
)
{
const
char
*
utf8
=
FLAC_plugin__tags_get_tag_utf8
(
tags
,
name
);
if
(
0
!=
utf8
)
{
if
(
flac_cfg
.
title
.
convert_char_set
)
return
convert_from_utf8_to_user
(
utf8
);
else
return
strdup
(
utf8
)
;
}
else