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
8dbbea85
Commit
8dbbea85
authored
Oct 23, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slightly better error handling/broken connection detection for shout output
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2316
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
23c59e8c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
26 deletions
+60
-26
audioOutput_shout.c
src/audioOutput_shout.c
+60
-26
No files found.
src/audioOutput_shout.c
View file @
8dbbea85
...
...
@@ -64,6 +64,8 @@ typedef struct _ShoutData {
long
convBufferLen
;
/* shoud we convert the audio to a different format? */
int
audioFormatConvert
;
int
opened
;
}
ShoutData
;
static
ShoutData
*
newShoutData
()
{
...
...
@@ -73,6 +75,7 @@ static ShoutData * newShoutData() {
ret
->
serialno
=
rand
();
ret
->
convBuffer
=
NULL
;
ret
->
convBufferLen
=
0
;
ret
->
opened
=
0
;
return
ret
;
}
...
...
@@ -187,9 +190,28 @@ static int shout_initDriver(AudioOutput * audioOutput) {
return
0
;
}
static
void
shout_closeShoutConn
(
ShoutData
*
sd
)
{
if
(
sd
->
opened
)
{
if
(
shout_close
(
sd
->
shoutConn
)
!=
SHOUTERR_SUCCESS
)
{
ERROR
(
"problem closing connection to shout server: "
"%s
\n
"
,
shout_get_error
(
sd
->
shoutConn
));
}
ogg_stream_clear
(
&
(
sd
->
os
));
vorbis_block_clear
(
&
(
sd
->
vb
));
vorbis_dsp_clear
(
&
(
sd
->
vd
));
vorbis_comment_clear
(
&
(
sd
->
vc
));
vorbis_info_clear
(
&
(
sd
->
vi
));
}
sd
->
opened
=
0
;
}
static
void
shout_finishDriver
(
AudioOutput
*
audioOutput
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
shout_closeShoutConn
(
sd
);
freeShoutData
(
sd
);
shoutInitCount
--
;
...
...
@@ -198,29 +220,33 @@ static void shout_finishDriver(AudioOutput * audioOutput) {
}
static
void
shout_closeDevice
(
AudioOutput
*
audioOutput
)
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
audioOutput
->
open
=
0
;
}
if
(
shout_close
(
sd
->
shoutConn
)
!=
SHOUTERR_SUCCESS
)
{
ERROR
(
"problem closing connection to shout server: %s
\n
"
,
shout_get_error
(
sd
->
shoutConn
));
static
void
shout_handleError
(
ShoutData
*
sd
,
int
err
)
{
switch
(
err
)
{
case
SHOUTERR_SUCCESS
:
break
;
case
SHOUTERR_UNCONNECTED
:
case
SHOUTERR_SOCKET
:
ERROR
(
"Lost shout connection, attempting to reconnect
\n
"
);
shout_close
(
sd
->
shoutConn
);
shout_open
(
sd
->
shoutConn
);
break
;
default:
ERROR
(
"shout: error: %s
\n
"
,
shout_get_error
(
sd
->
shoutConn
));
break
;
}
ogg_stream_clear
(
&
(
sd
->
os
));
vorbis_block_clear
(
&
(
sd
->
vb
));
vorbis_dsp_clear
(
&
(
sd
->
vd
));
vorbis_comment_clear
(
&
(
sd
->
vc
));
vorbis_info_clear
(
&
(
sd
->
vi
));
audioOutput
->
open
=
0
;
}
static
void
write_page
(
ShoutData
*
sd
)
{
if
(
!
sd
->
og
.
header_len
||
!
sd
->
og
.
body_len
)
return
;
shout_sync
(
sd
->
shoutConn
);
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
header
,
sd
->
og
.
header_len
);
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
body
,
sd
->
og
.
body_len
);
/*shout_sync(sd->shoutConn);*/
int
err
=
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
header
,
sd
->
og
.
header_len
);
shout_handleError
(
sd
,
err
);
err
=
shout_send
(
sd
->
shoutConn
,
sd
->
og
.
body
,
sd
->
og
.
body_len
);
shout_handleError
(
sd
,
err
);
shout_sync
(
sd
->
shoutConn
);
}
...
...
@@ -229,10 +255,25 @@ static int shout_openDevice(AudioOutput * audioOutput,
{
ShoutData
*
sd
=
(
ShoutData
*
)
audioOutput
->
data
;
memcpy
(
&
(
sd
->
inAudioFormat
),
audioFormat
,
sizeof
(
AudioFormat
));
if
(
0
==
memcmp
(
&
(
sd
->
inAudioFormat
),
&
(
sd
->
outAudioFormat
),
sizeof
(
AudioFormat
)))
{
sd
->
audioFormatConvert
=
0
;
}
else
sd
->
audioFormatConvert
=
1
;
audioOutput
->
open
=
1
;
if
(
sd
->
opened
)
return
0
;
if
(
shout_open
(
sd
->
shoutConn
)
!=
SHOUTERR_SUCCESS
)
{
ERROR
(
"problem opening connection to shout server: %s
\n
"
,
shout_get_error
(
sd
->
shoutConn
));
audioOutput
->
open
=
0
;
return
-
1
;
}
...
...
@@ -243,6 +284,8 @@ static int shout_openDevice(AudioOutput * audioOutput,
{
ERROR
(
"problem seting up vorbis encoder for shout
\n
"
);
vorbis_info_clear
(
&
(
sd
->
vi
));
shout_close
(
sd
->
shoutConn
);
audioOutput
->
open
=
0
;
return
-
1
;
}
...
...
@@ -259,21 +302,12 @@ static int shout_openDevice(AudioOutput * audioOutput,
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_comments
));
ogg_stream_packetin
(
&
(
sd
->
os
),
&
(
sd
->
header_codebooks
));
audioOutput
->
open
=
1
;
while
(
ogg_stream_flush
(
&
(
sd
->
os
),
&
(
sd
->
og
)))
{
write_page
(
sd
);
}
memcpy
(
&
(
sd
->
inAudioFormat
),
audioFormat
,
sizeof
(
AudioFormat
));
if
(
0
==
memcmp
(
&
(
sd
->
inAudioFormat
),
&
(
sd
->
outAudioFormat
),
sizeof
(
AudioFormat
)))
{
sd
->
audioFormatConvert
=
0
;
}
else
sd
->
audioFormatConvert
=
1
;
sd
->
opened
=
1
;
return
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