作者 主題: (ACM 聲音壓縮 PCM轉GSM) acmStreamOpen 錯誤? 我已經努力了3天了,拜託各位大哥幫幫忙  (閱讀 3909 次)

0 會員 與 1 訪客 正在閱讀本文。

scott777

  • 可愛的小學生
  • *
  • 文章數: 2
    • 檢視個人資料
請問各位先進,當小弟執行下列程式碼時
acmStreamOpen總是傳回ACMERR_NOTPOSSIBLE的錯誤
請問要如何解決呢?

ps.如果是PCM 8bits轉PCM 16bits程式又沒問題.
我已經努力了3天了,拜託各位大哥幫幫忙


代碼: [選擇]

int main(int argc, char* argv[])
{
    MMRESULT mmr;
    WORD wFormatTag = WAVE_FORMAT_GSM610;

    HACMDRIVERID hadid = find_driver(wFormatTag);
    if (hadid == NULL) {
        printf("No driver found\n");
        exit(1);
    }
    printf("Driver found (hadid: %4.4lXH)\n", hadid);

HACMDRIVER had = NULL;
    mmr = acmDriverOpen(&had, hadid, 0);
    if (mmr) {
        printf("Failed to open driver\n");
        exit(1);
    }

memset(&wfPCM, 0, sizeof(wfPCM));

// PCM
wfPCM.cbSize = 0;
wfPCM.wFormatTag = WAVE_FORMAT_PCM;
wfPCM.nChannels = 1;
wfPCM.nSamplesPerSec = 11025;
wfPCM.wBitsPerSample = 16;
wfPCM.nBlockAlign = wfPCM.nChannels * wfPCM.wBitsPerSample / 8;
wfPCM.nAvgBytesPerSec = wfPCM.nSamplesPerSec * wfPCM.nBlockAlign;

// GSM
wfDrv.cbSize = 2;
wfDrv.wFormatTag = WAVE_FORMAT_GSM610;
wfDrv.nAvgBytesPerSec = 1625;
wfDrv.nBlockAlign = 65;
wfDrv.nChannels = 1;
wfDrv.nSamplesPerSec = 8000;
wfDrv.wBitsPerSample = 0;


printf("--------------------------------------------------------\n");
HACMSTREAM hstr = NULL;
    mmr = acmStreamOpen(&hstr,
                        had,
                        &wfPCM,
                        &wfDrv,
                        NULL,
                        NULL,
                        0,
                        ACM_STREAMOPENF_NONREALTIME);
    if (mmr) {
        printf("Failed to open a stream to do PCM to GSM conversion\n");
switch(mmr)
{
case ACMERR_NOTPOSSIBLE:
printf("The requested operation cannot be performed.\n");
break;
case MMSYSERR_INVALFLAG:
printf("At least one flag is invalid. \n");
break;
case MMSYSERR_INVALHANDLE:
printf("The specified handle is invalid. \n");
break;
case MMSYSERR_INVALPARAM:
printf("At least one parameter is invalid. \n");
break;
case MMSYSERR_NOMEM:
printf("The system is unable to allocate resources.\n");
break;
}
        exit(1);
    }
    return 0;
}