@@ -1730,9 +1730,10 @@ static void test_performance_pmsg(void)
1730
1730
static const DWORD delivery_flags [] = {DMUS_PMSGF_TOOL_IMMEDIATE , DMUS_PMSGF_TOOL_QUEUE , DMUS_PMSGF_TOOL_ATTIME };
1731
1731
static const DWORD message_types [] = {DMUS_PMSGT_MIDI , DMUS_PMSGT_USER };
1732
1732
IDirectMusicPerformance * performance ;
1733
- IDirectMusicGraph * graph ;
1733
+ IDirectMusicGraph * graph , * performance_graph ;
1734
1734
IDirectMusicTool * tool ;
1735
1735
DMUS_PMSG * msg , * clone ;
1736
+ MUSIC_TIME music_time ;
1736
1737
REFERENCE_TIME time ;
1737
1738
HRESULT hr ;
1738
1739
DWORD ret ;
@@ -1744,6 +1745,8 @@ static void test_performance_pmsg(void)
1744
1745
hr = CoCreateInstance (& CLSID_DirectMusicPerformance , NULL , CLSCTX_INPROC_SERVER ,
1745
1746
& IID_IDirectMusicPerformance , (void * * )& performance );
1746
1747
ok (hr == S_OK , "got %#lx\n" , hr );
1748
+ hr = IDirectMusicPerformance_QueryInterface (performance , & IID_IDirectMusicGraph , (void * * )& performance_graph );
1749
+ ok (hr == S_OK , "got %#lx\n" , hr );
1747
1750
1748
1751
1749
1752
hr = IDirectMusicPerformance_AllocPMsg (performance , 0 , NULL );
@@ -1826,64 +1829,107 @@ static void test_performance_pmsg(void)
1826
1829
ok (hr == S_OK , "got %#lx\n" , hr );
1827
1830
1828
1831
1832
+ /* SendPMsg skips all the tools unless messages are stamped beforehand */
1833
+
1834
+ hr = IDirectMusicPerformance_AllocPMsg (performance , sizeof (DMUS_PMSG ), & msg );
1835
+ ok (hr == S_OK , "got %#lx\n" , hr );
1836
+ ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1837
+ msg -> mtTime = 0 ;
1838
+ msg -> dwFlags = DMUS_PMSGF_MUSICTIME ;
1839
+ msg -> dwType = DMUS_PMSGT_USER ;
1840
+ hr = IDirectMusicPerformance_SendPMsg (performance , msg );
1841
+ ok (hr == S_OK , "got %#lx\n" , hr );
1842
+
1843
+ ret = test_tool_wait_message (tool , 10 , & msg );
1844
+ ok (ret == WAIT_TIMEOUT , "got %#lx\n" , ret );
1845
+ ok (!msg , "got %p\n" , msg );
1846
+
1847
+
1848
+ /* SendPMsg converts music time to reference time if it is missing */
1849
+
1850
+ hr = IDirectMusicPerformance_AllocPMsg (performance , sizeof (DMUS_PMSG ), & msg );
1851
+ ok (hr == S_OK , "got %#lx\n" , hr );
1852
+ ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1853
+ msg -> mtTime = 500 ;
1854
+ msg -> dwFlags = DMUS_PMSGF_MUSICTIME ;
1855
+ msg -> dwType = DMUS_PMSGT_USER ;
1856
+ hr = IDirectMusicGraph_StampPMsg (performance_graph , msg );
1857
+ ok (hr == S_OK , "got %#lx\n" , hr );
1858
+ hr = IDirectMusicPerformance_SendPMsg (performance , msg );
1859
+ ok (hr == S_OK , "got %#lx\n" , hr );
1860
+
1861
+ ret = test_tool_wait_message (tool , 50 , & msg );
1862
+ todo_wine ok (!ret , "got %#lx\n" , ret );
1863
+ todo_wine ok (msg != NULL , "got %p\n" , msg );
1864
+ if (!msg ) goto skip_rtime ;
1865
+
1829
1866
time = 0xdeadbeef ;
1830
1867
hr = IDirectMusicPerformance_MusicToReferenceTime (performance , msg -> mtTime , & time );
1831
1868
ok (hr == S_OK , "got %#lx\n" , hr );
1832
1869
ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1833
1870
todo_wine ok (msg -> rtTime == time , "got %I64d\n" , msg -> rtTime );
1834
1871
ok (msg -> mtTime == 500 , "got %ld\n" , msg -> mtTime );
1835
1872
todo_wine ok (msg -> dwFlags & DMUS_PMSGF_REFTIME , "got %#lx\n" , msg -> dwFlags );
1873
+ todo_wine ok (msg -> dwFlags & DMUS_PMSGF_MUSICTIME , "got %#lx\n" , msg -> dwFlags );
1836
1874
todo_wine ok (msg -> dwFlags & (DMUS_PMSGF_TOOL_QUEUE | DMUS_PMSGF_TOOL_IMMEDIATE ), "got %#lx\n" , msg -> dwFlags );
1837
1875
ok (!msg -> dwPChannel , "got %ld\n" , msg -> dwPChannel );
1838
1876
ok (!msg -> dwVirtualTrackID , "got %ld\n" , msg -> dwVirtualTrackID );
1839
- ok (! msg -> pTool , "got %p\n" , msg -> pTool );
1840
- ok (! msg -> pGraph , "got %p\n" , msg -> pGraph );
1841
- ok (! msg -> dwType , "got %#lx\n" , msg -> dwType );
1877
+ ok (msg -> pTool == tool , "got %p\n" , msg -> pTool );
1878
+ ok (msg -> pGraph == performance_graph , "got %p\n" , msg -> pGraph );
1879
+ ok (msg -> dwType == DMUS_PMSGT_USER , "got %#lx\n" , msg -> dwType );
1842
1880
ok (!msg -> dwVoiceID , "got %ld\n" , msg -> dwVoiceID );
1843
1881
ok (!msg -> dwGroupID , "got %ld\n" , msg -> dwGroupID );
1844
1882
ok (!msg -> punkUser , "got %p\n" , msg -> punkUser );
1845
1883
1846
-
1847
- /* SendPMsg skips all the tools unless messages are stamped beforehand */
1848
-
1849
- hr = IDirectMusicPerformance_AllocPMsg (performance , sizeof (DMUS_PMSG ), & msg );
1850
- ok (hr == S_OK , "got %#lx\n" , hr );
1851
- ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1852
- msg -> rtTime = time ;
1853
- msg -> dwFlags = DMUS_PMSGF_REFTIME ;
1854
- msg -> dwType = DMUS_PMSGT_USER ;
1855
- hr = IDirectMusicPerformance_SendPMsg (performance , msg );
1884
+ hr = IDirectMusicPerformance_FreePMsg (performance , msg );
1856
1885
ok (hr == S_OK , "got %#lx\n" , hr );
1857
1886
1858
- ret = test_tool_wait_message (tool , 10 , & msg );
1859
- ok (ret == WAIT_TIMEOUT , "got %#lx\n" , ret );
1860
- ok (!msg , "got %p\n" , msg );
1861
1887
1888
+ skip_rtime :
1889
+ /* SendPMsg converts reference time to music time if it is missing */
1890
+
1891
+ hr = IDirectMusicPerformance_GetTime (performance , & time , & music_time );
1892
+ ok (hr == S_OK , "got %#lx\n" , hr );
1862
1893
1863
1894
hr = IDirectMusicPerformance_AllocPMsg (performance , sizeof (DMUS_PMSG ), & msg );
1864
1895
ok (hr == S_OK , "got %#lx\n" , hr );
1865
1896
ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1866
1897
msg -> rtTime = time ;
1867
1898
msg -> dwFlags = DMUS_PMSGF_REFTIME ;
1868
1899
msg -> dwType = DMUS_PMSGT_USER ;
1869
-
1870
- hr = IDirectMusicPerformance_QueryInterface (performance , & IID_IDirectMusicGraph , (void * * )& graph );
1900
+ hr = IDirectMusicGraph_StampPMsg (performance_graph , msg );
1871
1901
ok (hr == S_OK , "got %#lx\n" , hr );
1872
- hr = IDirectMusicGraph_StampPMsg (graph , msg );
1873
- ok (hr == S_OK , "got %#lx\n" , hr );
1874
- IDirectMusicGraph_Release (graph );
1875
-
1876
1902
hr = IDirectMusicPerformance_SendPMsg (performance , msg );
1877
1903
ok (hr == S_OK , "got %#lx\n" , hr );
1878
1904
1879
1905
ret = test_tool_wait_message (tool , 50 , & msg );
1880
1906
todo_wine ok (!ret , "got %#lx\n" , ret );
1881
1907
todo_wine ok (msg != NULL , "got %p\n" , msg );
1882
- if (!msg ) hr = S_OK ;
1883
- else hr = IDirectMusicPerformance_FreePMsg (performance , msg );
1908
+ if (!msg ) goto skip_mtime ;
1909
+
1910
+ music_time = 0xdeadbeef ;
1911
+ hr = IDirectMusicPerformance_ReferenceToMusicTime (performance , msg -> rtTime , & music_time );
1912
+ ok (hr == S_OK , "got %#lx\n" , hr );
1913
+ ok (msg -> dwSize == sizeof (DMUS_PMSG ), "got %ld\n" , msg -> dwSize );
1914
+ todo_wine ok (msg -> rtTime == time , "got %I64d\n" , msg -> rtTime );
1915
+ todo_wine ok (msg -> mtTime == music_time , "got %ld\n" , msg -> mtTime );
1916
+ todo_wine ok (msg -> dwFlags & DMUS_PMSGF_REFTIME , "got %#lx\n" , msg -> dwFlags );
1917
+ todo_wine ok (msg -> dwFlags & DMUS_PMSGF_MUSICTIME , "got %#lx\n" , msg -> dwFlags );
1918
+ todo_wine ok (msg -> dwFlags & (DMUS_PMSGF_TOOL_QUEUE | DMUS_PMSGF_TOOL_IMMEDIATE ), "got %#lx\n" , msg -> dwFlags );
1919
+ ok (!msg -> dwPChannel , "got %ld\n" , msg -> dwPChannel );
1920
+ ok (!msg -> dwVirtualTrackID , "got %ld\n" , msg -> dwVirtualTrackID );
1921
+ ok (msg -> pTool == tool , "got %p\n" , msg -> pTool );
1922
+ ok (msg -> pGraph == performance_graph , "got %p\n" , msg -> pGraph );
1923
+ ok (msg -> dwType == DMUS_PMSGT_USER , "got %#lx\n" , msg -> dwType );
1924
+ ok (!msg -> dwVoiceID , "got %ld\n" , msg -> dwVoiceID );
1925
+ ok (!msg -> dwGroupID , "got %ld\n" , msg -> dwGroupID );
1926
+ ok (!msg -> punkUser , "got %p\n" , msg -> punkUser );
1927
+
1928
+ hr = IDirectMusicPerformance_FreePMsg (performance , msg );
1884
1929
ok (hr == S_OK , "got %#lx\n" , hr );
1885
1930
1886
1931
1932
+ skip_mtime :
1887
1933
for (i = 0 ; i < ARRAY_SIZE (delivery_flags ); i ++ )
1888
1934
{
1889
1935
DWORD duration = 0 ;
@@ -1896,12 +1942,8 @@ static void test_performance_pmsg(void)
1896
1942
msg -> rtTime = time + 150 * 10000 ;
1897
1943
msg -> dwFlags = DMUS_PMSGF_REFTIME ;
1898
1944
msg -> dwType = DMUS_PMSGT_USER ;
1899
-
1900
- hr = IDirectMusicPerformance_QueryInterface (performance , & IID_IDirectMusicGraph , (void * * )& graph );
1901
- ok (hr == S_OK , "got %#lx\n" , hr );
1902
- hr = IDirectMusicGraph_StampPMsg (graph , msg );
1945
+ hr = IDirectMusicGraph_StampPMsg (performance_graph , msg );
1903
1946
ok (hr == S_OK , "got %#lx\n" , hr );
1904
- IDirectMusicGraph_Release (graph );
1905
1947
1906
1948
msg -> dwFlags &= ~(DMUS_PMSGF_TOOL_IMMEDIATE | DMUS_PMSGF_TOOL_QUEUE | DMUS_PMSGF_TOOL_ATTIME );
1907
1949
msg -> dwFlags |= delivery_flags [i ];
@@ -1921,8 +1963,8 @@ static void test_performance_pmsg(void)
1921
1963
switch (delivery_flags [i ])
1922
1964
{
1923
1965
case DMUS_PMSGF_TOOL_IMMEDIATE : todo_wine ok (duration <= 50 , "got %lu\n" , duration ); break ;
1924
- case DMUS_PMSGF_TOOL_QUEUE : todo_wine ok (duration >= 50 && duration <= 100 , "got %lu\n" , duration ); break ;
1925
- case DMUS_PMSGF_TOOL_ATTIME : todo_wine ok (duration >= 150 && duration <= 500 , "got %lu\n" , duration ); break ;
1966
+ case DMUS_PMSGF_TOOL_QUEUE : todo_wine ok (duration >= 50 && duration <= 125 , "got %lu\n" , duration ); break ;
1967
+ case DMUS_PMSGF_TOOL_ATTIME : todo_wine ok (duration >= 125 && duration <= 500 , "got %lu\n" , duration ); break ;
1926
1968
}
1927
1969
}
1928
1970
@@ -1931,7 +1973,10 @@ static void test_performance_pmsg(void)
1931
1973
ok (hr == S_OK , "got %#lx\n" , hr );
1932
1974
1933
1975
1976
+ IDirectMusicGraph_Release (performance_graph );
1977
+
1934
1978
IDirectMusicPerformance_Release (performance );
1979
+ IDirectMusicTool_Release (tool );
1935
1980
}
1936
1981
1937
1982
START_TEST (dmime )
0 commit comments