2 * Copyright (C) 2010 David Adam
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/test.h"
25 static unsigned char mp3file
[] = "\xFF\xFB\x92\x04"; /* MP3 header */
26 static unsigned char rifffile
[8+4+8+16+8+256] = "RIFF\x24\x01\x00\x00WAVE" /* header: 4 ("WAVE") + (8 + 16) (format segment) + (8 + 256) (data segment) = 0x124 */
27 "fmt \x10\x00\x00\x00\x01\x00\x20\x00\xAC\x44\x00\x00\x10\xB1\x02\x00\x04\x00\x10\x00" /* format segment: PCM, 2 chan, 44100 Hz, 16 bits */
28 "data\x00\x01\x00\x00"; /* 256 byte data segment (silence) */
30 static void test_release_object(void)
33 IDirectMusicLoader8
* loader
= NULL
;
35 hr
= CoCreateInstance(&CLSID_DirectMusicLoader
, NULL
, CLSCTX_INPROC
, &IID_IDirectMusicLoader8
, (void**)&loader
);
38 skip("CoCreateInstance failed.\n");
42 hr
= IDirectMusicLoader_ReleaseObject(loader
, NULL
);
43 ok(hr
== E_POINTER
, "Expected E_POINTER, received %#x\n", hr
);
45 IDirectMusicLoader_Release(loader
);
48 static void test_simple_playing(void)
50 IDirectMusic
*music
= NULL
;
51 IDirectMusicLoader8
*loader
;
52 IDirectMusicPerformance8
*perf
;
53 IDirectMusicAudioPath8
*path
= NULL
;
54 IDirectMusicSegment8
*segment
= NULL
;
55 IDirectMusicSegmentState
*state
= NULL
;
56 IDirectSound
*dsound
= NULL
;
57 DMUS_OBJECTDESC desc
= {0};
60 hr
= CoCreateInstance(&CLSID_DirectMusicPerformance
, NULL
,
61 CLSCTX_INPROC_SERVER
, &IID_IDirectMusicPerformance8
,
65 skip("CoCreateInstance failed.\n");
69 hr
= CoCreateInstance(&CLSID_DirectMusicLoader
, NULL
,
70 CLSCTX_INPROC_SERVER
, &IID_IDirectMusicLoader8
,
72 ok(hr
== S_OK
, "Couldn't create Loader %08x\n", hr
);
74 hr
= IDirectMusicPerformance8_InitAudio(perf
, &music
, &dsound
, NULL
,
75 DMUS_APATH_DYNAMIC_STEREO
, 64, DMUS_AUDIOF_ALL
, NULL
);
76 ok(hr
== S_OK
, "InitAudio failed: %08x\n", hr
);
77 ok(music
!= NULL
, "Didn't get IDirectMusic pointer\n");
78 ok(dsound
!= NULL
, "Didn't get IDirectSound pointer\n");
80 hr
= IDirectMusicPerformance8_CreateStandardAudioPath(perf
,
81 DMUS_APATH_DYNAMIC_STEREO
, 64, TRUE
, &path
);
82 ok(hr
== S_OK
, "CreateStandardAudioPath failed: %08x\n", hr
);
83 ok(path
!= NULL
, "Didn't get IDirectMusicAudioPath pointer\n");
85 desc
.dwSize
= sizeof(DMUS_OBJECTDESC
);
86 desc
.dwValidData
= DMUS_OBJ_CLASS
| DMUS_OBJ_MEMORY
;
87 desc
.guidClass
= CLSID_DirectMusicSegment
;
88 desc
.pbMemData
= mp3file
;
89 desc
.llMemLength
= sizeof(mp3file
);
90 hr
= IDirectMusicLoader8_GetObject(loader
, &desc
, &IID_IDirectMusicSegment8
,
92 ok(hr
== DMUS_E_UNSUPPORTED_STREAM
, "GetObject gave wrong error: %08x\n", hr
);
93 ok(segment
== NULL
, "Didn't get NULL IDirectMusicSegment pointer\n");
95 desc
.pbMemData
= rifffile
;
96 desc
.llMemLength
= sizeof(rifffile
);
97 hr
= IDirectMusicLoader8_GetObject(loader
, &desc
, &IID_IDirectMusicSegment8
,
99 ok(hr
== S_OK
, "GetObject failed: %08x\n", hr
);
100 ok(segment
!= NULL
, "Didn't get IDirectMusicSegment pointer\n");
102 hr
= IDirectMusicSegment8_Download(segment
, (IUnknown
*)path
);
103 ok(hr
== S_OK
, "Download failed: %08x\n", hr
);
105 hr
= IDirectMusicSegment8_SetRepeats(segment
, 1);
106 ok(hr
== S_OK
, "SetRepeats failed: %08x\n", hr
);
108 hr
= IDirectMusicPerformance8_PlaySegmentEx(perf
, (IUnknown
*)segment
,
109 NULL
, NULL
, DMUS_SEGF_SECONDARY
, 0, &state
, NULL
, (IUnknown
*)path
);
110 ok(hr
== S_OK
, "PlaySegmentEx failed: %08x\n", hr
);
111 ok(state
!= NULL
, "Didn't get IDirectMusicSegmentState pointer\n");
113 hr
= IDirectMusicPerformance8_CloseDown(perf
);
114 ok(hr
== S_OK
, "CloseDown failed: %08x\n", hr
);
116 IDirectSound_Release(dsound
);
117 IDirectMusicSegmentState_Release(state
);
118 IDirectMusicSegment8_Release(segment
);
119 IDirectMusic_Release(music
);
120 IDirectMusicPerformance8_Release(perf
);
121 IDirectMusicLoader8_Release(loader
);
127 test_release_object();
128 test_simple_playing();