Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6d7e6a85
Commit
6d7e6a85
authored
Nov 01, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a memory leak if write_page() fails in openShoutConn()
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2455
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
023fba80
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
34 deletions
+39
-34
audioOutput_shout.c
src/audioOutput_shout.c
+39
-34
No files found.
src/audioOutput_shout.c
View file @
6d7e6a85
...
...
@@ -103,7 +103,7 @@ static void freeShoutData(ShoutData * sd) {
} \
}
static
int
s
hout_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
static
int
myS
hout_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
ShoutData
*
sd
;
char
*
test
;
int
port
;
...
...
@@ -265,7 +265,7 @@ static void clearEncoder(ShoutData * sd) {
vorbis_info_clear
(
&
sd
->
vi
);
}
static
void
s
hout_closeShoutConn
(
ShoutData
*
sd
)
{
static
void
myS
hout_closeShoutConn
(
ShoutData
*
sd
)
{
if
(
sd
->
opened
)
{
clearEncoder
(
sd
);
...
...
@@ -278,10 +278,10 @@ static void shout_closeShoutConn(ShoutData * sd) {
sd
->
opened
=
0
;
}
static
void
s
hout_finishDriver
(
AudioOutput
*
audioOutput
)
{
static
void
myS
hout_finishDriver
(
AudioOutput
*
audioOutput
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
s
hout_closeShoutConn
(
sd
);
myS
hout_closeShoutConn
(
sd
);
freeShoutData
(
sd
);
...
...
@@ -290,11 +290,11 @@ static void shout_finishDriver(AudioOutput * audioOutput) {
if
(
shoutInitCount
==
0
)
shout_shutdown
();
}
static
void
s
hout_closeDevice
(
AudioOutput
*
audioOutput
)
{
static
void
myS
hout_closeDevice
(
AudioOutput
*
audioOutput
)
{
audioOutput
->
open
=
0
;
}
static
int
s
hout_handleError
(
ShoutData
*
sd
,
int
err
)
{
static
int
myS
hout_handleError
(
ShoutData
*
sd
,
int
err
)
{
switch
(
err
)
{
case
SHOUTERR_SUCCESS
:
break
;
...
...
@@ -313,16 +313,12 @@ static int shout_handleError(ShoutData * sd, int err) {
static
int
write_page
(
ShoutData
*
sd
)
{
shout_sync
(
sd
->
shoutConn
);
int
err
=
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
header
,
sd
->
og
.
header_len
);
if
(
shout_handleError
(
sd
,
err
)
<
0
)
goto
fail
;
if
(
myShout_handleError
(
sd
,
err
)
<
0
)
return
-
1
;
err
=
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
body
,
sd
->
og
.
body_len
);
if
(
shout_handleError
(
sd
,
err
)
<
0
)
goto
fail
;
if
(
myShout_handleError
(
sd
,
err
)
<
0
)
return
-
1
;
/*shout_sync(sd->shoutConn);*/
return
0
;
fail:
shout_closeShoutConn
(
sd
);
return
-
1
;
}
#define addTag(name, value) { \
...
...
@@ -378,7 +374,7 @@ static int initEncoder(ShoutData * sd) {
return
0
;
}
static
int
s
hout_openShoutConn
(
AudioOutput
*
audioOutput
)
{
static
int
myS
hout_openShoutConn
(
AudioOutput
*
audioOutput
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
if
(
shout_open
(
sd
->
shoutConn
)
!=
SHOUTERR_SUCCESS
)
...
...
@@ -403,21 +399,24 @@ static int shout_openShoutConn(AudioOutput * audioOutput) {
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_comments
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_codebooks
));
sd
->
opened
=
1
;
sd
->
tagToSend
=
0
;
while
(
ogg_stream_flush
(
&
(
sd
->
os
),
&
(
sd
->
og
)))
{
if
(
write_page
(
sd
)
<
0
)
return
-
1
;
if
(
write_page
(
sd
)
<
0
)
{
myShout_closeShoutConn
(
sd
);
return
-
1
;
}
}
/*if(sd->tag) freeMpdTag(sd->tag);
sd->tag = NULL;*/
sd
->
tagToSend
=
0
;
sd
->
opened
=
1
;
return
0
;
}
static
int
s
hout_openDevice
(
AudioOutput
*
audioOutput
,
static
int
myS
hout_openDevice
(
AudioOutput
*
audioOutput
,
AudioFormat
*
audioFormat
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
...
...
@@ -435,7 +434,7 @@ static int shout_openDevice(AudioOutput * audioOutput,
if
(
sd
->
opened
)
return
0
;
if
(
s
hout_openShoutConn
(
audioOutput
)
<
0
)
{
if
(
myS
hout_openShoutConn
(
audioOutput
)
<
0
)
{
audioOutput
->
open
=
0
;
return
-
1
;
}
...
...
@@ -443,7 +442,7 @@ static int shout_openDevice(AudioOutput * audioOutput,
return
0
;
}
static
void
s
hout_convertAudioFormat
(
ShoutData
*
sd
,
char
**
chunkArgPtr
,
static
void
myS
hout_convertAudioFormat
(
ShoutData
*
sd
,
char
**
chunkArgPtr
,
int
*
sizeArgPtr
)
{
int
size
=
pcm_sizeOfOutputBufferForAudioFormatConversion
(
...
...
@@ -462,7 +461,7 @@ static void shout_convertAudioFormat(ShoutData * sd, char ** chunkArgPtr,
*
chunkArgPtr
=
sd
->
convBuffer
;
}
static
void
s
hout_sendMetadata
(
ShoutData
*
sd
)
{
static
void
myS
hout_sendMetadata
(
ShoutData
*
sd
)
{
ogg_int64_t
granulepos
=
sd
->
vd
.
granulepos
;
if
(
!
sd
->
opened
||
!
sd
->
tag
)
return
;
...
...
@@ -483,7 +482,10 @@ static void shout_sendMetadata(ShoutData * sd) {
while
(
ogg_stream_flush
(
&
(
sd
->
os
),
&
(
sd
->
og
)))
{
if
(
write_page
(
sd
)
<
0
)
return
;
if
(
write_page
(
sd
)
<
0
)
{
myShout_closeShoutConn
(
sd
);
return
;
}
}
/*if(sd->tag) freeMpdTag(sd->tag);
...
...
@@ -491,23 +493,23 @@ static void shout_sendMetadata(ShoutData * sd) {
sd
->
tagToSend
=
0
;
}
static
int
s
hout_play
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
int
size
)
{
static
int
myS
hout_play
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
int
size
)
{
int
i
,
j
;
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
float
**
vorbbuf
;
int
samples
;
int
bytes
=
sd
->
outAudioFormat
.
bits
/
8
;
if
(
sd
->
opened
&&
sd
->
tagToSend
)
s
hout_sendMetadata
(
sd
);
if
(
sd
->
opened
&&
sd
->
tagToSend
)
myS
hout_sendMetadata
(
sd
);
if
(
!
sd
->
opened
)
{
if
(
s
hout_openShoutConn
(
audioOutput
)
<
0
)
{
if
(
myS
hout_openShoutConn
(
audioOutput
)
<
0
)
{
return
-
1
;
}
}
if
(
sd
->
audioFormatConvert
)
{
s
hout_convertAudioFormat
(
sd
,
&
playChunk
,
&
size
);
myS
hout_convertAudioFormat
(
sd
,
&
playChunk
,
&
size
);
}
samples
=
size
/
(
bytes
*
sd
->
outAudioFormat
.
channels
);
...
...
@@ -536,13 +538,16 @@ static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
while
(
ogg_stream_pageout
(
&
(
sd
->
os
),
&
(
sd
->
og
))
!=
0
)
{
if
(
write_page
(
sd
)
<
0
)
return
-
1
;
if
(
write_page
(
sd
)
<
0
)
{
myShout_closeShoutConn
(
sd
);
return
-
1
;
}
}
return
0
;
}
static
void
s
hout_setTag
(
AudioOutput
*
audioOutput
,
MpdTag
*
tag
)
{
static
void
myS
hout_setTag
(
AudioOutput
*
audioOutput
,
MpdTag
*
tag
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
if
(
sd
->
tag
)
freeMpdTag
(
sd
->
tag
);
...
...
@@ -558,12 +563,12 @@ static void shout_setTag(AudioOutput * audioOutput, MpdTag * tag) {
AudioOutputPlugin
shoutPlugin
=
{
"shout"
,
s
hout_initDriver
,
s
hout_finishDriver
,
s
hout_openDevice
,
s
hout_play
,
s
hout_closeDevice
,
s
hout_setTag
myS
hout_initDriver
,
myS
hout_finishDriver
,
myS
hout_openDevice
,
myS
hout_play
,
myS
hout_closeDevice
,
myS
hout_setTag
};
#else
...
...
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