public AndroidAudioStreamingPlayer(IMediaBufferGenerator generator, AudioParameters parameters, TimeSpan totalTime)
        {
            if (generator == null)
                throw new ArgumentNullException ("generator");
            gen = generator;

            min_buf_size = AudioTrack.GetMinBufferSize (
                parameters.SamplesPerSecond / CompressionRate * 2,
                ChannelOut.Stereo,
                Encoding.Pcm16bit
            );
            buf_size = min_buf_size * 8;

            // "* n" part is adjusted for device.
            audio = new AudioTrack (
                Android.Media.Stream.Music,
                parameters.SamplesPerSecond / CompressionRate * 2,
                ToChannelConfiguration (parameters.Channels),
                Android.Media.Encoding.Pcm16bit,
                buf_size * 4,
                AudioTrackMode.Stream
            );
            player_thread = new Thread (() => DoRun ());
            this.total_time = totalTime;
        }
 public BufferGeneratorMediaStreamSource(IMediaBufferGenerator generator, AudioParameters parameters, TimeSpan trackDuration)
 {
     if (gen == null)
         throw new ArgumentNullException ("generator");
     parameters = parameters ?? AudioParameters.Default;
     this.gen = generator;
     track_duration = trackDuration;
 }
Ejemplo n.º 3
0
 public PortAudioStreamPlayer(IMediaBufferGenerator generator, AudioParameters parameters, PaSampleFormat sampleFormat, uint frames, object userData)
     : base(generator)
 {
     stream = new PortAudioOutputStream (
         parameters.Channels,
         sampleFormat,
         parameters.SamplesPerSecond,
         frames,
         StreamCallback,
         userData
     );
 }