Sfoglia il codice sorgente

reset device parameter in DeInit

Coder 8 mesi fa
parent
commit
b607b74645
1 ha cambiato i file con 22 aggiunte e 12 eliminazioni
  1. 22 12
      Bmp.WinForms/MainForm.cs

+ 22 - 12
Bmp.WinForms/MainForm.cs

@@ -112,7 +112,7 @@ namespace Bmp.WinForms
 
                     foreach (var pair in meta.RawTags.OrderBy(p => p.Key))
                     {
-                        item.ToolTipText += $"{Environment.NewLine}{pair.Key}:{pair.Value}";
+                        item.ToolTipText += $"{Environment.NewLine}【{pair.Key}】{pair.Value.Trim()}";
                     }
                 }
                 else
@@ -183,6 +183,17 @@ namespace Bmp.WinForms
             {
                 local.PlaybackStopped -= _outputDevice_PlaybackStopped;
                 local.Stop();
+
+                if (local is AsioOut ao)
+                {
+                    if (_nativeDsd)
+                    {
+                        //try reset device
+                        ao.SetNativeDsd(false);
+                        ao.Driver.SetSampleRate(44100);
+                    }
+                }
+
                 local.Dispose();
             }
         }
@@ -203,7 +214,6 @@ namespace Bmp.WinForms
                 if (_inputSource is DsdAbstractSourceStream)
                 {
                     _nativeDsd = true;
-                    //TODO: 匹配原生DSD设备
                     if (_sl?.State?.SelectedDsdAsioOutputDeviceId == null)
                     {
                         finalState = EMOJI_X;
@@ -311,7 +321,7 @@ namespace Bmp.WinForms
             }
             catch (Exception e)
             {
-                //TODO: 异常处理
+                //TODO: 异常处理 ReInitOutputDevice
                 Console.WriteLine(e);
                 throw;
             }
@@ -364,7 +374,7 @@ namespace Bmp.WinForms
                 }
                 catch (Exception e)
                 {
-                    //TODO: 异常处理
+                    //TODO: 异常处理 PlayAsync
                     Console.WriteLine(e);
                     _playbackState = UIPlaybackState.Error;
                 }
@@ -381,12 +391,12 @@ namespace Bmp.WinForms
 
         private void TrackPrev()
         {
-            //TODO: 上一曲
+            //TODO: 上一曲(按播放模式)
         }
 
         private void TrackNext()
         {
-            //TODO: 下一曲
+            //TODO: 下一曲(按播放模式)
         }
 
         // -----------------  playback event -----------------
@@ -409,7 +419,7 @@ namespace Bmp.WinForms
             }
             else
             {
-                //TODO: 消息机制
+                //TODO: 消息机制 因为发生错误而停止
                 _playbackState = UIPlaybackState.Error;
             }
         }
@@ -778,7 +788,7 @@ namespace Bmp.WinForms
                 var point = MainListView.PointToClient(new Point(e.X, e.Y));
 
                 var targetIndex = MainListView.InsertionMark.NearestIndex(point);
-                //BUG: move down
+
                 if (targetIndex >= 0 && targetIndex < MainListView.Items.Count)
                 {
                     foreach (var item in items!)
@@ -1015,9 +1025,9 @@ namespace Bmp.WinForms
                     unit = "M";
                 }
 
-                sb.Append(sampleRate % 1000 == 0
-                    ? $"/{sampleRate / 1000.0:N0}{unit}Hz"
-                    : $"/{sampleRate / 1000.0:N1}{unit}Hz");
+                sb.Append(sampleRate % 1000 == 0 
+                    ? $"/{sampleRate / 1000.0}{unit}Hz" 
+                    :$"/{Math.Floor((float)sampleRate / 100) / 10.0:0.0}{unit}Hz");
             }
 
             if (_selectedOutputDevice != null && _playbackState == UIPlaybackState.Playing)
@@ -1032,7 +1042,7 @@ namespace Bmp.WinForms
                     }
                     catch (Exception exception)
                     {
-                        //TODO: 异常处理
+                        //TODO: 异常处理 UpdateTimer_Tick asioOut.Driver.Capabilities.OutputChannelInfos
                         Console.WriteLine(exception);
                     }
                 }