コード例 #1
0
 private void checkStuck(AudioTrack track)
 {
     if (!stuckEventSent && nanoTime() - lastReceiveTime > manager.TrackStuckThresholdNanos)
     {
         stuckEventSent = true;
         dispatchEvent(new TrackStuckEvent(this, track, TimeUnit.NANOSECONDS.toMillis(manager.TrackStuckThresholdNanos)));
     }
 }
コード例 #2
0
 /// <param name="track"> Audio track to play </param>
 /// <param name="configuration"> Configuration for audio processing </param>
 /// <param name="remoteNodeManager"> Manager of remote nodes </param>
 /// <param name="volumeLevel"> Mutable volume level </param>
 public RemoteAudioTrackExecutor(AudioTrack track, AudioConfiguration configuration, RemoteNodeManager remoteNodeManager, AtomicInteger volumeLevel)
 {
     this.track             = track;
     this.configuration     = configuration.copy();
     this.remoteNodeManager = remoteNodeManager;
     this.volumeLevel       = volumeLevel;
     this.executorId        = nanoTime();
     this.frameBuffer       = new AudioFrameBuffer(BUFFER_DURATION_MS, configuration.OutputFormat, null);
 }
コード例 #3
0
        public bool isPlayingTrack(AudioTrack track)
        {
            AudioTrackExecutor executor = ((InternalAudioTrack)track).ActiveExecutor;

            if (executor is RemoteAudioTrackExecutor)
            {
                return(playingTracks.ContainsKey(((RemoteAudioTrackExecutor)executor).ExecutorId));
            }

            return(false);
        }
コード例 #4
0
        /// <summary>
        /// Start playing a track through this remote node. </summary>
        /// <param name="executor"> The executor of the track </param>
        public virtual void startPlaying(RemoteAudioTrackExecutor executor)
        {
            AudioTrack track = executor.Track;

            if (playingTracks.PutIfAbsent(executor.ExecutorId, executor) == null)
            {
                long position = executor.NextInputTimecode;
                log.LogInformation("Sending request to play {} {} from position {}", track.Identifier, executor.ExecutorId, position);

                queuedMessages.add(new TrackStartRequestMessage(executor.ExecutorId, track.Info, playerManager.encodeTrackDetails(track), executor.Volume, executor.Configuration, position));
            }
        }
コード例 #5
0
        /// <param name="track"> The track to start playing, passing null will stop the current track and return false </param>
        /// <param name="noInterrupt"> Whether to only start if nothing else is playing </param>
        /// <returns> True if the track was started </returns>
        public virtual bool startTrack(AudioTrack track, bool noInterrupt)
        {
            InternalAudioTrack newTrack = (InternalAudioTrack)track;
            InternalAudioTrack previousTrack;

            lock (trackSwitchLock)
            {
                previousTrack = activeTrack;

                if (noInterrupt && previousTrack != null)
                {
                    return(false);
                }
            }
            activeTrack     = newTrack;
            lastRequestTime = DateTimeHelperClass.CurrentUnixTimeMillis();
            lastReceiveTime = nanoTime();
            stuckEventSent  = false;

            if (previousTrack != null)
            {
                previousTrack.stop();
                dispatchEvent(new TrackEndEvent(this, previousTrack, newTrack == null ? AudioTrackEndReason.STOPPED : AudioTrackEndReason.REPLACED));

                shadowTrack = previousTrack;
            }


            if (newTrack == null)
            {
                shadowTrack = null;
                return(false);
            }
            dispatchEvent(new TrackStartEvent(this, newTrack));

            manager.executeTrack(this, newTrack, manager.Configuration, volumeLevel);
            return(true);
        }
コード例 #6
0
 /// <param name="track"> The track to start playing </param>
 public virtual void playTrack(AudioTrack track)
 {
     startTrack(track, false);
 }