kb_machblue_core_pcm.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:3k
- //*****************************************************************************
- //File Name: kb_machblue_core_pcm.c
- //
- //Description: pcm function
- //
- // used by Machblue to access the platform's pcm engine api
- //
- //Author: steven
- //
- //Date: 2006.12.29
- //
- //Version: v1.0
- //*****************************************************************************
- #include "machblue_defines.h"
- #include "machblue_customer.h"
- #include "machblue_porting_core.h"
- #include "kb_machblue_client_define.h"
- /**
- * Opens device pcm engine for playback.
- * pcm_engine < pointer to pcm engine handle to store handle
- of newly opened pcm engine >
-
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_pcm_engine_open(mb_pcm_engine_t *pcm_engine)
- {
- kb_movie_pcm_t *p_pcm_engine;
- *pcm_engine=MB_INVALID_PCM_ENGINE;
- p_pcm_engine=(kb_movie_pcm_t *)mb_malloc(sizeof(kb_movie_pcm_t)) ;
- if(p_pcm_engine==NULL)
- {
- mb_printf("n[Machblue]:PCM open error.");
- return MB_FAILURE ;
- }
-
- *pcm_engine=(mb_pcm_engine_t)p_pcm_engine;
-
- return MB_SUCCESS ;
- }
- /**
- * Closes PCM engine.
- * pcm_engine < PCM engine to close >
-
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_pcm_engine_close(mb_pcm_engine_t pcm_engine)
- {
- if(pcm_engine==MB_INVALID_PCM_ENGINE)
- {
- mb_printf("n[Machblue]:PCM close error.");
- return MB_FAILURE ;
- }
-
- mb_free((kb_movie_pcm_t *)pcm_engine) ;
- return MB_SUCCESS ;
- }
- /**
- * Sets PCM engine format.
- * pcm_engine < pcm engine to configure >
- * format < pcm format requested >
- * sample_rate < pcm sample rate requested in Hz >
- * n_channels < number of channels requested (1 for mono,2 for stereo, etc.) >
-
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_pcm_engine_format_set(mb_pcm_engine_t pcm_engine,
- mb_pcm_format_t format,unsigned long sample_rate,int n_channels)
- {
- kb_movie_pcm_t *p_pcm_engine=(kb_movie_pcm_t *)pcm_engine;
- if(p_pcm_engine==NULL)
- {
- mb_printf("n[Machblue]:PCM format set error.");
- return MB_FAILURE ;
- }
-
- p_pcm_engine->m_format = format;
- p_pcm_engine->m_sample_rate = sample_rate;
- p_pcm_engine->m_n_channels = n_channels;
-
- return MB_SUCCESS ;
- }
- /**
- * Plays a sample buffer on a PCM engine.
- * pcm_engine < pcm engine to play samples on >
- * sample_buffer < sample buffer to play >
- * n_samples < number of samples to play >
- * callback_f < callback function to invoke when playback is over >
- * cb_client_data < callback function client data >
-
- * @return MB_SUCCESS on success, MB_FAILURE on failure.
- */
- mb_error_t mb_pcm_engine_play(mb_pcm_engine_t cm_engine,const void *sample_buffer,
- int n_samples,mb_pcm_callback_f *callback_f,void *cb_client_data)
- {
- mb_printf("n[Machblue]:mb_pcm_engine_play.");
- return MB_SUCCESS ;
- }