OSDN Git Service

#34800 サウンド設定の変更時に、NullReferenceの例外が発生することがあった問題を修正。
authoryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Tue, 13 Jan 2015 13:15:11 +0000 (13:15 +0000)
committeryyagi <yyagi@16f42ceb-6dc6-49c8-ba94-f2d53467949d>
Tue, 13 Jan 2015 13:15:11 +0000 (13:15 +0000)
git-svn-id: http://svn.osdn.jp/svnroot/dtxmania/trunk@809 16f42ceb-6dc6-49c8-ba94-f2d53467949d

FDK17プロジェクト/コード/03.サウンド/CSound.cs
FDK17プロジェクト/コード/03.サウンド/CSoundTimer.cs
実行時フォルダ(DTXCreator)/dll/FDK.dll
実行時フォルダ/DTXManiaGR.exe
実行時フォルダ/dll/FDK.dll

index 9609fb8..be0b896 100644 (file)
@@ -1574,7 +1574,7 @@ Debug.WriteLine("更に再生に失敗: " + Path.GetFileName(this.strファイ
                                // DirectShowのデコードに失敗したら、次はACMでのデコードを試すことになるため、ここではエラーログを出さない。\r
                                // Trace.TraceWarning( "Warning: " + Path.GetFileName( strファイル名 ) + " : デコードに失敗しました。" );\r
                        }\r
-                       catch ( Exception )\r
+                       catch ( Exception )\r
                        {\r
                                Trace.TraceWarning( "Warning: " + Path.GetFileName( strファイル名 ) + " : 読み込みに失敗しました。" );\r
                        }\r
index d5aa3ee..02149bb 100644 (file)
@@ -83,9 +83,20 @@ namespace FDK
                {\r
                        if ( this.Device.e出力デバイス != ESoundDeviceType.DirectSound )\r
                        {\r
-                               this.nDInputTimerCounter = this.ctDInputTimer.nシステム時刻ms;\r
-                               this.nSoundTimerCounter = this.nシステム時刻ms;\r
-                               //Debug.WriteLine( "BaseCounter: " + nDInputTimerCounter + ", " + nSoundTimerCounter );\r
+                               try\r
+                               {\r
+                                       this.nDInputTimerCounter = this.ctDInputTimer.nシステム時刻ms;\r
+                                       this.nSoundTimerCounter = this.nシステム時刻ms;\r
+                                       //Debug.WriteLine( "BaseCounter: " + nDInputTimerCounter + ", " + nSoundTimerCounter );\r
+                               }\r
+                               catch ( Exception e )\r
+                               // サウンド設定変更時に、timer.Dispose()した後、timerが実際に停止する前にここに来てしまう場合があり\r
+                               // その際にNullReferenceExceptionが発生する\r
+                               // timerが実際に停止したことを検出してから次の設定をすべきだが、実装が難しいため、\r
+                               // ここで単に例外破棄することで代替する\r
+                               {\r
+                                       Trace.TraceInformation("FDK: CSoundTimer.SnapTimers(): 例外発生しましたが、継続します。" + e.Message );\r
+                               }\r
                        }\r
                }\r
                public long nサウンドタイマーのシステム時刻msへの変換( long nDInputのタイムスタンプ )\r
@@ -177,6 +188,8 @@ Debug.WriteLine( "B" );
                        if ( timer != null )\r
                        {\r
                                timer.Change( System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite );\r
+                               // ここで、実際にtimerが停止したことを確認するコードを追加すべきだが、やり方わからず。\r
+                               // 代替策として、SnapTimers()中で、例外発生を破棄している。\r
                                timer.Dispose();\r
                                timer = null;\r
                        }\r
@@ -190,7 +203,7 @@ Debug.WriteLine( "B" );
 \r
                public ISoundDevice Device = null;      // debugのため、一時的にprotectedをpublicにする。後で元に戻しておくこと。\r
                //protected Thread thSendInput = null;\r
-               protected Thread thSnapTimers = null;\r
+               //protected Thread thSnapTimers = null;\r
                private CTimer ctDInputTimer = null;\r
                private long nDInputTimerCounter = 0;\r
                private long nSoundTimerCounter = 0;\r
index 155a8e8..5ba8fd0 100644 (file)
Binary files a/実行時フォルダ(DTXCreator)/dll/FDK.dll and b/実行時フォルダ(DTXCreator)/dll/FDK.dll differ
index cbe2a13..3776efb 100644 (file)
Binary files a/実行時フォルダ/DTXManiaGR.exe and b/実行時フォルダ/DTXManiaGR.exe differ
index 155a8e8..5ba8fd0 100644 (file)
Binary files a/実行時フォルダ/dll/FDK.dll and b/実行時フォルダ/dll/FDK.dll differ