Skip to content

Commit

Permalink
Cache info.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptabor committed Dec 1, 2024
1 parent 78283cd commit 0c3261f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ type Application struct {
// Current values from the chromecast.
application *cast.Application // It is possible that there is no current application, can happen for google home.
media *cast.Media
info *cast.DeviceInfo
// There seems to be two different volumes returned from the chromecast,
// one for the receiver and one for the playing media. It looks we update
// the receiver volume from go-chromecast, so we should use that one. But
Expand Down Expand Up @@ -451,6 +452,9 @@ func (a *Application) Status() (*cast.Application, *cast.Media, *cast.Volume) {
}

func (a *Application) Info() (*cast.DeviceInfo, error) {
if a.info != nil {
return a.info, nil
}
addr, err := a.conn.RemoteAddr()
if err != nil {
return nil, err
Expand All @@ -463,6 +467,7 @@ func (a *Application) Info() (*cast.DeviceInfo, error) {
if len(a.deviceNameOverride) > 0 {
info.Name = a.deviceNameOverride
}
a.info = info
return info, err
}

Expand Down

0 comments on commit 0c3261f

Please sign in to comment.