Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
djrandom
Commits
e2ba5a61
Commit
e2ba5a61
authored
10 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
reflect gompd API changes
parent
501e6d69
Branches
Branches containing commit
Tags
v0.1.2
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/mpd/djmpd/djmpd.go
+1
-3
1 addition, 3 deletions
client/mpd/djmpd/djmpd.go
client/mpd/djrandom.go
+6
-6
6 additions, 6 deletions
client/mpd/djrandom.go
with
7 additions
and
9 deletions
client/mpd/djmpd/djmpd.go
+
1
−
3
View file @
e2ba5a61
...
...
@@ -17,9 +17,7 @@ func main() {
flag
.
Parse
()
db
:=
djmpd
.
NewDJRandomDatabase
()
player
:=
mpd
.
NewPortAudioPlayer
()
db
.
SetupPlayRecorder
(
player
)
m
:=
mpd
.
NewMPD
(
player
,
db
)
m
:=
mpd
.
NewMPD
(
db
,
db
.
GetPlayRecorder
())
m
.
HandleURL
(
"djrandom"
,
db
)
log
.
Fatal
(
m
.
ListenAndServe
(
fmt
.
Sprintf
(
":%d"
,
*
port
)))
}
This diff is collapsed.
Click to expand it.
client/mpd/djrandom.go
+
6
−
6
View file @
e2ba5a61
...
...
@@ -120,11 +120,12 @@ type songReader struct {
url
string
pos
,
size
int64
resp
*
http
.
Response
closed
bool
}
func
(
r
*
songReader
)
Read
(
buf
[]
byte
)
(
int
,
error
)
{
var
err
error
for
i
:=
0
;
i
<
2
;
i
++
{
for
i
:=
0
;
!
r
.
closed
&&
i
<
3
;
i
++
{
if
r
.
pos
>=
r
.
size
{
return
0
,
io
.
EOF
}
...
...
@@ -144,7 +145,6 @@ func (r *songReader) Read(buf []byte) (int, error) {
r
.
pos
+=
int64
(
n
)
return
n
,
err
}
log
.
Printf
(
"HTTP read error: %v"
,
err
)
r
.
resp
.
Body
.
Close
()
r
.
resp
=
nil
}
...
...
@@ -152,6 +152,7 @@ func (r *songReader) Read(buf []byte) (int, error) {
}
func
(
r
*
songReader
)
Close
()
error
{
r
.
closed
=
true
if
r
.
resp
!=
nil
{
r
.
resp
.
Body
.
Close
()
}
...
...
@@ -256,9 +257,8 @@ func (d *DJRandomDatabase) GetSong(songURL *url.URL) (mpd.Song, error) {
return
newDJRandomSong
(
&
resp
,
d
.
client
),
nil
}
func
(
d
*
DJRandomDatabase
)
SetupPlayRecorder
(
player
mpd
.
Player
)
{
rec
:=
newPlayRecorder
(
d
.
client
)
player
.
SetSongPlayedCallback
(
rec
.
SongPlayed
)
func
(
d
*
DJRandomDatabase
)
GetPlayRecorder
()
*
PlayRecorder
{
return
newPlayRecorder
(
d
.
client
)
}
type
PlayRecorder
struct
{
...
...
@@ -277,7 +277,7 @@ func newPlayRecorder(client *util.HttpClient) *PlayRecorder {
}
}
func
(
r
*
PlayRecorder
)
SongPlayed
(
song
mpd
.
Song
)
{
func
(
r
*
PlayRecorder
)
Notify
(
song
mpd
.
Song
)
{
s
,
ok
:=
song
.
(
*
DJRandomSong
)
if
!
ok
{
return
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment