0

Some parts that includes important function of Playsound

MCI_OPEN_PARMS m_mciOpenParms;
MCI_PLAY_PARMS m_mciPlayParms;
DWORD m_dwDeviceID;
MCI_OPEN_PARMS mciOpen;
MCI_PLAY_PARMS mciPlay;

int dwID;
//
#define TITLE_SPACE 55
#define TITLE_ENTER 10
/*music address*/#definedecision_change "C:\\Users\\chanho\\Desktop\\decision_change.wav"
#define main_theme "C:\\Users\\chanho\\Desktop\\FlappyChicken.mp3"

part of my code

        if (inner_time == 0)
    {
        //bgm
        mciOpen.lpstrElementName = TEXT(main_theme);
        mciOpen.lpstrDeviceType = "mpegvideo";
        mciSendCommand(NULL, MCI_OPEN, MCI_OPEN_ELEMENT | MCI_OPEN_TYPE, (DWORD)(LPVOID)&mciOpen);
        dwID = mciOpen.wDeviceID;
        mciSendCommand(dwID, MCI_PLAY, MCI_DGV_PLAY_REPEAT, (DWORD)(LPVOID)&m_mciPlayParms);
        //
    }

It worked well on other PCs or laptop, but when I insert this code and comfile it, It returns weird exit code and stops at the moment of "part of my code"

when I delete this "part of my code", it worked without problem.

No error occured on comfiling this code, even though it has weird exit code.

Could anyone explain me why only my laptop returns that -107~~~ code thing and how to fix it?

LtWorf
  • 7,286
  • 6
  • 31
  • 45
Ju Jeong
  • 3
  • 2
  • 1
    Unrolled my edit - perhaps "comfile" is meant. – chux - Reinstate Monica Nov 29 '18 at 00:30
  • You say PlaySound is failing, but you don't show that code - you're showing mciSendCommand. Can you show the code that actually fails and how you're inferring the error code? Also, unless something has changed in recent versions of Windows, PlaySound API only supports WAV files. (You can however, build a WAV container file for MP3 bytes). – selbie Nov 29 '18 at 02:55
  • Complete, minimal, verifiable example is really needed here. – selbie Nov 29 '18 at 02:55
  • It is actually mciSendCommand. Right. I dunno y I said PlaySound... huh – Ju Jeong Nov 30 '18 at 00:03

1 Answers1

0

well -1073741819 is 0xc0000005 in hex, which is ACCESS_VIOLATION

maybe you dont have read permission on the file

see Exception Error c0000005 in VC++

On second thoughts this is not a perm thing but a memory read write error. I suspect that you are not testing a return value somewhere and are thus using a NULL pointer that was returned by a function. You dont show enough code to be able to tell though

pm100
  • 48,078
  • 23
  • 82
  • 145
  • It's likely due to the `(DWORD)(LPVOID)` cast in the OP's code. That's not a `DWORD_PTR`. Casting to `DWORD` truncates the upper 32-bit value of `&mciOpen` if it's a 64-bit address. – Eryk Sun Nov 29 '18 at 14:52