/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2026-present Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** USBX Component                                                        */
/**                                                                       */
/**   Audio Class                                                         */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/* Include necessary system files.  */

#define UX_SOURCE_CODE

#include "ux_api.h"
#include "ux_host_class_audio.h"
#include "ux_host_stack.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _ux_host_class_audio_interrupt_notification         PORTABLE C      */
/*                                                           6.1.12       */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function receives a completion callback on a interrupt         */
/*    transfer request.                                                   */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    transfer_request                      Pointer to transfer request   */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    None                                                                */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    (ux_host_class_audio_interrupt_callback)                            */
/*                                          App notification callback     */
/*    _ux_host_stack_transfer_request       Issue the transfer request    */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    HCD                                                                 */
/*                                                                        */
/**************************************************************************/
VOID  _ux_host_class_audio_interrupt_notification(UX_TRANSFER *transfer_request)
{

UX_HOST_CLASS_AUDIO_AC *ac;

    /* Check status.  */
    if (transfer_request -> ux_transfer_request_completion_code != UX_SUCCESS)
        return;

    /* Get AC instance.  */
    ac = (UX_HOST_CLASS_AUDIO_AC *)transfer_request -> ux_transfer_request_class_instance;

    /* Invoke application callback.  */
    if (ac -> ux_host_class_audio_interrupt_callback)
    {
        ac -> ux_host_class_audio_interrupt_callback(ac,
                        transfer_request -> ux_transfer_request_data_pointer,
                        transfer_request -> ux_transfer_request_actual_length,
                        ac -> ux_host_class_audio_interrupt_callback_arg);
    }

    /* Issue another request again.  */
    _ux_host_stack_transfer_request(transfer_request);
}
