Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
3.0 KiB

  1. /****************************************************************************
  2. MODULE: MIDI_OUT.CPP
  3. Tab stops 5 9
  4. Copyright 1995, 1996, Microsoft Corporation, All Rights Reserved.
  5. PURPOSE: Uses a low-level callback function to get timestamped
  6. MIDI output. The callback function sets an Event to indicate
  7. to wake up a blocked object.
  8. FUNCTIONS:
  9. Author(s): Name:
  10. ---------- ----------------
  11. MEA Manolito E. Adan
  12. Revision History:
  13. -----------------
  14. Version Date Author Comments
  15. ------- ------ ----- -------------------------------------------
  16. 1.0 10-Jan-97 MEA original
  17. ****************************************************************************/
  18. #include <windows.h>
  19. #include <mmsystem.h>
  20. #include <stdio.h>
  21. #include <crtdbg.h>
  22. #include "midi_obj.hpp"
  23. /****************************************************************************
  24. Declaration of externs
  25. ****************************************************************************/
  26. #ifdef _DEBUG
  27. extern char g_cMsg[160];
  28. #endif
  29. // Prototypes
  30. void CALLBACK midiOutputHandler(HMIDIOUT, UINT, DWORD, DWORD, DWORD);
  31. // ----------------------------------------------------------------------------
  32. // Function: midiOutputHandler
  33. // Purpose:
  34. // Parameters: hMidiIn - Handle for the associated output device.
  35. // wMsg - One of the MIM_***** messages.
  36. // dwInstance - Points to CALLBACKINSTANCEDATA structure.
  37. // dwParam1 - MIDI data.
  38. // dwParam2 - Timestamp (in milliseconds)
  39. //
  40. // Returns: none
  41. // Algorithm:
  42. // Comments:
  43. // Low-level callback function to handle MIDI output.
  44. // Installed by midiOutOpen(). The Output handler checks for MM_MOM_DONE
  45. // message and wakes up the thread waiting for completion of MIDI SysEx
  46. // output. Note: Normal Short messages don't get notification!!!
  47. // This function is accessed at interrupt time, so it should be as
  48. // fast and efficient as possible. You can't make any
  49. // Windows calls here, except PostMessage(). The only Multimedia
  50. // Windows call you can make are timeGetSystemTime(), midiOutShortMsg().
  51. // ----------------------------------------------------------------------------
  52. void CALLBACK midiOutputHandler(
  53. IN HMIDIOUT hMidiOut,
  54. IN UINT wMsg,
  55. IN DWORD dwInstance,
  56. IN DWORD dwParam1,
  57. IN DWORD dwParam2)
  58. {
  59. CJoltMidi *pJoltMidi = (CJoltMidi *) dwInstance;
  60. assert(pJoltMidi);
  61. BOOL bRet;
  62. switch(wMsg)
  63. {
  64. case MOM_OPEN:
  65. #ifdef _DEBUG
  66. _RPT0(_CRT_WARN, "midiOutputHandler: MOM_OPEN.\n");
  67. #endif
  68. break;
  69. case MM_MOM_DONE:
  70. #ifdef _DEBUG
  71. _RPT0(_CRT_WARN, "midiOutputHandler: MM_MOM_DONE\n");
  72. #endif
  73. // Notify task waiting on this object to trigger
  74. bRet = SetEvent(pJoltMidi->MidiOutputEventHandleOf());
  75. assert(bRet);
  76. break;
  77. default:
  78. #ifdef _DEBUG
  79. _RPT0(_CRT_WARN, "midiOutputHandler: default case.\n");
  80. #endif
  81. break;
  82. }
  83. }