473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Protected Memory Error from COM Interface

Hi,

I gotten Protected Memory Error while trying to access the C++ interface from C#, I am wandering is it something is not correct on my interpretation from C++ to C#. Below is the C++ Interface code and next to it is my C# code.

//*************** C++ Code ************************************************** ***
// {AEB23DA0-54BB-11d2-BD98-0080ADB67301}
DEFINE_GUID(IID_IAudioOutput,
0xaeb23da0, 0x54bb, 0x11d2, 0xbd, 0x98, 0x0, 0x80, 0xad, 0xb6, 0x73, 0x1);


/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////

// The different audio output format
#ifndef _Quasar_AudioOutputType
#define _Quasar_AudioOutputType
typedef enum
{
DIGITAL_AUDIO, // Through On-board DAC
PCM_AUDIO, // Through Quasar SpDiff channel, no AC-3
AC3_AUDIO // Through Quasar SpDiff channel
} AUDIO_OUTPUT, *PAUDIO_OUTPUT;
#endif

// Audio channel
#ifndef _Quasar_AudioOutputMode
#define _Quasar_AudioOutputMode
typedef enum
{
STEREO,
LEFT_ONLY, // Right channel output on both speakers
RIGHT_ONLY // Left channel output on both speakers
} AUDIO_CHANNEL, *PAUDIO_CHANNEL;
#endif

/////////////////////////////////////////////////////////////////////////////
// interface IAudioOutput used to get/set audio output (Digital, PCM or AC3)

interface IAudioOutput : public IUnknown
{
public:
STDMETHOD(GetOutput)(PAUDIO_OUTPUT pAudioOutput) PURE;
STDMETHOD(SetOutput)(AUDIO_OUTPUT AudioOutput) PURE;
STDMETHOD(GetChannel)(PAUDIO_CHANNEL pAudioChannel) PURE;
STDMETHOD(SetChannel)(AUDIO_CHANNEL AudioChannel) PURE;
};

/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////


//*************************************** C# Code *******************************
public enum AUDIO_OUTPUT : int
{
DIGITAL_AUDIO=0,
PCM_AUDIO=1,
AC3_AUDIO=2 // Through Quasar SpDiff channel
}

public enum AUDIO_CHANNEL : int
{
STEREO=0,
LEFT_ONLY=1,
RIGHT_ONLY=2 // Left channel output on both speakers
}


[ComVisible(true), ComImport,
Guid("AEB23DA0-54BB-11d2-BD98-0080ADB67301"),
InterfaceType(ComInterfaceType.InterfaceIsDual )]
public interface IAudioOutput
{

[PreserveSig]
int SetOutPut(AUDIO_CHANNEL pAudioOutput);


[PreserveSig]
int GetOutput([Out]out AUDIO_CHANNEL pAudioOutput);


[PreserveSig]
int SetMode(AUDIO_CHANNEL AudioMode);


[PreserveSig]
int GetMode([Out]out AUDIO_CHANNEL pAudioMode);

}
Sep 16 '07 #1
0 892

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Adam H. Peterson | last post by:
I just made an observation and I wondered if it's generally known (or if I'm missing something). My observation is that static protected members are essentially useless, only a hint to the user. ...
2
by: Ilkka | last post by:
I have created an C++ application with Windows Forms, ADO and SQL server 2005. Now I need to change something and started debugging the code. Then suddenly I receive an error. "An unhandled...
0
by: harisenbon | last post by:
Hello All, I'm starting into the wide world of using unmanaged C++ dlls in my C# programs, and I've run into sort of an issue. I've used the win32 and user32 dlls with no problem in the past, but...
3
by: sriram347 | last post by:
Hi I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error. B]Error message : "System.AccessViolation Exception attempted to read or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.