示例#1
0
void *_GalSS_init_server(GalIO_ServerStruct *server, int argc, char **argv)
{
  char *data_file = (char *) NULL;
  AudioDevice *a;
  AudioPkg *p;
  int num_batch = 0;
  
  if (GalUtil_OACheckUsage(argc, argv, oas, NULL) == 0)	
    exit(1);
  
  if (GalUtil_OAExtract(argc, argv, oas, "-audio_data",
			GAL_OA_STRING, &data_file) == 0) {
    GalUtil_Warn("No -audio_data argument. Exiting.");
    exit(1);
  }
  GalUtil_OAExtract(argc, argv, oas, "-batch",
		    GAL_OA_INT, &num_batch);
  a = InitializeAudio(data_file, __AudioPoll, num_batch);
  free(data_file);
  if (!a) {
    GalUtil_Warn("Can't initialize audio device. Exiting.");
    exit(1);
  }
  p = (AudioPkg *) calloc(1, sizeof(AudioPkg));
  p->device = a;
  a->client_data = (void *) p;
  return (void *) p;
}
示例#2
0
文件: Main.cpp 项目: 173210/project64
EXPORT void CALL AiDacrateChanged(int SystemType)
{
    WriteTrace(TraceAudioInterface, TraceDebug, "Start (SystemType: %d)",SystemType);
    if (!g_PluginInit)
    {
        WriteTrace(TraceAudioInterface, TraceNotice, "Plugin has not been initilized");
        WriteTrace(TraceAudioInterface, TraceDebug, "Done");
        return;
    }

    int f = g_GameFreq != 0 ? g_GameFreq : DEFAULT_FREQUENCY;
    switch (SystemType)
    {
        case SYSTEM_NTSC:
            f = 48681812 / (*g_AudioInfo.AI__DACRATE_REG + 1);
            break;
        case SYSTEM_PAL:
            f = 49656530 / (*g_AudioInfo.AI__DACRATE_REG + 1);
            break;
        case SYSTEM_MPAL:
            f = 48628316 / (*g_AudioInfo.AI__DACRATE_REG + 1);
            break;
    }
    InitializeAudio(f);
    
    WriteTrace(TraceAudioInterface, TraceDebug, "Done");
}
示例#3
0
/**
 * @brief Play the MP3 music file
 *
 */
void playMusic() {

	hMP3Decoder = MP3InitDecoder();
	InitializeAudio(Audio44100HzSettings);
	SetAudioVolume(0xCF);
	PlayAudioWithCallback(AudioCallback, 0);
}
示例#4
0
文件: main.c 项目: RDCH106/n64oid
EXPORT void CALL RomOpen()
{
    if (!l_PluginInit)
        return;

    ReadConfig();
    InitializeAudio(GameFreq);
}
示例#5
0
文件: main.c 项目: z00t/n64iphone
EXPORT void CALL AiDacrateChanged( int SystemType )
{
    int f = GameFreq;
    switch (SystemType)
    {
        case SYSTEM_NTSC:
            f = 48681812 / (*AudioInfo.AI_DACRATE_REG + 1);
            break;
        case SYSTEM_PAL:
            f = 49656530 / (*AudioInfo.AI_DACRATE_REG + 1);
            break;
        case SYSTEM_MPAL:
            f = 48628316 / (*AudioInfo.AI_DACRATE_REG + 1);
            break;
    }
    InitializeAudio(f);
}
示例#6
0
int main()
{
	InitializeSystem();
	SysTick_Config(HCLKFrequency()/100);
	InitializeLEDs();

	InitializeAccelerometer();
	InitializeAnglephone();

	InitializeAudio(Audio22050HzSettings);
	SetAudioVolume(0x60);

	PlayAudioWithCallback(AudioCallback, 0);

	while(1)
	{
		SetLEDs(0x5);
		Delay(100);
		SetLEDs(0xA);
		Delay(100);
	}
}
示例#7
0
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
   // m_buffer.resize(BufferSize);
    InitializeAudio();

    m_audioInput->setBufferSize(BufferSize);
    m_audioOutput->setBufferSize(BufferSize);

    printf("BufferSize = %d \n", BufferSize);

    //Audio output device
    m_output= m_audioOutput->start();
     //Audio input device
    m_input = m_audioInput->start();

    while (1==1)
    {
        double ret = ReadData();
//        if(ret > 0.04)
//            return 0;
    }
    return a.exec();
}
示例#8
0
文件: main.c 项目: z00t/n64iphone
EXPORT void CALL RomOpen()
{
    /* This function is for compatibility with Mupen64. */
    ReadConfig();
    InitializeAudio( GameFreq );
}
示例#9
0
文件: main.cpp 项目: ravencgg/GLMario
// int main(int argc, char* argv[])
int GameMain()
{
//    assert(argc || argv[0]); // Fixes the compiler complaining about unused values;

    GameState* game_state = CreateNewGameState("EnGen", 1600, 900);
    Renderer* renderer = game_state->renderer;
    game_state->active_scene = PushScene(&game_state->permanent_memory, MAX_GAME_ENTITES);

    TileMap* tilemap = game_state->active_scene->tilemap;

    for (int32 i = 0; i < 10; ++i)
    {
        Vec2 pos = { (float)i, 2.f };
        AddTileToMap(tilemap, pos);
    }

    for (int32 i = 0; i < 10; ++i)
    {
        Vec2 pos = { 0, (float)i };
        AddTileToMap(tilemap, pos);
    }

    for (int32 i = 0; i < 10; ++i)
    {
        Vec2 pos = { 10.f, (float)i };
        AddTileToMap(tilemap, pos);
    }

    UIWindow* ui = PushStruct(&game_state->permanent_memory, UIWindow);
    SetTitle(ui, "Editor UI!");

    SetSize(ui, { 0.1f, 0.3f, 0.2f, 0.2f }, 0.05f);

    UIWindow* ui2 = PushStruct(&game_state->permanent_memory, UIWindow);
    SetTitle(ui2, "Editor UI2!");

    SetSize(ui2, { 0.2f, 0.3f, 0.2f, 0.2f }, 0.05f);

    InitializeDebugConsole();

#if 0
    InitializeAudio();
    char* test_sound_file = "C:\\projects\\imperial_march.wav";
    bool test_sound_loaded = LoadWavFile(test_sound_file);
    if(test_sound_loaded)
    {
        printf("Loaded File\n");
    }
    PauseAudio(false);
#endif

    Camera default_camera = {}; // maybe put this in game_state?
    default_camera.position = vec2(0, 0);
    default_camera.viewport_size.x = 16;
    default_camera.viewport_size.y = 9;

    uint32 frame_count = 0;
    uint32 fps = 0;
    double last_fps_time = 0;

    bool running = true;

    while (running)
    {
        ProfileBeginFrame();
        ProfileBeginSection(Profile_Frame);
        ProfileBeginSection(Profile_Input);

        Platform_RunMessageLoop(game_state->input);

        Camera* draw_camera = game_state->active_camera ? game_state->active_camera : &default_camera;

        game_state->window.resolution = Platform_GetResolution();
        UpdateMouseWorldPosition(game_state->input, game_state->window.resolution, draw_camera->viewport_size, draw_camera->position);

        ProfileEndSection(Profile_Input);

        Vec2i mouse_pos = MousePosition(game_state->input);
        //DebugPrintf("Mouse World Position: (%.2f, %.2f)", mouse_pos.x, mouse_pos.y);
        DebugPrintf("Mouse World Position: (%d, %d)", mouse_pos.x, mouse_pos.y);
        DebugPrintf("Main Camera Position: (%.2f, %.2f)", default_camera.position.x, default_camera.position.y);


        DebugPrintf("Key Pressed: %s", IsDown(game_state->input, KeyCode_a) ? "TRUE" : "FALSE");

        if (OnDown(game_state->input, KeyCode_ESCAPE))
        {
            running = false;
            break;
        }

#if 0 // TODO: Platform layer
        if (OnDown(game_state->input, KeyCode_z))
        {
            ForceColorClear();
            SwapBuffer(game_state);
            //WindowSetScreenMode(&game_state->window, ScreenMode_Windowed);
        }
        else if (OnDown(game_state->input, KeyCode_c))
        {
            ForceColorClear();
            SwapBuffer(game_state);
            //WindowSetScreenMode(&game_state->window, ScreenMode_Borderless);
        }
#endif

        static bool draw_debug = true;
        if (OnDown(game_state->input, KeyCode_BACKQUOTE))
        {
            draw_debug = !draw_debug;
        }

        Renderer* debug_renderer = draw_debug ? renderer : 0;

        TimeBeginFrame(game_state);

        // Update the scene first, pushing draw calls if necessary.
        // Then call begin_frame which builds matrices and clears buffers;
        float current_time = CurrentTime(game_state);
        if (current_time - last_fps_time > 1.0f)
        {
            last_fps_time = current_time;
            fps = frame_count;
            frame_count = 0;
        }
        frame_count++;
        DebugPrintf("FPS: \t\t%d \tFrames: \t%d", fps, FrameCount(game_state));

        DebugControlCamera(game_state, &default_camera);

        // TODO(cgenova): separate update and render calls so that things can be set up when rendering begins;
        BeginFrame(renderer, &game_state->window);

        ProfileBeginSection(Profile_SceneUpdate);

        DebugPrintPushColor(vec4(1.0f, 0, 0, 1.0f));
        DebugPrintf("Active scene entity usage: (%d / %d)", game_state->active_scene->active_entities, MAX_GAME_ENTITES);
        DebugPrintPopColor();

        UpdateSceneEntities(game_state, game_state->active_scene);
        DrawSceneEntities(game_state->active_scene, renderer);

        ProfileEndSection(Profile_SceneUpdate);

#if 1 // Spaghetti test
        const size_t num_verts = 200;
        static SimpleVertex v[num_verts];
        static bool initialized = false;
        if (!initialized)
        {
            initialized = true;
            for (uint32 i = 0; i < num_verts; ++i)
            {
                SimpleVertex verts = {};
                verts.position = vec2((float)(i / 50.f) - 2.f, (float)i);
                verts.color = vec4(1, 1, 0, 1.f);
                v[i] = verts;
            }
        }
        else
        {
            for (uint32 i = 0; i < num_verts; ++i)
            {
                v[i].position.y = sin(CurrentTime(game_state) + i / (PI * 20));
            }
        }

        PrimitiveDrawParams spaghetti_params = {};
        spaghetti_params.line_draw_flags |= PrimitiveDraw_Smooth;
        //      spaghetti_params.line_draw_flags |= Draw_ScreenSpace;
        spaghetti_params.line_width = 0;
        DrawLine(renderer, v, num_verts, spaghetti_params);
#endif

        DrawTileMap(game_state, game_state->active_scene->tilemap);

        UpdateUIWindow(game_state, ui);
        UpdateUIWindow(game_state, ui2);

        RenderDrawBuffer(renderer, draw_camera);

        ProfileEndSection(Profile_Frame);
        ProfileEndFrame(debug_renderer, TARGET_FPS);
        DebugDrawConsole(debug_renderer);

        // NOTE:
        // For drawing Debug info, the profiling in this section will be discarded,
        // but it is only drawing text and the debug graph.
        RenderDrawBuffer(renderer, draw_camera);

        SwapBuffer(game_state);

        // TODO(cgenova): High granularity sleep function!

        ResetArena(&game_state->temporary_memory);

    }// End main loop

    return 1;
}
示例#10
0
void KPSdl2UserInterface::OpenWindow(int /* argc */ , char ** /* argv */)
{
    auto flags = SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE;
    SDL_version compiled;
    SDL_version linked;
    std::stringstream message;

    SDL_VERSION(&compiled);
    SDL_GetVersion(&linked);

    BLogger::Log("SDL UserInterface initialization");
    BLogger::Log("SDL linked version: ",
                 static_cast<unsigned int>(linked.major), '.',
                 static_cast<unsigned int>(linked.minor), '.',
                 static_cast<unsigned int>(linked.patch));
    BLogger::Log("SDL compiled version: ",
                 static_cast<unsigned int>(compiled.major), '.',
                 static_cast<unsigned int>(compiled.minor), '.',
                 static_cast<unsigned int>(compiled.patch));
    BLogger::Log("SDL Header version: ",
                 SDL_MAJOR_VERSION, '.', SDL_MINOR_VERSION, '.',
                 SDL_PATCHLEVEL);
    BLogger::Log("SDL Revision: ", SDL_GetRevision());
    auto pVersion = Mix_Linked_Version();
    BLogger::Log("SDL_mixer Linked version: ",
                 static_cast<unsigned int>(pVersion->major), '.',
                 static_cast<unsigned int>(pVersion->minor), '.',
                 static_cast<unsigned int>(pVersion->patch));
    BLogger::Log("SDL_mixer Header version: ",
                 MIX_MAJOR_VERSION, '.', MIX_MINOR_VERSION, '.',
                 MIX_PATCHLEVEL);

    // Set OpenGL's context to 2.1 subset functionality profile.
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);

    // Open OpenGL Window with SDL
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
    {
        message << "Error in SDL_Init: " << SDL_GetError();
        SDL_Quit();
        throw std::runtime_error(message.str());
    }

    if (config->FullScreen)
    {
        flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
    }

    if (!IsWindowResolutionSupported(config->ScreenXResolution,
                                     (config->ScreenXResolution * 3) / 4))
    {
        config->ScreenXResolution = 640;
    }

    window = SDL_CreateWindow(
                 GetWindowTitle().c_str(),
                 SDL_WINDOWPOS_UNDEFINED,
                 SDL_WINDOWPOS_UNDEFINED,
                 config->ScreenXResolution,
                 (config->ScreenXResolution * 3) / 4,
                 flags);

    if (window == nullptr)
    {
        message << "Error in SDL_CreateWindow: " << SDL_GetError();
        SDL_Quit();
        throw std::runtime_error(message.str());
    }

    // We intentionally do not use the SDL renderer. It only supports 2D
    // and on Windows would use DirectX and not the OpenGL backend.
    // Instead the OpenGL renderer is used together with ligGLEW.
    glContext = SDL_GL_CreateContext(window);

    if (glContext == nullptr)
    {
        message << "Error in SDL_GL_CreateContext: " << SDL_GetError();
        SDL_Quit();
        throw std::runtime_error(message.str());
    }

    // Do updates synchronized with VSync
    SDL_GL_SetSwapInterval(1);

    auto glewReturn = glewInit();

    if (glewReturn != GLEW_OK)
    {
        message << "Error in glewInit: " << glewGetErrorString(glewReturn);
        SDL_Quit();
        throw std::runtime_error(message.str());
    }

    BLogger::Log("GLEW version: ", glewGetString(GLEW_VERSION));

    SDL_DisplayMode mode;

    SDL_GetWindowDisplayMode(window, &mode);
    BLogger::Log("SDL pixel format: ", SDL_GetPixelFormatName(mode.format));
    BLogger::Log("SDL refresh rate: ", mode.refresh_rate, " Hz");

    DebugPrintOpenGLVersion();
    DebugPrintOpenGLContextVersion();
    InitializeAudio(config->TextureName);
    InitializeAfterOpen();
}
示例#11
0
void KPSdl12UserInterface::OpenWindow(int /* argc */ , char ** /* argv */)
{
    auto flags = SDL_OPENGL | SDL_RESIZABLE;

    BLogger::Log("SDL UserInterface initialization");
    auto pVersion = SDL_Linked_Version();
    BLogger::Log("SDL Linked version: ",
                 static_cast<unsigned int>(pVersion->major), '.',
                 static_cast<unsigned int>(pVersion->minor), '.',
                 static_cast<unsigned int>(pVersion->patch));
    BLogger::Log("SDL Header version: ",
                 SDL_MAJOR_VERSION, '.', SDL_MINOR_VERSION, '.',
                 SDL_PATCHLEVEL);
    pVersion = Mix_Linked_Version();
    BLogger::Log("SDL_mixer Linked version: ",
                 static_cast<unsigned int>(pVersion->major), '.',
                 static_cast<unsigned int>(pVersion->minor), '.',
                 static_cast<unsigned int>(pVersion->patch));
    BLogger::Log("SDL_mixer Header version: ",
                 MIX_MAJOR_VERSION, '.', MIX_MINOR_VERSION, '.',
                 MIX_PATCHLEVEL);

    // Open OpenGL Window with SDL
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE) < 0)
    {
        std::stringstream message;

        message << "Error in SDL_Init: " << SDL_GetError();
        throw std::runtime_error(message.str());
    }

    // Full-screen mode is not supported. Disable full-screen flag.
    config->FullScreen = false;

    if (!IsWindowResolutionSupported(config->ScreenXResolution,
                                     (config->ScreenXResolution * 3) / 4))
    {
        config->ScreenXResolution = 640;
    }

    screen = SDL_SetVideoMode(
                 config->ScreenXResolution,
                 (config->ScreenXResolution * 3) / 4,
                 config->ColorDepth,
                 flags);

    if (screen == nullptr)
    {
        std::stringstream message;

        message << "Error in SDL_SetVideoMode: " << SDL_GetError();
        SDL_Quit();
        throw std::runtime_error(message.str());
    }

    SDL_WM_SetCaption(GetWindowTitle().c_str(), GetWindowTitle().c_str());

    DebugPrintOpenGLVersion();
    InitializeAudio(config->TextureName);
    InitializeAfterOpen();
}
示例#12
0
文件: Main.cpp 项目: 173210/project64
EXPORT void CALL RomOpen()
{
    WriteTrace(TraceAudioInterface, TraceDebug, "Start");
    InitializeAudio(DEFAULT_FREQUENCY);
    WriteTrace(TraceAudioInterface, TraceDebug, "Done");
}
示例#13
0
static void play_mp3(char* filename) {
	unsigned int br, btr;
	FRESULT res;

	bytes_left = FILE_READ_BUFFER_SIZE;
	read_ptr = file_read_buffer;

	if (FR_OK == f_open(&file, filename, FA_OPEN_EXISTING | FA_READ)) {

		// Read ID3v2 Tag
		char szArtist[120];
		char szTitle[120];
		Mp3ReadId3V2Tag(&file, szArtist, sizeof(szArtist), szTitle, sizeof(szTitle));

		// Fill buffer
		f_read(&file, file_read_buffer, FILE_READ_BUFFER_SIZE, &br);

		// Play mp3
		hMP3Decoder = MP3InitDecoder();
		InitializeAudio(Audio44100HzSettings);
		SetAudioVolume(0xAF);
		PlayAudioWithCallback(AudioCallback, 0);

		for(;;) {
			/*
			 * If past half of buffer, refill...
			 *
			 * When bytes_left changes, the audio callback has just been executed. This
			 * means that there should be enough time to copy the end of the buffer
			 * to the beginning and update the pointer before the next audio callback.
			 * Getting audio callbacks while the next part of the file is read from the
			 * file system should not cause problems.
			 */
			if (bytes_left < (FILE_READ_BUFFER_SIZE / 2)) {
				// Copy rest of data to beginning of read buffer
				memcpy(file_read_buffer, read_ptr, bytes_left);

				// Update read pointer for audio sampling
				read_ptr = file_read_buffer;

				// Read next part of file
				btr = FILE_READ_BUFFER_SIZE - bytes_left;
				res = f_read(&file, file_read_buffer + bytes_left, btr, &br);

				// Update the bytes left variable
				bytes_left = FILE_READ_BUFFER_SIZE;

				// Out of data or error or user button... Stop playback!
				if (br < btr || res != FR_OK || BUTTON)
				  {
					StopAudio();

					// Re-initialize and set volume to avoid noise
					InitializeAudio(Audio44100HzSettings);
					SetAudioVolume(0);

					// Close currently open file
					f_close(&file);

					// Wait for user button release
					while(BUTTON){};

					// Return to previous function
					return;
				}
			}
		}
	}
}
示例#14
0
文件: main.c 项目: ahmedjafri/EE478
int main(void) {
	init();

        currentWriteBuffer = mp3_data;
        currentReadBuffer = mp3_data2;
        
        mySPI_Init();                           //Init SPI for comm with Pi
        
        //initialize SPI rx buffer counter
        rxIndex = 0;
        
        
        /* Enable the Rx buffer not empty interrupt */
        SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE);
        
        /* send initial pulse for RPi to send data*/
        GPIO_ToggleBits(GPIOD,  GPIO_Pin_11);
        //sending end of pulse
        if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_RXNE) != SET)
        {
          GPIO_ToggleBits(GPIOD,  GPIO_Pin_11);
        }
        
        //wait until data buffer loaded first time (change?)
        while (!dataRxComplete) 
        {
            dataRxComplete = dataRxComplete;
        }
        
        //rxIndex = 0;                    //reset rxIndex (do in interrupt?)
        dataRxComplete = 0;
        
        flipBuffers();
        
	hMP3Decoder = MP3InitDecoder();
                
        //Send need more data GPIO signal
        
	InitializeAudio(Audio44100HzSettings);
	SetAudioVolume(0xCF);
        PlayAudioWithCallback(AudioCallback, 0);
        
        
	while(1) { 
          
//                while(!dataRxComplete) 
//                {
//                     dataRxComplete = dataRxComplete;        
//                }
//                dataRxComplete = 0;
//                
//                //flip buffers
//                char *tempBuffer = currentReadBuffer;
//                currentReadBuffer = currentWriteBuffer;
//                currentWriteBuffer = tempBuffer;
//                
//                
//                GPIO_ToggleBits(GPIOD,  GPIO_Pin_11);
//                GPIO_ToggleBits(GPIOD,  GPIO_Pin_11);
              
	}
}
示例#15
0
static void play_mp3(char* filename) {

	bool out_of_data;
	int cc;


	// Open file
	if (FR_OK == f_open(&file, filename, FA_OPEN_EXISTING | FA_READ)) {

		// Read ID3v2 Tag
		char szArtist[120];
		char szTitle[120];
		Mp3ReadId3V2Tag(&file, szArtist, sizeof(szArtist), szTitle, sizeof(szTitle));


		///////////////////////////////////////////////////////////buffer starts getting filled for first time
		// Start Initial fill of buffer
		hMP3Decoder = MP3InitDecoder();
		for (cc = 0 ; cc < NUMBER_BUFFERS ; cc++ ) {
			out_of_data = fill_mp3_buffer(&file,cc);

			if ( out_of_data ) {
				break;
			}
		}

		// Initialize buffer counters
		buffer_read = 0;
		buffer_write = 0;

/////////////////////////////////////////////////////////////////////////////////////////
		// Play mp3
		running_player = true;
		InitializeAudio(Audio44100HzSettings);
		// InitializeAudio(Audio32000HzSettings);
		SetAudioVolume(0xAF);
		PlayAudioWithCallback(AudioCallback, 0);
//////////////////////////////////////////////////////////////////////////////////////////
		for(;;) {
			/*
			 *  If we have an unused buffer, call fill_mp3_buffer to fill it.
			 */
			if ( buffer_read != buffer_write ) {


				// Refill the MP3 buffer
				out_of_data = fill_mp3_buffer(&file,buffer_write);

				if ( !out_of_data ) {
					buffer_write = ( buffer_write + 1 ) % NUMBER_BUFFERS;
				}

				// Out of data or error or user button... Stop playback!
				if (out_of_data || (exitMp3 == 1))
				{
					StopAudio();
					running_player = false;

					// Re-initialize and set volume to avoid noise
					InitializeAudio(Audio44100HzSettings);
					SetAudioVolume(0);

					// Close currently open file
					f_close(&file);
					return;
				}


			}
			else {
				// We don't have any work to do, shut down until interrupt (DMA transfer complete)
				__asm__ volatile ("wfi");
			}
		}
	}
示例#16
0
文件: device.cpp 项目: MHesham/bsp
_Use_decl_annotations_
VOID
OnIoDeviceControl(
    WDFQUEUE    Queue,
    WDFREQUEST  Request,
    size_t      OutputBufferLength,
    size_t      InputBufferLength,
    ULONG       IoControlCode
)
/*++

Routine Description:

    This event handled device control calls.

Arguments:

    Queue - Handle of the queue object associated with the request
    Request - Handle of the request object
    OutputBufferLength - length of the request's output buffer
    InputBufferLength - length of the request's input buffer
    IoControlCode - the driver-defined or system-defined I/O control code

Return Value:

    None

--*/
{
    UNREFERENCED_PARAMETER(OutputBufferLength);
    UNREFERENCED_PARAMETER(InputBufferLength);

    WDFDEVICE device;
    PDEVICE_CONTEXT deviceContext;
    NTSTATUS status = STATUS_SUCCESS;

    device = WdfIoQueueGetDevice(Queue);
    deviceContext = GetContext(device);

    //
    // Validate the IO code and exexute on it.
    //

    switch (IoControlCode)
    {
    case IOCTL_BCM_PWM_SET_CLOCKCONFIG:
        status = ValidateAndSetClockConfig(device, Request);
        break;

    case IOCTL_BCM_PWM_GET_CLOCKCONFIG:
        status = GetClockConfig(device, Request);
        break;

    case IOCTL_BCM_PWM_SET_CHANNELCONFIG:
        status = ValidateAndSetChannelConfig(device, Request);
        break;

    case IOCTL_BCM_PWM_GET_CHANNELCONFIG:
        status = GetChannelConfig(device, Request);
        break;

    case IOCTL_BCM_PWM_SET_DUTY_REGISTER:
        status = ValidateAndSetDutyRegister(device, Request);
        break;

    case IOCTL_BCM_PWM_GET_DUTY_REGISTER:
        status = GetDutyRegister(device, Request);
        break;

    case IOCTL_BCM_PWM_START:
        status = ValidateAndStartChannel(device, Request);
        break;

    case IOCTL_BCM_PWM_STOP:
        status = ValidateAndStopChannel(device, Request);
        break;

    case IOCTL_BCM_PWM_AQUIRE_AUDIO:
        status = AquireAudio(device);
        break;

    case IOCTL_BCM_PWM_RELEASE_AUDIO:
        status = ReleaseAudio(device);
        break;

    case IOCTL_BCM_PWM_INITIALIZE_AUDIO:
        status = InitializeAudio(device, Request);
        break;

    case IOCTL_BCM_PWM_REGISTER_AUDIO_NOTIFICATION:
        status = RegisterAudioNotification(device, Request);
        break;

    case IOCTL_BCM_PWM_UNREGISTER_AUDIO_NOTIFICATION:
        status = UnregisterAudioNotification(device, Request);
        break;

    case IOCTL_BCM_PWM_START_AUDIO:
        status = StartAudio(device);
        break;

    case IOCTL_BCM_PWM_PAUSE_AUDIO:
        status = PauseAudio(device);
        break;

    case IOCTL_BCM_PWM_RESUME_AUDIO:
        status = ResumeAudio(device);
        break;

    case IOCTL_BCM_PWM_STOP_AUDIO:
        status = StopAudio(device);
        break;

    default:
        status = STATUS_INVALID_DEVICE_REQUEST;
        TraceEvents(TRACE_LEVEL_ERROR, TRACE_IOCTL, "Unexpected IO code in request. Request: 0x%08x, Code: 0x%08x", (ULONG)Request, IoControlCode);
        break;
    }

    WdfRequestComplete(Request, status);
}