| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 704 人关注过本帖
标题:【求助】vs2012下DirectSound的问题
只看楼主 加入收藏
lq983065876
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-6-13
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
【求助】vs2012下DirectSound的问题
问题: if(FAILED(hr = mainbuffer->
         {
             MessageBox(hWnd,TEXT("Create ....."),TEXT("Error"),MB_OK);
              return 0;
         }
       总是创建失败,弹出对话框。   代码是照着某网站敲的。
顺便求解QueryInterface(IID_IDirectSound3DBuffer8,(LPVOID*)&sbuffer)是干什么用的?

代码如下:
         //声音测试
         LPDIRECTSOUNDBUFFER8    sbuffer = NULL;
         LPDIRECTSOUND8            device = NULL;
         CWaveFile* file = NULL;
         HRESULT hr;
         
         if(FAILED(hr = DirectSoundCreate8(NULL, &device, NULL)))
         {
             MessageBox(hWnd,TEXT("Create Sound"),TEXT("Error"),MB_OK);
             return 0;
         }
         if(FAILED(hr = device->SetCooperativeLevel(hWnd, DSSCL_PRIORITY)))
         {
             MessageBox(hWnd,TEXT("Create Cooperative"),TEXT("Error"),MB_OK);
             return 0;
         }

         file = new CWaveFile;
         file->Open(_T("D:\\mySAO\\handsonic.wav"), NULL, WAVEFILE_READ);
         DSBUFFERDESC desc;
         ZeroMemory(&desc,sizeof(DSBUFFERDESC));

         desc.dwSize = sizeof(DSBUFFERDESC);
         desc.dwFlags = DSBCAPS_GLOBALFOCUS | DSBCAPS_CTRLFX| DSBCAPS_CTRLPOSITIONNOTIFY |DSBCAPS_GETCURRENTPOSITION2;
         desc.dwBufferBytes = file->GetSize();
         desc.lpwfxFormat = file->m_pwfx;

         LPDIRECTSOUNDBUFFER mainbuffer = NULL;
         if(FAILED(hr = device->CreateSoundBuffer(&desc,&mainbuffer,NULL)))
         {
             MessageBox(hWnd,TEXT("Create soubdbuffer"),TEXT("Error"),MB_OK);
             return 0;
         }
         if(FAILED(hr = mainbuffer->QueryInterface(IID_IDirectSound3DBuffer8,(LPVOID*)&sbuffer)))
         {
             MessageBox(hWnd,TEXT("Create ....."),TEXT("Error"),MB_OK);
              return 0;
         }
         mainbuffer->Release();

         LPVOID lock;
         DWORD  len;
         DWORD  write;
         sbuffer->Lock(0, 0, &lock, &len, NULL, NULL, DSBLOCK_ENTIREBUFFER);
         file->Read((BYTE*)lock, len, &write);
         sbuffer->Unlock((LPVOID)lock, len, NULL, 0);
         sbuffer->SetCurrentPosition(0);
         
搜索更多相关主题的帖子: Create return 对话框 干什么 
2013-06-13 23:20
蚕头燕尾
Rank: 10Rank: 10Rank: 10
来 自:Gryffindo
等 级:贵宾
威 望:12
帖 子:734
专家分:1546
注 册:2013-3-24
收藏
得分:20 
学习了。好高端的样子,帮顶了。


学习编程,为的是表达自己的思想,而不是被别人的思想所禁锢。要先明白自己想干嘛,而不要先问别人让你干嘛。               

                                                                                                                    Black Cat      Hello Tomorrow~
2013-06-13 23:27
快速回复:【求助】vs2012下DirectSound的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031591 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved