Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
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-gpu
Commits
a127a089
Commit
a127a089
authored
Feb 24, 2009
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up/Fix memleak in CDDB code for our cdda access.
parent
87513511
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
45 deletions
+52
-45
modules/access/cdda.c
modules/access/cdda.c
+52
-45
No files found.
modules/access/cdda.c
View file @
a127a089
...
@@ -117,10 +117,6 @@ struct access_sys_t
...
@@ -117,10 +117,6 @@ struct access_sys_t
int
i_track
;
int
i_track
;
int
i_first_sector
;
int
i_first_sector
;
int
i_last_sector
;
int
i_last_sector
;
#ifdef HAVE_LIBCDDB
cddb_disc_t
*
p_disc
;
#endif
};
};
static
block_t
*
Block
(
access_t
*
);
static
block_t
*
Block
(
access_t
*
);
...
@@ -130,7 +126,7 @@ static int Control( access_t *, int, va_list );
...
@@ -130,7 +126,7 @@ static int Control( access_t *, int, va_list );
static
int
GetTracks
(
access_t
*
p_access
,
input_item_t
*
p_current
);
static
int
GetTracks
(
access_t
*
p_access
,
input_item_t
*
p_current
);
#ifdef HAVE_LIBCDDB
#ifdef HAVE_LIBCDDB
static
void
GetCDDBInfo
(
access_t
*
p_access
,
int
i_titles
,
int
*
p_sectors
);
static
cddb_disc_t
*
GetCDDBInfo
(
access_t
*
p_access
,
int
i_titles
,
int
*
p_sectors
);
#endif
#endif
/*****************************************************************************
/*****************************************************************************
...
@@ -397,22 +393,22 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
...
@@ -397,22 +393,22 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
input_item_SetName
(
p_current
,
"Audio CD"
);
input_item_SetName
(
p_current
,
"Audio CD"
);
#ifdef HAVE_LIBCDDB
#ifdef HAVE_LIBCDDB
GetCDDBInfo
(
p_access
,
i_titles
,
p_sys
->
p_sectors
);
cddb_disc_t
*
p_disc
=
GetCDDBInfo
(
p_access
,
i_titles
,
p_sys
->
p_sectors
);
const
char
*
psz_album
=
NULL
;
const
char
*
psz_album
=
NULL
;
const
char
*
psz_year
=
NULL
;
const
char
*
psz_year
=
NULL
;
const
char
*
psz_genre
=
NULL
;
const
char
*
psz_genre
=
NULL
;
char
psz_year_buffer
[
4
+
1
];
char
psz_year_buffer
[
4
+
1
];
if
(
p_
sys
->
p_
disc
)
if
(
p_disc
)
{
{
psz_album
=
cddb_disc_get_title
(
p_
sys
->
p_
disc
);
psz_album
=
cddb_disc_get_title
(
p_disc
);
if
(
psz_album
&&
*
psz_album
)
if
(
psz_album
&&
*
psz_album
)
{
{
input_item_SetName
(
p_current
,
psz_album
);
input_item_SetName
(
p_current
,
psz_album
);
input_item_SetAlbum
(
p_current
,
psz_album
);
input_item_SetAlbum
(
p_current
,
psz_album
);
}
}
const
unsigned
i_year
=
cddb_disc_get_year
(
p_
sys
->
p_
disc
);
const
unsigned
i_year
=
cddb_disc_get_year
(
p_disc
);
if
(
i_year
>
0
)
if
(
i_year
>
0
)
{
{
psz_year
=
psz_year_buffer
;
psz_year
=
psz_year_buffer
;
...
@@ -420,7 +416,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
...
@@ -420,7 +416,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
input_item_SetDate
(
p_current
,
psz_year
);
input_item_SetDate
(
p_current
,
psz_year
);
}
}
psz_genre
=
cddb_disc_get_genre
(
p_
sys
->
p_
disc
);
psz_genre
=
cddb_disc_get_genre
(
p_disc
);
if
(
psz_genre
&&
*
psz_genre
)
if
(
psz_genre
&&
*
psz_genre
)
input_item_SetGenre
(
p_current
,
psz_genre
);
input_item_SetGenre
(
p_current
,
psz_genre
);
...
@@ -428,7 +424,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
...
@@ -428,7 +424,7 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
const
char
*
psz_artist
=
NULL
;
const
char
*
psz_artist
=
NULL
;
for
(
int
i
=
0
;
i
<
i_titles
;
i
++
)
for
(
int
i
=
0
;
i
<
i_titles
;
i
++
)
{
{
cddb_track_t
*
t
=
cddb_disc_get_track
(
p_
sys
->
p_
disc
,
i
);
cddb_track_t
*
t
=
cddb_disc_get_track
(
p_disc
,
i
);
if
(
!
t
)
if
(
!
t
)
continue
;
continue
;
const
char
*
psz_track_artist
=
cddb_track_get_artist
(
t
);
const
char
*
psz_track_artist
=
cddb_track_get_artist
(
t
);
...
@@ -486,9 +482,9 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
...
@@ -486,9 +482,9 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
#ifdef HAVE_LIBCDDB
#ifdef HAVE_LIBCDDB
/* If we have CDDB info, change the name */
/* If we have CDDB info, change the name */
if
(
p_
sys
->
p_
disc
)
if
(
p_disc
)
{
{
cddb_track_t
*
t
=
cddb_disc_get_track
(
p_
sys
->
p_
disc
,
i
);
cddb_track_t
*
t
=
cddb_disc_get_track
(
p_disc
,
i
);
if
(
t
!=
NULL
)
if
(
t
!=
NULL
)
{
{
const
char
*
psz_title
=
cddb_track_get_title
(
t
);
const
char
*
psz_title
=
cddb_track_get_title
(
t
);
...
@@ -522,28 +518,34 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
...
@@ -522,28 +518,34 @@ static int GetTracks( access_t *p_access, input_item_t *p_current )
free
(
psz_uri
);
free
(
psz_opt
);
free
(
psz_name
);
free
(
psz_uri
);
free
(
psz_opt
);
free
(
psz_name
);
free
(
psz_first
);
free
(
psz_last
);
free
(
psz_first
);
free
(
psz_last
);
}
}
#ifdef HAVE_LIBCDDB
if
(
p_disc
)
cddb_disc_destroy
(
p_disc
);
#endif
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
#ifdef HAVE_LIBCDDB
#ifdef HAVE_LIBCDDB
static
void
GetCDDBInfo
(
access_t
*
p_access
,
int
i_titles
,
int
*
p_sectors
)
static
cddb_disc_t
*
GetCDDBInfo
(
access_t
*
p_access
,
int
i_titles
,
int
*
p_sectors
)
{
{
int
i
,
i_matches
;
/* */
int64_t
i_length
=
0
,
i_size
=
0
;
cddb_conn_t
*
p_cddb
=
cddb_new
();
cddb_conn_t
*
p_cddb
=
cddb_new
();
if
(
!
p_cddb
)
if
(
!
p_cddb
)
{
{
msg_Warn
(
p_access
,
"unable to use CDDB"
);
msg_Warn
(
p_access
,
"unable to use CDDB"
);
goto
cddb_destroy
;
return
NULL
;
}
}
char
*
psz_tmp
=
config_GetPsz
(
p_access
,
"cddb-server"
);
/* */
c
ddb_set_email_address
(
p_cddb
,
"vlc@videolan.org
"
);
c
har
*
psz_tmp
=
config_GetPsz
(
p_access
,
"cddb-server
"
);
cddb_set_server_name
(
p_cddb
,
psz_tmp
);
cddb_set_server_name
(
p_cddb
,
psz_tmp
);
cddb_set_server_port
(
p_cddb
,
config_GetInt
(
p_access
,
"cddb-port"
)
);
free
(
psz_tmp
);
free
(
psz_tmp
);
cddb_set_server_port
(
p_cddb
,
config_GetInt
(
p_access
,
"cddb-port"
)
);
cddb_set_email_address
(
p_cddb
,
"vlc@videolan.org"
);
/// \todo
/// \todo
cddb_cache_disable
(
p_cddb
);
cddb_cache_disable
(
p_cddb
);
...
@@ -556,47 +558,52 @@ static void GetCDDBInfo( access_t *p_access, int i_titles, int *p_sectors )
...
@@ -556,47 +558,52 @@ static void GetCDDBInfo( access_t *p_access, int i_titles, int *p_sectors )
/// \todo
/// \todo
cddb_http_disable
(
p_cddb
);
cddb_http_disable
(
p_cddb
);
p_access
->
p_sys
->
p_disc
=
cddb_disc_new
();
/* */
cddb_disc_t
*
p_disc
=
cddb_disc_new
();
if
(
!
p_access
->
p_sys
->
p_disc
)
if
(
!
p_disc
)
{
{
msg_Err
(
p_access
,
"unable to create CDDB disc structure."
);
msg_Err
(
p_access
,
"unable to create CDDB disc structure."
);
goto
cddb_end
;
goto
error
;
}
}
for
(
i
=
0
;
i
<
i_titles
;
i
++
)
int64_t
i_length
=
0
;
for
(
int
i
=
0
;
i
<
i_titles
;
i
++
)
{
{
cddb_track_t
*
t
=
cddb_track_new
();
cddb_track_t
*
t
=
cddb_track_new
();
cddb_track_set_frame_offset
(
t
,
p_sectors
[
i
]
);
cddb_track_set_frame_offset
(
t
,
p_sectors
[
i
]
);
cddb_disc_add_track
(
p_
access
->
p_sys
->
p_
disc
,
t
);
cddb_disc_add_track
(
p_disc
,
t
);
i_size
=
(
p_sectors
[
i
+
1
]
-
p_sectors
[
i
]
)
*
const
int64_t
i_size
=
(
p_sectors
[
i
+
1
]
-
p_sectors
[
i
]
)
*
(
int64_t
)
CDDA_DATA_SIZE
;
(
int64_t
)
CDDA_DATA_SIZE
;
i_length
+=
INT64_C
(
1000000
)
*
i_size
/
44100
/
4
;
i_length
+=
INT64_C
(
1000000
)
*
i_size
/
44100
/
4
;
}
}
cddb_disc_set_length
(
p_
access
->
p_sys
->
p_
disc
,
(
int
)(
i_length
/
1000000
)
);
cddb_disc_set_length
(
p_disc
,
(
int
)(
i_length
/
1000000
)
);
if
(
!
cddb_disc_calc_discid
(
p_access
->
p_sys
->
p_disc
)
)
if
(
!
cddb_disc_calc_discid
(
p_disc
)
)
{
{
msg_Err
(
p_access
,
"CDDB disc ID calculation failed"
);
msg_Err
(
p_access
,
"CDDB disc ID calculation failed"
);
goto
cddb_destroy
;
goto
error
;
}
}
i_matches
=
cddb_query
(
p_cddb
,
p_access
->
p_sys
->
p_disc
);
const
int
i_matches
=
cddb_query
(
p_cddb
,
p_disc
);
if
(
i_matches
<=
0
)
if
(
i_matches
>
0
)
{
{
if
(
i_matches
>
1
)
msg_Warn
(
p_access
,
"found %d matches in CDDB. Using first one."
,
i_matches
);
cddb_read
(
p_cddb
,
p_access
->
p_sys
->
p_disc
);
}
else
msg_Warn
(
p_access
,
"CDDB error: %s"
,
cddb_error_str
(
errno
));
msg_Warn
(
p_access
,
"CDDB error: %s"
,
cddb_error_str
(
errno
));
goto
error
;
}
if
(
i_matches
>
1
)
msg_Warn
(
p_access
,
"found %d matches in CDDB. Using first one."
,
i_matches
);
cddb_read
(
p_cddb
,
p_disc
);
cddb_destroy:
cddb_destroy
(
p_cddb
);
cddb_destroy
(
p_cddb
);
return
p_disc
;
cddb_end:
;
error:
if
(
p_disc
)
cddb_disc_destroy
(
p_disc
);
cddb_destroy
(
p_cddb
);
return
NULL
;
}
}
#endif
/*HAVE_LIBCDDB*/
#endif
/*HAVE_LIBCDDB*/
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