Пример #1
0
 public override bool Play()
 {
     if (!initialized)
         return false;
     var input = PlayList[currentIndex];
     //Spec.callback = FillBuffer;
     for (int i = 0; i < formats.Length; i++)
     {
         Spec.format = formats[i];
         Spec.freq = input.Frequency;
         Spec.channels = input.Channels;
         Spec.silence = 255;
         Spec.samples = Convert.ToUInt16(Math.Pow(2, 15) - 1);
         Spec.size = 0;
         try
         {
             currentDevice = SdlAudio.OpenAudioDevice(null, 0, ref Spec, out SdlAudioSpec obtained, (int)AudioAdjust.FORMAT_CHANGE);
             if (currentDevice != 0)
             {
                 Spec = obtained;
                 break;
             }
         }
         catch { continue; }
     }
     opened = currentDevice != 0;
     if (!opened)
         return false;
     SdlAudio.QueueAudio(currentDevice, input.data, input.length);
     SdlAudio.PauseAudioDevice(currentDevice, 0);
     return Loop;
 }
Пример #2
0
 public override bool Play()
 {
     if (!opened)
         return false;
     try
     {
         currentDevice = SdlAudio.OpenAudioDevice(null, 0, ref Spec, out _, (int)AudioAdjust.FORMAT_CHANGE);
         SdlAudio.QueueAudio(currentDevice, Buffer, Length);
         SdlAudio.PauseAudioDevice(currentDevice, 0);
         return Loop;
     }
     catch { }
     return false;
 }