📄 sounddb.cpp
字号:
/*****************************************************************************
******************************************************************************
** **
** Copyright (c) 2005-2006 Videon Central, Inc. **
** All rights reserved. **
** **
** The computer program contained herein contains proprietary information **
** which is the property of Videon Central, Inc. The program may be used **
** and/or copied only with the written permission of Videon Central, Inc. **
** or in accordance with the terms and conditions stipulated in the **
** agreement/contract under which the programs have been supplied. **
** **
******************************************************************************
*****************************************************************************/
/**
* @file sounddb.cpp
*
* $Id: sounddb.cpp,v 1.8 2006/10/30 20:45:24 ccoble Exp $
*/
#include "vdvd_types.h"
#include "loader_app.h"
#include "sounddb.h"
#include "osapi.h"
#include "utility.h"
#include "dbgprint.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* Debug macros */
#define DBG_SOUNDDB DBG_ERROR
#define DBG_ON(x) (DBG_SOUNDDB >= x)
#ifndef SOUNDDB_ENDIAN_FIX
#define SOUNDDB_ENDIAN_FIX 1
#endif
/**
* Local handle
*/
typedef struct tagSOUND_DB_HANDLE
{
LOADER_HANDLE hLoader;
SOUNDDB tSounddb;
} SOUND_DB_HANDLE;
/**
* Local variables
*/
static SOUND_DB_HANDLE *hSDB = NULL;
/**
* SOUNDDBCreate -- Create the Sound Database
*
* @param
* tLoader -- handle to the loader.
*
* @retval
* SOUNDDB_STATUS
*/
SOUNDDB_STATUS SOUNDDBCreate(LOADER_HANDLE tLoader)
{
SOUNDDB_STATUS tStatus;
/* validate parameter */
if (tLoader == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Null pointer!\n", __FUNCTION__));
return (SOUNDDB_NULL_PTR);
}
/* If database is already created, return a failure */
if (hSDB != NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Database already created!\n", __FUNCTION__));
tStatus = SOUNDDB_FAILURE;
}
else
{
/* Allocate local handle */
hSDB = (SOUND_DB_HANDLE *)OS_MemAlloc(sizeof(SOUND_DB_HANDLE) );
if (hSDB == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Error allocating local handle!\n", __FUNCTION__));
tStatus = SOUNDDB_FAILURE;
}
else
{
/* Keep loader handle */
hSDB->hLoader = tLoader;
/* initialize pointers */
hSDB->tSounddb.SoundIndex.sound_attributes = NULL;
hSDB->tSounddb.SoundIndex.sound_location = NULL;
hSDB->tSounddb.SoundData = NULL;
tStatus = SOUNDDB_SUCCESS;
}
}
return (tStatus);
}
/**
* ClpInfoDelete -- Delete the clip info database
*
* @param
* none
*
* @retval
* MPLS_STATUS
*/
SOUNDDB_STATUS SOUNDDBDelete(void)
{
SOUNDDB_STATUS tStatus;
/* If database has not been created, return a failure */
if (hSDB == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Database doesn't exist!\n", __FUNCTION__));
tStatus = SOUNDDB_FAILURE;
}
else
{
/* free allocated db space */
if (hSDB->tSounddb.SoundIndex.sound_attributes != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundIndex.sound_attributes);
hSDB->tSounddb.SoundIndex.sound_attributes = NULL;
}
if (hSDB->tSounddb.SoundIndex.sound_location != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundIndex.sound_location);
hSDB->tSounddb.SoundIndex.sound_location = NULL;
}
if (hSDB->tSounddb.SoundData != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundData);
hSDB->tSounddb.SoundData = NULL;
}
/* free local handle */
if (hSDB != NULL)
{
OS_MemFree(hSDB);
hSDB = NULL;
}
tStatus = SOUNDDB_SUCCESS;
}
return (tStatus);
}
/**
* SOUNDDBLoad -- Load the sound data from BDROM disc into the database.
*
* @param
*
* @retval
* SOUNDDB_STATUS
*/
SOUNDDB_STATUS SOUNDDBLoad(void)
{
LOADER_FILE_HANDLE sound_file;
SOUNDDB_STATUS tStatus = SOUNDDB_SUCCESS;
UBYTE pTmpBuf[16];
ULONG i;
ULONG sounddatalength;
if (hSDB == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Database doesn't exist!\n", __FUNCTION__));
tStatus = SOUNDDB_FAILURE;
goto errout_1;
}
/* Clear db in case previsouly loaded disc still not cleared */
hSDB->tSounddb.SoundIndex.number_of_sound_entries = 0;
if (hSDB->tSounddb.SoundIndex.sound_attributes != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundIndex.sound_attributes);
hSDB->tSounddb.SoundIndex.sound_attributes = NULL;
}
if (hSDB->tSounddb.SoundIndex.sound_location != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundIndex.sound_location);
hSDB->tSounddb.SoundIndex.sound_location = NULL;
}
if (hSDB->tSounddb.SoundData != NULL)
{
OS_MemFree(hSDB->tSounddb.SoundData);
hSDB->tSounddb.SoundData = NULL;
}
/* Open the movie playlist */
if (LoaderFileOpen(hSDB->hLoader, "/mnt/cdrom/BDMV/AUXDATA/sound.bdmv", &sound_file) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Could not open file!\n", __FUNCTION__));
tStatus = SOUNDDB_FAILURE;
goto errout_1;
}
/* Read up to the reserved field */
if (LoaderFileRead(hSDB->hLoader, sound_file, (PVOID)pTmpBuf, 16, NULL) != LOADER_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Failed to read type indicator!\n", __FUNCTION__));
tStatus = SOUNDDB_FILE_ERROR;
goto errout_2;
}
/* store the type indicator */
hSDB->tSounddb.type_indicator[0] = pTmpBuf[0];
hSDB->tSounddb.type_indicator[1] = pTmpBuf[1];
hSDB->tSounddb.type_indicator[2] = pTmpBuf[2];
hSDB->tSounddb.type_indicator[3] = pTmpBuf[3];
/* Check that type indicator is valid */
if ( (pTmpBuf[0] != 'B') || (pTmpBuf[1] != 'C') || (pTmpBuf[2] != 'L') || (pTmpBuf[3] != 'K') )
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Invalid type indicator!\n", __FUNCTION__));
tStatus = SOUNDDB_INVALID_FORMAT;
goto errout_2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -